diff --git a/docs/app/js/sanddance-app.js b/docs/app/js/sanddance-app.js index 3fd4d4433..3f71492d8 100644 --- a/docs/app/js/sanddance-app.js +++ b/docs/app/js/sanddance-app.js @@ -73,7 +73,7 @@ localRequire, module, module.exports, - this + globalObject ); } @@ -142,7 +142,7 @@ this[globalName] = mainExports; } } -})({"fV4j0":[function(require,module,exports) { +})({"bxQeC":[function(require,module,exports,__globalThis) { // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. var _base = require("./base"); @@ -153,21 +153,21 @@ var _react = require("react"); var _reactDom = require("react-dom"); var _vega = require("vega"); (0, _base.use)((0, _fluentUIComponents.fluentUI), _vega); -const staticContent = Array.from(document.querySelectorAll("a.sanddance-app-static-content")); +const staticContent = Array.from(document.querySelectorAll('a.sanddance-app-static-content')); const dataSets = staticContent.filter((f)=>f.id).map((n)=>{ - const forData = staticContent.filter((f)=>f.dataset["for"] === n.id)[0]; + const forData = staticContent.filter((f)=>f.dataset['for'] === n.id)[0]; return { - dataSourceType: "sample", + dataSourceType: 'sample', id: n.id, - displayName: n.dataset["displayName"], + displayName: n.dataset['displayName'], dataUrl: n.href, - type: n.dataset["type"], + type: n.dataset['type'], snapshotsUrl: forData ? forData.href : null }; }); let explorer; const undef = "undefined"; -_reactDom.render(/*#__PURE__*/ _react.createElement((0, _sanddanceApp.SandDanceApp), { +_reactDom.render(_react.createElement((0, _sanddanceApp.SandDanceApp), { setTheme: typeof setTheme !== undef && setTheme, darkTheme: typeof darkTheme !== undef && darkTheme, insights: typeof insights !== undef && insights, @@ -177,9 +177,9 @@ _reactDom.render(/*#__PURE__*/ _react.createElement((0, _sanddanceApp.SandDanceA mounted: (app)=>{ explorer = app.explorer; } -}), document.getElementById("app")); -const z = "z".charCodeAt(0); -const Z = "Z".charCodeAt(0); +}), document.getElementById('app')); +const z = 'z'.charCodeAt(0); +const Z = 'Z'.charCodeAt(0); document.onkeyup = (e)=>{ //look for CTRL Z or CTRL SHIFT Z if (e.ctrlKey && (e.keyCode === z || e.keyCode === Z)) { @@ -187,12 +187,12 @@ document.onkeyup = (e)=>{ else explorer.undo(); } }; -window["SandDanceApp"] = { +window['SandDanceApp'] = { explorer, SandDanceExplorer: _sanddanceExplorer }; -},{"./base":"6wvRv","./fluentUIComponents":"jSYVB","./sanddanceApp":"42eQi","@msrvida/sanddance-explorer":"i4GWD","react":"8ePka","react-dom":"j73oT","vega":"1ublu"}],"6wvRv":[function(require,module,exports) { +},{"./base":"4CyyC","./fluentUIComponents":"dtgCh","./sanddanceApp":"7pzEo","@msrvida/sanddance-explorer":"cEojs","react":"jGrId","react-dom":"1a3X3","vega":"75mIL"}],"4CyyC":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "base", ()=>base); @@ -215,10 +215,12 @@ function use(fluentUI, vega) { base.fluentUI = fluentUI; } -},{"@msrvida/sanddance-explorer":"i4GWD","react":"8ePka","react-dom":"j73oT","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i4GWD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/sanddance-explorer":"cEojs","react":"jGrId","react-dom":"1a3X3","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cEojs":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "controls", ()=>_controls); parcelHelpers.export(exports, "getEmbedHTML", ()=>(0, _dataExporter.getEmbedHTML)); parcelHelpers.export(exports, "SideTabId", ()=>(0, _interfaces.SideTabId)); parcelHelpers.export(exports, "use", ()=>(0, _base.use)); @@ -227,13 +229,10 @@ parcelHelpers.export(exports, "getColorSettingsFromThemePalette", ()=>(0, _theme parcelHelpers.export(exports, "themePalettes", ()=>(0, _themes.themePalettes)); parcelHelpers.export(exports, "SandDance", ()=>(0, _sanddanceReact.SandDance)); parcelHelpers.export(exports, "util", ()=>(0, _sanddanceReact.util)); -parcelHelpers.export(exports, "SandDanceReact", ()=>_sanddanceReact); parcelHelpers.export(exports, "version", ()=>(0, _version.version)); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _controls = require("./controls"); -var _sanddanceReact = require("@msrvida/sanddance-react"); +parcelHelpers.export(exports, "controls", ()=>_controls); +parcelHelpers.export(exports, "SandDanceReact", ()=>_sanddanceReact); +var _controls = require("./controls"); var _dataExporter = require("./controls/dataExporter"); var _interfaces = require("./interfaces"); var _base = require("./base"); @@ -241,25 +240,26 @@ var _canvas = require("./canvas"); var _themes = require("./themes"); var _explorer = require("./explorer"); parcelHelpers.exportAll(_explorer, exports); +var _sanddanceReact = require("@msrvida/sanddance-react"); var _version = require("./version"); -},{"./controls":"lnSIe","@msrvida/sanddance-react":"73dPQ","./controls/dataExporter":"789YP","./interfaces":"8LHoz","./base":"9M4eu","./canvas":"7FRqY","./themes":"CJpaJ","./explorer":"6D4Qi","./version":"7rYwz","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lnSIe":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./controls":"j1PTB","./controls/dataExporter":"7XSio","./interfaces":"k3BwW","./base":"3TPz5","./canvas":"55nq5","./themes":"g7FJh","./explorer":"cQRoj","@msrvida/sanddance-react":"lPyTZ","./version":"CFT5Q","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"j1PTB":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _dialog = require("./dialog"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +var _dialog = require("./dialog"); parcelHelpers.exportAll(_dialog, exports); -},{"./dialog":"ep4zG","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ep4zG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Dialog", ()=>Dialog); +},{"./dialog":"OQi9w","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"OQi9w":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Dialog", ()=>Dialog); +var _base = require("../base"); var _language = require("../language"); function Dialog(props) { return (0, _base.base).react.createElement((0, _base.base).fluentUI.Dialog, Object.assign({}, props, { @@ -273,15 +273,18 @@ function Dialog(props) { } }, props.children), (0, _base.base).react.createElement((0, _base.base).fluentUI.DialogFooter, null, props.buttons, (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { iconProps: { - iconName: "Cancel" + iconName: 'Cancel' }, onClick: props.onDismiss, text: (0, _language.strings).buttonClose }))); } -},{"../base":"9M4eu","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9M4eu":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"3TPz5","../language":"67xOI","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3TPz5":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "base", ()=>base); /** @@ -293,10 +296,7 @@ parcelHelpers.export(exports, "base", ()=>base); * @param layers @deck.gl/layers library. * @param luma @luma.gl/core library. */ parcelHelpers.export(exports, "use", ()=>use); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _backgroundImageEditor = require("./dialogs/backgroundImageEditor"); +var _backgroundImageEditor = require("./dialogs/backgroundImageEditor"); var _clickableTextLayer = require("./clickableTextLayer"); var _columnTypeChanger = require("./controls/columnTypeChanger"); var _dataExporter = require("./controls/dataExporter"); @@ -334,15 +334,15 @@ function use(fluentUI, react, reactDOM, vega) { (0, _transition.TransitionEditor).prototype = react.Component.prototype; } -},{"./dialogs/backgroundImageEditor":"02TgK","./clickableTextLayer":"9L5VX","./controls/columnTypeChanger":"86e3b","./controls/dataExporter":"789YP","./dialogs/chart":"9MRcr","./dialogs/search":"dda71","./dialogs/settings":"1PLto","./dialogs/snapshotEditor":"2kESg","./dialogs/snapshots":"k9WKc","./dialogs/transition":"2vaDJ","./explorer":"6D4Qi","@msrvida/sanddance-react":"73dPQ","./controls/renderer":"2N3JL","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"02TgK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "BackgroundImageEditor", ()=>BackgroundImageEditor); -parcelHelpers.export(exports, "setInsightBackgroundImage", ()=>setInsightBackgroundImage); +},{"./dialogs/backgroundImageEditor":"hTdbK","./clickableTextLayer":"2iqEH","./controls/columnTypeChanger":"7dBYz","./controls/dataExporter":"7XSio","./dialogs/chart":"dwBpS","./dialogs/search":"eXzPo","./dialogs/settings":"2xbhO","./dialogs/snapshotEditor":"g29jp","./dialogs/snapshots":"sTI5I","./dialogs/transition":"3tDGl","./explorer":"cQRoj","@msrvida/sanddance-react":"lPyTZ","./controls/renderer":"4tj9B","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hTdbK":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "BackgroundImageEditor", ()=>BackgroundImageEditor); +parcelHelpers.export(exports, "setInsightBackgroundImage", ()=>setInsightBackgroundImage); +var _base = require("../base"); var _dialog = require("../controls/dialog"); var _sanddanceReact = require("@msrvida/sanddance-react"); var _language = require("../language"); @@ -358,7 +358,7 @@ function _BackgroundImageEditor(_props) { }; } show(insightColumns) { - const { explorer , quantitativeColumns } = this.props; + const { explorer, quantitativeColumns } = this.props; if (!quantitativeColumns.length) //TODO show error return; const xCol = quantitativeColumns.filter((c)=>c.name === insightColumns.x)[0]; @@ -374,8 +374,8 @@ function _BackgroundImageEditor(_props) { this.checkReady(); } render() { - const { props , state } = this; - const { explorer } = props; + const { props, state } = this; + const { explorer } = props; return (0, _base.base).react.createElement((0, _dialog.Dialog), { hidden: state.hidden, onDismiss: ()=>this.setState({ @@ -383,7 +383,7 @@ function _BackgroundImageEditor(_props) { backgroundImageFileFormatError: null }), modalProps: { - containerClassName: "sanddance-background-image-dialog" + containerClassName: 'sanddance-background-image-dialog' }, dialogContentProps: { type: (0, _base.base).fluentUI.DialogType.normal, @@ -392,23 +392,23 @@ function _BackgroundImageEditor(_props) { }, buttons: [ (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - key: "apply", + key: 'apply', iconProps: { - iconName: "Photo2Add" + iconName: 'Photo2Add' }, text: (0, _language.strings).buttonApply, onClick: ()=>this.applyImage(true), disabled: !state.readyToApply - }), + }) ] }, explorer.imageHolder.img ? (0, _base.base).react.createElement("div", { - className: "thumbnail" + className: 'thumbnail' }, (0, _base.base).react.createElement("img", { src: explorer.imageHolder.img.src }), (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - key: "remove", + key: 'remove', iconProps: { - iconName: "Photo2Remove" + iconName: 'Photo2Remove' }, text: (0, _language.strings).buttonRemove, onClick: ()=>{ @@ -419,21 +419,21 @@ function _BackgroundImageEditor(_props) { }); } })) : (0, _base.base).react.createElement("div", { - className: "thumbnail" + className: 'thumbnail' }, (0, _base.base).react.createElement("input", { type: "file", onChange: (e)=>this.readBackgroundImage(e) }), state.backgroundImageFileFormatError && (0, _base.base).react.createElement("div", { className: "error" - }, state.backgroundImageFileFormatError)), this.inputForColumn(state.xCol, "X axis", "x", (0, _language.strings).labelBackgroundLeft, (0, _language.strings).labelBackgroundRight), this.inputForColumn(state.yCol, "Y axis", "y", (0, _language.strings).labelBackgroundBottom, (0, _language.strings).labelBackgroundTop)); + }, state.backgroundImageFileFormatError)), this.inputForColumn(state.xCol, 'X axis', 'x', (0, _language.strings).labelBackgroundLeft, (0, _language.strings).labelBackgroundRight), this.inputForColumn(state.yCol, 'Y axis', 'y', (0, _language.strings).labelBackgroundBottom, (0, _language.strings).labelBackgroundTop)); } inputForColumn(column, label, dimension, minLabel, maxLabel) { - const { props , state } = this; + const { props, state } = this; const fieldInput = (label, dataExtent, getDefault)=>{ const bounds = state.backgroundImageColumnBounds.filter((b)=>b.columnName === (column === null || column === void 0 ? void 0 : column.name) && b.dimension === dimension && b.dataExtent === dataExtent)[0]; if (!bounds) return null; return (0, _base.base).react.createElement("div", { - className: "axis-bound-field" + className: 'axis-bound-field' }, (0, _base.base).react.createElement((0, _base.base).fluentUI.TextField, { label: label, onChange: (e, value)=>{ @@ -452,9 +452,9 @@ function _BackgroundImageEditor(_props) { errorMessage: bounds.valid ? null : (0, _language.strings).errorNumericValue, onRenderSuffix: (a)=>{ return (0, _base.base).react.createElement((0, _iconButton.IconButton), { - iconName: "ScaleVolume", + iconName: 'ScaleVolume', themePalette: props.themePalette, - title: "Use data extent" //TODO + title: 'Use data extent' //TODO , onClick: ()=>{ bounds.numericValue = getDefault(); @@ -472,7 +472,7 @@ function _BackgroundImageEditor(_props) { })); }; return (0, _base.base).react.createElement("div", { - className: "axis-bounds" + className: 'axis-bounds' }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Dropdown, { label: label, options: props.quantitativeColumns.map((c)=>{ @@ -488,10 +488,10 @@ function _BackgroundImageEditor(_props) { }; const newColumn = props.quantitativeColumns.filter((c)=>c.name === o.key)[0]; switch(dimension){ - case "x": + case 'x': newState.xCol = newColumn; break; - case "y": + case 'y': newState.yCol = newColumn; break; } @@ -500,8 +500,8 @@ function _BackgroundImageEditor(_props) { }, selectedKey: column === null || column === void 0 ? void 0 : column.name }), (0, _base.base).react.createElement("div", { - className: "axis-bound-fields" - }, fieldInput(minLabel, "min", ()=>column.stats.min), fieldInput(maxLabel, "max", ()=>column.stats.max))); + className: 'axis-bound-fields' + }, fieldInput(minLabel, 'min', ()=>column.stats.min), fieldInput(maxLabel, 'max', ()=>column.stats.max))); } readBackgroundImage(e) { if (e.target.files) { @@ -516,7 +516,7 @@ function _BackgroundImageEditor(_props) { }; img.onload = ()=>{ //success - const { src , height , width } = img; + const { src, height, width } = img; this.props.explorer.imageHolder.img = { src, height, @@ -538,17 +538,17 @@ function _BackgroundImageEditor(_props) { checkReady() { //allow state to resolve setTimeout(()=>{ - const { state , props } = this; - const { explorer } = props; - const { backgroundImageColumnBounds } = state; + const { state, props } = this; + const { explorer } = props; + const { backgroundImageColumnBounds } = state; let valid = true; const dimensions = [ - "x", - "y" + 'x', + 'y' ]; const dataExtents = [ - "max", - "min" + 'max', + 'min' ]; [ state.xCol, @@ -564,19 +564,19 @@ function _BackgroundImageEditor(_props) { }, 0); } applyImage(showBackgroundImage) { - const { props , state } = this; - const { explorer } = props; + const { props, state } = this; + const { explorer } = props; explorer.imageHolder.showBackgroundImage = showBackgroundImage; explorer.imageHolder.backgroundImageColumnBounds = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(state.backgroundImageColumnBounds); if (showBackgroundImage) switch(props.chart){ - case "density": - case "scatterplot": - case "stacks": + case 'density': + case 'scatterplot': + case 'stacks': break; default: //TODO use xcol & ycol //make sure x & y are numeric - explorer.changeChartType("scatterplot"); + explorer.changeChartType('scatterplot'); return; } explorer.forceUpdate(); @@ -587,9 +587,9 @@ function _BackgroundImageEditor(_props) { const BackgroundImageEditor = _BackgroundImageEditor; function setInsightBackgroundImage(insight, imageHolder, columns) { if (!imageHolder.showBackgroundImage || !columns.x || !columns.y) return; - const { backgroundImageColumnBounds } = imageHolder; - const xBounds = backgroundImageColumnBounds.filter((b)=>b.columnName === columns.x && b.dimension === "x"); - const yBounds = backgroundImageColumnBounds.filter((b)=>b.columnName === columns.y && b.dimension === "y"); + const { backgroundImageColumnBounds } = imageHolder; + const xBounds = backgroundImageColumnBounds.filter((b)=>b.columnName === columns.x && b.dimension === 'x'); + const yBounds = backgroundImageColumnBounds.filter((b)=>b.columnName === columns.y && b.dimension === 'y'); if (!xBounds.length || !yBounds.length) return; const allBounds = [ ...xBounds, @@ -598,20 +598,20 @@ function setInsightBackgroundImage(insight, imageHolder, columns) { for(let i = 0; i < allBounds.length; i++){ if (!allBounds[i].valid) return; } - const bottom = yBounds.filter((b)=>b.dataExtent === "min")[0]; - const left = xBounds.filter((b)=>b.dataExtent === "min")[0]; - const right = xBounds.filter((b)=>b.dataExtent === "max")[0]; - const top = yBounds.filter((b)=>b.dataExtent === "max")[0]; + const bottom = yBounds.filter((b)=>b.dataExtent === 'min')[0]; + const left = xBounds.filter((b)=>b.dataExtent === 'min')[0]; + const right = xBounds.filter((b)=>b.dataExtent === 'max')[0]; + const top = yBounds.filter((b)=>b.dataExtent === 'max')[0]; const all = [ bottom, left, right, top ]; - for(let i1 = 0; i1 < all.length; i1++){ - if (!all[i1]) return; + for(let i = 0; i < all.length; i++){ + if (!all[i]) return; } - const { src , height , width } = imageHolder.img; + const { src, height, width } = imageHolder.img; insight.backgroundImage = { url: src, size: { @@ -628,26 +628,30 @@ function setInsightBackgroundImage(insight, imageHolder, columns) { insight.size = insight.backgroundImage.size; } -},{"../base":"9M4eu","../controls/dialog":"ep4zG","@msrvida/sanddance-react":"73dPQ","../language":"kzoCJ","../controls/iconButton":"6gzbB","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"73dPQ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"3TPz5","../controls/dialog":"OQi9w","@msrvida/sanddance-react":"lPyTZ","../language":"67xOI","../controls/iconButton":"6pZiK","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lPyTZ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SandDance", ()=>_sanddance); -parcelHelpers.export(exports, "util", ()=>_util); parcelHelpers.export(exports, "Viewer", ()=>(0, _viewer.Viewer)); parcelHelpers.export(exports, "use", ()=>(0, _base.use)); parcelHelpers.export(exports, "version", ()=>(0, _version.version)); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddance = require("@msrvida/sanddance"); +parcelHelpers.export(exports, "SandDance", ()=>_sanddance); +parcelHelpers.export(exports, "util", ()=>_util); +var _sanddance = require("@msrvida/sanddance"); var _util = require("./util"); var _viewer = require("./viewer"); var _base = require("./base"); var _version = require("./version"); -},{"@msrvida/sanddance":"cN6Hq","./util":"drIds","./viewer":"lbyGU","./base":"jKLdn","./version":"dImTG","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cN6Hq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/sanddance":"ganM8","./util":"71zHd","./viewer":"2yfj3","./base":"e2btd","./version":"g42QN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ganM8":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "version", ()=>(0, _version.version)); parcelHelpers.export(exports, "colorSchemes", ()=>(0, _colorSchemes.colorSchemes)); parcelHelpers.export(exports, "constants", ()=>_constants); parcelHelpers.export(exports, "searchExpression", ()=>_searchExpression); @@ -657,11 +661,7 @@ parcelHelpers.export(exports, "use", ()=>use); parcelHelpers.export(exports, "util", ()=>_util); parcelHelpers.export(exports, "VegaMorphCharts", ()=>_vegaMorphcharts); parcelHelpers.export(exports, "Viewer", ()=>(0, _viewer.Viewer)); -parcelHelpers.export(exports, "version", ()=>(0, _version.version)); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("./constants"); +var _constants = require("./constants"); var _searchExpression = require("@msrvida/search-expression"); var _sanddanceSpecs = require("@msrvida/sanddance-specs"); var _types = require("./types"); @@ -672,27 +672,27 @@ var _viewer = require("./viewer"); var _version = require("./version"); const use = (0, _vegaMorphcharts.use); -},{"./constants":"ghoOR","@msrvida/search-expression":"j6CcD","@msrvida/sanddance-specs":"4hjOh","./types":"gjMTK","./util":"3kvmX","@msrvida/vega-morphcharts":"guKLg","./colorSchemes":"5MHBA","./viewer":"hhZNh","./version":"2xUqU","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ghoOR":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./constants":"ix2qh","@msrvida/search-expression":"4F93b","@msrvida/sanddance-specs":"aOvSr","./types":"bD3z1","./util":"g08sL","@msrvida/vega-morphcharts":"9Sd5M","./colorSchemes":"iDNR0","./viewer":"9IMa3","./version":"7m9yM","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ix2qh":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "ColorScaleNone", ()=>(0, _sanddanceSpecs.ColorScaleNone)); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ColorScaleNone", ()=>(0, _sanddanceSpecs.ColorScaleNone)); parcelHelpers.export(exports, "FieldNames", ()=>(0, _sanddanceSpecs.FieldNames)); parcelHelpers.export(exports, "ScaleNames", ()=>(0, _sanddanceSpecs.ScaleNames)); parcelHelpers.export(exports, "SignalNames", ()=>(0, _sanddanceSpecs.SignalNames)); parcelHelpers.export(exports, "GL_ORDINAL", ()=>GL_ORDINAL); var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -const GL_ORDINAL = "GL_ORDINAL"; +const GL_ORDINAL = 'GL_ORDINAL'; -},{"@msrvida/sanddance-specs":"4hjOh","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4hjOh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@msrvida/sanddance-specs":"aOvSr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aOvSr":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _build = require("./build"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +var _build = require("./build"); parcelHelpers.exportAll(_build, exports); var _constants = require("./constants"); parcelHelpers.exportAll(_constants, exports); @@ -703,18 +703,18 @@ parcelHelpers.exportAll(_interfaces, exports); var _types = require("./types"); parcelHelpers.exportAll(_types, exports); -},{"./build":"eOeli","./constants":"6pnJw","./inference":"ckVYZ","./interfaces":"fHczm","./types":"aLUrZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eOeli":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "build", ()=>build); +},{"./build":"dNBKI","./constants":"22TRA","./inference":"aEiKQ","./interfaces":"d6Ht8","./types":"1NHSP","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dNBKI":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _charts = require("./charts"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "build", ()=>build); +var _charts = require("./charts"); var _inference = require("./inference"); var _specBuilder = require("./specBuilder"); function build(specContext, currData) { - const { specColumns } = specContext; + const { specColumns } = specContext; const columns = [ specColumns.color, specColumns.facet, @@ -724,7 +724,7 @@ function build(specContext, currData) { specColumns.sort, specColumns.x, specColumns.y, - specColumns.z, + specColumns.z ]; (0, _inference.inferAll)(columns, currData); const specBuilderProps = (0, _charts.getSpecBuilderPropsForChart)(specContext); @@ -762,14 +762,14 @@ function build(specContext, currData) { return specResult; } -},{"./charts":"j53dH","./inference":"ckVYZ","./specBuilder":"a5Xh1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"j53dH":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getSpecBuilderPropsForChart", ()=>getSpecBuilderPropsForChart); +},{"./charts":"gjBpZ","./inference":"aEiKQ","./specBuilder":"h5flx","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gjBpZ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _barchartH = require("./barchartH"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getSpecBuilderPropsForChart", ()=>getSpecBuilderPropsForChart); +var _barchartH = require("./barchartH"); var _barchartHDefault = parcelHelpers.interopDefault(_barchartH); var _barchartV = require("./barchartV"); var _barchartVDefault = parcelHelpers.interopDefault(_barchartV); @@ -800,7 +800,7 @@ const map = { treemap: (0, _treemapDefault.default) }; function getSpecBuilderPropsForChart(specContext) { - const { insight , specColumns , specViewOptions } = specContext; + const { insight, specColumns, specViewOptions } = specContext; const fn = map[insight.chart]; if (fn) { const props = fn(specContext); @@ -819,7 +819,7 @@ function getSpecBuilderPropsForChart(specContext) { maxbinsSignalDisplayName: specViewOptions.language.FacetVMaxBins, maxbinsSignalName: (0, _constants.SignalNames).FacetVBins }; - const { facetLayout , layoutPair } = (0, _facetLayout.getFacetLayout)(insight.facetStyle, discreteFacetColumn, discreteFacetVColumn, specViewOptions.colors.axisText); + const { facetLayout, layoutPair } = (0, _facetLayout.getFacetLayout)(insight.facetStyle, discreteFacetColumn, discreteFacetVColumn, specViewOptions.colors.axisText); props.layouts.unshift(layoutPair); props.facetLayout = facetLayout; props.collapseFacetAxes = specViewOptions.collapseFacetAxes; @@ -828,218 +828,221 @@ function getSpecBuilderPropsForChart(specContext) { } } -},{"./barchartH":"3HFo7","./barchartV":"9v0R3","./density":"aEqxi","./grid":"guiV8","./scatterplot":"jimHY","./stacks":"fm6Eo","./strips":"peNnJ","./treemap":"6mOC0","../facetLayout":"h5A6O","../constants":"6pnJw","../defaults":"dX5m9","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3HFo7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./barchartH":"36QjZ","./barchartV":"6xzC3","./density":"3nLmY","./grid":"8jSVp","./scatterplot":"cktKX","./stacks":"7r3BC","./strips":"8tBSJ","./treemap":"3rGzu","../facetLayout":"5wBmI","../constants":"22TRA","../defaults":"jpVjH","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"36QjZ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("../constants"); -var _defaults = require("../defaults"); -var _size = require("../size"); -exports.default = function(specContext) { - var _a, _b, _c, _d; - const { insight , specColumns , specViewOptions } = specContext; - const { language } = specViewOptions; - const showAxes = !insight.hideAxes; - const bandProps = { - orientation: "horizontal", - groupby: { - column: specColumns.y, - defaultBins: (0, _defaults.defaultBins), - maxbinsSignalName: (0, _constants.SignalNames).YBins, - maxbinsSignalDisplayName: specContext.specViewOptions.language.YMaxBins, - maxbins: (0, _defaults.maxbins) - }, - minBandWidth: (0, _defaults.minBarBandWidth), - showAxes - }; - const x = { - title: null - }; - const axisScales = { - x, - y: { - title: (_a = specColumns.y) === null || _a === void 0 ? void 0 : _a.name - }, - z: { - title: (_b = specColumns.z) === null || _b === void 0 ? void 0 : _b.name - } - }; - const layouts = [ - { - layoutType: "Band", - props: bandProps - } - ]; - const { totalStyle , view } = insight; - if (totalStyle === "sum-strip-percent") { - x.aggregate = "percent"; - x.title = language.percent; - const stripProps = { - addPercentageScale: true, - sortOrder: "ascending", - orientation: "horizontal", - size: specColumns.size, - sort: specColumns.sort, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Strip", - props: stripProps - }); - } else { - const aggProps = { - niceScale: true, - dock: "left", - globalAggregateMaxExtentSignal: "aggMaxExtent", - globalAggregateMaxExtentScaledSignal: "aggMaxExtentScaled", - sumBy: specColumns.size, +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a, _b, _c, _d; + const { insight, specColumns, specViewOptions } = specContext; + const { language } = specViewOptions; + const showAxes = !insight.hideAxes; + const bandProps = { + orientation: 'horizontal', + groupby: { + column: specColumns.y, + defaultBins: (0, _defaults.defaultBins), + maxbinsSignalName: (0, _constants.SignalNames).YBins, + maxbinsSignalDisplayName: specContext.specViewOptions.language.YMaxBins, + maxbins: (0, _defaults.maxbins) + }, + minBandWidth: (0, _defaults.minBarBandWidth), showAxes }; - layouts.push({ - layoutType: "AggregateContainer", - props: aggProps - }); - switch(totalStyle){ - case "sum-treemap": - { - x.aggregate = "sum"; - x.title = language.sum; - const treemapProps = { - corner: "top-left", - size: specColumns.size, - treeMapMethod: specViewOptions.language.treeMapMethod, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Treemap", - props: treemapProps - }); - break; - } - case "sum-strip": - { - x.aggregate = "sum"; - x.title = language.sum; - const stripProps1 = { - sortOrder: "ascending", - orientation: "horizontal", - size: specColumns.size, - sort: specColumns.sort, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Strip", - props: stripProps1 - }); - break; - } - case "count-strip": - { - x.aggregate = "count"; - x.title = language.count; - const stripProps2 = { - sortOrder: "ascending", - orientation: "horizontal", - size: specColumns.size, - sort: specColumns.sort, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Strip", - props: stripProps2 - }); - break; - } - default: - { - x.aggregate = "count"; - x.title = language.count; - const squareProps = { - sortBy: specColumns.sort, - fillDirection: "down-right", - z: specColumns.z, - maxGroupedUnits: aggProps.globalAggregateMaxExtentSignal, - maxGroupedFillSize: aggProps.globalAggregateMaxExtentScaledSignal, - showAxes, - view - }; - layouts.push({ - layoutType: "Square", - props: squareProps - }); - break; - } - } - } - return { - axisScales, - layouts, - specCapabilities: { - countsAndSums: true, - percentage: true, - roles: [ - { - role: "y", - binnable: true, - axisSelection: ((_c = specColumns.y) === null || _c === void 0 ? void 0 : _c.quantitative) ? "range" : "exact", - axisSelectionBetweenTicks: true, - signals: [ - (0, _constants.SignalNames).YBins - ] - }, - { - role: "z", - axisSelection: ((_d = specColumns.z) === null || _d === void 0 ? void 0 : _d.quantitative) ? "range" : "exact", - allowNone: true, - disabled: view === "2d" - }, - { - role: "color", - allowNone: true - }, - { - role: "sort", - allowNone: true - }, - { - role: "size", - allowNone: (0, _size.allowNoneForSize), - excludeCategoric: true, - signals: [ - (0, _constants.SignalNames).TreeMapMethod - ] - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, - { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ] + const x = { + title: null + }; + const axisScales = { + x, + y: { + title: (_a = specColumns.y) === null || _a === void 0 ? void 0 : _a.name + }, + z: { + title: (_b = specColumns.z) === null || _b === void 0 ? void 0 : _b.name + } + }; + const layouts = [ + { + layoutType: 'Band', + props: bandProps + } + ]; + const { totalStyle, view } = insight; + if (totalStyle === 'sum-strip-percent') { + x.aggregate = 'percent'; + x.title = language.percent; + const stripProps = { + addPercentageScale: true, + sortOrder: 'ascending', + orientation: 'horizontal', + size: specColumns.size, + sort: specColumns.sort, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Strip', + props: stripProps + }); + } else { + const aggProps = { + niceScale: true, + dock: 'left', + globalAggregateMaxExtentSignal: 'aggMaxExtent', + globalAggregateMaxExtentScaledSignal: 'aggMaxExtentScaled', + sumBy: specColumns.size, + showAxes + }; + layouts.push({ + layoutType: 'AggregateContainer', + props: aggProps + }); + switch(totalStyle){ + case 'sum-treemap': + { + x.aggregate = 'sum'; + x.title = language.sum; + const treemapProps = { + corner: 'top-left', + size: specColumns.size, + treeMapMethod: specViewOptions.language.treeMapMethod, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Treemap', + props: treemapProps + }); + break; + } + case 'sum-strip': + { + x.aggregate = 'sum'; + x.title = language.sum; + const stripProps = { + sortOrder: 'ascending', + orientation: 'horizontal', + size: specColumns.size, + sort: specColumns.sort, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Strip', + props: stripProps + }); + break; + } + case 'count-strip': + { + x.aggregate = 'count'; + x.title = language.count; + const stripProps = { + sortOrder: 'ascending', + orientation: 'horizontal', + size: specColumns.size, + sort: specColumns.sort, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Strip', + props: stripProps + }); + break; + } + default: + { + x.aggregate = 'count'; + x.title = language.count; + const squareProps = { + sortBy: specColumns.sort, + fillDirection: 'down-right', + z: specColumns.z, + maxGroupedUnits: aggProps.globalAggregateMaxExtentSignal, + maxGroupedFillSize: aggProps.globalAggregateMaxExtentScaledSignal, + showAxes, + view + }; + layouts.push({ + layoutType: 'Square', + props: squareProps + }); + break; + } + } } - }; -}; + return { + axisScales, + layouts, + specCapabilities: { + countsAndSums: true, + percentage: true, + roles: [ + { + role: 'y', + binnable: true, + axisSelection: ((_c = specColumns.y) === null || _c === void 0 ? void 0 : _c.quantitative) ? 'range' : 'exact', + axisSelectionBetweenTicks: true, + signals: [ + (0, _constants.SignalNames).YBins + ] + }, + { + role: 'z', + axisSelection: ((_d = specColumns.z) === null || _d === void 0 ? void 0 : _d.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: view === '2d' + }, + { + role: 'color', + allowNone: true + }, + { + role: 'sort', + allowNone: true + }, + { + role: 'size', + allowNone: (0, _size.allowNoneForSize), + excludeCategoric: true, + signals: [ + (0, _constants.SignalNames).TreeMapMethod + ] + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ] + } + }; + }); +var _constants = require("../constants"); +var _defaults = require("../defaults"); +var _size = require("../size"); -},{"../constants":"6pnJw","../defaults":"dX5m9","../size":"hPYmk","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6pnJw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../constants":"22TRA","../defaults":"jpVjH","../size":"h7gMN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"22TRA":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "FieldNames", ()=>FieldNames); parcelHelpers.export(exports, "ScaleNames", ()=>ScaleNames); @@ -1047,90 +1050,90 @@ parcelHelpers.export(exports, "SignalNames", ()=>SignalNames); parcelHelpers.export(exports, "Other", ()=>Other); parcelHelpers.export(exports, "ColorScaleNone", ()=>ColorScaleNone); const FieldNames = { - Active: "__SandDance__Active", - Collapsed: "__SandDance__Collapsed", - Contains: "__SandDance__Contains", - Count: "__SandDance__Count", - Sum: "__SandDance__Sum", - SumOfCount: "__SandDance__CountSum", - SumOfSum: "__SandDance__SumSum", - Selected: "__SandDance__Selected", - First: "__SandDance__First", - Last: "__SandDance__Last", - Top: "__SandDance__Top", - TopColor: "__SandDance__TopColor", - TopIndex: "__SandDance__TopIndex", - PowerBISelectionId: "__SandDance__PowerBISelectionId", - FacetSearch: "__SandDance__FacetSearch", - FacetTitle: "__SandDance__FacetTitle", - Ordinal: "__SandDance__Ordinal", - WrapCol: "__SandDance__WrapCol", - WrapRow: "__SandDance__WrapRow", - Value: "__SandDance__Value", - OffsetX: "__SandDance__X", - OffsetY: "__SandDance__Y", - OffsetHeight: "__SandDance__H", - OffsetWidth: "__SandDance__W" + Active: '__SandDance__Active', + Collapsed: '__SandDance__Collapsed', + Contains: '__SandDance__Contains', + Count: '__SandDance__Count', + Sum: '__SandDance__Sum', + SumOfCount: '__SandDance__CountSum', + SumOfSum: '__SandDance__SumSum', + Selected: '__SandDance__Selected', + First: '__SandDance__First', + Last: '__SandDance__Last', + Top: '__SandDance__Top', + TopColor: '__SandDance__TopColor', + TopIndex: '__SandDance__TopIndex', + PowerBISelectionId: '__SandDance__PowerBISelectionId', + FacetSearch: '__SandDance__FacetSearch', + FacetTitle: '__SandDance__FacetTitle', + Ordinal: '__SandDance__Ordinal', + WrapCol: '__SandDance__WrapCol', + WrapRow: '__SandDance__WrapRow', + Value: '__SandDance__Value', + OffsetX: '__SandDance__X', + OffsetY: '__SandDance__Y', + OffsetHeight: '__SandDance__H', + OffsetWidth: '__SandDance__W' }; const ScaleNames = { - Color: "scale_color", - X: "scale_x", - Y: "scale_y", - Z: "scale_z" + Color: 'scale_color', + X: 'scale_x', + Y: 'scale_y', + Z: 'scale_z' }; const SignalNames = { - ViewportWidth: "ViewportWidth", - ViewportHeight: "ViewportHeight", - MinCellWidth: "MinCellWidth", - MinCellHeight: "MinCellHeight", - PlotOffsetLeft: "PlotOffsetLeft", - PlotOffsetTop: "PlotOffsetTop", - PlotOffsetBottom: "PlotOffsetBottom", - PlotOffsetRight: "PlotOffsetRight", - PlotHeightIn: "PlotHeightIn", - PlotWidthIn: "PlotWidthIn", - PlotHeightOut: "PlotHeightOut", - PlotWidthOut: "PlotWidthOut", - ColorBinCount: "RoleColor_BinCountSignal", - ColorReverse: "RoleColor_ReverseSignal", - FacetAxesAdjustX: "RoleFacet_AxesAdjustSignalX", - FacetAxesAdjustY: "RoleFacet_AxesAdjustSignalY", - FacetBins: "RoleFacet_BinsSignal", - FacetVBins: "RoleFacetV_BinsSignal", - FacetPaddingTop: "FacetPaddingTop", - FacetPaddingBottom: "FacetPaddingBottom", - FacetPaddingLeft: "FacetPaddingLeft", - MarkOpacity: "Mark_OpacitySignal", - PointScale: "Chart_PointScaleSignal", - TextAngleX: "Text_AngleXSignal", - TextAngleY: "Text_AngleYSignal", - TextScale: "Text_ScaleSignal", - TextSize: "Text_SizeSignal", - TextTitleSize: "Text_TitleSizeSignal", - TreeMapMethod: "Chart_TreeMapMethodSignal", - XBins: "RoleX_BinsSignal", - YBins: "RoleY_BinsSignal", - ZHeight: "RoleZ_HeightSignal", - ZGrounded: "RoleZ_Grounded", - ZProportion: "RoleZ_ProportionSignal" -}; -const Other = "__Other"; -const ColorScaleNone = "none"; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dWZT9":[function(require,module,exports) { + ViewportWidth: 'ViewportWidth', + ViewportHeight: 'ViewportHeight', + MinCellWidth: 'MinCellWidth', + MinCellHeight: 'MinCellHeight', + PlotOffsetLeft: 'PlotOffsetLeft', + PlotOffsetTop: 'PlotOffsetTop', + PlotOffsetBottom: 'PlotOffsetBottom', + PlotOffsetRight: 'PlotOffsetRight', + PlotHeightIn: 'PlotHeightIn', + PlotWidthIn: 'PlotWidthIn', + PlotHeightOut: 'PlotHeightOut', + PlotWidthOut: 'PlotWidthOut', + ColorBinCount: 'RoleColor_BinCountSignal', + ColorReverse: 'RoleColor_ReverseSignal', + FacetAxesAdjustX: 'RoleFacet_AxesAdjustSignalX', + FacetAxesAdjustY: 'RoleFacet_AxesAdjustSignalY', + FacetBins: 'RoleFacet_BinsSignal', + FacetVBins: 'RoleFacetV_BinsSignal', + FacetPaddingTop: 'FacetPaddingTop', + FacetPaddingBottom: 'FacetPaddingBottom', + FacetPaddingLeft: 'FacetPaddingLeft', + MarkOpacity: 'Mark_OpacitySignal', + PointScale: 'Chart_PointScaleSignal', + TextAngleX: 'Text_AngleXSignal', + TextAngleY: 'Text_AngleYSignal', + TextScale: 'Text_ScaleSignal', + TextSize: 'Text_SizeSignal', + TextTitleSize: 'Text_TitleSizeSignal', + TreeMapMethod: 'Chart_TreeMapMethodSignal', + XBins: 'RoleX_BinsSignal', + YBins: 'RoleY_BinsSignal', + ZHeight: 'RoleZ_HeightSignal', + ZGrounded: 'RoleZ_Grounded', + ZProportion: 'RoleZ_ProportionSignal' +}; +const Other = '__Other'; +const ColorScaleNone = 'none'; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"j7FRh":[function(require,module,exports,__globalThis) { exports.interopDefault = function(a) { return a && a.__esModule ? a : { default: a }; }; exports.defineInteropFlag = function(a) { - Object.defineProperty(a, "__esModule", { + Object.defineProperty(a, '__esModule', { value: true }); }; exports.exportAll = function(source, dest) { Object.keys(source).forEach(function(key) { - if (key === "default" || key === "__esModule" || dest.hasOwnProperty(key)) return; + if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return; Object.defineProperty(dest, key, { enumerable: true, get: function() { @@ -1147,7 +1150,11 @@ exports.export = function(dest, destName, get) { }); }; -},{}],"dX5m9":[function(require,module,exports) { +},{}],"jpVjH":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ //TODO move these to options var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "defaultBins", ()=>defaultBins); @@ -1191,18 +1198,18 @@ const scatterSizedMin = 10; const scatterSizedDiv = 20; const debounce = 250; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hPYmk":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h7gMN":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "allowNoneForSize", ()=>allowNoneForSize); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "allowNoneForSize", ()=>allowNoneForSize); function allowNoneForSize(specContext) { switch(specContext.insight.totalStyle){ - case "sum-strip": - case "sum-strip-percent": - case "sum-treemap": + case 'sum-strip': + case 'sum-strip-percent': + case 'sum-treemap': return false; default: //if totalStyle is blank, count is assumed @@ -1210,88 +1217,297 @@ function allowNoneForSize(specContext) { } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9v0R3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6xzC3":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("../constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a, _b; + const { insight, specColumns, specViewOptions } = specContext; + const { language } = specViewOptions; + const showAxes = !insight.hideAxes; + const bandProps = { + orientation: 'vertical', + groupby: { + column: specColumns.x, + defaultBins: (0, _defaults.defaultBins), + maxbinsSignalName: (0, _constants.SignalNames).XBins, + maxbinsSignalDisplayName: specContext.specViewOptions.language.XMaxBins, + maxbins: (0, _defaults.maxbins) + }, + minBandWidth: (0, _defaults.minBarBandWidth), + showAxes + }; + const y = { + title: null + }; + const axisScales = { + x: { + title: specColumns.x && specColumns.x.name + }, + y, + z: { + title: specColumns.z && specColumns.z.name + } + }; + const layouts = [ + { + layoutType: 'Band', + props: bandProps + } + ]; + const { totalStyle, view } = insight; + if (totalStyle === 'sum-strip-percent') { + y.aggregate = 'percent'; + y.title = language.percent; + const stripProps = { + addPercentageScale: true, + sortOrder: 'descending', + orientation: 'vertical', + size: specColumns.size, + sort: specColumns.sort, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Strip', + props: stripProps + }); + } else { + const aggProps = { + niceScale: true, + dock: 'bottom', + globalAggregateMaxExtentSignal: 'aggMaxExtent', + globalAggregateMaxExtentScaledSignal: 'aggMaxExtentScaled', + sumBy: specColumns.size, + showAxes + }; + layouts.push({ + layoutType: 'AggregateContainer', + props: aggProps + }); + switch(totalStyle){ + case 'sum-treemap': + { + y.aggregate = 'sum'; + y.title = language.sum; + const treemapProps = { + corner: 'bottom-left', + size: specColumns.size, + treeMapMethod: specViewOptions.language.treeMapMethod, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Treemap', + props: treemapProps + }); + break; + } + case 'sum-strip': + { + y.aggregate = 'sum'; + y.title = language.sum; + const stripProps = { + sortOrder: 'descending', + orientation: 'vertical', + size: specColumns.size, + sort: specColumns.sort, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Strip', + props: stripProps + }); + break; + } + case 'count-strip': + { + y.aggregate = 'count'; + y.title = language.count; + const stripProps = { + sortOrder: 'descending', + orientation: 'vertical', + sort: specColumns.sort, + z: specColumns.z, + showAxes, + view + }; + layouts.push({ + layoutType: 'Strip', + props: stripProps + }); + break; + } + default: + { + y.aggregate = 'count'; + y.title = language.count; + const squareProps = { + sortBy: specColumns.sort, + fillDirection: 'right-up', + z: specColumns.z, + maxGroupedUnits: aggProps.globalAggregateMaxExtentSignal, + maxGroupedFillSize: aggProps.globalAggregateMaxExtentScaledSignal, + showAxes, + view + }; + layouts.push({ + layoutType: 'Square', + props: squareProps + }); + break; + } + } + } + return { + axisScales, + layouts, + specCapabilities: { + countsAndSums: true, + percentage: true, + roles: [ + { + role: 'x', + binnable: true, + axisSelection: ((_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.quantitative) ? 'range' : 'exact', + axisSelectionBetweenTicks: true, + signals: [ + (0, _constants.SignalNames).XBins + ] + }, + { + role: 'z', + axisSelection: ((_b = specColumns.z) === null || _b === void 0 ? void 0 : _b.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: view === '2d' + }, + { + role: 'color', + allowNone: true + }, + { + role: 'sort', + allowNone: true + }, + { + role: 'size', + allowNone: (0, _size.allowNoneForSize), + excludeCategoric: true, + signals: [ + (0, _constants.SignalNames).TreeMapMethod + ] + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ] + } + }; + }); +var _constants = require("../constants"); var _defaults = require("../defaults"); var _size = require("../size"); -exports.default = function(specContext) { - var _a, _b; - const { insight , specColumns , specViewOptions } = specContext; - const { language } = specViewOptions; - const showAxes = !insight.hideAxes; - const bandProps = { - orientation: "vertical", - groupby: { - column: specColumns.x, - defaultBins: (0, _defaults.defaultBins), - maxbinsSignalName: (0, _constants.SignalNames).XBins, - maxbinsSignalDisplayName: specContext.specViewOptions.language.XMaxBins, - maxbins: (0, _defaults.maxbins) - }, - minBandWidth: (0, _defaults.minBarBandWidth), - showAxes - }; - const y = { - title: null - }; - const axisScales = { - x: { - title: specColumns.x && specColumns.x.name - }, - y, - z: { - title: specColumns.z && specColumns.z.name - } - }; - const layouts = [ - { - layoutType: "Band", - props: bandProps - } - ]; - const { totalStyle , view } = insight; - if (totalStyle === "sum-strip-percent") { - y.aggregate = "percent"; - y.title = language.percent; - const stripProps = { - addPercentageScale: true, - sortOrder: "descending", - orientation: "vertical", - size: specColumns.size, - sort: specColumns.sort, - z: specColumns.z, + +},{"../constants":"22TRA","../defaults":"jpVjH","../size":"h7gMN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3nLmY":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + const { insight, specColumns, specViewOptions } = specContext; + const axisScales = { + x: { + title: (_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.name + }, + y: { + title: (_b = specColumns.y) === null || _b === void 0 ? void 0 : _b.name + }, + z: { + title: (_c = specColumns.z) === null || _c === void 0 ? void 0 : _c.name + } + }; + const backgroundImage = ((_d = specColumns.x) === null || _d === void 0 ? void 0 : _d.quantitative) && ((_e = specColumns.y) === null || _e === void 0 ? void 0 : _e.quantitative) && ((_f = insight.backgroundImage) === null || _f === void 0 ? void 0 : _f.extents) && insight.backgroundImage; + const showAxes = !(backgroundImage || insight.hideAxes); + const hBandProps = { + excludeEncodingRuleMap: true, + orientation: 'horizontal', + groupby: { + column: specColumns.y, + defaultBins: (0, _defaults.defaultBins), + maxbinsSignalName: (0, _constants.SignalNames).YBins, + maxbinsSignalDisplayName: specContext.specViewOptions.language.YMaxBins, + maxbins: (0, _defaults.maxbins) + }, + minBandWidth: (0, _defaults.minBarBandWidth), showAxes, - view + outerSignalExtents: backgroundImage && { + max: backgroundImage.extents.top, + min: backgroundImage.extents.bottom + } + }; + const vBandProps = { + excludeEncodingRuleMap: true, + orientation: 'vertical', + groupby: { + column: specColumns.x, + defaultBins: (0, _defaults.defaultBins), + maxbinsSignalName: (0, _constants.SignalNames).XBins, + maxbinsSignalDisplayName: specContext.specViewOptions.language.XMaxBins, + maxbins: (0, _defaults.maxbins) + }, + minBandWidth: (0, _defaults.minBarBandWidth), + showAxes, + outerSignalExtents: backgroundImage && { + max: backgroundImage.extents.right, + min: backgroundImage.extents.left + } }; - layouts.push({ - layoutType: "Strip", - props: stripProps - }); - } else { const aggProps = { - niceScale: true, - dock: "bottom", - globalAggregateMaxExtentSignal: "aggMaxExtent", - globalAggregateMaxExtentScaledSignal: "aggMaxExtentScaled", - sumBy: specColumns.size, - showAxes + onBuild: null, + aggregation: null, + sumBy: specColumns.size }; - layouts.push({ - layoutType: "AggregateContainer", - props: aggProps - }); + const layouts = [ + { + layoutType: 'Band', + props: vBandProps + }, + { + layoutType: 'Band', + props: hBandProps + }, + { + layoutType: 'AggregateSquare', + props: aggProps + } + ]; + const { totalStyle, view } = insight; switch(totalStyle){ - case "sum-treemap": + case 'sum-treemap': { - y.aggregate = "sum"; - y.title = language.sum; + aggProps.aggregation = 'sum'; const treemapProps = { - corner: "bottom-left", + corner: 'bottom-left', size: specColumns.size, treeMapMethod: specViewOptions.language.treeMapMethod, z: specColumns.z, @@ -1299,18 +1515,17 @@ exports.default = function(specContext) { view }; layouts.push({ - layoutType: "Treemap", + layoutType: 'Treemap', props: treemapProps }); break; } - case "sum-strip": + case 'sum-strip': { - y.aggregate = "sum"; - y.title = language.sum; - const stripProps1 = { - sortOrder: "descending", - orientation: "vertical", + aggProps.aggregation = 'sum'; + const stripProps = { + sortOrder: 'ascending', + orientation: 'vertical', size: specColumns.size, sort: specColumns.sort, z: specColumns.z, @@ -1318,813 +1533,605 @@ exports.default = function(specContext) { view }; layouts.push({ - layoutType: "Strip", - props: stripProps1 + layoutType: 'Strip', + props: stripProps }); break; } - case "count-strip": + case 'count-strip': { - y.aggregate = "count"; - y.title = language.count; - const stripProps2 = { - sortOrder: "descending", - orientation: "vertical", + aggProps.aggregation = 'count'; + const stripProps = { + sortOrder: 'ascending', + orientation: 'vertical', sort: specColumns.sort, z: specColumns.z, showAxes, view }; layouts.push({ - layoutType: "Strip", - props: stripProps2 + layoutType: 'Strip', + props: stripProps }); break; } default: { - y.aggregate = "count"; - y.title = language.count; + aggProps.aggregation = 'count'; const squareProps = { sortBy: specColumns.sort, - fillDirection: "right-up", + fillDirection: 'right-down', z: specColumns.z, - maxGroupedUnits: aggProps.globalAggregateMaxExtentSignal, - maxGroupedFillSize: aggProps.globalAggregateMaxExtentScaledSignal, + maxGroupedUnits: null, + maxGroupedFillSize: null, showAxes, view }; + aggProps.onBuild = (aggMaxExtent, aggMaxExtentScaled)=>{ + squareProps.maxGroupedUnits = aggMaxExtent; + squareProps.maxGroupedFillSize = aggMaxExtentScaled; + }; layouts.push({ - layoutType: "Square", + layoutType: 'Square', props: squareProps }); break; } } - } - return { - axisScales, - layouts, - specCapabilities: { - countsAndSums: true, - percentage: true, - roles: [ - { - role: "x", - binnable: true, - axisSelection: ((_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.quantitative) ? "range" : "exact", - axisSelectionBetweenTicks: true, - signals: [ - (0, _constants.SignalNames).XBins - ] - }, - { - role: "z", - axisSelection: ((_b = specColumns.z) === null || _b === void 0 ? void 0 : _b.quantitative) ? "range" : "exact", - allowNone: true, - disabled: view === "2d" - }, - { - role: "color", - allowNone: true - }, - { - role: "sort", - allowNone: true - }, - { - role: "size", - allowNone: (0, _size.allowNoneForSize), - excludeCategoric: true, - signals: [ - (0, _constants.SignalNames).TreeMapMethod - ] - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, - { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ] - } - }; -}; - -},{"../constants":"6pnJw","../defaults":"dX5m9","../size":"hPYmk","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aEqxi":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("../constants"); + return { + axisScales, + layouts, + specCapabilities: { + backgroundImage: true, + countsAndSums: true, + roles: [ + { + role: 'x', + binnable: true, + axisSelection: ((_g = specColumns.x) === null || _g === void 0 ? void 0 : _g.quantitative) ? 'range' : 'exact', + axisSelectionBetweenTicks: true, + signals: [ + (0, _constants.SignalNames).XBins + ] + }, + { + role: 'y', + binnable: true, + axisSelection: ((_h = specColumns.y) === null || _h === void 0 ? void 0 : _h.quantitative) ? 'range' : 'exact', + axisSelectionBetweenTicks: true, + signals: [ + (0, _constants.SignalNames).YBins + ] + }, + { + role: 'z', + axisSelection: ((_j = specColumns.z) === null || _j === void 0 ? void 0 : _j.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: view === '2d' + }, + { + role: 'color', + allowNone: true + }, + { + role: 'sort', + allowNone: true + }, + { + role: 'size', + allowNone: (0, _size.allowNoneForSize), + excludeCategoric: true, + signals: [ + (0, _constants.SignalNames).TreeMapMethod + ] + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ] + } + }; + }); +var _constants = require("../constants"); var _defaults = require("../defaults"); var _size = require("../size"); -exports.default = function(specContext) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - const { insight , specColumns , specViewOptions } = specContext; - const axisScales = { - x: { - title: (_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.name - }, - y: { - title: (_b = specColumns.y) === null || _b === void 0 ? void 0 : _b.name - }, - z: { - title: (_c = specColumns.z) === null || _c === void 0 ? void 0 : _c.name - } - }; - const backgroundImage = ((_d = specColumns.x) === null || _d === void 0 ? void 0 : _d.quantitative) && ((_e = specColumns.y) === null || _e === void 0 ? void 0 : _e.quantitative) && ((_f = insight.backgroundImage) === null || _f === void 0 ? void 0 : _f.extents) && insight.backgroundImage; - const showAxes = !(backgroundImage || insight.hideAxes); - const hBandProps = { - excludeEncodingRuleMap: true, - orientation: "horizontal", - groupby: { - column: specColumns.y, - defaultBins: (0, _defaults.defaultBins), - maxbinsSignalName: (0, _constants.SignalNames).YBins, - maxbinsSignalDisplayName: specContext.specViewOptions.language.YMaxBins, - maxbins: (0, _defaults.maxbins) - }, - minBandWidth: (0, _defaults.minBarBandWidth), - showAxes, - outerSignalExtents: backgroundImage && { - max: backgroundImage.extents.top, - min: backgroundImage.extents.bottom - } - }; - const vBandProps = { - excludeEncodingRuleMap: true, - orientation: "vertical", - groupby: { - column: specColumns.x, - defaultBins: (0, _defaults.defaultBins), - maxbinsSignalName: (0, _constants.SignalNames).XBins, - maxbinsSignalDisplayName: specContext.specViewOptions.language.XMaxBins, - maxbins: (0, _defaults.maxbins) - }, - minBandWidth: (0, _defaults.minBarBandWidth), - showAxes, - outerSignalExtents: backgroundImage && { - max: backgroundImage.extents.right, - min: backgroundImage.extents.left - } - }; - const aggProps = { - onBuild: null, - aggregation: null, - sumBy: specColumns.size - }; - const layouts = [ - { - layoutType: "Band", - props: vBandProps - }, - { - layoutType: "Band", - props: hBandProps - }, - { - layoutType: "AggregateSquare", - props: aggProps - }, - ]; - const { totalStyle , view } = insight; - switch(totalStyle){ - case "sum-treemap": - { - aggProps.aggregation = "sum"; - const treemapProps = { - corner: "bottom-left", - size: specColumns.size, - treeMapMethod: specViewOptions.language.treeMapMethod, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Treemap", - props: treemapProps - }); - break; - } - case "sum-strip": - { - aggProps.aggregation = "sum"; - const stripProps = { - sortOrder: "ascending", - orientation: "vertical", - size: specColumns.size, - sort: specColumns.sort, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Strip", - props: stripProps - }); - break; - } - case "count-strip": - { - aggProps.aggregation = "count"; - const stripProps1 = { - sortOrder: "ascending", - orientation: "vertical", - sort: specColumns.sort, - z: specColumns.z, - showAxes, - view - }; - layouts.push({ - layoutType: "Strip", - props: stripProps1 - }); - break; - } - default: - { - aggProps.aggregation = "count"; - const squareProps = { - sortBy: specColumns.sort, - fillDirection: "right-down", - z: specColumns.z, - maxGroupedUnits: null, - maxGroupedFillSize: null, - showAxes, - view - }; - aggProps.onBuild = (aggMaxExtent, aggMaxExtentScaled)=>{ - squareProps.maxGroupedUnits = aggMaxExtent; - squareProps.maxGroupedFillSize = aggMaxExtentScaled; - }; - layouts.push({ - layoutType: "Square", - props: squareProps - }); - break; - } - } - return { - axisScales, - layouts, - specCapabilities: { - backgroundImage: true, - countsAndSums: true, - roles: [ - { - role: "x", - binnable: true, - axisSelection: ((_g = specColumns.x) === null || _g === void 0 ? void 0 : _g.quantitative) ? "range" : "exact", - axisSelectionBetweenTicks: true, - signals: [ - (0, _constants.SignalNames).XBins - ] - }, - { - role: "y", - binnable: true, - axisSelection: ((_h = specColumns.y) === null || _h === void 0 ? void 0 : _h.quantitative) ? "range" : "exact", - axisSelectionBetweenTicks: true, - signals: [ - (0, _constants.SignalNames).YBins - ] - }, - { - role: "z", - axisSelection: ((_j = specColumns.z) === null || _j === void 0 ? void 0 : _j.quantitative) ? "range" : "exact", - allowNone: true, - disabled: view === "2d" - }, - { - role: "color", - allowNone: true - }, - { - role: "sort", - allowNone: true - }, - { - role: "size", - allowNone: (0, _size.allowNoneForSize), - excludeCategoric: true, - signals: [ - (0, _constants.SignalNames).TreeMapMethod - ] - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, - { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ] - } - }; -}; -},{"../constants":"6pnJw","../defaults":"dX5m9","../size":"hPYmk","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"guiV8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"../constants":"22TRA","../defaults":"jpVjH","../size":"h7gMN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8jSVp":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("../constants"); -exports.default = function(specContext) { - var _a; - const { insight , specColumns } = specContext; - const { view } = insight; - const squareProps = { - sortBy: specColumns.sort, - fillDirection: "right-down", - z: specColumns.z, - collapseYHeight: true, - showAxes: !insight.hideAxes, - view - }; - const axisScales = { - z: { - title: specColumns.z && specColumns.z.name - } - }; - return { - axisScales, - layouts: [ - { - layoutType: "Square", - props: squareProps - }, - ], - specCapabilities: { - countsAndSums: false, - roles: [ - { - role: "z", - axisSelection: ((_a = specColumns.z) === null || _a === void 0 ? void 0 : _a.quantitative) ? "range" : "exact", - allowNone: true, - disabled: view === "2d" - }, - { - role: "color", - allowNone: true - }, - { - role: "sort", - allowNone: true - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a; + const { insight, specColumns } = specContext; + const { view } = insight; + const squareProps = { + sortBy: specColumns.sort, + fillDirection: 'right-down', + z: specColumns.z, + collapseYHeight: true, + showAxes: !insight.hideAxes, + view + }; + const axisScales = { + z: { + title: specColumns.z && specColumns.z.name + } + }; + return { + axisScales, + layouts: [ { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ] - } - }; -}; + layoutType: 'Square', + props: squareProps + } + ], + specCapabilities: { + countsAndSums: false, + roles: [ + { + role: 'z', + axisSelection: ((_a = specColumns.z) === null || _a === void 0 ? void 0 : _a.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: view === '2d' + }, + { + role: 'color', + allowNone: true + }, + { + role: 'sort', + allowNone: true + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ] + } + }; + }); +var _constants = require("../constants"); -},{"../constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jimHY":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"../constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cktKX":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("../constants"); -exports.default = function(specContext) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - const { insight , specColumns , specViewOptions } = specContext; - const backgroundImageExtents = ((_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.quantitative) && ((_b = specColumns.y) === null || _b === void 0 ? void 0 : _b.quantitative) && ((_c = insight.backgroundImage) === null || _c === void 0 ? void 0 : _c.extents); - const scatterProps = { - x: specColumns.x, - y: specColumns.y, - z: specColumns.z, - size: specColumns.size, - scatterPointScaleDisplay: specViewOptions.language.scatterPointScale, - zGrounded: specViewOptions.language.zGrounded, - backgroundImageExtents, - showAxes: !(backgroundImageExtents || insight.hideAxes), - view: insight.view - }; - const axisScales = { - x: { - title: (_d = specColumns.x) === null || _d === void 0 ? void 0 : _d.name - }, - y: { - title: (_e = specColumns.y) === null || _e === void 0 ? void 0 : _e.name - }, - z: { - title: (_f = specColumns.z) === null || _f === void 0 ? void 0 : _f.name - } - }; - return { - axisScales, - layouts: [ - { - layoutType: "Scatter", - props: scatterProps - }, - ], - specCapabilities: { - backgroundImage: true, - countsAndSums: false, - roles: [ - { - role: "x", - axisSelection: ((_g = specColumns.x) === null || _g === void 0 ? void 0 : _g.quantitative) ? "range" : "exact" - }, - { - role: "y", - axisSelection: ((_h = specColumns.y) === null || _h === void 0 ? void 0 : _h.quantitative) ? "range" : "exact" - }, - { - role: "z", - axisSelection: ((_j = specColumns.z) === null || _j === void 0 ? void 0 : _j.quantitative) ? "range" : "exact", - allowNone: true, - disabled: false - }, - { - role: "color", - allowNone: true - }, - { - role: "size", - excludeCategoric: true, - allowNone: true - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + const { insight, specColumns, specViewOptions } = specContext; + const backgroundImageExtents = ((_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.quantitative) && ((_b = specColumns.y) === null || _b === void 0 ? void 0 : _b.quantitative) && ((_c = insight.backgroundImage) === null || _c === void 0 ? void 0 : _c.extents); + const scatterProps = { + x: specColumns.x, + y: specColumns.y, + z: specColumns.z, + size: specColumns.size, + scatterPointScaleDisplay: specViewOptions.language.scatterPointScale, + zGrounded: specViewOptions.language.zGrounded, + backgroundImageExtents, + showAxes: !(backgroundImageExtents || insight.hideAxes), + view: insight.view + }; + const axisScales = { + x: { + title: (_d = specColumns.x) === null || _d === void 0 ? void 0 : _d.name + }, + y: { + title: (_e = specColumns.y) === null || _e === void 0 ? void 0 : _e.name + }, + z: { + title: (_f = specColumns.z) === null || _f === void 0 ? void 0 : _f.name + } + }; + return { + axisScales, + layouts: [ { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, + layoutType: 'Scatter', + props: scatterProps + } ], - signals: [ - (0, _constants.SignalNames).PointScale, - (0, _constants.SignalNames).ZGrounded - ] - } - }; -}; + specCapabilities: { + backgroundImage: true, + countsAndSums: false, + roles: [ + { + role: 'x', + axisSelection: ((_g = specColumns.x) === null || _g === void 0 ? void 0 : _g.quantitative) ? 'range' : 'exact' + }, + { + role: 'y', + axisSelection: ((_h = specColumns.y) === null || _h === void 0 ? void 0 : _h.quantitative) ? 'range' : 'exact' + }, + { + role: 'z', + axisSelection: ((_j = specColumns.z) === null || _j === void 0 ? void 0 : _j.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: false + }, + { + role: 'color', + allowNone: true + }, + { + role: 'size', + excludeCategoric: true, + allowNone: true + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ], + signals: [ + (0, _constants.SignalNames).PointScale, + (0, _constants.SignalNames).ZGrounded + ] + } + }; + }); +var _constants = require("../constants"); -},{"../constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fm6Eo":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"../constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7r3BC":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _defaults = require("../defaults"); -var _constants = require("../constants"); -exports.default = function(specContext) { - var _a, _b, _c, _d, _e, _f, _g; - const { insight , specColumns , specViewOptions } = specContext; - const axisScales = { - x: { - title: (_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.name - }, - y: { - title: (_b = specColumns.y) === null || _b === void 0 ? void 0 : _b.name - }, - z: { - title: specViewOptions.language.count - } - }; - const backgroundImage = ((_c = specColumns.x) === null || _c === void 0 ? void 0 : _c.quantitative) && ((_d = specColumns.y) === null || _d === void 0 ? void 0 : _d.quantitative) && ((_e = insight.backgroundImage) === null || _e === void 0 ? void 0 : _e.extents) && insight.backgroundImage; - const showAxes = !(backgroundImage || insight.hideAxes); - const hBandProps = { - excludeEncodingRuleMap: true, - orientation: "horizontal", - groupby: { - column: specColumns.y, - defaultBins: (0, _defaults.defaultBins), - maxbinsSignalName: (0, _constants.SignalNames).YBins, - maxbinsSignalDisplayName: specContext.specViewOptions.language.YMaxBins, - maxbins: (0, _defaults.maxbins) - }, - minBandWidth: (0, _defaults.minBarBandWidth), - showAxes, - outerSignalExtents: backgroundImage && { - max: backgroundImage.extents.top, - min: backgroundImage.extents.bottom - } - }; - const vBandProps = { - excludeEncodingRuleMap: true, - orientation: "vertical", - groupby: { - column: specColumns.x, - defaultBins: (0, _defaults.defaultBins), - maxbinsSignalName: (0, _constants.SignalNames).XBins, - maxbinsSignalDisplayName: specContext.specViewOptions.language.XMaxBins, - maxbins: (0, _defaults.maxbins) - }, - minBandWidth: (0, _defaults.minBarBandWidth), - showAxes, - outerSignalExtents: backgroundImage && { - max: backgroundImage.extents.right, - min: backgroundImage.extents.left - } - }; - const stackProps = { - sort: specColumns.sort, - showAxes - }; - return { - axisScales, - customZScale: true, - layouts: [ - { - layoutType: "Band", - props: vBandProps +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a, _b, _c, _d, _e, _f, _g; + const { insight, specColumns, specViewOptions } = specContext; + const axisScales = { + x: { + title: (_a = specColumns.x) === null || _a === void 0 ? void 0 : _a.name }, - { - layoutType: "Band", - props: hBandProps + y: { + title: (_b = specColumns.y) === null || _b === void 0 ? void 0 : _b.name }, - { - layoutType: "Stack", - props: stackProps - }, - ], - specCapabilities: { - backgroundImage: true, - countsAndSums: false, - roles: [ - { - role: "x", - binnable: true, - axisSelection: ((_f = specColumns.x) === null || _f === void 0 ? void 0 : _f.quantitative) ? "range" : "exact", - axisSelectionBetweenTicks: true, - signals: [ - (0, _constants.SignalNames).XBins - ] - }, - { - role: "y", - binnable: true, - axisSelection: ((_g = specColumns.y) === null || _g === void 0 ? void 0 : _g.quantitative) ? "range" : "exact", - axisSelectionBetweenTicks: true, - signals: [ - (0, _constants.SignalNames).YBins - ] - }, - { - role: "color", - allowNone: true - }, + z: { + title: specViewOptions.language.count + } + }; + const backgroundImage = ((_c = specColumns.x) === null || _c === void 0 ? void 0 : _c.quantitative) && ((_d = specColumns.y) === null || _d === void 0 ? void 0 : _d.quantitative) && ((_e = insight.backgroundImage) === null || _e === void 0 ? void 0 : _e.extents) && insight.backgroundImage; + const showAxes = !(backgroundImage || insight.hideAxes); + const hBandProps = { + excludeEncodingRuleMap: true, + orientation: 'horizontal', + groupby: { + column: specColumns.y, + defaultBins: (0, _defaults.defaultBins), + maxbinsSignalName: (0, _constants.SignalNames).YBins, + maxbinsSignalDisplayName: specContext.specViewOptions.language.YMaxBins, + maxbins: (0, _defaults.maxbins) + }, + minBandWidth: (0, _defaults.minBarBandWidth), + showAxes, + outerSignalExtents: backgroundImage && { + max: backgroundImage.extents.top, + min: backgroundImage.extents.bottom + } + }; + const vBandProps = { + excludeEncodingRuleMap: true, + orientation: 'vertical', + groupby: { + column: specColumns.x, + defaultBins: (0, _defaults.defaultBins), + maxbinsSignalName: (0, _constants.SignalNames).XBins, + maxbinsSignalDisplayName: specContext.specViewOptions.language.XMaxBins, + maxbins: (0, _defaults.maxbins) + }, + minBandWidth: (0, _defaults.minBarBandWidth), + showAxes, + outerSignalExtents: backgroundImage && { + max: backgroundImage.extents.right, + min: backgroundImage.extents.left + } + }; + const stackProps = { + sort: specColumns.sort, + showAxes + }; + return { + axisScales, + customZScale: true, + layouts: [ { - role: "sort", - allowNone: true + layoutType: 'Band', + props: vBandProps }, { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] + layoutType: 'Band', + props: hBandProps }, { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ] - } - }; -}; + layoutType: 'Stack', + props: stackProps + } + ], + specCapabilities: { + backgroundImage: true, + countsAndSums: false, + roles: [ + { + role: 'x', + binnable: true, + axisSelection: ((_f = specColumns.x) === null || _f === void 0 ? void 0 : _f.quantitative) ? 'range' : 'exact', + axisSelectionBetweenTicks: true, + signals: [ + (0, _constants.SignalNames).XBins + ] + }, + { + role: 'y', + binnable: true, + axisSelection: ((_g = specColumns.y) === null || _g === void 0 ? void 0 : _g.quantitative) ? 'range' : 'exact', + axisSelectionBetweenTicks: true, + signals: [ + (0, _constants.SignalNames).YBins + ] + }, + { + role: 'color', + allowNone: true + }, + { + role: 'sort', + allowNone: true + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ] + } + }; + }); +var _defaults = require("../defaults"); +var _constants = require("../constants"); -},{"../defaults":"dX5m9","../constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"peNnJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"../defaults":"jpVjH","../constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8tBSJ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("../constants"); -exports.default = function(specContext) { - var _a; - const { insight , specColumns } = specContext; - const { view } = insight; - const stripProps = { - sortOrder: "ascending", - orientation: "vertical", - size: specColumns.size, - sort: specColumns.sort, - z: specColumns.z, - showAxes: !insight.hideAxes, - view - }; - const axisScales = { - z: { - title: specColumns.z && specColumns.z.name - } - }; - const layouts = []; - if (specColumns.facet) { - axisScales.y = { - title: null, - aggregate: specColumns.size ? "sum" : "count" +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a; + const { insight, specColumns } = specContext; + const { view } = insight; + const stripProps = { + sortOrder: 'ascending', + orientation: 'vertical', + size: specColumns.size, + sort: specColumns.sort, + z: specColumns.z, + showAxes: !insight.hideAxes, + view }; - const globalAggregateMaxExtentScaledSignal = "globalAggregateMaxExtentScaledSignal"; - const globalAggregateMaxExtentSignal = "globalAggregateMaxExtentSignal"; - const props = { - dock: "top", - niceScale: false, - globalAggregateMaxExtentScaledSignal, - globalAggregateMaxExtentSignal, - sumBy: specColumns.size, - showAxes: false + const axisScales = { + z: { + title: specColumns.z && specColumns.z.name + } }; + const layouts = []; + if (specColumns.facet) { + axisScales.y = { + title: null, + aggregate: specColumns.size ? 'sum' : 'count' + }; + const globalAggregateMaxExtentScaledSignal = 'globalAggregateMaxExtentScaledSignal'; + const globalAggregateMaxExtentSignal = 'globalAggregateMaxExtentSignal'; + const props = { + dock: 'top', + niceScale: false, + globalAggregateMaxExtentScaledSignal, + globalAggregateMaxExtentSignal, + sumBy: specColumns.size, + showAxes: false + }; + layouts.push({ + layoutType: 'AggregateContainer', + props + }); + } layouts.push({ - layoutType: "AggregateContainer", - props + layoutType: 'Strip', + props: stripProps }); - } - layouts.push({ - layoutType: "Strip", - props: stripProps + return { + axisScales, + layouts, + specCapabilities: { + countsAndSums: false, + roles: [ + { + role: 'size', + allowNone: true, + excludeCategoric: true + }, + { + role: 'z', + axisSelection: ((_a = specColumns.z) === null || _a === void 0 ? void 0 : _a.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: view === '2d' + }, + { + role: 'color', + allowNone: true + }, + { + role: 'sort', + allowNone: true + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ] + } + }; }); - return { - axisScales, - layouts, - specCapabilities: { - countsAndSums: false, - roles: [ - { - role: "size", - allowNone: true, - excludeCategoric: true - }, - { - role: "z", - axisSelection: ((_a = specColumns.z) === null || _a === void 0 ? void 0 : _a.quantitative) ? "range" : "exact", - allowNone: true, - disabled: view === "2d" - }, - { - role: "color", - allowNone: true - }, - { - role: "sort", - allowNone: true - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, - { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ] - } - }; -}; +var _constants = require("../constants"); -},{"../constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6mOC0":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"../constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3rGzu":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("../constants"); -exports.default = function(specContext) { - var _a; - const { insight , specColumns , specViewOptions } = specContext; - const { view } = insight; - const treemapProps = { - corner: "top-left", - group: specColumns.group, - size: specColumns.size, - treeMapMethod: specViewOptions.language.treeMapMethod, - z: specColumns.z, - showAxes: !insight.hideAxes, - view - }; - const axisScales = { - z: { - title: specColumns.z && specColumns.z.name - } - }; - const layouts = []; - if (specColumns.facet) { - axisScales.y = { - title: null, - aggregate: "sum" +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(specContext) { + var _a; + const { insight, specColumns, specViewOptions } = specContext; + const { view } = insight; + const treemapProps = { + corner: 'top-left', + group: specColumns.group, + size: specColumns.size, + treeMapMethod: specViewOptions.language.treeMapMethod, + z: specColumns.z, + showAxes: !insight.hideAxes, + view }; - const globalAggregateMaxExtentScaledSignal = "globalAggregateMaxExtentScaledSignal"; - const globalAggregateMaxExtentSignal = "globalAggregateMaxExtentSignal"; - const props = { - dock: "top", - niceScale: false, - globalAggregateMaxExtentScaledSignal, - globalAggregateMaxExtentSignal, - sumBy: specColumns.size, - showAxes: false + const axisScales = { + z: { + title: specColumns.z && specColumns.z.name + } }; + const layouts = []; + if (specColumns.facet) { + axisScales.y = { + title: null, + aggregate: 'sum' + }; + const globalAggregateMaxExtentScaledSignal = 'globalAggregateMaxExtentScaledSignal'; + const globalAggregateMaxExtentSignal = 'globalAggregateMaxExtentSignal'; + const props = { + dock: 'top', + niceScale: false, + globalAggregateMaxExtentScaledSignal, + globalAggregateMaxExtentSignal, + sumBy: specColumns.size, + showAxes: false + }; + layouts.push({ + layoutType: 'AggregateContainer', + props + }); + } layouts.push({ - layoutType: "AggregateContainer", - props + layoutType: 'Treemap', + props: treemapProps }); - } - layouts.push({ - layoutType: "Treemap", - props: treemapProps + return { + axisScales, + layouts, + specCapabilities: { + countsAndSums: false, + roles: [ + { + role: 'size', + excludeCategoric: true + }, + { + role: 'group', + allowNone: true + }, + { + role: 'z', + axisSelection: ((_a = specColumns.z) === null || _a === void 0 ? void 0 : _a.quantitative) ? 'range' : 'exact', + allowNone: true, + disabled: view === '2d' + }, + { + role: 'color', + allowNone: true + }, + { + role: 'facet', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetBins + ] + }, + { + role: 'facetV', + allowNone: true, + signals: [ + (0, _constants.SignalNames).FacetVBins + ] + } + ], + signals: [ + (0, _constants.SignalNames).TreeMapMethod + ] + } + }; }); - return { - axisScales, - layouts, - specCapabilities: { - countsAndSums: false, - roles: [ - { - role: "size", - excludeCategoric: true - }, - { - role: "group", - allowNone: true - }, - { - role: "z", - axisSelection: ((_a = specColumns.z) === null || _a === void 0 ? void 0 : _a.quantitative) ? "range" : "exact", - allowNone: true, - disabled: view === "2d" - }, - { - role: "color", - allowNone: true - }, - { - role: "facet", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetBins - ] - }, - { - role: "facetV", - allowNone: true, - signals: [ - (0, _constants.SignalNames).FacetVBins - ] - }, - ], - signals: [ - (0, _constants.SignalNames).TreeMapMethod - ] - } - }; -}; +var _constants = require("../constants"); -},{"../constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"h5A6O":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getFacetLayout", ()=>getFacetLayout); +},{"../constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5wBmI":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _defaults = require("./defaults"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getFacetLayout", ()=>getFacetLayout); +var _defaults = require("./defaults"); function getFacetLayout(facetStyle, facetColumn, facetVColumn, axisTextColor) { let layoutPair; const groupby = facetColumn; @@ -2134,7 +2141,7 @@ function getFacetLayout(facetStyle, facetColumn, facetVColumn, axisTextColor) { }; let facetPadding; switch(facetStyle){ - case "cross": + case 'cross': { const props = { axisTextColor, @@ -2143,7 +2150,7 @@ function getFacetLayout(facetStyle, facetColumn, facetVColumn, axisTextColor) { groupbyY: facetVColumn }; layoutPair = { - layoutType: "Cross", + layoutType: 'Cross', props }; facetPadding = { @@ -2155,17 +2162,17 @@ function getFacetLayout(facetStyle, facetColumn, facetVColumn, axisTextColor) { plotPadding.x = (0, _defaults.facetPaddingRight); break; } - case "wrap": + case 'wrap': default: { - const props1 = { + const props = { axisTextColor, cellTitles: true, groupby }; layoutPair = { - layoutType: "Wrap", - props: props1 + layoutType: 'Wrap', + props }; facetPadding = { bottom: (0, _defaults.facetPaddingBottom), @@ -2185,13 +2192,13 @@ function getFacetLayout(facetStyle, facetColumn, facetVColumn, axisTextColor) { }; } -},{"./defaults":"dX5m9","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ckVYZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./defaults":"jpVjH","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aEiKQ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "getColumnsFromData", ()=>(0, _dataInference.getColumnsFromData)); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getColumnsFromData", ()=>(0, _dataInference.getColumnsFromData)); parcelHelpers.export(exports, "getStats", ()=>(0, _dataInference.getStats)); parcelHelpers.export(exports, "inferAll", ()=>(0, _dataInference.inferAll)); /** @@ -2218,30 +2225,32 @@ function getSpecColumns(insight, columns) { }; } -},{"@msrvida/data-inference":"1shHZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1shHZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@msrvida/data-inference":"wjoyE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"wjoyE":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _colorJs = require("./color.js"); -parcelHelpers.exportAll(_colorJs, exports); -var _inferenceJs = require("./inference.js"); -parcelHelpers.exportAll(_inferenceJs, exports); -var _numericJs = require("./numeric.js"); -parcelHelpers.exportAll(_numericJs, exports); -var _statsJs = require("./stats.js"); -parcelHelpers.exportAll(_statsJs, exports); - -},{"./color.js":"gEjqa","./inference.js":"dOIKW","./numeric.js":"fN5Zu","./stats.js":"etRKd","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gEjqa":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "isColor", ()=>isColor); -parcelHelpers.export(exports, "checkIsColorData", ()=>checkIsColorData); +var _color = require("./color"); +parcelHelpers.exportAll(_color, exports); +var _inference = require("./inference"); +parcelHelpers.exportAll(_inference, exports); +var _numeric = require("./numeric"); +parcelHelpers.exportAll(_numeric, exports); +var _stats = require("./stats"); +parcelHelpers.exportAll(_stats, exports); +var _summary = require("./summary"); +parcelHelpers.exportAll(_summary, exports); + +},{"./color":"jS4V7","./inference":"2vdcV","./numeric":"hDLgJ","./stats":"jRSDf","./summary":"4Nkk9","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jS4V7":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _d3Color = require("d3-color"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "isColor", ()=>isColor); +parcelHelpers.export(exports, "checkIsColorData", ()=>checkIsColorData); +var _d3Color = require("d3-color"); function isColor(cssColorSpecifier) { return !!(0, _d3Color.color)(cssColorSpecifier); } @@ -2257,7 +2266,7 @@ function checkIsColorData(data, column) { column.isColorData = true; } -},{"d3-color":"88mW0","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"88mW0":[function(require,module,exports) { +},{"d3-color":"37LNF","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"37LNF":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "color", ()=>(0, _colorJsDefault.default)); @@ -2275,12 +2284,13 @@ var _labJsDefault = parcelHelpers.interopDefault(_labJs); var _cubehelixJs = require("./cubehelix.js"); var _cubehelixJsDefault = parcelHelpers.interopDefault(_cubehelixJs); -},{"./color.js":"e6AhB","./lab.js":false,"./cubehelix.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"e6AhB":[function(require,module,exports) { +},{"./color.js":"1ttKl","./lab.js":"1NJbB","./cubehelix.js":"ddL6Z","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1ttKl":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "Color", ()=>Color); parcelHelpers.export(exports, "darker", ()=>darker); parcelHelpers.export(exports, "brighter", ()=>brighter); +parcelHelpers.export(exports, "default", ()=>color); parcelHelpers.export(exports, "rgbConvert", ()=>rgbConvert); parcelHelpers.export(exports, "rgb", ()=>rgb); parcelHelpers.export(exports, "Rgb", ()=>Rgb); @@ -2485,7 +2495,6 @@ function color(format) { : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; } -exports.default = color; function rgbn(n) { return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); } @@ -2618,81 +2627,231 @@ function clampt(value) { return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; } -},{"./define.js":"97GEP","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"97GEP":[function(require,module,exports) { +},{"./define.js":"kwMap","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kwMap":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(constructor, factory, prototype) { + constructor.prototype = factory.prototype = prototype; + prototype.constructor = constructor; + }); parcelHelpers.export(exports, "extend", ()=>extend); -exports.default = function(constructor, factory, prototype) { - constructor.prototype = factory.prototype = prototype; - prototype.constructor = constructor; -}; function extend(parent, definition) { var prototype = Object.create(parent.prototype); for(var key in definition)prototype[key] = definition[key]; return prototype; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dOIKW":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1NJbB":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Derive column metadata from the data array. - * @param data Array of data objects. - */ parcelHelpers.export(exports, "getColumnsFromData", ()=>getColumnsFromData); -/** - * Populate columns with type inferences and stats. - * @param columns Array of columns. - * @param data Array of data objects. - */ parcelHelpers.export(exports, "inferAll", ()=>inferAll); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _colorJs = require("./color.js"); -var _numericJs = require("./numeric.js"); -var _statsJs = require("./stats.js"); -function getColumnsFromData(inferTypesFn, data, columnTypes) { - const sample = data[0]; - const fields = sample ? Object.keys(sample) : []; - const inferences = Object.assign(Object.assign({}, inferTypesFn(data, fields)), columnTypes); - const columns = fields.map((name)=>{ - const column = { - name, - type: inferences[name] - }; - return column; - }); - inferAll(columns, data); - return columns; -} -function inferAll(columns, data) { - columns.forEach((column)=>{ - if (column) { - if (typeof column.quantitative !== "boolean") column.quantitative = (0, _numericJs.isQuantitative)(column); - if (!column.stats) column.stats = (0, _statsJs.getStats)(data, column); - // hex codes, ex. #003300, are parsed as dates - if ((column.type === "date" || column.type === "string") && typeof column.isColorData !== "boolean") (0, _colorJs.checkIsColorData)(data, column); - } - }); +parcelHelpers.export(exports, "gray", ()=>gray); +parcelHelpers.export(exports, "default", ()=>lab); +parcelHelpers.export(exports, "Lab", ()=>Lab); +parcelHelpers.export(exports, "lch", ()=>lch); +parcelHelpers.export(exports, "hcl", ()=>hcl); +parcelHelpers.export(exports, "Hcl", ()=>Hcl); +var _defineJs = require("./define.js"); +var _defineJsDefault = parcelHelpers.interopDefault(_defineJs); +var _colorJs = require("./color.js"); +var _mathJs = require("./math.js"); +// https://observablehq.com/@mbostock/lab-and-rgb +const K = 18, Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1; +function labConvert(o) { + if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); + if (o instanceof Hcl) return hcl2lab(o); + if (!(o instanceof (0, _colorJs.Rgb))) o = (0, _colorJs.rgbConvert)(o); + var r = rgb2lrgb(o.r), g = rgb2lrgb(o.g), b = rgb2lrgb(o.b), y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; + else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } + return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); } - -},{"./color.js":"gEjqa","./numeric.js":"fN5Zu","./stats.js":"etRKd","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fN5Zu":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ parcelHelpers.export(exports, "isQuantitative", ()=>isQuantitative); -parcelHelpers.export(exports, "detectNegative", ()=>detectNegative); -parcelHelpers.export(exports, "detectSequentialColumn", ()=>detectSequentialColumn); -function isQuantitative(column) { - return column.type === "number" || column.type === "integer"; +function gray(l, opacity) { + return new Lab(l, 0, 0, opacity == null ? 1 : opacity); } -function detectNegative(columnName, data) { - for(let i = 1; i < data.length; i++){ - const value = columnName == null ? data[i] : data[i][columnName]; - if (value < 0) return true; - } - return false; +function lab(l, a, b, opacity) { + return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); +} +function Lab(l, a, b, opacity) { + this.l = +l; + this.a = +a; + this.b = +b; + this.opacity = +opacity; +} +(0, _defineJsDefault.default)(Lab, lab, (0, _defineJs.extend)((0, _colorJs.Color), { + brighter (k) { + return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + darker (k) { + return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + rgb () { + var y = (this.l + 16) / 116, x = isNaN(this.a) ? y : y + this.a / 500, z = isNaN(this.b) ? y : y - this.b / 200; + x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); + z = Zn * lab2xyz(z); + return new (0, _colorJs.Rgb)(lrgb2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), lrgb2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity); + } +})); +function xyz2lab(t) { + return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0; +} +function lab2xyz(t) { + return t > t1 ? t * t * t : t2 * (t - t0); +} +function lrgb2rgb(x) { + return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); +} +function rgb2lrgb(x) { + return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); +} +function hclConvert(o) { + if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); + if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); + var h = Math.atan2(o.b, o.a) * (0, _mathJs.degrees); + return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); +} +function lch(l, c, h, opacity) { + return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} +function hcl(h, c, l, opacity) { + return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} +function Hcl(h, c, l, opacity) { + this.h = +h; + this.c = +c; + this.l = +l; + this.opacity = +opacity; +} +function hcl2lab(o) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); + var h = o.h * (0, _mathJs.radians); + return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); +} +(0, _defineJsDefault.default)(Hcl, hcl, (0, _defineJs.extend)((0, _colorJs.Color), { + brighter (k) { + return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); + }, + darker (k) { + return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); + }, + rgb () { + return hcl2lab(this).rgb(); + } +})); + +},{"./define.js":"kwMap","./color.js":"1ttKl","./math.js":"k7vm2","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"k7vm2":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "radians", ()=>radians); +parcelHelpers.export(exports, "degrees", ()=>degrees); +const radians = Math.PI / 180; +const degrees = 180 / Math.PI; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ddL6Z":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>cubehelix); +parcelHelpers.export(exports, "Cubehelix", ()=>Cubehelix); +var _defineJs = require("./define.js"); +var _defineJsDefault = parcelHelpers.interopDefault(_defineJs); +var _colorJs = require("./color.js"); +var _mathJs = require("./math.js"); +var A = -0.14861, B = 1.78277, C = -0.29227, D = -0.90649, E = 1.97294, ED = E * D, EB = E * B, BC_DA = B * C - D * A; +function cubehelixConvert(o) { + if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity); + if (!(o instanceof (0, _colorJs.Rgb))) o = (0, _colorJs.rgbConvert)(o); + var r = o.r / 255, g = o.g / 255, b = o.b / 255, l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB), bl = b - l, k = (E * (g - l) - C * bl) / D, s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), h = s ? Math.atan2(k, bl) * (0, _mathJs.degrees) - 120 : NaN; + return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity); +} +function cubehelix(h, s, l, opacity) { + return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity); +} +function Cubehelix(h, s, l, opacity) { + this.h = +h; + this.s = +s; + this.l = +l; + this.opacity = +opacity; +} +(0, _defineJsDefault.default)(Cubehelix, cubehelix, (0, _defineJs.extend)((0, _colorJs.Color), { + brighter (k) { + k = k == null ? (0, _colorJs.brighter) : Math.pow((0, _colorJs.brighter), k); + return new Cubehelix(this.h, this.s, this.l * k, this.opacity); + }, + darker (k) { + k = k == null ? (0, _colorJs.darker) : Math.pow((0, _colorJs.darker), k); + return new Cubehelix(this.h, this.s, this.l * k, this.opacity); + }, + rgb () { + var h = isNaN(this.h) ? 0 : (this.h + 120) * (0, _mathJs.radians), l = +this.l, a = isNaN(this.s) ? 0 : this.s * l * (1 - l), cosh = Math.cos(h), sinh = Math.sin(h); + return new (0, _colorJs.Rgb)(255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity); + } +})); + +},{"./define.js":"kwMap","./color.js":"1ttKl","./math.js":"k7vm2","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2vdcV":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +/** + * Derive column metadata from the data array. + * @param data Array of data objects. + */ parcelHelpers.export(exports, "getColumnsFromData", ()=>getColumnsFromData); +/** + * Populate columns with type inferences and stats. + * @param columns Array of columns. + * @param data Array of data objects. + */ parcelHelpers.export(exports, "inferAll", ()=>inferAll); +var _color = require("./color"); +var _numeric = require("./numeric"); +var _stats = require("./stats"); +function getColumnsFromData(inferTypesFn, data, columnTypes) { + const sample = data[0]; + const fields = sample ? Object.keys(sample) : []; + const inferences = Object.assign(Object.assign({}, inferTypesFn(data, fields)), columnTypes); + const columns = fields.map((name)=>{ + const column = { + name, + type: inferences[name] + }; + return column; + }); + inferAll(columns, data); + return columns; +} +function inferAll(columns, data) { + columns.forEach((column)=>{ + if (column) { + if (typeof column.quantitative !== 'boolean') column.quantitative = (0, _numeric.isQuantitative)(column); + if (!column.stats) column.stats = (0, _stats.getStats)(data, column); + // hex codes, ex. #003300, are parsed as dates + if ((column.type === 'date' || column.type === 'string') && typeof column.isColorData !== 'boolean') (0, _color.checkIsColorData)(data, column); + } + }); +} + +},{"./color":"jS4V7","./numeric":"hDLgJ","./stats":"jRSDf","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hDLgJ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "isQuantitative", ()=>isQuantitative); +parcelHelpers.export(exports, "detectNegative", ()=>detectNegative); +parcelHelpers.export(exports, "detectSequentialColumn", ()=>detectSequentialColumn); +function isQuantitative(column) { + return column.type === 'number' || column.type === 'integer'; +} +function detectNegative(columnName, data) { + for(let i = 1; i < data.length; i++){ + const value = columnName == null ? data[i] : data[i][columnName]; + if (value < 0) return true; + } + return false; } function detectSequentialColumn(columnName, data) { if (data.length < 2) return false; @@ -2704,15 +2863,15 @@ function detectSequentialColumn(columnName, data) { return true; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"etRKd":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getStats", ()=>getStats); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jRSDf":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _colorJs = require("./color.js"); -var _numericJs = require("./numeric.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getStats", ()=>getStats); +var _color = require("./color"); +var _numeric = require("./numeric"); function getStats(data, ...args) { let columnName; let columnType; @@ -2732,15 +2891,20 @@ function getStats(data, ...args) { } const distinctMap = {}; const stats = { + nonNull: 0, distinctValueCount: null, max: null, mean: null, min: null }; + const columnIsString = columnType === 'string'; let sum = 0; for(let i = 0; i < data.length; i++){ const row = data[i]; const value = columnName == null ? row : row[columnName]; + if (columnIsString) { + if (value !== '') stats.nonNull++; + } else if (value != null) stats.nonNull++; const num = +value; distinctMap[value] = true; if (!isNaN(num)) { @@ -2749,12 +2913,12 @@ function getStats(data, ...args) { sum += num; } // hex codes, ex. #003300, are parsed as dates - if ((columnType === "date" || columnType === "string") && !stats.hasColorData && (0, _colorJs.isColor)(value)) stats.hasColorData = true; + if ((columnType === 'date' || columnIsString) && !stats.hasColorData && (0, _color.isColor)(value)) stats.hasColorData = true; } if (columnQuantitative) { stats.mean = data.length > 0 && sum / data.length; - stats.hasNegative = (0, _numericJs.detectNegative)(columnName, data); - if (columnType === "integer") stats.isSequential = (0, _numericJs.detectSequentialColumn)(columnName, data); + stats.hasNegative = (0, _numeric.detectNegative)(columnName, data); + if (columnType === 'integer') stats.isSequential = (0, _numeric.detectSequentialColumn)(columnName, data); } const distinctValues = Object.keys(distinctMap); if (distinctValuesCallback) { @@ -2765,14 +2929,165 @@ function getStats(data, ...args) { return stats; } -},{"./color.js":"gEjqa","./numeric.js":"fN5Zu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"a5Xh1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./color":"jS4V7","./numeric":"hDLgJ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4Nkk9":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SpecBuilder", ()=>SpecBuilder); +parcelHelpers.export(exports, "pandasSimulation", ()=>pandasSimulation); +class Table { + constructor(columns, rows, maxWidth = 80, underlineHeaders = false, align = 'right'){ + this.columns = columns; + this.rows = rows; + this.maxWidth = maxWidth; + this.underlineHeaders = underlineHeaders; + this.align = align; + // Calculate maximum width for each column + this.columnWidths = this.columns.map((col, idx)=>Math.max(col.length, ...this.rows.map((row)=>{ + var _a; + return ((_a = row[idx]) === null || _a === void 0 ? void 0 : _a.length) || 0; + }))); + } + createSpaces(num) { + return ' '.repeat(num); + } + groupColumns() { + let cumulativeWidth = 0; + const columnGroups = []; + let currentGroup = []; + this.columns.forEach((col, idx)=>{ + const columnSpace = this.columnWidths[idx] + 1; // account for one space between columns + if (cumulativeWidth + columnSpace > this.maxWidth && currentGroup.length > 0) { + columnGroups.push(currentGroup); + cumulativeWidth = columnSpace; + currentGroup = [ + col + ]; + } else { + cumulativeWidth += columnSpace; + currentGroup.push(col); + } + }); + if (currentGroup.length > 0) columnGroups.push(currentGroup); + return columnGroups; + } + formatRow(row, group) { + return group.map((col)=>{ + const idx = this.columns.indexOf(col); + const cellValue = row[idx] == null ? '' : row[idx].toString(); + return this.align === 'right' ? cellValue.padStart(this.columnWidths[idx], ' ') : cellValue.padEnd(this.columnWidths[idx], ' '); + }).join(this.createSpaces(1)); + } + formatHeader(group) { + return group.map((col)=>{ + const idx = this.columns.indexOf(col); + return this.align === 'right' ? col.padStart(this.columnWidths[idx], ' ') : col.padEnd(this.columnWidths[idx], ' '); + }).join(this.createSpaces(1)); + } + underlineHeader(group) { + return group.map((col)=>'-'.repeat(this.columnWidths[this.columns.indexOf(col)])).join(this.createSpaces(1)); + } + render() { + const output = []; + const columnGroups = this.groupColumns(); + columnGroups.forEach((group, groupIndex)=>{ + const headerRow = this.formatHeader(group); + let section = headerRow + (groupIndex < columnGroups.length - 1 ? ' \\' : '') + '\n'; + if (this.underlineHeaders) section += this.underlineHeader(group) + '\n'; + this.rows.forEach((row)=>{ + section += this.formatRow(row, group) + '\n'; + }); + output.push(section); + if (groupIndex < columnGroups.length - 1) output.push('\n'); + }); + return output.join(''); + } +} +var pandasSimulation; +(function(pandasSimulation) { + // Mapping TypeScript types to Python-like dtypes + const typeMapping = { + boolean: 'bool', + number: 'float64', + date: 'datetime64[ns]', + string: 'object', + integer: 'int64' + }; + function head(columns, data, maxWidth = 80) { + const numRows = 5; // Number of rows as in `head(5)` from pandas + const top = data.slice(0, numRows); // Get the top `numRows` rows + // Create a "fake" row number column + const rowNumbers = Array.from({ + length: numRows + }, (_, i)=>(i + 1).toString()); + // Extract column names and rows for the table + const columnNames = [ + '' + ].concat(columns.map((col)=>col.name)); + const rows = top.map((row, i)=>[ + rowNumbers[i] + ].concat(columns.map((col)=>{ + var _a; + return ((_a = row[col.name]) === null || _a === void 0 ? void 0 : _a.toString()) || ''; + }))); + // Create and render the table with right alignment + const table = new Table(columnNames, rows, maxWidth, false, 'right'); // Right alignment + return table.render(); + } + pandasSimulation.head = head; + function info(columns, data, maxWidth = 80) { + const numRows = data.length; + const output = []; + // Summary header + output.push(''); + output.push(`Index: ${numRows} entries, 0 to ${numRows - 1}`); + output.push(`Data columns (total ${columns.length} columns):\n`); + // Column headers and details + const columnHeaders = [ + '#', + 'Column', + 'Non-Null Count', + 'Dtype' + ]; + const rows = columns.map((col, idx)=>{ + const nonNullCount = col.stats.nonNull.toString(); + const dtype = typeMapping[col.type] || 'unknown'; + return [ + idx.toString(), + col.name, + `${nonNullCount} non-null`, + dtype + ]; + }); + // Create and render the table with left alignment and header underline + const table = new Table(columnHeaders, rows, maxWidth, true, 'left'); // Left alignment + output.push(table.render()); + // Memory usage estimation + const memoryUsage = columns.reduce((total, col)=>{ + var _a; + const exampleValue = (_a = data.find((row)=>row[col.name] != null)) === null || _a === void 0 ? void 0 : _a[col.name]; + if (exampleValue == null) return total; + const size = new Blob([ + exampleValue.toString() + ]).size; + return total + size * numRows; + }, 0); + output.push(`\ndtypes: ${columns.filter((col)=>col.type === 'number').length} float64, ` + `${columns.filter((col)=>col.type === 'integer').length} int64, ` + `${columns.filter((col)=>col.type === 'string').length} object`); + output.push(`memory usage: ${(memoryUsage / 1024).toFixed(1)} KB`); + return output.join('\n'); + } + pandasSimulation.info = info; +})(pandasSimulation || (pandasSimulation = {})); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h5flx":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _axes = require("./axes"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "SpecBuilder", ()=>SpecBuilder); +var _axes = require("./axes"); var _color = require("./color"); var _constants = require("./constants"); var _defaults = require("./defaults"); @@ -2790,11 +3105,11 @@ class SpecBuilder { this.globalSignals = { facetAxesAdjustX: { name: (0, _constants.SignalNames).FacetAxesAdjustX, - update: props.facetLayout && props.collapseFacetAxes ? (0, _defaults.facetPaddingLeft).toString() : "0" + update: props.facetLayout && props.collapseFacetAxes ? (0, _defaults.facetPaddingLeft).toString() : '0' }, facetAxesAdjustY: { name: (0, _constants.SignalNames).FacetAxesAdjustY, - update: props.facetLayout && props.collapseFacetAxes ? (0, _defaults.facetPaddingBottom).toString() : "0" + update: props.facetLayout && props.collapseFacetAxes ? (0, _defaults.facetPaddingBottom).toString() : '0' }, minCellWidth: { name: (0, _constants.SignalNames).MinCellWidth, @@ -2806,19 +3121,19 @@ class SpecBuilder { }, plotOffsetLeft: { name: (0, _constants.SignalNames).PlotOffsetLeft, - update: "0" + update: '0' }, plotOffsetTop: { name: (0, _constants.SignalNames).PlotOffsetTop, - update: "0" + update: '0' }, plotOffsetBottom: { name: (0, _constants.SignalNames).PlotOffsetBottom, - update: "0" + update: '0' }, plotOffsetRight: { name: (0, _constants.SignalNames).PlotOffsetRight, - update: "0" + update: '0' }, plotHeightOut: { name: (0, _constants.SignalNames).PlotHeightOut, @@ -2831,16 +3146,16 @@ class SpecBuilder { }; } validate() { - const { specContext } = this; - const { specCapabilities } = this.props; - const { roles } = specCapabilities; + const { specContext } = this; + const { specCapabilities } = this.props; + const { roles } = specCapabilities; const required = roles.filter((r)=>{ switch(typeof r.allowNone){ - case "boolean": + case 'boolean': return !r.allowNone; - case "undefined": + case 'undefined': return true; - case "function": + case 'function': return !r.allowNone(specContext); } }); @@ -2852,24 +3167,24 @@ class SpecBuilder { if (specContext.specColumns[r.role] && !specContext.specColumns[r.role].quantitative) return `Field ${r.role} must be quantitative.`; else return null; })).filter(Boolean); - const { backgroundImage } = specContext.insight; - if (backgroundImage && !backgroundImage.extents) errors.push("BackgroundImage must have extents."); + const { backgroundImage } = specContext.insight; + if (backgroundImage && !backgroundImage.extents) errors.push('BackgroundImage must have extents.'); return errors; } build() { var _a, _b; - const { globalSignals , specContext } = this; - const { facetLayout , specCapabilities } = this.props; - const { insight , specColumns , specViewOptions } = specContext; - const dataName = "data_source"; - const { vegaSpec , groupMark } = this.initSpec(dataName); - const { topColorField , colorDataName } = (0, _color.addColor)({ + const { globalSignals, specContext } = this; + const { facetLayout, specCapabilities } = this.props; + const { insight, specColumns, specViewOptions } = specContext; + const dataName = 'data_source'; + const { vegaSpec, groupMark } = this.initSpec(dataName); + const { topColorField, colorDataName } = (0, _color.addColor)({ scope: vegaSpec, dataName, specContext, scaleName: (0, _constants.ScaleNames).Color, - legendDataName: "data_legend", - topLookupName: "data_topcolorlookup", + legendDataName: 'data_legend', + topLookupName: 'data_topcolorlookup', colorReverseSignalName: (0, _constants.SignalNames).ColorReverse }); const globalScope = new (0, _globalScope.GlobalScope)({ @@ -2892,7 +3207,7 @@ class SpecBuilder { globalSignals.plotOffsetTop.update = `${facetLayout.plotPadding.y}`; globalSignals.plotOffsetRight.update = `${facetLayout.plotPadding.x}`; } - const { firstScope , finalScope , specResult , allGlobalScales , allEncodingRules , } = this.iterateLayouts(globalScope, (i, innerScope)=>{ + const { firstScope, finalScope, specResult, allGlobalScales, allEncodingRules } = this.iterateLayouts(globalScope, (i, innerScope)=>{ if (facetLayout && i === 0) globalScope.zSize = innerScope.offsets.h; }); if (specResult) return specResult; @@ -2900,8 +3215,8 @@ class SpecBuilder { const plotHeightOut = globalSignals.plotHeightOut.name; const plotWidthOut = globalSignals.plotWidthOut.name; const colTitleScale = { - type: "linear", - name: "scale_facet_col_title", + type: 'linear', + name: 'scale_facet_col_title', domain: [ 0, 1 @@ -2914,8 +3229,8 @@ class SpecBuilder { ] }; const rowTitleScale = { - type: "linear", - name: "scale_facet_row_title", + type: 'linear', + name: 'scale_facet_row_title', domain: [ 0, 1 @@ -2942,8 +3257,8 @@ class SpecBuilder { facetScope, colTitleScale, rowTitleScale, - colSeqName: "data_FacetCellColTitles", - rowSeqName: "data_FacetCellRowTitles" + colSeqName: 'data_FacetCellColTitles', + rowSeqName: 'data_FacetCellRowTitles' }) : { main: [ { @@ -2974,8 +3289,8 @@ class SpecBuilder { y: (0, _defaults.axesTitlePaddingY) }, labelBaseline: { - x: "top", - y: "middle" + x: 'top', + y: 'middle' }, specColumns, specViewOptions, @@ -2986,23 +3301,23 @@ class SpecBuilder { } //add mark to the final scope if (finalScope.mark) { - const { update } = finalScope.mark.encode; - const outputDataName = "output"; + const { update } = finalScope.mark.encode; + const outputDataName = 'output'; finalScope.mark.from.data = outputDataName; (0, _scope.addData)(globalScope.markGroup, { name: outputDataName, source: globalScope.markDataName, transform: [ { - type: "formula", + type: 'formula', expr: finalScope.offsets.x, as: (0, _constants.FieldNames).OffsetX }, { - type: "formula", + type: 'formula', expr: finalScope.offsets.y, as: (0, _constants.FieldNames).OffsetY - }, + } ] }); update.x = { @@ -3021,8 +3336,8 @@ class SpecBuilder { arrIn.forEach((rule)=>arrOut.push(rule)); arrOut.push(value); } else { - const arrOut1 = update[key]; - arrIn.forEach((rule)=>arrOut1.unshift(rule)); + const arrOut = update[key]; + arrIn.forEach((rule)=>arrOut.unshift(rule)); } } }); @@ -3035,12 +3350,12 @@ class SpecBuilder { }; } initSpec(dataName) { - const { globalSignals } = this; - const { facetAxesAdjustX , facetAxesAdjustY , minCellWidth , minCellHeight , plotOffsetLeft , plotOffsetBottom , plotOffsetTop , plotOffsetRight , plotHeightOut , plotWidthOut } = globalSignals; - const { specContext } = this; - const { insight } = specContext; + const { globalSignals } = this; + const { facetAxesAdjustX, facetAxesAdjustY, minCellWidth, minCellHeight, plotOffsetLeft, plotOffsetBottom, plotOffsetTop, plotOffsetRight, plotHeightOut, plotWidthOut } = globalSignals; + const { specContext } = this; + const { insight } = specContext; const groupMark = { - type: "group", + type: 'group', //style: 'cell', encode: { update: { @@ -3059,9 +3374,9 @@ class SpecBuilder { } } }; - const inputDataname = "input"; + const inputDataname = 'input'; const vegaSpec = { - $schema: "https://vega.github.io/schema/vega/v5.json", + $schema: 'https://vega.github.io/schema/vega/v5.json', //style: 'cell', data: [ { @@ -3104,13 +3419,13 @@ class SpecBuilder { plotHeightOut, plotWidthOut, { - name: "height", + name: 'height', update: `${(0, _constants.SignalNames).PlotOffsetTop} + ${(0, _constants.SignalNames).PlotHeightOut} + ${(0, _constants.SignalNames).PlotOffsetBottom} - ${(0, _constants.SignalNames).FacetAxesAdjustY}` }, { - name: "width", + name: 'width', update: `${(0, _constants.SignalNames).PlotWidthOut} + ${(0, _constants.SignalNames).PlotOffsetLeft} + ${(0, _constants.SignalNames).PlotOffsetRight}` - }, + } ]) }; return { @@ -3127,7 +3442,7 @@ class SpecBuilder { let firstScope; let childScope; const groupings = []; - const { layouts , specCapabilities } = this.props; + const { layouts, specCapabilities } = this.props; const allGlobalScales = []; const allEncodingRules = []; for(let i = 0; i < layouts.length; i++){ @@ -3150,9 +3465,9 @@ class SpecBuilder { fieldOps: [ { field: null, - op: "count", + op: 'count', as: (0, _constants.FieldNames).Count - }, + } ] }); const sumOp = layout.getAggregateSumOp(); @@ -3182,7 +3497,7 @@ class SpecBuilder { }; } createLayout(layoutPair, buildProps) { - const { layoutType , props } = layoutPair; + const { layoutType, props } = layoutPair; const layoutBuildProps = Object.assign(Object.assign({}, props), buildProps); const layoutClass = (0, _index.layoutClasses)[layoutType]; const layout = new layoutClass(layoutBuildProps); @@ -3191,30 +3506,30 @@ class SpecBuilder { } } -},{"./axes":"aRtOw","./color":"9HcVa","./constants":"6pnJw","./defaults":"dX5m9","./facetTitle":"7cHD5","./fill":"dEsIN","./globalScope":"82cS5","./scope":"4pyrl","./signals":"3OaQI","./layouts/index":"2Xxpg","./image":"l00jx","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aRtOw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "addGlobalAxes", ()=>addGlobalAxes); +},{"./axes":"iTLIR","./color":"gKKJ5","./constants":"22TRA","./defaults":"jpVjH","./facetTitle":"a1RbZ","./fill":"aaLsK","./globalScope":"iaGl2","./scope":"9ojhQ","./signals":"Bq6BR","./layouts/index":"i7uNc","./image":"akfUH","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iTLIR":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "addGlobalAxes", ()=>addGlobalAxes); +var _constants = require("./constants"); var _defaults = require("./defaults"); var _scope = require("./scope"); function addGlobalAxes(props) { - const { axesOffsets , axisScales , axesScopes , axesTitlePadding , allGlobalScales , globalScope , labelBaseline , plotOffsetSignals , specColumns , specViewOptions } = props; - const { scope } = globalScope; + const { axesOffsets, axisScales, axesScopes, axesTitlePadding, allGlobalScales, globalScope, labelBaseline, plotOffsetSignals, specColumns, specViewOptions } = props; + const { scope } = globalScope; allGlobalScales.forEach((globalScales)=>{ - const { scales } = globalScales; + const { scales } = globalScales; for(const xyz in scales){ const _scales = scales[xyz]; if (_scales) { (0, _scope.addScales)(scope, ..._scales); - let { showAxes } = globalScales; + let { showAxes } = globalScales; let zindex = undefined; - if (xyz === "z") { + if (xyz === 'z') { showAxes = false; - if (props.view === "3d" && specViewOptions.zAxisOptions && !props.hideZAxis) { + if (props.view === '3d' && specViewOptions.zAxisOptions && !props.hideZAxis) { if (specViewOptions.zAxisOptions.showZAxis) { showAxes = true; zindex = specViewOptions.zAxisOptions.zIndex; @@ -3225,12 +3540,12 @@ function addGlobalAxes(props) { const axisScale = axisScales[xyz]; if (axisScale) { const lineColor = specViewOptions.colors.axisLine; - const horizontal = xyz === "x"; + const horizontal = xyz === 'x'; const column = specColumns[xyz] || { quantitative: true }; const title = axisScale.title; - const props1 = { + const props = { title, horizontal, column, @@ -3240,13 +3555,13 @@ function addGlobalAxes(props) { labelBaseline: labelBaseline[xyz], zindex }; - axesScopes["main"].forEach((a)=>(0, _scope.addAxes)(a.scope, createAxis(Object.assign(Object.assign({}, props1), { + axesScopes['main'].forEach((a)=>(0, _scope.addAxes)(a.scope, createAxis(Object.assign(Object.assign({}, props), { scale: a.scale || _scales[0], showTitle: a.title, showLabels: a.labels, showLines: a.lines })))); - if (axesScopes[xyz]) axesScopes[xyz].forEach((a)=>(0, _scope.addAxes)(a.scope, createAxis(Object.assign(Object.assign({}, props1), { + if (axesScopes[xyz]) axesScopes[xyz].forEach((a)=>(0, _scope.addAxes)(a.scope, createAxis(Object.assign(Object.assign({}, props), { scale: a.scale || _scales[0], showTitle: a.title, showLabels: a.labels, @@ -3263,11 +3578,11 @@ function addGlobalAxes(props) { }); } function createAxis(props) { - const { column , horizontal , labelBaseline , lineColor , scale , showLabels , showTitle , showLines , specViewOptions , title , titlePadding , zindex } = props; + const { column, horizontal, labelBaseline, lineColor, scale, showLabels, showTitle, showLines, specViewOptions, title, titlePadding, zindex } = props; const axis = Object.assign(Object.assign(Object.assign(Object.assign({ zindex, scale: scale.name, - orient: horizontal ? "bottom" : "left", + orient: horizontal ? 'bottom' : 'left', domain: showLines, ticks: showLines }, showLines && { @@ -3276,7 +3591,7 @@ function createAxis(props) { tickSize: specViewOptions.tickSize }), showTitle && { title, - titleAlign: horizontal ? "left" : "right", + titleAlign: horizontal ? 'left' : 'right', titleAngle: { signal: horizontal ? (0, _constants.SignalNames).TextAngleX : (0, _constants.SignalNames).TextAngleY }, @@ -3289,7 +3604,7 @@ function createAxis(props) { }), { labels: showLabels }), showLabels && { - labelAlign: horizontal ? "left" : "right", + labelAlign: horizontal ? 'left' : 'right', labelBaseline, labelAngle: { signal: horizontal ? (0, _constants.SignalNames).TextAngleX : (0, _constants.SignalNames).TextAngleY @@ -3300,17 +3615,17 @@ function createAxis(props) { }, labelLimit: (0, _defaults.axesLabelLimit) }); - if (column.quantitative) axis.format = "~r"; + if (column.quantitative) axis.format = '~r'; return axis; } -},{"./constants":"6pnJw","./defaults":"dX5m9","./scope":"4pyrl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4pyrl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./constants":"22TRA","./defaults":"jpVjH","./scope":"9ojhQ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9ojhQ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "addAxes", ()=>addAxes); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "addAxes", ()=>addAxes); parcelHelpers.export(exports, "addData", ()=>addData); parcelHelpers.export(exports, "addMarks", ()=>addMarks); parcelHelpers.export(exports, "addScales", ()=>addScales); @@ -3362,26 +3677,26 @@ function getGroupBy(groupings) { return groupby.reduce((acc, val)=>acc.concat(val), []); } function addOffsets(...offsets) { - return offsets.filter(Boolean).join(" + "); + return offsets.filter(Boolean).join(' + '); } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9HcVa":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "addColor", ()=>addColor); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gKKJ5":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _scope = require("./scope"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "addColor", ()=>addColor); +var _scope = require("./scope"); var _scales = require("./scales"); var _signals = require("./signals"); var _constants = require("./constants"); var _legends = require("./legends"); var _top = require("./top"); function addColor(props) { - const { colorReverseSignalName , dataName , scope , legendDataName , scaleName , specContext , topLookupName } = props; + const { colorReverseSignalName, dataName, scope, legendDataName, scaleName, specContext, topLookupName } = props; let colorDataName = dataName; - const { insight , specColumns , specViewOptions } = specContext; + const { insight, specColumns, specViewOptions } = specContext; const legends = (0, _legends.getLegends)(specContext, scaleName); if (legends) scope.legends = legends; const categoricalColor = specColumns.color && !specColumns.color.quantitative; @@ -3393,7 +3708,7 @@ function addColor(props) { if (specColumns.color.quantitative) (0, _scope.addScales)(scope, (0, _scales.binnableColorScale)(scaleName, insight.colorBin, dataName, specColumns.color.name, insight.scheme)); else (0, _scope.addScales)(scope, { name: scaleName, - type: "ordinal", + type: 'ordinal', domain: { data: colorDataName, field: (0, _constants.FieldNames).TopColor, @@ -3414,21 +3729,21 @@ function addColor(props) { }; } -},{"./scope":"4pyrl","./scales":"1sFCW","./signals":"3OaQI","./constants":"6pnJw","./legends":"bzAY3","./top":"2hoZH","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1sFCW":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./scope":"9ojhQ","./scales":"feLP9","./signals":"Bq6BR","./constants":"22TRA","./legends":"7TJVK","./top":"83rkq","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"feLP9":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "linearScale", ()=>linearScale); parcelHelpers.export(exports, "pointScale", ()=>pointScale); parcelHelpers.export(exports, "binnableColorScale", ()=>binnableColorScale); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("./constants"); +var _constants = require("./constants"); var _expr = require("./expr"); function linearScale(scaleName, domain, range, reverse, zero, nice = true) { const scale = { name: scaleName, - type: "linear", + type: 'linear', range, round: true, reverse, @@ -3441,7 +3756,7 @@ function linearScale(scaleName, domain, range, reverse, zero, nice = true) { function pointScale(scaleName, data, range, field, reverse) { const scale = { name: scaleName, - type: "point", + type: 'point', range, domain: { data, @@ -3465,26 +3780,26 @@ function binnableColorScale(scaleName, colorBin, data, field, scheme) { const reverse = { signal: (0, _constants.SignalNames).ColorReverse }; - if (colorBin !== "continuous") range.count = { + if (colorBin !== 'continuous') range.count = { signal: (0, _constants.SignalNames).ColorBinCount }; switch(colorBin){ - case "continuous": + case 'continuous': { const sequentialScale = { name: scaleName, - type: "linear", + type: 'linear', domain, range, reverse }; return sequentialScale; } - case "quantile": + case 'quantile': { const quantileScale = { name: scaleName, - type: "quantile", + type: 'quantile', domain, range, reverse @@ -3495,7 +3810,7 @@ function binnableColorScale(scaleName, colorBin, data, field, scheme) { { const quantizeScale = { name: scaleName, - type: "quantize", + type: 'quantize', domain, range, reverse @@ -3505,9 +3820,7 @@ function binnableColorScale(scaleName, colorBin, data, field, scheme) { } } -},{"./constants":"6pnJw","./expr":"buVVl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"buVVl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./constants":"22TRA","./expr":"eSi6o","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eSi6o":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. @@ -3515,34 +3828,42 @@ parcelHelpers.defineInteropFlag(exports); * Make sure that the field name is accessible via Vega's Field type * https://vega.github.io/vega/docs/types/#Field * examples: "source.x", "target['x']", "[my.field]" - */ parcelHelpers.export(exports, "safeFieldName", ()=>safeFieldName); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "safeFieldName", ()=>safeFieldName); /** * Make sure the field name is usable in a Vega expression */ parcelHelpers.export(exports, "exprSafeFieldName", ()=>exprSafeFieldName); function safeFieldName(field) { - return field.replace(".", "\\.").replace("[", "\\[").replace("]", "\\]"); + return field.replace(/\\/g, '\\\\') //escape backslashes + .replace(/'/g, '\\\'') //escape single quotes + .replace(/"/g, '\\"') //escape double quotes + .replace(/\./g, '\\.') //escape periods + .replace(/\[/g, '\\[') //escape left square brackets + .replace(/\]/g, '\\]') //escape right square brackets + ; } function exprSafeFieldName(field) { //remove whitespace, period, accessors and logical modifiers - return field.replace(/[.,:;+=\-/<>{}|~!@#$%^*[\]`'"()?\s\\]/g, ""); + return field.replace(/[.,:;+=\-/<>{}|~!@#$%^*[\]`'"()?\s\\]/g, ''); } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3OaQI":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"Bq6BR":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "defaultZProportion", ()=>defaultZProportion); parcelHelpers.export(exports, "textSignals", ()=>textSignals); parcelHelpers.export(exports, "colorBinCountSignal", ()=>colorBinCountSignal); parcelHelpers.export(exports, "colorReverseSignal", ()=>colorReverseSignal); parcelHelpers.export(exports, "modifySignal", ()=>modifySignal); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("./constants"); +var _constants = require("./constants"); var _defaults = require("./defaults"); const defaultZProportion = 0.6; function textSignals(context, heightSignal) { - const { specViewOptions } = context; + const { specViewOptions } = context; const signals = [ { name: (0, _constants.SignalNames).ZProportion, @@ -3550,7 +3871,7 @@ function textSignals(context, heightSignal) { bind: { name: specViewOptions.language.zScaleProportion, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 0.1, max: 2, step: 0.1 @@ -3566,7 +3887,7 @@ function textSignals(context, heightSignal) { bind: { name: specViewOptions.language.textScaleSignal, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 0.5, max: 2, step: 0.1 @@ -3586,7 +3907,7 @@ function textSignals(context, heightSignal) { bind: { name: specViewOptions.language.xAxisTextAngleSignal, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 0, max: 90, step: 1 @@ -3598,7 +3919,7 @@ function textSignals(context, heightSignal) { bind: { name: specViewOptions.language.yAxisTextAngleSignal, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: -90, max: 0, step: 1 @@ -3610,24 +3931,24 @@ function textSignals(context, heightSignal) { bind: { name: specViewOptions.language.markOpacitySignal, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 0.1, max: 1, step: 0.05 } - }, + } ]; return signals; } function colorBinCountSignal(context) { - const { specViewOptions } = context; + const { specViewOptions } = context; const signal = { name: (0, _constants.SignalNames).ColorBinCount, value: 7, bind: { name: specViewOptions.language.colorBinCount, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 1, max: specViewOptions.maxLegends + 1, step: 1 @@ -3636,13 +3957,13 @@ function colorBinCountSignal(context) { return signal; } function colorReverseSignal(context) { - const { specViewOptions } = context; + const { specViewOptions } = context; const signal = { name: (0, _constants.SignalNames).ColorReverse, value: false, bind: { name: specViewOptions.language.colorReverse, - input: "checkbox" + input: 'checkbox' } }; return signal; @@ -3651,49 +3972,49 @@ function modifySignal(s, fn, update) { s.update = `${fn}((${s.update}), (${update}))`; } -},{"./constants":"6pnJw","./defaults":"dX5m9","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bzAY3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getLegends", ()=>getLegends); +},{"./constants":"22TRA","./defaults":"jpVjH","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7TJVK":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ function legend(column, fill) { +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getLegends", ()=>getLegends); +function legend(column, fill) { const legend = { - orient: "none", + orient: 'none', title: column.name, fill, encode: { symbols: { update: { shape: { - value: "square" + value: 'square' } } } } }; if (column.quantitative) { - legend.type = "symbol"; - legend.format = "~r"; + legend.type = 'symbol'; + legend.format = '~r'; } return legend; } function getLegends(context, fill) { - const { specColumns , insight } = context; + const { specColumns, insight } = context; if (specColumns.color && !insight.hideLegend && !insight.directColor && !specColumns.color.isColorData) return [ legend(specColumns.color, fill) ]; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2hoZH":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "topLookup", ()=>topLookup); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"83rkq":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "topLookup", ()=>topLookup); +var _constants = require("./constants"); var _expr = require("./expr"); function topLookup(column, count, source, legend, lookupName, fieldName, indexName) { const data = [ @@ -3702,24 +4023,24 @@ function topLookup(column, count, source, legend, lookupName, fieldName, indexNa source, transform: [ { - type: "aggregate", + type: 'aggregate', groupby: [ (0, _expr.safeFieldName)(column.name) ] }, { - type: "window", + type: 'window', ops: [ - "count" + 'count' ], as: [ indexName ] }, { - type: "filter", + type: 'filter', expr: `datum[${JSON.stringify(indexName)}] <= ${count}` - }, + } ] }, { @@ -3727,7 +4048,7 @@ function topLookup(column, count, source, legend, lookupName, fieldName, indexNa source, transform: [ { - type: "lookup", + type: 'lookup', from: lookupName, key: (0, _expr.safeFieldName)(column.name), fields: [ @@ -3741,28 +4062,28 @@ function topLookup(column, count, source, legend, lookupName, fieldName, indexNa ] }, { - type: "formula", + type: 'formula', expr: `datum[${JSON.stringify(fieldName)}] == null ? '${(0, _constants.Other)}' : datum[${JSON.stringify(fieldName)}]`, as: fieldName - }, + } ] - }, + } ]; return data; } -},{"./constants":"6pnJw","./expr":"buVVl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7cHD5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./constants":"22TRA","./expr":"eSi6o","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"a1RbZ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "addFacetColRowTitles", ()=>addFacetColRowTitles); parcelHelpers.export(exports, "addFacetCellTitles", ()=>addFacetCellTitles); parcelHelpers.export(exports, "addFacetAxesGroupMarks", ()=>addFacetAxesGroupMarks); parcelHelpers.export(exports, "facetRowHeaderFooter", ()=>facetRowHeaderFooter); parcelHelpers.export(exports, "facetColumnHeaderFooter", ()=>facetColumnHeaderFooter); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _scope = require("./scope"); +var _scope = require("./scope"); var _constants = require("./constants"); function addFacetColRowTitles(globalScope, colTitleSource, rowTitleSource, sizeSignals, axisTextColor) { const titleSignal = `parent[${JSON.stringify((0, _constants.FieldNames).FacetTitle)}]`; @@ -3771,14 +4092,14 @@ function addFacetColRowTitles(globalScope, colTitleSource, rowTitleSource, sizeS const row = facetRowHeaderFooter(rowTitleSource.dataName, sizeSignals, index); (0, _scope.addMarks)(globalScope, col.header, row.footer); (0, _scope.addMarks)(col.header, { - type: "text", + type: 'text', encode: { enter: { align: { - value: "center" + value: 'center' }, baseline: { - value: "middle" + value: 'middle' }, fill: { value: axisTextColor @@ -3804,14 +4125,14 @@ function addFacetColRowTitles(globalScope, colTitleSource, rowTitleSource, sizeS } }); (0, _scope.addMarks)(row.footer, { - type: "text", + type: 'text', encode: { enter: { align: { - value: "left" + value: 'left' }, baseline: { - value: "middle" + value: 'middle' }, fill: { value: axisTextColor @@ -3839,14 +4160,14 @@ function addFacetColRowTitles(globalScope, colTitleSource, rowTitleSource, sizeS } function addFacetCellTitles(scope, sizeSignals, axisTextColor) { (0, _scope.addMarks)(scope, { - type: "text", + type: 'text', encode: { enter: { align: { - value: "center" + value: 'center' }, baseline: { - value: "bottom" + value: 'bottom' }, fill: { value: axisTextColor @@ -3876,11 +4197,11 @@ function addFacetCellTitles(scope, sizeSignals, axisTextColor) { }); } function addFacetAxesGroupMarks(props) { - const { colSeqName , colTitleScale , globalScope , facetScope , plotScope , rowSeqName , rowTitleScale } = props; - const { sizeSignals } = facetScope; + const { colSeqName, colTitleScale, globalScope, facetScope, plotScope, rowSeqName, rowTitleScale } = props; + const { sizeSignals } = facetScope; const colSequence = createSequence(colSeqName, sizeSignals.colCount); const rowSequence = createSequence(rowSeqName, sizeSignals.rowCount); - const index = "datum.data"; + const index = 'datum.data'; const col = facetColumnHeaderFooter(colSeqName, sizeSignals, index); const row = facetRowHeaderFooter(rowSeqName, sizeSignals, index); (0, _scope.addData)(globalScope, colSequence, rowSequence); @@ -3893,7 +4214,7 @@ function addFacetAxesGroupMarks(props) { lines: true, labels: false, title: false - }, + } ], x: [ { @@ -3908,7 +4229,7 @@ function addFacetAxesGroupMarks(props) { lines: false, labels: false, title: true - }, + } ], y: [ { @@ -3923,7 +4244,7 @@ function addFacetAxesGroupMarks(props) { lines: false, labels: false, title: true - }, + } ] }; return map; @@ -3931,7 +4252,7 @@ function addFacetAxesGroupMarks(props) { function facetRowHeaderFooter(data, sizeSignals, index) { const rowFn = (xSignal)=>{ return { - type: "group", + type: 'group', from: { data }, @@ -3960,7 +4281,7 @@ function facetRowHeaderFooter(data, sizeSignals, index) { function facetColumnHeaderFooter(data, sizeSignals, index) { const colFn = (ySignal)=>{ return { - type: "group", + type: 'group', from: { data }, @@ -3992,28 +4313,28 @@ function createSequence(dataName, countSignal) { name: dataName, transform: [ { - type: "sequence", + type: 'sequence', start: 0, stop: { signal: countSignal } - }, + } ] }; } -},{"./scope":"4pyrl","./constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dEsIN":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "fill", ()=>fill); -parcelHelpers.export(exports, "opacity", ()=>opacity); +},{"./scope":"9ojhQ","./constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aaLsK":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "fill", ()=>fill); +parcelHelpers.export(exports, "opacity", ()=>opacity); +var _constants = require("./constants"); var _expr = require("./expr"); function fill(context, colorFieldName, scale) { - const { specColumns , insight , specViewOptions } = context; + const { specColumns, insight, specViewOptions } = context; const colorColumn = specColumns.color; return colorColumn ? colorColumn.isColorData || insight.directColor ? { field: (0, _expr.safeFieldName)(colorColumn.name) @@ -4031,26 +4352,26 @@ function opacity(context) { return result; } -},{"./constants":"6pnJw","./expr":"buVVl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"82cS5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "GlobalScope", ()=>GlobalScope); +},{"./constants":"22TRA","./expr":"eSi6o","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iaGl2":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "GlobalScope", ()=>GlobalScope); +var _constants = require("./constants"); var _scope = require("./scope"); class GlobalScope { constructor(props){ - const { dataName , markGroup , scope , signals } = props; + const { dataName, markGroup, scope, signals } = props; this.scope = scope; this._markGroup = markGroup; this.signals = signals; this.data = (0, _scope.getDataByName)(scope.data, dataName).data; this._markDataName = dataName; this.offsets = { - x: "0", - y: "0", + x: '0', + y: '0', h: (0, _constants.SignalNames).PlotHeightIn, w: (0, _constants.SignalNames).PlotWidthIn }; @@ -4074,14 +4395,14 @@ class GlobalScope { } } -},{"./constants":"6pnJw","./scope":"4pyrl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2Xxpg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "layoutClasses", ()=>layoutClasses); +},{"./constants":"22TRA","./scope":"9ojhQ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"i7uNc":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _aggregateContainer = require("./aggregateContainer"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "layoutClasses", ()=>layoutClasses); +var _aggregateContainer = require("./aggregateContainer"); var _aggregateSquare = require("./aggregateSquare"); var _band = require("./band"); var _cross = require("./cross"); @@ -4104,14 +4425,14 @@ const layoutClasses = { Wrap: (0, _wrap.Wrap) }; -},{"./aggregateContainer":"5Nm0a","./aggregateSquare":"muj1E","./band":"isnFL","./cross":"c0Nwh","./scatter":"5bRVL","./square":"4Crxy","./stack":"5OOcx","./strip":"1Kejb","./treemap":"la9W6","./wrap":"5f7cw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5Nm0a":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AggregateContainer", ()=>AggregateContainer); +},{"./aggregateContainer":"23lsA","./aggregateSquare":"ksGXP","./band":"3pFuA","./cross":"iXWbC","./scatter":"eLCwq","./square":"5vsTh","./stack":"l09WI","./strip":"7mPSq","./treemap":"caw7y","./wrap":"iDL5r","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"23lsA":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AggregateContainer", ()=>AggregateContainer); +var _layout = require("./layout"); var _constants = require("../constants"); var _expr = require("../expr"); var _scope = require("../scope"); @@ -4132,24 +4453,24 @@ class AggregateContainer extends (0, _layout.Layout) { }; } getAggregateSumOp() { - if (this.aggregation === "sum") { + if (this.aggregation === 'sum') { const fieldOp = { field: (0, _expr.safeFieldName)(this.props.sumBy.name), - op: "sum", + op: 'sum', as: (0, _constants.FieldNames).Sum }; return fieldOp; } } build() { - const { aggregation , names , props } = this; - const { dock , globalScope , groupings , niceScale , parentScope , showAxes } = props; + const { aggregation, names, props } = this; + const { dock, globalScope, groupings, niceScale, parentScope, showAxes } = props; (0, _scope.addTransforms)(globalScope.data, Object.assign(Object.assign({}, this.getTransforms(aggregation, (0, _scope.getGroupBy)(groupings))), { as: [ names.aggregateField ] }), { - type: "extent", + type: 'extent', field: (0, _expr.safeFieldName)(names.aggregateField), signal: names.globalAggregateExtentSignal }); @@ -4157,42 +4478,42 @@ class AggregateContainer extends (0, _layout.Layout) { name: props.globalAggregateMaxExtentSignal, update: `${names.globalAggregateExtentSignal}[1]` }); - const horizontal = dock === "left"; + const horizontal = dock === 'left'; const groupScaled = `scale(${JSON.stringify(names.scale)}, datum[${JSON.stringify(names.aggregateField)}])`; const offsets = { x: parentScope.offsets.x, - y: (0, _scope.addOffsets)(parentScope.offsets.y, dock === "bottom" ? groupScaled : ""), - h: horizontal ? parentScope.offsets.h : dock === "top" ? groupScaled : `${parentScope.offsets.h} - ${groupScaled}`, + y: (0, _scope.addOffsets)(parentScope.offsets.y, dock === 'bottom' ? groupScaled : ''), + h: horizontal ? parentScope.offsets.h : dock === 'top' ? groupScaled : `${parentScope.offsets.h} - ${groupScaled}`, w: horizontal ? groupScaled : parentScope.offsets.w }; const scale = { - type: "linear", + type: 'linear', name: names.scale, domain: [ 0, { signal: props.globalAggregateMaxExtentSignal - }, + } ], range: horizontal ? [ 0, { signal: parentScope.sizeSignals.layoutWidth - }, + } ] : [ { signal: parentScope.sizeSignals.layoutHeight }, - 0, + 0 ], nice: niceScale, zero: true, - reverse: dock === "top" + reverse: dock === 'top' }; const globalAggregateMaxExtentScaledValue = `scale(${JSON.stringify(names.scale)}, ${props.globalAggregateMaxExtentSignal})`; (0, _scope.addSignals)(globalScope.scope, { name: props.globalAggregateMaxExtentScaledSignal, - update: dock === "bottom" ? `${parentScope.sizeSignals.layoutHeight} - ${globalAggregateMaxExtentScaledValue}` : globalAggregateMaxExtentScaledValue + update: dock === 'bottom' ? `${parentScope.sizeSignals.layoutHeight} - ${globalAggregateMaxExtentScaledValue}` : globalAggregateMaxExtentScaledValue }); return { offsets, @@ -4231,7 +4552,7 @@ class AggregateContainer extends (0, _layout.Layout) { y: [ { test: (0, _selection.testForCollapseSelection)(), - signal: dock === "top" ? parentScope.offsets.y : (0, _scope.addOffsets)(parentScope.offsets.y, parentScope.offsets.h) + signal: dock === 'top' ? parentScope.offsets.y : (0, _scope.addOffsets)(parentScope.offsets.y, parentScope.offsets.h) } ], height: [ @@ -4245,38 +4566,38 @@ class AggregateContainer extends (0, _layout.Layout) { } getTransforms(aggregation, groupby) { const trans = { - type: "joinaggregate", + type: 'joinaggregate', groupby: groupby.map((0, _expr.safeFieldName)), ops: [ aggregation ] }; - if (aggregation === "sum") trans.fields = [ + if (aggregation === 'sum') trans.fields = [ this.props.sumBy.name ].map((0, _expr.safeFieldName)); return trans; } getAggregation() { - const { props } = this; + const { props } = this; let s; - if (props.dock === "left") s = props.axesScales.x; + if (props.dock === 'left') s = props.axesScales.x; else s = props.axesScales.y; switch(s.aggregate){ - case "sum": - return "sum"; + case 'sum': + return 'sum'; default: - return "count"; + return 'count'; } } } -},{"./layout":"eTeFq","../constants":"6pnJw","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eTeFq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./layout":"i2QIi","../constants":"22TRA","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"i2QIi":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "Layout", ()=>Layout); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Layout", ()=>Layout); class Layout { constructor(props){ this.props = props; @@ -4289,30 +4610,30 @@ class Layout { return null; } build() { - throw "Not implemented"; + throw 'Not implemented'; } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fjVfM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "testForCollapseSelection", ()=>testForCollapseSelection); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ef2qR":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "testForCollapseSelection", ()=>testForCollapseSelection); +var _constants = require("./constants"); function testForCollapseSelection() { return `datum.${(0, _constants.FieldNames).Collapsed}`; } -},{"./constants":"6pnJw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"muj1E":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AggregateSquare", ()=>AggregateSquare); +},{"./constants":"22TRA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ksGXP":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AggregateSquare", ()=>AggregateSquare); +var _layout = require("./layout"); var _expr = require("../expr"); var _scope = require("../scope"); var _selection = require("../selection"); @@ -4330,15 +4651,15 @@ class AggregateSquare extends (0, _layout.Layout) { }; } build() { - const { names , props } = this; - const { aggregation , globalScope , groupings , onBuild , parentScope } = props; - const { sizeSignals } = parentScope; + const { names, props } = this; + const { aggregation, globalScope, groupings, onBuild, parentScope } = props; + const { sizeSignals } = parentScope; (0, _scope.addTransforms)(globalScope.data, Object.assign(Object.assign({}, this.getTransforms(aggregation, (0, _scope.getGroupBy)(groupings))), { as: [ names.aggregateField ] }), { - type: "extent", + type: 'extent', field: (0, _expr.safeFieldName)(names.aggregateField), signal: names.globalAggregateExtentSignal }); @@ -4347,12 +4668,12 @@ class AggregateSquare extends (0, _layout.Layout) { const squareMaxArea = `(${[ squareMaxSide, squareMaxSide - ].join(" * ")})`; + ].join(' * ')})`; const shrinkRatio = `((${localAggregateMaxExtent}) / (${names.globalAggregateExtentSignal}[1]))`; const squareArea = `(${[ squareMaxArea, shrinkRatio - ].join(" * ")})`; + ].join(' * ')})`; const squareSide = `sqrt(${squareArea})`; const localAggregateMaxExtentScaled = squareSide; onBuild && onBuild(localAggregateMaxExtent, localAggregateMaxExtentScaled); @@ -4386,35 +4707,35 @@ class AggregateSquare extends (0, _layout.Layout) { } getTransforms(aggregation, groupby) { const trans = { - type: "joinaggregate", + type: 'joinaggregate', groupby: groupby.map((0, _expr.safeFieldName)), ops: [ aggregation ] }; - if (aggregation === "sum") trans.fields = [ + if (aggregation === 'sum') trans.fields = [ this.props.sumBy.name ].map((0, _expr.safeFieldName)); return trans; } } -},{"./layout":"eTeFq","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"isnFL":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "bandScaleLinearSuffix", ()=>bandScaleLinearSuffix); -parcelHelpers.export(exports, "Band", ()=>Band); +},{"./layout":"i2QIi","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3pFuA":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "bandScaleLinearSuffix", ()=>bandScaleLinearSuffix); +parcelHelpers.export(exports, "Band", ()=>Band); +var _layout = require("./layout"); var _bin = require("../bin"); var _expr = require("../expr"); var _scope = require("../scope"); var _selection = require("../selection"); var _signals = require("../signals"); var _scales = require("../scales"); -const bandScaleLinearSuffix = "_linear"; +const bandScaleLinearSuffix = '_linear'; class Band extends (0, _layout.Layout) { constructor(props){ super(props); @@ -4432,8 +4753,8 @@ class Band extends (0, _layout.Layout) { return this.bin.fields; } build() { - const { bin , names , props } = this; - const { globalScope , minBandWidth , orientation , parentScope , showAxes } = props; + const { bin, names, props } = this; + const { globalScope, minBandWidth, orientation, parentScope, showAxes } = props; const binField = bin.fields[0]; if (bin.native === false) { (0, _scope.addSignals)(globalScope.scope, ...bin.signals); @@ -4446,17 +4767,17 @@ class Band extends (0, _layout.Layout) { source: bin.fullScaleDataname, transform: [ { - type: "aggregate", + type: 'aggregate', groupby: this.getGrouping().map((0, _expr.safeFieldName)), ops: [ - "count" + 'count' ] - }, + } ] }); - const horizontal = orientation === "horizontal"; + const horizontal = orientation === 'horizontal'; const minCellSignal = horizontal ? globalScope.signals.minCellHeight : globalScope.signals.minCellWidth; - (0, _signals.modifySignal)(minCellSignal, "max", `length(data(${JSON.stringify(names.accumulative)})) * ${minBandWidth}`); + (0, _signals.modifySignal)(minCellSignal, 'max', `length(data(${JSON.stringify(names.accumulative)})) * ${minBandWidth}`); (0, _scope.addSignals)(globalScope.scope, { name: names.bandWidth, update: `bandwidth(${JSON.stringify(horizontal ? names.yScale : names.xScale)})` @@ -4472,26 +4793,26 @@ class Band extends (0, _layout.Layout) { { test: (0, _selection.testForCollapseSelection)(), signal: parentScope.offsets.x - }, + } ], width: [ { test: (0, _selection.testForCollapseSelection)(), value: 0 - }, + } ] } : { y: [ { test: (0, _selection.testForCollapseSelection)(), signal: (0, _scope.addOffsets)(parentScope.offsets.y, parentScope.offsets.h) - }, + } ], height: [ { test: (0, _selection.testForCollapseSelection)(), value: 0 - }, + } ] }; return { @@ -4518,28 +4839,28 @@ class Band extends (0, _layout.Layout) { }; } getOffset(horizontal, binField) { - const { names , props } = this; - const { parentScope } = props; + const { names, props } = this; + const { parentScope } = props; return { - x: (0, _scope.addOffsets)(parentScope.offsets.x, horizontal ? "" : `scale(${JSON.stringify(names.xScale)}, datum[${JSON.stringify(binField)}])`), - y: (0, _scope.addOffsets)(parentScope.offsets.y, horizontal ? `scale(${JSON.stringify(names.yScale)}, datum[${JSON.stringify(binField)}])` : ""), + x: (0, _scope.addOffsets)(parentScope.offsets.x, horizontal ? '' : `scale(${JSON.stringify(names.xScale)}, datum[${JSON.stringify(binField)}])`), + y: (0, _scope.addOffsets)(parentScope.offsets.y, horizontal ? `scale(${JSON.stringify(names.yScale)}, datum[${JSON.stringify(binField)}])` : ''), h: horizontal ? names.bandWidth : parentScope.offsets.h, w: horizontal ? parentScope.offsets.w : names.bandWidth }; } getScale(bin, horizontal) { - const { names } = this; - const { parentScope } = this.props; + const { names } = this; + const { parentScope } = this.props; const binField = (0, _expr.safeFieldName)(bin.fields[0]); let bandScale; if (horizontal) bandScale = { - type: "band", + type: 'band', name: names.yScale, range: [ 0, { signal: parentScope.sizeSignals.layoutHeight - }, + } ], padding: 0.1, domain: { @@ -4550,13 +4871,13 @@ class Band extends (0, _layout.Layout) { reverse: true }; else bandScale = { - type: "band", + type: 'band', name: names.xScale, range: [ 0, { signal: parentScope.sizeSignals.layoutWidth - }, + } ], padding: 0.1, domain: { @@ -4569,21 +4890,21 @@ class Band extends (0, _layout.Layout) { } } -},{"./layout":"eTeFq","../bin":"kMjN2","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","../signals":"3OaQI","../scales":"1sFCW","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kMjN2":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./layout":"i2QIi","../bin":"2ZuOQ","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","../signals":"Bq6BR","../scales":"feLP9","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2ZuOQ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "binnable", ()=>binnable); parcelHelpers.export(exports, "outerExtentSignal", ()=>outerExtentSignal); parcelHelpers.export(exports, "shouldBeIntegralBinStep", ()=>shouldBeIntegralBinStep); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("./constants"); +var _constants = require("./constants"); var _expr = require("./expr"); var _defaults = require("./defaults"); var _transforms = require("./transforms"); function binnable(prefix, domainDataName, discreteColumn, outerSignalExtents) { - const { column , defaultBins , maxbins , maxbinsSignalDisplayName , maxbinsSignalName } = discreteColumn; + const { column, defaultBins, maxbins, maxbinsSignalDisplayName, maxbinsSignalName } = discreteColumn; if (column.quantitative) { const field = `${prefix}_bin_${(0, _expr.exprSafeFieldName)(column.name)}`; const fieldEnd = `${field}_end`; @@ -4601,7 +4922,7 @@ function binnable(prefix, domainDataName, discreteColumn, outerSignalExtents) { bind: { name: maxbinsSignalDisplayName, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 1, max: maxbins, step: 1 @@ -4609,11 +4930,11 @@ function binnable(prefix, domainDataName, discreteColumn, outerSignalExtents) { }; const extentSignal = (imageSignal === null || imageSignal === void 0 ? void 0 : imageSignal.name) || dataExtentSignal; const binTransform = { - type: "bin", + type: 'bin', field: (0, _expr.safeFieldName)(column.name), as: [ field, - fieldEnd, + fieldEnd ], signal: binSignal, extent: { @@ -4628,7 +4949,7 @@ function binnable(prefix, domainDataName, discreteColumn, outerSignalExtents) { name: domainDataName, transform: [ { - type: "sequence", + type: 'sequence', start: { signal: `${binSignal}.start` }, @@ -4640,39 +4961,39 @@ function binnable(prefix, domainDataName, discreteColumn, outerSignalExtents) { } }, { - type: "formula", - expr: "datum.data", + type: 'formula', + expr: 'datum.data', as: field }, { - type: "formula", + type: 'formula', expr: `datum.data + ${binSignal}.step`, as: fieldEnd }, { - type: "window", + type: 'window', ops: [ - "row_number" + 'row_number' ], as: [ (0, _constants.FieldNames).Ordinal ] }, { - type: "formula", + type: 'formula', expr: `datum.data === ${binSignal}.start`, as: (0, _constants.FieldNames).First }, { - type: "formula", + type: 'formula', expr: `datum.data === ${binSignal}.stop - ${binSignal}.step`, as: (0, _constants.FieldNames).Last }, { // when there is only one bin, use only first sequence element - type: "filter", + type: 'filter', expr: `${dataExtentSpanSignal} === 0 ? datum[${JSON.stringify((0, _constants.FieldNames).First)}] : true` - }, + } ] }; const signals = [ @@ -4680,7 +5001,7 @@ function binnable(prefix, domainDataName, discreteColumn, outerSignalExtents) { { name: dataExtentSpanSignal, update: `${extentSignal}[1] - ${extentSignal}[0]` - }, + } ]; if (imageSignal) signals.push(imageSignal); const augmentBinnable = { @@ -4723,33 +5044,33 @@ function outerExtentSignal(name, min, max, dataExtent) { } function shouldBeIntegralBinStep(column) { //prevent Vega from showing ".5" steps between integer scale values - return column.quantitative && column.type === "integer" && column.stats.max - column.stats.min <= 7; + return column.quantitative && column.type === 'integer' && column.stats.max - column.stats.min <= 7; } -},{"./constants":"6pnJw","./expr":"buVVl","./defaults":"dX5m9","./transforms":"cGnVZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cGnVZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "dataExtent", ()=>dataExtent); +},{"./constants":"22TRA","./expr":"eSi6o","./defaults":"jpVjH","./transforms":"iZfe4","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iZfe4":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _expr = require("./expr"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "dataExtent", ()=>dataExtent); +var _expr = require("./expr"); function dataExtent(column, signal) { return { - type: "extent", + type: 'extent', field: (0, _expr.safeFieldName)(column.name), signal }; } -},{"./expr":"buVVl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"c0Nwh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cross", ()=>Cross); +},{"./expr":"eSi6o","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iXWbC":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cross", ()=>Cross); +var _layout = require("./layout"); var _bin = require("../bin"); var _constants = require("../constants"); var _facetSearch = require("../facetSearch"); @@ -4778,8 +5099,8 @@ class Cross extends (0, _layout.Layout) { return this.binX.fields.concat(this.binY.fields); } build() { - const { binX , binY , names , prefix , props } = this; - const { axisTextColor , colRowTitles , globalScope , parentScope } = props; + const { binX, binY, names, prefix, props } = this; + const { axisTextColor, colRowTitles, globalScope, parentScope } = props; const titles = { x: { dataName: null, @@ -4791,9 +5112,9 @@ class Cross extends (0, _layout.Layout) { } }; const dx = { - dim: "x", + dim: 'x', bin: binX, - sortOrder: "ascending", + sortOrder: 'ascending', size: parentScope.sizeSignals.layoutWidth, layout: parentScope.sizeSignals.layoutWidth, min: globalScope.signals.minCellWidth.name, @@ -4805,9 +5126,9 @@ class Cross extends (0, _layout.Layout) { position: null }; const dy = { - dim: "y", + dim: 'y', bin: binY, - sortOrder: "ascending", + sortOrder: 'ascending', size: parentScope.sizeSignals.layoutHeight, layout: parentScope.sizeSignals.layoutHeight, min: globalScope.signals.minCellHeight.name, @@ -4823,7 +5144,7 @@ class Cross extends (0, _layout.Layout) { dy ]; dimensions.forEach((d)=>{ - const { bin , dim , padding , sortOrder } = d; + const { bin, dim, padding, sortOrder } = d; let data; let dataName; let countSignal; @@ -4834,7 +5155,7 @@ class Cross extends (0, _layout.Layout) { (0, _scope.addTransforms)(globalScope.data, ...bin.transforms); (0, _scope.addData)(globalScope.scope, bin.dataSequence); (0, _scope.addTransforms)(bin.dataSequence, { - type: "formula", + type: 'formula', expr: `indata(${JSON.stringify(globalScope.markDataName)}, ${JSON.stringify(bin.fields[0])}, datum[${JSON.stringify(bin.fields[0])}])`, as: (0, _constants.FieldNames).Contains }); @@ -4856,11 +5177,11 @@ class Cross extends (0, _layout.Layout) { d.dataOut = data; d.scaleName = scale.name; (0, _scope.addTransforms)(data, { - type: "formula", + type: 'formula', expr: (0, _facetSearch.serializeAsVegaExpression)(bin, (0, _constants.FieldNames).First, (0, _constants.FieldNames).Last), as: (0, _constants.FieldNames).FacetSearch }, { - type: "formula", + type: 'formula', expr: (0, _facetSearch.displayBin)(bin), as: (0, _constants.FieldNames).FacetTitle }); @@ -4879,11 +5200,11 @@ class Cross extends (0, _layout.Layout) { name: size, update: `max(${d.min}, (${calc} - ${padding}))` }); - (0, _signals.modifySignal)(d.out, "max", `((${size} + ${padding}) * ${count})`); + (0, _signals.modifySignal)(d.out, 'max', `((${size} + ${padding}) * ${count})`); d.position = this.dimensionOffset(d); }); const groupRow = { - type: "group", + type: 'group', encode: { update: { y: { @@ -4900,18 +5221,18 @@ class Cross extends (0, _layout.Layout) { source: dx.dataOut.name, transform: [ { - type: "formula", + type: 'formula', expr: `[datum[${JSON.stringify((0, _constants.FieldNames).FacetSearch)}], merge(parent[${JSON.stringify((0, _constants.FieldNames).FacetSearch)}], { clause: '&&'})]`, as: (0, _constants.FieldNames).FacetSearch - }, + } ] - }, + } ] }; const groupCol = { - style: "cell", + style: 'cell', name: prefix, - type: "group", + type: 'group', encode: { update: { height: { @@ -4952,18 +5273,18 @@ class Cross extends (0, _layout.Layout) { }; } dimensionOffset(d) { - const { names } = this; + const { names } = this; return `${d.offset} + (scale(${JSON.stringify(d.scaleName)}, datum[${JSON.stringify(d.bin.fields[0])}]) - 1) * (${names.dimCellSize}_${d.dim} + ${d.padding})`; } } -},{"./layout":"eTeFq","../bin":"kMjN2","../constants":"6pnJw","../facetSearch":"kZQv2","../facetTitle":"7cHD5","../ordinal":"iPe7t","../scope":"4pyrl","../signals":"3OaQI","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kZQv2":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./layout":"i2QIi","../bin":"2ZuOQ","../constants":"22TRA","../facetSearch":"7jRmp","../facetTitle":"a1RbZ","../ordinal":"hxe8x","../scope":"9ojhQ","../signals":"Bq6BR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7jRmp":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "displayBin", ()=>displayBin); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "displayBin", ()=>displayBin); parcelHelpers.export(exports, "serializeAsVegaExpression", ()=>serializeAsVegaExpression); function displayBin(bin) { const val = (index)=>`datum[${JSON.stringify(bin.fields[index])}]`; @@ -4980,39 +5301,39 @@ function serializeAsVegaExpression(bin, firstFieldName, lastFieldName, clause) { if (bin.discreteColumn.column.quantitative) { const low = [ `name:${JSON.stringify(bin.discreteColumn.column.name)}`, - "operator:'>='", - `value:datum[${JSON.stringify(bin.fields[0])}]`, + 'operator:\'>=\'', + `value:datum[${JSON.stringify(bin.fields[0])}]` ]; const high = [ - "clause:'&&'", + 'clause:\'&&\'', `name:${JSON.stringify(bin.discreteColumn.column.name)}`, - "operator:'<'", - `value:datum[${JSON.stringify(bin.fields[1])}]`, + 'operator:\'<\'', + `value:datum[${JSON.stringify(bin.fields[1])}]` ]; return obj([ - `expressions:[ datum[${JSON.stringify(firstFieldName)}] ? null : ${obj(low)}, datum[${JSON.stringify(lastFieldName)}] ? null : ${obj(high)}]`, + `expressions:[ datum[${JSON.stringify(firstFieldName)}] ? null : ${obj(low)}, datum[${JSON.stringify(lastFieldName)}] ? null : ${obj(high)}]` ], clause); } else { const exact = [ `name:${JSON.stringify(bin.discreteColumn.column.name)}`, - "operator:'=='", - `value:datum[${JSON.stringify(bin.fields[0])}]`, + 'operator:\'==\'', + `value:datum[${JSON.stringify(bin.fields[0])}]` ]; return obj([ - `expressions:[${obj(exact)}]`, + `expressions:[${obj(exact)}]` ], clause); } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iPe7t":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "createOrdinals", ()=>createOrdinals); -parcelHelpers.export(exports, "ordinalScale", ()=>ordinalScale); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hxe8x":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "createOrdinals", ()=>createOrdinals); +parcelHelpers.export(exports, "ordinalScale", ()=>ordinalScale); +var _constants = require("./constants"); var _expr = require("./expr"); function createOrdinals(source, prefix, binFields, sortOrder) { const _binFields = binFields.map((0, _expr.safeFieldName)); @@ -5022,25 +5343,25 @@ function createOrdinals(source, prefix, binFields, sortOrder) { source, transform: [ { - type: "aggregate", + type: 'aggregate', groupby: _binFields }, { - type: "collect", + type: 'collect', sort: { field: _binFields, order: _binFields.map((f)=>sortOrder) } }, { - type: "window", + type: 'window', ops: [ - "row_number" + 'row_number' ], as: [ (0, _constants.FieldNames).Ordinal ] - }, + } ] }; return { @@ -5050,7 +5371,7 @@ function createOrdinals(source, prefix, binFields, sortOrder) { } function ordinalScale(dataName, scaleName, binFields) { return { - type: "ordinal", + type: 'ordinal', name: scaleName, domain: { data: dataName, @@ -5063,14 +5384,14 @@ function ordinalScale(dataName, scaleName, binFields) { }; } -},{"./constants":"6pnJw","./expr":"buVVl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5bRVL":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Scatter", ()=>Scatter); +},{"./constants":"22TRA","./expr":"eSi6o","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eLCwq":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Scatter", ()=>Scatter); +var _layout = require("./layout"); var _constants = require("../constants"); var _defaults = require("../defaults"); var _expr = require("../expr"); @@ -5100,8 +5421,8 @@ class Scatter extends (0, _layout.Layout) { }; } build() { - const { names , prefix , props } = this; - const { backgroundImageExtents , globalScope , parentScope , scatterPointScaleDisplay , showAxes , size , view , x , y , z , zGrounded } = props; + const { names, prefix, props } = this; + const { backgroundImageExtents, globalScope, parentScope, scatterPointScaleDisplay, showAxes, size, view, x, y, z, zGrounded } = props; const qsize = size && size.quantitative && size; (0, _scope.addSignals)(globalScope.scope, { name: (0, _constants.SignalNames).PointScale, @@ -5109,7 +5430,7 @@ class Scatter extends (0, _layout.Layout) { bind: { name: scatterPointScaleDisplay, debounce: (0, _defaults.debounce), - input: "range", + input: 'range', min: 1, max: 10, step: 0.1 @@ -5119,7 +5440,7 @@ class Scatter extends (0, _layout.Layout) { value: false, bind: { name: zGrounded, - input: "checkbox" + input: 'checkbox' } }); if (backgroundImageExtents) { @@ -5130,13 +5451,13 @@ class Scatter extends (0, _layout.Layout) { } if (qsize) { (0, _scope.addTransforms)(globalScope.data, { - type: "extent", + type: 'extent', field: (0, _expr.safeFieldName)(qsize.name), signal: names.sizeExtent }); (0, _scope.addScales)(globalScope.scope, { name: names.sizeScale, - type: "pow", + type: 'pow', exponent: 0.5, domain: [ 0, @@ -5166,7 +5487,7 @@ class Scatter extends (0, _layout.Layout) { ].map((c)=>{ if (!c || !c.quantitative) return; const t = { - type: "filter", + type: 'filter', expr: `isValid(datum[${JSON.stringify(c.name)}])` }; return t; @@ -5187,7 +5508,7 @@ class Scatter extends (0, _layout.Layout) { }, { signal: sizeValueSignal - }, + } ], width: { signal: sizeValueSignal @@ -5200,12 +5521,12 @@ class Scatter extends (0, _layout.Layout) { }, { signal: `${(0, _constants.SignalNames).ZGrounded} ? 0 : ${zValue}` - }, + } ], zindex: [ { signal: `${(0, _constants.SignalNames).ZGrounded} ? 0 : ${zValue}` - }, + } ], depth: [ { @@ -5213,14 +5534,14 @@ class Scatter extends (0, _layout.Layout) { value: 0 }, { - signal: view === "3d" ? `${(0, _constants.SignalNames).ZGrounded} ? ${zValue} : ${sizeValueSignal}` : "0" - }, + signal: view === '3d' ? `${(0, _constants.SignalNames).ZGrounded} ? ${zValue} : ${sizeValueSignal}` : '0' + } ] }); const columnSignals = [ { column: x, - xyz: "x", + xyz: 'x', scaleName: names.xScale, domain: backgroundImageExtents ? { signal: names.xExtent @@ -5233,7 +5554,7 @@ class Scatter extends (0, _layout.Layout) { }, { column: y, - xyz: "y", + xyz: 'y', scaleName: names.yScale, domain: backgroundImageExtents ? { signal: names.yExtent @@ -5246,18 +5567,18 @@ class Scatter extends (0, _layout.Layout) { }, { column: z, - xyz: "z", + xyz: 'z', scaleName: names.zScale, domain: { data: globalScope.data.name, field: z ? (0, _expr.safeFieldName)(z.name) : null }, reverse: false, - signal: view === "3d" ? `(${globalScope.zSize}) * ${(0, _constants.SignalNames).ZProportion}` : `10 * ${(0, _constants.SignalNames).ZProportion}` - }, + signal: view === '3d' ? `(${globalScope.zSize}) * ${(0, _constants.SignalNames).ZProportion}` : `10 * ${(0, _constants.SignalNames).ZProportion}` + } ]; columnSignals.forEach((cs)=>{ - const { column , domain , reverse , scaleName , signal , xyz } = cs; + const { column, domain, reverse, scaleName, signal, xyz } = cs; if (!column) return; let scale; if (column.quantitative) { @@ -5282,7 +5603,7 @@ class Scatter extends (0, _layout.Layout) { }); const mark = { name: prefix, - type: "rect", + type: 'rect', from: { data: globalScope.markDataName }, @@ -5309,21 +5630,21 @@ class Scatter extends (0, _layout.Layout) { { test: (0, _selection.testForCollapseSelection)(), signal: (0, _scope.addOffsets)(parentScope.offsets.y, parentScope.sizeSignals.layoutHeight) - }, + } ] } }; } } -},{"./layout":"eTeFq","../constants":"6pnJw","../defaults":"dX5m9","../expr":"buVVl","../scales":"1sFCW","../scope":"4pyrl","../selection":"fjVfM","../transforms":"cGnVZ","../bin":"kMjN2","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4Crxy":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Square", ()=>Square); +},{"./layout":"i2QIi","../constants":"22TRA","../defaults":"jpVjH","../expr":"eSi6o","../scales":"feLP9","../scope":"9ojhQ","../selection":"ef2qR","../transforms":"iZfe4","../bin":"2ZuOQ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5vsTh":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Square", ()=>Square); +var _layout = require("./layout"); var _constants = require("../constants"); var _expr = require("../expr"); var _scope = require("../scope"); @@ -5344,11 +5665,11 @@ class Square extends (0, _layout.Layout) { }; } build() { - const { names , prefix , props } = this; - const { fillDirection , globalScope , groupings , parentScope , collapseYHeight , showAxes , sortBy , view , z } = props; + const { names, prefix, props } = this; + const { fillDirection, globalScope, groupings, parentScope, collapseYHeight, showAxes, sortBy, view, z } = props; const zScale = (0, _zBase.addZScale)(z, globalScope.zSize, globalScope.data.name, names.zScale); (0, _scope.addTransforms)(globalScope.data, Object.assign({ - type: "stack", + type: 'stack', groupby: (0, _scope.getGroupBy)(groupings).map((0, _expr.safeFieldName)), as: [ names.stack0, @@ -5357,16 +5678,16 @@ class Square extends (0, _layout.Layout) { }, sortBy && { sort: { field: (0, _expr.safeFieldName)(sortBy.name), - order: "ascending" + order: 'ascending' } })); - const { gap , levelSize , size , squaresPerBand } = this.addSignals(); + const { gap, levelSize, size, squaresPerBand } = this.addSignals(); const heightSignal = { - signal: fillDirection === "down-right" ? size : levelSize + signal: fillDirection === 'down-right' ? size : levelSize }; const mark = { name: prefix, - type: "rect", + type: 'rect', from: { data: globalScope.markDataName }, @@ -5377,10 +5698,10 @@ class Square extends (0, _layout.Layout) { test: (0, _selection.testForCollapseSelection)(), value: 0 }, - heightSignal, + heightSignal ] : heightSignal, width: { - signal: fillDirection === "down-right" ? levelSize : size + signal: fillDirection === 'down-right' ? levelSize : size } }, z && { z: { @@ -5391,18 +5712,18 @@ class Square extends (0, _layout.Layout) { test: (0, _selection.testForCollapseSelection)(), value: 0 }, - view === "3d" ? { + view === '3d' ? { scale: names.zScale, field: (0, _expr.safeFieldName)(z.name) } : { value: 0 - }, + } ] }) } }; (0, _scope.addMarks)(globalScope.markGroup, mark); - const { tx , ty } = this.transformXY(gap, levelSize, squaresPerBand); + const { tx, ty } = this.transformXY(gap, levelSize, squaresPerBand); return Object.assign(Object.assign(Object.assign({}, z && { globalScales: { showAxes, @@ -5430,44 +5751,44 @@ class Square extends (0, _layout.Layout) { { test: (0, _selection.testForCollapseSelection)(), signal: parentScope.offsets.y - }, + } ] } }); } getBandWidth() { - const { offsets } = this.props.parentScope; + const { offsets } = this.props.parentScope; switch(this.props.fillDirection){ - case "down-right": + case 'down-right': return offsets.h; default: return offsets.w; } } addSignals() { - const { names , props } = this; - const { fillDirection , globalScope , groupings , parentScope } = props; - let { maxGroupedFillSize , maxGroupedUnits } = props; + const { names, props } = this; + const { fillDirection, globalScope, groupings, parentScope } = props; + let { maxGroupedFillSize, maxGroupedUnits } = props; if (!maxGroupedUnits) { if (groupings) { (0, _scope.addTransforms)(globalScope.data, { - type: "joinaggregate", + type: 'joinaggregate', groupby: (0, _scope.getGroupBy)(groupings).map((0, _expr.safeFieldName)), ops: [ - "count" + 'count' ], as: [ names.maxGroupField ] }, { - type: "extent", + type: 'extent', field: names.maxGroupField, signal: names.maxGroupSignal }); maxGroupedUnits = `(${names.maxGroupSignal}[1])`; } else maxGroupedUnits = `length(data(${JSON.stringify(globalScope.data.name)}))`; } - if (!maxGroupedFillSize) maxGroupedFillSize = fillDirection === "down-right" ? parentScope.offsets.w : parentScope.offsets.h; + if (!maxGroupedFillSize) maxGroupedFillSize = fillDirection === 'down-right' ? parentScope.offsets.w : parentScope.offsets.h; const aspect = `((${names.bandWidth}) / (${maxGroupedFillSize}))`; const squaresPerBand = `ceil(sqrt(${maxGroupedUnits} * ${aspect}))`; const gap = `min(0.1 * ((${names.bandWidth}) / (${squaresPerBand} - 1)), 1)`; @@ -5482,30 +5803,30 @@ class Square extends (0, _layout.Layout) { }; } transformXY(gap, levelSize, squaresPerBand) { - const { names , prefix } = this; + const { names, prefix } = this; const compartment = `(${names.bandWidth}) / ${squaresPerBand} * ((datum[${JSON.stringify(names.stack0)}]) % ${squaresPerBand})`; const level = `floor((datum[${JSON.stringify(names.stack0)}]) / ${squaresPerBand})`; - const { fillDirection , parentScope } = this.props; + const { fillDirection, parentScope } = this.props; const tx = { - type: "formula", + type: 'formula', expr: null, as: `${prefix}_${(0, _constants.FieldNames).OffsetX}` }; const ty = { - type: "formula", + type: 'formula', expr: null, as: `${prefix}_${(0, _constants.FieldNames).OffsetY}` }; switch(fillDirection){ - case "down-right": + case 'down-right': tx.expr = `${level} * (${levelSize} + ${gap})`; ty.expr = compartment; break; - case "right-up": + case 'right-up': tx.expr = compartment; ty.expr = `${parentScope.offsets.h} - ${levelSize} - ${level} * (${levelSize} + ${gap})`; break; - case "right-down": + case 'right-down': default: tx.expr = compartment; ty.expr = `${level} * (${levelSize} + ${gap})`; @@ -5518,14 +5839,14 @@ class Square extends (0, _layout.Layout) { } } -},{"./layout":"eTeFq","../constants":"6pnJw","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","../zBase":"fBFr3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fBFr3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "addZScale", ()=>addZScale); +},{"./layout":"i2QIi","../constants":"22TRA","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","../zBase":"iUpjg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iUpjg":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _constants = require("./constants"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "addZScale", ()=>addZScale); +var _constants = require("./constants"); var _scales = require("./scales"); var _expr = require("./expr"); function addZScale(z, zSize, dataName, zScaleName) { @@ -5544,14 +5865,14 @@ function addZScale(z, zSize, dataName, zScaleName) { } } -},{"./constants":"6pnJw","./scales":"1sFCW","./expr":"buVVl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5OOcx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Stack", ()=>Stack); +},{"./constants":"22TRA","./scales":"feLP9","./expr":"eSi6o","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"l09WI":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Stack", ()=>Stack); +var _layout = require("./layout"); var _expr = require("../expr"); var _scope = require("../scope"); var _selection = require("../selection"); @@ -5578,24 +5899,24 @@ class Stack extends (0, _layout.Layout) { }; } build() { - const { names , props } = this; - const { globalScope , groupings , parentScope , showAxes , sort } = props; - const { sizeSignals } = parentScope; + const { names, props } = this; + const { globalScope, groupings, parentScope, showAxes, sort } = props; + const { sizeSignals } = parentScope; (0, _scope.addTransforms)(globalScope.data, { - type: "joinaggregate", + type: 'joinaggregate', groupby: (0, _scope.getGroupBy)(groupings).map((0, _expr.safeFieldName)), ops: [ - "count" + 'count' ], as: [ names.count ] }, { - type: "extent", + type: 'extent', field: names.count, signal: names.globalExtent }, Object.assign({ - type: "stack", + type: 'stack', groupby: (0, _scope.getGroupBy)(groupings).map((0, _expr.safeFieldName)), as: [ names.stack0, @@ -5604,61 +5925,61 @@ class Stack extends (0, _layout.Layout) { }, sort && { sort: { field: (0, _expr.safeFieldName)(sort.name), - order: "ascending" + order: 'ascending' } })); (0, _scope.addData)(globalScope.scope, { name: names.sequence, transform: [ { - type: "sequence", + type: 'sequence', start: 1, stop: { signal: `sqrt(${names.globalExtent}[1])` } }, { - type: "formula", - expr: "datum.data * datum.data", - as: "squared" + type: 'formula', + expr: 'datum.data * datum.data', + as: 'squared' }, { - type: "formula", + type: 'formula', expr: `ceil(${names.globalExtent}[1] / datum.squared)`, - as: "maxlevels" + as: 'maxlevels' }, { - type: "formula", + type: 'formula', expr: `(${names.size} - (datum.data - 1) * datum.data) / datum.data`, - as: "side" + as: 'side' }, { - type: "formula", - expr: "datum.side * datum.maxlevels + datum.maxlevels - 1", - as: "sidecubeheight" + type: 'formula', + expr: 'datum.side * datum.maxlevels + datum.maxlevels - 1', + as: 'sidecubeheight' }, { - type: "formula", + type: 'formula', expr: `abs(${globalScope.zSize} - datum.sidecubeheight)`, - as: "heightmatch" + as: 'heightmatch' }, { - type: "collect", + type: 'collect', sort: { - field: "heightmatch", - order: "ascending" + field: 'heightmatch', + order: 'ascending' } }, { - type: "window", + type: 'window', ops: [ - "row_number" + 'row_number' ] }, { - type: "filter", - expr: "datum.row_number === 1" - }, + type: 'filter', + expr: 'datum.row_number === 1' + } ] }); (0, _scope.addSignals)(globalScope.scope, { @@ -5693,7 +6014,7 @@ class Stack extends (0, _layout.Layout) { w: names.size }; const mark = { - type: "rect", + type: 'rect', from: { data: this.names.levelDataName }, @@ -5716,19 +6037,19 @@ class Stack extends (0, _layout.Layout) { }; (0, _scope.addMarks)(globalScope.markGroup, mark); const zScale = { - type: "linear", + type: 'linear', name: names.zScale, domain: [ 0, { signal: names.maxCount - }, + } ], range: [ 0, { signal: `${names.maxLevels} * (${names.cube} + 1) - 1` - }, + } ], nice: false }; @@ -5777,14 +6098,14 @@ class Stack extends (0, _layout.Layout) { } } -},{"./layout":"eTeFq","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1Kejb":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Strip", ()=>Strip); +},{"./layout":"i2QIi","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7mPSq":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Strip", ()=>Strip); +var _layout = require("./layout"); var _constants = require("../constants"); var _expr = require("../expr"); var _scope = require("../scope"); @@ -5804,13 +6125,13 @@ class Strip extends (0, _layout.Layout) { }; } build() { - const { names , prefix , props } = this; - const { addPercentageScale , globalScope , groupings , orientation , showAxes , size , sort , sortOrder , parentScope , view , z } = props; + const { names, prefix, props } = this; + const { addPercentageScale, globalScope, groupings, orientation, showAxes, size, sort, sortOrder, parentScope, view, z } = props; const zScale = (0, _zBase.addZScale)(z, globalScope.zSize, globalScope.data.name, names.zScale); - const horizontal = orientation === "horizontal"; + const horizontal = orientation === 'horizontal'; const transform = []; if (sort) transform.push({ - type: "collect", + type: 'collect', sort: { field: (0, _expr.safeFieldName)(sort.name), order: sortOrder @@ -5820,21 +6141,21 @@ class Strip extends (0, _layout.Layout) { if (size) { stackField = size.name; transform.push({ - type: "filter", + type: 'filter', expr: `datum[${JSON.stringify(size.name)}] > 0` }); } else { stackField = names.valueField; transform.push({ - type: "formula", - expr: "1", + type: 'formula', + expr: '1', as: stackField }); } const stackTransform = { - type: "stack", + type: 'stack', field: (0, _expr.safeFieldName)(stackField), - offset: "normalize", + offset: 'normalize', as: [ names.firstField, names.lastField @@ -5846,16 +6167,16 @@ class Strip extends (0, _layout.Layout) { const span = [ names.lastField, names.firstField - ].map((f)=>`datum[${JSON.stringify(f)}]`).join(" - "); + ].map((f)=>`datum[${JSON.stringify(f)}]`).join(' - '); const offsets = { - x: (0, _scope.addOffsets)(parentScope.offsets.x, horizontal ? `datum[${JSON.stringify(names.firstField)}] * (${parentScope.offsets.w})` : ""), - y: (0, _scope.addOffsets)(parentScope.offsets.y, horizontal ? "" : `datum[${JSON.stringify(names.firstField)}] * (${parentScope.offsets.h})`), + x: (0, _scope.addOffsets)(parentScope.offsets.x, horizontal ? `datum[${JSON.stringify(names.firstField)}] * (${parentScope.offsets.w})` : ''), + y: (0, _scope.addOffsets)(parentScope.offsets.y, horizontal ? '' : `datum[${JSON.stringify(names.firstField)}] * (${parentScope.offsets.h})`), h: horizontal ? parentScope.offsets.h : `(${span}) * (${parentScope.offsets.h})`, w: horizontal ? `(${span}) * (${parentScope.offsets.w})` : parentScope.offsets.w }; const mark = { name: prefix, - type: "rect", + type: 'rect', from: { data: globalScope.markDataName }, @@ -5876,12 +6197,12 @@ class Strip extends (0, _layout.Layout) { test: (0, _selection.testForCollapseSelection)(), value: 0 }, - view === "3d" ? { + view === '3d' ? { scale: names.zScale, field: (0, _expr.safeFieldName)(z.name) } : { value: 0 - }, + } ] }) } @@ -5890,7 +6211,7 @@ class Strip extends (0, _layout.Layout) { let percentageScale; if (addPercentageScale) percentageScale = [ { - type: "linear", + type: 'linear', name: names.scale, domain: [ 0, @@ -5900,12 +6221,12 @@ class Strip extends (0, _layout.Layout) { 0, { signal: parentScope.sizeSignals.layoutWidth - }, + } ] : [ { signal: parentScope.sizeSignals.layoutHeight }, - 0, + 0 ] } ]; @@ -5930,14 +6251,14 @@ class Strip extends (0, _layout.Layout) { } } -},{"./layout":"eTeFq","../constants":"6pnJw","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","../zBase":"fBFr3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"la9W6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Treemap", ()=>Treemap); +},{"./layout":"i2QIi","../constants":"22TRA","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","../zBase":"iUpjg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"caw7y":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Treemap", ()=>Treemap); +var _layout = require("./layout"); var _constants = require("../constants"); var _expr = require("../expr"); var _scope = require("../scope"); @@ -5968,8 +6289,8 @@ class Treemap extends (0, _layout.Layout) { }; } build() { - const { names , props } = this; - const { globalScope , parentScope , showAxes , treeMapMethod , z } = props; + const { names, props } = this; + const { globalScope, parentScope, showAxes, treeMapMethod, z } = props; const zScale = (0, _zBase.addZScale)(z, globalScope.zSize, globalScope.data.name, names.zScale); const offsets = { x: (0, _scope.addOffsets)(parentScope.offsets.x, fn(names.fieldX0)), @@ -5980,13 +6301,13 @@ class Treemap extends (0, _layout.Layout) { const mark = this.transformedMark(offsets); (0, _scope.addSignals)(globalScope.scope, { name: (0, _constants.SignalNames).TreeMapMethod, - value: "squarify", + value: 'squarify', bind: { name: treeMapMethod, - input: "select", + input: 'select', options: [ - "squarify", - "binary", + 'squarify', + 'binary' ] } }); @@ -6009,8 +6330,8 @@ class Treemap extends (0, _layout.Layout) { }); } transformedMark(offsets) { - const { names , props } = this; - const { globalScope , groupings , parentScope } = props; + const { names, props } = this; + const { globalScope, groupings, parentScope } = props; if (groupings.length) { //treemap transform can't have it's boundary size grouped, so we need to facet the data. (0, _scope.addData)(globalScope.scope, { @@ -6018,15 +6339,15 @@ class Treemap extends (0, _layout.Layout) { source: globalScope.markDataName, transform: [ { - type: "formula", + type: 'formula', expr: parentScope.offsets.h, as: names.fieldHeight }, { - type: "formula", + type: 'formula', expr: parentScope.offsets.w, as: names.fieldWidth - }, + } ] }); const treemapData = { @@ -6034,7 +6355,7 @@ class Treemap extends (0, _layout.Layout) { source: names.dataFacet }; const facets = { - type: "group", + type: 'group', from: { facet: { name: names.dataFacet, @@ -6048,18 +6369,18 @@ class Treemap extends (0, _layout.Layout) { source: names.dataFacet, transform: [ { - type: "extent", + type: 'extent', field: names.fieldHeight, signal: names.heightExtent }, { - type: "extent", + type: 'extent', field: names.fieldWidth, signal: names.widthExtent - }, + } ] }, - treemapData, + treemapData ] }; globalScope.setMarkDataName(names.dataFacetMark); @@ -6074,11 +6395,11 @@ class Treemap extends (0, _layout.Layout) { } } addMark(offsets, markParent, markDataName) { - const { names , prefix , props } = this; - const { view , z } = props; + const { names, prefix, props } = this; + const { view, z } = props; const mark = { name: prefix, - type: "rect", + type: 'rect', from: { data: markDataName }, @@ -6099,12 +6420,12 @@ class Treemap extends (0, _layout.Layout) { test: (0, _selection.testForCollapseSelection)(), value: 0 }, - view === "3d" ? { + view === '3d' ? { scale: names.zScale, field: (0, _expr.safeFieldName)(z.name) } : { value: 0 - }, + } ] }) } @@ -6113,22 +6434,22 @@ class Treemap extends (0, _layout.Layout) { return mark; } treemapTransform(treemapData, widthSignal, heightSignal) { - const { names , props } = this; - const { group , size } = props; + const { names, props } = this; + const { group, size } = props; (0, _scope.addTransforms)(treemapData, { - type: "filter", + type: 'filter', expr: `datum[${JSON.stringify(size.name)}] > 0` }, { - type: "nest", + type: 'nest', keys: [ - group && group.name || "__NONE__" + group && group.name || '__NONE__' ] }, { - type: "treemap", + type: 'treemap', field: (0, _expr.safeFieldName)(size.name), sort: { - field: "value", - order: "descending" + field: 'value', + order: 'descending' }, round: true, method: { @@ -6142,7 +6463,7 @@ class Treemap extends (0, _layout.Layout) { }, { signal: heightSignal - }, + } ], as: [ names.fieldX0, @@ -6150,7 +6471,7 @@ class Treemap extends (0, _layout.Layout) { names.fieldX1, names.fieldY1, names.fieldDepth, - names.fieldChildren, + names.fieldChildren ] }); } @@ -6159,17 +6480,17 @@ function fn(n) { return `datum[${JSON.stringify(n)}]`; } function subtract(...fields) { - return fields.map((n)=>fn(n)).join(" - "); + return fields.map((n)=>fn(n)).join(' - '); } -},{"./layout":"eTeFq","../constants":"6pnJw","../expr":"buVVl","../scope":"4pyrl","../selection":"fjVfM","../zBase":"fBFr3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5f7cw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Wrap", ()=>Wrap); +},{"./layout":"i2QIi","../constants":"22TRA","../expr":"eSi6o","../scope":"9ojhQ","../selection":"ef2qR","../zBase":"iUpjg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iDL5r":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _layout = require("./layout"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Wrap", ()=>Wrap); +var _layout = require("./layout"); var _bin = require("../bin"); var _constants = require("../constants"); var _expr = require("../expr"); @@ -6210,21 +6531,21 @@ class Wrap extends (0, _layout.Layout) { return this.bin.fields; } build() { - const { bin , names , prefix , props } = this; - const { axisTextColor , cellTitles , globalScope , parentScope } = props; + const { bin, names, prefix, props } = this; + const { axisTextColor, cellTitles, globalScope, parentScope } = props; let ordinalBinData; if (bin.native === false) { (0, _scope.addSignals)(globalScope.scope, ...bin.signals); (0, _scope.addTransforms)(globalScope.data, ...bin.transforms); (0, _scope.addData)(globalScope.scope, bin.dataSequence); (0, _scope.addTransforms)(bin.dataSequence, { - type: "formula", + type: 'formula', expr: `indata(${JSON.stringify(globalScope.data.name)}, ${JSON.stringify(bin.fields[0])}, datum[${JSON.stringify(bin.fields[0])}])`, as: (0, _constants.FieldNames).Contains }); ordinalBinData = bin.dataSequence.name; } else { - const ord = (0, _ordinal.createOrdinals)(globalScope.data.name, prefix, bin.fields, "ascending"); + const ord = (0, _ordinal.createOrdinals)(globalScope.data.name, prefix, bin.fields, 'ascending'); (0, _scope.addData)(globalScope.scope, ord.data); ordinalBinData = ord.data.name; } @@ -6232,45 +6553,45 @@ class Wrap extends (0, _layout.Layout) { name: names.rxc0, transform: [ { - type: "sequence", + type: 'sequence', start: 1, stop: { signal: `ceil(sqrt(${names.dataLength})) + 1` } }, { - type: "formula", + type: 'formula', expr: `ceil(${names.dataLength} / datum.data)`, - as: "complement" - }, + as: 'complement' + } ] }, { name: names.rxc1, source: names.rxc0, transform: [ { - type: "project", + type: 'project', fields: [ - "data" + 'data' ], as: [ - "cols" + 'cols' ] - }, + } ] }, { name: names.rxc2, source: names.rxc0, transform: [ { - type: "project", + type: 'project', fields: [ - "complement" + 'complement' ], as: [ - "cols" + 'cols' ] - }, + } ] }, { name: names.rxc, @@ -6280,92 +6601,92 @@ class Wrap extends (0, _layout.Layout) { ], transform: [ { - type: "formula", + type: 'formula', expr: `ceil(${names.dataLength} / datum.cols)`, - as: "rows" + as: 'rows' }, { - type: "formula", + type: 'formula', expr: `${parentScope.sizeSignals.layoutWidth} / datum.cols`, - as: "cellw" + as: 'cellw' }, { - type: "formula", + type: 'formula', expr: `datum.cols === 1 ? max(datum.cellw, ${(0, _constants.SignalNames).MinCellWidth}) : datum.cellw`, - as: "cellw" + as: 'cellw' }, { - type: "formula", + type: 'formula', expr: `${parentScope.sizeSignals.layoutHeight} / datum.rows`, - as: "cellh" + as: 'cellh' }, { - type: "formula", + type: 'formula', expr: `datum.rows === 1 ? max(datum.cellh, ${(0, _constants.SignalNames).MinCellHeight}) : datum.cellh`, - as: "cellh" + as: 'cellh' }, { - type: "formula", + type: 'formula', expr: `(datum.cellw >= ${(0, _constants.SignalNames).MinCellWidth} && datum.cellh >= ${(0, _constants.SignalNames).MinCellHeight})`, - as: "meetsmin" + as: 'meetsmin' }, { - type: "filter", - expr: "datum.meetsmin" + type: 'filter', + expr: 'datum.meetsmin' }, { - type: "formula", - expr: "datum.cellw / datum.cellh", + type: 'formula', + expr: 'datum.cellw / datum.cellh', as: names.aspect }, { - type: "formula", + type: 'formula', expr: `abs(datum.${names.aspect} - ${names.target})`, as: names.idealAspect }, { - type: "formula", + type: 'formula', expr: `${names.dataLength} / (datum.cols * datum.rows)`, - as: "coverage" + as: 'coverage' }, { - type: "collect", + type: 'collect', sort: { field: [ names.idealAspect, - "coverage" + 'coverage' ], order: [ - "ascending", - "descending" + 'ascending', + 'descending' ] } - }, + } ] }, { name: names.rowColumnDataName, source: ordinalBinData, transform: [ { - type: "formula", + type: 'formula', expr: `floor((datum[${JSON.stringify((0, _constants.FieldNames).Ordinal)}] - 1) / ${names.colCount})`, as: (0, _constants.FieldNames).WrapRow }, { - type: "formula", + type: 'formula', expr: `(datum[${JSON.stringify((0, _constants.FieldNames).Ordinal)}] - 1) % ${names.colCount}`, as: (0, _constants.FieldNames).WrapCol }, { - type: "formula", + type: 'formula', expr: (0, _facetSearch.serializeAsVegaExpression)(bin, (0, _constants.FieldNames).First, (0, _constants.FieldNames).Last), as: (0, _constants.FieldNames).FacetSearch }, { - type: "formula", + type: 'formula', expr: (0, _facetSearch.displayBin)(bin), as: (0, _constants.FieldNames).FacetTitle - }, + } ] }); const dataOut = { @@ -6373,7 +6694,7 @@ class Wrap extends (0, _layout.Layout) { source: globalScope.data.name, transform: [ { - type: "lookup", + type: 'lookup', from: names.rowColumnDataName, key: (0, _expr.safeFieldName)(bin.fields[0]), fields: [ @@ -6383,7 +6704,7 @@ class Wrap extends (0, _layout.Layout) { (0, _constants.FieldNames).WrapRow, (0, _constants.FieldNames).WrapCol ] - }, + } ] }; (0, _scope.addData)(globalScope.scope, dataOut); @@ -6425,17 +6746,17 @@ class Wrap extends (0, _layout.Layout) { name: names.cellHeight, update: `${names.fits} ? data(${JSON.stringify(names.rxc)})[0].cellh : ${(0, _constants.SignalNames).MinCellHeight}` }); - (0, _signals.modifySignal)(globalScope.signals.plotHeightOut, "max", `(${names.cellHeight} * ceil(${names.dataLength} / ${names.colCount}))`); - (0, _signals.modifySignal)(globalScope.signals.plotWidthOut, "max", `(${names.cellWidth} * ${names.colCount})`); + (0, _signals.modifySignal)(globalScope.signals.plotHeightOut, 'max', `(${names.cellHeight} * ceil(${names.dataLength} / ${names.colCount}))`); + (0, _signals.modifySignal)(globalScope.signals.plotWidthOut, 'max', `(${names.cellWidth} * ${names.colCount})`); const signalH = [ names.cellHeight, (0, _constants.SignalNames).FacetPaddingTop, (0, _constants.SignalNames).FacetPaddingBottom - ].join(" - "); + ].join(' - '); const signalW = [ names.cellWidth, (0, _constants.SignalNames).FacetPaddingLeft - ].join(" - "); + ].join(' - '); const signalX = (0, _scope.addOffsets)(parentScope.offsets.x, `datum[${JSON.stringify((0, _constants.FieldNames).WrapCol)}] * ${names.cellWidth}`, (0, _constants.SignalNames).FacetPaddingLeft); const signalY = (0, _scope.addOffsets)(parentScope.offsets.y, `datum[${JSON.stringify((0, _constants.FieldNames).WrapRow)}] * ${names.cellHeight}`, (0, _constants.SignalNames).FacetPaddingTop); const update = { @@ -6459,9 +6780,9 @@ class Wrap extends (0, _layout.Layout) { w: signalW }; const group = { - style: "cell", + style: 'cell', name: prefix, - type: "group", + type: 'group', from: { data: names.rowColumnDataName }, @@ -6485,23 +6806,23 @@ class Wrap extends (0, _layout.Layout) { } } -},{"./layout":"eTeFq","../bin":"kMjN2","../constants":"6pnJw","../expr":"buVVl","../facetSearch":"kZQv2","../facetTitle":"7cHD5","../ordinal":"iPe7t","../scope":"4pyrl","../signals":"3OaQI","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"l00jx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getImageMark", ()=>getImageMark); +},{"./layout":"i2QIi","../bin":"2ZuOQ","../constants":"22TRA","../expr":"eSi6o","../facetSearch":"7jRmp","../facetTitle":"a1RbZ","../ordinal":"hxe8x","../scope":"9ojhQ","../signals":"Bq6BR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"akfUH":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _band = require("./layouts/band"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getImageMark", ()=>getImageMark); +var _band = require("./layouts/band"); function getImageMark(backgroundImage, allGlobalScales) { const xScale = allGlobalScales.filter((s)=>s.scales.x)[0].scales.x[0]; const yScale = allGlobalScales.filter((s)=>s.scales.y)[0].scales.y[0]; const [xScaleName, yScaleName] = [ xScale, yScale - ].map((s)=>s.name + (xScale.type === "band" ? (0, _band.bandScaleLinearSuffix) : "")); + ].map((s)=>s.name + (xScale.type === 'band' ? (0, _band.bandScaleLinearSuffix) : '')); return { - type: "image", + type: 'image', encode: { update: { url: { @@ -6511,7 +6832,7 @@ function getImageMark(backgroundImage, allGlobalScales) { value: false }, baseline: { - value: "bottom" + value: 'bottom' }, height: { signal: getScaledSpan(yScaleName, backgroundImage.extents.bottom, backgroundImage.extents.top) @@ -6536,21 +6857,27 @@ function getScaledValue(scaleName, value) { return `scale('${scaleName}', ${value})`; } -},{"./layouts/band":"isnFL","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fHczm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./layouts/band":"3pFuA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"d6Ht8":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aLUrZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1NHSP":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"j6CcD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4F93b":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _compare = require("./compare"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +var _compare = require("./compare"); parcelHelpers.exportAll(_compare, exports); var _exec = require("./exec"); parcelHelpers.exportAll(_exec, exports); @@ -6563,17 +6890,17 @@ parcelHelpers.exportAll(_narrow, exports); var _types = require("./types"); parcelHelpers.exportAll(_types, exports); -},{"./compare":"6Tmaf","./exec":"aGWO6","./group":"1B3Om","./invert":"6JO30","./narrow":"gWeIf","./types":"jMLxd","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6Tmaf":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./compare":"lDdGy","./exec":"ekkGf","./group":"4OkbD","./invert":"DMPkf","./narrow":"jhXKW","./types":"eHpZP","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lDdGy":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "compareExpression", ()=>compareExpression); parcelHelpers.export(exports, "compareGroup", ()=>compareGroup); parcelHelpers.export(exports, "compare", ()=>compare); parcelHelpers.export(exports, "startsWith", ()=>startsWith); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _group = require("./group"); +var _group = require("./group"); const expressionKeys = Object.keys({ clause: null, name: null, @@ -6632,13 +6959,13 @@ function startsWith(whole, part) { return true; } -},{"./group":"1B3Om","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1B3Om":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./group":"4OkbD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4OkbD":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "isSearchExpressionGroup", ()=>isSearchExpressionGroup); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "isSearchExpressionGroup", ()=>isSearchExpressionGroup); parcelHelpers.export(exports, "createGroupFromExpression", ()=>createGroupFromExpression); parcelHelpers.export(exports, "ensureSearchExpressionGroupArray", ()=>ensureSearchExpressionGroupArray); function isSearchExpressionGroup(search) { @@ -6665,47 +6992,47 @@ function ensureSearchExpressionGroupArray(search) { ]; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aGWO6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Exec", ()=>Exec); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ekkGf":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _group = require("./group"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Exec", ()=>Exec); +var _group = require("./group"); function valueToBoolean(value) { - if (typeof value === "string") switch(value.toLowerCase()){ - case "true": + if (typeof value === 'string') switch(value.toLowerCase()){ + case 'true': return true; - case "false": + case 'false': return false; } return !!value; } function valueToString(value) { - if (value == null) return ""; + if (value == null) return ''; switch(typeof value){ - case "string": + case 'string': return value; - case "boolean": - case "number": + case 'boolean': + case 'number': return value.toString(); } - return ""; + return ''; } function isStringOperation(ex) { switch(ex.operator){ - case "contains": - case "!contains": - case "starts": - case "!starts": + case 'contains': + case '!contains': + case 'starts': + case '!starts': return true; } return false; } function isnullorEmpty(value) { if (value == null) return true; //double equal sign to also catch undefined - if (typeof value === "string" && value.length === 0) return true; + if (typeof value === 'string' && value.length === 0) return true; return false; } class Exec { @@ -6732,15 +7059,15 @@ class Exec { } runExpressionOnColumn(datum, ex) { const actualDataValue = datum[ex.name]; - if (ex.operator === "isnullorEmpty") return isnullorEmpty(actualDataValue); - else if (ex.operator === "!isnullorEmpty") return !isnullorEmpty(actualDataValue); + if (ex.operator === 'isnullorEmpty') return isnullorEmpty(actualDataValue); + else if (ex.operator === '!isnullorEmpty') return !isnullorEmpty(actualDataValue); let dataValue = actualDataValue; let expressionValue = ex.value; if (ex.column) { - if (ex.column.type === "string" || ex.stringOperation) { + if (ex.column.type === 'string' || ex.stringOperation) { dataValue = valueToString(actualDataValue).toLocaleLowerCase(); expressionValue = ex.valueLow; - } else if (ex.column.type === "boolean") { + } else if (ex.column.type === 'boolean') { dataValue = valueToBoolean(actualDataValue); expressionValue = ex.valueBool; } else if (ex.column.quantitative) { @@ -6749,25 +7076,25 @@ class Exec { } } switch(ex.operator){ - case "!=": + case '!=': return dataValue != expressionValue; - case "<": + case '<': return dataValue < expressionValue; - case "<=": + case '<=': return dataValue <= expressionValue; - case "==": + case '==': return dataValue == expressionValue; - case ">": + case '>': return dataValue > expressionValue; - case ">=": + case '>=': return dataValue >= expressionValue; - case "contains": + case 'contains': return dataValue.indexOf(expressionValue) >= 0; - case "!contains": + case '!contains': return dataValue.indexOf(expressionValue) < 0; - case "starts": + case 'starts': return dataValue.indexOf(expressionValue) == 0; - case "!starts": + case '!starts': return dataValue.indexOf(expressionValue) !== 0; } } @@ -6780,7 +7107,7 @@ class Exec { column, name: column.name }); - if (i) ex2.clause = "||"; + if (i) ex2.clause = '||'; return ex2; }) }; @@ -6792,10 +7119,10 @@ class Exec { for(let i = 1; i < group.expressions.length; i++){ const ex = group.expressions[i]; switch(ex.clause){ - case "&&": + case '&&': accumulator = accumulator && this.runExpression(datum, ex); break; - case "||": + case '||': accumulator = accumulator || this.runExpression(datum, ex); break; } @@ -6807,10 +7134,10 @@ class Exec { for(let i = 1; i < this.groups.length; i++){ const group = this.groups[i]; switch(group.clause){ - case "&&": + case '&&': accumulator = accumulator && this.runGroup(datum, group); break; - case "||": + case '||': accumulator = accumulator || this.runGroup(datum, group); break; } @@ -6819,14 +7146,14 @@ class Exec { } } -},{"./group":"1B3Om","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6JO30":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "invert", ()=>invert); +},{"./group":"4OkbD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"DMPkf":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _group = require("./group"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "invert", ()=>invert); +var _group = require("./group"); function invertSearchExpressionGroup(input) { //this only works if all expressions in this group have the same clause const output = { @@ -6836,22 +7163,22 @@ function invertSearchExpressionGroup(input) { return output; } const invertedOperators = { - "!=": "==", - "==": "!=", - "<": ">=", - ">=": "<", - "<=": ">", - ">": "<=", - "!contains": "contains", - "contains": "!contains", - "!isnullorEmpty": "isnullorEmpty", - "isnullorEmpty": "!isnullorEmpty", - "!starts": "starts", - "starts": "!starts" + '!=': '==', + '==': '!=', + '<': '>=', + '>=': '<', + '<=': '>', + '>': '<=', + '!contains': 'contains', + 'contains': '!contains', + '!isnullorEmpty': 'isnullorEmpty', + 'isnullorEmpty': '!isnullorEmpty', + '!starts': 'starts', + 'starts': '!starts' }; const invertedClauses = { - "&&": "||", - "||": "&&" + '&&': '||', + '||': '&&' }; function invertSearchExpression(input) { const operator = invertedOperators[input.operator]; @@ -6867,14 +7194,14 @@ function invert(search) { else return invertSearchExpression(search); } -},{"./group":"1B3Om","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gWeIf":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "narrow", ()=>narrow); +},{"./group":"4OkbD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jhXKW":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _group = require("./group"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "narrow", ()=>narrow); +var _group = require("./group"); function narrow(a, b) { if (!a) return b; const arrs = [ @@ -6882,30 +7209,36 @@ function narrow(a, b) { b ].map((0, _group.ensureSearchExpressionGroupArray)); const [arrA, arrB] = arrs; - arrB[0].clause = "&&"; + arrB[0].clause = '&&'; return arrA.concat(arrB); } -},{"./group":"1B3Om","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jMLxd":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./group":"4OkbD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eHpZP":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gjMTK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bD3z1":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3kvmX":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g08sL":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "getColumnsFromData", ()=>(0, _sanddanceSpecs.getColumnsFromData)); parcelHelpers.export(exports, "getStats", ()=>(0, _sanddanceSpecs.getStats)); parcelHelpers.export(exports, "inferAll", ()=>(0, _sanddanceSpecs.inferAll)); parcelHelpers.export(exports, "getPresenterStyle", ()=>(0, _defaults.getPresenterStyle)); parcelHelpers.export(exports, "isInternalFieldName", ()=>isInternalFieldName); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("./constants"); +var _constants = require("./constants"); var _sanddanceSpecs = require("@msrvida/sanddance-specs"); var _defaults = require("./defaults"); function isInternalFieldName(columnName, includeVegaMorphChartsFields = false) { @@ -6918,75 +7251,75 @@ function isInternalFieldName(columnName, includeVegaMorphChartsFields = false) { return false; } -},{"./constants":"ghoOR","@msrvida/sanddance-specs":"4hjOh","./defaults":"lNUGC","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lNUGC":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./constants":"ix2qh","@msrvida/sanddance-specs":"aOvSr","./defaults":"7bMd0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7bMd0":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "defaultViewerOptions", ()=>defaultViewerOptions); parcelHelpers.export(exports, "getPresenterStyle", ()=>getPresenterStyle); parcelHelpers.export(exports, "cssPrefix", ()=>cssPrefix); parcelHelpers.export(exports, "dualColorSchemeColors", ()=>dualColorSchemeColors); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -const { defaultPresenterStyle } = _vegaMorphcharts.defaults; +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +const { defaultPresenterStyle } = _vegaMorphcharts.defaults; const defaultViewerOptions = { colors: { - activeCube: "purple", + activeCube: 'purple', defaultCube: _vegaMorphcharts.util.colorToString(defaultPresenterStyle.defaultCubeColor), hoveredCube: _vegaMorphcharts.util.colorToString(defaultPresenterStyle.highlightColor), - selectedCube: "yellow", + selectedCube: 'yellow', axisSelectHighlight: _vegaMorphcharts.util.colorToString([ 128, 128, 128, 128 ]), - axisLine: "#000", - axisText: "#000", - gridLine: "#CCC", - backgroundColor: "#FFF" + axisLine: '#000', + axisText: '#000', + gridLine: '#CCC', + backgroundColor: '#FFF' }, language: { headers: { - chart: "Chart", - details: "Details", - legend: "Legend", - selection: "Select & Filter" - }, - bing: "bing", - newColorMap: "remap color to filtered items", - oldColorMap: "keep same colors", - deselect: "deselect", - exclude: "exclude", - isolate: "isolate", - legendOther: "other", - nextDetail: ">", - previousDetail: "<", - reset: "reset", - colorBinCount: "Color bin count", - colorReverse: "Color reverse", - count: "Count", - percent: "Percent", - sum: "Sum", - scatterPointScale: "Point scale", - FacetMaxBins: "Facet max bins", - FacetVMaxBins: "Cross facet max bins", - XMaxBins: "X axis max bins", - YMaxBins: "Y axis max bins", - XGridSize: "X grid size", - YGridSize: "Y grid size", - InnerPaddingSize: "Inner padding size", - OuterPaddingSize: "Outer padding size", - treeMapMethod: "Treemap layout", - facetColumns: "Facet columns", - facetRows: "Facet rows", - markOpacitySignal: "Mark opacity", - textScaleSignal: "Text scale", - xAxisTextAngleSignal: "X axis text angle", - yAxisTextAngleSignal: "Y axis text angle", - zGrounded: "Z grounded", - zScaleProportion: "Z scale proportion to Y", + chart: 'Chart', + details: 'Details', + legend: 'Legend', + selection: 'Select & Filter' + }, + bing: 'bing', + newColorMap: 'remap color to filtered items', + oldColorMap: 'keep same colors', + deselect: 'deselect', + exclude: 'exclude', + isolate: 'isolate', + legendOther: 'other', + nextDetail: '>', + previousDetail: '<', + reset: 'reset', + colorBinCount: 'Color bin count', + colorReverse: 'Color reverse', + count: 'Count', + percent: 'Percent', + sum: 'Sum', + scatterPointScale: 'Point scale', + FacetMaxBins: 'Facet max bins', + FacetVMaxBins: 'Cross facet max bins', + XMaxBins: 'X axis max bins', + YMaxBins: 'Y axis max bins', + XGridSize: 'X grid size', + YGridSize: 'Y grid size', + InnerPaddingSize: 'Inner padding size', + OuterPaddingSize: 'Outer padding size', + treeMapMethod: 'Treemap layout', + facetColumns: 'Facet columns', + facetRows: 'Facet rows', + markOpacitySignal: 'Mark opacity', + textScaleSignal: 'Text scale', + xAxisTextAngleSignal: 'X axis text angle', + yAxisTextAngleSignal: 'Y axis text angle', + zGrounded: 'Z grounded', + zScaleProportion: 'Z scale proportion to Y', selectionCount: (count)=>`${count} items selected` }, maxLegends: 19, @@ -7009,32 +7342,32 @@ function getPresenterStyle(options) { //} return style; } -const cssPrefix = "sanddance-"; +const cssPrefix = 'sanddance-'; const dualColorSchemeColors = { - black: "#212121", - gray: "#D2D2D2", - blue: "#0060F0", - green: "#00C000", - orange: "#FF9900", - red: "#E00000" + black: '#212121', + gray: '#D2D2D2', + blue: '#0060F0', + green: '#00C000', + orange: '#FF9900', + red: '#E00000' }; -},{"@msrvida/vega-morphcharts":"guKLg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"guKLg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/vega-morphcharts":"9Sd5M","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9Sd5M":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "base", ()=>(0, _base.base)); parcelHelpers.export(exports, "use", ()=>(0, _base.use)); parcelHelpers.export(exports, "Presenter", ()=>(0, _presenter.Presenter)); parcelHelpers.export(exports, "ViewGl", ()=>(0, _viewGl.ViewGl)); +parcelHelpers.export(exports, "version", ()=>(0, _version.version)); parcelHelpers.export(exports, "controls", ()=>_controls); parcelHelpers.export(exports, "defaults", ()=>_defaults); parcelHelpers.export(exports, "types", ()=>_types); parcelHelpers.export(exports, "util", ()=>_util); -parcelHelpers.export(exports, "version", ()=>(0, _version.version)); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _controls = require("./exports/controls"); +var _controls = require("./exports/controls"); var _types = require("./exports/types"); var _util = require("./exports/util"); var _defaults = require("./defaults"); @@ -7045,47 +7378,47 @@ var _enums = require("./enums"); parcelHelpers.exportAll(_enums, exports); var _version = require("./version"); -},{"./exports/controls":"gr2ze","./exports/types":"j5ekF","./exports/util":"5jv9L","./defaults":"4ObFg","./base":"77OTl","./presenter":"lSg1r","./vega-classes/viewGl":"58pd9","./enums":"cMvaW","./version":"lJKL8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gr2ze":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -//alphabetize variables for documentation -parcelHelpers.export(exports, "Table", ()=>(0, _controls.Table)); +},{"./exports/controls":"7DYOW","./exports/types":"jWJzt","./exports/util":"iZ1f5","./defaults":"4Q1zd","./base":"hIePf","./presenter":"9yYY0","./vega-classes/viewGl":"3abZO","./enums":"hnVHt","./version":"eMVZG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7DYOW":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. */ /** * This file is for external facing export only, do not use this for internal references, * as it may cause circular dependencies in Rollup. - */ var _controls = require("../controls"); - -},{"../controls":"gjf7F","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gjf7F":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Table", ()=>Table); +//alphabetize variables for documentation +parcelHelpers.export(exports, "Table", ()=>(0, _controls.Table)); +var _controls = require("../controls"); + +},{"../controls":"9lm1L","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9lm1L":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _tsxCreateElement = require("tsx-create-element"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Table", ()=>Table); +var _tsxCreateElement = require("tsx-create-element"); const KeyCodes = { - ENTER: "Enter" + ENTER: 'Enter' }; const Table = (props)=>{ return (0, _tsxCreateElement.createElement)("table", { className: props.className }, props.children, props.rows.map((row, i)=>(0, _tsxCreateElement.createElement)("tr", { - className: props.rowClassName || "", + className: props.rowClassName || '', onClick: (e)=>props.onRowClick && props.onRowClick(e, i), tabIndex: props.onRowClick ? 0 : -1, onKeyUp: (e)=>{ if (e.key === KeyCodes.ENTER && props.onRowClick) props.onRowClick(e, i); } }, row.cells.map((cell, i)=>(0, _tsxCreateElement.createElement)("td", { - className: cell.className || "", - title: cell.title || "" + className: cell.className || '', + title: cell.title || '' }, cell.content))))); }; -},{"tsx-create-element":"c7YxA","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"c7YxA":[function(require,module,exports) { +},{"tsx-create-element":"dPDUq","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dPDUq":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "createElement", ()=>createElement); @@ -7105,11 +7438,11 @@ const svgTagArray = _svgTags.default || _svgTags; * * @param str String in camelcase * @param separator Separator for the new decamelized string. - */ function decamelize(str, separator = "-") { - return str.replace(/([a-z\d])([A-Z])/g, "$1" + separator + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + separator + "$2").toLowerCase(); + */ function decamelize(str, separator = '-') { + return str.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2').replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2').toLowerCase(); } function createElement(tag, attrs, ...children) { - if (typeof tag === "function") { + if (typeof tag === 'function') { const fn = tag; const props = attrs; props.children = children; @@ -7121,14 +7454,14 @@ function createElement(tag, attrs, ...children) { let ref; for(let name in map)if (name && map.hasOwnProperty(name)) { let value = map[name]; - if (name === "className" && value !== void 0) setAttribute(el, ns, "class", value.toString()); - else if (name === "disabled" && !value) ; + if (name === 'className' && value !== void 0) setAttribute(el, ns, 'class', value.toString()); + else if (name === 'disabled' && !value) ; else if (value === null || value === undefined) continue; else if (value === true) setAttribute(el, ns, name, name); - else if (typeof value === "function") { - if (name === "ref") ref = value; + else if (typeof value === 'function') { + if (name === 'ref') ref = value; else el[name.toLowerCase()] = value; - } else if (typeof value === "object") setAttribute(el, ns, name, flatten(value)); + } else if (typeof value === 'object') setAttribute(el, ns, name, flatten(value)); else setAttribute(el, ns, name, value.toString()); } if (children && children.length > 0) appendChildren(el, children); @@ -7142,8 +7475,8 @@ function setAttribute(el, ns, name, value) { } function flatten(o) { const arr = []; - for(let prop in o)arr.push(`${decamelize(prop, "-")}:${o[prop]}`); - return arr.join(";"); + for(let prop in o)arr.push(`${decamelize(prop, '-')}:${o[prop]}`); + return arr.join(';'); } function addChild(parentElement, child) { if (child === null || child === undefined || typeof child === "boolean") return; @@ -7159,7 +7492,7 @@ function isElement(el) { return !!el.nodeType; } function mount(element, container) { - container.innerHTML = ""; + container.innerHTML = ''; if (element) addChild(container, element); } function findElementByChildPositions(childPositions, container) { @@ -7185,7 +7518,7 @@ function setActiveElement(activeElementInfo, container) { } function getActiveElementInfo(container) { let element = document.activeElement; - const { scrollTop , selectionDirection , selectionEnd , selectionStart } = element; + const { scrollTop, selectionDirection, selectionEnd, selectionStart } = element; const activeElementInfo = { childPositions: [], scrollTop, @@ -7206,62 +7539,63 @@ function getChildPosition(element) { } function tagNamespace(tag) { //issue: this won't disambiguate certain tags which exist in both svg and html: , ... - if (tag === "svg" || svgTagArray.indexOf(tag) >= 0 && !(htmlTagArray.indexOf(tag) >= 0)) return "http://www.w3.org/2000/svg"; + if (tag === 'svg' || svgTagArray.indexOf(tag) >= 0 && !(htmlTagArray.indexOf(tag) >= 0)) return "http://www.w3.org/2000/svg"; } -},{"html-tags":"6ra8f","svg-tags":"3HsYn","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6ra8f":[function(require,module,exports) { -"use strict"; -module.exports = require("./html-tags.json"); +},{"html-tags":"d5cAX","svg-tags":"kuFQD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"d5cAX":[function(require,module,exports,__globalThis) { +'use strict'; +module.exports = require("6c9bf1ded7f8a5a1"); -},{"./html-tags.json":"dUGGF"}],"dUGGF":[function(require,module,exports) { -module.exports = JSON.parse('["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]'); +},{"6c9bf1ded7f8a5a1":"6OgGY"}],"6OgGY":[function(require,module,exports,__globalThis) { +module.exports = JSON.parse("[\"a\",\"abbr\",\"address\",\"area\",\"article\",\"aside\",\"audio\",\"b\",\"base\",\"bdi\",\"bdo\",\"blockquote\",\"body\",\"br\",\"button\",\"canvas\",\"caption\",\"cite\",\"code\",\"col\",\"colgroup\",\"data\",\"datalist\",\"dd\",\"del\",\"details\",\"dfn\",\"dialog\",\"div\",\"dl\",\"dt\",\"em\",\"embed\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hgroup\",\"hr\",\"html\",\"i\",\"iframe\",\"img\",\"input\",\"ins\",\"kbd\",\"keygen\",\"label\",\"legend\",\"li\",\"link\",\"main\",\"map\",\"mark\",\"math\",\"menu\",\"menuitem\",\"meta\",\"meter\",\"nav\",\"noscript\",\"object\",\"ol\",\"optgroup\",\"option\",\"output\",\"p\",\"param\",\"picture\",\"pre\",\"progress\",\"q\",\"rb\",\"rp\",\"rt\",\"rtc\",\"ruby\",\"s\",\"samp\",\"script\",\"section\",\"select\",\"slot\",\"small\",\"source\",\"span\",\"strong\",\"style\",\"sub\",\"summary\",\"sup\",\"svg\",\"table\",\"tbody\",\"td\",\"template\",\"textarea\",\"tfoot\",\"th\",\"thead\",\"time\",\"title\",\"tr\",\"track\",\"u\",\"ul\",\"var\",\"video\",\"wbr\"]"); -},{}],"3HsYn":[function(require,module,exports) { -module.exports = require("./svg-tags.json"); +},{}],"kuFQD":[function(require,module,exports,__globalThis) { +module.exports = require("8c03a2b8d2417863"); -},{"./svg-tags.json":"cn9qA"}],"cn9qA":[function(require,module,exports) { -module.exports = JSON.parse('["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"]'); +},{"8c03a2b8d2417863":"d3wrv"}],"d3wrv":[function(require,module,exports,__globalThis) { +module.exports = JSON.parse("[\"a\",\"altGlyph\",\"altGlyphDef\",\"altGlyphItem\",\"animate\",\"animateColor\",\"animateMotion\",\"animateTransform\",\"circle\",\"clipPath\",\"color-profile\",\"cursor\",\"defs\",\"desc\",\"ellipse\",\"feBlend\",\"feColorMatrix\",\"feComponentTransfer\",\"feComposite\",\"feConvolveMatrix\",\"feDiffuseLighting\",\"feDisplacementMap\",\"feDistantLight\",\"feFlood\",\"feFuncA\",\"feFuncB\",\"feFuncG\",\"feFuncR\",\"feGaussianBlur\",\"feImage\",\"feMerge\",\"feMergeNode\",\"feMorphology\",\"feOffset\",\"fePointLight\",\"feSpecularLighting\",\"feSpotLight\",\"feTile\",\"feTurbulence\",\"filter\",\"font\",\"font-face\",\"font-face-format\",\"font-face-name\",\"font-face-src\",\"font-face-uri\",\"foreignObject\",\"g\",\"glyph\",\"glyphRef\",\"hkern\",\"image\",\"line\",\"linearGradient\",\"marker\",\"mask\",\"metadata\",\"missing-glyph\",\"mpath\",\"path\",\"pattern\",\"polygon\",\"polyline\",\"radialGradient\",\"rect\",\"script\",\"set\",\"stop\",\"style\",\"svg\",\"switch\",\"symbol\",\"text\",\"textPath\",\"title\",\"tref\",\"tspan\",\"use\",\"view\",\"vkern\"]"); -},{}],"j5ekF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -//alphabetize interfaces for documentation -parcelHelpers.export(exports, "MorphChartsCore", ()=>(0, _interfaces.MorphChartsCore)); +},{}],"jWJzt":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. */ /** * This file is for external facing export only, do not use this for internal references, * as it may cause circular dependencies in Rollup. - */ var _interfaces = require("../interfaces"); - -},{"../interfaces":"6YWfl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6YWfl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "MorphChartsCore", ()=>(0, _morphcharts.Core)); +//alphabetize interfaces for documentation +parcelHelpers.export(exports, "MorphChartsCore", ()=>(0, _interfaces.MorphChartsCore)); +var _interfaces = require("../interfaces"); + +},{"../interfaces":"5p3aO","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5p3aO":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); - -},{"morphcharts":"eKLJv","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eKLJv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "MorphChartsCore", ()=>(0, _morphcharts.Core)); +var _morphcharts = require("morphcharts"); + +},{"morphcharts":"9s7CR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9s7CR":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Core", ()=>(0, _mainJs.Core)); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Core", ()=>(0, _mainJs.Core)); parcelHelpers.export(exports, "ModelView", ()=>(0, _mainJs.ModelView)); -parcelHelpers.export(exports, "PlotType", ()=>(0, _mainJs.PlotType)); parcelHelpers.export(exports, "SingleTouchAction", ()=>(0, _mainJs.SingleTouchAction)); parcelHelpers.export(exports, "UnitType", ()=>(0, _mainJs.UnitType)); parcelHelpers.export(exports, "Theme", ()=>(0, _mainJs.Theme)); parcelHelpers.export(exports, "PickType", ()=>(0, _mainJs.PickType)); parcelHelpers.export(exports, "SelectionMode", ()=>(0, _mainJs.SelectionMode)); +parcelHelpers.export(exports, "HighlightMode", ()=>(0, _mainJs.HighlightMode)); parcelHelpers.export(exports, "FilterMode", ()=>(0, _mainJs.FilterMode)); parcelHelpers.export(exports, "AxesTextOrientation", ()=>(0, _mainJs.AxesTextOrientation)); parcelHelpers.export(exports, "Orientation", ()=>(0, _mainJs.Orientation)); parcelHelpers.export(exports, "StereoMode", ()=>(0, _mainJs.StereoMode)); +parcelHelpers.export(exports, "RenderMode", ()=>(0, _mainJs.RenderMode)); parcelHelpers.export(exports, "HorizontalAlignment", ()=>(0, _mainJs.HorizontalAlignment)); parcelHelpers.export(exports, "VerticalAlignment", ()=>(0, _mainJs.VerticalAlignment)); parcelHelpers.export(exports, "LogLevel", ()=>(0, _mainJs.LogLevel)); @@ -7295,6 +7629,14 @@ parcelHelpers.export(exports, "Meshes", ()=>_indexJs6); parcelHelpers.export(exports, "Renderers", ()=>_indexJs7); parcelHelpers.export(exports, "Tables", ()=>_indexJs8); parcelHelpers.export(exports, "Cameras", ()=>_indexJs9); +var _mainJs = require("./main.js"); +var _paletteJs = require("./palette.js"); +var _configJs = require("./config.js"); +var _constantsJs = require("./constants.js"); +var _colorsJs = require("./colors.js"); +var _fontJs = require("./font.js"); +var _mapJs = require("./map.js"); +var _iconsJs = require("./icons.js"); var _indexJs = require("./components/index.js"); var _indexJs1 = require("./components/axes/index.js"); var _indexJs2 = require("./helpers/index.js"); @@ -7305,182 +7647,12 @@ var _indexJs6 = require("./meshes/index.js"); var _indexJs7 = require("./renderers/index.js"); var _indexJs8 = require("./tables/index.js"); var _indexJs9 = require("./cameras/index.js"); -var _mainJs = require("./main.js"); -var _paletteJs = require("./palette.js"); -var _configJs = require("./config.js"); -var _constantsJs = require("./constants.js"); -var _colorsJs = require("./colors.js"); -var _fontJs = require("./font.js"); -var _mapJs = require("./map.js"); -var _iconsJs = require("./icons.js"); - -},{"./components/index.js":"lEIOn","./components/axes/index.js":"gZn9D","./helpers/index.js":"fBjC9","./layouts/index.js":"8NW4M","./input/index.js":"2TO94","./providers/index.js":"hlPw6","./meshes/index.js":"dI7q8","./renderers/index.js":"bvOAu","./tables/index.js":"6ceod","./cameras/index.js":"dDVZM","./main.js":"1Kju3","./palette.js":"8zxgm","./config.js":"jvVb3","./constants.js":"2Scl5","./colors.js":"lwUwQ","./font.js":"5CPIb","./map.js":"eFmnR","./icons.js":"hMOrK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lEIOn":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Controller", ()=>(0, _controllerJs.Controller)); -parcelHelpers.export(exports, "ControllerVisual", ()=>(0, _controllerJs.ControllerVisual)); -parcelHelpers.export(exports, "Label", ()=>(0, _labelsJs.Label)); -parcelHelpers.export(exports, "LabelVisual", ()=>(0, _labelsJs.LabelVisual)); -parcelHelpers.export(exports, "LabelSet", ()=>(0, _labelsJs.LabelSet)); -parcelHelpers.export(exports, "LabelSetVisual", ()=>(0, _labelsJs.LabelSetVisual)); -parcelHelpers.export(exports, "ImageVisual", ()=>(0, _imageJs.ImageVisual)); -parcelHelpers.export(exports, "ImageQuad", ()=>(0, _imageJs.ImageQuad)); -parcelHelpers.export(exports, "ImageSphere", ()=>(0, _imageJs.ImageSphere)); -parcelHelpers.export(exports, "NominalKey", ()=>(0, _keysJs.NominalKey)); -var _controllerJs = require("./controller.js"); -var _labelsJs = require("./labels.js"); -var _imageJs = require("./image.js"); -var _keysJs = require("./keys.js"); -},{"./controller.js":"jirYv","./labels.js":"4IFc8","./image.js":"llF9m","./keys.js":"21hIN","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jirYv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ControllerVisual", ()=>ControllerVisual); -parcelHelpers.export(exports, "Controller", ()=>Controller); +},{"./main.js":"f421K","./palette.js":"hZb65","./config.js":"bCTP3","./constants.js":"lD0bG","./colors.js":"cYEeU","./font.js":"ibkbS","./map.js":"5JhCv","./icons.js":"lPq9g","./components/index.js":"5C4Hk","./components/axes/index.js":"eiGCN","./helpers/index.js":"9v1at","./layouts/index.js":"duBHP","./input/index.js":"flmwt","./providers/index.js":"hACG3","./meshes/index.js":"6XXZT","./renderers/index.js":"1IHvF","./tables/index.js":"dUaaI","./cameras/index.js":"h7YGk","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"f421K":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _mainJs = require("../main.js"); -var _objJs = require("../helpers/obj.js"); -var _glMatrix = require("gl-matrix"); -var _cubeJs = require("../meshes/cube.js"); -var _vertexJs = require("../vertex.js"); -class ControllerVisual { - render(elapsedTime, xrFrame) {} - update(elapsedTime) {} - constructor(controller){ - this.controller = controller; - } -} -class Controller { - get isInitialized() { - return this._isInitialized; - } - get mMatrix() { - return this._mMatrix; - } - get indexCount() { - return this._indexCount; - } - get vertices() { - return this._vertices; - } - get indices() { - return this._indices; - } - get texture() { - return this._texture; - } - get rayMMatrix() { - return this._rayMMatrix; - } - get rayIndexCount() { - return this._rayIndexCount; - } - get rayVertices() { - return this._rayVertices; - } - get rayIndices() { - return this._rayIndices; - } - constructor(core, options){ - this._cubeObj = `o Cube -v 1.000000 -1.000000 -1.000000 -v 1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 1.000000 -v -1.000000 -1.000000 -1.000000 -v 1.000000 1.000000 -0.999999 -v 0.999999 1.000000 1.000001 -v -1.000000 1.000000 1.000000 -v -1.000000 1.000000 -1.000000 -vt 1.000000 0.333333 -vt 1.000000 0.666667 -vt 0.666667 0.666667 -vt 0.666667 0.333333 -vt 0.666667 0.000000 -vt 0.000000 0.333333 -vt 0.000000 0.000000 -vt 0.333333 0.000000 -vt 0.333333 1.000000 -vt 0.000000 1.000000 -vt 0.000000 0.666667 -vt 0.333333 0.333333 -vt 0.333333 0.666667 -vt 1.000000 0.000000 -vn 0.000000 -1.000000 0.000000 -vn 0.000000 1.000000 0.000000 -vn 1.000000 0.000000 0.000000 -vn -0.000000 0.000000 1.000000 -vn -1.000000 -0.000000 -0.000000 -vn 0.000000 0.000000 -1.000000 -s off -f 2/1/1 3/2/1 4/3/1 -f 8/1/2 7/4/2 6/5/2 -f 5/6/3 6/7/3 2/8/3 -f 6/8/4 7/5/4 3/4/4 -f 3/9/5 7/10/5 8/11/5 -f 1/12/6 4/13/6 8/11/6 -f 1/4/1 2/1/1 4/3/1 -f 5/14/2 8/1/2 6/5/2 -f 1/12/3 5/6/3 2/8/3 -f 2/12/4 6/8/4 3/4/4 -f 4/13/5 3/9/5 8/11/5 -f 5/6/6 1/12/6 8/11/6`; - this._core = core; - this._obj = options.obj; - this._texture = options.texture || new ImageData(new Uint8ClampedArray([ - 0, - 0, - 0, - 255 - ]), 1, 1); - } - initialize() { - const _vec3 = (0, _glMatrix.vec3).create(); - this._mMatrix = (0, _glMatrix.mat4).create(); - const objMesh = new (0, _objJs.ObjHelper)(this._core).read(this._obj || this._cubeObj); - if (!this._obj) { - this.useRayPose = true; - const modelThickness = 0.02; - const modelLength = 0.1; - (0, _glMatrix.vec3).set(_vec3, modelThickness, modelThickness, modelLength); - (0, _glMatrix.mat4).fromScaling(this._mMatrix, _vec3); - (0, _glMatrix.vec3).set(_vec3, 0, 0, 1); - (0, _glMatrix.mat4).translate(this._mMatrix, this._mMatrix, _vec3); - } - this._vertices = objMesh.vertices; - this._indices = objMesh.indices; - this._indexCount = objMesh.indexCount; - this._rayMMatrix = (0, _glMatrix.mat4).create(); - const rayVertices = (0, _cubeJs.Cube).POSITIONS; - this._rayVertices = new ArrayBuffer((0, _vertexJs.PositionColorVertex).SIZE_BYTES * rayVertices.length / (0, _vertexJs.PositionVertex).SIZE); - const rayVerticesView = new DataView(this._rayVertices); - const rayIndices = (0, _cubeJs.Cube).INDICES; - this._rayIndices = new Uint16Array(rayIndices); - const rayVertexCount = rayVertices.length / (0, _vertexJs.PositionVertex).SIZE; - this._rayIndexCount = rayIndices.length; - for(let i = 0; i < rayVertexCount; i++){ - (0, _glMatrix.vec3).set(_vec3, rayVertices[i * (0, _vertexJs.PositionVertex).SIZE], rayVertices[i * (0, _vertexJs.PositionVertex).SIZE + 1], rayVertices[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _vertexJs.PositionColorVertex).setPosition(rayVerticesView, i, _vec3); - (0, _vertexJs.PositionColorVertex).setColor(rayVerticesView, i, this._core.config.xrControllerRayColor); - } - const rayThickness = 0.0025; - const rayLength = 10; - (0, _glMatrix.vec3).set(_vec3, rayThickness, rayThickness, rayLength); - (0, _glMatrix.mat4).fromScaling(this._rayMMatrix, _vec3); - (0, _glMatrix.vec3).set(_vec3, 0, 0, -0.5); - (0, _glMatrix.mat4).translate(this._rayMMatrix, this._rayMMatrix, _vec3); - this._isInitialized = true; - this._core.log.write((0, _mainJs.LogLevel).info, "controller initialized"); - } - update(elapsedTime) {} -} - -},{"../main.js":"1Kju3","../helpers/obj.js":"9htAN","gl-matrix":"9GjEQ","../meshes/cube.js":"7rTMs","../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1Kju3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "ModelView", ()=>ModelView); parcelHelpers.export(exports, "Core", ()=>Core); @@ -7498,7 +7670,6 @@ parcelHelpers.export(exports, "PickType", ()=>PickType); parcelHelpers.export(exports, "Theme", ()=>Theme); parcelHelpers.export(exports, "HighlightMode", ()=>HighlightMode); parcelHelpers.export(exports, "UnitType", ()=>UnitType); -parcelHelpers.export(exports, "PlotType", ()=>PlotType); parcelHelpers.export(exports, "SingleTouchAction", ()=>SingleTouchAction); parcelHelpers.export(exports, "MouseWheelAction", ()=>MouseWheelAction); parcelHelpers.export(exports, "LogLevel", ()=>LogLevel); @@ -7507,10 +7678,8 @@ parcelHelpers.export(exports, "Face2D", ()=>Face2D); parcelHelpers.export(exports, "Edge3D", ()=>Edge3D); parcelHelpers.export(exports, "Face3D", ()=>Face3D); parcelHelpers.export(exports, "HexOrientation", ()=>HexOrientation); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); +parcelHelpers.export(exports, "RenderMode", ()=>RenderMode); +var _glMatrix = require("gl-matrix"); var _altazimuthJs = require("./cameras/altazimuth.js"); var _configJs = require("./config.js"); var _constantsJs = require("./constants.js"); @@ -7527,6 +7696,33 @@ var _vertexJs = require("./vertex.js"); var _managerJs = require("./input/manager.js"); var _logJs = require("./log.js"); var _mathJs = require("./helpers/math.js"); +var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; class ModelView { constructor(core){ this.position = (0, _glMatrix.vec3).create(); @@ -7592,11 +7788,12 @@ class Core { return this._renderer; } set renderer(renderer) { + if (this._renderer == renderer) return; if (this._renderer) { this.stop(); this._renderer.remove(); } - renderer.initialize(this); + if (!renderer.isInitialized) renderer.initialize(this); if (this._renderer) { renderer.transitionTime = this._renderer.transitionTime; for(let i = 0; i < this._renderer.transitionBuffers.length; i++){ @@ -7608,8 +7805,8 @@ class Core { const currentAxes = this._renderer.currentAxes; if (currentAxes) { renderer.currentAxes = []; - for(let i1 = 0; i1 < currentAxes.length; i1++){ - const axesVisual = currentAxes[i1]; + for(let i = 0; i < currentAxes.length; i++){ + const axesVisual = currentAxes[i]; const axes = axesVisual.axes; if (axes instanceof (0, _cartesian3DJs.Cartesian3dAxes)) { const cartesian3dAxesVisual = renderer.createCartesian3dAxesVisual(axes); @@ -7620,12 +7817,12 @@ class Core { const labelSets = this._renderer.labelSets; if (labelSets) { renderer.labelSets = []; - for(let i2 = 0; i2 < labelSets.length; i2++)renderer.labelSets.push(renderer.createLabelSetVisual(labelSets[i2].label)); + for(let i = 0; i < labelSets.length; i++)renderer.labelSets.push(renderer.createLabelSetVisual(labelSets[i].label)); } const images = this._renderer.images; if (images) { renderer.images = []; - for(let i3 = 0; i3 < images.length; i3++)renderer.images.push(renderer.createImageVisual(images[i3].image)); + for(let i = 0; i < images.length; i++)renderer.images.push(renderer.createImageVisual(images[i].image)); } const fonts = this._renderer.fonts; if (fonts) for(const key in fonts){ @@ -7664,7 +7861,7 @@ class Core { fontAtlas: new (0, _fontJs.FontAtlas)(256, 512), fontSize: 24, border: 3, - fontFamily: '"segoe ui semibold", sans-serif', + fontFamily: "\"segoe ui semibold\", sans-serif", fontWeight: "normal", fontStyle: "normal", baseline: "alphabetic", @@ -7797,14 +7994,16 @@ class Core { if (event.removed.length > 0) this.renderer.controllers.length = 0; } _tick(currentTime, xrFrame) { - let elapsedTime = currentTime - this._previousTime; - this._previousTime = currentTime; - if (elapsedTime > 0) { - this.update(elapsedTime, xrFrame); - this.render(elapsedTime, xrFrame); - } - if (xrFrame) xrFrame.session.requestAnimationFrame((currentTime, xrframe)=>this._tick(currentTime, xrframe)); - else if (this._started) this._windowAnimationFrame = window.requestAnimationFrame((currentTime)=>this._tick(currentTime)); + return __awaiter(this, void 0, void 0, function*() { + let elapsedTime = currentTime - this._previousTime; + this._previousTime = currentTime; + if (elapsedTime > 0) { + this.update(elapsedTime, xrFrame); + yield this.render(elapsedTime, xrFrame); + } + if (xrFrame) xrFrame.session.requestAnimationFrame((currentTime, xrframe)=>this._tick(currentTime, xrframe)); + else if (this._started) this._windowAnimationFrame = window.requestAnimationFrame((currentTime)=>this._tick(currentTime)); + }); } update(elapsedTime, xrFrame) { this._renderer.setSize(elapsedTime); @@ -7857,11 +8056,13 @@ class Core { if (this._renderer.isInitialized) this._renderer.update(elapsedTime); } render(elapsedTime, xrFrame) { - this._fps.render(); - if (this._renderer.isInitialized) { - this._renderer.render(elapsedTime, xrFrame); - if (this.afterRenderCallback) this.afterRenderCallback(); - } + return __awaiter(this, void 0, void 0, function*() { + this._fps.render(); + if (this._renderer.isInitialized) { + yield this._renderer.render(elapsedTime, xrFrame); + if (this.afterRenderCallback) this.afterRenderCallback(); + } + }); } _syncSmooth() { (0, _glMatrix.vec3).copy(this._smoothedModelPosition, this._modelPosition); @@ -7869,12 +8070,12 @@ class Core { (0, _glMatrix.quat).copy(this._smoothedModelRotation, this._modelRotation); } _updateManipulationOrigin(position) { + this._log.write(LogLevel.info, `manipulation origin ${position[0].toFixed(3)},${position[1].toFixed(3)},${position[2].toFixed(3)}`); this._camera.updateModelManipulationOrigin(this._modelManipulationOrigin, position); (0, _glMatrix.vec3).copy(this._modelManipulationOrigin, position); (0, _glMatrix.vec3).transformMat4(this._vec3, this._modelManipulationOrigin, this._modelMMatrix); (0, _glMatrix.vec3).subtract(this._modelPosition, this._vec3, this._modelManipulationOrigin); (0, _glMatrix.vec3).copy(this._smoothedModelPosition, this._modelPosition); - this._log.write(LogLevel.info, `manipulation origin ${position[0].toFixed(3)},${position[1].toFixed(3)},${position[2].toFixed(3)}`); if (this.manipulationOriginChangedCallback) { const result = { x: position[0], @@ -7927,15 +8128,15 @@ class Core { (0, _glMatrix.vec3).create() ]; const d = []; - for(let i1 = 0; i1 < 4; i1++){ - (0, _glMatrix.vec3).cross(normals[i1], directions[(i1 + 1) % 4], directions[i1]); - (0, _glMatrix.vec3).normalize(normals[i1], normals[i1]); - d.push(-(0, _glMatrix.vec3).dot(normals[i1], nearPositions[i1])); + for(let i = 0; i < 4; i++){ + (0, _glMatrix.vec3).cross(normals[i], directions[(i + 1) % 4], directions[i]); + (0, _glMatrix.vec3).normalize(normals[i], normals[i]); + d.push(-(0, _glMatrix.vec3).dot(normals[i], nearPositions[i])); } if (pickType == PickType.data) { const translation = (0, _glMatrix.vec3).create(); - for(let i2 = 0; i2 < this._renderer.transitionBuffers.length; i2++){ - const transitionBuffer = this._renderer.transitionBuffers[i2]; + for(let i = 0; i < this._renderer.transitionBuffers.length; i++){ + const transitionBuffer = this._renderer.transitionBuffers[i]; const set = new Set(); if (transitionBuffer.isVisible) { const start = window.performance.now(); @@ -7958,7 +8159,7 @@ class Core { if (isInside) set.add(id); } } - if (set.size > 0) this._log.write(LogLevel.info, `lasso transition buffer ${i2} picked ${set.size} ${Math.round(window.performance.now() - start)}ms`); + if (set.size > 0) this._log.write(LogLevel.info, `lasso transition buffer ${i} picked ${set.size} ${Math.round(window.performance.now() - start)}ms`); } sets.push(set); } @@ -8042,14 +8243,9 @@ const UnitType = { cylinderSdf: "cylinderSdf", hexPrism: "hexPrism", hexPrismSdf: "hexPrismSdf", - sdf: "sdf" -}; -const PlotType = { - scatter: "scatter", - stack: "stack", - line: "line", - nodeLink: "nodeLink", - squarifiedTreeMap: "squarifiedTreeMap" + sdf: "sdf", + disk: "disk", + ringSdf: "ringSdf" }; const SingleTouchAction = { none: "none", @@ -8105,8 +8301,16 @@ const HexOrientation = { pointyTop: "pointyTop", flatTop: "flatTop" }; +const RenderMode = { + color: "color", + hdr: "hdr", + depth: "depth", + normal: "normal", + segment: "segment", + edge: "edge" +}; -},{"gl-matrix":"9GjEQ","./cameras/altazimuth.js":"6C63a","./config.js":"jvVb3","./constants.js":"2Scl5","./debug.js":"9N356","./fps.js":"kylSI","./helpers/angle.js":"eKtPm","./palette.js":"8zxgm","./components/controller.js":"jirYv","./helpers/matrix.js":"cQEMs","./components/axes/cartesian3d.js":"7VqSF","./components/axes/cartesian2d.js":"7HjCZ","./font.js":"5CPIb","./vertex.js":"ddAub","./input/manager.js":"75sHN","./log.js":"9eIyY","./helpers/math.js":"fOnPF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9GjEQ":[function(require,module,exports) { +},{"gl-matrix":"5x28d","./cameras/altazimuth.js":"gRqOf","./config.js":"bCTP3","./constants.js":"lD0bG","./debug.js":"eYPBQ","./fps.js":"9OHgw","./helpers/angle.js":"53hwW","./palette.js":"hZb65","./components/controller.js":"f5tIG","./helpers/matrix.js":"7gWc5","./components/axes/cartesian3d.js":"jfjef","./components/axes/cartesian2d.js":"d0jS2","./font.js":"ibkbS","./vertex.js":"4J2YE","./input/manager.js":"8nDg6","./log.js":"c6yiP","./helpers/math.js":"f65d0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5x28d":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "glMatrix", ()=>_commonJs); @@ -8130,7 +8334,11 @@ var _vec2Js = require("./vec2.js"); var _vec3Js = require("./vec3.js"); var _vec4Js = require("./vec4.js"); -},{"./common.js":"2bz5f","./mat2.js":"bXjt6","./mat2d.js":"jfS5o","./mat3.js":"gHsXS","./mat4.js":"6PEOw","./quat.js":"bBHpM","./quat2.js":"hDV5p","./vec2.js":"2fFbx","./vec3.js":"7D9HD","./vec4.js":"9RmVs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2bz5f":[function(require,module,exports) { +},{"./common.js":"7GML7","./mat2.js":false,"./mat2d.js":false,"./mat3.js":"80EZI","./mat4.js":"e5zmM","./quat.js":"2chmr","./quat2.js":false,"./vec2.js":"eovGI","./vec3.js":"9zs5l","./vec4.js":"ao75m","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7GML7":[function(require,module,exports,__globalThis) { +/** + * Common utilities + * @module glMatrix + */ // Configuration Constants var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "EPSILON", ()=>EPSILON); @@ -8156,7 +8364,7 @@ parcelHelpers.export(exports, "RANDOM", ()=>RANDOM); * @returns {Boolean} True if the numbers are approximately equal, false otherwise. */ parcelHelpers.export(exports, "equals", ()=>equals); var EPSILON = 0.000001; -var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array; +var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array; var RANDOM = Math.random; function setMatrixArrayType(type) { ARRAY_TYPE = type; @@ -8174,213 +8382,295 @@ if (!Math.hypot) Math.hypot = function() { return Math.sqrt(y); }; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bXjt6":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"80EZI":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); /** - * 2x2 Matrix - * @module mat2 + * 3x3 Matrix + * @module mat3 */ /** - * Creates a new identity mat2 + * Creates a new identity mat3 * - * @returns {mat2} a new 2x2 matrix + * @returns {mat3} a new 3x3 matrix */ parcelHelpers.export(exports, "create", ()=>create); /** - * Creates a new mat2 initialized with values from an existing matrix + * Copies the upper-left 3x3 values into the given mat3. + * + * @param {mat3} out the receiving 3x3 matrix + * @param {ReadonlyMat4} a the source 4x4 matrix + * @returns {mat3} out + */ parcelHelpers.export(exports, "fromMat4", ()=>fromMat4); +/** + * Creates a new mat3 initialized with values from an existing matrix * - * @param {ReadonlyMat2} a matrix to clone - * @returns {mat2} a new 2x2 matrix + * @param {ReadonlyMat3} a matrix to clone + * @returns {mat3} a new 3x3 matrix */ parcelHelpers.export(exports, "clone", ()=>clone); /** - * Copy the values from one mat2 to another + * Copy the values from one mat3 to another * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out */ parcelHelpers.export(exports, "copy", ()=>copy); /** - * Set a mat2 to the identity matrix - * - * @param {mat2} out the receiving matrix - * @returns {mat2} out - */ parcelHelpers.export(exports, "identity", ()=>identity); -/** - * Create a new mat2 with the given values + * Create a new mat3 with the given values * * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m10 Component in column 1, row 0 position (index 2) - * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out A new 2x2 matrix + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} A new mat3 */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); /** - * Set the components of a mat2 to the given values + * Set the components of a mat3 to the given values * - * @param {mat2} out the receiving matrix + * @param {mat3} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m10 Component in column 1, row 0 position (index 2) - * @param {Number} m11 Component in column 1, row 1 position (index 3) - * @returns {mat2} out + * @param {Number} m02 Component in column 0, row 2 position (index 2) + * @param {Number} m10 Component in column 1, row 0 position (index 3) + * @param {Number} m11 Component in column 1, row 1 position (index 4) + * @param {Number} m12 Component in column 1, row 2 position (index 5) + * @param {Number} m20 Component in column 2, row 0 position (index 6) + * @param {Number} m21 Component in column 2, row 1 position (index 7) + * @param {Number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} out */ parcelHelpers.export(exports, "set", ()=>set); /** - * Transpose the values of a mat2 + * Set a mat3 to the identity matrix + * + * @param {mat3} out the receiving matrix + * @returns {mat3} out + */ parcelHelpers.export(exports, "identity", ()=>identity); +/** + * Transpose the values of a mat3 * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out */ parcelHelpers.export(exports, "transpose", ()=>transpose); /** - * Inverts a mat2 + * Inverts a mat3 * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out */ parcelHelpers.export(exports, "invert", ()=>invert); /** - * Calculates the adjugate of a mat2 + * Calculates the adjugate of a mat3 * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the source matrix - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the source matrix + * @returns {mat3} out */ parcelHelpers.export(exports, "adjoint", ()=>adjoint); /** - * Calculates the determinant of a mat2 + * Calculates the determinant of a mat3 * - * @param {ReadonlyMat2} a the source matrix + * @param {ReadonlyMat3} a the source matrix * @returns {Number} determinant of a */ parcelHelpers.export(exports, "determinant", ()=>determinant); /** - * Multiplies two mat2's + * Multiplies two mat3's * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the first operand - * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {mat3} out */ parcelHelpers.export(exports, "multiply", ()=>multiply); /** - * Rotates a mat2 by the given angle + * Translate a mat3 by the given vector + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to translate + * @param {ReadonlyVec2} v vector to translate by + * @returns {mat3} out + */ parcelHelpers.export(exports, "translate", ()=>translate); +/** + * Rotates a mat3 by the given angle * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the matrix to rotate + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {mat3} out */ parcelHelpers.export(exports, "rotate", ()=>rotate); /** - * Scales the mat2 by the dimensions in the given vec2 + * Scales the mat3 by the dimensions in the given vec2 * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the matrix to rotate + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to rotate * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2} out + * @returns {mat3} out **/ parcelHelpers.export(exports, "scale", ()=>scale); +/** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.translate(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyVec2} v Translation vector + * @returns {mat3} out + */ parcelHelpers.export(exports, "fromTranslation", ()=>fromTranslation); /** * Creates a matrix from a given angle * This is equivalent to (but much faster than): * - * mat2.identity(dest); - * mat2.rotate(dest, dest, rad); + * mat3.identity(dest); + * mat3.rotate(dest, dest, rad); * - * @param {mat2} out mat2 receiving operation result + * @param {mat3} out mat3 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2} out + * @returns {mat3} out */ parcelHelpers.export(exports, "fromRotation", ()=>fromRotation); /** * Creates a matrix from a vector scaling * This is equivalent to (but much faster than): * - * mat2.identity(dest); - * mat2.scale(dest, dest, vec); + * mat3.identity(dest); + * mat3.scale(dest, dest, vec); * - * @param {mat2} out mat2 receiving operation result + * @param {mat3} out mat3 receiving operation result * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2} out + * @returns {mat3} out */ parcelHelpers.export(exports, "fromScaling", ()=>fromScaling); /** - * Returns a string representation of a mat2 + * Copies the values from a mat2d into a mat3 + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat2d} a the matrix to copy + * @returns {mat3} out + **/ parcelHelpers.export(exports, "fromMat2d", ()=>fromMat2d); +/** + * Calculates a 3x3 matrix from the given quaternion + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyQuat} q Quaternion to create matrix from + * + * @returns {mat3} out + */ parcelHelpers.export(exports, "fromQuat", ()=>fromQuat); +/** + * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix + * + * @param {mat3} out mat3 receiving operation result + * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from + * + * @returns {mat3} out + */ parcelHelpers.export(exports, "normalFromMat4", ()=>normalFromMat4); +/** + * Generates a 2D projection matrix with the given bounds + * + * @param {mat3} out mat3 frustum matrix will be written into + * @param {number} width Width of your gl context + * @param {number} height Height of gl context + * @returns {mat3} out + */ parcelHelpers.export(exports, "projection", ()=>projection); +/** + * Returns a string representation of a mat3 * - * @param {ReadonlyMat2} a matrix to represent as a string + * @param {ReadonlyMat3} a matrix to represent as a string * @returns {String} string representation of the matrix */ parcelHelpers.export(exports, "str", ()=>str); /** - * Returns Frobenius norm of a mat2 + * Returns Frobenius norm of a mat3 * - * @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of + * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of * @returns {Number} Frobenius norm */ parcelHelpers.export(exports, "frob", ()=>frob); /** - * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix - * @param {ReadonlyMat2} L the lower triangular matrix - * @param {ReadonlyMat2} D the diagonal matrix - * @param {ReadonlyMat2} U the upper triangular matrix - * @param {ReadonlyMat2} a the input matrix to factorize - */ parcelHelpers.export(exports, "LDU", ()=>LDU); -/** - * Adds two mat2's + * Adds two mat3's * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the first operand - * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {mat3} out */ parcelHelpers.export(exports, "add", ()=>add); /** * Subtracts matrix b from matrix a * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the first operand - * @param {ReadonlyMat2} b the second operand - * @returns {mat2} out + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @returns {mat3} out */ parcelHelpers.export(exports, "subtract", ()=>subtract); +/** + * Multiply each element of the matrix by a scalar. + * + * @param {mat3} out the receiving matrix + * @param {ReadonlyMat3} a the matrix to scale + * @param {Number} b amount to scale the matrix's elements by + * @returns {mat3} out + */ parcelHelpers.export(exports, "multiplyScalar", ()=>multiplyScalar); +/** + * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * + * @param {mat3} out the receiving vector + * @param {ReadonlyMat3} a the first operand + * @param {ReadonlyMat3} b the second operand + * @param {Number} scale the amount to scale b's elements by before adding + * @returns {mat3} out + */ parcelHelpers.export(exports, "multiplyScalarAndAdd", ()=>multiplyScalarAndAdd); /** * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) * - * @param {ReadonlyMat2} a The first matrix. - * @param {ReadonlyMat2} b The second matrix. + * @param {ReadonlyMat3} a The first matrix. + * @param {ReadonlyMat3} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); /** * Returns whether or not the matrices have approximately the same elements in the same position. * - * @param {ReadonlyMat2} a The first matrix. - * @param {ReadonlyMat2} b The second matrix. + * @param {ReadonlyMat3} a The first matrix. + * @param {ReadonlyMat3} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ parcelHelpers.export(exports, "equals", ()=>equals); -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat2} out the receiving matrix - * @param {ReadonlyMat2} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2} out - */ parcelHelpers.export(exports, "multiplyScalar", ()=>multiplyScalar); -/** - * Adds two mat2's after multiplying each element of the second operand by a scalar value. - * - * @param {mat2} out the receiving vector - * @param {ReadonlyMat2} a the first operand - * @param {ReadonlyMat2} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2} out - */ parcelHelpers.export(exports, "multiplyScalarAndAdd", ()=>multiplyScalarAndAdd); parcelHelpers.export(exports, "mul", ()=>mul); parcelHelpers.export(exports, "sub", ()=>sub); var _commonJs = require("./common.js"); function create() { - var out = new _commonJs.ARRAY_TYPE(4); + var out = new _commonJs.ARRAY_TYPE(9); if (_commonJs.ARRAY_TYPE != Float32Array) { out[1] = 0; out[2] = 0; + out[3] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; } out[0] = 1; - out[3] = 1; + out[4] = 1; + out[8] = 1; + return out; +} +function fromMat4(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; return out; } function clone(a) { - var out = new _commonJs.ARRAY_TYPE(4); + var out = new _commonJs.ARRAY_TYPE(9); out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; return out; } function copy(out, a) { @@ -8388,529 +8678,294 @@ function copy(out, a) { out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; return out; } -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; -} -function fromValues(m00, m01, m10, m11) { - var out = new _commonJs.ARRAY_TYPE(4); +function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { + var out = new _commonJs.ARRAY_TYPE(9); out[0] = m00; out[1] = m01; - out[2] = m10; - out[3] = m11; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; return out; } -function set(out, m00, m01, m10, m11) { +function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; out[1] = m01; - out[2] = m10; - out[3] = m11; + out[2] = m02; + out[3] = m10; + out[4] = m11; + out[5] = m12; + out[6] = m20; + out[7] = m21; + out[8] = m22; + return out; +} +function identity(out) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; return out; } function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache - // some values + // If we are transposing ourselves we can skip a few steps but have to cache some values if (out === a) { - var a1 = a[1]; - out[1] = a[2]; - out[2] = a1; + var a01 = a[1], a02 = a[2], a12 = a[5]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a01; + out[5] = a[7]; + out[6] = a02; + out[7] = a12; } else { out[0] = a[0]; - out[1] = a[2]; - out[2] = a[1]; - out[3] = a[3]; + out[1] = a[3]; + out[2] = a[6]; + out[3] = a[1]; + out[4] = a[4]; + out[5] = a[7]; + out[6] = a[2]; + out[7] = a[5]; + out[8] = a[8]; } return out; } function invert(out, a) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; // Calculate the determinant - var det = a0 * a3 - a2 * a1; + var a00 = a[0], a01 = a[1], a02 = a[2]; + var a10 = a[3], a11 = a[4], a12 = a[5]; + var a20 = a[6], a21 = a[7], a22 = a[8]; + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; if (!det) return null; det = 1.0 / det; - out[0] = a3 * det; - out[1] = -a1 * det; - out[2] = -a2 * det; - out[3] = a0 * det; + out[0] = b01 * det; + out[1] = (-a22 * a01 + a02 * a21) * det; + out[2] = (a12 * a01 - a02 * a11) * det; + out[3] = b11 * det; + out[4] = (a22 * a00 - a02 * a20) * det; + out[5] = (-a12 * a00 + a02 * a10) * det; + out[6] = b21 * det; + out[7] = (-a21 * a00 + a01 * a20) * det; + out[8] = (a11 * a00 - a01 * a10) * det; return out; } function adjoint(out, a) { - // Caching this value is nessecary if out == a - var a0 = a[0]; - out[0] = a[3]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a0; + var a00 = a[0], a01 = a[1], a02 = a[2]; + var a10 = a[3], a11 = a[4], a12 = a[5]; + var a20 = a[6], a21 = a[7], a22 = a[8]; + out[0] = a11 * a22 - a12 * a21; + out[1] = a02 * a21 - a01 * a22; + out[2] = a01 * a12 - a02 * a11; + out[3] = a12 * a20 - a10 * a22; + out[4] = a00 * a22 - a02 * a20; + out[5] = a02 * a10 - a00 * a12; + out[6] = a10 * a21 - a11 * a20; + out[7] = a01 * a20 - a00 * a21; + out[8] = a00 * a11 - a01 * a10; return out; } function determinant(a) { - return a[0] * a[3] - a[2] * a[1]; -} + var a00 = a[0], a01 = a[1], a02 = a[2]; + var a10 = a[3], a11 = a[4], a12 = a[5]; + var a20 = a[6], a21 = a[7], a22 = a[8]; + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); +} function multiply(out, a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = a0 * b0 + a2 * b1; - out[1] = a1 * b0 + a3 * b1; - out[2] = a0 * b2 + a2 * b3; - out[3] = a1 * b2 + a3 * b3; + var a00 = a[0], a01 = a[1], a02 = a[2]; + var a10 = a[3], a11 = a[4], a12 = a[5]; + var a20 = a[6], a21 = a[7], a22 = a[8]; + var b00 = b[0], b01 = b[1], b02 = b[2]; + var b10 = b[3], b11 = b[4], b12 = b[5]; + var b20 = b[6], b21 = b[7], b22 = b[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[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; + return out; +} +function translate(out, a, v) { + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], x = v[0], y = v[1]; + out[0] = a00; + out[1] = a01; + out[2] = a02; + out[3] = a10; + out[4] = a11; + out[5] = a12; + out[6] = x * a00 + y * a10 + a20; + out[7] = x * a01 + y * a11 + a21; + out[8] = x * a02 + y * a12 + a22; return out; } function rotate(out, a, rad) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var s = Math.sin(rad); - var c = Math.cos(rad); - out[0] = a0 * c + a2 * s; - out[1] = a1 * c + a3 * s; - out[2] = a0 * -s + a2 * c; - out[3] = a1 * -s + a3 * c; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], s = Math.sin(rad), c = Math.cos(rad); + out[0] = c * a00 + s * a10; + out[1] = c * a01 + s * a11; + out[2] = c * a02 + s * a12; + out[3] = c * a10 - s * a00; + out[4] = c * a11 - s * a01; + out[5] = c * a12 - s * a02; + out[6] = a20; + out[7] = a21; + out[8] = a22; return out; } function scale(out, a, v) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; + var x = v[0], y = v[1]; + out[0] = x * a[0]; + out[1] = x * a[1]; + out[2] = x * a[2]; + out[3] = y * a[3]; + out[4] = y * a[4]; + out[5] = y * a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + return out; +} +function fromTranslation(out, v) { + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = v[0]; + out[7] = v[1]; + out[8] = 1; return out; } function fromRotation(out, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); + var s = Math.sin(rad), c = Math.cos(rad); out[0] = c; out[1] = s; - out[2] = -s; - out[3] = c; + out[2] = 0; + out[3] = -s; + out[4] = c; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; return out; } function fromScaling(out, v) { out[0] = v[0]; out[1] = 0; out[2] = 0; - out[3] = v[1]; - return out; -} -function str(a) { - return "mat2(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; -} -function frob(a) { - return Math.hypot(a[0], a[1], a[2], a[3]); -} -function LDU(L, D, U, a) { - L[2] = a[2] / a[0]; - U[0] = a[0]; - U[1] = a[1]; - U[3] = a[3] - L[2] * U[1]; - return [ - L, - D, - U - ]; -} -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - return out; -} -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - return out; -} -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; -} -function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)); -} -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - return out; -} -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + b[0] * scale; - out[1] = a[1] + b[1] * scale; - out[2] = a[2] + b[2] * scale; - out[3] = a[3] + b[3] * scale; - return out; -} -var mul = multiply; -var sub = subtract; - -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jfS5o":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * 2x3 Matrix - * @module mat2d - * @description - * A mat2d contains six elements defined as: - * <pre> - * [a, b, - * c, d, - * tx, ty] - * </pre> - * This is a short form for the 3x3 matrix: - * <pre> - * [a, b, 0, - * c, d, 0, - * tx, ty, 1] - * </pre> - * The last column is ignored so the array is shorter and operations are faster. - */ /** - * Creates a new identity mat2d - * - * @returns {mat2d} a new 2x3 matrix - */ parcelHelpers.export(exports, "create", ()=>create); -/** - * Creates a new mat2d initialized with values from an existing matrix - * - * @param {ReadonlyMat2d} a matrix to clone - * @returns {mat2d} a new 2x3 matrix - */ parcelHelpers.export(exports, "clone", ()=>clone); -/** - * Copy the values from one mat2d to another - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d} out - */ parcelHelpers.export(exports, "copy", ()=>copy); -/** - * Set a mat2d to the identity matrix - * - * @param {mat2d} out the receiving matrix - * @returns {mat2d} out - */ parcelHelpers.export(exports, "identity", ()=>identity); -/** - * Create a new mat2d with the given values - * - * @param {Number} a Component A (index 0) - * @param {Number} b Component B (index 1) - * @param {Number} c Component C (index 2) - * @param {Number} d Component D (index 3) - * @param {Number} tx Component TX (index 4) - * @param {Number} ty Component TY (index 5) - * @returns {mat2d} A new mat2d - */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); -/** - * Set the components of a mat2d to the given values - * - * @param {mat2d} out the receiving matrix - * @param {Number} a Component A (index 0) - * @param {Number} b Component B (index 1) - * @param {Number} c Component C (index 2) - * @param {Number} d Component D (index 3) - * @param {Number} tx Component TX (index 4) - * @param {Number} ty Component TY (index 5) - * @returns {mat2d} out - */ parcelHelpers.export(exports, "set", ()=>set); -/** - * Inverts a mat2d - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the source matrix - * @returns {mat2d} out - */ parcelHelpers.export(exports, "invert", ()=>invert); -/** - * Calculates the determinant of a mat2d - * - * @param {ReadonlyMat2d} a the source matrix - * @returns {Number} determinant of a - */ parcelHelpers.export(exports, "determinant", ()=>determinant); -/** - * Multiplies two mat2d's - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the first operand - * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out - */ parcelHelpers.export(exports, "multiply", ()=>multiply); -/** - * Rotates a mat2d by the given angle - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out - */ parcelHelpers.export(exports, "rotate", ()=>rotate); -/** - * Scales the mat2d by the dimensions in the given vec2 - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the matrix to translate - * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat2d} out - **/ parcelHelpers.export(exports, "scale", ()=>scale); -/** - * Translates the mat2d by the dimensions in the given vec2 - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the matrix to translate - * @param {ReadonlyVec2} v the vec2 to translate the matrix by - * @returns {mat2d} out - **/ parcelHelpers.export(exports, "translate", ()=>translate); -/** - * Creates a matrix from a given angle - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.rotate(dest, dest, rad); - * - * @param {mat2d} out mat2d receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat2d} out - */ parcelHelpers.export(exports, "fromRotation", ()=>fromRotation); -/** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.scale(dest, dest, vec); - * - * @param {mat2d} out mat2d receiving operation result - * @param {ReadonlyVec2} v Scaling vector - * @returns {mat2d} out - */ parcelHelpers.export(exports, "fromScaling", ()=>fromScaling); -/** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat2d.identity(dest); - * mat2d.translate(dest, dest, vec); - * - * @param {mat2d} out mat2d receiving operation result - * @param {ReadonlyVec2} v Translation vector - * @returns {mat2d} out - */ parcelHelpers.export(exports, "fromTranslation", ()=>fromTranslation); -/** - * Returns a string representation of a mat2d - * - * @param {ReadonlyMat2d} a matrix to represent as a string - * @returns {String} string representation of the matrix - */ parcelHelpers.export(exports, "str", ()=>str); -/** - * Returns Frobenius norm of a mat2d - * - * @param {ReadonlyMat2d} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ parcelHelpers.export(exports, "frob", ()=>frob); -/** - * Adds two mat2d's - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the first operand - * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out - */ parcelHelpers.export(exports, "add", ()=>add); -/** - * Subtracts matrix b from matrix a - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the first operand - * @param {ReadonlyMat2d} b the second operand - * @returns {mat2d} out - */ parcelHelpers.export(exports, "subtract", ()=>subtract); -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat2d} out the receiving matrix - * @param {ReadonlyMat2d} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat2d} out - */ parcelHelpers.export(exports, "multiplyScalar", ()=>multiplyScalar); -/** - * Adds two mat2d's after multiplying each element of the second operand by a scalar value. - * - * @param {mat2d} out the receiving vector - * @param {ReadonlyMat2d} a the first operand - * @param {ReadonlyMat2d} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat2d} out - */ parcelHelpers.export(exports, "multiplyScalarAndAdd", ()=>multiplyScalarAndAdd); -/** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) - * - * @param {ReadonlyMat2d} a The first matrix. - * @param {ReadonlyMat2d} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); -/** - * Returns whether or not the matrices have approximately the same elements in the same position. - * - * @param {ReadonlyMat2d} a The first matrix. - * @param {ReadonlyMat2d} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ parcelHelpers.export(exports, "equals", ()=>equals); -parcelHelpers.export(exports, "mul", ()=>mul); -parcelHelpers.export(exports, "sub", ()=>sub); -var _commonJs = require("./common.js"); -function create() { - var out = new _commonJs.ARRAY_TYPE(6); - if (_commonJs.ARRAY_TYPE != Float32Array) { - out[1] = 0; - out[2] = 0; - out[4] = 0; - out[5] = 0; - } - out[0] = 1; - out[3] = 1; - return out; -} -function clone(a) { - var out = new _commonJs.ARRAY_TYPE(6); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; + out[3] = 0; + out[4] = v[1]; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; return out; } -function copy(out, a) { +function fromMat2d(out, a) { out[0] = a[0]; out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - return out; -} -function identity(out) { - out[0] = 1; - out[1] = 0; out[2] = 0; - out[3] = 1; - out[4] = 0; + out[3] = a[2]; + out[4] = a[3]; out[5] = 0; + out[6] = a[4]; + out[7] = a[5]; + out[8] = 1; return out; } -function fromValues(a, b, c, d, tx, ty) { - var out = new _commonJs.ARRAY_TYPE(6); - out[0] = a; - out[1] = b; - out[2] = c; - out[3] = d; - out[4] = tx; - out[5] = ty; - return out; -} -function set(out, a, b, c, d, tx, ty) { - out[0] = a; - out[1] = b; - out[2] = c; - out[3] = d; - out[4] = tx; - out[5] = ty; +function fromQuat(out, q) { + var x = q[0], y = q[1], z = q[2], w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var yx = y * x2; + var yy = y * y2; + var zx = z * x2; + var zy = z * y2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = 1 - yy - zz; + out[3] = yx - wz; + out[6] = zx + wy; + out[1] = yx + wz; + out[4] = 1 - xx - zz; + out[7] = zy - wx; + out[2] = zx - wy; + out[5] = zy + wx; + out[8] = 1 - xx - yy; return out; } -function invert(out, a) { - var aa = a[0], ab = a[1], ac = a[2], ad = a[3]; - var atx = a[4], aty = a[5]; - var det = aa * ad - ab * ac; +function normalFromMat4(out, a) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; if (!det) return null; det = 1.0 / det; - out[0] = ad * det; - out[1] = -ab * det; - out[2] = -ac * det; - out[3] = aa * det; - out[4] = (ac * aty - ad * atx) * det; - out[5] = (ab * atx - aa * aty) * det; - return out; -} -function determinant(a) { - return a[0] * a[3] - a[1] * a[2]; -} -function multiply(out, a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; - out[0] = a0 * b0 + a2 * b1; - out[1] = a1 * b0 + a3 * b1; - out[2] = a0 * b2 + a2 * b3; - out[3] = a1 * b2 + a3 * b3; - out[4] = a0 * b4 + a2 * b5 + a4; - out[5] = a1 * b4 + a3 * b5 + a5; - return out; -} -function rotate(out, a, rad) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - var s = Math.sin(rad); - var c = Math.cos(rad); - out[0] = a0 * c + a2 * s; - out[1] = a1 * c + a3 * s; - out[2] = a0 * -s + a2 * c; - out[3] = a1 * -s + a3 * c; - out[4] = a4; - out[5] = a5; - return out; -} -function scale(out, a, v) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - var v0 = v[0], v1 = v[1]; - out[0] = a0 * v0; - out[1] = a1 * v0; - out[2] = a2 * v1; - out[3] = a3 * v1; - out[4] = a4; - out[5] = a5; - return out; -} -function translate(out, a, v) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - var v0 = v[0], v1 = v[1]; - out[0] = a0; - out[1] = a1; - out[2] = a2; - out[3] = a3; - out[4] = a0 * v0 + a2 * v1 + a4; - out[5] = a1 * v0 + a3 * v1 + a5; - return out; -} -function fromRotation(out, rad) { - var s = Math.sin(rad), c = Math.cos(rad); - out[0] = c; - out[1] = s; - out[2] = -s; - out[3] = c; - out[4] = 0; - out[5] = 0; + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; return out; } -function fromScaling(out, v) { - out[0] = v[0]; +function projection(out, width, height) { + out[0] = 2 / width; out[1] = 0; out[2] = 0; - out[3] = v[1]; - out[4] = 0; + out[3] = 0; + out[4] = -2 / height; out[5] = 0; - return out; -} -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = v[0]; - out[5] = v[1]; + out[6] = -1; + out[7] = 1; + out[8] = 1; return out; } function str(a) { - return "mat2d(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ")"; + return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")"; } function frob(a) { - return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], 1); + return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); } function add(out, a, b) { out[0] = a[0] + b[0]; @@ -8919,6 +8974,9 @@ function add(out, a, b) { out[3] = a[3] + b[3]; out[4] = a[4] + b[4]; out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; return out; } function subtract(out, a, b) { @@ -8928,6 +8986,9 @@ function subtract(out, a, b) { out[3] = a[3] - b[3]; out[4] = a[4] - b[4]; out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; return out; } function multiplyScalar(out, a, b) { @@ -8937,6 +8998,9 @@ function multiplyScalar(out, a, b) { out[3] = a[3] * b; out[4] = a[4] * b; out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; return out; } function multiplyScalarAndAdd(out, a, b, scale) { @@ -8946,299 +9010,525 @@ function multiplyScalarAndAdd(out, a, b, scale) { out[3] = a[3] + b[3] * scale; out[4] = a[4] + b[4] * scale; out[5] = a[5] + b[5] * scale; + out[6] = a[6] + b[6] * scale; + out[7] = a[7] + b[7] * scale; + out[8] = a[8] + b[8] * scale; return out; } function exactEquals(a, b) { - 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] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; } function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)); + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; + return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)); } var mul = multiply; var sub = subtract; -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gHsXS":[function(require,module,exports) { +},{"./common.js":"7GML7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e5zmM":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); /** - * 3x3 Matrix - * @module mat3 + * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied. + * @module mat4 */ /** - * Creates a new identity mat3 + * Creates a new identity mat4 * - * @returns {mat3} a new 3x3 matrix + * @returns {mat4} a new 4x4 matrix */ parcelHelpers.export(exports, "create", ()=>create); /** - * Copies the upper-left 3x3 values into the given mat3. - * - * @param {mat3} out the receiving 3x3 matrix - * @param {ReadonlyMat4} a the source 4x4 matrix - * @returns {mat3} out - */ parcelHelpers.export(exports, "fromMat4", ()=>fromMat4); -/** - * Creates a new mat3 initialized with values from an existing matrix + * Creates a new mat4 initialized with values from an existing matrix * - * @param {ReadonlyMat3} a matrix to clone - * @returns {mat3} a new 3x3 matrix + * @param {ReadonlyMat4} a matrix to clone + * @returns {mat4} a new 4x4 matrix */ parcelHelpers.export(exports, "clone", ()=>clone); /** - * Copy the values from one mat3 to another + * Copy the values from one mat4 to another * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out */ parcelHelpers.export(exports, "copy", ()=>copy); /** - * Create a new mat3 with the given values + * Create a new mat4 with the given values * * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m10 Component in column 1, row 0 position (index 3) - * @param {Number} m11 Component in column 1, row 1 position (index 4) - * @param {Number} m12 Component in column 1, row 2 position (index 5) - * @param {Number} m20 Component in column 2, row 0 position (index 6) - * @param {Number} m21 Component in column 2, row 1 position (index 7) - * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} A new mat3 + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} A new mat4 */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); /** - * Set the components of a mat3 to the given values + * Set the components of a mat4 to the given values * - * @param {mat3} out the receiving matrix + * @param {mat4} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m10 Component in column 1, row 0 position (index 3) - * @param {Number} m11 Component in column 1, row 1 position (index 4) - * @param {Number} m12 Component in column 1, row 2 position (index 5) - * @param {Number} m20 Component in column 2, row 0 position (index 6) - * @param {Number} m21 Component in column 2, row 1 position (index 7) - * @param {Number} m22 Component in column 2, row 2 position (index 8) - * @returns {mat3} out + * @param {Number} m03 Component in column 0, row 3 position (index 3) + * @param {Number} m10 Component in column 1, row 0 position (index 4) + * @param {Number} m11 Component in column 1, row 1 position (index 5) + * @param {Number} m12 Component in column 1, row 2 position (index 6) + * @param {Number} m13 Component in column 1, row 3 position (index 7) + * @param {Number} m20 Component in column 2, row 0 position (index 8) + * @param {Number} m21 Component in column 2, row 1 position (index 9) + * @param {Number} m22 Component in column 2, row 2 position (index 10) + * @param {Number} m23 Component in column 2, row 3 position (index 11) + * @param {Number} m30 Component in column 3, row 0 position (index 12) + * @param {Number} m31 Component in column 3, row 1 position (index 13) + * @param {Number} m32 Component in column 3, row 2 position (index 14) + * @param {Number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} out */ parcelHelpers.export(exports, "set", ()=>set); /** - * Set a mat3 to the identity matrix + * Set a mat4 to the identity matrix * - * @param {mat3} out the receiving matrix - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @returns {mat4} out */ parcelHelpers.export(exports, "identity", ()=>identity); /** - * Transpose the values of a mat3 + * Transpose the values of a mat4 * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out */ parcelHelpers.export(exports, "transpose", ()=>transpose); /** - * Inverts a mat3 + * Inverts a mat4 * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out */ parcelHelpers.export(exports, "invert", ()=>invert); /** - * Calculates the adjugate of a mat3 + * Calculates the adjugate of a mat4 * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the source matrix - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the source matrix + * @returns {mat4} out */ parcelHelpers.export(exports, "adjoint", ()=>adjoint); /** - * Calculates the determinant of a mat3 + * Calculates the determinant of a mat4 * - * @param {ReadonlyMat3} a the source matrix + * @param {ReadonlyMat4} a the source matrix * @returns {Number} determinant of a */ parcelHelpers.export(exports, "determinant", ()=>determinant); /** - * Multiplies two mat3's + * Multiplies two mat4s * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the first operand - * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {mat4} out */ parcelHelpers.export(exports, "multiply", ()=>multiply); /** - * Translate a mat3 by the given vector + * Translate a mat4 by the given vector * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the matrix to translate - * @param {ReadonlyVec2} v vector to translate by - * @returns {mat3} out - */ parcelHelpers.export(exports, "translate", ()=>translate); -/** - * Rotates a mat3 by the given angle + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to translate + * @param {ReadonlyVec3} v vector to translate by + * @returns {mat4} out + */ parcelHelpers.export(exports, "translate", ()=>translate); +/** + * Scales the mat4 by the dimensions in the given vec3 not using vectorization * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the matrix to rotate + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to scale + * @param {ReadonlyVec3} v the vec3 to scale the matrix by + * @returns {mat4} out + **/ parcelHelpers.export(exports, "scale", ()=>scale); +/** + * Rotates a mat4 by the given angle around the given axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @param {ReadonlyVec3} axis the axis to rotate around + * @returns {mat4} out */ parcelHelpers.export(exports, "rotate", ()=>rotate); /** - * Scales the mat3 by the dimensions in the given vec2 + * Rotates a matrix by the given angle around the X axis * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the matrix to rotate - * @param {ReadonlyVec2} v the vec2 to scale the matrix by - * @returns {mat3} out - **/ parcelHelpers.export(exports, "scale", ()=>scale); + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ parcelHelpers.export(exports, "rotateX", ()=>rotateX); +/** + * Rotates a matrix by the given angle around the Y axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ parcelHelpers.export(exports, "rotateY", ()=>rotateY); +/** + * Rotates a matrix by the given angle around the Z axis + * + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to rotate + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ parcelHelpers.export(exports, "rotateZ", ()=>rotateZ); /** * Creates a matrix from a vector translation * This is equivalent to (but much faster than): * - * mat3.identity(dest); - * mat3.translate(dest, dest, vec); + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result - * @param {ReadonlyVec2} v Translation vector - * @returns {mat3} out + * @param {mat4} out mat4 receiving operation result + * @param {ReadonlyVec3} v Translation vector + * @returns {mat4} out */ parcelHelpers.export(exports, "fromTranslation", ()=>fromTranslation); /** - * Creates a matrix from a given angle + * Creates a matrix from a vector scaling * This is equivalent to (but much faster than): * - * mat3.identity(dest); - * mat3.rotate(dest, dest, rad); + * mat4.identity(dest); + * mat4.scale(dest, dest, vec); * - * @param {mat3} out mat3 receiving operation result + * @param {mat4} out mat4 receiving operation result + * @param {ReadonlyVec3} v Scaling vector + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromScaling", ()=>fromScaling); +/** + * Creates a matrix from a given angle around a given axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotate(dest, dest, rad, axis); + * + * @param {mat4} out mat4 receiving operation result * @param {Number} rad the angle to rotate the matrix by - * @returns {mat3} out + * @param {ReadonlyVec3} axis the axis to rotate around + * @returns {mat4} out */ parcelHelpers.export(exports, "fromRotation", ()=>fromRotation); /** - * Creates a matrix from a vector scaling + * Creates a matrix from the given angle around the X axis * This is equivalent to (but much faster than): * - * mat3.identity(dest); - * mat3.scale(dest, dest, vec); + * mat4.identity(dest); + * mat4.rotateX(dest, dest, rad); * - * @param {mat3} out mat3 receiving operation result - * @param {ReadonlyVec2} v Scaling vector - * @returns {mat3} out - */ parcelHelpers.export(exports, "fromScaling", ()=>fromScaling); + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromXRotation", ()=>fromXRotation); /** - * Copies the values from a mat2d into a mat3 + * Creates a matrix from the given angle around the Y axis + * This is equivalent to (but much faster than): * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat2d} a the matrix to copy - * @returns {mat3} out - **/ parcelHelpers.export(exports, "fromMat2d", ()=>fromMat2d); + * mat4.identity(dest); + * mat4.rotateY(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromYRotation", ()=>fromYRotation); /** - * Calculates a 3x3 matrix from the given quaternion + * Creates a matrix from the given angle around the Z axis + * This is equivalent to (but much faster than): * - * @param {mat3} out mat3 receiving operation result + * mat4.identity(dest); + * mat4.rotateZ(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {Number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromZRotation", ()=>fromZRotation); +/** + * Creates a matrix from a quaternion rotation and vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromRotationTranslation", ()=>fromRotationTranslation); +/** + * Creates a new mat4 from a dual quat. + * + * @param {mat4} out Matrix + * @param {ReadonlyQuat2} a Dual Quaternion + * @returns {mat4} mat4 receiving operation result + */ parcelHelpers.export(exports, "fromQuat2", ()=>fromQuat2); +/** + * Returns the translation vector component of a transformation + * matrix. If a matrix is built with fromRotationTranslation, + * the returned vector will be the same as the translation vector + * originally supplied. + * @param {vec3} out Vector to receive translation component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ parcelHelpers.export(exports, "getTranslation", ()=>getTranslation); +/** + * Returns the scaling factor component of a transformation + * matrix. If a matrix is built with fromRotationTranslationScale + * with a normalized Quaternion paramter, the returned vector will be + * the same as the scaling vector + * originally supplied. + * @param {vec3} out Vector to receive scaling factor component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ parcelHelpers.export(exports, "getScaling", ()=>getScaling); +/** + * Returns a quaternion representing the rotational component + * of a transformation matrix. If a matrix is built with + * fromRotationTranslation, the returned quaternion will be the + * same as the quaternion originally supplied. + * @param {quat} out Quaternion to receive the rotation component + * @param {ReadonlyMat4} mat Matrix to be decomposed (input) + * @return {quat} out + */ parcelHelpers.export(exports, "getRotation", ()=>getRotation); +/** + * Creates a matrix from a quaternion rotation, vector translation and vector scale + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @param {ReadonlyVec3} s Scaling vector + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromRotationTranslationScale", ()=>fromRotationTranslationScale); +/** + * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * mat4.translate(dest, origin); + * let quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * mat4.translate(dest, negativeOrigin); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat4} q Rotation quaternion + * @param {ReadonlyVec3} v Translation vector + * @param {ReadonlyVec3} s Scaling vector + * @param {ReadonlyVec3} o The origin vector around which to scale and rotate + * @returns {mat4} out + */ parcelHelpers.export(exports, "fromRotationTranslationScaleOrigin", ()=>fromRotationTranslationScaleOrigin); +/** + * Calculates a 4x4 matrix from the given quaternion + * + * @param {mat4} out mat4 receiving operation result * @param {ReadonlyQuat} q Quaternion to create matrix from * - * @returns {mat3} out + * @returns {mat4} out */ parcelHelpers.export(exports, "fromQuat", ()=>fromQuat); /** - * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix + * Generates a frustum matrix with the given bounds * - * @param {mat3} out mat3 receiving operation result - * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Number} left Left bound of the frustum + * @param {Number} right Right bound of the frustum + * @param {Number} bottom Bottom bound of the frustum + * @param {Number} top Top bound of the frustum + * @param {Number} near Near bound of the frustum + * @param {Number} far Far bound of the frustum + * @returns {mat4} out + */ parcelHelpers.export(exports, "frustum", ()=>frustum); +/** + * Generates a perspective projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. * - * @returns {mat3} out - */ parcelHelpers.export(exports, "normalFromMat4", ()=>normalFromMat4); + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {mat4} out + */ parcelHelpers.export(exports, "perspectiveNO", ()=>perspectiveNO); +parcelHelpers.export(exports, "perspective", ()=>perspective); /** - * Generates a 2D projection matrix with the given bounds + * Generates a perspective projection matrix suitable for WebGPU with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], + * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. + * Passing null/undefined/no value for far will generate infinite projection matrix. * - * @param {mat3} out mat3 frustum matrix will be written into - * @param {number} width Width of your gl context - * @param {number} height Height of gl context - * @returns {mat3} out - */ parcelHelpers.export(exports, "projection", ()=>projection); + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} fovy Vertical field of view in radians + * @param {number} aspect Aspect ratio. typically viewport width/height + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum, can be null or Infinity + * @returns {mat4} out + */ parcelHelpers.export(exports, "perspectiveZO", ()=>perspectiveZO); /** - * Returns a string representation of a mat3 + * Generates a perspective projection matrix with the given field of view. + * This is primarily useful for generating projection matrices to be used + * with the still experiemental WebVR API. * - * @param {ReadonlyMat3} a matrix to represent as a string + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ parcelHelpers.export(exports, "perspectiveFromFieldOfView", ()=>perspectiveFromFieldOfView); +/** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], + * which matches WebGL/OpenGL's clip volume. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ parcelHelpers.export(exports, "orthoNO", ()=>orthoNO); +parcelHelpers.export(exports, "ortho", ()=>ortho); +/** + * Generates a orthogonal projection matrix with the given bounds. + * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], + * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {number} left Left bound of the frustum + * @param {number} right Right bound of the frustum + * @param {number} bottom Bottom bound of the frustum + * @param {number} top Top bound of the frustum + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ parcelHelpers.export(exports, "orthoZO", ()=>orthoZO); +/** + * Generates a look-at matrix with the given eye position, focal point, and up axis. + * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {ReadonlyVec3} eye Position of the viewer + * @param {ReadonlyVec3} center Point the viewer is looking at + * @param {ReadonlyVec3} up vec3 pointing up + * @returns {mat4} out + */ parcelHelpers.export(exports, "lookAt", ()=>lookAt); +/** + * Generates a matrix that makes something look at something else. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {ReadonlyVec3} eye Position of the viewer + * @param {ReadonlyVec3} center Point the viewer is looking at + * @param {ReadonlyVec3} up vec3 pointing up + * @returns {mat4} out + */ parcelHelpers.export(exports, "targetTo", ()=>targetTo); +/** + * Returns a string representation of a mat4 + * + * @param {ReadonlyMat4} a matrix to represent as a string * @returns {String} string representation of the matrix */ parcelHelpers.export(exports, "str", ()=>str); /** - * Returns Frobenius norm of a mat3 + * Returns Frobenius norm of a mat4 * - * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of + * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of * @returns {Number} Frobenius norm */ parcelHelpers.export(exports, "frob", ()=>frob); /** - * Adds two mat3's + * Adds two mat4's * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the first operand - * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {mat4} out */ parcelHelpers.export(exports, "add", ()=>add); /** * Subtracts matrix b from matrix a * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the first operand - * @param {ReadonlyMat3} b the second operand - * @returns {mat3} out + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand + * @returns {mat4} out */ parcelHelpers.export(exports, "subtract", ()=>subtract); /** * Multiply each element of the matrix by a scalar. * - * @param {mat3} out the receiving matrix - * @param {ReadonlyMat3} a the matrix to scale + * @param {mat4} out the receiving matrix + * @param {ReadonlyMat4} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by - * @returns {mat3} out + * @returns {mat4} out */ parcelHelpers.export(exports, "multiplyScalar", ()=>multiplyScalar); /** - * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * Adds two mat4's after multiplying each element of the second operand by a scalar value. * - * @param {mat3} out the receiving vector - * @param {ReadonlyMat3} a the first operand - * @param {ReadonlyMat3} b the second operand + * @param {mat4} out the receiving vector + * @param {ReadonlyMat4} a the first operand + * @param {ReadonlyMat4} b the second operand * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat3} out + * @returns {mat4} out */ parcelHelpers.export(exports, "multiplyScalarAndAdd", ()=>multiplyScalarAndAdd); /** * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) * - * @param {ReadonlyMat3} a The first matrix. - * @param {ReadonlyMat3} b The second matrix. + * @param {ReadonlyMat4} a The first matrix. + * @param {ReadonlyMat4} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); /** * Returns whether or not the matrices have approximately the same elements in the same position. * - * @param {ReadonlyMat3} a The first matrix. - * @param {ReadonlyMat3} b The second matrix. + * @param {ReadonlyMat4} a The first matrix. + * @param {ReadonlyMat4} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ parcelHelpers.export(exports, "equals", ()=>equals); parcelHelpers.export(exports, "mul", ()=>mul); parcelHelpers.export(exports, "sub", ()=>sub); var _commonJs = require("./common.js"); function create() { - var out = new _commonJs.ARRAY_TYPE(9); + var out = new _commonJs.ARRAY_TYPE(16); if (_commonJs.ARRAY_TYPE != Float32Array) { out[1] = 0; out[2] = 0; out[3] = 0; - out[5] = 0; + out[4] = 0; out[6] = 0; out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; } out[0] = 1; - out[4] = 1; - out[8] = 1; - return out; -} -function fromMat4(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; + out[5] = 1; + out[10] = 1; + out[15] = 1; return out; } function clone(a) { - var out = new _commonJs.ARRAY_TYPE(9); + var out = new _commonJs.ARRAY_TYPE(16); out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; @@ -9248,6 +9538,13 @@ function clone(a) { out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; return out; } function copy(out, a) { @@ -9260,31 +9557,52 @@ function copy(out, a) { out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; return out; } -function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { - var out = new _commonJs.ARRAY_TYPE(9); +function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { + var out = new _commonJs.ARRAY_TYPE(16); out[0] = m00; out[1] = m01; out[2] = m02; - out[3] = m10; - out[4] = m11; - out[5] = m12; - out[6] = m20; - out[7] = m21; - out[8] = m22; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; return out; } -function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { +function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { out[0] = m00; out[1] = m01; out[2] = m02; - out[3] = m10; - out[4] = m11; - out[5] = m12; - out[6] = m20; - out[7] = m21; - out[8] = m22; + out[3] = m03; + out[4] = m10; + out[5] = m11; + out[6] = m12; + out[7] = m13; + out[8] = m20; + out[9] = m21; + out[10] = m22; + out[11] = m23; + out[12] = m30; + out[13] = m31; + out[14] = m32; + out[15] = m33; return out; } function identity(out) { @@ -9292,133 +9610,390 @@ function identity(out) { out[1] = 0; out[2] = 0; out[3] = 0; - out[4] = 1; - out[5] = 0; + out[4] = 0; + out[5] = 1; out[6] = 0; out[7] = 0; - out[8] = 1; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values if (out === a) { - var a01 = a[1], a02 = a[2], a12 = a[5]; - out[1] = a[3]; - out[2] = a[6]; - out[3] = a01; - out[5] = a[7]; - out[6] = a02; - out[7] = a12; + var a01 = a[1], a02 = a[2], a03 = a[3]; + var a12 = a[6], a13 = a[7]; + var a23 = a[11]; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a01; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a02; + out[9] = a12; + out[11] = a[14]; + out[12] = a03; + out[13] = a13; + out[14] = a23; } else { out[0] = a[0]; - out[1] = a[3]; - out[2] = a[6]; - out[3] = a[1]; - out[4] = a[4]; - out[5] = a[7]; - out[6] = a[2]; - out[7] = a[5]; - out[8] = a[8]; - } - return out; -} -function invert(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2]; - var a10 = a[3], a11 = a[4], a12 = a[5]; - var a20 = a[6], a21 = a[7], a22 = a[8]; - var b01 = a22 * a11 - a12 * a21; - var b11 = -a22 * a10 + a12 * a20; - var b21 = a21 * a10 - a11 * a20; // Calculate the determinant - var det = a00 * b01 + a01 * b11 + a02 * b21; - if (!det) return null; - det = 1.0 / det; - out[0] = b01 * det; - out[1] = (-a22 * a01 + a02 * a21) * det; - out[2] = (a12 * a01 - a02 * a11) * det; - out[3] = b11 * det; - out[4] = (a22 * a00 - a02 * a20) * det; - out[5] = (-a12 * a00 + a02 * a10) * det; - out[6] = b21 * det; - out[7] = (-a21 * a00 + a01 * a20) * det; - out[8] = (a11 * a00 - a01 * a10) * det; + out[1] = a[4]; + out[2] = a[8]; + out[3] = a[12]; + out[4] = a[1]; + out[5] = a[5]; + out[6] = a[9]; + out[7] = a[13]; + out[8] = a[2]; + out[9] = a[6]; + out[10] = a[10]; + out[11] = a[14]; + out[12] = a[3]; + out[13] = a[7]; + out[14] = a[11]; + out[15] = a[15]; + } + return out; +} +function invert(out, a) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + if (!det) return null; + det = 1.0 / det; + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; return out; } function adjoint(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2]; - var a10 = a[3], a11 = a[4], a12 = a[5]; - var a20 = a[6], a21 = a[7], a22 = a[8]; - out[0] = a11 * a22 - a12 * a21; - out[1] = a02 * a21 - a01 * a22; - out[2] = a01 * a12 - a02 * a11; - out[3] = a12 * a20 - a10 * a22; - out[4] = a00 * a22 - a02 * a20; - out[5] = a02 * a10 - a00 * a12; - out[6] = a10 * a21 - a11 * a20; - out[7] = a01 * a20 - a00 * a21; - out[8] = a00 * a11 - a01 * a10; + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22); + out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12); + out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22); + out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12); + out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21); + out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11); + out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21); + out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11); return out; } function determinant(a) { - var a00 = a[0], a01 = a[1], a02 = a[2]; - var a10 = a[3], a11 = a[4], a12 = a[5]; - var a20 = a[6], a21 = a[7], a22 = a[8]; - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; } function multiply(out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2]; - var a10 = a[3], a11 = a[4], a12 = a[5]; - var a20 = a[6], a21 = a[7], a22 = a[8]; - var b00 = b[0], b01 = b[1], b02 = b[2]; - var b10 = b[3], b11 = b[4], b12 = b[5]; - var b20 = b[6], b21 = b[7], b22 = b[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[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; + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; // Cache only the current line of the second matrix + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[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[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[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[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[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[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[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; return out; } function translate(out, a, v) { - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], x = v[0], y = v[1]; - out[0] = a00; - out[1] = a01; - out[2] = a02; - out[3] = a10; - out[4] = a11; - out[5] = a12; - out[6] = x * a00 + y * a10 + a20; - out[7] = x * a01 + y * a11 + a21; - out[8] = x * a02 + y * a12 + a22; + var x = v[0], y = v[1], z = v[2]; + var a00, a01, a02, a03; + var a10, a11, a12, a13; + var a20, a21, a22, a23; + if (a === out) { + out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + } else { + a00 = a[0]; + a01 = a[1]; + a02 = a[2]; + a03 = a[3]; + a10 = a[4]; + a11 = a[5]; + a12 = a[6]; + a13 = a[7]; + a20 = a[8]; + a21 = a[9]; + a22 = a[10]; + a23 = a[11]; + out[0] = a00; + out[1] = a01; + out[2] = a02; + out[3] = a03; + out[4] = a10; + out[5] = a11; + out[6] = a12; + out[7] = a13; + out[8] = a20; + out[9] = a21; + out[10] = a22; + out[11] = a23; + out[12] = a00 * x + a10 * y + a20 * z + a[12]; + out[13] = a01 * x + a11 * y + a21 * z + a[13]; + out[14] = a02 * x + a12 * y + a22 * z + a[14]; + out[15] = a03 * x + a13 * y + a23 * z + a[15]; + } return out; } -function rotate(out, a, rad) { - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], s = Math.sin(rad), c = Math.cos(rad); - out[0] = c * a00 + s * a10; - out[1] = c * a01 + s * a11; - out[2] = c * a02 + s * a12; - out[3] = c * a10 - s * a00; - out[4] = c * a11 - s * a01; - out[5] = c * a12 - s * a02; - out[6] = a20; - out[7] = a21; - out[8] = a22; +function scale(out, a, v) { + var x = v[0], y = v[1], z = v[2]; + out[0] = a[0] * x; + out[1] = a[1] * x; + out[2] = a[2] * x; + out[3] = a[3] * x; + out[4] = a[4] * y; + out[5] = a[5] * y; + out[6] = a[6] * y; + out[7] = a[7] * y; + out[8] = a[8] * z; + out[9] = a[9] * z; + out[10] = a[10] * z; + out[11] = a[11] * z; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; return out; } -function scale(out, a, v) { - var x = v[0], y = v[1]; - out[0] = x * a[0]; - out[1] = x * a[1]; - out[2] = x * a[2]; - out[3] = y * a[3]; - out[4] = y * a[4]; - out[5] = y * a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; +function rotate(out, a, rad, axis) { + var x = axis[0], y = axis[1], z = axis[2]; + var len = Math.hypot(x, y, z); + var s, c, t; + var a00, a01, a02, a03; + var a10, a11, a12, a13; + var a20, a21, a22, a23; + var b00, b01, b02; + var b10, b11, b12; + var b20, b21, b22; + if (len < _commonJs.EPSILON) return null; + len = 1 / len; + x *= len; + y *= len; + z *= len; + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; + a00 = a[0]; + a01 = a[1]; + a02 = a[2]; + a03 = a[3]; + a10 = a[4]; + a11 = a[5]; + a12 = a[6]; + a13 = a[7]; + a20 = a[8]; + a21 = a[9]; + a22 = a[10]; + a23 = a[11]; // Construct the elements of the rotation matrix + b00 = x * x * t + c; + b01 = y * x * t + z * s; + b02 = z * x * t - y * s; + b10 = x * y * t - z * s; + b11 = y * y * t + c; + b12 = z * y * t + x * s; + b20 = x * z * t + y * s; + b21 = y * z * t - x * s; + b22 = z * z * t + c; // Perform rotation-specific matrix multiplication + out[0] = a00 * b00 + a10 * b01 + a20 * b02; + out[1] = a01 * b00 + a11 * b01 + a21 * b02; + out[2] = a02 * b00 + a12 * b01 + a22 * b02; + out[3] = a03 * b00 + a13 * b01 + a23 * b02; + out[4] = a00 * b10 + a10 * b11 + a20 * b12; + out[5] = a01 * b10 + a11 * b11 + a21 * b12; + out[6] = a02 * b10 + a12 * b11 + a22 * b12; + out[7] = a03 * b10 + a13 * b11 + a23 * b12; + out[8] = a00 * b20 + a10 * b21 + a20 * b22; + out[9] = a01 * b20 + a11 * b21 + a21 * b22; + out[10] = a02 * b20 + a12 * b21 + a22 * b22; + out[11] = a03 * b20 + a13 * b21 + a23 * b22; + if (a !== out) { + // If the source and destination differ, copy the unchanged last row + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } + return out; +} +function rotateX(out, a, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + if (a !== out) { + // If the source and destination differ, copy the unchanged rows + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } // Perform axis-specific matrix multiplication + out[4] = a10 * c + a20 * s; + out[5] = a11 * c + a21 * s; + out[6] = a12 * c + a22 * s; + out[7] = a13 * c + a23 * s; + out[8] = a20 * c - a10 * s; + out[9] = a21 * c - a11 * s; + out[10] = a22 * c - a12 * s; + out[11] = a23 * c - a13 * s; + return out; +} +function rotateY(out, a, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + if (a !== out) { + // If the source and destination differ, copy the unchanged rows + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } // Perform axis-specific matrix multiplication + out[0] = a00 * c - a20 * s; + out[1] = a01 * c - a21 * s; + out[2] = a02 * c - a22 * s; + out[3] = a03 * c - a23 * s; + out[8] = a00 * s + a20 * c; + out[9] = a01 * s + a21 * c; + out[10] = a02 * s + a22 * c; + out[11] = a03 * s + a23 * c; + return out; +} +function rotateZ(out, a, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + if (a !== out) { + // If the source and destination differ, copy the unchanged last row + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + } // Perform axis-specific matrix multiplication + out[0] = a00 * c + a10 * s; + out[1] = a01 * c + a11 * s; + out[2] = a02 * c + a12 * s; + out[3] = a03 * c + a13 * s; + out[4] = a10 * c - a00 * s; + out[5] = a11 * c - a01 * s; + out[6] = a12 * c - a02 * s; + out[7] = a13 * c - a03 * s; return out; } function fromTranslation(out, v) { @@ -9426,24 +10001,18 @@ function fromTranslation(out, v) { out[1] = 0; out[2] = 0; out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = v[0]; - out[7] = v[1]; - out[8] = 1; - return out; -} -function fromRotation(out, rad) { - var s = Math.sin(rad), c = Math.cos(rad); - out[0] = c; - out[1] = s; - out[2] = 0; - out[3] = -s; - out[4] = c; - out[5] = 0; + out[4] = 0; + out[5] = 1; out[6] = 0; out[7] = 0; - out[8] = 1; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; return out; } function fromScaling(out, v) { @@ -9451,4927 +10020,3156 @@ function fromScaling(out, v) { out[1] = 0; out[2] = 0; out[3] = 0; - out[4] = v[1]; - out[5] = 0; + out[4] = 0; + out[5] = v[1]; out[6] = 0; out[7] = 0; - out[8] = 1; + out[8] = 0; + out[9] = 0; + out[10] = v[2]; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } -function fromMat2d(out, a) { - out[0] = a[0]; - out[1] = a[1]; +function fromRotation(out, rad, axis) { + var x = axis[0], y = axis[1], z = axis[2]; + var len = Math.hypot(x, y, z); + var s, c, t; + if (len < _commonJs.EPSILON) return null; + len = 1 / len; + x *= len; + y *= len; + z *= len; + s = Math.sin(rad); + c = Math.cos(rad); + t = 1 - c; // Perform rotation-specific matrix multiplication + out[0] = x * x * t + c; + out[1] = y * x * t + z * s; + out[2] = z * x * t - y * s; + out[3] = 0; + out[4] = x * y * t - z * s; + out[5] = y * y * t + c; + out[6] = z * y * t + x * s; + out[7] = 0; + out[8] = x * z * t + y * s; + out[9] = y * z * t - x * s; + out[10] = z * z * t + c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +function fromXRotation(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); // Perform axis-specific matrix multiplication + out[0] = 1; + out[1] = 0; out[2] = 0; - out[3] = a[2]; - out[4] = a[3]; - out[5] = 0; - out[6] = a[4]; - out[7] = a[5]; - out[8] = 1; + out[3] = 0; + out[4] = 0; + out[5] = c; + out[6] = s; + out[7] = 0; + out[8] = 0; + out[9] = -s; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } -function fromQuat(out, q) { - var x = q[0], y = q[1], z = q[2], w = q[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var yx = y * x2; - var yy = y * y2; - var zx = z * x2; - var zy = z * y2; +function fromYRotation(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); // Perform axis-specific matrix multiplication + out[0] = c; + out[1] = 0; + out[2] = -s; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = s; + out[9] = 0; + out[10] = c; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +function fromZRotation(out, rad) { + var s = Math.sin(rad); + var c = Math.cos(rad); // Perform axis-specific matrix multiplication + out[0] = c; + out[1] = s; + out[2] = 0; + out[3] = 0; + out[4] = -s; + out[5] = c; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + return out; +} +function fromRotationTranslation(out, q, v) { + // Quaternion math + var x = q[0], y = q[1], z = q[2], w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; +} +function fromQuat2(out, a) { + var translation = new _commonJs.ARRAY_TYPE(3); + var bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], ax = a[4], ay = a[5], az = a[6], aw = a[7]; + var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense + if (magnitude > 0) { + translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude; + translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude; + translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude; + } else { + translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; + translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; + translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; + } + fromRotationTranslation(out, a, translation); + return out; +} +function getTranslation(out, mat) { + out[0] = mat[12]; + out[1] = mat[13]; + out[2] = mat[14]; + return out; +} +function getScaling(out, mat) { + var m11 = mat[0]; + var m12 = mat[1]; + var m13 = mat[2]; + var m21 = mat[4]; + var m22 = mat[5]; + var m23 = mat[6]; + var m31 = mat[8]; + var m32 = mat[9]; + var m33 = mat[10]; + out[0] = Math.hypot(m11, m12, m13); + out[1] = Math.hypot(m21, m22, m23); + out[2] = Math.hypot(m31, m32, m33); + return out; +} +function getRotation(out, mat) { + var scaling = new _commonJs.ARRAY_TYPE(3); + getScaling(scaling, mat); + var is1 = 1 / scaling[0]; + var is2 = 1 / scaling[1]; + var is3 = 1 / scaling[2]; + var sm11 = mat[0] * is1; + var sm12 = mat[1] * is2; + var sm13 = mat[2] * is3; + var sm21 = mat[4] * is1; + var sm22 = mat[5] * is2; + var sm23 = mat[6] * is3; + var sm31 = mat[8] * is1; + var sm32 = mat[9] * is2; + var sm33 = mat[10] * is3; + var trace = sm11 + sm22 + sm33; + var S = 0; + if (trace > 0) { + S = Math.sqrt(trace + 1.0) * 2; + out[3] = 0.25 * S; + out[0] = (sm23 - sm32) / S; + out[1] = (sm31 - sm13) / S; + out[2] = (sm12 - sm21) / S; + } else if (sm11 > sm22 && sm11 > sm33) { + S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2; + out[3] = (sm23 - sm32) / S; + out[0] = 0.25 * S; + out[1] = (sm12 + sm21) / S; + out[2] = (sm31 + sm13) / S; + } else if (sm22 > sm33) { + S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2; + out[3] = (sm31 - sm13) / S; + out[0] = (sm12 + sm21) / S; + out[1] = 0.25 * S; + out[2] = (sm23 + sm32) / S; + } else { + S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2; + out[3] = (sm12 - sm21) / S; + out[0] = (sm31 + sm13) / S; + out[1] = (sm23 + sm32) / S; + out[2] = 0.25 * S; + } + return out; +} +function fromRotationTranslationScale(out, q, v, s) { + // Quaternion math + var x = q[0], y = q[1], z = q[2], w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = s[0]; + var sy = s[1]; + var sz = s[2]; + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = v[0]; + out[13] = v[1]; + out[14] = v[2]; + out[15] = 1; + return out; +} +function fromRotationTranslationScaleOrigin(out, q, v, s, o) { + // Quaternion math + var x = q[0], y = q[1], z = q[2], w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + var sx = s[0]; + var sy = s[1]; + var sz = s[2]; + var ox = o[0]; + var oy = o[1]; + var oz = o[2]; + var out0 = (1 - (yy + zz)) * sx; + var out1 = (xy + wz) * sx; + var out2 = (xz - wy) * sx; + var out4 = (xy - wz) * sy; + var out5 = (1 - (xx + zz)) * sy; + var out6 = (yz + wx) * sy; + var out8 = (xz + wy) * sz; + var out9 = (yz - wx) * sz; + var out10 = (1 - (xx + yy)) * sz; + out[0] = out0; + out[1] = out1; + out[2] = out2; + out[3] = 0; + out[4] = out4; + out[5] = out5; + out[6] = out6; + out[7] = 0; + out[8] = out8; + out[9] = out9; + out[10] = out10; + out[11] = 0; + out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz); + out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz); + out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz); + out[15] = 1; + return out; +} +function fromQuat(out, q) { + var x = q[0], y = q[1], z = q[2], w = q[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var yx = y * x2; + var yy = y * y2; + var zx = z * x2; + var zy = z * y2; var zz = z * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; out[0] = 1 - yy - zz; - out[3] = yx - wz; - out[6] = zx + wy; out[1] = yx + wz; - out[4] = 1 - xx - zz; - out[7] = zy - wx; out[2] = zx - wy; - out[5] = zy + wx; - out[8] = 1 - xx - yy; + out[3] = 0; + out[4] = yx - wz; + out[5] = 1 - xx - zz; + out[6] = zy + wx; + out[7] = 0; + out[8] = zx + wy; + out[9] = zy - wx; + out[10] = 1 - xx - yy; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; return out; } -function normalFromMat4(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - if (!det) return null; - det = 1.0 / det; - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; +function frustum(out, left, right, bottom, top, near, far) { + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + out[0] = near * 2 * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = near * 2 * tb; + out[6] = 0; + out[7] = 0; + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[14] = far * near * 2 * nf; + out[15] = 0; return out; } -function projection(out, width, height) { - out[0] = 2 / width; +function perspectiveNO(out, fovy, aspect, near, far) { + var f = 1.0 / Math.tan(fovy / 2), nf; + out[0] = f / aspect; out[1] = 0; out[2] = 0; out[3] = 0; - out[4] = -2 / height; - out[5] = 0; - out[6] = -1; - out[7] = 1; - out[8] = 1; + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[15] = 0; + if (far != null && far !== Infinity) { + nf = 1 / (near - far); + out[10] = (far + near) * nf; + out[14] = 2 * far * near * nf; + } else { + out[10] = -1; + out[14] = -2 * near; + } return out; } -function str(a) { - return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")"; -} -function frob(a) { - return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); -} -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - out[8] = a[8] + b[8]; +var perspective = perspectiveNO; +function perspectiveZO(out, fovy, aspect, near, far) { + var f = 1.0 / Math.tan(fovy / 2), nf; + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[11] = -1; + out[12] = 0; + out[13] = 0; + out[15] = 0; + if (far != null && far !== Infinity) { + nf = 1 / (near - far); + out[10] = far * nf; + out[14] = far * near * nf; + } else { + out[10] = -1; + out[14] = -near; + } return out; } -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - out[6] = a[6] - b[6]; - out[7] = a[7] - b[7]; - out[8] = a[8] - b[8]; +function perspectiveFromFieldOfView(out, fov, near, far) { + var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0); + var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0); + var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0); + var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0); + var xScale = 2.0 / (leftTan + rightTan); + var yScale = 2.0 / (upTan + downTan); + out[0] = xScale; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; + out[4] = 0.0; + out[5] = yScale; + out[6] = 0.0; + out[7] = 0.0; + out[8] = -((leftTan - rightTan) * xScale * 0.5); + out[9] = (upTan - downTan) * yScale * 0.5; + out[10] = far / (near - far); + out[11] = -1; + out[12] = 0.0; + out[13] = 0.0; + out[14] = far * near / (near - far); + out[15] = 0.0; return out; } -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - out[8] = a[8] * b; +function orthoNO(out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right); + var bt = 1 / (bottom - top); + var nf = 1 / (near - far); + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; return out; } -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + b[0] * scale; - out[1] = a[1] + b[1] * scale; - out[2] = a[2] + b[2] * scale; - out[3] = a[3] + b[3] * scale; - out[4] = a[4] + b[4] * scale; - out[5] = a[5] + b[5] * scale; - out[6] = a[6] + b[6] * scale; - out[7] = a[7] + b[7] * scale; - out[8] = a[8] + b[8] * scale; +var ortho = orthoNO; +function orthoZO(out, left, right, bottom, top, near, far) { + var lr = 1 / (left - right); + var bt = 1 / (bottom - top); + var nf = 1 / (near - far); + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = nf; + out[11] = 0; + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = near * nf; + out[15] = 1; return out; } -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; -} -function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)); -} -var mul = multiply; -var sub = subtract; - -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6PEOw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied. - * @module mat4 - */ /** - * Creates a new identity mat4 - * - * @returns {mat4} a new 4x4 matrix - */ parcelHelpers.export(exports, "create", ()=>create); -/** - * Creates a new mat4 initialized with values from an existing matrix - * - * @param {ReadonlyMat4} a matrix to clone - * @returns {mat4} a new 4x4 matrix - */ parcelHelpers.export(exports, "clone", ()=>clone); -/** - * Copy the values from one mat4 to another - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out - */ parcelHelpers.export(exports, "copy", ()=>copy); -/** - * Create a new mat4 with the given values - * - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m03 Component in column 0, row 3 position (index 3) - * @param {Number} m10 Component in column 1, row 0 position (index 4) - * @param {Number} m11 Component in column 1, row 1 position (index 5) - * @param {Number} m12 Component in column 1, row 2 position (index 6) - * @param {Number} m13 Component in column 1, row 3 position (index 7) - * @param {Number} m20 Component in column 2, row 0 position (index 8) - * @param {Number} m21 Component in column 2, row 1 position (index 9) - * @param {Number} m22 Component in column 2, row 2 position (index 10) - * @param {Number} m23 Component in column 2, row 3 position (index 11) - * @param {Number} m30 Component in column 3, row 0 position (index 12) - * @param {Number} m31 Component in column 3, row 1 position (index 13) - * @param {Number} m32 Component in column 3, row 2 position (index 14) - * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} A new mat4 - */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); +function lookAt(out, eye, center, up) { + var x0, x1, x2, y0, y1, y2, z0, z1, z2, len; + var eyex = eye[0]; + var eyey = eye[1]; + var eyez = eye[2]; + var upx = up[0]; + var upy = up[1]; + var upz = up[2]; + var centerx = center[0]; + var centery = center[1]; + var centerz = center[2]; + if (Math.abs(eyex - centerx) < _commonJs.EPSILON && Math.abs(eyey - centery) < _commonJs.EPSILON && Math.abs(eyez - centerz) < _commonJs.EPSILON) return identity(out); + z0 = eyex - centerx; + z1 = eyey - centery; + z2 = eyez - centerz; + len = 1 / Math.hypot(z0, z1, z2); + z0 *= len; + z1 *= len; + z2 *= len; + x0 = upy * z2 - upz * z1; + x1 = upz * z0 - upx * z2; + x2 = upx * z1 - upy * z0; + len = Math.hypot(x0, x1, x2); + if (!len) { + x0 = 0; + x1 = 0; + x2 = 0; + } else { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + y0 = z1 * x2 - z2 * x1; + y1 = z2 * x0 - z0 * x2; + y2 = z0 * x1 - z1 * x0; + len = Math.hypot(y0, y1, y2); + if (!len) { + y0 = 0; + y1 = 0; + y2 = 0; + } else { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + return out; +} +function targetTo(out, eye, target, up) { + var eyex = eye[0], eyey = eye[1], eyez = eye[2], upx = up[0], upy = up[1], upz = up[2]; + var z0 = eyex - target[0], z1 = eyey - target[1], z2 = eyez - target[2]; + var len = z0 * z0 + z1 * z1 + z2 * z2; + if (len > 0) { + len = 1 / Math.sqrt(len); + z0 *= len; + z1 *= len; + z2 *= len; + } + var x0 = upy * z2 - upz * z1, x1 = upz * z0 - upx * z2, x2 = upx * z1 - upy * z0; + len = x0 * x0 + x1 * x1 + x2 * x2; + if (len > 0) { + len = 1 / Math.sqrt(len); + x0 *= len; + x1 *= len; + x2 *= len; + } + out[0] = x0; + out[1] = x1; + out[2] = x2; + out[3] = 0; + out[4] = z1 * x2 - z2 * x1; + out[5] = z2 * x0 - z0 * x2; + out[6] = z0 * x1 - z1 * x0; + out[7] = 0; + out[8] = z0; + out[9] = z1; + out[10] = z2; + out[11] = 0; + out[12] = eyex; + out[13] = eyey; + out[14] = eyez; + out[15] = 1; + return out; +} +function str(a) { + return "mat4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ", " + a[9] + ", " + a[10] + ", " + a[11] + ", " + a[12] + ", " + a[13] + ", " + a[14] + ", " + a[15] + ")"; +} +function frob(a) { + return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); +} +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; + out[4] = a[4] + b[4]; + out[5] = a[5] + b[5]; + out[6] = a[6] + b[6]; + out[7] = a[7] + b[7]; + out[8] = a[8] + b[8]; + out[9] = a[9] + b[9]; + out[10] = a[10] + b[10]; + out[11] = a[11] + b[11]; + out[12] = a[12] + b[12]; + out[13] = a[13] + b[13]; + out[14] = a[14] + b[14]; + out[15] = a[15] + b[15]; + return out; +} +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; + out[4] = a[4] - b[4]; + out[5] = a[5] - b[5]; + out[6] = a[6] - b[6]; + out[7] = a[7] - b[7]; + out[8] = a[8] - b[8]; + out[9] = a[9] - b[9]; + out[10] = a[10] - b[10]; + out[11] = a[11] - b[11]; + out[12] = a[12] - b[12]; + out[13] = a[13] - b[13]; + out[14] = a[14] - b[14]; + out[15] = a[15] - b[15]; + return out; +} +function multiplyScalar(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; + out[4] = a[4] * b; + out[5] = a[5] * b; + out[6] = a[6] * b; + out[7] = a[7] * b; + out[8] = a[8] * b; + out[9] = a[9] * b; + out[10] = a[10] * b; + out[11] = a[11] * b; + out[12] = a[12] * b; + out[13] = a[13] * b; + out[14] = a[14] * b; + out[15] = a[15] * b; + return out; +} +function multiplyScalarAndAdd(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; + out[4] = a[4] + b[4] * scale; + out[5] = a[5] + b[5] * scale; + out[6] = a[6] + b[6] * scale; + out[7] = a[7] + b[7] * scale; + out[8] = a[8] + b[8] * scale; + out[9] = a[9] + b[9] * scale; + out[10] = a[10] + b[10] * scale; + out[11] = a[11] + b[11] * scale; + out[12] = a[12] + b[12] * scale; + out[13] = a[13] + b[13] * scale; + out[14] = a[14] + b[14] * scale; + out[15] = a[15] + b[15] * scale; + return out; +} +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; +} +function equals(a, b) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + var a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; + var a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11]; + var a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15]; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + var b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; + var b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11]; + var b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; + return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15)); +} +var mul = multiply; +var sub = subtract; + +},{"./common.js":"7GML7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2chmr":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); /** - * Set the components of a mat4 to the given values + * Quaternion + * @module quat + */ /** + * Creates a new identity quat * - * @param {mat4} out the receiving matrix - * @param {Number} m00 Component in column 0, row 0 position (index 0) - * @param {Number} m01 Component in column 0, row 1 position (index 1) - * @param {Number} m02 Component in column 0, row 2 position (index 2) - * @param {Number} m03 Component in column 0, row 3 position (index 3) - * @param {Number} m10 Component in column 1, row 0 position (index 4) - * @param {Number} m11 Component in column 1, row 1 position (index 5) - * @param {Number} m12 Component in column 1, row 2 position (index 6) - * @param {Number} m13 Component in column 1, row 3 position (index 7) - * @param {Number} m20 Component in column 2, row 0 position (index 8) - * @param {Number} m21 Component in column 2, row 1 position (index 9) - * @param {Number} m22 Component in column 2, row 2 position (index 10) - * @param {Number} m23 Component in column 2, row 3 position (index 11) - * @param {Number} m30 Component in column 3, row 0 position (index 12) - * @param {Number} m31 Component in column 3, row 1 position (index 13) - * @param {Number} m32 Component in column 3, row 2 position (index 14) - * @param {Number} m33 Component in column 3, row 3 position (index 15) - * @returns {mat4} out - */ parcelHelpers.export(exports, "set", ()=>set); + * @returns {quat} a new quaternion + */ parcelHelpers.export(exports, "create", ()=>create); /** - * Set a mat4 to the identity matrix + * Set a quat to the identity quaternion * - * @param {mat4} out the receiving matrix - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @returns {quat} out */ parcelHelpers.export(exports, "identity", ()=>identity); /** - * Transpose the values of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out - */ parcelHelpers.export(exports, "transpose", ()=>transpose); -/** - * Inverts a mat4 + * Sets a quat from the given angle and rotation axis, + * then returns it. * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out - */ parcelHelpers.export(exports, "invert", ()=>invert); + * @param {quat} out the receiving quaternion + * @param {ReadonlyVec3} axis the axis around which to rotate + * @param {Number} rad the angle in radians + * @returns {quat} out + **/ parcelHelpers.export(exports, "setAxisAngle", ()=>setAxisAngle); /** - * Calculates the adjugate of a mat4 - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the source matrix - * @returns {mat4} out - */ parcelHelpers.export(exports, "adjoint", ()=>adjoint); + * Gets the rotation axis and angle for a given + * quaternion. If a quaternion is created with + * setAxisAngle, this method will return the same + * values as providied in the original parameter list + * OR functionally equivalent values. + * Example: The quaternion formed by axis [0, 0, 1] and + * angle -90 is the same as the quaternion formed by + * [0, 0, 1] and 270. This method favors the latter. + * @param {vec3} out_axis Vector receiving the axis of rotation + * @param {ReadonlyQuat} q Quaternion to be decomposed + * @return {Number} Angle, in radians, of the rotation + */ parcelHelpers.export(exports, "getAxisAngle", ()=>getAxisAngle); /** - * Calculates the determinant of a mat4 + * Gets the angular distance between two unit quaternions * - * @param {ReadonlyMat4} a the source matrix - * @returns {Number} determinant of a - */ parcelHelpers.export(exports, "determinant", ()=>determinant); + * @param {ReadonlyQuat} a Origin unit quaternion + * @param {ReadonlyQuat} b Destination unit quaternion + * @return {Number} Angle, in radians, between the two quaternions + */ parcelHelpers.export(exports, "getAngle", ()=>getAngle); /** - * Multiplies two mat4s + * Multiplies two quat's * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the first operand - * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @returns {quat} out */ parcelHelpers.export(exports, "multiply", ()=>multiply); /** - * Translate a mat4 by the given vector - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to translate - * @param {ReadonlyVec3} v vector to translate by - * @returns {mat4} out - */ parcelHelpers.export(exports, "translate", ()=>translate); -/** - * Scales the mat4 by the dimensions in the given vec3 not using vectorization - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to scale - * @param {ReadonlyVec3} v the vec3 to scale the matrix by - * @returns {mat4} out - **/ parcelHelpers.export(exports, "scale", ()=>scale); -/** - * Rotates a mat4 by the given angle around the given axis - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out - */ parcelHelpers.export(exports, "rotate", ()=>rotate); -/** - * Rotates a matrix by the given angle around the X axis + * Rotates a quaternion by the given angle about the X axis * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {quat} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out */ parcelHelpers.export(exports, "rotateX", ()=>rotateX); /** - * Rotates a matrix by the given angle around the Y axis + * Rotates a quaternion by the given angle about the Y axis * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {quat} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out */ parcelHelpers.export(exports, "rotateY", ()=>rotateY); /** - * Rotates a matrix by the given angle around the Z axis + * Rotates a quaternion by the given angle about the Z axis * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to rotate - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out + * @param {quat} out quat receiving operation result + * @param {ReadonlyQuat} a quat to rotate + * @param {number} rad angle (in radians) to rotate + * @returns {quat} out */ parcelHelpers.export(exports, "rotateZ", ()=>rotateZ); /** - * Creates a matrix from a vector translation - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, dest, vec); + * Calculates the W component of a quat from the X, Y, and Z components. + * Assumes that quaternion is 1 unit in length. + * Any existing W component will be ignored. * - * @param {mat4} out mat4 receiving operation result - * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromTranslation", ()=>fromTranslation); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate W component of + * @returns {quat} out + */ parcelHelpers.export(exports, "calculateW", ()=>calculateW); /** - * Creates a matrix from a vector scaling - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.scale(dest, dest, vec); + * Calculate the exponential of a unit quaternion. * - * @param {mat4} out mat4 receiving operation result - * @param {ReadonlyVec3} v Scaling vector - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromScaling", ()=>fromScaling); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @returns {quat} out + */ parcelHelpers.export(exports, "exp", ()=>exp); /** - * Creates a matrix from a given angle around a given axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotate(dest, dest, rad, axis); + * Calculate the natural logarithm of a unit quaternion. * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @param {ReadonlyVec3} axis the axis to rotate around - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromRotation", ()=>fromRotation); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @returns {quat} out + */ parcelHelpers.export(exports, "ln", ()=>ln); /** - * Creates a matrix from the given angle around the X axis - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.rotateX(dest, dest, rad); + * Calculate the scalar power of a unit quaternion. * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromXRotation", ()=>fromXRotation); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate the exponential of + * @param {Number} b amount to scale the quaternion by + * @returns {quat} out + */ parcelHelpers.export(exports, "pow", ()=>pow); /** - * Creates a matrix from the given angle around the Y axis - * This is equivalent to (but much faster than): + * Performs a spherical linear interpolation between two quat * - * mat4.identity(dest); - * mat4.rotateY(dest, dest, rad); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a the first operand + * @param {ReadonlyQuat} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {quat} out + */ parcelHelpers.export(exports, "slerp", ()=>slerp); +/** + * Generates a random unit quaternion * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromYRotation", ()=>fromYRotation); + * @param {quat} out the receiving quaternion + * @returns {quat} out + */ parcelHelpers.export(exports, "random", ()=>random); /** - * Creates a matrix from the given angle around the Z axis - * This is equivalent to (but much faster than): + * Calculates the inverse of a quat * - * mat4.identity(dest); - * mat4.rotateZ(dest, dest, rad); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate inverse of + * @returns {quat} out + */ parcelHelpers.export(exports, "invert", ()=>invert); +/** + * Calculates the conjugate of a quat + * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. * - * @param {mat4} out mat4 receiving operation result - * @param {Number} rad the angle to rotate the matrix by - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromZRotation", ()=>fromZRotation); + * @param {quat} out the receiving quaternion + * @param {ReadonlyQuat} a quat to calculate conjugate of + * @returns {quat} out + */ parcelHelpers.export(exports, "conjugate", ()=>conjugate); /** - * Creates a matrix from a quaternion rotation and vector translation - * This is equivalent to (but much faster than): + * Creates a quaternion from the given 3x3 rotation matrix. * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); + * NOTE: The resultant quaternion is not normalized, so you should be sure + * to renormalize the quaternion yourself where necessary. * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {ReadonlyVec3} v Translation vector - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromRotationTranslation", ()=>fromRotationTranslation); + * @param {quat} out the receiving quaternion + * @param {ReadonlyMat3} m rotation matrix + * @returns {quat} out + * @function + */ parcelHelpers.export(exports, "fromMat3", ()=>fromMat3); /** - * Creates a new mat4 from a dual quat. + * Creates a quaternion from the given euler angle x, y, z. * - * @param {mat4} out Matrix - * @param {ReadonlyQuat2} a Dual Quaternion - * @returns {mat4} mat4 receiving operation result - */ parcelHelpers.export(exports, "fromQuat2", ()=>fromQuat2); -/** - * Returns the translation vector component of a transformation - * matrix. If a matrix is built with fromRotationTranslation, - * the returned vector will be the same as the translation vector - * originally supplied. - * @param {vec3} out Vector to receive translation component - * @param {ReadonlyMat4} mat Matrix to be decomposed (input) - * @return {vec3} out - */ parcelHelpers.export(exports, "getTranslation", ()=>getTranslation); + * @param {quat} out the receiving quaternion + * @param {x} Angle to rotate around X axis in degrees. + * @param {y} Angle to rotate around Y axis in degrees. + * @param {z} Angle to rotate around Z axis in degrees. + * @returns {quat} out + * @function + */ parcelHelpers.export(exports, "fromEuler", ()=>fromEuler); /** - * Returns the scaling factor component of a transformation - * matrix. If a matrix is built with fromRotationTranslationScale - * with a normalized Quaternion paramter, the returned vector will be - * the same as the scaling vector - * originally supplied. - * @param {vec3} out Vector to receive scaling factor component - * @param {ReadonlyMat4} mat Matrix to be decomposed (input) - * @return {vec3} out - */ parcelHelpers.export(exports, "getScaling", ()=>getScaling); -/** - * Returns a quaternion representing the rotational component - * of a transformation matrix. If a matrix is built with - * fromRotationTranslation, the returned quaternion will be the - * same as the quaternion originally supplied. - * @param {quat} out Quaternion to receive the rotation component - * @param {ReadonlyMat4} mat Matrix to be decomposed (input) - * @return {quat} out - */ parcelHelpers.export(exports, "getRotation", ()=>getRotation); -/** - * Creates a matrix from a quaternion rotation, vector translation and vector scale - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * mat4.scale(dest, scale) - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {ReadonlyVec3} v Translation vector - * @param {ReadonlyVec3} s Scaling vector - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromRotationTranslationScale", ()=>fromRotationTranslationScale); -/** - * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin - * This is equivalent to (but much faster than): - * - * mat4.identity(dest); - * mat4.translate(dest, vec); - * mat4.translate(dest, origin); - * let quatMat = mat4.create(); - * quat4.toMat4(quat, quatMat); - * mat4.multiply(dest, quatMat); - * mat4.scale(dest, scale) - * mat4.translate(dest, negativeOrigin); - * - * @param {mat4} out mat4 receiving operation result - * @param {quat4} q Rotation quaternion - * @param {ReadonlyVec3} v Translation vector - * @param {ReadonlyVec3} s Scaling vector - * @param {ReadonlyVec3} o The origin vector around which to scale and rotate - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromRotationTranslationScaleOrigin", ()=>fromRotationTranslationScaleOrigin); -/** - * Calculates a 4x4 matrix from the given quaternion - * - * @param {mat4} out mat4 receiving operation result - * @param {ReadonlyQuat} q Quaternion to create matrix from - * - * @returns {mat4} out - */ parcelHelpers.export(exports, "fromQuat", ()=>fromQuat); -/** - * Generates a frustum matrix with the given bounds - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {Number} left Left bound of the frustum - * @param {Number} right Right bound of the frustum - * @param {Number} bottom Bottom bound of the frustum - * @param {Number} top Top bound of the frustum - * @param {Number} near Near bound of the frustum - * @param {Number} far Far bound of the frustum - * @returns {mat4} out - */ parcelHelpers.export(exports, "frustum", ()=>frustum); -/** - * Generates a perspective projection matrix with the given bounds. - * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], - * which matches WebGL/OpenGL's clip volume. - * Passing null/undefined/no value for far will generate infinite projection matrix. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} fovy Vertical field of view in radians - * @param {number} aspect Aspect ratio. typically viewport width/height - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out - */ parcelHelpers.export(exports, "perspectiveNO", ()=>perspectiveNO); -parcelHelpers.export(exports, "perspective", ()=>perspective); -/** - * Generates a perspective projection matrix suitable for WebGPU with the given bounds. - * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], - * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. - * Passing null/undefined/no value for far will generate infinite projection matrix. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} fovy Vertical field of view in radians - * @param {number} aspect Aspect ratio. typically viewport width/height - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum, can be null or Infinity - * @returns {mat4} out - */ parcelHelpers.export(exports, "perspectiveZO", ()=>perspectiveZO); -/** - * Generates a perspective projection matrix with the given field of view. - * This is primarily useful for generating projection matrices to be used - * with the still experiemental WebVR API. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out - */ parcelHelpers.export(exports, "perspectiveFromFieldOfView", ()=>perspectiveFromFieldOfView); -/** - * Generates a orthogonal projection matrix with the given bounds. - * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1], - * which matches WebGL/OpenGL's clip volume. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} left Left bound of the frustum - * @param {number} right Right bound of the frustum - * @param {number} bottom Bottom bound of the frustum - * @param {number} top Top bound of the frustum - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out - */ parcelHelpers.export(exports, "orthoNO", ()=>orthoNO); -parcelHelpers.export(exports, "ortho", ()=>ortho); -/** - * Generates a orthogonal projection matrix with the given bounds. - * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1], - * which matches WebGPU/Vulkan/DirectX/Metal's clip volume. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {number} left Left bound of the frustum - * @param {number} right Right bound of the frustum - * @param {number} bottom Bottom bound of the frustum - * @param {number} top Top bound of the frustum - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {mat4} out - */ parcelHelpers.export(exports, "orthoZO", ()=>orthoZO); -/** - * Generates a look-at matrix with the given eye position, focal point, and up axis. - * If you want a matrix that actually makes an object look at another object, you should use targetTo instead. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {ReadonlyVec3} eye Position of the viewer - * @param {ReadonlyVec3} center Point the viewer is looking at - * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out - */ parcelHelpers.export(exports, "lookAt", ()=>lookAt); -/** - * Generates a matrix that makes something look at something else. - * - * @param {mat4} out mat4 frustum matrix will be written into - * @param {ReadonlyVec3} eye Position of the viewer - * @param {ReadonlyVec3} center Point the viewer is looking at - * @param {ReadonlyVec3} up vec3 pointing up - * @returns {mat4} out - */ parcelHelpers.export(exports, "targetTo", ()=>targetTo); -/** - * Returns a string representation of a mat4 + * Returns a string representation of a quatenion * - * @param {ReadonlyMat4} a matrix to represent as a string - * @returns {String} string representation of the matrix + * @param {ReadonlyQuat} a vector to represent as a string + * @returns {String} string representation of the vector */ parcelHelpers.export(exports, "str", ()=>str); -/** - * Returns Frobenius norm of a mat4 - * - * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of - * @returns {Number} Frobenius norm - */ parcelHelpers.export(exports, "frob", ()=>frob); -/** - * Adds two mat4's - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the first operand - * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out - */ parcelHelpers.export(exports, "add", ()=>add); -/** - * Subtracts matrix b from matrix a - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the first operand - * @param {ReadonlyMat4} b the second operand - * @returns {mat4} out - */ parcelHelpers.export(exports, "subtract", ()=>subtract); -/** - * Multiply each element of the matrix by a scalar. - * - * @param {mat4} out the receiving matrix - * @param {ReadonlyMat4} a the matrix to scale - * @param {Number} b amount to scale the matrix's elements by - * @returns {mat4} out - */ parcelHelpers.export(exports, "multiplyScalar", ()=>multiplyScalar); -/** - * Adds two mat4's after multiplying each element of the second operand by a scalar value. - * - * @param {mat4} out the receiving vector - * @param {ReadonlyMat4} a the first operand - * @param {ReadonlyMat4} b the second operand - * @param {Number} scale the amount to scale b's elements by before adding - * @returns {mat4} out - */ parcelHelpers.export(exports, "multiplyScalarAndAdd", ()=>multiplyScalarAndAdd); -/** - * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) - * - * @param {ReadonlyMat4} a The first matrix. - * @param {ReadonlyMat4} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); -/** - * Returns whether or not the matrices have approximately the same elements in the same position. - * - * @param {ReadonlyMat4} a The first matrix. - * @param {ReadonlyMat4} b The second matrix. - * @returns {Boolean} True if the matrices are equal, false otherwise. - */ parcelHelpers.export(exports, "equals", ()=>equals); +parcelHelpers.export(exports, "clone", ()=>clone); +parcelHelpers.export(exports, "fromValues", ()=>fromValues); +parcelHelpers.export(exports, "copy", ()=>copy); +parcelHelpers.export(exports, "set", ()=>set); +parcelHelpers.export(exports, "add", ()=>add); parcelHelpers.export(exports, "mul", ()=>mul); -parcelHelpers.export(exports, "sub", ()=>sub); +parcelHelpers.export(exports, "scale", ()=>scale); +parcelHelpers.export(exports, "dot", ()=>dot); +parcelHelpers.export(exports, "lerp", ()=>lerp); +parcelHelpers.export(exports, "length", ()=>length); +parcelHelpers.export(exports, "len", ()=>len); +parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); +parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); +parcelHelpers.export(exports, "normalize", ()=>normalize); +parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); +parcelHelpers.export(exports, "equals", ()=>equals); +parcelHelpers.export(exports, "rotationTo", ()=>rotationTo); +parcelHelpers.export(exports, "sqlerp", ()=>sqlerp); +parcelHelpers.export(exports, "setAxes", ()=>setAxes); var _commonJs = require("./common.js"); +var _mat3Js = require("./mat3.js"); +var _vec3Js = require("./vec3.js"); +var _vec4Js = require("./vec4.js"); function create() { - var out = new _commonJs.ARRAY_TYPE(16); + var out = new _commonJs.ARRAY_TYPE(4); if (_commonJs.ARRAY_TYPE != Float32Array) { + out[0] = 0; out[1] = 0; out[2] = 0; - out[3] = 0; - out[4] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; } - out[0] = 1; - out[5] = 1; - out[10] = 1; - out[15] = 1; + out[3] = 1; return out; } -function clone(a) { - var out = new _commonJs.ARRAY_TYPE(16); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; +function identity(out) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; return out; } -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; +function setAxisAngle(out, axis, rad) { + rad = rad * 0.5; + var s = Math.sin(rad); + out[0] = s * axis[0]; + out[1] = s * axis[1]; + out[2] = s * axis[2]; + out[3] = Math.cos(rad); return out; } -function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { - var out = new _commonJs.ARRAY_TYPE(16); - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m03; - out[4] = m10; - out[5] = m11; - out[6] = m12; - out[7] = m13; - out[8] = m20; - out[9] = m21; - out[10] = m22; - out[11] = m23; - out[12] = m30; - out[13] = m31; - out[14] = m32; - out[15] = m33; - return out; +function getAxisAngle(out_axis, q) { + var rad = Math.acos(q[3]) * 2.0; + var s = Math.sin(rad / 2.0); + if (s > _commonJs.EPSILON) { + out_axis[0] = q[0] / s; + out_axis[1] = q[1] / s; + out_axis[2] = q[2] / s; + } else { + // If s is zero, return any axis (no rotation - axis does not matter) + out_axis[0] = 1; + out_axis[1] = 0; + out_axis[2] = 0; + } + return rad; } -function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { - out[0] = m00; - out[1] = m01; - out[2] = m02; - out[3] = m03; - out[4] = m10; - out[5] = m11; - out[6] = m12; - out[7] = m13; - out[8] = m20; - out[9] = m21; - out[10] = m22; - out[11] = m23; - out[12] = m30; - out[13] = m31; - out[14] = m32; - out[15] = m33; +function getAngle(a, b) { + var dotproduct = dot(a, b); + return Math.acos(2 * dotproduct * dotproduct - 1); +} +function multiply(out, a, b) { + var ax = a[0], ay = a[1], az = a[2], aw = a[3]; + var bx = b[0], by = b[1], bz = b[2], bw = b[3]; + out[0] = ax * bw + aw * bx + ay * bz - az * by; + out[1] = ay * bw + aw * by + az * bx - ax * bz; + out[2] = az * bw + aw * bz + ax * by - ay * bx; + out[3] = aw * bw - ax * bx - ay * by - az * bz; return out; } -function identity(out) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function rotateX(out, a, rad) { + rad *= 0.5; + var ax = a[0], ay = a[1], az = a[2], aw = a[3]; + var bx = Math.sin(rad), bw = Math.cos(rad); + out[0] = ax * bw + aw * bx; + out[1] = ay * bw + az * bx; + out[2] = az * bw - ay * bx; + out[3] = aw * bw - ax * bx; return out; } -function transpose(out, a) { - // If we are transposing ourselves we can skip a few steps but have to cache some values - if (out === a) { - var a01 = a[1], a02 = a[2], a03 = a[3]; - var a12 = a[6], a13 = a[7]; - var a23 = a[11]; - out[1] = a[4]; - out[2] = a[8]; - out[3] = a[12]; - out[4] = a01; - out[6] = a[9]; - out[7] = a[13]; - out[8] = a02; - out[9] = a12; - out[11] = a[14]; - out[12] = a03; - out[13] = a13; - out[14] = a23; - } else { - out[0] = a[0]; - out[1] = a[4]; - out[2] = a[8]; - out[3] = a[12]; - out[4] = a[1]; - out[5] = a[5]; - out[6] = a[9]; - out[7] = a[13]; - out[8] = a[2]; - out[9] = a[6]; - out[10] = a[10]; - out[11] = a[14]; - out[12] = a[3]; - out[13] = a[7]; - out[14] = a[11]; - out[15] = a[15]; - } +function rotateY(out, a, rad) { + rad *= 0.5; + var ax = a[0], ay = a[1], az = a[2], aw = a[3]; + var by = Math.sin(rad), bw = Math.cos(rad); + out[0] = ax * bw - az * by; + out[1] = ay * bw + aw * by; + out[2] = az * bw + ax * by; + out[3] = aw * bw - ay * by; return out; } -function invert(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - if (!det) return null; - det = 1.0 / det; - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; +function rotateZ(out, a, rad) { + rad *= 0.5; + var ax = a[0], ay = a[1], az = a[2], aw = a[3]; + var bz = Math.sin(rad), bw = Math.cos(rad); + out[0] = ax * bw + ay * bz; + out[1] = ay * bw - ax * bz; + out[2] = az * bw + aw * bz; + out[3] = aw * bw - az * bz; return out; } -function adjoint(out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22); - out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12); - out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22); - out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12); - out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21); - out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11); - out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21); - out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11); +function calculateW(out, a) { + var x = a[0], y = a[1], z = a[2]; + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); return out; } -function determinant(a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; -} -function multiply(out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; // Cache only the current line of the second matrix - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[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[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[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[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[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[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[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; - return out; -} -function translate(out, a, v) { - var x = v[0], y = v[1], z = v[2]; - var a00, a01, a02, a03; - var a10, a11, a12, a13; - var a20, a21, a22, a23; - if (a === out) { - out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - } else { - a00 = a[0]; - a01 = a[1]; - a02 = a[2]; - a03 = a[3]; - a10 = a[4]; - a11 = a[5]; - a12 = a[6]; - a13 = a[7]; - a20 = a[8]; - a21 = a[9]; - a22 = a[10]; - a23 = a[11]; - out[0] = a00; - out[1] = a01; - out[2] = a02; - out[3] = a03; - out[4] = a10; - out[5] = a11; - out[6] = a12; - out[7] = a13; - out[8] = a20; - out[9] = a21; - out[10] = a22; - out[11] = a23; - out[12] = a00 * x + a10 * y + a20 * z + a[12]; - out[13] = a01 * x + a11 * y + a21 * z + a[13]; - out[14] = a02 * x + a12 * y + a22 * z + a[14]; - out[15] = a03 * x + a13 * y + a23 * z + a[15]; - } - return out; -} -function scale(out, a, v) { - var x = v[0], y = v[1], z = v[2]; - out[0] = a[0] * x; - out[1] = a[1] * x; - out[2] = a[2] * x; - out[3] = a[3] * x; - out[4] = a[4] * y; - out[5] = a[5] * y; - out[6] = a[6] * y; - out[7] = a[7] * y; - out[8] = a[8] * z; - out[9] = a[9] * z; - out[10] = a[10] * z; - out[11] = a[11] * z; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - return out; -} -function rotate(out, a, rad, axis) { - var x = axis[0], y = axis[1], z = axis[2]; - var len = Math.hypot(x, y, z); - var s, c, t; - var a00, a01, a02, a03; - var a10, a11, a12, a13; - var a20, a21, a22, a23; - var b00, b01, b02; - var b10, b11, b12; - var b20, b21, b22; - if (len < _commonJs.EPSILON) return null; - len = 1 / len; - x *= len; - y *= len; - z *= len; - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; - a00 = a[0]; - a01 = a[1]; - a02 = a[2]; - a03 = a[3]; - a10 = a[4]; - a11 = a[5]; - a12 = a[6]; - a13 = a[7]; - a20 = a[8]; - a21 = a[9]; - a22 = a[10]; - a23 = a[11]; // Construct the elements of the rotation matrix - b00 = x * x * t + c; - b01 = y * x * t + z * s; - b02 = z * x * t - y * s; - b10 = x * y * t - z * s; - b11 = y * y * t + c; - b12 = z * y * t + x * s; - b20 = x * z * t + y * s; - b21 = y * z * t - x * s; - b22 = z * z * t + c; // Perform rotation-specific matrix multiplication - out[0] = a00 * b00 + a10 * b01 + a20 * b02; - out[1] = a01 * b00 + a11 * b01 + a21 * b02; - out[2] = a02 * b00 + a12 * b01 + a22 * b02; - out[3] = a03 * b00 + a13 * b01 + a23 * b02; - out[4] = a00 * b10 + a10 * b11 + a20 * b12; - out[5] = a01 * b10 + a11 * b11 + a21 * b12; - out[6] = a02 * b10 + a12 * b11 + a22 * b12; - out[7] = a03 * b10 + a13 * b11 + a23 * b12; - out[8] = a00 * b20 + a10 * b21 + a20 * b22; - out[9] = a01 * b20 + a11 * b21 + a21 * b22; - out[10] = a02 * b20 + a12 * b21 + a22 * b22; - out[11] = a03 * b20 + a13 * b21 + a23 * b22; - if (a !== out) { - // If the source and destination differ, copy the unchanged last row - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } +function exp(out, a) { + var x = a[0], y = a[1], z = a[2], w = a[3]; + var r = Math.sqrt(x * x + y * y + z * z); + var et = Math.exp(w); + var s = r > 0 ? et * Math.sin(r) / r : 0; + out[0] = x * s; + out[1] = y * s; + out[2] = z * s; + out[3] = et * Math.cos(r); return out; } -function rotateX(out, a, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - if (a !== out) { - // If the source and destination differ, copy the unchanged rows - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } // Perform axis-specific matrix multiplication - out[4] = a10 * c + a20 * s; - out[5] = a11 * c + a21 * s; - out[6] = a12 * c + a22 * s; - out[7] = a13 * c + a23 * s; - out[8] = a20 * c - a10 * s; - out[9] = a21 * c - a11 * s; - out[10] = a22 * c - a12 * s; - out[11] = a23 * c - a13 * s; +function ln(out, a) { + var x = a[0], y = a[1], z = a[2], w = a[3]; + var r = Math.sqrt(x * x + y * y + z * z); + var t = r > 0 ? Math.atan2(r, w) / r : 0; + out[0] = x * t; + out[1] = y * t; + out[2] = z * t; + out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w); return out; } -function rotateY(out, a, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - if (a !== out) { - // If the source and destination differ, copy the unchanged rows - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } // Perform axis-specific matrix multiplication - out[0] = a00 * c - a20 * s; - out[1] = a01 * c - a21 * s; - out[2] = a02 * c - a22 * s; - out[3] = a03 * c - a23 * s; - out[8] = a00 * s + a20 * c; - out[9] = a01 * s + a21 * c; - out[10] = a02 * s + a22 * c; - out[11] = a03 * s + a23 * c; +function pow(out, a, b) { + ln(out, a); + scale(out, out, b); + exp(out, out); return out; } -function rotateZ(out, a, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - if (a !== out) { - // If the source and destination differ, copy the unchanged last row - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - } // Perform axis-specific matrix multiplication - out[0] = a00 * c + a10 * s; - out[1] = a01 * c + a11 * s; - out[2] = a02 * c + a12 * s; - out[3] = a03 * c + a13 * s; - out[4] = a10 * c - a00 * s; - out[5] = a11 * c - a01 * s; - out[6] = a12 * c - a02 * s; - out[7] = a13 * c - a03 * s; +function slerp(out, a, b, t) { + // benchmarks: + // http://jsperf.com/quaternion-slerp-implementations + var ax = a[0], ay = a[1], az = a[2], aw = a[3]; + var bx = b[0], by = b[1], bz = b[2], bw = b[3]; + var omega, cosom, sinom, scale0, scale1; // calc cosine + cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary) + if (cosom < 0.0) { + cosom = -cosom; + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + } // calculate coefficients + if (1.0 - cosom > _commonJs.EPSILON) { + // standard case (slerp) + omega = Math.acos(cosom); + sinom = Math.sin(omega); + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } else { + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + scale0 = 1.0 - t; + scale1 = t; + } // calculate final values + out[0] = scale0 * ax + scale1 * bx; + out[1] = scale0 * ay + scale1 * by; + out[2] = scale0 * az + scale1 * bz; + out[3] = scale0 * aw + scale1 * bw; return out; } -function fromTranslation(out, v) { - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; +function random(out) { + // Implementation of http://planning.cs.uiuc.edu/node198.html + // TODO: Calling random 3 times is probably not the fastest solution + var u1 = _commonJs.RANDOM(); + var u2 = _commonJs.RANDOM(); + var u3 = _commonJs.RANDOM(); + var sqrt1MinusU1 = Math.sqrt(1 - u1); + var sqrtU1 = Math.sqrt(u1); + out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2); + out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2); + out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3); + out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3); return out; } -function fromScaling(out, v) { - out[0] = v[0]; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = v[1]; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = v[2]; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function invert(out, a) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + out[0] = -a0 * invDot; + out[1] = -a1 * invDot; + out[2] = -a2 * invDot; + out[3] = a3 * invDot; return out; } -function fromRotation(out, rad, axis) { - var x = axis[0], y = axis[1], z = axis[2]; - var len = Math.hypot(x, y, z); - var s, c, t; - if (len < _commonJs.EPSILON) return null; - len = 1 / len; - x *= len; - y *= len; - z *= len; - s = Math.sin(rad); - c = Math.cos(rad); - t = 1 - c; // Perform rotation-specific matrix multiplication - out[0] = x * x * t + c; - out[1] = y * x * t + z * s; - out[2] = z * x * t - y * s; - out[3] = 0; - out[4] = x * y * t - z * s; - out[5] = y * y * t + c; - out[6] = z * y * t + x * s; - out[7] = 0; - out[8] = x * z * t + y * s; - out[9] = y * z * t - x * s; - out[10] = z * z * t + c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function conjugate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; + out[3] = a[3]; return out; } -function fromXRotation(out, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); // Perform axis-specific matrix multiplication - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = c; - out[6] = s; - out[7] = 0; - out[8] = 0; - out[9] = -s; - out[10] = c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function fromMat3(out, m) { + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + if (fTrace > 0.0) { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + out[3] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; // 1/(4w) + out[0] = (m[5] - m[7]) * fRoot; + out[1] = (m[6] - m[2]) * fRoot; + out[2] = (m[1] - m[3]) * fRoot; + } else { + // |w| <= 1/2 + var i = 0; + if (m[4] > m[0]) i = 1; + if (m[8] > m[i * 3 + i]) i = 2; + var j = (i + 1) % 3; + var k = (i + 2) % 3; + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0); + out[i] = 0.5 * fRoot; + fRoot = 0.5 / fRoot; + out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot; + out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + } return out; } -function fromYRotation(out, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); // Perform axis-specific matrix multiplication - out[0] = c; - out[1] = 0; - out[2] = -s; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = s; - out[9] = 0; - out[10] = c; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function fromEuler(out, x, y, z) { + var halfToRad = 0.5 * Math.PI / 180.0; + x *= halfToRad; + y *= halfToRad; + z *= halfToRad; + var sx = Math.sin(x); + var cx = Math.cos(x); + var sy = Math.sin(y); + var cy = Math.cos(y); + var sz = Math.sin(z); + var cz = Math.cos(z); + out[0] = sx * cy * cz - cx * sy * sz; + out[1] = cx * sy * cz + sx * cy * sz; + out[2] = cx * cy * sz - sx * sy * cz; + out[3] = cx * cy * cz + sx * sy * sz; return out; } -function fromZRotation(out, rad) { - var s = Math.sin(rad); - var c = Math.cos(rad); // Perform axis-specific matrix multiplication - out[0] = c; - out[1] = s; - out[2] = 0; - out[3] = 0; - out[4] = -s; - out[5] = c; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - return out; +function str(a) { + return "quat(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; } -function fromRotationTranslation(out, q, v) { - // Quaternion math - var x = q[0], y = q[1], z = q[2], w = q[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; +var clone = _vec4Js.clone; +var fromValues = _vec4Js.fromValues; +var copy = _vec4Js.copy; +var set = _vec4Js.set; +var add = _vec4Js.add; +var mul = multiply; +var scale = _vec4Js.scale; +var dot = _vec4Js.dot; +var lerp = _vec4Js.lerp; +var length = _vec4Js.length; +var len = length; +var squaredLength = _vec4Js.squaredLength; +var sqrLen = squaredLength; +var normalize = _vec4Js.normalize; +var exactEquals = _vec4Js.exactEquals; +var equals = _vec4Js.equals; +var rotationTo = function() { + var tmpvec3 = _vec3Js.create(); + var xUnitVec3 = _vec3Js.fromValues(1, 0, 0); + var yUnitVec3 = _vec3Js.fromValues(0, 1, 0); + return function(out, a, b) { + var dot = _vec3Js.dot(a, b); + if (dot < -0.999999) { + _vec3Js.cross(tmpvec3, xUnitVec3, a); + if (_vec3Js.len(tmpvec3) < 0.000001) _vec3Js.cross(tmpvec3, yUnitVec3, a); + _vec3Js.normalize(tmpvec3, tmpvec3); + setAxisAngle(out, tmpvec3, Math.PI); + return out; + } else if (dot > 0.999999) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 1; + return out; + } else { + _vec3Js.cross(tmpvec3, a, b); + out[0] = tmpvec3[0]; + out[1] = tmpvec3[1]; + out[2] = tmpvec3[2]; + out[3] = 1 + dot; + return normalize(out, out); + } + }; +}(); +var sqlerp = function() { + var temp1 = create(); + var temp2 = create(); + return function(out, a, b, c, d, t) { + slerp(temp1, a, d, t); + slerp(temp2, b, c, t); + slerp(out, temp1, temp2, 2 * t * (1 - t)); + return out; + }; +}(); +var setAxes = function() { + var matr = _mat3Js.create(); + return function(out, view, right, up) { + matr[0] = right[0]; + matr[3] = right[1]; + matr[6] = right[2]; + matr[1] = up[0]; + matr[4] = up[1]; + matr[7] = up[2]; + matr[2] = -view[0]; + matr[5] = -view[1]; + matr[8] = -view[2]; + return normalize(out, fromMat3(out, matr)); + }; +}(); + +},{"./common.js":"7GML7","./mat3.js":"80EZI","./vec3.js":"9zs5l","./vec4.js":"ao75m","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9zs5l":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +/** + * 3 Dimensional Vector + * @module vec3 + */ /** + * Creates a new, empty vec3 + * + * @returns {vec3} a new 3D vector + */ parcelHelpers.export(exports, "create", ()=>create); +/** + * Creates a new vec3 initialized with values from an existing vector + * + * @param {ReadonlyVec3} a vector to clone + * @returns {vec3} a new 3D vector + */ parcelHelpers.export(exports, "clone", ()=>clone); +/** + * Calculates the length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate length of + * @returns {Number} length of a + */ parcelHelpers.export(exports, "length", ()=>length); +/** + * Creates a new vec3 initialized with the given values + * + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} a new 3D vector + */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); +/** + * Copy the values from one vec3 to another + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the source vector + * @returns {vec3} out + */ parcelHelpers.export(exports, "copy", ()=>copy); +/** + * Set the components of a vec3 to the given values + * + * @param {vec3} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @returns {vec3} out + */ parcelHelpers.export(exports, "set", ()=>set); +/** + * Adds two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "add", ()=>add); +/** + * Subtracts vector b from vector a + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "subtract", ()=>subtract); +/** + * Multiplies two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "multiply", ()=>multiply); +/** + * Divides two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "divide", ()=>divide); +/** + * Math.ceil the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to ceil + * @returns {vec3} out + */ parcelHelpers.export(exports, "ceil", ()=>ceil); +/** + * Math.floor the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to floor + * @returns {vec3} out + */ parcelHelpers.export(exports, "floor", ()=>floor); +/** + * Returns the minimum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "min", ()=>min); +/** + * Returns the maximum of two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "max", ()=>max); +/** + * Math.round the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to round + * @returns {vec3} out + */ parcelHelpers.export(exports, "round", ()=>round); +/** + * Scales a vec3 by a scalar number + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec3} out + */ parcelHelpers.export(exports, "scale", ()=>scale); +/** + * Adds two vec3's after scaling the second operand by a scalar value + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec3} out + */ parcelHelpers.export(exports, "scaleAndAdd", ()=>scaleAndAdd); +/** + * Calculates the euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} distance between a and b + */ parcelHelpers.export(exports, "distance", ()=>distance); +/** + * Calculates the squared euclidian distance between two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} squared distance between a and b + */ parcelHelpers.export(exports, "squaredDistance", ()=>squaredDistance); +/** + * Calculates the squared length of a vec3 + * + * @param {ReadonlyVec3} a vector to calculate squared length of + * @returns {Number} squared length of a + */ parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); +/** + * Negates the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to negate + * @returns {vec3} out + */ parcelHelpers.export(exports, "negate", ()=>negate); +/** + * Returns the inverse of the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to invert + * @returns {vec3} out + */ parcelHelpers.export(exports, "inverse", ()=>inverse); +/** + * Normalize a vec3 + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a vector to normalize + * @returns {vec3} out + */ parcelHelpers.export(exports, "normalize", ()=>normalize); +/** + * Calculates the dot product of two vec3's + * + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {Number} dot product of a and b + */ parcelHelpers.export(exports, "dot", ()=>dot); +/** + * Computes the cross product of two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @returns {vec3} out + */ parcelHelpers.export(exports, "cross", ()=>cross); +/** + * Performs a linear interpolation between two vec3's + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ parcelHelpers.export(exports, "lerp", ()=>lerp); +/** + * Performs a hermite interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec3} c the third operand + * @param {ReadonlyVec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ parcelHelpers.export(exports, "hermite", ()=>hermite); +/** + * Performs a bezier interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the first operand + * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec3} c the third operand + * @param {ReadonlyVec3} d the fourth operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec3} out + */ parcelHelpers.export(exports, "bezier", ()=>bezier); +/** + * Generates a random vector with the given scale + * + * @param {vec3} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec3} out + */ parcelHelpers.export(exports, "random", ()=>random); +/** + * Transforms the vec3 with a mat4. + * 4th vector component is implicitly '1' + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {vec3} out + */ parcelHelpers.export(exports, "transformMat4", ()=>transformMat4); +/** + * Transforms the vec3 with a mat3. + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyMat3} m the 3x3 matrix to transform with + * @returns {vec3} out + */ parcelHelpers.export(exports, "transformMat3", ()=>transformMat3); +/** + * Transforms the vec3 with a quat + * Can also be used for dual quaternions. (Multiply it with the real part) + * + * @param {vec3} out the receiving vector + * @param {ReadonlyVec3} a the vector to transform + * @param {ReadonlyQuat} q quaternion to transform with + * @returns {vec3} out + */ parcelHelpers.export(exports, "transformQuat", ()=>transformQuat); +/** + * Rotate a 3D vector around the x-axis + * @param {vec3} out The receiving vec3 + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec3} out + */ parcelHelpers.export(exports, "rotateX", ()=>rotateX); +/** + * Rotate a 3D vector around the y-axis + * @param {vec3} out The receiving vec3 + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec3} out + */ parcelHelpers.export(exports, "rotateY", ()=>rotateY); +/** + * Rotate a 3D vector around the z-axis + * @param {vec3} out The receiving vec3 + * @param {ReadonlyVec3} a The vec3 point to rotate + * @param {ReadonlyVec3} b The origin of the rotation + * @param {Number} rad The angle of rotation in radians + * @returns {vec3} out + */ parcelHelpers.export(exports, "rotateZ", ()=>rotateZ); +/** + * Get the angle between two 3D vectors + * @param {ReadonlyVec3} a The first operand + * @param {ReadonlyVec3} b The second operand + * @returns {Number} The angle in radians + */ parcelHelpers.export(exports, "angle", ()=>angle); +/** + * Set the components of a vec3 to zero + * + * @param {vec3} out the receiving vector + * @returns {vec3} out + */ parcelHelpers.export(exports, "zero", ()=>zero); +/** + * Returns a string representation of a vector + * + * @param {ReadonlyVec3} a vector to represent as a string + * @returns {String} string representation of the vector + */ parcelHelpers.export(exports, "str", ()=>str); +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec3} a The first vector. + * @param {ReadonlyVec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec3} a The first vector. + * @param {ReadonlyVec3} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ parcelHelpers.export(exports, "equals", ()=>equals); +parcelHelpers.export(exports, "sub", ()=>sub); +parcelHelpers.export(exports, "mul", ()=>mul); +parcelHelpers.export(exports, "div", ()=>div); +parcelHelpers.export(exports, "dist", ()=>dist); +parcelHelpers.export(exports, "sqrDist", ()=>sqrDist); +parcelHelpers.export(exports, "len", ()=>len); +parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); +parcelHelpers.export(exports, "forEach", ()=>forEach); +var _commonJs = require("./common.js"); +function create() { + var out = new _commonJs.ARRAY_TYPE(3); + if (_commonJs.ARRAY_TYPE != Float32Array) { + out[0] = 0; + out[1] = 0; + out[2] = 0; + } return out; } -function fromQuat2(out, a) { - var translation = new _commonJs.ARRAY_TYPE(3); - var bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], ax = a[4], ay = a[5], az = a[6], aw = a[7]; - var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense - if (magnitude > 0) { - translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude; - translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude; - translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude; - } else { - translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; - translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; - translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; - } - fromRotationTranslation(out, a, translation); +function clone(a) { + var out = new _commonJs.ARRAY_TYPE(3); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; return out; } -function getTranslation(out, mat) { - out[0] = mat[12]; - out[1] = mat[13]; - out[2] = mat[14]; +function length(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + return Math.hypot(x, y, z); +} +function fromValues(x, y, z) { + var out = new _commonJs.ARRAY_TYPE(3); + out[0] = x; + out[1] = y; + out[2] = z; return out; } -function getScaling(out, mat) { - var m11 = mat[0]; - var m12 = mat[1]; - var m13 = mat[2]; - var m21 = mat[4]; - var m22 = mat[5]; - var m23 = mat[6]; - var m31 = mat[8]; - var m32 = mat[9]; - var m33 = mat[10]; - out[0] = Math.hypot(m11, m12, m13); - out[1] = Math.hypot(m21, m22, m23); - out[2] = Math.hypot(m31, m32, m33); +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; return out; } -function getRotation(out, mat) { - var scaling = new _commonJs.ARRAY_TYPE(3); - getScaling(scaling, mat); - var is1 = 1 / scaling[0]; - var is2 = 1 / scaling[1]; - var is3 = 1 / scaling[2]; - var sm11 = mat[0] * is1; - var sm12 = mat[1] * is2; - var sm13 = mat[2] * is3; - var sm21 = mat[4] * is1; - var sm22 = mat[5] * is2; - var sm23 = mat[6] * is3; - var sm31 = mat[8] * is1; - var sm32 = mat[9] * is2; - var sm33 = mat[10] * is3; - var trace = sm11 + sm22 + sm33; - var S = 0; - if (trace > 0) { - S = Math.sqrt(trace + 1.0) * 2; - out[3] = 0.25 * S; - out[0] = (sm23 - sm32) / S; - out[1] = (sm31 - sm13) / S; - out[2] = (sm12 - sm21) / S; - } else if (sm11 > sm22 && sm11 > sm33) { - S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2; - out[3] = (sm23 - sm32) / S; - out[0] = 0.25 * S; - out[1] = (sm12 + sm21) / S; - out[2] = (sm31 + sm13) / S; - } else if (sm22 > sm33) { - S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2; - out[3] = (sm31 - sm13) / S; - out[0] = (sm12 + sm21) / S; - out[1] = 0.25 * S; - out[2] = (sm23 + sm32) / S; - } else { - S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2; - out[3] = (sm12 - sm21) / S; - out[0] = (sm31 + sm13) / S; - out[1] = (sm23 + sm32) / S; - out[2] = 0.25 * S; - } +function set(out, x, y, z) { + out[0] = x; + out[1] = y; + out[2] = z; return out; } -function fromRotationTranslationScale(out, q, v, s) { - // Quaternion math - var x = q[0], y = q[1], z = q[2], w = q[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - var sx = s[0]; - var sy = s[1]; - var sz = s[2]; - out[0] = (1 - (yy + zz)) * sx; - out[1] = (xy + wz) * sx; - out[2] = (xz - wy) * sx; - out[3] = 0; - out[4] = (xy - wz) * sy; - out[5] = (1 - (xx + zz)) * sy; - out[6] = (yz + wx) * sy; - out[7] = 0; - out[8] = (xz + wy) * sz; - out[9] = (yz - wx) * sz; - out[10] = (1 - (xx + yy)) * sz; - out[11] = 0; - out[12] = v[0]; - out[13] = v[1]; - out[14] = v[2]; - out[15] = 1; +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; return out; } -function fromRotationTranslationScaleOrigin(out, q, v, s, o) { - // Quaternion math - var x = q[0], y = q[1], z = q[2], w = q[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - var sx = s[0]; - var sy = s[1]; - var sz = s[2]; - var ox = o[0]; - var oy = o[1]; - var oz = o[2]; - var out0 = (1 - (yy + zz)) * sx; - var out1 = (xy + wz) * sx; - var out2 = (xz - wy) * sx; - var out4 = (xy - wz) * sy; - var out5 = (1 - (xx + zz)) * sy; - var out6 = (yz + wx) * sy; - var out8 = (xz + wy) * sz; - var out9 = (yz - wx) * sz; - var out10 = (1 - (xx + yy)) * sz; - out[0] = out0; - out[1] = out1; - out[2] = out2; - out[3] = 0; - out[4] = out4; - out[5] = out5; - out[6] = out6; - out[7] = 0; - out[8] = out8; - out[9] = out9; - out[10] = out10; - out[11] = 0; - out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz); - out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz); - out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz); - out[15] = 1; +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; return out; } -function fromQuat(out, q) { - var x = q[0], y = q[1], z = q[2], w = q[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var yx = y * x2; - var yy = y * y2; - var zx = z * x2; - var zy = z * y2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - out[0] = 1 - yy - zz; - out[1] = yx + wz; - out[2] = zx - wy; - out[3] = 0; - out[4] = yx - wz; - out[5] = 1 - xx - zz; - out[6] = zy + wx; - out[7] = 0; - out[8] = zx + wy; - out[9] = zy - wx; - out[10] = 1 - xx - yy; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; +function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; return out; } -function frustum(out, left, right, bottom, top, near, far) { - var rl = 1 / (right - left); - var tb = 1 / (top - bottom); - var nf = 1 / (near - far); - out[0] = near * 2 * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = near * 2 * tb; - out[6] = 0; - out[7] = 0; - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[14] = far * near * 2 * nf; - out[15] = 0; +function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; return out; } -function perspectiveNO(out, fovy, aspect, near, far) { - var f = 1.0 / Math.tan(fovy / 2), nf; - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[15] = 0; - if (far != null && far !== Infinity) { - nf = 1 / (near - far); - out[10] = (far + near) * nf; - out[14] = 2 * far * near * nf; - } else { - out[10] = -1; - out[14] = -2 * near; - } +function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); return out; } -var perspective = perspectiveNO; -function perspectiveZO(out, fovy, aspect, near, far) { - var f = 1.0 / Math.tan(fovy / 2), nf; - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[11] = -1; - out[12] = 0; - out[13] = 0; - out[15] = 0; - if (far != null && far !== Infinity) { - nf = 1 / (near - far); - out[10] = far * nf; - out[14] = far * near * nf; - } else { - out[10] = -1; - out[14] = -near; - } +function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); return out; } -function perspectiveFromFieldOfView(out, fov, near, far) { - var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0); - var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0); - var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0); - var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0); - var xScale = 2.0 / (leftTan + rightTan); - var yScale = 2.0 / (upTan + downTan); - out[0] = xScale; - out[1] = 0.0; - out[2] = 0.0; - out[3] = 0.0; - out[4] = 0.0; - out[5] = yScale; - out[6] = 0.0; - out[7] = 0.0; - out[8] = -((leftTan - rightTan) * xScale * 0.5); - out[9] = (upTan - downTan) * yScale * 0.5; - out[10] = far / (near - far); - out[11] = -1; - out[12] = 0.0; - out[13] = 0.0; - out[14] = far * near / (near - far); - out[15] = 0.0; +function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); return out; } -function orthoNO(out, left, right, bottom, top, near, far) { - var lr = 1 / (left - right); - var bt = 1 / (bottom - top); - var nf = 1 / (near - far); - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; +function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); return out; } -var ortho = orthoNO; -function orthoZO(out, left, right, bottom, top, near, far) { - var lr = 1 / (left - right); - var bt = 1 / (bottom - top); - var nf = 1 / (near - far); - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = nf; - out[11] = 0; - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = near * nf; - out[15] = 1; +function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); return out; } -function lookAt(out, eye, center, up) { - var x0, x1, x2, y0, y1, y2, z0, z1, z2, len; - var eyex = eye[0]; - var eyey = eye[1]; - var eyez = eye[2]; - var upx = up[0]; - var upy = up[1]; - var upz = up[2]; - var centerx = center[0]; - var centery = center[1]; - var centerz = center[2]; - if (Math.abs(eyex - centerx) < _commonJs.EPSILON && Math.abs(eyey - centery) < _commonJs.EPSILON && Math.abs(eyez - centerz) < _commonJs.EPSILON) return identity(out); - z0 = eyex - centerx; - z1 = eyey - centery; - z2 = eyez - centerz; - len = 1 / Math.hypot(z0, z1, z2); - z0 *= len; - z1 *= len; - z2 *= len; - x0 = upy * z2 - upz * z1; - x1 = upz * z0 - upx * z2; - x2 = upx * z1 - upy * z0; - len = Math.hypot(x0, x1, x2); - if (!len) { - x0 = 0; - x1 = 0; - x2 = 0; - } else { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } - y0 = z1 * x2 - z2 * x1; - y1 = z2 * x0 - z0 * x2; - y2 = z0 * x1 - z1 * x0; - len = Math.hypot(y0, y1, y2); - if (!len) { - y0 = 0; - y1 = 0; - y2 = 0; - } else { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; +function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; return out; } -function targetTo(out, eye, target, up) { - var eyex = eye[0], eyey = eye[1], eyez = eye[2], upx = up[0], upy = up[1], upz = up[2]; - var z0 = eyex - target[0], z1 = eyey - target[1], z2 = eyez - target[2]; - var len = z0 * z0 + z1 * z1 + z2 * z2; - if (len > 0) { - len = 1 / Math.sqrt(len); - z0 *= len; - z1 *= len; - z2 *= len; - } - var x0 = upy * z2 - upz * z1, x1 = upz * z0 - upx * z2, x2 = upx * z1 - upy * z0; - len = x0 * x0 + x1 * x1 + x2 * x2; - if (len > 0) { - len = 1 / Math.sqrt(len); - x0 *= len; - x1 *= len; - x2 *= len; - } - out[0] = x0; - out[1] = x1; - out[2] = x2; - out[3] = 0; - out[4] = z1 * x2 - z2 * x1; - out[5] = z2 * x0 - z0 * x2; - out[6] = z0 * x1 - z1 * x0; - out[7] = 0; - out[8] = z0; - out[9] = z1; - out[10] = z2; - out[11] = 0; - out[12] = eyex; - out[13] = eyey; - out[14] = eyez; - out[15] = 1; +function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; return out; } -function str(a) { - return "mat4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ", " + a[9] + ", " + a[10] + ", " + a[11] + ", " + a[12] + ", " + a[13] + ", " + a[14] + ", " + a[15] + ")"; +function distance(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + return Math.hypot(x, y, z); } -function frob(a) { - return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); +function squaredDistance(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + return x * x + y * y + z * z; } -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - out[8] = a[8] + b[8]; - out[9] = a[9] + b[9]; - out[10] = a[10] + b[10]; - out[11] = a[11] + b[11]; - out[12] = a[12] + b[12]; - out[13] = a[13] + b[13]; - out[14] = a[14] + b[14]; - out[15] = a[15] + b[15]; - return out; +function squaredLength(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + return x * x + y * y + z * z; } -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - out[4] = a[4] - b[4]; - out[5] = a[5] - b[5]; - out[6] = a[6] - b[6]; - out[7] = a[7] - b[7]; - out[8] = a[8] - b[8]; - out[9] = a[9] - b[9]; - out[10] = a[10] - b[10]; - out[11] = a[11] - b[11]; - out[12] = a[12] - b[12]; - out[13] = a[13] - b[13]; - out[14] = a[14] - b[14]; - out[15] = a[15] - b[15]; +function negate(out, a) { + out[0] = -a[0]; + out[1] = -a[1]; + out[2] = -a[2]; return out; } -function multiplyScalar(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - out[8] = a[8] * b; - out[9] = a[9] * b; - out[10] = a[10] * b; - out[11] = a[11] * b; - out[12] = a[12] * b; - out[13] = a[13] * b; - out[14] = a[14] * b; - out[15] = a[15] * b; +function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; return out; } -function multiplyScalarAndAdd(out, a, b, scale) { - out[0] = a[0] + b[0] * scale; - out[1] = a[1] + b[1] * scale; - out[2] = a[2] + b[2] * scale; - out[3] = a[3] + b[3] * scale; - out[4] = a[4] + b[4] * scale; - out[5] = a[5] + b[5] * scale; - out[6] = a[6] + b[6] * scale; - out[7] = a[7] + b[7] * scale; - out[8] = a[8] + b[8] * scale; - out[9] = a[9] + b[9] * scale; - out[10] = a[10] + b[10] * scale; - out[11] = a[11] + b[11] * scale; - out[12] = a[12] + b[12] * scale; - out[13] = a[13] + b[13] * scale; - out[14] = a[14] + b[14] * scale; - out[15] = a[15] + b[15] * scale; +function normalize(out, a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var len = x * x + y * y + z * z; + if (len > 0) //TODO: evaluate use of glm_invsqrt here? + len = 1 / Math.sqrt(len); + out[0] = a[0] * len; + out[1] = a[1] * len; + out[2] = a[2] * len; return out; } -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15]; +function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } -function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; - var a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11]; - var a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - var b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; - var b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11]; - var b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15)); +function cross(out, a, b) { + var ax = a[0], ay = a[1], az = a[2]; + var bx = b[0], by = b[1], bz = b[2]; + out[0] = ay * bz - az * by; + out[1] = az * bx - ax * bz; + out[2] = ax * by - ay * bx; + return out; } -var mul = multiply; -var sub = subtract; +function lerp(out, a, b, t) { + var ax = a[0]; + var ay = a[1]; + var az = a[2]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + return out; +} +function hermite(out, a, b, c, d, t) { + var factorTimes2 = t * t; + var factor1 = factorTimes2 * (2 * t - 3) + 1; + var factor2 = factorTimes2 * (t - 2) + t; + var factor3 = factorTimes2 * (t - 1); + var factor4 = factorTimes2 * (3 - 2 * t); + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + return out; +} +function bezier(out, a, b, c, d, t) { + var inverseFactor = 1 - t; + var inverseFactorTimesTwo = inverseFactor * inverseFactor; + var factorTimes2 = t * t; + var factor1 = inverseFactorTimesTwo * inverseFactor; + var factor2 = 3 * t * inverseFactorTimesTwo; + var factor3 = 3 * factorTimes2 * inverseFactor; + var factor4 = factorTimes2 * t; + out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; + out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; + out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; + return out; +} +function random(out, scale) { + scale = scale || 1.0; + var r = _commonJs.RANDOM() * 2.0 * Math.PI; + var z = _commonJs.RANDOM() * 2.0 - 1.0; + var zScale = Math.sqrt(1.0 - z * z) * scale; + out[0] = Math.cos(r) * zScale; + out[1] = Math.sin(r) * zScale; + out[2] = z * scale; + return out; +} +function transformMat4(out, a, m) { + var x = a[0], y = a[1], z = a[2]; + var w = m[3] * x + m[7] * y + m[11] * z + m[15]; + w = w || 1.0; + out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; + out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; + out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + return out; +} +function transformMat3(out, a, m) { + var x = a[0], y = a[1], z = a[2]; + out[0] = x * m[0] + y * m[3] + z * m[6]; + out[1] = x * m[1] + y * m[4] + z * m[7]; + out[2] = x * m[2] + y * m[5] + z * m[8]; + return out; +} +function transformQuat(out, a, q) { + // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed + var qx = q[0], qy = q[1], qz = q[2], qw = q[3]; + var x = a[0], y = a[1], z = a[2]; // var qvec = [qx, qy, qz]; + // var uv = vec3.cross([], qvec, a); + var uvx = qy * z - qz * y, uvy = qz * x - qx * z, uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv); + var uuvx = qy * uvz - qz * uvy, uuvy = qz * uvx - qx * uvz, uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w); + var w2 = qw * 2; + uvx *= w2; + uvy *= w2; + uvz *= w2; // vec3.scale(uuv, uuv, 2); + uuvx *= 2; + uuvy *= 2; + uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv)); + out[0] = x + uvx + uuvx; + out[1] = y + uvy + uuvy; + out[2] = z + uvz + uuvz; + return out; +} +function rotateX(out, a, b, rad) { + var p = [], r = []; //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; //perform rotation + r[0] = p[0]; + r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad); + r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + return out; +} +function rotateY(out, a, b, rad) { + var p = [], r = []; //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; //perform rotation + r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad); + r[1] = p[1]; + r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + return out; +} +function rotateZ(out, a, b, rad) { + var p = [], r = []; //Translate point to the origin + p[0] = a[0] - b[0]; + p[1] = a[1] - b[1]; + p[2] = a[2] - b[2]; //perform rotation + r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad); + r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad); + r[2] = p[2]; //translate to correct position + out[0] = r[0] + b[0]; + out[1] = r[1] + b[1]; + out[2] = r[2] + b[2]; + return out; +} +function angle(a, b) { + var ax = a[0], ay = a[1], az = a[2], bx = b[0], by = b[1], bz = b[2], mag1 = Math.sqrt(ax * ax + ay * ay + az * az), mag2 = Math.sqrt(bx * bx + by * by + bz * bz), mag = mag1 * mag2, cosine = mag && dot(a, b) / mag; + return Math.acos(Math.min(Math.max(cosine, -1), 1)); +} +function zero(out) { + out[0] = 0.0; + out[1] = 0.0; + out[2] = 0.0; + return out; +} +function str(a) { + return "vec3(" + a[0] + ", " + a[1] + ", " + a[2] + ")"; +} +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; +} +function equals(a, b) { + var a0 = a[0], a1 = a[1], a2 = a[2]; + var b0 = b[0], b1 = b[1], b2 = b[2]; + return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)); +} +var sub = subtract; +var mul = multiply; +var div = divide; +var dist = distance; +var sqrDist = squaredDistance; +var len = length; +var sqrLen = squaredLength; +var forEach = function() { + var vec = create(); + return function(a, stride, offset, count, fn, arg) { + var i, l; + if (!stride) stride = 3; + if (!offset) offset = 0; + if (count) l = Math.min(count * stride + offset, a.length); + else l = a.length; + for(i = offset; i < l; i += stride){ + vec[0] = a[i]; + vec[1] = a[i + 1]; + vec[2] = a[i + 2]; + fn(vec, vec, arg); + a[i] = vec[0]; + a[i + 1] = vec[1]; + a[i + 2] = vec[2]; + } + return a; + }; +}(); -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bBHpM":[function(require,module,exports) { +},{"./common.js":"7GML7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ao75m":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); /** - * Quaternion - * @module quat + * 4 Dimensional Vector + * @module vec4 */ /** - * Creates a new identity quat + * Creates a new, empty vec4 * - * @returns {quat} a new quaternion + * @returns {vec4} a new 4D vector */ parcelHelpers.export(exports, "create", ()=>create); /** - * Set a quat to the identity quaternion + * Creates a new vec4 initialized with values from an existing vector * - * @param {quat} out the receiving quaternion - * @returns {quat} out - */ parcelHelpers.export(exports, "identity", ()=>identity); + * @param {ReadonlyVec4} a vector to clone + * @returns {vec4} a new 4D vector + */ parcelHelpers.export(exports, "clone", ()=>clone); /** - * Sets a quat from the given angle and rotation axis, - * then returns it. + * Creates a new vec4 initialized with the given values * - * @param {quat} out the receiving quaternion - * @param {ReadonlyVec3} axis the axis around which to rotate - * @param {Number} rad the angle in radians - * @returns {quat} out - **/ parcelHelpers.export(exports, "setAxisAngle", ()=>setAxisAngle); + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} a new 4D vector + */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); /** - * Gets the rotation axis and angle for a given - * quaternion. If a quaternion is created with - * setAxisAngle, this method will return the same - * values as providied in the original parameter list - * OR functionally equivalent values. - * Example: The quaternion formed by axis [0, 0, 1] and - * angle -90 is the same as the quaternion formed by - * [0, 0, 1] and 270. This method favors the latter. - * @param {vec3} out_axis Vector receiving the axis of rotation - * @param {ReadonlyQuat} q Quaternion to be decomposed - * @return {Number} Angle, in radians, of the rotation - */ parcelHelpers.export(exports, "getAxisAngle", ()=>getAxisAngle); + * Copy the values from one vec4 to another + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the source vector + * @returns {vec4} out + */ parcelHelpers.export(exports, "copy", ()=>copy); /** - * Gets the angular distance between two unit quaternions + * Set the components of a vec4 to the given values * - * @param {ReadonlyQuat} a Origin unit quaternion - * @param {ReadonlyQuat} b Destination unit quaternion - * @return {Number} Angle, in radians, between the two quaternions - */ parcelHelpers.export(exports, "getAngle", ()=>getAngle); + * @param {vec4} out the receiving vector + * @param {Number} x X component + * @param {Number} y Y component + * @param {Number} z Z component + * @param {Number} w W component + * @returns {vec4} out + */ parcelHelpers.export(exports, "set", ()=>set); /** - * Multiplies two quat's + * Adds two vec4's * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a the first operand - * @param {ReadonlyQuat} b the second operand - * @returns {quat} out + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ parcelHelpers.export(exports, "add", ()=>add); +/** + * Subtracts vector b from vector a + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ parcelHelpers.export(exports, "subtract", ()=>subtract); +/** + * Multiplies two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out */ parcelHelpers.export(exports, "multiply", ()=>multiply); /** - * Rotates a quaternion by the given angle about the X axis + * Divides two vec4's * - * @param {quat} out quat receiving operation result - * @param {ReadonlyQuat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ parcelHelpers.export(exports, "rotateX", ()=>rotateX); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ parcelHelpers.export(exports, "divide", ()=>divide); /** - * Rotates a quaternion by the given angle about the Y axis + * Math.ceil the components of a vec4 * - * @param {quat} out quat receiving operation result - * @param {ReadonlyQuat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ parcelHelpers.export(exports, "rotateY", ()=>rotateY); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to ceil + * @returns {vec4} out + */ parcelHelpers.export(exports, "ceil", ()=>ceil); /** - * Rotates a quaternion by the given angle about the Z axis + * Math.floor the components of a vec4 * - * @param {quat} out quat receiving operation result - * @param {ReadonlyQuat} a quat to rotate - * @param {number} rad angle (in radians) to rotate - * @returns {quat} out - */ parcelHelpers.export(exports, "rotateZ", ()=>rotateZ); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to floor + * @returns {vec4} out + */ parcelHelpers.export(exports, "floor", ()=>floor); /** - * Calculates the W component of a quat from the X, Y, and Z components. - * Assumes that quaternion is 1 unit in length. - * Any existing W component will be ignored. + * Returns the minimum of two vec4's * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a quat to calculate W component of - * @returns {quat} out - */ parcelHelpers.export(exports, "calculateW", ()=>calculateW); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ parcelHelpers.export(exports, "min", ()=>min); /** - * Calculate the exponential of a unit quaternion. + * Returns the maximum of two vec4's * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out - */ parcelHelpers.export(exports, "exp", ()=>exp); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {vec4} out + */ parcelHelpers.export(exports, "max", ()=>max); /** - * Calculate the natural logarithm of a unit quaternion. + * Math.round the components of a vec4 * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a quat to calculate the exponential of - * @returns {quat} out - */ parcelHelpers.export(exports, "ln", ()=>ln); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to round + * @returns {vec4} out + */ parcelHelpers.export(exports, "round", ()=>round); /** - * Calculate the scalar power of a unit quaternion. + * Scales a vec4 by a scalar number * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a quat to calculate the exponential of - * @param {Number} b amount to scale the quaternion by - * @returns {quat} out - */ parcelHelpers.export(exports, "pow", ()=>pow); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the vector to scale + * @param {Number} b amount to scale the vector by + * @returns {vec4} out + */ parcelHelpers.export(exports, "scale", ()=>scale); /** - * Performs a spherical linear interpolation between two quat + * Adds two vec4's after scaling the second operand by a scalar value * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a the first operand - * @param {ReadonlyQuat} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat} out - */ parcelHelpers.export(exports, "slerp", ()=>slerp); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @param {Number} scale the amount to scale b by before adding + * @returns {vec4} out + */ parcelHelpers.export(exports, "scaleAndAdd", ()=>scaleAndAdd); /** - * Generates a random unit quaternion + * Calculates the euclidian distance between two vec4's * - * @param {quat} out the receiving quaternion - * @returns {quat} out - */ parcelHelpers.export(exports, "random", ()=>random); + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} distance between a and b + */ parcelHelpers.export(exports, "distance", ()=>distance); /** - * Calculates the inverse of a quat + * Calculates the squared euclidian distance between two vec4's * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a quat to calculate inverse of - * @returns {quat} out - */ parcelHelpers.export(exports, "invert", ()=>invert); + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} squared distance between a and b + */ parcelHelpers.export(exports, "squaredDistance", ()=>squaredDistance); /** - * Calculates the conjugate of a quat - * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. + * Calculates the length of a vec4 * - * @param {quat} out the receiving quaternion - * @param {ReadonlyQuat} a quat to calculate conjugate of - * @returns {quat} out - */ parcelHelpers.export(exports, "conjugate", ()=>conjugate); + * @param {ReadonlyVec4} a vector to calculate length of + * @returns {Number} length of a + */ parcelHelpers.export(exports, "length", ()=>length); /** - * Creates a quaternion from the given 3x3 rotation matrix. + * Calculates the squared length of a vec4 * - * NOTE: The resultant quaternion is not normalized, so you should be sure - * to renormalize the quaternion yourself where necessary. + * @param {ReadonlyVec4} a vector to calculate squared length of + * @returns {Number} squared length of a + */ parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); +/** + * Negates the components of a vec4 * - * @param {quat} out the receiving quaternion - * @param {ReadonlyMat3} m rotation matrix - * @returns {quat} out - * @function - */ parcelHelpers.export(exports, "fromMat3", ()=>fromMat3); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to negate + * @returns {vec4} out + */ parcelHelpers.export(exports, "negate", ()=>negate); /** - * Creates a quaternion from the given euler angle x, y, z. + * Returns the inverse of the components of a vec4 * - * @param {quat} out the receiving quaternion - * @param {x} Angle to rotate around X axis in degrees. - * @param {y} Angle to rotate around Y axis in degrees. - * @param {z} Angle to rotate around Z axis in degrees. - * @returns {quat} out - * @function - */ parcelHelpers.export(exports, "fromEuler", ()=>fromEuler); + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to invert + * @returns {vec4} out + */ parcelHelpers.export(exports, "inverse", ()=>inverse); /** - * Returns a string representation of a quatenion + * Normalize a vec4 * - * @param {ReadonlyQuat} a vector to represent as a string + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a vector to normalize + * @returns {vec4} out + */ parcelHelpers.export(exports, "normalize", ()=>normalize); +/** + * Calculates the dot product of two vec4's + * + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @returns {Number} dot product of a and b + */ parcelHelpers.export(exports, "dot", ()=>dot); +/** + * Returns the cross-product of three vectors in a 4-dimensional space + * + * @param {ReadonlyVec4} result the receiving vector + * @param {ReadonlyVec4} U the first vector + * @param {ReadonlyVec4} V the second vector + * @param {ReadonlyVec4} W the third vector + * @returns {vec4} result + */ parcelHelpers.export(exports, "cross", ()=>cross); +/** + * Performs a linear interpolation between two vec4's + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the first operand + * @param {ReadonlyVec4} b the second operand + * @param {Number} t interpolation amount, in the range [0-1], between the two inputs + * @returns {vec4} out + */ parcelHelpers.export(exports, "lerp", ()=>lerp); +/** + * Generates a random vector with the given scale + * + * @param {vec4} out the receiving vector + * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns {vec4} out + */ parcelHelpers.export(exports, "random", ()=>random); +/** + * Transforms the vec4 with a mat4. + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {vec4} out + */ parcelHelpers.export(exports, "transformMat4", ()=>transformMat4); +/** + * Transforms the vec4 with a quat + * + * @param {vec4} out the receiving vector + * @param {ReadonlyVec4} a the vector to transform + * @param {ReadonlyQuat} q quaternion to transform with + * @returns {vec4} out + */ parcelHelpers.export(exports, "transformQuat", ()=>transformQuat); +/** + * Set the components of a vec4 to zero + * + * @param {vec4} out the receiving vector + * @returns {vec4} out + */ parcelHelpers.export(exports, "zero", ()=>zero); +/** + * Returns a string representation of a vector + * + * @param {ReadonlyVec4} a vector to represent as a string * @returns {String} string representation of the vector */ parcelHelpers.export(exports, "str", ()=>str); -parcelHelpers.export(exports, "clone", ()=>clone); -parcelHelpers.export(exports, "fromValues", ()=>fromValues); -parcelHelpers.export(exports, "copy", ()=>copy); -parcelHelpers.export(exports, "set", ()=>set); -parcelHelpers.export(exports, "add", ()=>add); +/** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {ReadonlyVec4} a The first vector. + * @param {ReadonlyVec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); +/** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {ReadonlyVec4} a The first vector. + * @param {ReadonlyVec4} b The second vector. + * @returns {Boolean} True if the vectors are equal, false otherwise. + */ parcelHelpers.export(exports, "equals", ()=>equals); +parcelHelpers.export(exports, "sub", ()=>sub); parcelHelpers.export(exports, "mul", ()=>mul); -parcelHelpers.export(exports, "scale", ()=>scale); -parcelHelpers.export(exports, "dot", ()=>dot); -parcelHelpers.export(exports, "lerp", ()=>lerp); -parcelHelpers.export(exports, "length", ()=>length); +parcelHelpers.export(exports, "div", ()=>div); +parcelHelpers.export(exports, "dist", ()=>dist); +parcelHelpers.export(exports, "sqrDist", ()=>sqrDist); parcelHelpers.export(exports, "len", ()=>len); -parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); -parcelHelpers.export(exports, "normalize", ()=>normalize); -parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); -parcelHelpers.export(exports, "equals", ()=>equals); -parcelHelpers.export(exports, "rotationTo", ()=>rotationTo); -parcelHelpers.export(exports, "sqlerp", ()=>sqlerp); -parcelHelpers.export(exports, "setAxes", ()=>setAxes); +parcelHelpers.export(exports, "forEach", ()=>forEach); var _commonJs = require("./common.js"); -var _mat3Js = require("./mat3.js"); -var _vec3Js = require("./vec3.js"); -var _vec4Js = require("./vec4.js"); function create() { var out = new _commonJs.ARRAY_TYPE(4); if (_commonJs.ARRAY_TYPE != Float32Array) { out[0] = 0; out[1] = 0; out[2] = 0; + out[3] = 0; } - out[3] = 1; return out; } -function identity(out) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; +function clone(a) { + var out = new _commonJs.ARRAY_TYPE(4); + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; return out; } -function setAxisAngle(out, axis, rad) { - rad = rad * 0.5; - var s = Math.sin(rad); - out[0] = s * axis[0]; - out[1] = s * axis[1]; - out[2] = s * axis[2]; - out[3] = Math.cos(rad); +function fromValues(x, y, z, w) { + var out = new _commonJs.ARRAY_TYPE(4); + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; return out; } -function getAxisAngle(out_axis, q) { - var rad = Math.acos(q[3]) * 2.0; - var s = Math.sin(rad / 2.0); - if (s > _commonJs.EPSILON) { - out_axis[0] = q[0] / s; - out_axis[1] = q[1] / s; - out_axis[2] = q[2] / s; - } else { - // If s is zero, return any axis (no rotation - axis does not matter) - out_axis[0] = 1; - out_axis[1] = 0; - out_axis[2] = 0; - } - return rad; +function copy(out, a) { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + return out; } -function getAngle(a, b) { - var dotproduct = dot(a, b); - return Math.acos(2 * dotproduct * dotproduct - 1); +function set(out, x, y, z, w) { + out[0] = x; + out[1] = y; + out[2] = z; + out[3] = w; + return out; } -function multiply(out, a, b) { - var ax = a[0], ay = a[1], az = a[2], aw = a[3]; - var bx = b[0], by = b[1], bz = b[2], bw = b[3]; - out[0] = ax * bw + aw * bx + ay * bz - az * by; - out[1] = ay * bw + aw * by + az * bx - ax * bz; - out[2] = az * bw + aw * bz + ax * by - ay * bx; - out[3] = aw * bw - ax * bx - ay * by - az * bz; +function add(out, a, b) { + out[0] = a[0] + b[0]; + out[1] = a[1] + b[1]; + out[2] = a[2] + b[2]; + out[3] = a[3] + b[3]; return out; } -function rotateX(out, a, rad) { - rad *= 0.5; - var ax = a[0], ay = a[1], az = a[2], aw = a[3]; - var bx = Math.sin(rad), bw = Math.cos(rad); - out[0] = ax * bw + aw * bx; - out[1] = ay * bw + az * bx; - out[2] = az * bw - ay * bx; - out[3] = aw * bw - ax * bx; +function subtract(out, a, b) { + out[0] = a[0] - b[0]; + out[1] = a[1] - b[1]; + out[2] = a[2] - b[2]; + out[3] = a[3] - b[3]; return out; } -function rotateY(out, a, rad) { - rad *= 0.5; - var ax = a[0], ay = a[1], az = a[2], aw = a[3]; - var by = Math.sin(rad), bw = Math.cos(rad); - out[0] = ax * bw - az * by; - out[1] = ay * bw + aw * by; - out[2] = az * bw + ax * by; - out[3] = aw * bw - ay * by; +function multiply(out, a, b) { + out[0] = a[0] * b[0]; + out[1] = a[1] * b[1]; + out[2] = a[2] * b[2]; + out[3] = a[3] * b[3]; return out; } -function rotateZ(out, a, rad) { - rad *= 0.5; - var ax = a[0], ay = a[1], az = a[2], aw = a[3]; - var bz = Math.sin(rad), bw = Math.cos(rad); - out[0] = ax * bw + ay * bz; - out[1] = ay * bw - ax * bz; - out[2] = az * bw + aw * bz; - out[3] = aw * bw - az * bz; +function divide(out, a, b) { + out[0] = a[0] / b[0]; + out[1] = a[1] / b[1]; + out[2] = a[2] / b[2]; + out[3] = a[3] / b[3]; return out; } -function calculateW(out, a) { - var x = a[0], y = a[1], z = a[2]; - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); +function ceil(out, a) { + out[0] = Math.ceil(a[0]); + out[1] = Math.ceil(a[1]); + out[2] = Math.ceil(a[2]); + out[3] = Math.ceil(a[3]); return out; } -function exp(out, a) { - var x = a[0], y = a[1], z = a[2], w = a[3]; - var r = Math.sqrt(x * x + y * y + z * z); - var et = Math.exp(w); - var s = r > 0 ? et * Math.sin(r) / r : 0; - out[0] = x * s; - out[1] = y * s; - out[2] = z * s; - out[3] = et * Math.cos(r); +function floor(out, a) { + out[0] = Math.floor(a[0]); + out[1] = Math.floor(a[1]); + out[2] = Math.floor(a[2]); + out[3] = Math.floor(a[3]); return out; } -function ln(out, a) { - var x = a[0], y = a[1], z = a[2], w = a[3]; - var r = Math.sqrt(x * x + y * y + z * z); - var t = r > 0 ? Math.atan2(r, w) / r : 0; - out[0] = x * t; - out[1] = y * t; - out[2] = z * t; - out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w); +function min(out, a, b) { + out[0] = Math.min(a[0], b[0]); + out[1] = Math.min(a[1], b[1]); + out[2] = Math.min(a[2], b[2]); + out[3] = Math.min(a[3], b[3]); return out; } -function pow(out, a, b) { - ln(out, a); - scale(out, out, b); - exp(out, out); +function max(out, a, b) { + out[0] = Math.max(a[0], b[0]); + out[1] = Math.max(a[1], b[1]); + out[2] = Math.max(a[2], b[2]); + out[3] = Math.max(a[3], b[3]); return out; } -function slerp(out, a, b, t) { - // benchmarks: - // http://jsperf.com/quaternion-slerp-implementations - var ax = a[0], ay = a[1], az = a[2], aw = a[3]; - var bx = b[0], by = b[1], bz = b[2], bw = b[3]; - var omega, cosom, sinom, scale0, scale1; // calc cosine - cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary) - if (cosom < 0.0) { - cosom = -cosom; - bx = -bx; - by = -by; - bz = -bz; - bw = -bw; - } // calculate coefficients - if (1.0 - cosom > _commonJs.EPSILON) { - // standard case (slerp) - omega = Math.acos(cosom); - sinom = Math.sin(omega); - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t; - scale1 = t; - } // calculate final values - out[0] = scale0 * ax + scale1 * bx; - out[1] = scale0 * ay + scale1 * by; - out[2] = scale0 * az + scale1 * bz; - out[3] = scale0 * aw + scale1 * bw; +function round(out, a) { + out[0] = Math.round(a[0]); + out[1] = Math.round(a[1]); + out[2] = Math.round(a[2]); + out[3] = Math.round(a[3]); return out; } -function random(out) { - // Implementation of http://planning.cs.uiuc.edu/node198.html - // TODO: Calling random 3 times is probably not the fastest solution - var u1 = _commonJs.RANDOM(); - var u2 = _commonJs.RANDOM(); - var u3 = _commonJs.RANDOM(); - var sqrt1MinusU1 = Math.sqrt(1 - u1); - var sqrtU1 = Math.sqrt(u1); - out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2); - out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2); - out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3); - out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3); +function scale(out, a, b) { + out[0] = a[0] * b; + out[1] = a[1] * b; + out[2] = a[2] * b; + out[3] = a[3] * b; return out; } -function invert(out, a) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; - var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - out[0] = -a0 * invDot; - out[1] = -a1 * invDot; - out[2] = -a2 * invDot; - out[3] = a3 * invDot; +function scaleAndAdd(out, a, b, scale) { + out[0] = a[0] + b[0] * scale; + out[1] = a[1] + b[1] * scale; + out[2] = a[2] + b[2] * scale; + out[3] = a[3] + b[3] * scale; return out; } -function conjugate(out, a) { +function distance(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + var w = b[3] - a[3]; + return Math.hypot(x, y, z, w); +} +function squaredDistance(a, b) { + var x = b[0] - a[0]; + var y = b[1] - a[1]; + var z = b[2] - a[2]; + var w = b[3] - a[3]; + return x * x + y * y + z * z + w * w; +} +function length(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var w = a[3]; + return Math.hypot(x, y, z, w); +} +function squaredLength(a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var w = a[3]; + return x * x + y * y + z * z + w * w; +} +function negate(out, a) { out[0] = -a[0]; out[1] = -a[1]; out[2] = -a[2]; - out[3] = a[3]; + out[3] = -a[3]; return out; } -function fromMat3(out, m) { - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - var fTrace = m[0] + m[4] + m[8]; - var fRoot; - if (fTrace > 0.0) { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - out[3] = 0.5 * fRoot; - fRoot = 0.5 / fRoot; // 1/(4w) - out[0] = (m[5] - m[7]) * fRoot; - out[1] = (m[6] - m[2]) * fRoot; - out[2] = (m[1] - m[3]) * fRoot; - } else { - // |w| <= 1/2 - var i = 0; - if (m[4] > m[0]) i = 1; - if (m[8] > m[i * 3 + i]) i = 2; - var j = (i + 1) % 3; - var k = (i + 2) % 3; - fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0); - out[i] = 0.5 * fRoot; - fRoot = 0.5 / fRoot; - out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot; - out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; - out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; - } +function inverse(out, a) { + out[0] = 1.0 / a[0]; + out[1] = 1.0 / a[1]; + out[2] = 1.0 / a[2]; + out[3] = 1.0 / a[3]; return out; } -function fromEuler(out, x, y, z) { - var halfToRad = 0.5 * Math.PI / 180.0; - x *= halfToRad; - y *= halfToRad; - z *= halfToRad; - var sx = Math.sin(x); - var cx = Math.cos(x); - var sy = Math.sin(y); - var cy = Math.cos(y); - var sz = Math.sin(z); - var cz = Math.cos(z); - out[0] = sx * cy * cz - cx * sy * sz; - out[1] = cx * sy * cz + sx * cy * sz; - out[2] = cx * cy * sz - sx * sy * cz; - out[3] = cx * cy * cz + sx * sy * sz; +function normalize(out, a) { + var x = a[0]; + var y = a[1]; + var z = a[2]; + var w = a[3]; + var len = x * x + y * y + z * z + w * w; + if (len > 0) len = 1 / Math.sqrt(len); + out[0] = x * len; + out[1] = y * len; + out[2] = z * len; + out[3] = w * len; + return out; +} +function dot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; +} +function cross(out, u, v, w) { + var A = v[0] * w[1] - v[1] * w[0], B = v[0] * w[2] - v[2] * w[0], C = v[0] * w[3] - v[3] * w[0], D = v[1] * w[2] - v[2] * w[1], E = v[1] * w[3] - v[3] * w[1], F = v[2] * w[3] - v[3] * w[2]; + var G = u[0]; + var H = u[1]; + var I = u[2]; + var J = u[3]; + out[0] = H * F - I * E + J * D; + out[1] = -(G * F) + I * C - J * B; + out[2] = G * E - H * C + J * A; + out[3] = -(G * D) + H * B - I * A; + return out; +} +function lerp(out, a, b, t) { + var ax = a[0]; + var ay = a[1]; + var az = a[2]; + var aw = a[3]; + out[0] = ax + t * (b[0] - ax); + out[1] = ay + t * (b[1] - ay); + out[2] = az + t * (b[2] - az); + out[3] = aw + t * (b[3] - aw); + return out; +} +function random(out, scale) { + scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a + // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646. + // http://projecteuclid.org/euclid.aoms/1177692644; + var v1, v2, v3, v4; + var s1, s2; + do { + v1 = _commonJs.RANDOM() * 2 - 1; + v2 = _commonJs.RANDOM() * 2 - 1; + s1 = v1 * v1 + v2 * v2; + }while (s1 >= 1); + do { + v3 = _commonJs.RANDOM() * 2 - 1; + v4 = _commonJs.RANDOM() * 2 - 1; + s2 = v3 * v3 + v4 * v4; + }while (s2 >= 1); + var d = Math.sqrt((1 - s1) / s2); + out[0] = scale * v1; + out[1] = scale * v2; + out[2] = scale * v3 * d; + out[3] = scale * v4 * d; + return out; +} +function transformMat4(out, a, m) { + var x = a[0], y = a[1], z = a[2], w = a[3]; + out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + return out; +} +function transformQuat(out, a, q) { + var x = a[0], y = a[1], z = a[2]; + var qx = q[0], qy = q[1], qz = q[2], qw = q[3]; // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat + out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; + out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; + out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; + out[3] = a[3]; + return out; +} +function zero(out) { + out[0] = 0.0; + out[1] = 0.0; + out[2] = 0.0; + out[3] = 0.0; return out; } function str(a) { - return "quat(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; + return "vec4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; } -var clone = _vec4Js.clone; -var fromValues = _vec4Js.fromValues; -var copy = _vec4Js.copy; -var set = _vec4Js.set; -var add = _vec4Js.add; +function exactEquals(a, b) { + return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; +} +function equals(a, b) { + var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)); +} +var sub = subtract; var mul = multiply; -var scale = _vec4Js.scale; -var dot = _vec4Js.dot; -var lerp = _vec4Js.lerp; -var length = _vec4Js.length; +var div = divide; +var dist = distance; +var sqrDist = squaredDistance; var len = length; -var squaredLength = _vec4Js.squaredLength; var sqrLen = squaredLength; -var normalize = _vec4Js.normalize; -var exactEquals = _vec4Js.exactEquals; -var equals = _vec4Js.equals; -var rotationTo = function() { - var tmpvec3 = _vec3Js.create(); - var xUnitVec3 = _vec3Js.fromValues(1, 0, 0); - var yUnitVec3 = _vec3Js.fromValues(0, 1, 0); - return function(out, a, b) { - var dot = _vec3Js.dot(a, b); - if (dot < -0.999999) { - _vec3Js.cross(tmpvec3, xUnitVec3, a); - if (_vec3Js.len(tmpvec3) < 0.000001) _vec3Js.cross(tmpvec3, yUnitVec3, a); - _vec3Js.normalize(tmpvec3, tmpvec3); - setAxisAngle(out, tmpvec3, Math.PI); - return out; - } else if (dot > 0.999999) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - return out; - } else { - _vec3Js.cross(tmpvec3, a, b); - out[0] = tmpvec3[0]; - out[1] = tmpvec3[1]; - out[2] = tmpvec3[2]; - out[3] = 1 + dot; - return normalize(out, out); +var forEach = function() { + var vec = create(); + return function(a, stride, offset, count, fn, arg) { + var i, l; + if (!stride) stride = 4; + if (!offset) offset = 0; + if (count) l = Math.min(count * stride + offset, a.length); + else l = a.length; + for(i = offset; i < l; i += stride){ + vec[0] = a[i]; + vec[1] = a[i + 1]; + vec[2] = a[i + 2]; + vec[3] = a[i + 3]; + fn(vec, vec, arg); + a[i] = vec[0]; + a[i + 1] = vec[1]; + a[i + 2] = vec[2]; + a[i + 3] = vec[3]; } - }; -}(); -var sqlerp = function() { - var temp1 = create(); - var temp2 = create(); - return function(out, a, b, c, d, t) { - slerp(temp1, a, d, t); - slerp(temp2, b, c, t); - slerp(out, temp1, temp2, 2 * t * (1 - t)); - return out; - }; -}(); -var setAxes = function() { - var matr = _mat3Js.create(); - return function(out, view, right, up) { - matr[0] = right[0]; - matr[3] = right[1]; - matr[6] = right[2]; - matr[1] = up[0]; - matr[4] = up[1]; - matr[7] = up[2]; - matr[2] = -view[0]; - matr[5] = -view[1]; - matr[8] = -view[2]; - return normalize(out, fromMat3(out, matr)); + return a; }; }(); -},{"./common.js":"2bz5f","./mat3.js":"gHsXS","./vec3.js":"7D9HD","./vec4.js":"9RmVs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7D9HD":[function(require,module,exports) { +},{"./common.js":"7GML7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eovGI":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); /** - * 3 Dimensional Vector - * @module vec3 + * 2 Dimensional Vector + * @module vec2 */ /** - * Creates a new, empty vec3 + * Creates a new, empty vec2 * - * @returns {vec3} a new 3D vector + * @returns {vec2} a new 2D vector */ parcelHelpers.export(exports, "create", ()=>create); /** - * Creates a new vec3 initialized with values from an existing vector + * Creates a new vec2 initialized with values from an existing vector * - * @param {ReadonlyVec3} a vector to clone - * @returns {vec3} a new 3D vector + * @param {ReadonlyVec2} a vector to clone + * @returns {vec2} a new 2D vector */ parcelHelpers.export(exports, "clone", ()=>clone); /** - * Calculates the length of a vec3 - * - * @param {ReadonlyVec3} a vector to calculate length of - * @returns {Number} length of a - */ parcelHelpers.export(exports, "length", ()=>length); -/** - * Creates a new vec3 initialized with the given values + * Creates a new vec2 initialized with the given values * * @param {Number} x X component * @param {Number} y Y component - * @param {Number} z Z component - * @returns {vec3} a new 3D vector + * @returns {vec2} a new 2D vector */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); /** - * Copy the values from one vec3 to another + * Copy the values from one vec2 to another * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the source vector - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the source vector + * @returns {vec2} out */ parcelHelpers.export(exports, "copy", ()=>copy); /** - * Set the components of a vec3 to the given values + * Set the components of a vec2 to the given values * - * @param {vec3} out the receiving vector + * @param {vec2} out the receiving vector * @param {Number} x X component * @param {Number} y Y component - * @param {Number} z Z component - * @returns {vec3} out + * @returns {vec2} out */ parcelHelpers.export(exports, "set", ()=>set); /** - * Adds two vec3's + * Adds two vec2's * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out */ parcelHelpers.export(exports, "add", ()=>add); /** * Subtracts vector b from vector a * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out */ parcelHelpers.export(exports, "subtract", ()=>subtract); /** - * Multiplies two vec3's + * Multiplies two vec2's * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out */ parcelHelpers.export(exports, "multiply", ()=>multiply); /** - * Divides two vec3's + * Divides two vec2's * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out */ parcelHelpers.export(exports, "divide", ()=>divide); /** - * Math.ceil the components of a vec3 + * Math.ceil the components of a vec2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a vector to ceil - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to ceil + * @returns {vec2} out */ parcelHelpers.export(exports, "ceil", ()=>ceil); /** - * Math.floor the components of a vec3 + * Math.floor the components of a vec2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a vector to floor - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to floor + * @returns {vec2} out */ parcelHelpers.export(exports, "floor", ()=>floor); /** - * Returns the minimum of two vec3's + * Returns the minimum of two vec2's * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out */ parcelHelpers.export(exports, "min", ()=>min); /** - * Returns the maximum of two vec3's + * Returns the maximum of two vec2's * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand + * @returns {vec2} out */ parcelHelpers.export(exports, "max", ()=>max); /** - * Math.round the components of a vec3 + * Math.round the components of a vec2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a vector to round - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to round + * @returns {vec2} out */ parcelHelpers.export(exports, "round", ()=>round); /** - * Scales a vec3 by a scalar number + * Scales a vec2 by a scalar number * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the vector to scale + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to scale * @param {Number} b amount to scale the vector by - * @returns {vec3} out + * @returns {vec2} out */ parcelHelpers.export(exports, "scale", ()=>scale); /** - * Adds two vec3's after scaling the second operand by a scalar value + * Adds two vec2's after scaling the second operand by a scalar value * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand * @param {Number} scale the amount to scale b by before adding - * @returns {vec3} out + * @returns {vec2} out */ parcelHelpers.export(exports, "scaleAndAdd", ()=>scaleAndAdd); /** - * Calculates the euclidian distance between two vec3's + * Calculates the euclidian distance between two vec2's * - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand * @returns {Number} distance between a and b */ parcelHelpers.export(exports, "distance", ()=>distance); /** - * Calculates the squared euclidian distance between two vec3's + * Calculates the squared euclidian distance between two vec2's * - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand * @returns {Number} squared distance between a and b */ parcelHelpers.export(exports, "squaredDistance", ()=>squaredDistance); /** - * Calculates the squared length of a vec3 + * Calculates the length of a vec2 * - * @param {ReadonlyVec3} a vector to calculate squared length of + * @param {ReadonlyVec2} a vector to calculate length of + * @returns {Number} length of a + */ parcelHelpers.export(exports, "length", ()=>length); +/** + * Calculates the squared length of a vec2 + * + * @param {ReadonlyVec2} a vector to calculate squared length of * @returns {Number} squared length of a */ parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); /** - * Negates the components of a vec3 + * Negates the components of a vec2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a vector to negate - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to negate + * @returns {vec2} out */ parcelHelpers.export(exports, "negate", ()=>negate); /** - * Returns the inverse of the components of a vec3 + * Returns the inverse of the components of a vec2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a vector to invert - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to invert + * @returns {vec2} out */ parcelHelpers.export(exports, "inverse", ()=>inverse); /** - * Normalize a vec3 + * Normalize a vec2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a vector to normalize - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a vector to normalize + * @returns {vec2} out */ parcelHelpers.export(exports, "normalize", ()=>normalize); /** - * Calculates the dot product of two vec3's + * Calculates the dot product of two vec2's * - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand * @returns {Number} dot product of a and b */ parcelHelpers.export(exports, "dot", ()=>dot); /** - * Computes the cross product of two vec3's + * Computes the cross product of two vec2's + * Note that the cross product must by definition produce a 3D vector * * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand * @returns {vec3} out */ parcelHelpers.export(exports, "cross", ()=>cross); /** - * Performs a linear interpolation between two vec3's + * Performs a linear interpolation between two vec2's * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the first operand + * @param {ReadonlyVec2} b the second operand * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out + * @returns {vec2} out */ parcelHelpers.export(exports, "lerp", ()=>lerp); -/** - * Performs a hermite interpolation with two control points - * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @param {ReadonlyVec3} c the third operand - * @param {ReadonlyVec3} d the fourth operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out - */ parcelHelpers.export(exports, "hermite", ()=>hermite); -/** - * Performs a bezier interpolation with two control points - * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the first operand - * @param {ReadonlyVec3} b the second operand - * @param {ReadonlyVec3} c the third operand - * @param {ReadonlyVec3} d the fourth operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec3} out - */ parcelHelpers.export(exports, "bezier", ()=>bezier); /** * Generates a random vector with the given scale * - * @param {vec3} out the receiving vector + * @param {vec2} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec3} out + * @returns {vec2} out */ parcelHelpers.export(exports, "random", ()=>random); /** - * Transforms the vec3 with a mat4. - * 4th vector component is implicitly '1' + * Transforms the vec2 with a mat2 * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the vector to transform - * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec3} out - */ parcelHelpers.export(exports, "transformMat4", ()=>transformMat4); + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat2} m matrix to transform with + * @returns {vec2} out + */ parcelHelpers.export(exports, "transformMat2", ()=>transformMat2); /** - * Transforms the vec3 with a mat3. + * Transforms the vec2 with a mat2d * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the vector to transform - * @param {ReadonlyMat3} m the 3x3 matrix to transform with - * @returns {vec3} out - */ parcelHelpers.export(exports, "transformMat3", ()=>transformMat3); + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat2d} m matrix to transform with + * @returns {vec2} out + */ parcelHelpers.export(exports, "transformMat2d", ()=>transformMat2d); /** - * Transforms the vec3 with a quat - * Can also be used for dual quaternions. (Multiply it with the real part) + * Transforms the vec2 with a mat3 + * 3rd vector component is implicitly '1' * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec3} a the vector to transform - * @param {ReadonlyQuat} q quaternion to transform with - * @returns {vec3} out - */ parcelHelpers.export(exports, "transformQuat", ()=>transformQuat); -/** - * Rotate a 3D vector around the x-axis - * @param {vec3} out The receiving vec3 - * @param {ReadonlyVec3} a The vec3 point to rotate - * @param {ReadonlyVec3} b The origin of the rotation - * @param {Number} rad The angle of rotation in radians - * @returns {vec3} out - */ parcelHelpers.export(exports, "rotateX", ()=>rotateX); + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat3} m matrix to transform with + * @returns {vec2} out + */ parcelHelpers.export(exports, "transformMat3", ()=>transformMat3); /** - * Rotate a 3D vector around the y-axis - * @param {vec3} out The receiving vec3 - * @param {ReadonlyVec3} a The vec3 point to rotate - * @param {ReadonlyVec3} b The origin of the rotation - * @param {Number} rad The angle of rotation in radians - * @returns {vec3} out - */ parcelHelpers.export(exports, "rotateY", ()=>rotateY); + * Transforms the vec2 with a mat4 + * 3rd vector component is implicitly '0' + * 4th vector component is implicitly '1' + * + * @param {vec2} out the receiving vector + * @param {ReadonlyVec2} a the vector to transform + * @param {ReadonlyMat4} m matrix to transform with + * @returns {vec2} out + */ parcelHelpers.export(exports, "transformMat4", ()=>transformMat4); /** - * Rotate a 3D vector around the z-axis - * @param {vec3} out The receiving vec3 - * @param {ReadonlyVec3} a The vec3 point to rotate - * @param {ReadonlyVec3} b The origin of the rotation + * Rotate a 2D vector + * @param {vec2} out The receiving vec2 + * @param {ReadonlyVec2} a The vec2 point to rotate + * @param {ReadonlyVec2} b The origin of the rotation * @param {Number} rad The angle of rotation in radians - * @returns {vec3} out - */ parcelHelpers.export(exports, "rotateZ", ()=>rotateZ); + * @returns {vec2} out + */ parcelHelpers.export(exports, "rotate", ()=>rotate); /** - * Get the angle between two 3D vectors - * @param {ReadonlyVec3} a The first operand - * @param {ReadonlyVec3} b The second operand + * Get the angle between two 2D vectors + * @param {ReadonlyVec2} a The first operand + * @param {ReadonlyVec2} b The second operand * @returns {Number} The angle in radians */ parcelHelpers.export(exports, "angle", ()=>angle); /** - * Set the components of a vec3 to zero + * Set the components of a vec2 to zero * - * @param {vec3} out the receiving vector - * @returns {vec3} out + * @param {vec2} out the receiving vector + * @returns {vec2} out */ parcelHelpers.export(exports, "zero", ()=>zero); /** * Returns a string representation of a vector * - * @param {ReadonlyVec3} a vector to represent as a string + * @param {ReadonlyVec2} a vector to represent as a string * @returns {String} string representation of the vector */ parcelHelpers.export(exports, "str", ()=>str); /** - * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) * - * @param {ReadonlyVec3} a The first vector. - * @param {ReadonlyVec3} b The second vector. + * @param {ReadonlyVec2} a The first vector. + * @param {ReadonlyVec2} b The second vector. * @returns {Boolean} True if the vectors are equal, false otherwise. */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); /** * Returns whether or not the vectors have approximately the same elements in the same position. * - * @param {ReadonlyVec3} a The first vector. - * @param {ReadonlyVec3} b The second vector. + * @param {ReadonlyVec2} a The first vector. + * @param {ReadonlyVec2} b The second vector. * @returns {Boolean} True if the vectors are equal, false otherwise. */ parcelHelpers.export(exports, "equals", ()=>equals); +parcelHelpers.export(exports, "len", ()=>len); parcelHelpers.export(exports, "sub", ()=>sub); parcelHelpers.export(exports, "mul", ()=>mul); parcelHelpers.export(exports, "div", ()=>div); parcelHelpers.export(exports, "dist", ()=>dist); parcelHelpers.export(exports, "sqrDist", ()=>sqrDist); -parcelHelpers.export(exports, "len", ()=>len); parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); parcelHelpers.export(exports, "forEach", ()=>forEach); var _commonJs = require("./common.js"); function create() { - var out = new _commonJs.ARRAY_TYPE(3); + var out = new _commonJs.ARRAY_TYPE(2); if (_commonJs.ARRAY_TYPE != Float32Array) { out[0] = 0; out[1] = 0; - out[2] = 0; } return out; } function clone(a) { - var out = new _commonJs.ARRAY_TYPE(3); + var out = new _commonJs.ARRAY_TYPE(2); out[0] = a[0]; out[1] = a[1]; - out[2] = a[2]; return out; } -function length(a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - return Math.hypot(x, y, z); -} -function fromValues(x, y, z) { - var out = new _commonJs.ARRAY_TYPE(3); +function fromValues(x, y) { + var out = new _commonJs.ARRAY_TYPE(2); out[0] = x; out[1] = y; - out[2] = z; return out; } function copy(out, a) { out[0] = a[0]; out[1] = a[1]; - out[2] = a[2]; return out; } -function set(out, x, y, z) { +function set(out, x, y) { out[0] = x; out[1] = y; - out[2] = z; return out; } function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; return out; } function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; return out; } function multiply(out, a, b) { out[0] = a[0] * b[0]; out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; return out; } function divide(out, a, b) { out[0] = a[0] / b[0]; out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; return out; } function ceil(out, a) { out[0] = Math.ceil(a[0]); out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); return out; } function floor(out, a) { out[0] = Math.floor(a[0]); out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); return out; } function min(out, a, b) { out[0] = Math.min(a[0], b[0]); out[1] = Math.min(a[1], b[1]); - out[2] = Math.min(a[2], b[2]); return out; } function max(out, a, b) { out[0] = Math.max(a[0], b[0]); out[1] = Math.max(a[1], b[1]); - out[2] = Math.max(a[2], b[2]); return out; } function round(out, a) { out[0] = Math.round(a[0]); out[1] = Math.round(a[1]); - out[2] = Math.round(a[2]); return out; } function scale(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; - out[2] = a[2] * b; return out; } function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; out[1] = a[1] + b[1] * scale; - out[2] = a[2] + b[2] * scale; return out; } function distance(a, b) { - var x = b[0] - a[0]; - var y = b[1] - a[1]; - var z = b[2] - a[2]; - return Math.hypot(x, y, z); + var x = b[0] - a[0], y = b[1] - a[1]; + return Math.hypot(x, y); } function squaredDistance(a, b) { - var x = b[0] - a[0]; - var y = b[1] - a[1]; - var z = b[2] - a[2]; - return x * x + y * y + z * z; + var x = b[0] - a[0], y = b[1] - a[1]; + return x * x + y * y; +} +function length(a) { + var x = a[0], y = a[1]; + return Math.hypot(x, y); } function squaredLength(a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - return x * x + y * y + z * z; + var x = a[0], y = a[1]; + return x * x + y * y; } function negate(out, a) { out[0] = -a[0]; out[1] = -a[1]; - out[2] = -a[2]; return out; } function inverse(out, a) { out[0] = 1.0 / a[0]; out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; return out; } function normalize(out, a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - var len = x * x + y * y + z * z; + var x = a[0], y = a[1]; + var len = x * x + y * y; if (len > 0) //TODO: evaluate use of glm_invsqrt here? len = 1 / Math.sqrt(len); out[0] = a[0] * len; out[1] = a[1] * len; - out[2] = a[2] * len; return out; } function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + return a[0] * b[0] + a[1] * b[1]; } function cross(out, a, b) { - var ax = a[0], ay = a[1], az = a[2]; - var bx = b[0], by = b[1], bz = b[2]; - out[0] = ay * bz - az * by; - out[1] = az * bx - ax * bz; - out[2] = ax * by - ay * bx; + var z = a[0] * b[1] - a[1] * b[0]; + out[0] = out[1] = 0; + out[2] = z; return out; } function lerp(out, a, b, t) { - var ax = a[0]; - var ay = a[1]; - var az = a[2]; + var ax = a[0], ay = a[1]; out[0] = ax + t * (b[0] - ax); out[1] = ay + t * (b[1] - ay); - out[2] = az + t * (b[2] - az); - return out; -} -function hermite(out, a, b, c, d, t) { - var factorTimes2 = t * t; - var factor1 = factorTimes2 * (2 * t - 3) + 1; - var factor2 = factorTimes2 * (t - 2) + t; - var factor3 = factorTimes2 * (t - 1); - var factor4 = factorTimes2 * (3 - 2 * t); - out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; - out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; - out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; - return out; -} -function bezier(out, a, b, c, d, t) { - var inverseFactor = 1 - t; - var inverseFactorTimesTwo = inverseFactor * inverseFactor; - var factorTimes2 = t * t; - var factor1 = inverseFactorTimesTwo * inverseFactor; - var factor2 = 3 * t * inverseFactorTimesTwo; - var factor3 = 3 * factorTimes2 * inverseFactor; - var factor4 = factorTimes2 * t; - out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; - out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; - out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; return out; } function random(out, scale) { scale = scale || 1.0; var r = _commonJs.RANDOM() * 2.0 * Math.PI; - var z = _commonJs.RANDOM() * 2.0 - 1.0; - var zScale = Math.sqrt(1.0 - z * z) * scale; - out[0] = Math.cos(r) * zScale; - out[1] = Math.sin(r) * zScale; - out[2] = z * scale; - return out; -} -function transformMat4(out, a, m) { - var x = a[0], y = a[1], z = a[2]; - var w = m[3] * x + m[7] * y + m[11] * z + m[15]; - w = w || 1.0; - out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; - out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; - out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; + out[0] = Math.cos(r) * scale; + out[1] = Math.sin(r) * scale; return out; } -function transformMat3(out, a, m) { - var x = a[0], y = a[1], z = a[2]; - out[0] = x * m[0] + y * m[3] + z * m[6]; - out[1] = x * m[1] + y * m[4] + z * m[7]; - out[2] = x * m[2] + y * m[5] + z * m[8]; +function transformMat2(out, a, m) { + var x = a[0], y = a[1]; + out[0] = m[0] * x + m[2] * y; + out[1] = m[1] * x + m[3] * y; return out; } -function transformQuat(out, a, q) { - // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed - var qx = q[0], qy = q[1], qz = q[2], qw = q[3]; - var x = a[0], y = a[1], z = a[2]; // var qvec = [qx, qy, qz]; - // var uv = vec3.cross([], qvec, a); - var uvx = qy * z - qz * y, uvy = qz * x - qx * z, uvz = qx * y - qy * x; // var uuv = vec3.cross([], qvec, uv); - var uuvx = qy * uvz - qz * uvy, uuvy = qz * uvx - qx * uvz, uuvz = qx * uvy - qy * uvx; // vec3.scale(uv, uv, 2 * w); - var w2 = qw * 2; - uvx *= w2; - uvy *= w2; - uvz *= w2; // vec3.scale(uuv, uuv, 2); - uuvx *= 2; - uuvy *= 2; - uuvz *= 2; // return vec3.add(out, a, vec3.add(out, uv, uuv)); - out[0] = x + uvx + uuvx; - out[1] = y + uvy + uuvy; - out[2] = z + uvz + uuvz; +function transformMat2d(out, a, m) { + var x = a[0], y = a[1]; + out[0] = m[0] * x + m[2] * y + m[4]; + out[1] = m[1] * x + m[3] * y + m[5]; return out; } -function rotateX(out, a, b, rad) { - var p = [], r = []; //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; //perform rotation - r[0] = p[0]; - r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad); - r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad); //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; +function transformMat3(out, a, m) { + var x = a[0], y = a[1]; + out[0] = m[0] * x + m[3] * y + m[6]; + out[1] = m[1] * x + m[4] * y + m[7]; return out; } -function rotateY(out, a, b, rad) { - var p = [], r = []; //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; //perform rotation - r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad); - r[1] = p[1]; - r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad); //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; +function transformMat4(out, a, m) { + var x = a[0]; + var y = a[1]; + out[0] = m[0] * x + m[4] * y + m[12]; + out[1] = m[1] * x + m[5] * y + m[13]; return out; } -function rotateZ(out, a, b, rad) { - var p = [], r = []; //Translate point to the origin - p[0] = a[0] - b[0]; - p[1] = a[1] - b[1]; - p[2] = a[2] - b[2]; //perform rotation - r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad); - r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad); - r[2] = p[2]; //translate to correct position - out[0] = r[0] + b[0]; - out[1] = r[1] + b[1]; - out[2] = r[2] + b[2]; +function rotate(out, a, b, rad) { + //Translate point to the origin + var p0 = a[0] - b[0], p1 = a[1] - b[1], sinC = Math.sin(rad), cosC = Math.cos(rad); //perform rotation and translate to correct position + out[0] = p0 * cosC - p1 * sinC + b[0]; + out[1] = p0 * sinC + p1 * cosC + b[1]; return out; } function angle(a, b) { - var ax = a[0], ay = a[1], az = a[2], bx = b[0], by = b[1], bz = b[2], mag1 = Math.sqrt(ax * ax + ay * ay + az * az), mag2 = Math.sqrt(bx * bx + by * by + bz * bz), mag = mag1 * mag2, cosine = mag && dot(a, b) / mag; + var x1 = a[0], y1 = a[1], x2 = b[0], y2 = b[1], // mag is the product of the magnitudes of a and b + mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2), // mag &&.. short circuits if mag == 0 + cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1 return Math.acos(Math.min(Math.max(cosine, -1), 1)); } function zero(out) { out[0] = 0.0; out[1] = 0.0; - out[2] = 0.0; return out; } function str(a) { - return "vec3(" + a[0] + ", " + a[1] + ", " + a[2] + ")"; + return "vec2(" + a[0] + ", " + a[1] + ")"; } function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; + return a[0] === b[0] && a[1] === b[1]; } function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2]; - var b0 = b[0], b1 = b[1], b2 = b[2]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)); + var a0 = a[0], a1 = a[1]; + var b0 = b[0], b1 = b[1]; + return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)); } +var len = length; var sub = subtract; var mul = multiply; var div = divide; var dist = distance; var sqrDist = squaredDistance; -var len = length; var sqrLen = squaredLength; var forEach = function() { var vec = create(); return function(a, stride, offset, count, fn, arg) { var i, l; - if (!stride) stride = 3; + if (!stride) stride = 2; if (!offset) offset = 0; if (count) l = Math.min(count * stride + offset, a.length); else l = a.length; for(i = offset; i < l; i += stride){ vec[0] = a[i]; vec[1] = a[i + 1]; - vec[2] = a[i + 2]; fn(vec, vec, arg); a[i] = vec[0]; a[i + 1] = vec[1]; - a[i + 2] = vec[2]; } return a; }; }(); -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9RmVs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./common.js":"7GML7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gRqOf":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * 4 Dimensional Vector - * @module vec4 - */ /** - * Creates a new, empty vec4 - * - * @returns {vec4} a new 4D vector - */ parcelHelpers.export(exports, "create", ()=>create); -/** - * Creates a new vec4 initialized with values from an existing vector - * - * @param {ReadonlyVec4} a vector to clone - * @returns {vec4} a new 4D vector - */ parcelHelpers.export(exports, "clone", ()=>clone); -/** - * Creates a new vec4 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {vec4} a new 4D vector - */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); -/** - * Copy the values from one vec4 to another - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the source vector - * @returns {vec4} out - */ parcelHelpers.export(exports, "copy", ()=>copy); -/** - * Set the components of a vec4 to the given values - * - * @param {vec4} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @param {Number} z Z component - * @param {Number} w W component - * @returns {vec4} out - */ parcelHelpers.export(exports, "set", ()=>set); -/** - * Adds two vec4's - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out - */ parcelHelpers.export(exports, "add", ()=>add); -/** - * Subtracts vector b from vector a - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out - */ parcelHelpers.export(exports, "subtract", ()=>subtract); -/** - * Multiplies two vec4's - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out - */ parcelHelpers.export(exports, "multiply", ()=>multiply); -/** - * Divides two vec4's - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out - */ parcelHelpers.export(exports, "divide", ()=>divide); -/** - * Math.ceil the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a vector to ceil - * @returns {vec4} out - */ parcelHelpers.export(exports, "ceil", ()=>ceil); -/** - * Math.floor the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a vector to floor - * @returns {vec4} out - */ parcelHelpers.export(exports, "floor", ()=>floor); -/** - * Returns the minimum of two vec4's - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out - */ parcelHelpers.export(exports, "min", ()=>min); -/** - * Returns the maximum of two vec4's - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {vec4} out - */ parcelHelpers.export(exports, "max", ()=>max); -/** - * Math.round the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a vector to round - * @returns {vec4} out - */ parcelHelpers.export(exports, "round", ()=>round); -/** - * Scales a vec4 by a scalar number - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec4} out - */ parcelHelpers.export(exports, "scale", ()=>scale); -/** - * Adds two vec4's after scaling the second operand by a scalar value - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec4} out - */ parcelHelpers.export(exports, "scaleAndAdd", ()=>scaleAndAdd); -/** - * Calculates the euclidian distance between two vec4's - * - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {Number} distance between a and b - */ parcelHelpers.export(exports, "distance", ()=>distance); -/** - * Calculates the squared euclidian distance between two vec4's - * - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {Number} squared distance between a and b - */ parcelHelpers.export(exports, "squaredDistance", ()=>squaredDistance); -/** - * Calculates the length of a vec4 - * - * @param {ReadonlyVec4} a vector to calculate length of - * @returns {Number} length of a - */ parcelHelpers.export(exports, "length", ()=>length); -/** - * Calculates the squared length of a vec4 - * - * @param {ReadonlyVec4} a vector to calculate squared length of - * @returns {Number} squared length of a - */ parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); -/** - * Negates the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a vector to negate - * @returns {vec4} out - */ parcelHelpers.export(exports, "negate", ()=>negate); -/** - * Returns the inverse of the components of a vec4 - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a vector to invert - * @returns {vec4} out - */ parcelHelpers.export(exports, "inverse", ()=>inverse); -/** - * Normalize a vec4 - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a vector to normalize - * @returns {vec4} out - */ parcelHelpers.export(exports, "normalize", ()=>normalize); -/** - * Calculates the dot product of two vec4's - * - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @returns {Number} dot product of a and b - */ parcelHelpers.export(exports, "dot", ()=>dot); -/** - * Returns the cross-product of three vectors in a 4-dimensional space - * - * @param {ReadonlyVec4} result the receiving vector - * @param {ReadonlyVec4} U the first vector - * @param {ReadonlyVec4} V the second vector - * @param {ReadonlyVec4} W the third vector - * @returns {vec4} result - */ parcelHelpers.export(exports, "cross", ()=>cross); -/** - * Performs a linear interpolation between two vec4's - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the first operand - * @param {ReadonlyVec4} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec4} out - */ parcelHelpers.export(exports, "lerp", ()=>lerp); -/** - * Generates a random vector with the given scale - * - * @param {vec4} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec4} out - */ parcelHelpers.export(exports, "random", ()=>random); -/** - * Transforms the vec4 with a mat4. - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the vector to transform - * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec4} out - */ parcelHelpers.export(exports, "transformMat4", ()=>transformMat4); -/** - * Transforms the vec4 with a quat - * - * @param {vec4} out the receiving vector - * @param {ReadonlyVec4} a the vector to transform - * @param {ReadonlyQuat} q quaternion to transform with - * @returns {vec4} out - */ parcelHelpers.export(exports, "transformQuat", ()=>transformQuat); -/** - * Set the components of a vec4 to zero - * - * @param {vec4} out the receiving vector - * @returns {vec4} out - */ parcelHelpers.export(exports, "zero", ()=>zero); -/** - * Returns a string representation of a vector - * - * @param {ReadonlyVec4} a vector to represent as a string - * @returns {String} string representation of the vector - */ parcelHelpers.export(exports, "str", ()=>str); -/** - * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) - * - * @param {ReadonlyVec4} a The first vector. - * @param {ReadonlyVec4} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {ReadonlyVec4} a The first vector. - * @param {ReadonlyVec4} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ parcelHelpers.export(exports, "equals", ()=>equals); -parcelHelpers.export(exports, "sub", ()=>sub); -parcelHelpers.export(exports, "mul", ()=>mul); -parcelHelpers.export(exports, "div", ()=>div); -parcelHelpers.export(exports, "dist", ()=>dist); -parcelHelpers.export(exports, "sqrDist", ()=>sqrDist); -parcelHelpers.export(exports, "len", ()=>len); -parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); -parcelHelpers.export(exports, "forEach", ()=>forEach); -var _commonJs = require("./common.js"); -function create() { - var out = new _commonJs.ARRAY_TYPE(4); - if (_commonJs.ARRAY_TYPE != Float32Array) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; +parcelHelpers.export(exports, "AltAzimuthCameraView", ()=>AltAzimuthCameraView); +parcelHelpers.export(exports, "AltAzimuthCamera", ()=>AltAzimuthCamera); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _angleJs = require("../helpers/angle.js"); +var _mathJs = require("../helpers/math.js"); +var _cameraJs = require("./camera.js"); +class AltAzimuthCameraView extends (0, _cameraJs.CameraView) { + constructor(core){ + super(core); + this.fov = core.config.fov; + this.altitude = 0; + this.azimuth = 0; } - return out; -} -function clone(a) { - var out = new _commonJs.ARRAY_TYPE(4); - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; } -function fromValues(x, y, z, w) { - var out = new _commonJs.ARRAY_TYPE(4); - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; - return out; +class AltAzimuthCamera extends (0, _cameraJs.CameraBase) { + getView(view) { + super.getView(view); + view.altitude = this.altitude; + view.azimuth = this.azimuth; + view.fov = this._core.config.fov; + } + setView(view, isSmooth) { + super.setView(view, isSmooth); + this.setAltAzimuth(view.altitude, view.azimuth, isSmooth); + this._core.config.fov = view.fov; + } + lerpView(from, to, time) { + super.lerpView(from, to, time); + this.setAltAzimuth((0, _mathJs.MathHelper).lerp(from.altitude, to.altitude, time), (0, _mathJs.MathHelper).lerp(from.azimuth, to.azimuth, time), false); + this._core.config.fov = (0, _mathJs.MathHelper).lerp(from.fov, to.fov, time); + } + update(elapsedTime) { + super.update(elapsedTime); + if (this._core.config.isDebugVisible) { + const altitude = (0, _angleJs.AngleHelper).radiansToDegrees(this.altitude); + const azimuth = (0, _angleJs.AngleHelper).radiansToDegrees(this.azimuth); + this._core.debugText.addLine(`cam alt ${altitude < 0 ? "" : " "}${altitude.toFixed(1)}`); + this._core.debugText.addLine(`cam azi ${azimuth < 0 ? "" : " "}${azimuth.toFixed(1)}`); + } + } + get altitude() { + (0, _glMatrix.vec3).transformQuat(this._up, (0, _constantsJs.Constants).VECTOR3_UNITY, this._combinedRotation); + (0, _glMatrix.vec3).transformQuat(this._right, (0, _constantsJs.Constants).VECTOR3_UNITX, this._combinedRotation); + return -(0, _angleJs.AngleHelper).signedAngleBetweenVectors((0, _constantsJs.Constants).VECTOR3_UNITY, this._up, this._right); + } + get azimuth() { + (0, _glMatrix.vec3).transformQuat(this._up, (0, _constantsJs.Constants).VECTOR3_UNITY, this._combinedRotation); + (0, _glMatrix.vec3).transformQuat(this._right, (0, _constantsJs.Constants).VECTOR3_UNITX, this._combinedRotation); + return -(0, _angleJs.AngleHelper).signedAngleBetweenVectors((0, _constantsJs.Constants).VECTOR3_UNITX, this._right, this._up); + } + setAltAzimuth(altitude, azimuth, isSmooth) { + (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITX, altitude); + (0, _glMatrix.quat).multiply(this._orbitRotation, this._quat, (0, _constantsJs.Constants).QUAT_IDENTITY); + (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITY, azimuth); + (0, _glMatrix.quat).multiply(this._orbitRotation, this._orbitRotation, this._quat); + if (!isSmooth) this.syncSmooth(); + } + rotate(translationDelta) { + const length = Math.min(this.width, this.height); + let angle = translationDelta[1] * (0, _constantsJs.Constants).PI / length; + (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITX, angle); + (0, _glMatrix.quat).multiply(this._orbitRotation, this._quat, this._orbitRotation); + angle = translationDelta[0] * (0, _constantsJs.Constants).PI / length; + (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITY, angle); + (0, _glMatrix.quat).multiply(this._orbitRotation, this._orbitRotation, this._quat); + } } -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - return out; + +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/angle.js":"53hwW","../helpers/math.js":"f65d0","./camera.js":"h35rS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lD0bG":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Constants", ()=>Constants); +var _glMatrix = require("gl-matrix"); +class Constants { } -function set(out, x, y, z, w) { - out[0] = x; - out[1] = y; - out[2] = z; - out[3] = w; - return out; +Constants.TWO_PI = 6.283185307179586; +Constants.PI = 3.141592653589793; +Constants.PI_OVER_TWO = 1.5707963267948966; +Constants.PI_OVER_THREE = 1.0471975511965976; +Constants.PI_OVER_FOUR = 0.7853981633974483; +Constants.PI_OVER_SIX = 0.5235987755982988; +Constants.LOG_2 = 0.6931471805599453; +Constants.RADIANS_PER_DEGREE = 0.017453292519943295; +Constants.DEGREES_PER_RADIAN = 57.29577951308232; +Constants.ROOT_TWO = 1.4142135623730951; +Constants.ROOT_TWO_OVER_TWO = 0.7071067811865476; +Constants.ROOT_THREE = 1.7320508075688772; +Constants.ROOT_THREE_OVER_TWO = 0.8660254037844386; +Constants.ROOT_THREE_OVER_THREE = 0.5773502691896257; +Constants.VECTOR2_ZERO = (0, _glMatrix.vec2).fromValues(0, 0); +Constants.VECTOR2_ONE = (0, _glMatrix.vec2).fromValues(1, 1); +Constants.VECTOR2_UNITX = (0, _glMatrix.vec2).fromValues(1, 0); +Constants.VECTOR2_UNITY = (0, _glMatrix.vec2).fromValues(0, 1); +Constants.VECTOR3_ZERO = (0, _glMatrix.vec3).fromValues(0, 0, 0); +Constants.VECTOR3_ONE = (0, _glMatrix.vec3).fromValues(1, 1, 1); +Constants.VECTOR3_UNITX = (0, _glMatrix.vec3).fromValues(1, 0, 0); +Constants.VECTOR3_UNITY = (0, _glMatrix.vec3).fromValues(0, 1, 0); +Constants.VECTOR3_UNITZ = (0, _glMatrix.vec3).fromValues(0, 0, 1); +Constants.VECTOR3_REFLECTX = (0, _glMatrix.vec3).fromValues(1, -1, -1); +Constants.VECTOR3_REFLECTY = (0, _glMatrix.vec3).fromValues(-1, 1, -1); +Constants.VECTOR3_REFLECTZ = (0, _glMatrix.vec3).fromValues(-1, -1, 1); +Constants.VECTOR4_ZERO = (0, _glMatrix.vec4).fromValues(0, 0, 0, 0); +Constants.VECTOR4_ONE = (0, _glMatrix.vec4).fromValues(1, 1, 1, 1); +Constants.VECTOR4_UNITX = (0, _glMatrix.vec4).fromValues(1, 0, 0, 0); +Constants.VECTOR4_UNITY = (0, _glMatrix.vec4).fromValues(0, 1, 0, 0); +Constants.VECTOR4_UNITZ = (0, _glMatrix.vec4).fromValues(0, 0, 1, 0); +Constants.VECTOR4_UNITW = (0, _glMatrix.vec4).fromValues(0, 0, 0, 1); +Constants.MAT3_IDENTITY = (0, _glMatrix.mat3).create(); +Constants.MAT4_IDENTITY = (0, _glMatrix.mat4).create(); +Constants.MAT4_ROTATION_MINUS_90 = (0, _glMatrix.mat4).fromValues(0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); +Constants.QUAT_IDENTITY = (0, _glMatrix.quat).create(); +Constants.QUAT_ROTATEX_PLUS_90 = (0, _glMatrix.quat).fromValues(Constants.ROOT_TWO_OVER_TWO, 0, 0, Constants.ROOT_TWO_OVER_TWO); +Constants.QUAT_ROTATEX_MINUS_90 = (0, _glMatrix.quat).fromValues(-Constants.ROOT_TWO_OVER_TWO, 0, 0, Constants.ROOT_TWO_OVER_TWO); +Constants.QUAT_ROTATEY_PLUS_90 = (0, _glMatrix.quat).fromValues(0, Constants.ROOT_TWO_OVER_TWO, 0, Constants.ROOT_TWO_OVER_TWO); +Constants.QUAT_ROTATEY_MINUS_90 = (0, _glMatrix.quat).fromValues(0, -Constants.ROOT_TWO_OVER_TWO, 0, Constants.ROOT_TWO_OVER_TWO); +Constants.QUAT_ROTATEZ_PLUS_90 = (0, _glMatrix.quat).fromValues(0, 0, Constants.ROOT_TWO_OVER_TWO, Constants.ROOT_TWO_OVER_TWO); +Constants.QUAT_ROTATEZ_MINUS_90 = (0, _glMatrix.quat).fromValues(0, 0, -Constants.ROOT_TWO_OVER_TWO, Constants.ROOT_TWO_OVER_TWO); +Constants.MILLISECONDS_PER_DAY = 86400000; + +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"53hwW":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AngleHelper", ()=>AngleHelper); +var _glMatrix = require("gl-matrix"); +var _mathJs = require("./math.js"); +var _constantsJs = require("../constants.js"); +class AngleHelper { + static degreesToRadians(degrees) { + return degrees * (0, _constantsJs.Constants).RADIANS_PER_DEGREE; + } + static radiansToDegrees(radians) { + return radians * (0, _constantsJs.Constants).DEGREES_PER_RADIAN; + } + static wrapAngle(angle) { + if (angle > (0, _constantsJs.Constants).PI) angle = angle - (0, _constantsJs.Constants).TWO_PI; + else if (angle < -(0, _constantsJs.Constants).PI) angle += (0, _constantsJs.Constants).TWO_PI; + return angle; + } + static sphericalToCartesian(altitude, longitude, latitude, result) { + latitude = AngleHelper.degreesToRadians(latitude); + longitude = AngleHelper.degreesToRadians(longitude); + const scale = Math.cos(latitude); + result[0] = altitude * scale * Math.sin(longitude); + result[1] = altitude * Math.sin(latitude); + result[2] = altitude * scale * Math.cos(longitude); + } + static cartesianToSpherical(x, y, z, result) { + result[0] = Math.atan2(x, z); + result[1] = Math.asin(y); + } + static angleBetweenVectors(from, to) { + if ((0, _glMatrix.vec3).exactEquals(from, to)) return 0; + else { + const dot = (0, _mathJs.MathHelper).clamp((0, _glMatrix.vec3).dot(from, to), -1, 1); + return Math.acos(dot); + } + } + static signedAngleBetweenVectors(from, to, up) { + if ((0, _glMatrix.vec3).exactEquals(from, to)) return 0; + else { + const dot = (0, _mathJs.MathHelper).clamp((0, _glMatrix.vec3).dot(from, to), -1, 1); + let angle = Math.acos(dot); + (0, _glMatrix.vec3).cross(AngleHelper._vec3, from, to); + if ((0, _glMatrix.vec3).dot(AngleHelper._vec3, up) < 0) angle = -angle; + return angle; + } + } } -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - return out; +AngleHelper._vec3 = (0, _glMatrix.vec3).create(); + +},{"gl-matrix":"5x28d","./math.js":"f65d0","../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"f65d0":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "MathHelper", ()=>MathHelper); +parcelHelpers.export(exports, "PseudoRandom", ()=>PseudoRandom); +class MathHelper { + static simpleLinearRegression(points) { + const n = points.length; + let sumX = 0; + let sumY = 0; + let sumXY = 0; + let sumXX = 0; + for(let i = 0; i < n; i++){ + sumX += points[i].x; + sumY += points[i].y; + sumXY += points[i].x * points[i].y; + sumXX += points[i].x * points[i].x; + } + const slope = (n * sumXY - sumX * sumY) / (n * sumXX - sumX * sumX); + const yIntercept = (sumY - slope * sumX) / n; + return { + slope, + yIntercept + }; + } + static clamp(value, min, max) { + return Math.max(Math.min(value, max), min); + } + static lerp(value1, value2, amount) { + return value1 + (value2 - value1) * amount; + } + static normalize(value, min, max, from = 0, to = 1) { + return max - min == 0 ? 0 : Math.max(Math.min((to - from) * (value - min) / (max - min) + from, to), from); + } + static splitExponent(value, result) { + let exponent = Math.round(Math.log10(Math.abs(value))); + let coefficient = value / Math.pow(10, exponent); + if (coefficient < 1) { + coefficient *= 10; + exponent--; + } + result[0] = coefficient; + result[1] = exponent; + } + static combineExponent(mantissa, exponent) { + return mantissa * Math.pow(10, exponent); + } + static isPowerOf2(value) { + return (value & value - 1) == 0; + } } -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; - out[3] = a[3] - b[3]; - return out; -} -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - out[2] = a[2] * b[2]; - out[3] = a[3] * b[3]; - return out; -} -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - out[2] = a[2] / b[2]; - out[3] = a[3] / b[3]; - return out; -} -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - out[2] = Math.ceil(a[2]); - out[3] = Math.ceil(a[3]); - return out; -} -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - out[2] = Math.floor(a[2]); - out[3] = Math.floor(a[3]); - return out; -} -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - out[2] = Math.min(a[2], b[2]); - out[3] = Math.min(a[3], b[3]); - return out; -} -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - out[2] = Math.max(a[2], b[2]); - out[3] = Math.max(a[3], b[3]); - return out; -} -function round(out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - out[2] = Math.round(a[2]); - out[3] = Math.round(a[3]); - return out; -} -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - return out; -} -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + b[0] * scale; - out[1] = a[1] + b[1] * scale; - out[2] = a[2] + b[2] * scale; - out[3] = a[3] + b[3] * scale; - return out; -} -function distance(a, b) { - var x = b[0] - a[0]; - var y = b[1] - a[1]; - var z = b[2] - a[2]; - var w = b[3] - a[3]; - return Math.hypot(x, y, z, w); -} -function squaredDistance(a, b) { - var x = b[0] - a[0]; - var y = b[1] - a[1]; - var z = b[2] - a[2]; - var w = b[3] - a[3]; - return x * x + y * y + z * z + w * w; -} -function length(a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - var w = a[3]; - return Math.hypot(x, y, z, w); -} -function squaredLength(a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - var w = a[3]; - return x * x + y * y + z * z + w * w; -} -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = -a[3]; - return out; -} -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - out[2] = 1.0 / a[2]; - out[3] = 1.0 / a[3]; - return out; -} -function normalize(out, a) { - var x = a[0]; - var y = a[1]; - var z = a[2]; - var w = a[3]; - var len = x * x + y * y + z * z + w * w; - if (len > 0) len = 1 / Math.sqrt(len); - out[0] = x * len; - out[1] = y * len; - out[2] = z * len; - out[3] = w * len; - return out; -} -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; -} -function cross(out, u, v, w) { - var A = v[0] * w[1] - v[1] * w[0], B = v[0] * w[2] - v[2] * w[0], C = v[0] * w[3] - v[3] * w[0], D = v[1] * w[2] - v[2] * w[1], E = v[1] * w[3] - v[3] * w[1], F = v[2] * w[3] - v[3] * w[2]; - var G = u[0]; - var H = u[1]; - var I = u[2]; - var J = u[3]; - out[0] = H * F - I * E + J * D; - out[1] = -(G * F) + I * C - J * B; - out[2] = G * E - H * C + J * A; - out[3] = -(G * D) + H * B - I * A; - return out; -} -function lerp(out, a, b, t) { - var ax = a[0]; - var ay = a[1]; - var az = a[2]; - var aw = a[3]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - out[2] = az + t * (b[2] - az); - out[3] = aw + t * (b[3] - aw); - return out; -} -function random(out, scale) { - scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a - // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646. - // http://projecteuclid.org/euclid.aoms/1177692644; - var v1, v2, v3, v4; - var s1, s2; - do { - v1 = _commonJs.RANDOM() * 2 - 1; - v2 = _commonJs.RANDOM() * 2 - 1; - s1 = v1 * v1 + v2 * v2; - }while (s1 >= 1); - do { - v3 = _commonJs.RANDOM() * 2 - 1; - v4 = _commonJs.RANDOM() * 2 - 1; - s2 = v3 * v3 + v4 * v4; - }while (s2 >= 1); - var d = Math.sqrt((1 - s1) / s2); - out[0] = scale * v1; - out[1] = scale * v2; - out[2] = scale * v3 * d; - out[3] = scale * v4 * d; - return out; -} -function transformMat4(out, a, m) { - var x = a[0], y = a[1], z = a[2], w = a[3]; - out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - return out; -} -function transformQuat(out, a, q) { - var x = a[0], y = a[1], z = a[2]; - var qx = q[0], qy = q[1], qz = q[2], qw = q[3]; // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat - out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; - out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; - out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; - out[3] = a[3]; - return out; -} -function zero(out) { - out[0] = 0.0; - out[1] = 0.0; - out[2] = 0.0; - out[3] = 0.0; - return out; -} -function str(a) { - return "vec4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")"; -} -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3]; -} -function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)); +class PseudoRandom { + constructor(seed){ + this._seed = seed % 2147483647; + if (this._seed <= 0) this._seed += 2147483646; + } + next() { + return this._seed = this._seed * 16807 % 2147483647; + } + nextFloat() { + return (this.next() - 1) / 2147483646; + } + nextInteger(min, max) { + return Math.floor(this.nextFloat() * (max - min + 1) + min); + } } -var sub = subtract; -var mul = multiply; -var div = divide; -var dist = distance; -var sqrDist = squaredDistance; -var len = length; -var sqrLen = squaredLength; -var forEach = function() { - var vec = create(); - return function(a, stride, offset, count, fn, arg) { - var i, l; - if (!stride) stride = 4; - if (!offset) offset = 0; - if (count) l = Math.min(count * stride + offset, a.length); - else l = a.length; - for(i = offset; i < l; i += stride){ - vec[0] = a[i]; - vec[1] = a[i + 1]; - vec[2] = a[i + 2]; - vec[3] = a[i + 3]; - fn(vec, vec, arg); - a[i] = vec[0]; - a[i + 1] = vec[1]; - a[i + 2] = vec[2]; - a[i + 3] = vec[3]; - } - return a; - }; -}(); -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hDV5p":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h35rS":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Dual Quaternion<br> - * Format: [real, dual]<br> - * Quaternion format: XYZW<br> - * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.<br> - * @module quat2 - */ /** - * Creates a new identity dual quat - * - * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation] - */ parcelHelpers.export(exports, "create", ()=>create); -/** - * Creates a new quat initialized with values from an existing quaternion - * - * @param {ReadonlyQuat2} a dual quaternion to clone - * @returns {quat2} new dual quaternion - * @function - */ parcelHelpers.export(exports, "clone", ()=>clone); -/** - * Creates a new dual quat initialized with the given values - * - * @param {Number} x1 X component - * @param {Number} y1 Y component - * @param {Number} z1 Z component - * @param {Number} w1 W component - * @param {Number} x2 X component - * @param {Number} y2 Y component - * @param {Number} z2 Z component - * @param {Number} w2 W component - * @returns {quat2} new dual quaternion - * @function - */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); -/** - * Creates a new dual quat from the given values (quat and translation) - * - * @param {Number} x1 X component - * @param {Number} y1 Y component - * @param {Number} z1 Z component - * @param {Number} w1 W component - * @param {Number} x2 X component (translation) - * @param {Number} y2 Y component (translation) - * @param {Number} z2 Z component (translation) - * @returns {quat2} new dual quaternion - * @function - */ parcelHelpers.export(exports, "fromRotationTranslationValues", ()=>fromRotationTranslationValues); -/** - * Creates a dual quat from a quaternion and a translation - * - * @param {ReadonlyQuat2} dual quaternion receiving operation result - * @param {ReadonlyQuat} q a normalized quaternion - * @param {ReadonlyVec3} t tranlation vector - * @returns {quat2} dual quaternion receiving operation result - * @function - */ parcelHelpers.export(exports, "fromRotationTranslation", ()=>fromRotationTranslation); -/** - * Creates a dual quat from a translation - * - * @param {ReadonlyQuat2} dual quaternion receiving operation result - * @param {ReadonlyVec3} t translation vector - * @returns {quat2} dual quaternion receiving operation result - * @function - */ parcelHelpers.export(exports, "fromTranslation", ()=>fromTranslation); -/** - * Creates a dual quat from a quaternion - * - * @param {ReadonlyQuat2} dual quaternion receiving operation result - * @param {ReadonlyQuat} q the quaternion - * @returns {quat2} dual quaternion receiving operation result - * @function - */ parcelHelpers.export(exports, "fromRotation", ()=>fromRotation); -/** - * Creates a new dual quat from a matrix (4x4) - * - * @param {quat2} out the dual quaternion - * @param {ReadonlyMat4} a the matrix - * @returns {quat2} dual quat receiving operation result - * @function - */ parcelHelpers.export(exports, "fromMat4", ()=>fromMat4); -/** - * Copy the values from one dual quat to another - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the source dual quaternion - * @returns {quat2} out - * @function - */ parcelHelpers.export(exports, "copy", ()=>copy); -/** - * Set a dual quat to the identity dual quaternion - * - * @param {quat2} out the receiving quaternion - * @returns {quat2} out - */ parcelHelpers.export(exports, "identity", ()=>identity); -/** - * Set the components of a dual quat to the given values - * - * @param {quat2} out the receiving quaternion - * @param {Number} x1 X component - * @param {Number} y1 Y component - * @param {Number} z1 Z component - * @param {Number} w1 W component - * @param {Number} x2 X component - * @param {Number} y2 Y component - * @param {Number} z2 Z component - * @param {Number} w2 W component - * @returns {quat2} out - * @function - */ parcelHelpers.export(exports, "set", ()=>set); -parcelHelpers.export(exports, "getReal", ()=>getReal); -/** - * Gets the dual part of a dual quat - * @param {quat} out dual part - * @param {ReadonlyQuat2} a Dual Quaternion - * @return {quat} dual part - */ parcelHelpers.export(exports, "getDual", ()=>getDual); -parcelHelpers.export(exports, "setReal", ()=>setReal); -/** - * Set the dual component of a dual quat to the given quaternion - * - * @param {quat2} out the receiving quaternion - * @param {ReadonlyQuat} q a quaternion representing the dual part - * @returns {quat2} out - * @function - */ parcelHelpers.export(exports, "setDual", ()=>setDual); -/** - * Gets the translation of a normalized dual quat - * @param {vec3} out translation - * @param {ReadonlyQuat2} a Dual Quaternion to be decomposed - * @return {vec3} translation - */ parcelHelpers.export(exports, "getTranslation", ()=>getTranslation); -/** - * Translates a dual quat by the given vector - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the dual quaternion to translate - * @param {ReadonlyVec3} v vector to translate by - * @returns {quat2} out - */ parcelHelpers.export(exports, "translate", ()=>translate); -/** - * Rotates a dual quat around the X axis - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @param {number} rad how far should the rotation be - * @returns {quat2} out - */ parcelHelpers.export(exports, "rotateX", ()=>rotateX); -/** - * Rotates a dual quat around the Y axis - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @param {number} rad how far should the rotation be - * @returns {quat2} out - */ parcelHelpers.export(exports, "rotateY", ()=>rotateY); -/** - * Rotates a dual quat around the Z axis - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @param {number} rad how far should the rotation be - * @returns {quat2} out - */ parcelHelpers.export(exports, "rotateZ", ()=>rotateZ); -/** - * Rotates a dual quat by a given quaternion (a * q) - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @param {ReadonlyQuat} q quaternion to rotate by - * @returns {quat2} out - */ parcelHelpers.export(exports, "rotateByQuatAppend", ()=>rotateByQuatAppend); -/** - * Rotates a dual quat by a given quaternion (q * a) - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat} q quaternion to rotate by - * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @returns {quat2} out - */ parcelHelpers.export(exports, "rotateByQuatPrepend", ()=>rotateByQuatPrepend); -/** - * Rotates a dual quat around a given axis. Does the normalisation automatically - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the dual quaternion to rotate - * @param {ReadonlyVec3} axis the axis to rotate around - * @param {Number} rad how far the rotation should be - * @returns {quat2} out - */ parcelHelpers.export(exports, "rotateAroundAxis", ()=>rotateAroundAxis); -/** - * Adds two dual quat's - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the first operand - * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out - * @function - */ parcelHelpers.export(exports, "add", ()=>add); -/** - * Multiplies two dual quat's - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a the first operand - * @param {ReadonlyQuat2} b the second operand - * @returns {quat2} out - */ parcelHelpers.export(exports, "multiply", ()=>multiply); -parcelHelpers.export(exports, "mul", ()=>mul); -/** - * Scales a dual quat by a scalar number - * - * @param {quat2} out the receiving dual quat - * @param {ReadonlyQuat2} a the dual quat to scale - * @param {Number} b amount to scale the dual quat by - * @returns {quat2} out - * @function - */ parcelHelpers.export(exports, "scale", ()=>scale); -parcelHelpers.export(exports, "dot", ()=>dot); -/** - * Performs a linear interpolation between two dual quats's - * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5) - * - * @param {quat2} out the receiving dual quat - * @param {ReadonlyQuat2} a the first operand - * @param {ReadonlyQuat2} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {quat2} out - */ parcelHelpers.export(exports, "lerp", ()=>lerp); -/** - * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a dual quat to calculate inverse of - * @returns {quat2} out - */ parcelHelpers.export(exports, "invert", ()=>invert); -/** - * Calculates the conjugate of a dual quat - * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result. - * - * @param {quat2} out the receiving quaternion - * @param {ReadonlyQuat2} a quat to calculate conjugate of - * @returns {quat2} out - */ parcelHelpers.export(exports, "conjugate", ()=>conjugate); -parcelHelpers.export(exports, "length", ()=>length); -parcelHelpers.export(exports, "len", ()=>len); -parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); -parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); -/** - * Normalize a dual quat - * - * @param {quat2} out the receiving dual quaternion - * @param {ReadonlyQuat2} a dual quaternion to normalize - * @returns {quat2} out - * @function - */ parcelHelpers.export(exports, "normalize", ()=>normalize); -/** - * Returns a string representation of a dual quatenion - * - * @param {ReadonlyQuat2} a dual quaternion to represent as a string - * @returns {String} string representation of the dual quat - */ parcelHelpers.export(exports, "str", ()=>str); -/** - * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===) - * - * @param {ReadonlyQuat2} a the first dual quaternion. - * @param {ReadonlyQuat2} b the second dual quaternion. - * @returns {Boolean} true if the dual quaternions are equal, false otherwise. - */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); -/** - * Returns whether or not the dual quaternions have approximately the same elements in the same position. - * - * @param {ReadonlyQuat2} a the first dual quat. - * @param {ReadonlyQuat2} b the second dual quat. - * @returns {Boolean} true if the dual quats are equal, false otherwise. - */ parcelHelpers.export(exports, "equals", ()=>equals); -var _commonJs = require("./common.js"); -var _quatJs = require("./quat.js"); -var _mat4Js = require("./mat4.js"); -function create() { - var dq = new _commonJs.ARRAY_TYPE(8); - if (_commonJs.ARRAY_TYPE != Float32Array) { - dq[0] = 0; - dq[1] = 0; - dq[2] = 0; - dq[4] = 0; - dq[5] = 0; - dq[6] = 0; - dq[7] = 0; +parcelHelpers.export(exports, "CameraView", ()=>CameraView); +parcelHelpers.export(exports, "CameraBase", ()=>CameraBase); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +var _constantsJs = require("../constants.js"); +class CameraView { + constructor(core){ + this.position = (0, _glMatrix.vec3).create(); } - dq[3] = 1; - return dq; -} -function clone(a) { - var dq = new _commonJs.ARRAY_TYPE(8); - dq[0] = a[0]; - dq[1] = a[1]; - dq[2] = a[2]; - dq[3] = a[3]; - dq[4] = a[4]; - dq[5] = a[5]; - dq[6] = a[6]; - dq[7] = a[7]; - return dq; -} -function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) { - var dq = new _commonJs.ARRAY_TYPE(8); - dq[0] = x1; - dq[1] = y1; - dq[2] = z1; - dq[3] = w1; - dq[4] = x2; - dq[5] = y2; - dq[6] = z2; - dq[7] = w2; - return dq; -} -function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) { - var dq = new _commonJs.ARRAY_TYPE(8); - dq[0] = x1; - dq[1] = y1; - dq[2] = z1; - dq[3] = w1; - var ax = x2 * 0.5, ay = y2 * 0.5, az = z2 * 0.5; - dq[4] = ax * w1 + ay * z1 - az * y1; - dq[5] = ay * w1 + az * x1 - ax * z1; - dq[6] = az * w1 + ax * y1 - ay * x1; - dq[7] = -ax * x1 - ay * y1 - az * z1; - return dq; -} -function fromRotationTranslation(out, q, t) { - var ax = t[0] * 0.5, ay = t[1] * 0.5, az = t[2] * 0.5, bx = q[0], by = q[1], bz = q[2], bw = q[3]; - out[0] = bx; - out[1] = by; - out[2] = bz; - out[3] = bw; - out[4] = ax * bw + ay * bz - az * by; - out[5] = ay * bw + az * bx - ax * bz; - out[6] = az * bw + ax * by - ay * bx; - out[7] = -ax * bx - ay * by - az * bz; - return out; -} -function fromTranslation(out, t) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = t[0] * 0.5; - out[5] = t[1] * 0.5; - out[6] = t[2] * 0.5; - out[7] = 0; - return out; -} -function fromRotation(out, q) { - out[0] = q[0]; - out[1] = q[1]; - out[2] = q[2]; - out[3] = q[3]; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - return out; -} -function fromMat4(out, a) { - //TODO Optimize this - var outer = _quatJs.create(); - _mat4Js.getRotation(outer, a); - var t = new _commonJs.ARRAY_TYPE(3); - _mat4Js.getTranslation(t, a); - fromRotationTranslation(out, outer, t); - return out; -} -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - return out; -} -function identity(out) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 1; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - return out; -} -function set(out, x1, y1, z1, w1, x2, y2, z2, w2) { - out[0] = x1; - out[1] = y1; - out[2] = z1; - out[3] = w1; - out[4] = x2; - out[5] = y2; - out[6] = z2; - out[7] = w2; - return out; -} -var getReal = _quatJs.copy; -function getDual(out, a) { - out[0] = a[4]; - out[1] = a[5]; - out[2] = a[6]; - out[3] = a[7]; - return out; -} -var setReal = _quatJs.copy; -function setDual(out, q) { - out[4] = q[0]; - out[5] = q[1]; - out[6] = q[2]; - out[7] = q[3]; - return out; -} -function getTranslation(out, a) { - var ax = a[4], ay = a[5], az = a[6], aw = a[7], bx = -a[0], by = -a[1], bz = -a[2], bw = a[3]; - out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2; - out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2; - out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2; - return out; -} -function translate(out, a, v) { - var ax1 = a[0], ay1 = a[1], az1 = a[2], aw1 = a[3], bx1 = v[0] * 0.5, by1 = v[1] * 0.5, bz1 = v[2] * 0.5, ax2 = a[4], ay2 = a[5], az2 = a[6], aw2 = a[7]; - out[0] = ax1; - out[1] = ay1; - out[2] = az1; - out[3] = aw1; - out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2; - out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2; - out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2; - out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2; - return out; -} -function rotateX(out, a, rad) { - var bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], ax = a[4], ay = a[5], az = a[6], aw = a[7], ax1 = ax * bw + aw * bx + ay * bz - az * by, ay1 = ay * bw + aw * by + az * bx - ax * bz, az1 = az * bw + aw * bz + ax * by - ay * bx, aw1 = aw * bw - ax * bx - ay * by - az * bz; - _quatJs.rotateX(out, a, rad); - bx = out[0]; - by = out[1]; - bz = out[2]; - bw = out[3]; - out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - return out; -} -function rotateY(out, a, rad) { - var bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], ax = a[4], ay = a[5], az = a[6], aw = a[7], ax1 = ax * bw + aw * bx + ay * bz - az * by, ay1 = ay * bw + aw * by + az * bx - ax * bz, az1 = az * bw + aw * bz + ax * by - ay * bx, aw1 = aw * bw - ax * bx - ay * by - az * bz; - _quatJs.rotateY(out, a, rad); - bx = out[0]; - by = out[1]; - bz = out[2]; - bw = out[3]; - out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - return out; -} -function rotateZ(out, a, rad) { - var bx = -a[0], by = -a[1], bz = -a[2], bw = a[3], ax = a[4], ay = a[5], az = a[6], aw = a[7], ax1 = ax * bw + aw * bx + ay * bz - az * by, ay1 = ay * bw + aw * by + az * bx - ax * bz, az1 = az * bw + aw * bz + ax * by - ay * bx, aw1 = aw * bw - ax * bx - ay * by - az * bz; - _quatJs.rotateZ(out, a, rad); - bx = out[0]; - by = out[1]; - bz = out[2]; - bw = out[3]; - out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - return out; -} -function rotateByQuatAppend(out, a, q) { - var qx = q[0], qy = q[1], qz = q[2], qw = q[3], ax = a[0], ay = a[1], az = a[2], aw = a[3]; - out[0] = ax * qw + aw * qx + ay * qz - az * qy; - out[1] = ay * qw + aw * qy + az * qx - ax * qz; - out[2] = az * qw + aw * qz + ax * qy - ay * qx; - out[3] = aw * qw - ax * qx - ay * qy - az * qz; - ax = a[4]; - ay = a[5]; - az = a[6]; - aw = a[7]; - out[4] = ax * qw + aw * qx + ay * qz - az * qy; - out[5] = ay * qw + aw * qy + az * qx - ax * qz; - out[6] = az * qw + aw * qz + ax * qy - ay * qx; - out[7] = aw * qw - ax * qx - ay * qy - az * qz; - return out; -} -function rotateByQuatPrepend(out, q, a) { - var qx = q[0], qy = q[1], qz = q[2], qw = q[3], bx = a[0], by = a[1], bz = a[2], bw = a[3]; - out[0] = qx * bw + qw * bx + qy * bz - qz * by; - out[1] = qy * bw + qw * by + qz * bx - qx * bz; - out[2] = qz * bw + qw * bz + qx * by - qy * bx; - out[3] = qw * bw - qx * bx - qy * by - qz * bz; - bx = a[4]; - by = a[5]; - bz = a[6]; - bw = a[7]; - out[4] = qx * bw + qw * bx + qy * bz - qz * by; - out[5] = qy * bw + qw * by + qz * bx - qx * bz; - out[6] = qz * bw + qw * bz + qx * by - qy * bx; - out[7] = qw * bw - qx * bx - qy * by - qz * bz; - return out; -} -function rotateAroundAxis(out, a, axis, rad) { - //Special case for rad = 0 - if (Math.abs(rad) < _commonJs.EPSILON) return copy(out, a); - var axisLength = Math.hypot(axis[0], axis[1], axis[2]); - rad = rad * 0.5; - var s = Math.sin(rad); - var bx = s * axis[0] / axisLength; - var by = s * axis[1] / axisLength; - var bz = s * axis[2] / axisLength; - var bw = Math.cos(rad); - var ax1 = a[0], ay1 = a[1], az1 = a[2], aw1 = a[3]; - out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by; - out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz; - out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx; - out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz; - var ax = a[4], ay = a[5], az = a[6], aw = a[7]; - out[4] = ax * bw + aw * bx + ay * bz - az * by; - out[5] = ay * bw + aw * by + az * bx - ax * bz; - out[6] = az * bw + aw * bz + ax * by - ay * bx; - out[7] = aw * bw - ax * bx - ay * by - az * bz; - return out; -} -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - out[2] = a[2] + b[2]; - out[3] = a[3] + b[3]; - out[4] = a[4] + b[4]; - out[5] = a[5] + b[5]; - out[6] = a[6] + b[6]; - out[7] = a[7] + b[7]; - return out; -} -function multiply(out, a, b) { - var ax0 = a[0], ay0 = a[1], az0 = a[2], aw0 = a[3], bx1 = b[4], by1 = b[5], bz1 = b[6], bw1 = b[7], ax1 = a[4], ay1 = a[5], az1 = a[6], aw1 = a[7], bx0 = b[0], by0 = b[1], bz0 = b[2], bw0 = b[3]; - out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0; - out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0; - out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0; - out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0; - out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0; - out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0; - out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0; - out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0; - return out; -} -var mul = multiply; -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - out[2] = a[2] * b; - out[3] = a[3] * b; - out[4] = a[4] * b; - out[5] = a[5] * b; - out[6] = a[6] * b; - out[7] = a[7] * b; - return out; -} -var dot = _quatJs.dot; -function lerp(out, a, b, t) { - var mt = 1 - t; - if (dot(a, b) < 0) t = -t; - out[0] = a[0] * mt + b[0] * t; - out[1] = a[1] * mt + b[1] * t; - out[2] = a[2] * mt + b[2] * t; - out[3] = a[3] * mt + b[3] * t; - out[4] = a[4] * mt + b[4] * t; - out[5] = a[5] * mt + b[5] * t; - out[6] = a[6] * mt + b[6] * t; - out[7] = a[7] * mt + b[7] * t; - return out; -} -function invert(out, a) { - var sqlen = squaredLength(a); - out[0] = -a[0] / sqlen; - out[1] = -a[1] / sqlen; - out[2] = -a[2] / sqlen; - out[3] = a[3] / sqlen; - out[4] = -a[4] / sqlen; - out[5] = -a[5] / sqlen; - out[6] = -a[6] / sqlen; - out[7] = a[7] / sqlen; - return out; -} -function conjugate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - out[2] = -a[2]; - out[3] = a[3]; - out[4] = -a[4]; - out[5] = -a[5]; - out[6] = -a[6]; - out[7] = a[7]; - return out; } -var length = _quatJs.length; -var len = length; -var squaredLength = _quatJs.squaredLength; -var sqrLen = squaredLength; -function normalize(out, a) { - var magnitude = squaredLength(a); - if (magnitude > 0) { - magnitude = Math.sqrt(magnitude); - var a0 = a[0] / magnitude; - var a1 = a[1] / magnitude; - var a2 = a[2] / magnitude; - var a3 = a[3] / magnitude; - var b0 = a[4]; - var b1 = a[5]; - var b2 = a[6]; - var b3 = a[7]; - var a_dot_b = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3; - out[0] = a0; - out[1] = a1; - out[2] = a2; - out[3] = a3; - out[4] = (b0 - a0 * a_dot_b) / magnitude; - out[5] = (b1 - a1 * a_dot_b) / magnitude; - out[6] = (b2 - a2 * a_dot_b) / magnitude; - out[7] = (b3 - a3 * a_dot_b) / magnitude; +class CameraBase { + getView(view) { + this.getPosition(view.position); } - return out; -} -function str(a) { - return "quat2(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ")"; -} -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7]; -} -function equals(a, b) { - var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)); -} - -},{"./common.js":"2bz5f","./quat.js":"bBHpM","./mat4.js":"6PEOw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2fFbx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * 2 Dimensional Vector - * @module vec2 - */ /** - * Creates a new, empty vec2 - * - * @returns {vec2} a new 2D vector - */ parcelHelpers.export(exports, "create", ()=>create); -/** - * Creates a new vec2 initialized with values from an existing vector - * - * @param {ReadonlyVec2} a vector to clone - * @returns {vec2} a new 2D vector - */ parcelHelpers.export(exports, "clone", ()=>clone); -/** - * Creates a new vec2 initialized with the given values - * - * @param {Number} x X component - * @param {Number} y Y component - * @returns {vec2} a new 2D vector - */ parcelHelpers.export(exports, "fromValues", ()=>fromValues); -/** - * Copy the values from one vec2 to another - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the source vector - * @returns {vec2} out - */ parcelHelpers.export(exports, "copy", ()=>copy); -/** - * Set the components of a vec2 to the given values - * - * @param {vec2} out the receiving vector - * @param {Number} x X component - * @param {Number} y Y component - * @returns {vec2} out - */ parcelHelpers.export(exports, "set", ()=>set); -/** - * Adds two vec2's - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out - */ parcelHelpers.export(exports, "add", ()=>add); -/** - * Subtracts vector b from vector a - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out - */ parcelHelpers.export(exports, "subtract", ()=>subtract); -/** - * Multiplies two vec2's - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out - */ parcelHelpers.export(exports, "multiply", ()=>multiply); -/** - * Divides two vec2's - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out - */ parcelHelpers.export(exports, "divide", ()=>divide); -/** - * Math.ceil the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a vector to ceil - * @returns {vec2} out - */ parcelHelpers.export(exports, "ceil", ()=>ceil); -/** - * Math.floor the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a vector to floor - * @returns {vec2} out - */ parcelHelpers.export(exports, "floor", ()=>floor); -/** - * Returns the minimum of two vec2's - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out - */ parcelHelpers.export(exports, "min", ()=>min); -/** - * Returns the maximum of two vec2's - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec2} out - */ parcelHelpers.export(exports, "max", ()=>max); -/** - * Math.round the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a vector to round - * @returns {vec2} out - */ parcelHelpers.export(exports, "round", ()=>round); -/** - * Scales a vec2 by a scalar number - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the vector to scale - * @param {Number} b amount to scale the vector by - * @returns {vec2} out - */ parcelHelpers.export(exports, "scale", ()=>scale); -/** - * Adds two vec2's after scaling the second operand by a scalar value - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @param {Number} scale the amount to scale b by before adding - * @returns {vec2} out - */ parcelHelpers.export(exports, "scaleAndAdd", ()=>scaleAndAdd); -/** - * Calculates the euclidian distance between two vec2's - * - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {Number} distance between a and b - */ parcelHelpers.export(exports, "distance", ()=>distance); -/** - * Calculates the squared euclidian distance between two vec2's - * - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {Number} squared distance between a and b - */ parcelHelpers.export(exports, "squaredDistance", ()=>squaredDistance); -/** - * Calculates the length of a vec2 - * - * @param {ReadonlyVec2} a vector to calculate length of - * @returns {Number} length of a - */ parcelHelpers.export(exports, "length", ()=>length); -/** - * Calculates the squared length of a vec2 - * - * @param {ReadonlyVec2} a vector to calculate squared length of - * @returns {Number} squared length of a - */ parcelHelpers.export(exports, "squaredLength", ()=>squaredLength); -/** - * Negates the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a vector to negate - * @returns {vec2} out - */ parcelHelpers.export(exports, "negate", ()=>negate); -/** - * Returns the inverse of the components of a vec2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a vector to invert - * @returns {vec2} out - */ parcelHelpers.export(exports, "inverse", ()=>inverse); -/** - * Normalize a vec2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a vector to normalize - * @returns {vec2} out - */ parcelHelpers.export(exports, "normalize", ()=>normalize); -/** - * Calculates the dot product of two vec2's - * - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {Number} dot product of a and b - */ parcelHelpers.export(exports, "dot", ()=>dot); -/** - * Computes the cross product of two vec2's - * Note that the cross product must by definition produce a 3D vector - * - * @param {vec3} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @returns {vec3} out - */ parcelHelpers.export(exports, "cross", ()=>cross); -/** - * Performs a linear interpolation between two vec2's - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the first operand - * @param {ReadonlyVec2} b the second operand - * @param {Number} t interpolation amount, in the range [0-1], between the two inputs - * @returns {vec2} out - */ parcelHelpers.export(exports, "lerp", ()=>lerp); -/** - * Generates a random vector with the given scale - * - * @param {vec2} out the receiving vector - * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned - * @returns {vec2} out - */ parcelHelpers.export(exports, "random", ()=>random); -/** - * Transforms the vec2 with a mat2 - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the vector to transform - * @param {ReadonlyMat2} m matrix to transform with - * @returns {vec2} out - */ parcelHelpers.export(exports, "transformMat2", ()=>transformMat2); -/** - * Transforms the vec2 with a mat2d - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the vector to transform - * @param {ReadonlyMat2d} m matrix to transform with - * @returns {vec2} out - */ parcelHelpers.export(exports, "transformMat2d", ()=>transformMat2d); -/** - * Transforms the vec2 with a mat3 - * 3rd vector component is implicitly '1' - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the vector to transform - * @param {ReadonlyMat3} m matrix to transform with - * @returns {vec2} out - */ parcelHelpers.export(exports, "transformMat3", ()=>transformMat3); -/** - * Transforms the vec2 with a mat4 - * 3rd vector component is implicitly '0' - * 4th vector component is implicitly '1' - * - * @param {vec2} out the receiving vector - * @param {ReadonlyVec2} a the vector to transform - * @param {ReadonlyMat4} m matrix to transform with - * @returns {vec2} out - */ parcelHelpers.export(exports, "transformMat4", ()=>transformMat4); -/** - * Rotate a 2D vector - * @param {vec2} out The receiving vec2 - * @param {ReadonlyVec2} a The vec2 point to rotate - * @param {ReadonlyVec2} b The origin of the rotation - * @param {Number} rad The angle of rotation in radians - * @returns {vec2} out - */ parcelHelpers.export(exports, "rotate", ()=>rotate); -/** - * Get the angle between two 2D vectors - * @param {ReadonlyVec2} a The first operand - * @param {ReadonlyVec2} b The second operand - * @returns {Number} The angle in radians - */ parcelHelpers.export(exports, "angle", ()=>angle); -/** - * Set the components of a vec2 to zero - * - * @param {vec2} out the receiving vector - * @returns {vec2} out - */ parcelHelpers.export(exports, "zero", ()=>zero); -/** - * Returns a string representation of a vector - * - * @param {ReadonlyVec2} a vector to represent as a string - * @returns {String} string representation of the vector - */ parcelHelpers.export(exports, "str", ()=>str); -/** - * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) - * - * @param {ReadonlyVec2} a The first vector. - * @param {ReadonlyVec2} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ parcelHelpers.export(exports, "exactEquals", ()=>exactEquals); -/** - * Returns whether or not the vectors have approximately the same elements in the same position. - * - * @param {ReadonlyVec2} a The first vector. - * @param {ReadonlyVec2} b The second vector. - * @returns {Boolean} True if the vectors are equal, false otherwise. - */ parcelHelpers.export(exports, "equals", ()=>equals); -parcelHelpers.export(exports, "len", ()=>len); -parcelHelpers.export(exports, "sub", ()=>sub); -parcelHelpers.export(exports, "mul", ()=>mul); -parcelHelpers.export(exports, "div", ()=>div); -parcelHelpers.export(exports, "dist", ()=>dist); -parcelHelpers.export(exports, "sqrDist", ()=>sqrDist); -parcelHelpers.export(exports, "sqrLen", ()=>sqrLen); -parcelHelpers.export(exports, "forEach", ()=>forEach); -var _commonJs = require("./common.js"); -function create() { - var out = new _commonJs.ARRAY_TYPE(2); - if (_commonJs.ARRAY_TYPE != Float32Array) { - out[0] = 0; - out[1] = 0; - } - return out; -} -function clone(a) { - var out = new _commonJs.ARRAY_TYPE(2); - out[0] = a[0]; - out[1] = a[1]; - return out; -} -function fromValues(x, y) { - var out = new _commonJs.ARRAY_TYPE(2); - out[0] = x; - out[1] = y; - return out; -} -function copy(out, a) { - out[0] = a[0]; - out[1] = a[1]; - return out; -} -function set(out, x, y) { - out[0] = x; - out[1] = y; - return out; -} -function add(out, a, b) { - out[0] = a[0] + b[0]; - out[1] = a[1] + b[1]; - return out; -} -function subtract(out, a, b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - return out; -} -function multiply(out, a, b) { - out[0] = a[0] * b[0]; - out[1] = a[1] * b[1]; - return out; -} -function divide(out, a, b) { - out[0] = a[0] / b[0]; - out[1] = a[1] / b[1]; - return out; -} -function ceil(out, a) { - out[0] = Math.ceil(a[0]); - out[1] = Math.ceil(a[1]); - return out; -} -function floor(out, a) { - out[0] = Math.floor(a[0]); - out[1] = Math.floor(a[1]); - return out; -} -function min(out, a, b) { - out[0] = Math.min(a[0], b[0]); - out[1] = Math.min(a[1], b[1]); - return out; -} -function max(out, a, b) { - out[0] = Math.max(a[0], b[0]); - out[1] = Math.max(a[1], b[1]); - return out; -} -function round(out, a) { - out[0] = Math.round(a[0]); - out[1] = Math.round(a[1]); - return out; -} -function scale(out, a, b) { - out[0] = a[0] * b; - out[1] = a[1] * b; - return out; -} -function scaleAndAdd(out, a, b, scale) { - out[0] = a[0] + b[0] * scale; - out[1] = a[1] + b[1] * scale; - return out; -} -function distance(a, b) { - var x = b[0] - a[0], y = b[1] - a[1]; - return Math.hypot(x, y); -} -function squaredDistance(a, b) { - var x = b[0] - a[0], y = b[1] - a[1]; - return x * x + y * y; -} -function length(a) { - var x = a[0], y = a[1]; - return Math.hypot(x, y); -} -function squaredLength(a) { - var x = a[0], y = a[1]; - return x * x + y * y; -} -function negate(out, a) { - out[0] = -a[0]; - out[1] = -a[1]; - return out; -} -function inverse(out, a) { - out[0] = 1.0 / a[0]; - out[1] = 1.0 / a[1]; - return out; -} -function normalize(out, a) { - var x = a[0], y = a[1]; - var len = x * x + y * y; - if (len > 0) //TODO: evaluate use of glm_invsqrt here? - len = 1 / Math.sqrt(len); - out[0] = a[0] * len; - out[1] = a[1] * len; - return out; -} -function dot(a, b) { - return a[0] * b[0] + a[1] * b[1]; -} -function cross(out, a, b) { - var z = a[0] * b[1] - a[1] * b[0]; - out[0] = out[1] = 0; - out[2] = z; - return out; -} -function lerp(out, a, b, t) { - var ax = a[0], ay = a[1]; - out[0] = ax + t * (b[0] - ax); - out[1] = ay + t * (b[1] - ay); - return out; -} -function random(out, scale) { - scale = scale || 1.0; - var r = _commonJs.RANDOM() * 2.0 * Math.PI; - out[0] = Math.cos(r) * scale; - out[1] = Math.sin(r) * scale; - return out; -} -function transformMat2(out, a, m) { - var x = a[0], y = a[1]; - out[0] = m[0] * x + m[2] * y; - out[1] = m[1] * x + m[3] * y; - return out; -} -function transformMat2d(out, a, m) { - var x = a[0], y = a[1]; - out[0] = m[0] * x + m[2] * y + m[4]; - out[1] = m[1] * x + m[3] * y + m[5]; - return out; -} -function transformMat3(out, a, m) { - var x = a[0], y = a[1]; - out[0] = m[0] * x + m[3] * y + m[6]; - out[1] = m[1] * x + m[4] * y + m[7]; - return out; -} -function transformMat4(out, a, m) { - var x = a[0]; - var y = a[1]; - out[0] = m[0] * x + m[4] * y + m[12]; - out[1] = m[1] * x + m[5] * y + m[13]; - return out; -} -function rotate(out, a, b, rad) { - //Translate point to the origin - var p0 = a[0] - b[0], p1 = a[1] - b[1], sinC = Math.sin(rad), cosC = Math.cos(rad); //perform rotation and translate to correct position - out[0] = p0 * cosC - p1 * sinC + b[0]; - out[1] = p0 * sinC + p1 * cosC + b[1]; - return out; -} -function angle(a, b) { - var x1 = a[0], y1 = a[1], x2 = b[0], y2 = b[1], // mag is the product of the magnitudes of a and b - mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2), // mag &&.. short circuits if mag == 0 - cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1 - return Math.acos(Math.min(Math.max(cosine, -1), 1)); -} -function zero(out) { - out[0] = 0.0; - out[1] = 0.0; - return out; -} -function str(a) { - return "vec2(" + a[0] + ", " + a[1] + ")"; -} -function exactEquals(a, b) { - return a[0] === b[0] && a[1] === b[1]; -} -function equals(a, b) { - var a0 = a[0], a1 = a[1]; - var b0 = b[0], b1 = b[1]; - return Math.abs(a0 - b0) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _commonJs.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)); -} -var len = length; -var sub = subtract; -var mul = multiply; -var div = divide; -var dist = distance; -var sqrDist = squaredDistance; -var sqrLen = squaredLength; -var forEach = function() { - var vec = create(); - return function(a, stride, offset, count, fn, arg) { - var i, l; - if (!stride) stride = 2; - if (!offset) offset = 0; - if (count) l = Math.min(count * stride + offset, a.length); - else l = a.length; - for(i = offset; i < l; i += stride){ - vec[0] = a[i]; - vec[1] = a[i + 1]; - fn(vec, vec, arg); - a[i] = vec[0]; - a[i + 1] = vec[1]; - } - return a; - }; -}(); - -},{"./common.js":"2bz5f","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6C63a":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AltAzimuthCameraView", ()=>AltAzimuthCameraView); -parcelHelpers.export(exports, "AltAzimuthCamera", ()=>AltAzimuthCamera); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _angleJs = require("../helpers/angle.js"); -var _mathJs = require("../helpers/math.js"); -var _cameraJs = require("./camera.js"); -class AltAzimuthCameraView extends (0, _cameraJs.CameraView) { - constructor(core){ - super(core); - this.fov = core.config.fov; - this.altitude = 0; - this.azimuth = 0; - } -} -class AltAzimuthCamera extends (0, _cameraJs.CameraBase) { - getView(view) { - super.getView(view); - view.altitude = this.altitude; - view.azimuth = this.azimuth; - view.fov = this._core.config.fov; - } - setView(view, isSmooth) { - super.setView(view, isSmooth); - this.setAltAzimuth(view.altitude, view.azimuth, isSmooth); - this._core.config.fov = view.fov; - } - lerpView(from, to, time) { - super.lerpView(from, to, time); - this.setAltAzimuth((0, _mathJs.MathHelper).lerp(from.altitude, to.altitude, time), (0, _mathJs.MathHelper).lerp(from.azimuth, to.azimuth, time), false); - this._core.config.fov = (0, _mathJs.MathHelper).lerp(from.fov, to.fov, time); - } - update(elapsedTime) { - super.update(elapsedTime); - if (this._core.config.isDebugVisible) { - const altitude = (0, _angleJs.AngleHelper).radiansToDegrees(this.altitude); - const azimuth = (0, _angleJs.AngleHelper).radiansToDegrees(this.azimuth); - this._core.debugText.addLine(`cam alt ${altitude < 0 ? "" : " "}${altitude.toFixed(1)}`); - this._core.debugText.addLine(`cam azi ${azimuth < 0 ? "" : " "}${azimuth.toFixed(1)}`); - } - } - get altitude() { - (0, _glMatrix.vec3).transformQuat(this._up, (0, _constantsJs.Constants).VECTOR3_UNITY, this._combinedRotation); - (0, _glMatrix.vec3).transformQuat(this._right, (0, _constantsJs.Constants).VECTOR3_UNITX, this._combinedRotation); - return -(0, _angleJs.AngleHelper).signedAngleBetweenVectors((0, _constantsJs.Constants).VECTOR3_UNITY, this._up, this._right); - } - get azimuth() { - (0, _glMatrix.vec3).transformQuat(this._up, (0, _constantsJs.Constants).VECTOR3_UNITY, this._combinedRotation); - (0, _glMatrix.vec3).transformQuat(this._right, (0, _constantsJs.Constants).VECTOR3_UNITX, this._combinedRotation); - return -(0, _angleJs.AngleHelper).signedAngleBetweenVectors((0, _constantsJs.Constants).VECTOR3_UNITX, this._right, this._up); - } - setAltAzimuth(altitude, azimuth, isSmooth) { - (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITX, altitude); - (0, _glMatrix.quat).multiply(this._orbitRotation, this._quat, (0, _constantsJs.Constants).QUAT_IDENTITY); - (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITY, azimuth); - (0, _glMatrix.quat).multiply(this._orbitRotation, this._orbitRotation, this._quat); - if (!isSmooth) this.syncSmooth(); - } - rotate(translationDelta) { - const length = Math.min(this.width, this.height); - let angle = translationDelta[1] * (0, _constantsJs.Constants).PI / length; - (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITX, angle); - (0, _glMatrix.quat).multiply(this._orbitRotation, this._quat, this._orbitRotation); - angle = translationDelta[0] * (0, _constantsJs.Constants).PI / length; - (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITY, angle); - (0, _glMatrix.quat).multiply(this._orbitRotation, this._orbitRotation, this._quat); - } -} - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/angle.js":"eKtPm","../helpers/math.js":"fOnPF","./camera.js":"5VwCW","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2Scl5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Constants", ()=>Constants); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class Constants { -} -Constants.TWO_PI = 6.283185307179586; -Constants.PI = 3.141592653589793; -Constants.PI_OVER_TWO = 1.5707963267948966; -Constants.PI_OVER_THREE = 1.0471975511965976; -Constants.PI_OVER_FOUR = 0.7853981633974483; -Constants.PI_OVER_SIX = 0.5235987755982988; -Constants.LOG_2 = 0.6931471805599453; -Constants.RADIANS_PER_DEGREE = 0.017453292519943295; -Constants.DEGREES_PER_RADIAN = 57.29577951308232; -Constants.ROOT_TWO = 1.4142135623730951; -Constants.ROOT_TWO_OVER_TWO = 0.7071067811865476; -Constants.ROOT_THREE = 1.7320508075688772; -Constants.ROOT_THREE_OVER_TWO = 0.8660254037844386; -Constants.ROOT_THREE_OVER_THREE = 0.5773502691896257; -Constants.VECTOR2_ZERO = (0, _glMatrix.vec2).fromValues(0, 0); -Constants.VECTOR2_ONE = (0, _glMatrix.vec2).fromValues(1, 1); -Constants.VECTOR2_UNITX = (0, _glMatrix.vec2).fromValues(1, 0); -Constants.VECTOR2_UNITY = (0, _glMatrix.vec2).fromValues(0, 1); -Constants.VECTOR3_ZERO = (0, _glMatrix.vec3).fromValues(0, 0, 0); -Constants.VECTOR3_ONE = (0, _glMatrix.vec3).fromValues(1, 1, 1); -Constants.VECTOR3_UNITX = (0, _glMatrix.vec3).fromValues(1, 0, 0); -Constants.VECTOR3_UNITY = (0, _glMatrix.vec3).fromValues(0, 1, 0); -Constants.VECTOR3_UNITZ = (0, _glMatrix.vec3).fromValues(0, 0, 1); -Constants.VECTOR3_REFLECTX = (0, _glMatrix.vec3).fromValues(1, -1, -1); -Constants.VECTOR3_REFLECTY = (0, _glMatrix.vec3).fromValues(-1, 1, -1); -Constants.VECTOR3_REFLECTZ = (0, _glMatrix.vec3).fromValues(-1, -1, 1); -Constants.VECTOR4_ZERO = (0, _glMatrix.vec4).fromValues(0, 0, 0, 0); -Constants.VECTOR4_ONE = (0, _glMatrix.vec4).fromValues(1, 1, 1, 1); -Constants.VECTOR4_UNITX = (0, _glMatrix.vec4).fromValues(1, 0, 0, 0); -Constants.VECTOR4_UNITY = (0, _glMatrix.vec4).fromValues(0, 1, 0, 0); -Constants.VECTOR4_UNITZ = (0, _glMatrix.vec4).fromValues(0, 0, 1, 0); -Constants.VECTOR4_UNITW = (0, _glMatrix.vec4).fromValues(0, 0, 0, 1); -Constants.MAT3_IDENTITY = (0, _glMatrix.mat3).create(); -Constants.MAT4_IDENTITY = (0, _glMatrix.mat4).create(); -Constants.MAT4_ROTATION_MINUS_90 = (0, _glMatrix.mat4).fromValues(0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -Constants.QUAT_IDENTITY = (0, _glMatrix.quat).create(); -Constants.QUAT_ROTATEX_PLUS_90 = (0, _glMatrix.quat).fromValues(Constants.ROOT_TWO_OVER_TWO, 0, 0, Constants.ROOT_TWO_OVER_TWO); -Constants.QUAT_ROTATEX_MINUS_90 = (0, _glMatrix.quat).fromValues(-Constants.ROOT_TWO_OVER_TWO, 0, 0, Constants.ROOT_TWO_OVER_TWO); -Constants.QUAT_ROTATEY_PLUS_90 = (0, _glMatrix.quat).fromValues(0, Constants.ROOT_TWO_OVER_TWO, 0, Constants.ROOT_TWO_OVER_TWO); -Constants.QUAT_ROTATEY_MINUS_90 = (0, _glMatrix.quat).fromValues(0, -Constants.ROOT_TWO_OVER_TWO, 0, Constants.ROOT_TWO_OVER_TWO); -Constants.QUAT_ROTATEZ_PLUS_90 = (0, _glMatrix.quat).fromValues(0, 0, Constants.ROOT_TWO_OVER_TWO, Constants.ROOT_TWO_OVER_TWO); -Constants.QUAT_ROTATEZ_MINUS_90 = (0, _glMatrix.quat).fromValues(0, 0, -Constants.ROOT_TWO_OVER_TWO, Constants.ROOT_TWO_OVER_TWO); -Constants.MILLISECONDS_PER_DAY = 86400000; - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eKtPm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AngleHelper", ()=>AngleHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mathJs = require("./math.js"); -var _constantsJs = require("../constants.js"); -class AngleHelper { - static degreesToRadians(degrees) { - return degrees * (0, _constantsJs.Constants).RADIANS_PER_DEGREE; - } - static radiansToDegrees(radians) { - return radians * (0, _constantsJs.Constants).DEGREES_PER_RADIAN; - } - static wrapAngle(angle) { - if (angle > (0, _constantsJs.Constants).PI) angle = angle - (0, _constantsJs.Constants).TWO_PI; - else if (angle < -(0, _constantsJs.Constants).PI) angle += (0, _constantsJs.Constants).TWO_PI; - return angle; - } - static sphericalToCartesian(altitude, longitude, latitude, result) { - latitude = AngleHelper.degreesToRadians(latitude); - longitude = AngleHelper.degreesToRadians(longitude); - const scale = Math.cos(latitude); - result[0] = altitude * scale * Math.sin(longitude); - result[1] = altitude * Math.sin(latitude); - result[2] = altitude * scale * Math.cos(longitude); - } - static cartesianToSpherical(x, y, z, result) { - result[0] = Math.atan2(x, z); - result[1] = Math.asin(y); - } - static angleBetweenVectors(from, to) { - if ((0, _glMatrix.vec3).exactEquals(from, to)) return 0; - else { - const dot = (0, _mathJs.MathHelper).clamp((0, _glMatrix.vec3).dot(from, to), -1, 1); - return Math.acos(dot); - } - } - static signedAngleBetweenVectors(from, to, up) { - if ((0, _glMatrix.vec3).exactEquals(from, to)) return 0; - else { - const dot = (0, _mathJs.MathHelper).clamp((0, _glMatrix.vec3).dot(from, to), -1, 1); - let angle = Math.acos(dot); - (0, _glMatrix.vec3).cross(AngleHelper._vec3, from, to); - if ((0, _glMatrix.vec3).dot(AngleHelper._vec3, up) < 0) angle = -angle; - return angle; - } - } -} -AngleHelper._vec3 = (0, _glMatrix.vec3).create(); - -},{"gl-matrix":"9GjEQ","./math.js":"fOnPF","../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fOnPF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "MathHelper", ()=>MathHelper); -parcelHelpers.export(exports, "PseudoRandom", ()=>PseudoRandom); -class MathHelper { - static clamp(value, min, max) { - return Math.max(Math.min(value, max), min); - } - static lerp(value1, value2, amount) { - return value1 + (value2 - value1) * amount; - } - static normalize(value, min, max, from = 0, to = 1) { - return max - min == 0 ? 0 : Math.max(Math.min((to - from) * (value - min) / (max - min) + from, to), from); - } - static splitExponent(value, result) { - let exponent = Math.round(Math.log10(Math.abs(value))); - let coefficient = value / Math.pow(10, exponent); - if (coefficient < 1) { - coefficient *= 10; - exponent--; - } - result[0] = coefficient; - result[1] = exponent; - } - static combineExponent(mantissa, exponent) { - return mantissa * Math.pow(10, exponent); - } - static isPowerOf2(value) { - return (value & value - 1) == 0; - } -} -class PseudoRandom { - constructor(seed){ - this._seed = seed % 2147483647; - if (this._seed <= 0) this._seed += 2147483646; - } - next() { - return this._seed = this._seed * 16807 % 2147483647; - } - nextFloat() { - return (this.next() - 1) / 2147483646; - } - nextInteger(min, max) { - return Math.floor(this.nextFloat() * (max - min + 1) + min); - } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5VwCW":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "CameraView", ()=>CameraView); -parcelHelpers.export(exports, "CameraBase", ()=>CameraBase); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -var _constantsJs = require("../constants.js"); -class CameraView { - constructor(core){ - this.position = (0, _glMatrix.vec3).create(); - } -} -class CameraBase { - getView(view) { - this.getPosition(view.position); - } - setView(view, isSmooth) { - this.setPosition(view.position, isSmooth); + setView(view, isSmooth) { + this.setPosition(view.position, isSmooth); } lerpView(from, to, time) { (0, _glMatrix.vec3).lerp(this._vec3, from.position, to.position, time); @@ -14524,7 +13322,17 @@ class CameraBase { view[14] = -(0, _glMatrix.vec3).dot(this._forward, this._combinedPosition); const aspectRatio = this.width / this.height; if (this._core.config.stereoMode == (0, _mainJs.StereoMode).none) { - (0, _glMatrix.mat4).perspective(this.pMatrices[0], this._core.config.fov, aspectRatio, this._core.config.nearPlane, this._core.config.farPlane); + if (this._core.config.tilesX != 1 || this._core.config.tilesY != 1) { + const top = Math.tan(this._core.config.fov * 0.5) * this._core.config.nearPlane; + const bottom = -top; + const left = -aspectRatio * top; + const right = aspectRatio * top; + const width = right - left; + const height = top - bottom; + const tileWidth = width / this._core.config.tilesX; + const tileHeight = height / this._core.config.tilesY; + (0, _glMatrix.mat4).frustum(this._pMatrices[0], left + this._core.config.tileOffsetX * tileWidth, left + (this._core.config.tileOffsetX + 1) * tileWidth, bottom + (this._core.config.tilesY - this._core.config.tileOffsetY - 1) * tileHeight, bottom + (this._core.config.tilesY - this._core.config.tileOffsetY) * tileHeight, this._core.config.nearPlane, this._core.config.farPlane); + } else (0, _glMatrix.mat4).perspective(this.pMatrices[0], this._core.config.fov, aspectRatio, this._core.config.nearPlane, this._core.config.farPlane); (0, _glMatrix.mat4).multiply(this._mvMatrices[0], this._vMatrices[0], this.modelMMatrix); (0, _glMatrix.mat4).invert(this._inverseVMatrices[0], this.vMatrices[0]); (0, _glMatrix.mat4).invert(this._inversePMatrices[0], this.pMatrices[0]); @@ -14614,14 +13422,14 @@ class CameraBase { } } -},{"gl-matrix":"9GjEQ","../main.js":"1Kju3","../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jvVb3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Config", ()=>Config); +},{"gl-matrix":"5x28d","../main.js":"f421K","../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bCTP3":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Config", ()=>Config); +var _glMatrix = require("gl-matrix"); var _constantsJs = require("./constants.js"); var _mainJs = require("./main.js"); var _angleJs = require("./helpers/angle.js"); @@ -14675,7 +13483,7 @@ class Config { this.textColor = (0, _glMatrix.vec3).create(); this.textHoverColor = (0, _glMatrix.vec3).create(); this.textBorderColor = (0, _glMatrix.vec3).create(); - this.textBorderWidth = 0.1; + this.textBorderWidth = 0x18 / 0xff; this.identityRotation = (0, _constantsJs.Constants).VECTOR3_UNITY; this.axesTextLabelMaxGlyphs = 32; this.axesTextColor = (0, _glMatrix.vec3).create(); @@ -14687,6 +13495,9 @@ class Config { this.axesTextTitleSize = 0.05; this.axesTextHeadingMaxGlyphs = 128; this.axesTextHeadingSize = 0.075; + this.axesTextTitleLineHeight = 1.5; + this.axesTextHeadingLineHeight = 1.5; + this.axesTextLabelLineHeight = 1.5; this.axesGridMajorThickness = 0.0002; this.axesGridMinorThickness = 0.0001; this.axesGridZeroThickness = 0.002; @@ -14708,12 +13519,30 @@ class Config { this.lassoColor = (0, _glMatrix.vec3).create(); this.minCubifiedTreeMapSlice = 0.01; this.sdfBuffer = 0xc0; + this.sdfBorder = 0x0; + this.forceDirectIsEnabled = false; + this.forceDirectAttraction = 1; + this.forceDirectRepulsion = 1; + this.forceDirectGravity = 1; + this.forceDirectInterval = 0.1; + this.forceDirectMaxDistance = 0.1; + this.forceDirectTheta = 1; + this.forceDirectIterationsPerLayout = 1; + this.forceDirectEdgeWeightPower = 1; + this.forceDirectLockX = false; + this.forceDirectLockY = false; + this.forceDirectLockZ = false; this.transitionDuration = 400; this.transitionStaggering = 100; this.transitionView = true; this.isTransitionPickingEnabled = false; - this.backgroundColor = (0, _glMatrix.vec3).create(); + this.backgroundColor = (0, _glMatrix.vec4).create(); this.theme = (0, _mainJs.Theme).light; + this.renderMode = (0, _mainJs.RenderMode).color; + this.tilesX = 1; + this.tilesY = 1; + this.tileOffsetX = 0; + this.tileOffsetY = 0; } get theme() { return this._theme; @@ -14723,7 +13552,7 @@ class Config { this._theme = value; switch(value){ case (0, _mainJs.Theme).dark: - (0, _glMatrix.vec3).set(this.backgroundColor, 0, 0, 0); + (0, _glMatrix.vec4).set(this.backgroundColor, 0, 0, 0, 1); (0, _glMatrix.vec3).set(this.textColor, 0.9, 0.9, 0.9); (0, _glMatrix.vec3).set(this.textHoverColor, 1, 1, 1); (0, _glMatrix.vec3).set(this.textBorderColor, 0, 0, 0); @@ -14741,7 +13570,7 @@ class Config { (0, _glMatrix.vec3).set(this.lassoColor, 0.9, 0.9, 0.9); break; case (0, _mainJs.Theme).light: - (0, _glMatrix.vec3).set(this.backgroundColor, 1, 1, 1); + (0, _glMatrix.vec4).set(this.backgroundColor, 1, 1, 1, 1); (0, _glMatrix.vec3).set(this.textColor, 0, 0, 0); (0, _glMatrix.vec3).set(this.textHoverColor, 0.1, 0.1, 0.1); (0, _glMatrix.vec3).set(this.textBorderColor, 1, 1, 1); @@ -14764,13 +13593,13 @@ class Config { } } -},{"gl-matrix":"9GjEQ","./constants.js":"2Scl5","./main.js":"1Kju3","./helpers/angle.js":"eKtPm","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9N356":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"gl-matrix":"5x28d","./constants.js":"lD0bG","./main.js":"f421K","./helpers/angle.js":"53hwW","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eYPBQ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "DebugText", ()=>DebugText); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DebugText", ()=>DebugText); class DebugText { get text() { return this._text; @@ -14786,13 +13615,13 @@ class DebugText { } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kylSI":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9OHgw":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Fps", ()=>Fps); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Fps", ()=>Fps); class Fps { get frameCounter() { return this._frameCounter; @@ -14825,8 +13654,11 @@ class Fps { } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8zxgm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hZb65":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "PaletteType", ()=>PaletteType); parcelHelpers.export(exports, "PaletteName", ()=>PaletteName); @@ -16216,3156 +15048,1755 @@ class PaletteBase { class Palette extends PaletteBase { } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cQEMs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"f5tIG":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "MatrixHelper", ()=>MatrixHelper); -class MatrixHelper { - static fieldOfViewFromProjectionMatrix(p) { - return 2 * Math.atan(1 / p[5]); - } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7VqSF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cartesian3dAxesHelper", ()=>Cartesian3dAxesHelper); -parcelHelpers.export(exports, "Cartesian3dAxes", ()=>Cartesian3dAxes); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../../constants.js"); -var _mainJs = require("../../main.js"); -var _axesJs = require("./axes.js"); -var _quadJs = require("../../meshes/quad.js"); -var _cubeJs = require("../../meshes/cube.js"); -var _vertexJs = require("../../vertex.js"); -var _axesJs1 = require("../../helpers/axes.js"); -var _textJs = require("../../helpers/text.js"); -var _pickJs = require("../../helpers/pick.js"); -class Cartesian3dAxesHelper { - static create(core, options) { - const cartesian3dAxes = new Cartesian3dAxes(core); - const minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; - const minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; - const minBoundsZ = options.minBoundsZ === undefined ? 0 : options.minBoundsZ; - const maxBoundsX = options.maxBoundsX === undefined ? 1 : options.maxBoundsX; - const maxBoundsY = options.maxBoundsY === undefined ? 1 : options.maxBoundsY; - const maxBoundsZ = options.maxBoundsZ === undefined ? 1 : options.maxBoundsZ; - const minValueX = options.minValueX === undefined ? 0 : options.minValueX; - const minValueY = options.minValueY === undefined ? 0 : options.minValueY; - const minValueZ = options.minValueZ === undefined ? 0 : options.minValueZ; - const maxValueX = options.maxValueX === undefined ? 1 : options.maxValueX; - const maxValueY = options.maxValueY === undefined ? 1 : options.maxValueY; - const maxValueZ = options.maxValueZ === undefined ? 1 : options.maxValueZ; - const scaling = options.scaling === undefined ? 1 : options.scaling; - cartesian3dAxes.minBoundsX = minBoundsX; - cartesian3dAxes.minBoundsY = minBoundsY; - cartesian3dAxes.minBoundsZ = minBoundsZ; - cartesian3dAxes.maxBoundsX = maxBoundsX; - cartesian3dAxes.maxBoundsY = maxBoundsY; - cartesian3dAxes.maxBoundsZ = maxBoundsZ; - cartesian3dAxes.scalingX = scaling; - cartesian3dAxes.scalingY = scaling; - cartesian3dAxes.scalingZ = scaling; - const maxLength = Math.max(maxBoundsX - minBoundsX, Math.max(maxBoundsY - minBoundsY, maxBoundsZ - minBoundsZ)); - const requestedDivisions = [ - options.divisionsX == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsX - minBoundsX) / maxLength), 1) : options.divisionsX, - options.divisionsY == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsY - minBoundsY) / maxLength), 1) : options.divisionsY, - options.divisionsZ == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsZ - minBoundsZ) / maxLength), 1) : options.divisionsZ, - ]; - const minorGridlines = [ - options.minorGridlinesX == undefined ? 2 : options.minorGridlinesX, - options.minorGridlinesY == undefined ? 2 : options.minorGridlinesY, - options.minorGridlinesZ == undefined ? 2 : options.minorGridlinesZ - ]; - const labelMajorSizes = [ - options.labelMajorSizeX === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeX, - options.labelMajorSizeY === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeY, - options.labelMajorSizeZ === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeZ - ]; - const labelMinorSizes = [ - options.labelMinorSizeX === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeX, - options.labelMinorSizeY === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeY, - options.labelMinorSizeZ === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeZ - ]; - cartesian3dAxes.isDiscreteX = options.isDiscreteX; - cartesian3dAxes.isDiscreteY = options.isDiscreteY; - cartesian3dAxes.isDiscreteZ = options.isDiscreteZ; - cartesian3dAxes.isGridPickingEnabled = options.isGridPickingEnabled; - const isDivisionPickingEnabledArray = [ - options.isDivisionPickingEnabledX, - options.isDivisionPickingEnabledY, - options.isDivisionPickingEnabledZ, - ]; - const isLabelPickingEnabledArray = [ - options.isLabelPickingEnabledX, - options.isLabelPickingEnabledY, - options.isLabelPickingEnabledZ, - ]; - const isAxisReversed = [ - options.reverseX, - options.reverseY, - options.reverseZ - ]; - const labelsArray = [ - options.labelsX, - options.labelsY, - options.labelsZ - ]; - const labelOrientationsArray = [ - options.labelOrientationX, - options.labelOrientationY, - options.labelOrientationZ - ]; - const labelOrientationDefaultArray = [ - (0, _mainJs.AxesTextOrientation).parallel, - (0, _mainJs.AxesTextOrientation).perpendicular, - (0, _mainJs.AxesTextOrientation).parallel - ]; - const areTicksVisibleArray = [ - options.arePickDivisionsVisibleX, - options.arePickDivisionsVisibleY, - options.arePickDivisionsVisibleZ - ]; - const minValueArray = [ - minValueX, - minValueY, - minValueZ - ]; - const maxValueArray = [ - maxValueX, - maxValueY, - maxValueZ - ]; - const isDiscreteArray = [ - options.isDiscreteX, - options.isDiscreteY, - options.isDiscreteZ - ]; - const titleArray = [ - options.titleX, - options.titleY, - options.titleZ - ]; - const titleSizeArray = [ - options.titleSizeX, - options.titleSizeY, - options.titleSizeZ - ]; - const headingArray = [ - options.headingX, - options.headingY, - options.headingZ - ]; - const headingSizeArray = [ - options.headingSizeX, - options.headingSizeY, - options.headingSizeZ - ]; - for(let axisId = 0; axisId < 3; axisId++){ - const label = labelsArray[axisId]; - const minValue = minValueArray[axisId]; - const maxValue = maxValueArray[axisId]; - const discrete = isDiscreteArray[axisId]; - if (discrete) { - const divisions = maxValue - minValue + 1; - const maxDivisions = Math.min(requestedDivisions[axisId], divisions); - const discreteAxisOptions = { - min: minValue, - max: maxValue, - divisions: divisions, - maxDivisions: maxDivisions, - label: label - }; - const discreteAxis = (0, _axesJs1.AxisHelper).discrete(discreteAxisOptions); - cartesian3dAxes.setTickPositions(axisId, discreteAxis.tickPositions); - cartesian3dAxes.setLabelPositions(axisId, discreteAxis.labelPositions); - cartesian3dAxes.setLabels(axisId, discreteAxis.labels); - cartesian3dAxes.setFromValues(axisId, discreteAxis.fromValues); - cartesian3dAxes.setToValues(axisId, discreteAxis.toValues); - cartesian3dAxes.setLabelSizes(axisId, Array(discreteAxis.labels.length).fill(labelMajorSizes[axisId])); - cartesian3dAxes.minorGridlines[axisId] = 1; - } else { - const divisions1 = requestedDivisions[axisId]; - const continuousAxisOptions = { - min: minValue, - max: maxValue, - divisions: divisions1, - label: label - }; - const continuousAxis = (0, _axesJs1.AxisHelper).continuous(continuousAxisOptions); - cartesian3dAxes.setTickPositions(axisId, continuousAxis.positions); - cartesian3dAxes.setLabelPositions(axisId, continuousAxis.positions); - cartesian3dAxes.setLabels(axisId, continuousAxis.labels); - cartesian3dAxes.setFromValues(axisId, continuousAxis.fromValues); - cartesian3dAxes.setToValues(axisId, continuousAxis.toValues); - const labelSizes = []; - for(let i = 0; i < continuousAxis.labels.length; i++)labelSizes.push(i == 0 || i == divisions1 ? labelMajorSizes[axisId] : labelMinorSizes[axisId]); - cartesian3dAxes.setLabelSizes(axisId, labelSizes); - cartesian3dAxes.minorGridlines[axisId] = minorGridlines[axisId]; - } - cartesian3dAxes.setLabelOrientation(axisId, labelOrientationsArray[axisId] === undefined ? labelOrientationDefaultArray[axisId] : labelOrientationsArray[axisId]); - cartesian3dAxes.setTitle(axisId, titleArray[axisId]); - cartesian3dAxes.setTitleSize(axisId, titleSizeArray[axisId] === undefined ? core.config.axesTextTitleSize : titleSizeArray[axisId]); - cartesian3dAxes.setHeading(axisId, headingArray[axisId]); - cartesian3dAxes.setHeadingSize(axisId, headingSizeArray[axisId] === undefined ? core.config.axesTextHeadingSize : headingSizeArray[axisId]); - cartesian3dAxes.arePickDivisionsVisible[axisId] = areTicksVisibleArray[axisId] === undefined ? true : areTicksVisibleArray[axisId]; - cartesian3dAxes.isDivisionPickingEnabled[axisId] = isDivisionPickingEnabledArray[axisId]; - cartesian3dAxes.isLabelPickingEnabled[axisId] = isLabelPickingEnabledArray[axisId]; - cartesian3dAxes.isAxisReversed[axisId] = isAxisReversed[axisId]; - if (minValue <= 0 && maxValue >= 0) cartesian3dAxes.zero[axisId] = -minValue / (maxValue - minValue); - else cartesian3dAxes.zero[axisId] = -Number.MAX_VALUE; - } - return cartesian3dAxes; +parcelHelpers.export(exports, "ControllerVisual", ()=>ControllerVisual); +parcelHelpers.export(exports, "Controller", ()=>Controller); +var _mainJs = require("../main.js"); +var _objJs = require("../helpers/obj.js"); +var _glMatrix = require("gl-matrix"); +var _cubeJs = require("../meshes/cube.js"); +var _vertexJs = require("../vertex.js"); +class ControllerVisual { + render(elapsedTime, xrFrame) {} + update(elapsedTime) {} + constructor(controller){ + this.controller = controller; } } -class Cartesian3dAxes extends (0, _axesJs.AxesBase) { - get size() { - return this._size; +class Controller { + get isInitialized() { + return this._isInitialized; } - get isDiscreteX() { - return this._isDiscrete[0]; + get mMatrix() { + return this._mMatrix; } - set isDiscreteX(value) { - if (value != this._isDiscrete[0]) { - this._isDiscrete[0] = value; - this._hasChanged = true; - } + get indexCount() { + return this._indexCount; } - get isDiscreteY() { - return this._isDiscrete[1]; + get vertices() { + return this._vertices; } - set isDiscreteY(value) { - if (value != this._isDiscrete[1]) { - this._isDiscrete[1] = value; - this._hasChanged = true; - } + get indices() { + return this._indices; } - get isDiscreteZ() { - return this._isDiscrete[2]; + get texture() { + return this._texture; } - set isDiscreteZ(value) { - if (value != this._isDiscrete[2]) { - this._isDiscrete[2] = value; - this._hasChanged = true; - } + get rayMMatrix() { + return this._rayMMatrix; } - get minBoundsX() { - return this._minBoundsX; + get rayIndexCount() { + return this._rayIndexCount; } - set minBoundsX(value) { - if (value != this._minBoundsX) { - this._minBoundsX = value; - this._hasChanged = true; - } + get rayVertices() { + return this._rayVertices; } - get maxBoundsX() { - return this._maxBoundsX; + get rayIndices() { + return this._rayIndices; } - set maxBoundsX(value) { - if (value != this._minBoundsX) { - this._maxBoundsX = value; - this._hasChanged = true; - } - } - get minBoundsY() { - return this._minBoundsY; + constructor(core, options){ + this._cubeObj = `o Cube +v 1.000000 -1.000000 -1.000000 +v 1.000000 -1.000000 1.000000 +v -1.000000 -1.000000 1.000000 +v -1.000000 -1.000000 -1.000000 +v 1.000000 1.000000 -0.999999 +v 0.999999 1.000000 1.000001 +v -1.000000 1.000000 1.000000 +v -1.000000 1.000000 -1.000000 +vt 1.000000 0.333333 +vt 1.000000 0.666667 +vt 0.666667 0.666667 +vt 0.666667 0.333333 +vt 0.666667 0.000000 +vt 0.000000 0.333333 +vt 0.000000 0.000000 +vt 0.333333 0.000000 +vt 0.333333 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.666667 +vt 0.333333 0.333333 +vt 0.333333 0.666667 +vt 1.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn 1.000000 0.000000 0.000000 +vn -0.000000 0.000000 1.000000 +vn -1.000000 -0.000000 -0.000000 +vn 0.000000 0.000000 -1.000000 +s off +f 2/1/1 3/2/1 4/3/1 +f 8/1/2 7/4/2 6/5/2 +f 5/6/3 6/7/3 2/8/3 +f 6/8/4 7/5/4 3/4/4 +f 3/9/5 7/10/5 8/11/5 +f 1/12/6 4/13/6 8/11/6 +f 1/4/1 2/1/1 4/3/1 +f 5/14/2 8/1/2 6/5/2 +f 1/12/3 5/6/3 2/8/3 +f 2/12/4 6/8/4 3/4/4 +f 4/13/5 3/9/5 8/11/5 +f 5/6/6 1/12/6 8/11/6`; + this._core = core; + this._obj = options.obj; + this._texture = options.texture || new ImageData(new Uint8ClampedArray([ + 0, + 0, + 0, + 255 + ]), 1, 1); } - set minBoundsY(value) { - if (value != this._minBoundsY) { - this._minBoundsY = value; - this._hasChanged = true; + initialize() { + const _vec3 = (0, _glMatrix.vec3).create(); + this._mMatrix = (0, _glMatrix.mat4).create(); + const objMesh = new (0, _objJs.ObjHelper)(this._core).read(this._obj || this._cubeObj); + if (!this._obj) { + this.useRayPose = true; + const modelThickness = 0.02; + const modelLength = 0.1; + (0, _glMatrix.vec3).set(_vec3, modelThickness, modelThickness, modelLength); + (0, _glMatrix.mat4).fromScaling(this._mMatrix, _vec3); + (0, _glMatrix.vec3).set(_vec3, 0, 0, 1); + (0, _glMatrix.mat4).translate(this._mMatrix, this._mMatrix, _vec3); } - } - get maxBoundsY() { - return this._maxBoundsY; - } - set maxBoundsY(value) { - if (value != this._minBoundsY) { - this._maxBoundsY = value; - this._hasChanged = true; + this._vertices = objMesh.vertices; + this._indices = objMesh.indices; + this._indexCount = objMesh.indexCount; + this._rayMMatrix = (0, _glMatrix.mat4).create(); + const rayVertices = (0, _cubeJs.Cube).POSITIONS; + this._rayVertices = new ArrayBuffer((0, _vertexJs.PositionColorVertex).SIZE_BYTES * rayVertices.length / (0, _vertexJs.PositionVertex).SIZE); + const rayVerticesView = new DataView(this._rayVertices); + const rayIndices = (0, _cubeJs.Cube).INDICES; + this._rayIndices = new Uint16Array(rayIndices); + const rayVertexCount = rayVertices.length / (0, _vertexJs.PositionVertex).SIZE; + this._rayIndexCount = rayIndices.length; + for(let i = 0; i < rayVertexCount; i++){ + (0, _glMatrix.vec3).set(_vec3, rayVertices[i * (0, _vertexJs.PositionVertex).SIZE], rayVertices[i * (0, _vertexJs.PositionVertex).SIZE + 1], rayVertices[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _vertexJs.PositionColorVertex).setPosition(rayVerticesView, i, _vec3); + (0, _vertexJs.PositionColorVertex).setColor(rayVerticesView, i, this._core.config.xrControllerRayColor); } + const rayThickness = 0.0025; + const rayLength = 10; + (0, _glMatrix.vec3).set(_vec3, rayThickness, rayThickness, rayLength); + (0, _glMatrix.mat4).fromScaling(this._rayMMatrix, _vec3); + (0, _glMatrix.vec3).set(_vec3, 0, 0, -0.5); + (0, _glMatrix.mat4).translate(this._rayMMatrix, this._rayMMatrix, _vec3); + this._isInitialized = true; + this._core.log.write((0, _mainJs.LogLevel).info, "controller initialized"); } - get minBoundsZ() { - return this._minBoundsZ; + update(elapsedTime) {} +} + +},{"../main.js":"f421K","../helpers/obj.js":"kBT24","gl-matrix":"5x28d","../meshes/cube.js":"79I5N","../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kBT24":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ObjMesh", ()=>ObjMesh); +parcelHelpers.export(exports, "ObjHelper", ()=>ObjHelper); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +class ObjMesh { +} +class ObjHelper { + constructor(core){ + this._core = core; } - set minBoundsZ(value) { - if (value != this._minBoundsZ) { - this._minBoundsZ = value; - this._hasChanged = true; + read(data) { + const start = window.performance.now(); + const indices = []; + const positions = []; + const normals = []; + const texCoords = []; + const meshes = []; + const indexOffsets = []; + const indexCounts = []; + const faceLookup = {}; + const lines = data.split("\n"); + let faceCount = 0; + for(let i = 0; i < lines.length; i++){ + const parts = lines[i].trim().split(" "); + if (parts.length > 0) switch(parts[0]){ + case "o": + meshes.push(parts[1]); + indexOffsets.push(indices.length); + break; + case "v": + positions.push(parseFloat(parts[1])); + positions.push(parseFloat(parts[2])); + positions.push(parseFloat(parts[3])); + break; + case "vt": + texCoords.push(parseFloat(parts[1])); + texCoords.push(parseFloat(parts[2])); + break; + case "vn": + normals.push(parseFloat(parts[1])); + normals.push(parseFloat(parts[2])); + normals.push(parseFloat(parts[3])); + break; + case "f": + for(let i = 0; i < parts.length - 1; i++){ + const part = parts[i + 1]; + if (faceLookup[part] == undefined) faceLookup[part] = faceCount++; + indices.push(faceLookup[part]); + } + break; + case "usemtl": + case "mtllib": + default: + break; + } } - } - get maxBoundsZ() { - return this._maxBoundsZ; - } - set maxBoundsZ(value) { - if (value != this._minBoundsZ) { - this._maxBoundsZ = value; - this._hasChanged = true; + for(let i = 0; i < meshes.length - 1; i++)indexCounts.push(indexOffsets[i + 1] - indexOffsets[i]); + indexCounts.push(indices.length - indexOffsets[meshes.length - 1]); + const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * Object.keys(faceLookup).length); + const dataView = new DataView(vertices); + let minX = Number.MAX_VALUE; + let minY = Number.MAX_VALUE; + let minZ = Number.MAX_VALUE; + let maxX = -Number.MAX_VALUE; + let maxY = -Number.MAX_VALUE; + let maxZ = -Number.MAX_VALUE; + const faces = Object.keys(faceLookup); + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + let hasTexCoords, hasNormals; + if (faces.length > 0) { + const faceParts = faces[0].split("/"); + hasTexCoords = faceParts.length > 1 && !isNaN(parseInt(faceParts[1])); + hasNormals = faceParts.length > 2 && !isNaN(parseInt(faceParts[2])); } - } - getIsOutsideEdge(index) { - return this._isOutsideEdge[index]; - } - getIsForwardFace(index) { - return this._isForwardFace[index]; - } - get textVertices() { - return this._textVertices; - } - get textIndices() { - return this._textIndices; - } - getLabelMMatrix(index) { - return this._labelMMatrices[index]; - } - setLabelPositions(index, value) { - if (this._labelPositions[index] != value) { - this._labelPositions[index] = value; - this._hasChanged = true; + for(let i = 0; i < faces.length; i++){ + const faceParts = faces[i].split("/"); + let index = (parseInt(faceParts[0]) - 1) * 3; + const x = positions[index]; + const y = positions[index + 1]; + const z = positions[index + 2]; + (0, _glMatrix.vec3).set(_vec3, x, y, z); + (0, _vertexJs.PositionNormalTextureVertex).setPosition(dataView, i, _vec3); + minX = Math.min(x, minX); + minY = Math.min(y, minY); + minZ = Math.min(z, minZ); + maxX = Math.max(x, maxX); + maxY = Math.max(y, maxY); + maxZ = Math.max(z, maxZ); + if (hasNormals) { + index = (parseInt(faceParts[2]) - 1) * 3; + (0, _glMatrix.vec3).set(_vec3, normals[index], normals[index + 1], normals[index + 2]); + (0, _vertexJs.PositionNormalTextureVertex).setNormal(dataView, i, _vec3); + } + if (hasTexCoords) { + index = (parseInt(faceParts[1]) - 1) * 2; + (0, _glMatrix.vec2).set(_vec2, texCoords[index], texCoords[index + 1]); + (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(dataView, i, _vec2); + } } + const originX = (minX + maxX) / 2; + const originY = (minY + maxY) / 2; + const originZ = (minZ + maxZ) / 2; + const objMesh = new ObjMesh(); + objMesh.vertices = vertices; + objMesh.indices = new Uint16Array(indices); + objMesh.meshes = meshes; + objMesh.indexOffsets = indexOffsets; + objMesh.indexCounts = indexCounts; + objMesh.indexCount = indices.length; + objMesh.minX = minX; + objMesh.minY = minY; + objMesh.minZ = minZ; + objMesh.maxX = maxX; + objMesh.maxY = maxY; + objMesh.maxZ = maxZ; + objMesh.originX = originX; + objMesh.originY = originY; + objMesh.originZ = originZ; + this._core.log.write((0, _mainJs.LogLevel).info, `obj loaded ${Math.round(window.performance.now() - start)}ms`); + return objMesh; } - setLabels(index, value) { - if (this._labels[index] != value) { - this._labels[index] = value; - this._hasChanged = true; - } +} + +},{"gl-matrix":"5x28d","../main.js":"f421K","../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4J2YE":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PositionVertex", ()=>PositionVertex); +parcelHelpers.export(exports, "PositionColorVertex", ()=>PositionColorVertex); +parcelHelpers.export(exports, "PositionTextureVertex", ()=>PositionTextureVertex); +parcelHelpers.export(exports, "PositionTexturePickVertex", ()=>PositionTexturePickVertex); +parcelHelpers.export(exports, "PositionNormalVertex", ()=>PositionNormalVertex); +parcelHelpers.export(exports, "PositionNormalColorVertex", ()=>PositionNormalColorVertex); +parcelHelpers.export(exports, "PositionNormalTextureVertex", ()=>PositionNormalTextureVertex); +parcelHelpers.export(exports, "PickGridVertex", ()=>PickGridVertex); +parcelHelpers.export(exports, "UnitVertex", ()=>UnitVertex); +var _glMatrix = require("gl-matrix"); +class PositionVertex { + static getPosition(buffer, index, value) { + const offset = index * PositionVertex.SIZE; + (0, _glMatrix.vec3).set(value, buffer[offset], buffer[offset + 1], buffer[offset + 2]); } - setLabelSizes(index, value) { - if (this._labelSizes[index] != value) { - this._labelSizes[index] = value; - this._hasChanged = true; - } + static setPosition(buffer, index, value) { + const offset = index * PositionVertex.SIZE; + buffer[offset] = value[0]; + buffer[offset + 1] = value[1]; + buffer[offset + 2] = value[2]; } - getLabelOrientation(index) { - return this._orientations[index]; +} +PositionVertex.SIZE = 3; +PositionVertex.SIZE_BYTES = 12; +class PositionColorVertex { + static getPosition(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - setLabelOrientation(index, orientation) { - if (this._orientations[index] != orientation) { - this._orientations[index] = orientation; - this._hasChanged = true; - } + static setPosition(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - getTitleIndexCount(index) { - return this._titleIndexCounts[index]; + static getColor(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF); } - getTitleIndexOffset(index) { - return this._titleIndexOffsets[index]; + static setColor(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; + bufferView.setUint8(offset, value[0] * 0xFF); + bufferView.setUint8(offset + 1, value[1] * 0xFF); + bufferView.setUint8(offset + 2, value[2] * 0xFF); } - getTitleMMatrix(index) { - return this._titleMMatrices[index]; +} +PositionColorVertex.SIZE_BYTES = 16; +PositionColorVertex.POSITION_OFFSET_BYTES = 0; +PositionColorVertex.COLOR_OFFSET_BYTES = 12; +class PositionTextureVertex { + static getPosition(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - setTitle(index, value) { - if (this._titles[index] != value) { - this._titles[index] = value; - this._hasChanged = true; - } + static setPosition(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - setTitleSize(index, value) { - if (this._titleSizes[index] != value) { - this._titleSizes[index] = value; - this._hasChanged = true; - } + static getTexCoord(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); } - getHeadingIndexCount(index) { - return this._headingIndexCounts[index]; + static setTexCoord(bufferView, index, value) { + const offset = PositionColorVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + bufferView.setUint16(offset, value[0] * 0xFFFF, true); + bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); } - getHeadingIndexOffset(index) { - return this._headingIndexOffsets[index]; +} +PositionTextureVertex.SIZE_BYTES = 16; +PositionTextureVertex.POSITION_OFFSET_BYTES = 0; +PositionTextureVertex.TEX_COORD_OFFSET_BYTES = 12; +class PositionTexturePickVertex { + static getPosition(bufferView, index, value) { + const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - getHeadingMMatrix(index) { - return this._headingMMatrices[index]; + static setPosition(bufferView, index, value) { + const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - setHeading(index, value) { - if (this._headings[index] != value) { - this._headings[index] = value; - this._hasChanged = true; - } + static getTexCoord(bufferView, index, value) { + const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); } - setHeadingSize(index, value) { - if (this._headingSizes[index] != value) { - this._headingSizes[index] = value; - this._hasChanged = true; - } + static setTexCoord(bufferView, index, value) { + const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + bufferView.setUint16(offset, value[0] * 0xFFFF, true); + bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); } - getIsLeftToRightHorizontal(index) { - return this._isLeftToRightHorizontal[index]; + static getIdColor(bufferView, index, value) { + const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; + (0, _glMatrix.vec4).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF, bufferView.getUint8(offset + 3) / 0xFF); } - getIsLeftToRightVertical(index) { - return this._isLeftToRightVertical[index]; + static setIdColor(bufferView, index, value) { + const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; + bufferView.setUint8(offset, value[0] * 0xFF); + bufferView.setUint8(offset + 1, value[1] * 0xFF); + bufferView.setUint8(offset + 2, value[2] * 0xFF); + bufferView.setUint8(offset + 3, value[3] * 0xFF); } - getAxesLeftToRightIndexCount(index) { - return this._axesLeftToRightIndexCounts[index]; +} +PositionTexturePickVertex.SIZE_BYTES = 20; +PositionTexturePickVertex.ID_COLOR_OFFSET_BYTES = 0; +PositionTexturePickVertex.POSITION_OFFSET_BYTES = 4; +PositionTexturePickVertex.TEX_COORD_OFFSET_BYTES = 16; +class PositionNormalVertex { + static getPosition(bufferView, index, value) { + const offset = PositionNormalVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - getAxesRightToLeftIndexCount(index) { - return this._axesRightToLeftIndexCounts[index]; + static setPosition(bufferView, index, value) { + const offset = PositionNormalVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - getAxesLeftToRightIndexOffset(index) { - return this._axesLeftToRightIndexOffsets[index]; + static getNormal(bufferView, index, value) { + const offset = PositionNormalVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); } - getAxesRightToLeftIndexOffset(index) { - return this._axesRightToLeftIndexOffsets[index]; + static setNormal(bufferView, index, value) { + const offset = PositionNormalVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + bufferView.setInt8(offset, value[0] * 0x7F); + bufferView.setInt8(offset + 1, value[1] * 0x7F); + bufferView.setInt8(offset + 2, value[2] * 0x7F); } - get gridVertices() { - return this._gridVertices; +} +PositionNormalVertex.SIZE_BYTES = 16; +PositionNormalVertex.POSITION_OFFSET_BYTES = 0; +PositionNormalVertex.NORMAL_OFFSET_BYTES = 12; +class PositionNormalColorVertex { + static getPosition(bufferView, index, value) { + const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - get gridIndices() { - return this._gridIndices; + static setPosition(bufferView, index, value) { + const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - getGridTicksIndexCount(index) { - return this._gridTicksIndexCounts[index]; + static getNormal(bufferView, index, value) { + const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); } - getGridTicksIndexOffset(index) { - return this._gridTicksIndexOffsets[index]; + static setNormal(bufferView, index, value) { + const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + bufferView.setInt8(offset, value[0] * 0x7F); + bufferView.setInt8(offset + 1, value[1] * 0x7F); + bufferView.setInt8(offset + 2, value[2] * 0x7F); } - getGridFaceIndexCount(index) { - return this._gridFaceIndexCounts[index]; + static getColor(bufferView, index, value) { + const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF); } - getGridFaceIndexOffset(index) { - return this._gridFaceIndexOffsets[index]; + static setColor(bufferView, index, value) { + const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; + bufferView.setUint8(offset, value[0] * 0xFF); + bufferView.setUint8(offset + 1, value[1] * 0xFF); + bufferView.setUint8(offset + 2, value[2] * 0xFF); } - getGridTicksMMatrix(index) { - return this._gridTicksMMatrices[index]; +} +PositionNormalColorVertex.SIZE_BYTES = 20; +PositionNormalColorVertex.POSITION_OFFSET_BYTES = 0; +PositionNormalColorVertex.NORMAL_OFFSET_BYTES = 12; +PositionNormalColorVertex.COLOR_OFFSET_BYTES = 16; +class PositionNormalTextureVertex { + static getPosition(bufferView, index, value) { + const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - getGridFaceMMatrix(index) { - return this._gridFaceMMatrices[index]; + static setPosition(bufferView, index, value) { + const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - getGridTicksScale(index) { - return this._gridTicksScales[index]; + static getNormal(bufferView, index, value) { + const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); } - getGridFaceZero(index) { - return this._gridFaceZeros[index]; + static setNormal(bufferView, index, value) { + const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + bufferView.setInt8(offset, value[0] * 0x7F); + bufferView.setInt8(offset + 1, value[1] * 0x7F); + bufferView.setInt8(offset + 2, value[2] * 0x7F); } - getGridTicksZero(index) { - return this._gridTicksZeros[index]; + static getTexCoord(bufferView, index, value) { + const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); } - getGridFaceMinorGridlines(index) { - return this._gridFaceMinorGridlines[index]; + static setTexCoord(bufferView, index, value) { + const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + bufferView.setUint16(offset, value[0] * 0xFFFF, true); + bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); } - getGridTicksMinorGridlines(index) { - return this._gridTicksMinorGridlines[index]; +} +PositionNormalTextureVertex.SIZE_BYTES = 20; +PositionNormalTextureVertex.POSITION_OFFSET_BYTES = 0; +PositionNormalTextureVertex.NORMAL_OFFSET_BYTES = 12; +PositionNormalTextureVertex.TEX_COORD_OFFSET_BYTES = 16; +class PickGridVertex { + static getTranslation(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - setTickPositions(index, value) { - if (this._gridTicksPositions[index] != value) { - this._gridTicksPositions[index] = value; - this._hasChanged = true; - } + static setTranslation(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - get scalingX() { - return this._scalingX; + static getNormal(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); } - set scalingX(value) { - if (value != this._scalingX) { - this._scalingX = value; - this._hasChanged = true; - } + static setNormal(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; + bufferView.setInt8(offset, value[0] * 0x7F); + bufferView.setInt8(offset + 1, value[1] * 0x7F); + bufferView.setInt8(offset + 2, value[2] * 0x7F); } - get scalingY() { - return this._scalingY; + static getIdColor(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; + (0, _glMatrix.vec4).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF, bufferView.getUint8(offset + 3) / 0xFF); } - set scalingY(value) { - if (value != this._scalingY) { - this._scalingY = value; - this._hasChanged = true; - } + static setIdColor(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; + bufferView.setUint8(offset, value[0] * 0xFF); + bufferView.setUint8(offset + 1, value[1] * 0xFF); + bufferView.setUint8(offset + 2, value[2] * 0xFF); + bufferView.setUint8(offset + 3, value[3] * 0xFF); } - get scalingZ() { - return this._scalingZ; + static getTexCoord(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); } - set scalingZ(value) { - if (value != this._scalingZ) { - this._scalingZ = value; - this._hasChanged = true; - } + static setTexCoord(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; + bufferView.setUint16(offset, value[0] * 0xFFFF, true); + bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); } - get offsetX() { - return this._offset[12]; + static getBounds(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.BOUNDS_OFFSET_BYTES; + (0, _glMatrix.vec4).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF, bufferView.getUint16(offset + 4, true) / 0xFFFF, bufferView.getUint16(offset + 6, true) / 0xFFFF); } - set offsetX(value) { - if (value != this._offset[12]) this._offset[12] = value; + static setBounds(bufferView, index, value) { + const offset = PickGridVertex.SIZE_BYTES * index + this.BOUNDS_OFFSET_BYTES; + bufferView.setUint16(offset, value[0] * 0xFFFF, true); + bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); + bufferView.setUint16(offset + 4, value[2] * 0xFFFF, true); + bufferView.setUint16(offset + 6, value[3] * 0xFFFF, true); } - get offsetY() { - return this._offset[13]; +} +PickGridVertex.SIZE_BYTES = 32; +PickGridVertex.TRANSLATION_OFFSET_BYTES = 0; +PickGridVertex.NORMAL_OFFSET_BYTES = 12; +PickGridVertex.ID_COLOR_OFFSET_BYTES = 16; +PickGridVertex.TEX_COORD_OFFSET_BYTES = 20; +PickGridVertex.BOUNDS_OFFSET_BYTES = 24; +class UnitVertex { + static getIdHover(bufferView, index) { + return bufferView.getFloat32(UnitVertex.SIZE_BYTES * index + this.ID_HOVER_OFFSET_BYTES, true); } - set offsetY(value) { - if (value != this._offset[13]) this._offset[13] = value; + static setIdHover(bufferView, index, value) { + bufferView.setFloat32(UnitVertex.SIZE_BYTES * index + this.ID_HOVER_OFFSET_BYTES, value, true); } - get offsetZ() { - return this._offset[14]; + static copyIdHover(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setFloat32(UnitVertex.SIZE_BYTES * toIndex + this.ID_HOVER_OFFSET_BYTES, fromBufferView.getFloat32(UnitVertex.SIZE_BYTES * fromIndex + this.ID_HOVER_OFFSET_BYTES, true), true); } - set offsetZ(value) { - if (value != this._offset[14]) this._offset[14] = value; + static getTranslation(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - constructor(core){ - super(core); - this._size = (0, _glMatrix.vec3).create(); - this._translation = (0, _glMatrix.vec3).create(); - this._normal = (0, _glMatrix.vec3).create(); - this._forward = (0, _glMatrix.vec3).create(); - this._right = (0, _glMatrix.vec3).create(); - this._up = (0, _glMatrix.vec3).create(); - this._texCoord = (0, _glMatrix.vec2).create(); - this._bounds = (0, _glMatrix.vec4).create(); - this._vec3 = (0, _glMatrix.vec3).create(); - this._vec4 = (0, _glMatrix.vec4).create(); - this._mat3 = (0, _glMatrix.mat3).create(); - this._isDiscrete = [ - false, - false, - false - ]; - this._minBoundsX = 0; - this._minBoundsY = 0; - this._minBoundsZ = 0; - this._maxBoundsX = 0; - this._maxBoundsY = 0; - this._maxBoundsZ = 0; - this._isForwardFace = []; - this._isForwardEdge = []; - this._isOutsideEdge = []; - for(let i = 0; i < 6; i++)this._isForwardFace.push(false); - for(let i1 = 0; i1 < 12; i1++){ - this._isForwardEdge.push(false); - this._isOutsideEdge.push(false); - } - this._textOffset = (0, _glMatrix.vec3).create(); - this._textPosition = (0, _glMatrix.vec3).create(); - this._distances = []; - for(let i2 = 0; i2 < 12; i2++)this._distances.push(0); - this._labelPositions = []; - this._labels = []; - this._labelSizes = []; - this._maxLabelSize = []; - this._axesLeftToRightIndexCounts = []; - this._axesRightToLeftIndexCounts = []; - this._axesLeftToRightIndexOffsets = []; - this._axesRightToLeftIndexOffsets = []; - this._labelMMatrices = []; - this._orientations = []; - for(let i3 = 0; i3 < 3; i3++){ - this._maxLabelSize.push((0, _glMatrix.vec2).create()); - this._orientations.push((0, _mainJs.AxesTextOrientation).parallel); - this._axesLeftToRightIndexCounts.push(0); - this._axesRightToLeftIndexCounts.push(0); - this._axesLeftToRightIndexOffsets.push(0); - this._axesRightToLeftIndexOffsets.push(0); - } - for(let i4 = 0; i4 < 12; i4++)this._labelMMatrices.push((0, _glMatrix.mat4).create()); - this._titles = []; - this._titleSizes = []; - this._titleIndexCounts = []; - this._titleIndexOffsets = []; - this._titleMMatrices = []; - for(let i5 = 0; i5 < 3; i5++){ - this._titles.push(null); - this._titleSizes.push(core.config.axesTextTitleSize); - this._titleIndexCounts.push(0); - this._titleIndexOffsets.push(0); - } - for(let i6 = 0; i6 < 12; i6++)this._titleMMatrices.push((0, _glMatrix.mat4).create()); - this._headings = []; - this._headingSizes = []; - this._headingIndexCounts = []; - this._headingIndexOffsets = []; - this._headingMMatrices = []; - this.isHeadingVisible = []; - for(let i7 = 0; i7 < 3; i7++){ - this._headings.push(null); - this._headingSizes.push(core.config.axesTextHeadingSize); - this._headingIndexCounts.push(0); - this._headingIndexOffsets.push(0); - } - for(let i8 = 0; i8 < 12; i8++){ - this._headingMMatrices.push((0, _glMatrix.mat4).create()); - this.isHeadingVisible.push(true); - } - this.isEdgeVisible = []; - this._edgePosition = (0, _glMatrix.vec3).create(); - this._edgePositive = (0, _glMatrix.vec3).create(); - this._edgeNormal = (0, _glMatrix.vec3).create(); - this._edgeNormalTemp = (0, _glMatrix.vec3).create(); - this._edgePositiveTemp = (0, _glMatrix.vec3).create(); - this._isLeftToRightHorizontal = []; - this._isLeftToRightVertical = []; - this._edgeHorizontalRight = []; - this._edgeHorizontalUp = []; - this._edgeHorizontalForward = []; - this._edgeVerticalRight = []; - this._edgeVerticalUp = []; - this._edgeVerticalForward = []; - for(let i9 = 0; i9 < 12; i9++){ - this.isEdgeVisible.push(true); - this._isLeftToRightHorizontal.push(false); - this._isLeftToRightVertical.push(false); - this._edgeHorizontalRight.push((0, _glMatrix.vec3).create()); - this._edgeHorizontalUp.push((0, _glMatrix.vec3).create()); - this._edgeHorizontalForward.push((0, _glMatrix.vec3).create()); - this._edgeVerticalRight.push((0, _glMatrix.vec3).create()); - this._edgeVerticalUp.push((0, _glMatrix.vec3).create()); - this._edgeVerticalForward.push((0, _glMatrix.vec3).create()); - } - this.isFaceVisible = []; - for(let i10 = 0; i10 < 6; i10++)this.isFaceVisible.push(true); - this.arePickDivisionsVisible = []; - this.areFacesVisible = []; - this._indexTemplate = (0, _quadJs.Quad).INDICES; - this.zero = (0, _glMatrix.vec3).create(); - this._gridTicksZeros = []; - this._gridFaceZeros = []; - this.minorGridlines = (0, _glMatrix.vec3).fromValues(1, 1, 1); - this._gridTicksMinorGridlines = []; - this._gridFaceMinorGridlines = []; - this._gridTicksPositions = []; - this._gridTicksScales = []; - this._gridTicksIndexCounts = []; - this._gridTicksIndexOffsets = []; - this._gridFaceScale = (0, _glMatrix.vec3).create(); - this._gridFaceIndexCounts = []; - this._gridFaceIndexOffsets = []; - this._gridFaceMMatrices = []; - this._gridTicksMMatrices = []; - this._gridTicksRotations = []; - for(let i11 = 0; i11 < 3; i11++){ - this.arePickDivisionsVisible.push(true); - this.areFacesVisible.push(true); - this._gridTicksZeros.push((0, _glMatrix.vec2).create()); - this._gridFaceZeros.push((0, _glMatrix.vec2).create()); - this._gridTicksMinorGridlines.push((0, _glMatrix.vec2).create()); - this._gridFaceMinorGridlines.push((0, _glMatrix.vec2).create()); - this._gridTicksScales.push((0, _glMatrix.vec3).create()); - this._gridTicksIndexCounts.push(0); - this._gridTicksIndexOffsets.push(0); - } - for(let i12 = 0; i12 < 6; i12++){ - this._gridFaceIndexCounts.push(0); - this._gridFaceIndexOffsets.push(0); - this._gridFaceMMatrices.push((0, _glMatrix.mat4).create()); - } - for(let i13 = 0; i13 < 12; i13++){ - this._gridTicksMMatrices.push((0, _glMatrix.mat4).create()); - this._gridTicksRotations.push((0, _glMatrix.mat4).create()); - const _mat4 = this._gridTicksRotations[i13]; - _mat4[0] = (0, _cubeJs.Cube).EDGE_POSITIVES[i13][0]; - _mat4[1] = (0, _cubeJs.Cube).EDGE_POSITIVES[i13][1]; - _mat4[2] = (0, _cubeJs.Cube).EDGE_POSITIVES[i13][2]; - _mat4[4] = (0, _cubeJs.Cube).EDGE_NORMALS[i13][0]; - _mat4[5] = (0, _cubeJs.Cube).EDGE_NORMALS[i13][1]; - _mat4[6] = (0, _cubeJs.Cube).EDGE_NORMALS[i13][2]; - (0, _glMatrix.vec3).cross(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIVES[i13], (0, _cubeJs.Cube).EDGE_NORMALS[i13]); - _mat4[8] = this._vec3[0]; - _mat4[9] = this._vec3[1]; - _mat4[10] = this._vec3[2]; - } - this._fromValues = [ - null, - null, - null - ]; - this._toValues = [ - null, - null, - null - ]; - this.isDivisionPickingEnabled = [ - false, - false, - false - ]; - this.isLabelPickingEnabled = [ - false, - false, - false - ]; - this.isTitlePickingEnabled = [ - false, - false, - false - ]; - this.isHeadingPickingEnabled = [ - false, - false, - false - ]; - this.isAxisReversed = [ - false, - false, - false - ]; - this._scalingX = 1; - this._scalingY = 1; - this._scalingZ = 1; - this._offset = (0, _glMatrix.mat4).create(); + static setTranslation(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - initialize() { - this._isInitialized = true; + static copyTranslation(fromBufferView, fromIndex, toBufferView, toIndex) { + const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.TRANSLATION_OFFSET_BYTES; + const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.TRANSLATION_OFFSET_BYTES; + toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); + toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); + toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); } - update(elapsedTime) { - if (this.isInitialized) { - if (this._hasChanged) { - const start = window.performance.now(); - this._hasChanged = false; - (0, _glMatrix.vec3).set(this._size, this._maxBoundsX - this._minBoundsX, this._maxBoundsY - this._minBoundsY, this._maxBoundsZ - this._minBoundsZ); - const maxBounds = Math.max(this._size[0], Math.max(this._size[1], this._size[2])); - this._size[0] *= this._scalingX / maxBounds; - this._size[1] *= this._scalingY / maxBounds; - this._size[2] *= this._scalingZ / maxBounds; - this._updateGrids(this._size); - this._updateText(this._size); - if (this.hasChangedCallback) this.hasChangedCallback(); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d updated ${Math.round(window.performance.now() - start)}ms`); - } - (0, _glMatrix.mat4).multiply(this._mMatrix, this.mMatrix, this._offset); - this._mvMatrix = (0, _glMatrix.mat4).create(); - (0, _glMatrix.mat4).multiply(this._mvMatrix, this._vMatrix, this._mMatrix); - (0, _glMatrix.mat3).fromMat4(this._mat3, this._mvMatrix); - for(let faceId = 0; faceId < 6; faceId++){ - (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).FACE_POSITIONS[faceId], this._size); - (0, _glMatrix.vec3).transformMat4(this._forward, this._vec3, this._mvMatrix); - (0, _glMatrix.vec3).transformMat3(this._normal, (0, _cubeJs.Cube).FACE_NORMALS[faceId], this._mat3); - this._isForwardFace[faceId] = (0, _glMatrix.vec3).dot(this._normal, this._forward) > 0; - } - this._forward[0] = this._mat3[2]; - this._forward[1] = this._mat3[5]; - this._forward[2] = this._mat3[8]; - for(let edgeId = 0; edgeId < 12; edgeId++){ - const faceIds = (0, _cubeJs.Cube).EDGE_FACES[edgeId]; - const forward1 = this._isForwardFace[faceIds[0]]; - const forward2 = this._isForwardFace[faceIds[1]]; - const outsideEdge = forward1 != forward2; - this._isOutsideEdge[edgeId] = outsideEdge; - if (outsideEdge) this._isForwardEdge[edgeId] = (0, _glMatrix.vec3).dot((0, _cubeJs.Cube).EDGE_FORWARDS[edgeId], this._forward) < 0; - this._distances[edgeId] = 0; - } - for(let axisId = 0; axisId < 3; axisId++)if (this.arePickDivisionsVisible[axisId]) { - (0, _glMatrix.vec2).set(this._gridTicksZeros[axisId], this.zero[axisId], -1); - (0, _glMatrix.vec2).set(this._gridTicksMinorGridlines[axisId], this.minorGridlines[axisId], 1); - const gridTicksScale = this._gridTicksScales[axisId]; - for(let edge = 0; edge < 4; edge++){ - const edgeId1 = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; - if (this._isOutsideEdge[edgeId1] && this.isEdgeVisible[edgeId1]) { - let distance = this._distances[edgeId1]; - distance += this._gridPickDivisionHeight * 0.5; - const gridTicksMMatrix = this._gridTicksMMatrices[edgeId1]; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId1], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId1], distance); - (0, _glMatrix.mat4).translate(gridTicksMMatrix, this._mMatrix, this._vec3); - (0, _glMatrix.mat4).multiply(gridTicksMMatrix, gridTicksMMatrix, this._gridTicksRotations[edgeId1]); - if (!this._isForwardEdge[edgeId1]) (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, (0, _constantsJs.Constants).VECTOR3_REFLECTX); - (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, gridTicksScale); - distance += this._gridPickDivisionHeight * 0.5; - this._distances[edgeId1] = distance; - } - } - } - for(let axisId1 = 0; axisId1 < 3; axisId1++)if (this.areFacesVisible[axisId1]) { - const axisId2 = axisId1 == 0 ? 1 : 0; - const axisId3 = axisId1 == 2 ? 1 : 2; - (0, _glMatrix.vec2).set(this._gridFaceZeros[axisId1], this.zero[axisId2], this.zero[axisId3]); - (0, _glMatrix.vec2).set(this._gridFaceMinorGridlines[axisId1], this.minorGridlines[axisId2], this.minorGridlines[axisId3]); - for(let face = 0; face < 2; face++){ - const faceId1 = (0, _cubeJs.Cube).AXIS_FACES[axisId1][face]; - if (this._isForwardFace[faceId1]) { - const gridFaceMMatrix = this._gridFaceMMatrices[faceId1]; - (0, _glMatrix.mat4).scale(gridFaceMMatrix, this._mMatrix, this._gridFaceScale); - if (this._size[axisId1] > 0) (0, _glMatrix.mat4).translate(gridFaceMMatrix, gridFaceMMatrix, (0, _cubeJs.Cube).FACE_POSITIONS[faceId1]); - } - } - } - for(let axisId4 = 0; axisId4 < 3; axisId4++)for(let edge1 = 0; edge1 < 4; edge1++){ - const edgeId2 = (0, _cubeJs.Cube).AXIS_EDGES[axisId4][edge1]; - if (this._isOutsideEdge[edgeId2]) { - (0, _glMatrix.vec3).multiply(this._edgePosition, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId2], this._size); - (0, _glMatrix.vec3).transformMat4(this._edgePosition, this._edgePosition, this._mvMatrix); - (0, _glMatrix.vec3).normalize(this._forward, this._edgePosition); - (0, _glMatrix.vec3).negate(this._forward, this._forward); - (0, _glMatrix.vec3).cross(this._right, (0, _constantsJs.Constants).VECTOR3_UNITY, this._forward); - (0, _glMatrix.vec3).normalize(this._right, this._right); - (0, _glMatrix.vec3).cross(this._up, this._forward, this._right); - (0, _glMatrix.vec3).transformMat3(this._edgeNormal, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId2], this._mat3); - (0, _glMatrix.vec3).transformMat3(this._edgePositive, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId2], this._mat3); - (0, _glMatrix.vec3).copy(this._edgeNormalTemp, this._edgeNormal); - (0, _glMatrix.vec3).copy(this._edgePositiveTemp, this._edgePositive); - const edgeHorizontalRight = this._edgeHorizontalRight[edgeId2]; - const edgeHorizontalUp = this._edgeHorizontalUp[edgeId2]; - const edgeHorizontalForward = this._edgeHorizontalForward[edgeId2]; - if ((0, _glMatrix.vec3).dot(this._edgeNormalTemp, this._up) > 0) (0, _glMatrix.vec3).copy(edgeHorizontalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId2]); - else { - (0, _glMatrix.vec3).negate(edgeHorizontalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgeNormalTemp, this._edgeNormalTemp); - } - if ((0, _glMatrix.vec3).dot(this._edgePositiveTemp, this._right) > 0) { - this._isLeftToRightHorizontal[edgeId2] = true; - (0, _glMatrix.vec3).copy(edgeHorizontalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId2]); - } else { - this._isLeftToRightHorizontal[edgeId2] = false; - (0, _glMatrix.vec3).negate(edgeHorizontalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgePositiveTemp, this._edgePositiveTemp); - } - (0, _glMatrix.vec3).cross(edgeHorizontalForward, this._edgePositiveTemp, this._edgeNormalTemp); - if ((0, _glMatrix.vec3).dot(edgeHorizontalForward, this._forward) < 0) { - this._isLeftToRightHorizontal[edgeId2] = !this._isLeftToRightHorizontal[edgeId2]; - (0, _glMatrix.vec3).negate(edgeHorizontalRight, edgeHorizontalRight); - } - (0, _glMatrix.vec3).cross(edgeHorizontalForward, edgeHorizontalRight, edgeHorizontalUp); - const edgeVerticalRight = this._edgeVerticalRight[edgeId2]; - const edgeVerticalUp = this._edgeVerticalUp[edgeId2]; - const edgeVerticalForward = this._edgeVerticalForward[edgeId2]; - if ((0, _glMatrix.vec3).dot(this._edgeNormal, this._right) < 0) (0, _glMatrix.vec3).copy(edgeVerticalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId2]); - else { - (0, _glMatrix.vec3).negate(edgeVerticalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgeNormal, this._edgeNormal); - } - if ((0, _glMatrix.vec3).dot(this._edgePositive, this._up) < 0) { - this._isLeftToRightVertical[edgeId2] = true; - (0, _glMatrix.vec3).copy(edgeVerticalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId2]); - } else { - this._isLeftToRightVertical[edgeId2] = false; - (0, _glMatrix.vec3).negate(edgeVerticalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgePositive, this._edgePositive); - } - (0, _glMatrix.vec3).cross(edgeVerticalForward, this._edgePositive, this._edgeNormal); - if ((0, _glMatrix.vec3).dot(edgeVerticalForward, this._forward) < 0) { - this._isLeftToRightVertical[edgeId2] = !this._isLeftToRightVertical[edgeId2]; - (0, _glMatrix.vec3).negate(edgeVerticalRight, edgeVerticalRight); - } - (0, _glMatrix.vec3).cross(edgeVerticalForward, edgeVerticalRight, edgeVerticalUp); - if (this.isEdgeVisible[edgeId2]) { - if (this._labels[axisId4]) this._updateLabels(axisId4, edgeId2); - if (this._titles[axisId4]) this._updateTitle(axisId4, edgeId2); - } - if (this.isHeadingVisible[edgeId2]) this._updateHeading(axisId4, edgeId2); - } - } - } + static getColor(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; + (0, _glMatrix.vec2).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF); } - _updateLabels(axisId, edgeId) { - const orientation = this._orientations[axisId]; - let distance = this._distances[edgeId]; - let maxLabelSize = this._maxLabelSize[axisId][1]; - if (orientation == (0, _mainJs.AxesTextOrientation).parallel) maxLabelSize *= this._lineHeight; - distance += maxLabelSize * 0.5; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); - const labelMMatrix = this._labelMMatrices[edgeId]; - labelMMatrix[12] = this._vec3[0]; - labelMMatrix[13] = this._vec3[1]; - labelMMatrix[14] = this._vec3[2]; - if (orientation == (0, _mainJs.AxesTextOrientation).parallel) { - const right = this._edgeHorizontalRight[edgeId]; - const up = this._edgeHorizontalUp[edgeId]; - const forward = this._edgeHorizontalForward[edgeId]; - labelMMatrix[0] = right[0]; - labelMMatrix[1] = right[1]; - labelMMatrix[2] = right[2]; - labelMMatrix[4] = up[0]; - labelMMatrix[5] = up[1]; - labelMMatrix[6] = up[2]; - labelMMatrix[8] = forward[0]; - labelMMatrix[9] = forward[1]; - labelMMatrix[10] = forward[2]; - } else { - const right1 = this._edgeVerticalRight[edgeId]; - const up1 = this._edgeVerticalUp[edgeId]; - const forward1 = this._edgeVerticalForward[edgeId]; - labelMMatrix[0] = right1[0]; - labelMMatrix[1] = right1[1]; - labelMMatrix[2] = right1[2]; - labelMMatrix[4] = up1[0]; - labelMMatrix[5] = up1[1]; - labelMMatrix[6] = up1[2]; - labelMMatrix[8] = forward1[0]; - labelMMatrix[9] = forward1[1]; - labelMMatrix[10] = forward1[2]; - } - (0, _glMatrix.mat4).multiply(labelMMatrix, this._mMatrix, labelMMatrix); - if (orientation == (0, _mainJs.AxesTextOrientation).perpendicular) (0, _glMatrix.mat4).multiply(labelMMatrix, labelMMatrix, (0, _constantsJs.Constants).MAT4_ROTATION_MINUS_90); - distance += maxLabelSize * 0.5; - this._distances[edgeId] = distance; + static setColor(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; + bufferView.setUint8(offset, value[0] * 0xFF); + bufferView.setUint8(offset + 1, value[1] * 0xFF); } - _updateTitle(axisId, edgeId) { - let distance = this._distances[edgeId]; - const titleTextSize = this._titleSizes[axisId] * this._lineHeight; - distance += titleTextSize * 0.5; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); - const titleMMatrix = this._titleMMatrices[edgeId]; - titleMMatrix[12] = this._vec3[0]; - titleMMatrix[13] = this._vec3[1]; - titleMMatrix[14] = this._vec3[2]; - const right = this._edgeHorizontalRight[edgeId]; - const up = this._edgeHorizontalUp[edgeId]; - const forward = this._edgeHorizontalForward[edgeId]; - titleMMatrix[0] = right[0]; - titleMMatrix[1] = right[1]; - titleMMatrix[2] = right[2]; - titleMMatrix[4] = up[0]; - titleMMatrix[5] = up[1]; - titleMMatrix[6] = up[2]; - titleMMatrix[8] = forward[0]; - titleMMatrix[9] = forward[1]; - titleMMatrix[10] = forward[2]; - (0, _glMatrix.mat4).multiply(titleMMatrix, this._mMatrix, titleMMatrix); - distance += titleTextSize * 0.5; - this._distances[edgeId] = distance; + static copyColor(fromBufferView, fromIndex, toBufferView, toIndex) { + const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.COLOR_OFFSET_BYTES; + const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.COLOR_OFFSET_BYTES; + toBufferView.setUint8(toOffset, fromBufferView.getUint8(fromOffset)); + toBufferView.setUint8(toOffset + 1, fromBufferView.getUint8(fromOffset + 1)); } - _updateHeading(axisId, edgeId) { - let distance = this._distances[edgeId]; - const headingTextSize = this._headingSizes[axisId] * this._lineHeight; - distance += headingTextSize * 0.5; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); - const headingMMatrix = this._headingMMatrices[edgeId]; - headingMMatrix[12] = this._vec3[0]; - headingMMatrix[13] = this._vec3[1]; - headingMMatrix[14] = this._vec3[2]; - const right = this._edgeHorizontalRight[edgeId]; - const up = this._edgeHorizontalUp[edgeId]; - const forward = this._edgeHorizontalForward[edgeId]; - headingMMatrix[0] = right[0]; - headingMMatrix[1] = right[1]; - headingMMatrix[2] = right[2]; - headingMMatrix[4] = up[0]; - headingMMatrix[5] = up[1]; - headingMMatrix[6] = up[2]; - headingMMatrix[8] = forward[0]; - headingMMatrix[9] = forward[1]; - headingMMatrix[10] = forward[2]; - (0, _glMatrix.mat4).multiply(headingMMatrix, this._mMatrix, headingMMatrix); - distance += headingTextSize * 0.5; - this._distances[edgeId] = distance; + static getOrder(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.ORDER_OFFSET_BYTES; + (0, _glMatrix.vec2).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true)); } - _updateGrids(size) { - let offset = 0; - this.pickGridLookup = {}; - this._pickGrid = []; - const xDivisions = this._gridTicksPositions[0] ? this._gridTicksPositions[0].length - 1 : 0; - const yDivisions = this._gridTicksPositions[1] ? this._gridTicksPositions[1].length - 1 : 0; - const zDivisions = this._gridTicksPositions[2] ? this._gridTicksPositions[2].length - 1 : 0; - const count = 2 * (xDivisions * yDivisions) + 2 * (xDivisions * zDivisions) + 2 * (yDivisions * zDivisions) + xDivisions + yDivisions + zDivisions; - const byteLength = (0, _vertexJs.PickGridVertex).SIZE_BYTES * count * 4; - if (!this._gridVertices || this._gridVertices.byteLength < byteLength) { - this._gridVertices = new ArrayBuffer(byteLength); - this._gridVerticesView = new DataView(this._gridVertices); - this._gridIndices = new Uint16Array(count * 6); - } - for(let axisId = 0; axisId < 3; axisId++){ - const width = size[axisId]; - (0, _glMatrix.vec3).set(this._gridTicksScales[axisId], width, this._gridPickDivisionHeight, 1); - offset = this._updateGridTicks(axisId, this._gridVerticesView, this._gridIndices, offset); - for(let face = 0; face < 2; face++){ - const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId][face]; - offset = this._updateGridFace(axisId, faceId, this._gridVerticesView, this._gridIndices, offset); - } - this._gridFaceScale[axisId] = size[axisId] == 0 ? 1 : size[axisId]; - } + static setOrder(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.ORDER_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); } - _updateText(size) { - let glyphOffset = 0; - let count = 0; - for(let axisId = 0; axisId < 3; axisId++){ - const labels = this._labels[axisId]; - if (labels) for(let i = 0; i < labels.length; i++)count += 2 * Math.min(labels[i].length, this._core.config.axesTextLabelMaxGlyphs); - const title = this._titles[axisId]; - if (title) count += Math.min(title.length, this._core.config.axesTextTitleMaxGlyphs); - const heading = this._headings[axisId]; - if (heading) count += Math.min(heading.length, this._core.config.axesTextHeadingMaxGlyphs); - } - const byteLength = (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES * count * 4; - if (!this._textVertices || this._textVertices.byteLength < byteLength) { - this._textVertices = new ArrayBuffer(byteLength); - this._textVerticesView = new DataView(this._textVertices); - this._textIndices = new Uint16Array(count * 6); - } - this.pickLabelLookup = {}; - this._pickLabel = []; - for(let axisId1 = 0; axisId1 < 3; axisId1++)if (this._labels[axisId1]) { - const width = size[axisId1]; - const maxLabelSize = this._maxLabelSize[axisId1]; - const orientation = this._orientations[axisId1]; - (0, _glMatrix.vec2).set(maxLabelSize, 0, 0); - this._axesLeftToRightIndexOffsets[axisId1] = glyphOffset * 6; - glyphOffset = this._updateLeftToRightAxisLabels(axisId1, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId1], this._labelPositions[axisId1], this._labelSizes[axisId1]); - this._axesLeftToRightIndexCounts[axisId1] = glyphOffset * 6 - this._axesLeftToRightIndexOffsets[axisId1]; - this._axesRightToLeftIndexOffsets[axisId1] = glyphOffset * 6; - glyphOffset = this._updateRightToLeftAxisLabels(axisId1, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId1], this._labelPositions[axisId1], this._labelSizes[axisId1]); - this._axesRightToLeftIndexCounts[axisId1] = glyphOffset * 6 - this._axesRightToLeftIndexOffsets[axisId1]; - } else { - this._axesLeftToRightIndexOffsets[axisId1] = glyphOffset * 6; - this._axesRightToLeftIndexOffsets[axisId1] = glyphOffset * 6; - this._axesLeftToRightIndexCounts[axisId1] = 0; - this._axesRightToLeftIndexCounts[axisId1] = 0; - this._maxLabelSize[axisId1][0] = 0; - this._maxLabelSize[axisId1][1] = 0; - } - this.pickTitleLookup = {}; - this._pickTitle = []; - for(let axisId2 = 0; axisId2 < 3; axisId2++)if (this._titles[axisId2]) { - (0, _glMatrix.vec3).set(this._textPosition, 0, 0, 0); - (0, _glMatrix.vec3).set(this._textOffset, 0, 0, 0); - this._titleIndexOffsets[axisId2] = glyphOffset * 6; - const text = (0, _textJs.TextHelper).truncate(this._titles[axisId2], this._core.config.axesTextTitleMaxGlyphs); - const scale = this._titleSizes[axisId2] / this._font.size; - (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); - const width1 = this._textMetric.width * scale; - const maxGlyphTop = this._textMetric.maxTop * scale; - const lineHeight = this._font.size * scale; - this._textOffset[0] -= width1 / 2; - this._textOffset[1] -= (lineHeight - maxGlyphTop) / 2; - const pickId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesTitle, this._vec4); - this.pickTitleLookup[pickId] = this._pickTitle.length; - this._pickTitle.push(axisId2); - (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); - glyphOffset += text.length; - this._titleIndexCounts[axisId2] = glyphOffset * 6 - this._titleIndexOffsets[axisId2]; - } else { - this._titleIndexOffsets[axisId2] = glyphOffset * 6; - this._titleIndexCounts[axisId2] = 0; - } - this.pickHeadingLookup = {}; - this._pickHeading = []; - for(let axisId3 = 0; axisId3 < 3; axisId3++)if (this._headings[axisId3]) { - (0, _glMatrix.vec3).set(this._textPosition, 0, 0, 0); - (0, _glMatrix.vec3).set(this._textOffset, 0, 0, 0); - this._headingIndexOffsets[axisId3] = glyphOffset * 6; - const text1 = (0, _textJs.TextHelper).truncate(this._headings[axisId3], this._core.config.axesTextHeadingMaxGlyphs); - const scale1 = this._headingSizes[axisId3] / this._font.size; - (0, _textJs.TextHelper).measure(this._font, text1, this._textMetric); - const width2 = this._textMetric.width * scale1; - const maxGlyphTop1 = this._textMetric.maxTop * scale1; - const lineHeight1 = this._font.size * scale1; - this._textOffset[0] -= width2 / 2; - this._textOffset[1] -= (lineHeight1 - maxGlyphTop1) / 2; - const pickId1 = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId1, (0, _mainJs.PickType).axesHeading, this._vec4); - this.pickHeadingLookup[pickId1] = this._pickHeading.length; - this._pickHeading.push(axisId3); - (0, _textJs.TextHelper).addString(this._font, text1, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale1, this._textOffset, null, this._vec4); - glyphOffset += text1.length; - this._headingIndexCounts[axisId3] = glyphOffset * 6 - this._headingIndexOffsets[axisId3]; - } else { - this._headingIndexOffsets[axisId3] = glyphOffset * 6; - this._headingIndexCounts[axisId3] = 0; - } + static copyOrder(fromBufferView, fromIndex, toBufferView, toIndex) { + const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.ORDER_OFFSET_BYTES; + const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.ORDER_OFFSET_BYTES; + toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); + toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); } - _updateLeftToRightAxisLabels(axisId, size, maxSize, glyphOffset, orientation, labels, positions, scales) { - const isAxisReversed = this.isAxisReversed[axisId]; - for(let label = 0; label < labels.length; label++){ - const text = (0, _textJs.TextHelper).truncate(labels[label], this._core.config.axesTextLabelMaxGlyphs); - const lineHeight = scales[label]; - const scale = lineHeight / this._font.size; - (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); - const width = this._textMetric.width * scale; - const maxGlyphTop = this._textMetric.maxTop * scale; - const position = isAxisReversed ? 1 - positions[label] : positions[label]; - switch(orientation){ - case (0, _mainJs.AxesTextOrientation).parallel: - (0, _glMatrix.vec3).set(this._textPosition, (position - 0.5) * size, 0, 0); - if (this._isDiscrete[axisId]) this._textOffset[0] = -width / 2; - else this._textOffset[0] = position == 0 ? 0 : position == 1 ? -width : -width / 2; - this._textOffset[1] = (maxGlyphTop - lineHeight) / 2; - maxSize[0] = Math.max(width, maxSize[0]); - maxSize[1] = Math.max(lineHeight, maxSize[1]); - break; - case (0, _mainJs.AxesTextOrientation).perpendicular: - (0, _glMatrix.vec3).set(this._textPosition, 0, (position - 0.5) * size, 0); - this._textOffset[0] = -width / 2; - if (this._isDiscrete[axisId]) this._textOffset[1] = -maxGlyphTop / 2; - else this._textOffset[1] = position == 0 ? 0 : position == 1 ? -maxGlyphTop : -maxGlyphTop / 2; - maxSize[0] = Math.max(lineHeight, maxSize[0]); - maxSize[1] = Math.max(width, maxSize[1]); - break; - } - const pickId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesLabel, this._vec4); - this.pickLabelLookup[pickId] = this._pickLabel.length / 2; - this._pickLabel.push(axisId); - this._pickLabel.push(label); - (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); - glyphOffset += text.length; - } - return glyphOffset; + static getScale(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.SCALE_OFFSET_BYTES; + (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); } - _updateRightToLeftAxisLabels(axisId, size, maxSize, glyphOffset, orientation, labels, positions, scales) { - const isAxisReversed = this.isAxisReversed[axisId]; - for(let label = 0; label < labels.length; label++){ - const text = (0, _textJs.TextHelper).truncate(labels[label], this._core.config.axesTextLabelMaxGlyphs); - const lineHeight = scales[label]; - const scale = lineHeight / this._font.size; - (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); - const width = this._textMetric.width * scale; - const maxGlyphTop = this._textMetric.maxTop * scale; - const position = isAxisReversed ? 1 - positions[label] : positions[label]; - switch(orientation){ - case (0, _mainJs.AxesTextOrientation).parallel: - (0, _glMatrix.vec3).set(this._textPosition, (0.5 - position) * size, 0, 0); - if (this._isDiscrete[axisId]) this._textOffset[0] = -width / 2; - else this._textOffset[0] = label == 0 ? -width : label == labels.length - 1 ? 0 : -width / 2; - this._textOffset[1] = (maxGlyphTop - lineHeight) / 2; - break; - case (0, _mainJs.AxesTextOrientation).perpendicular: - (0, _glMatrix.vec3).set(this._textPosition, 0, (0.5 - position) * size, 0); - this._textOffset[0] = -width / 2; - if (this._isDiscrete[axisId]) this._textOffset[1] = -maxGlyphTop / 2; - else this._textOffset[1] = label == 0 ? -maxGlyphTop : label == labels.length - 1 ? 0 : -maxGlyphTop / 2; - break; - } - const pickId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesLabel, this._vec4); - this.pickLabelLookup[pickId] = this._pickLabel.length / 2; - this._pickLabel.push(axisId); - this._pickLabel.push(label); - (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); - glyphOffset += text.length; - } - return glyphOffset; + static setScale(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.SCALE_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); } - _updateGridTicks(axisId, dataView, indices, offset) { - this._gridTicksIndexOffsets[axisId] = offset * 6; - if (this._gridTicksPositions[axisId]) { - const axes = (0, _glMatrix.vec3).create(); - const positions = this._gridTicksPositions[axisId]; - const isAxisReversed = this.isAxisReversed[axisId]; - let vertexOffset = offset * 4; - for(let position = 0; position < positions.length - 1; position++){ - const left = isAxisReversed ? 1 - positions[position + 1] - 0.5 : positions[position] - 0.5; - const right = isAxisReversed ? 1 - positions[position] - 0.5 : positions[position + 1] - 0.5; - axes[axisId] = position + 1; - const pickId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesDivision, this._vec4); - this.pickGridLookup[pickId] = this._pickGrid.length / 3; - this._pickGrid.push(axes[0]); - this._pickGrid.push(axes[1]); - this._pickGrid.push(axes[2]); - let indexOffset = offset * 6; - for(let j = 0; j < this._indexTemplate.length; j++)indices[indexOffset++] = this._indexTemplate[j] + vertexOffset; - (0, _glMatrix.vec4).set(this._bounds, left + 0.5, 0, right + 0.5, 1); - this._translation[0] = left; - this._translation[1] = 0.5; - this._translation[2] = 0; - this._texCoord[0] = left + 0.5; - this._texCoord[1] = 1; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - this._translation[0] = right; - this._texCoord[0] = right + 0.5; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - this._translation[0] = left; - this._translation[1] = -0.5; - this._texCoord[0] = left + 0.5; - this._texCoord[1] = 0; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - this._translation[0] = right; - this._texCoord[0] = right + 0.5; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - offset++; - } - } - this._gridTicksIndexCounts[axisId] = offset * 6 - this._gridTicksIndexOffsets[axisId]; - return offset; + static copyScale(fromBufferView, fromIndex, toBufferView, toIndex) { + const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.SCALE_OFFSET_BYTES; + const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.SCALE_OFFSET_BYTES; + toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); + toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); + toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); } - _updateGridFace(axisId, faceId, dataView, indices, offset) { - (0, _glMatrix.vec3).set(this._translation, 0, 0, 0); - this._gridFaceIndexOffsets[faceId] = offset * 6; - const axisId2 = axisId == 0 ? 1 : 0; - const axisId3 = axisId == 2 ? 1 : 2; - if (this._gridTicksPositions[axisId2] && this._gridTicksPositions[axisId3]) { - const axes = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).negate(this._normal, (0, _cubeJs.Cube).FACE_NORMALS[faceId]); - const positions2 = this._gridTicksPositions[axisId2]; - const positions3 = this._gridTicksPositions[axisId3]; - const isAxisReversed2 = this.isAxisReversed[axisId2]; - const isAxisReversed3 = this.isAxisReversed[axisId3]; - for(let position2 = 0; position2 < positions2.length - 1; position2++){ - const min2 = isAxisReversed2 ? 1 - positions2[position2 + 1] - 0.5 : positions2[position2] - 0.5; - const max2 = isAxisReversed2 ? 1 - positions2[position2] - 0.5 : positions2[position2 + 1] - 0.5; - axes[axisId2] = position2 + 1; - let vertexOffset = offset * 4; - for(let position3 = 0; position3 < positions3.length - 1; position3++){ - const min3 = isAxisReversed3 ? 1 - positions3[position3 + 1] - 0.5 : positions3[position3] - 0.5; - const max3 = isAxisReversed3 ? 1 - positions3[position3] - 0.5 : positions3[position3 + 1] - 0.5; - axes[axisId3] = position3 + 1; - const pickId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesDivision, this._vec4); - this.pickGridLookup[pickId] = this._pickGrid.length / 3; - this._pickGrid.push(axes[0]); - this._pickGrid.push(axes[1]); - this._pickGrid.push(axes[2]); - let indexOffset = offset * 6; - for(let i = 0; i < this._indexTemplate.length; i++)indices[indexOffset++] = this._indexTemplate[i] + vertexOffset; - (0, _glMatrix.vec4).set(this._bounds, min2 + 0.5, min3 + 0.5, max2 + 0.5, max3 + 0.5); - this._translation[axisId2] = min2; - this._translation[axisId3] = max3; - this._texCoord[0] = min2 + 0.5; - this._texCoord[1] = max3 + 0.5; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - this._translation[axisId2] = max2; - this._texCoord[0] = max2 + 0.5; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - this._translation[axisId2] = min2; - this._translation[axisId3] = min3; - this._texCoord[0] = min2 + 0.5; - this._texCoord[1] = min3 + 0.5; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - this._translation[axisId2] = max2; - this._texCoord[0] = max2 + 0.5; - (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); - (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); - (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); - (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); - (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); - vertexOffset++; - offset++; - } - } - } - this._gridFaceIndexCounts[faceId] = offset * 6 - this._gridFaceIndexOffsets[faceId]; - return offset; + static getRotation(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.ROTATION_OFFSET_BYTES; + (0, _glMatrix.quat).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true), bufferView.getFloat32(offset + 12, true)); } -} - -},{"gl-matrix":"9GjEQ","../../constants.js":"2Scl5","../../main.js":"1Kju3","./axes.js":"duutq","../../meshes/quad.js":"jyd4s","../../meshes/cube.js":"7rTMs","../../vertex.js":"ddAub","../../helpers/axes.js":"8BmXc","../../helpers/text.js":"l2V9O","../../helpers/pick.js":"9zmDo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"duutq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AxesVisual", ()=>AxesVisual); -parcelHelpers.export(exports, "AxesBase", ()=>AxesBase); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class AxesVisual { - render(elapsedTime, xrFrame) {} - update(elapsedTime) {} - constructor(axes){ - this.axes = axes; + static setRotation(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.ROTATION_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); + bufferView.setFloat32(offset + 12, value[3], true); } -} -class AxesBase { - get isInitialized() { - return this._isInitialized; + static copyRotation(fromBufferView, fromIndex, toBufferView, toIndex) { + const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.ROTATION_OFFSET_BYTES; + const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.ROTATION_OFFSET_BYTES; + toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); + toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); + toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); + toBufferView.setFloat32(toOffset + 12, fromBufferView.getFloat32(fromOffset + 12, true), true); } - set vMatrix(value) { - this._vMatrix = value; + static getTexCoord(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.TEXCOORD_OFFSET_BYTES; + (0, _glMatrix.quat).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true), bufferView.getFloat32(offset + 12, true)); } - pickGrid(id) { - const offset = id * 3; - return { - divisionX: this._pickGrid[offset] - 1, - divisionY: this._pickGrid[offset + 1] - 1, - divisionZ: this._pickGrid[offset + 2] - 1 - }; + static setTexCoord(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.TEXCOORD_OFFSET_BYTES; + bufferView.setFloat32(offset, value[0], true); + bufferView.setFloat32(offset + 4, value[1], true); + bufferView.setFloat32(offset + 8, value[2], true); + bufferView.setFloat32(offset + 12, value[3], true); } - pickTitle(id) { - return { - axis: this._pickTitle[id] - }; + static copyTexCoord(fromBufferView, fromIndex, toBufferView, toIndex) { + const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.TEXCOORD_OFFSET_BYTES; + const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.TEXCOORD_OFFSET_BYTES; + toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); + toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); + toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); + toBufferView.setFloat32(toOffset + 12, fromBufferView.getFloat32(fromOffset + 12, true), true); } - pickLabel(id) { - const offset = id * 2; - return { - axis: this._pickLabel[offset], - label: this._pickLabel[offset + 1] - }; + static getIdColor(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; + (0, _glMatrix.vec4).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF, bufferView.getUint8(offset + 3) / 0xFF); } - pickHeading(id) { - return { - axis: this._pickHeading[id] - }; + static setIdColor(bufferView, index, value) { + const offset = UnitVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; + bufferView.setUint8(offset, value[0] * 0xFF); + bufferView.setUint8(offset + 1, value[1] * 0xFF); + bufferView.setUint8(offset + 2, value[2] * 0xFF); + bufferView.setUint8(offset + 3, value[3] * 0xFF); } - getFromValues(index) { - return this._fromValues[index]; + static getSelected(bufferView, index) { + return bufferView.getInt8(UnitVertex.SIZE_BYTES * index + this.SELECTED_OFFSET_BYTES) / 0x7F; } - setFromValues(index, value) { - if (this._fromValues[index] != value) { - this._fromValues[index] = value; - this._hasChanged = true; - } + static setSelected(bufferView, index, value) { + bufferView.setInt8(UnitVertex.SIZE_BYTES * index + this.SELECTED_OFFSET_BYTES, value * 0x7F); } - getToValues(index) { - return this._toValues[index]; + static copySelected(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setInt8(UnitVertex.SIZE_BYTES * toIndex + this.SELECTED_OFFSET_BYTES, fromBufferView.getInt8(UnitVertex.SIZE_BYTES * fromIndex + this.SELECTED_OFFSET_BYTES)); } - setToValues(index, value) { - if (this._toValues[index] != value) { - this._toValues[index] = value; - this._hasChanged = true; - } + static getRounding(bufferView, index) { + return bufferView.getFloat32(UnitVertex.SIZE_BYTES * index + this.ROUNDING_OFFSET_BYTES, true); } - get font() { - return this._font; + static setRounding(bufferView, index, value) { + bufferView.setFloat32(UnitVertex.SIZE_BYTES * index + this.ROUNDING_OFFSET_BYTES, value, true); } - set font(value) { - if (this._font != value) { - this._font = value; - this._hasChanged = true; - } + static copyRounding(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setFloat32(UnitVertex.SIZE_BYTES * toIndex + this.ROUNDING_OFFSET_BYTES, fromBufferView.getFloat32(UnitVertex.SIZE_BYTES * fromIndex + this.ROUNDING_OFFSET_BYTES, true), true); } - get gridPickDivisionHeight() { - return this._gridPickDivisionHeight; + static getParameter1(bufferView, index) { + return bufferView.getFloat32(UnitVertex.SIZE_BYTES * index + this.PARAMETER_1_OFFSET_BYTES, true); } - set gridPickDivisionHeight(value) { - if (this._gridPickDivisionHeight != value) { - this._gridPickDivisionHeight = value; - this._hasChanged = true; - } + static setParameter1(bufferView, index, value) { + bufferView.setFloat32(UnitVertex.SIZE_BYTES * index + this.PARAMETER_1_OFFSET_BYTES, value, true); } - constructor(core){ - this._core = core; - this._mMatrix = (0, _glMatrix.mat4).create(); - this._mvMatrix = (0, _glMatrix.mat4).create(); - this._textMetric = { - maxTop: 0, - width: 0, - maxHeight: 0 - }; - this._gridPickDivisionHeight = core.config.axesGridPickDivisionHeight; - this.textBorderWidth = core.config.textBorderWidth; - this.gamma = 0; - this.gridMajorThickness = core.config.axesGridMajorThickness; - this.gridMinorThickness = core.config.axesGridMinorThickness; - this.gridZeroThickness = core.config.axesGridZeroThickness; - this._font = core.font; - this._lineHeight = 1.5; - this.isGridPickingEnabled = false; + static copyParameter1(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setFloat32(UnitVertex.SIZE_BYTES * toIndex + this.PARAMETER_1_OFFSET_BYTES, fromBufferView.getFloat32(UnitVertex.SIZE_BYTES * fromIndex + this.PARAMETER_1_OFFSET_BYTES, true), true); + } + static getParameter2(bufferView, index) { + return bufferView.getFloat32(UnitVertex.SIZE_BYTES * index + this.PARAMETER_2_OFFSET_BYTES, true); + } + static setParameter2(bufferView, index, value) { + bufferView.setFloat32(UnitVertex.SIZE_BYTES * index + this.PARAMETER_2_OFFSET_BYTES, value, true); + } + static copyParameter2(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setFloat32(UnitVertex.SIZE_BYTES * toIndex + this.PARAMETER_2_OFFSET_BYTES, fromBufferView.getFloat32(UnitVertex.SIZE_BYTES * fromIndex + this.PARAMETER_2_OFFSET_BYTES, true), true); + } + static getMaterial(bufferView, index) { + return bufferView.getUint16(UnitVertex.SIZE_BYTES * index + this.MATERIAL_OFFSET_BYTES); + } + static setMaterial(bufferView, index, value) { + bufferView.setUint16(UnitVertex.SIZE_BYTES * index + this.MATERIAL_OFFSET_BYTES, value); + } + static copyMaterial(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setUint16(UnitVertex.SIZE_BYTES * toIndex + this.MATERIAL_OFFSET_BYTES, fromBufferView.getUint16(UnitVertex.SIZE_BYTES * fromIndex + this.MATERIAL_OFFSET_BYTES, true), true); + } + static getTexture(bufferView, index) { + return bufferView.getUint8(UnitVertex.SIZE_BYTES * index + this.TEXTURE_OFFSET_BYTES); + } + static setTexture(bufferView, index, value) { + bufferView.setUint8(UnitVertex.SIZE_BYTES * index + this.TEXTURE_OFFSET_BYTES, value); + } + static copyTexture(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setUint8(UnitVertex.SIZE_BYTES * toIndex + this.TEXTURE_OFFSET_BYTES, fromBufferView.getUint8(UnitVertex.SIZE_BYTES * fromIndex + this.TEXTURE_OFFSET_BYTES)); + } + static getSdfBuffer(bufferView, index) { + return bufferView.getUint8(UnitVertex.SIZE_BYTES * index + this.SDF_BUFFER_OFFSET_BYTES); + } + static setSdfBuffer(bufferView, index, value) { + bufferView.setUint8(UnitVertex.SIZE_BYTES * index + this.SDF_BUFFER_OFFSET_BYTES, value); + } + static copySdfBuffer(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setUint8(UnitVertex.SIZE_BYTES * toIndex + this.SDF_BUFFER_OFFSET_BYTES, fromBufferView.getUint8(UnitVertex.SIZE_BYTES * fromIndex + this.SDF_BUFFER_OFFSET_BYTES)); + } + static getSdfBorder(bufferView, index) { + return bufferView.getUint8(UnitVertex.SIZE_BYTES * index + this.SDF_BORDER_OFFSET_BYTES); + } + static setSdfBorder(bufferView, index, value) { + bufferView.setUint8(UnitVertex.SIZE_BYTES * index + this.SDF_BORDER_OFFSET_BYTES, value); + } + static copySdfBorder(fromBufferView, fromIndex, toBufferView, toIndex) { + toBufferView.setUint8(UnitVertex.SIZE_BYTES * toIndex + this.SDF_BORDER_OFFSET_BYTES, fromBufferView.getUint8(UnitVertex.SIZE_BYTES * fromIndex + this.SDF_BORDER_OFFSET_BYTES)); } - update(elapsedTime) {} } +UnitVertex.SIZE_BYTES = 92; +UnitVertex.ID_HOVER_OFFSET_BYTES = 0; +UnitVertex.ID_COLOR_OFFSET_BYTES = 4; +UnitVertex.ORDER_OFFSET_BYTES = 8; +UnitVertex.STAGGER_ORDER_OFFSET_BYTES = 12; +UnitVertex.SELECTED_OFFSET_BYTES = 80; +UnitVertex.TRANSLATION_OFFSET_BYTES = 16; +UnitVertex.COLOR_OFFSET_BYTES = 28; +UnitVertex.MATERIAL_OFFSET_BYTES = 30; +UnitVertex.SCALE_OFFSET_BYTES = 32; +UnitVertex.ROUNDING_OFFSET_BYTES = 44; +UnitVertex.ROTATION_OFFSET_BYTES = 48; +UnitVertex.TEXCOORD_OFFSET_BYTES = 64; +UnitVertex.TEXTURE_OFFSET_BYTES = 81; +UnitVertex.SDF_BUFFER_OFFSET_BYTES = 82; +UnitVertex.SDF_BORDER_OFFSET_BYTES = 83; +UnitVertex.PARAMETER_1_OFFSET_BYTES = 84; +UnitVertex.PARAMETER_2_OFFSET_BYTES = 88; -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jyd4s":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Quad", ()=>Quad); -parcelHelpers.export(exports, "Grid", ()=>Grid); +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"79I5N":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cube", ()=>Cube); +var _glMatrix = require("gl-matrix"); var _constantsJs = require("../constants.js"); -var _vertexJs = require("../vertex.js"); -class Quad { - static positions(transform) { - const positions = new Float32Array(12); - const position = (0, _glMatrix.vec3).create(); - for(let i = 0; i < 4; i++){ - (0, _glMatrix.vec3).set(position, this.POSITIONS[i * 3], this.POSITIONS[i * 3 + 1], this.POSITIONS[i * 3 + 2]); - (0, _glMatrix.vec3).transformMat4(position, position, transform); - positions[i * 3] = position[0]; - positions[i * 3 + 1] = position[1]; - positions[i * 3 + 2] = position[2]; - } - return positions; - } - static textured(transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { - const positions = this.positions(transform); - const texCoords = this.TEX_COORDS; - const vertices = new ArrayBuffer((0, _vertexJs.PositionTextureVertex).SIZE_BYTES * positions.length / 3); - const verticesView = new DataView(vertices); - const position = (0, _glMatrix.vec3).create(); - const texCoord = (0, _glMatrix.vec2).create(); - for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ - (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); - (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, texTransform); - (0, _vertexJs.PositionTextureVertex).setPosition(verticesView, i, position); - (0, _vertexJs.PositionTextureVertex).setTexCoord(verticesView, i, texCoord); - } - return verticesView; - } - static normalTextured(transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { - const positions = this.positions(transform); - const texCoords = this.TEX_COORDS; - const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * positions.length / 3); - const verticesView = new DataView(vertices); - const position = (0, _glMatrix.vec3).create(); - const texCoord = (0, _glMatrix.vec2).create(); - const normal3 = (0, _glMatrix.vec3).create(); - const normal4 = (0, _glMatrix.vec4).create(); - for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ - (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); - (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, texTransform); - (0, _vertexJs.PositionNormalTextureVertex).setPosition(verticesView, i, position); - (0, _glMatrix.vec4).set(normal4, 0.0, 0.0, 1.0, 0.0); - (0, _glMatrix.vec4).transformMat4(normal4, normal4, transform); - (0, _glMatrix.vec3).set(normal3, normal4[0], normal4[1], normal4[2]); - (0, _glMatrix.vec3).normalize(normal3, normal3); - (0, _vertexJs.PositionNormalTextureVertex).setNormal(verticesView, i, normal3); - (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(verticesView, i, texCoord); - } - return verticesView; - } +class Cube { } -Quad.FACE_NORMALS = [ - (0, _glMatrix.vec3).fromValues(0, 0, 1), - (0, _glMatrix.vec3).fromValues(0, 0, -1) -]; -Quad.FACE_ROTATIONS = [ - (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 1, 0, 0, 0, 1), - (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, -1, 0, 0, 0, -1) -]; -Quad.EDGE_POSITIONS = [ - (0, _glMatrix.vec3).fromValues(0, 0.5, 0), - (0, _glMatrix.vec3).fromValues(0.5, 0, 0), - (0, _glMatrix.vec3).fromValues(0, -0.5, 0), - (0, _glMatrix.vec3).fromValues(-0.5, 0, 0) -]; -Quad.EDGE_NORMALS = [ - (0, _glMatrix.vec3).fromValues(0, 1, 0), - (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, -1, 0), - (0, _glMatrix.vec3).fromValues(-1, 0, 0) -]; -Quad.EDGE_POSITIVES = [ - (0, _glMatrix.vec3).fromValues(1, 0, 0), +Cube.POSITIONS = new Float32Array([ + -0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + -0.5, + 0.5, + -0.5, + -0.5, + 0.5, + -0.5, + 0.5, + -0.5, + 0.5, + 0.5, + -0.5, + 0.5, + -0.5, + -0.5, + -0.5, + -0.5, + -0.5 +]); +Cube.INDICES = new Uint16Array([ + 5, + 4, + 1, + 0, + 3, + 4, + 7, + 5, + 6, + 1, + 2, + 3, + 6, + 7 +]); +Cube.CUBE_MAP_INDICES = new Uint16Array([ + 2, + 3, + 1, + 0, + 4, + 3, + 7, + 2, + 6, + 1, + 5, + 4, + 6, + 7 +]); +Cube.FACE_NORMALS = [ (0, _glMatrix.vec3).fromValues(0, 1, 0), (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, 1, 0) -]; -Quad.EDGE_FORWARDS = [ - (0, _glMatrix.vec3).fromValues(0, 0, -1), - (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(0, -1, 0), + (0, _glMatrix.vec3).fromValues(-1, 0, 0), (0, _glMatrix.vec3).fromValues(0, 0, 1), (0, _glMatrix.vec3).fromValues(0, 0, -1) ]; -Quad.AXIS_EDGES = [ +Cube.FACE_POSITIONS = [ + (0, _glMatrix.vec3).fromValues(0.0, 0.5, 0.0), + (0, _glMatrix.vec3).fromValues(0.5, 0.0, 0.0), + (0, _glMatrix.vec3).fromValues(0.0, -0.5, 0.0), + (0, _glMatrix.vec3).fromValues(-0.5, 0.0, 0.0), + (0, _glMatrix.vec3).fromValues(0.0, 0.0, 0.5), + (0, _glMatrix.vec3).fromValues(0.0, 0.0, -0.5) +]; +Cube.FACE_ROTATIONS = [ + (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 0, -1, 0, 1, 0), + (0, _glMatrix.mat3).fromValues(0, 0, -1, 0, 1, 0, 1, 0, 0), + (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 0, 1, 0, -1, 0), + (0, _glMatrix.mat3).fromValues(0, 0, 1, 0, 1, 0, -1, 0, 0), + (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 1, 0, 0, 0, 1), + (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, -1, 0, 0, 0, -1) +]; +Cube.EDGE_POSITIONS = [ + (0, _glMatrix.vec3).fromValues(0, 0.5, 0.5), + (0, _glMatrix.vec3).fromValues(0.5, 0.5, 0), + (0, _glMatrix.vec3).fromValues(0, 0.5, -0.5), + (0, _glMatrix.vec3).fromValues(-0.5, 0.5, 0), + (0, _glMatrix.vec3).fromValues(0, -0.5, 0.5), + (0, _glMatrix.vec3).fromValues(0.5, -0.5, 0), + (0, _glMatrix.vec3).fromValues(0, -0.5, -0.5), + (0, _glMatrix.vec3).fromValues(-0.5, -0.5, 0), + (0, _glMatrix.vec3).fromValues(0.5, 0, 0.5), + (0, _glMatrix.vec3).fromValues(0.5, 0, -0.5), + (0, _glMatrix.vec3).fromValues(-0.5, 0, -0.5), + (0, _glMatrix.vec3).fromValues(-0.5, 0, 0.5) +]; +Cube.EDGE_NORMALS = [ + (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO) +]; +Cube.EDGE_CORNERS = [ [ 0, - 2 + 1 + ], + [ + 1, + 5 + ], + [ + 4, + 5 + ], + [ + 0, + 4 + ], + [ + 2, + 3 + ], + [ + 2, + 6 + ], + [ + 6, + 7 + ], + [ + 3, + 7 ], [ 1, + 2 + ], + [ + 5, + 6 + ], + [ + 4, + 7 + ], + [ + 0, 3 ] ]; -Quad.POSITIONS = new Float32Array([ - -0.5, - 0.5, - 0, - 0.5, - 0.5, - 0, - -0.5, - -0.5, +Cube.EDGE_FACES = [ + [ + 0, + 4 + ], + [ + 0, + 1 + ], + [ + 0, + 5 + ], + [ + 0, + 3 + ], + [ + 2, + 4 + ], + [ + 2, + 1 + ], + [ + 2, + 5 + ], + [ + 2, + 3 + ], + [ + 1, + 4 + ], + [ + 1, + 5 + ], + [ + 3, + 5 + ], + [ + 3, + 4 + ] +]; +Cube.EDGE_AXIS = [ 0, - 0.5, - -0.5, - 0 -]); -Quad.INDICES = new Uint16Array([ + 2, 0, 2, - 1, - 1, + 0, 2, - 3 -]); -Quad.TEX_COORDS = new Float32Array([ 0, + 2, 1, 1, 1, - 0, + 1 +]; +Cube.AXIS_EDGES = [ + [ + 0, + 2, + 4, + 6 + ], + [ + 8, + 9, + 10, + 11 + ], + [ + 1, + 3, + 5, + 7 + ] +]; +Cube.AXIS_FACES = [ + [ + 1, + 3 + ], + [ + 0, + 2 + ], + [ + 4, + 5 + ] +]; +Cube.OPPOSITE_FACES = [ + 2, + 3, 0, 1, - 0 -]); -class Grid { - static positions(cols, rows, transform) { - const vertices = new Float32Array((cols + 1) * (rows + 1) * (0, _vertexJs.PositionVertex).SIZE); - const position = (0, _glMatrix.vec3).create(); - let index = 0; - for(let row = 0; row <= rows; row++)for(let col = 0; col <= cols; col++){ - (0, _glMatrix.vec3).set(position, col / cols - 0.5, 0.5 - row / rows, 0); - (0, _glMatrix.vec3).transformMat4(position, position, transform); - (0, _vertexJs.PositionVertex).setPosition(vertices, index++, position); - } - return vertices; - } - static indices(cols, rows) { - const indices = new Uint16Array(cols * rows * 6); - let index = 0; - for(let row = 0; row < rows; row++)for(let col = 0; col < cols; col++){ - indices[index++] = col + row * (cols + 1); - indices[index++] = col + (row + 1) * (cols + 1); - indices[index++] = col + row * (cols + 1) + 1; - indices[index++] = col + row * (cols + 1) + 1; - indices[index++] = col + (row + 1) * (cols + 1); - indices[index++] = col + (row + 1) * (cols + 1) + 1; - } - return indices; - } - static textured(cols, rows, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { - const positions = this.positions(cols, rows, transform); - const texCoords = this._texCoords(cols, rows, texTransform); - const vertices = new ArrayBuffer((0, _vertexJs.PositionTextureVertex).SIZE_BYTES * positions.length / 3); - const verticesView = new DataView(vertices); - const position = (0, _glMatrix.vec3).create(); - const texCoord = (0, _glMatrix.vec2).create(); - let index = 0; - for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ - (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); - (0, _vertexJs.PositionTextureVertex).setPosition(verticesView, index, position); - (0, _vertexJs.PositionTextureVertex).setTexCoord(verticesView, index++, texCoord); - } - return verticesView; - } - static normalTextured(cols, rows, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { - const positions = this.positions(cols, rows, transform); - const texCoords = this._texCoords(cols, rows, texTransform); - const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * positions.length / 3); - const verticesView = new DataView(vertices); - const position = (0, _glMatrix.vec3).create(); - const texCoord = (0, _glMatrix.vec2).create(); - let index = 0; - for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ - (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); - (0, _vertexJs.PositionNormalTextureVertex).setPosition(verticesView, index, position); - (0, _vertexJs.PositionNormalTextureVertex).setNormal(verticesView, index, (0, _constantsJs.Constants).VECTOR3_UNITZ); - (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(verticesView, index++, texCoord); - } - return verticesView; - } - static _texCoords(cols, rows, transform) { - const texCoords = new Float32Array((cols + 1) * (rows + 1) * 2); - const texCoord = (0, _glMatrix.vec2).create(); - let index = 0; - for(let row = 0; row <= rows; row++)for(let col = 0; col <= cols; col++){ - (0, _glMatrix.vec2).set(texCoord, col / cols, 1 - row / rows); - (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, transform); - texCoords[index++] = texCoord[0]; - texCoords[index++] = texCoord[1]; - } - return texCoords; - } -} + 5, + 4 +]; +Cube.EDGE_POSITIVES = [ + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(0, 1, 0), + (0, _glMatrix.vec3).fromValues(0, 1, 0), + (0, _glMatrix.vec3).fromValues(0, 1, 0), + (0, _glMatrix.vec3).fromValues(0, 1, 0) +]; +Cube.EDGE_FORWARDS = [ + (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), + (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO) +]; -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ddAub":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "PositionVertex", ()=>PositionVertex); -parcelHelpers.export(exports, "PositionColorVertex", ()=>PositionColorVertex); -parcelHelpers.export(exports, "PositionTextureVertex", ()=>PositionTextureVertex); -parcelHelpers.export(exports, "PositionTexturePickVertex", ()=>PositionTexturePickVertex); -parcelHelpers.export(exports, "PositionNormalVertex", ()=>PositionNormalVertex); -parcelHelpers.export(exports, "PositionNormalColorVertex", ()=>PositionNormalColorVertex); -parcelHelpers.export(exports, "PositionNormalTextureVertex", ()=>PositionNormalTextureVertex); -parcelHelpers.export(exports, "PickGridVertex", ()=>PickGridVertex); -parcelHelpers.export(exports, "UnitVertex", ()=>UnitVertex); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7gWc5":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class PositionVertex { - static getPosition(buffer, index, value) { - const offset = index * PositionVertex.SIZE; - (0, _glMatrix.vec3).set(value, buffer[offset], buffer[offset + 1], buffer[offset + 2]); - } - static setPosition(buffer, index, value) { - const offset = index * PositionVertex.SIZE; - buffer[offset] = value[0]; - buffer[offset + 1] = value[1]; - buffer[offset + 2] = value[2]; - } -} -PositionVertex.SIZE = 3; -PositionVertex.SIZE_BYTES = 12; -class PositionColorVertex { - static getPosition(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); - } - static setPosition(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); - } - static getColor(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF); - } - static setColor(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; - bufferView.setUint8(offset, value[0] * 0xFF); - bufferView.setUint8(offset + 1, value[1] * 0xFF); - bufferView.setUint8(offset + 2, value[2] * 0xFF); - } -} -PositionColorVertex.SIZE_BYTES = 16; -PositionColorVertex.POSITION_OFFSET_BYTES = 0; -PositionColorVertex.COLOR_OFFSET_BYTES = 12; -class PositionTextureVertex { - static getPosition(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); - } - static setPosition(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); - } - static getTexCoord(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); - } - static setTexCoord(bufferView, index, value) { - const offset = PositionColorVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - bufferView.setUint16(offset, value[0] * 0xFFFF, true); - bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); - } -} -PositionTextureVertex.SIZE_BYTES = 16; -PositionTextureVertex.POSITION_OFFSET_BYTES = 0; -PositionTextureVertex.TEX_COORD_OFFSET_BYTES = 12; -class PositionTexturePickVertex { - static getPosition(bufferView, index, value) { - const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); - } - static setPosition(bufferView, index, value) { - const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); - } - static getTexCoord(bufferView, index, value) { - const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); - } - static setTexCoord(bufferView, index, value) { - const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - bufferView.setUint16(offset, value[0] * 0xFFFF, true); - bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); - } - static getIdColor(bufferView, index, value) { - const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; - (0, _glMatrix.vec4).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF, bufferView.getUint8(offset + 3) / 0xFF); - } - static setIdColor(bufferView, index, value) { - const offset = PositionTexturePickVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; - bufferView.setUint8(offset, value[0] * 0xFF); - bufferView.setUint8(offset + 1, value[1] * 0xFF); - bufferView.setUint8(offset + 2, value[2] * 0xFF); - bufferView.setUint8(offset + 3, value[3] * 0xFF); - } -} -PositionTexturePickVertex.SIZE_BYTES = 20; -PositionTexturePickVertex.ID_COLOR_OFFSET_BYTES = 0; -PositionTexturePickVertex.POSITION_OFFSET_BYTES = 4; -PositionTexturePickVertex.TEX_COORD_OFFSET_BYTES = 16; -class PositionNormalVertex { - static getPosition(bufferView, index, value) { - const offset = PositionNormalVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); - } - static setPosition(bufferView, index, value) { - const offset = PositionNormalVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); - } - static getNormal(bufferView, index, value) { - const offset = PositionNormalVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); - } - static setNormal(bufferView, index, value) { - const offset = PositionNormalVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - bufferView.setInt8(offset, value[0] * 0x7F); - bufferView.setInt8(offset + 1, value[1] * 0x7F); - bufferView.setInt8(offset + 2, value[2] * 0x7F); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "MatrixHelper", ()=>MatrixHelper); +class MatrixHelper { + static fieldOfViewFromProjectionMatrix(p) { + return 2 * Math.atan(1 / p[5]); } } -PositionNormalVertex.SIZE_BYTES = 16; -PositionNormalVertex.POSITION_OFFSET_BYTES = 0; -PositionNormalVertex.NORMAL_OFFSET_BYTES = 12; -class PositionNormalColorVertex { - static getPosition(bufferView, index, value) { - const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); - } - static setPosition(bufferView, index, value) { - const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jfjef":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cartesian3dAxesHelper", ()=>Cartesian3dAxesHelper); +parcelHelpers.export(exports, "Cartesian3dAxes", ()=>Cartesian3dAxes); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../../constants.js"); +var _mainJs = require("../../main.js"); +var _axesJs = require("./axes.js"); +var _quadJs = require("../../meshes/quad.js"); +var _cubeJs = require("../../meshes/cube.js"); +var _vertexJs = require("../../vertex.js"); +var _axesJs1 = require("../../helpers/axes.js"); +var _textJs = require("../../helpers/text.js"); +var _pickJs = require("../../helpers/pick.js"); +class Cartesian3dAxesHelper { + static create(core, options) { + const cartesian3dAxes = new Cartesian3dAxes(core); + const minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; + const minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; + const minBoundsZ = options.minBoundsZ === undefined ? 0 : options.minBoundsZ; + const maxBoundsX = options.maxBoundsX === undefined ? 1 : options.maxBoundsX; + const maxBoundsY = options.maxBoundsY === undefined ? 1 : options.maxBoundsY; + const maxBoundsZ = options.maxBoundsZ === undefined ? 1 : options.maxBoundsZ; + const minValueX = options.minValueX === undefined ? 0 : options.minValueX; + const minValueY = options.minValueY === undefined ? 0 : options.minValueY; + const minValueZ = options.minValueZ === undefined ? 0 : options.minValueZ; + const maxValueX = options.maxValueX === undefined ? 1 : options.maxValueX; + const maxValueY = options.maxValueY === undefined ? 1 : options.maxValueY; + const maxValueZ = options.maxValueZ === undefined ? 1 : options.maxValueZ; + const scaling = options.scaling === undefined ? 1 : options.scaling; + cartesian3dAxes.minBoundsX = minBoundsX; + cartesian3dAxes.minBoundsY = minBoundsY; + cartesian3dAxes.minBoundsZ = minBoundsZ; + cartesian3dAxes.maxBoundsX = maxBoundsX; + cartesian3dAxes.maxBoundsY = maxBoundsY; + cartesian3dAxes.maxBoundsZ = maxBoundsZ; + cartesian3dAxes.scalingX = scaling; + cartesian3dAxes.scalingY = scaling; + cartesian3dAxes.scalingZ = scaling; + const maxLength = Math.max(maxBoundsX - minBoundsX, Math.max(maxBoundsY - minBoundsY, maxBoundsZ - minBoundsZ)); + const requestedDivisions = [ + options.divisionsX == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsX - minBoundsX) / maxLength), 1) : options.divisionsX, + options.divisionsY == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsY - minBoundsY) / maxLength), 1) : options.divisionsY, + options.divisionsZ == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsZ - minBoundsZ) / maxLength), 1) : options.divisionsZ + ]; + const minorGridlines = [ + options.minorGridlinesX == undefined ? 2 : options.minorGridlinesX, + options.minorGridlinesY == undefined ? 2 : options.minorGridlinesY, + options.minorGridlinesZ == undefined ? 2 : options.minorGridlinesZ + ]; + const labelMajorSizes = [ + options.labelMajorSizeX === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeX, + options.labelMajorSizeY === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeY, + options.labelMajorSizeZ === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeZ + ]; + const labelMinorSizes = [ + options.labelMinorSizeX === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeX, + options.labelMinorSizeY === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeY, + options.labelMinorSizeZ === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeZ + ]; + cartesian3dAxes.isDiscreteX = options.isDiscreteX; + cartesian3dAxes.isDiscreteY = options.isDiscreteY; + cartesian3dAxes.isDiscreteZ = options.isDiscreteZ; + cartesian3dAxes.isGridPickingEnabled = options.isGridPickingEnabled; + const isDivisionPickingEnabledArray = [ + options.isDivisionPickingEnabledX, + options.isDivisionPickingEnabledY, + options.isDivisionPickingEnabledZ + ]; + const isLabelPickingEnabledArray = [ + options.isLabelPickingEnabledX, + options.isLabelPickingEnabledY, + options.isLabelPickingEnabledZ + ]; + const isAxisReversed = [ + options.reverseX, + options.reverseY, + options.reverseZ + ]; + const labelsArray = [ + options.labelsX, + options.labelsY, + options.labelsZ + ]; + const labelOrientationsArray = [ + options.labelOrientationX, + options.labelOrientationY, + options.labelOrientationZ + ]; + const labelOrientationDefaultArray = [ + (0, _mainJs.AxesTextOrientation).parallel, + (0, _mainJs.AxesTextOrientation).perpendicular, + (0, _mainJs.AxesTextOrientation).parallel + ]; + const areTicksVisibleArray = [ + options.arePickDivisionsVisibleX, + options.arePickDivisionsVisibleY, + options.arePickDivisionsVisibleZ + ]; + const minValueArray = [ + minValueX, + minValueY, + minValueZ + ]; + const maxValueArray = [ + maxValueX, + maxValueY, + maxValueZ + ]; + const isDiscreteArray = [ + options.isDiscreteX, + options.isDiscreteY, + options.isDiscreteZ + ]; + const titleArray = [ + options.titleX, + options.titleY, + options.titleZ + ]; + const titleSizeArray = [ + options.titleSizeX, + options.titleSizeY, + options.titleSizeZ + ]; + const headingArray = [ + options.headingX, + options.headingY, + options.headingZ + ]; + const headingSizeArray = [ + options.headingSizeX, + options.headingSizeY, + options.headingSizeZ + ]; + for(let axisId = 0; axisId < 3; axisId++){ + const label = labelsArray[axisId]; + const minValue = minValueArray[axisId]; + const maxValue = maxValueArray[axisId]; + const discrete = isDiscreteArray[axisId]; + if (discrete) { + const divisions = maxValue - minValue + 1; + const maxDivisions = Math.min(requestedDivisions[axisId], divisions); + const discreteAxisOptions = { + min: minValue, + max: maxValue, + divisions: divisions, + maxDivisions: maxDivisions, + label: label + }; + const discreteAxis = (0, _axesJs1.AxisHelper).discrete(discreteAxisOptions); + cartesian3dAxes.setTickPositions(axisId, discreteAxis.tickPositions); + cartesian3dAxes.setLabelPositions(axisId, discreteAxis.labelPositions); + cartesian3dAxes.setLabels(axisId, discreteAxis.labels); + cartesian3dAxes.setFromValues(axisId, discreteAxis.fromValues); + cartesian3dAxes.setToValues(axisId, discreteAxis.toValues); + cartesian3dAxes.setLabelSizes(axisId, Array(discreteAxis.labels.length).fill(labelMajorSizes[axisId])); + cartesian3dAxes.minorGridlines[axisId] = 1; + } else { + const divisions = requestedDivisions[axisId]; + const continuousAxisOptions = { + min: minValue, + max: maxValue, + divisions: divisions, + label: label + }; + const continuousAxis = (0, _axesJs1.AxisHelper).continuous(continuousAxisOptions); + cartesian3dAxes.setTickPositions(axisId, continuousAxis.positions); + cartesian3dAxes.setLabelPositions(axisId, continuousAxis.positions); + cartesian3dAxes.setLabels(axisId, continuousAxis.labels); + cartesian3dAxes.setFromValues(axisId, continuousAxis.fromValues); + cartesian3dAxes.setToValues(axisId, continuousAxis.toValues); + const labelSizes = []; + for(let i = 0; i < continuousAxis.labels.length; i++)labelSizes.push(i == 0 || i == divisions ? labelMajorSizes[axisId] : labelMinorSizes[axisId]); + cartesian3dAxes.setLabelSizes(axisId, labelSizes); + cartesian3dAxes.minorGridlines[axisId] = minorGridlines[axisId]; + } + cartesian3dAxes.setLabelOrientation(axisId, labelOrientationsArray[axisId] === undefined ? labelOrientationDefaultArray[axisId] : labelOrientationsArray[axisId]); + cartesian3dAxes.setTitle(axisId, titleArray[axisId]); + cartesian3dAxes.setTitleSize(axisId, titleSizeArray[axisId] === undefined ? core.config.axesTextTitleSize : titleSizeArray[axisId]); + cartesian3dAxes.setHeading(axisId, headingArray[axisId]); + cartesian3dAxes.setHeadingSize(axisId, headingSizeArray[axisId] === undefined ? core.config.axesTextHeadingSize : headingSizeArray[axisId]); + cartesian3dAxes.arePickDivisionsVisible[axisId] = areTicksVisibleArray[axisId] === undefined ? true : areTicksVisibleArray[axisId]; + cartesian3dAxes.isDivisionPickingEnabled[axisId] = isDivisionPickingEnabledArray[axisId]; + cartesian3dAxes.isLabelPickingEnabled[axisId] = isLabelPickingEnabledArray[axisId]; + cartesian3dAxes.isAxisReversed[axisId] = isAxisReversed[axisId]; + if (minValue <= 0 && maxValue >= 0 && minValue != maxValue) cartesian3dAxes.zero[axisId] = -minValue / (maxValue - minValue); + else cartesian3dAxes.zero[axisId] = -Number.MAX_VALUE; + } + return cartesian3dAxes; } - static getNormal(bufferView, index, value) { - const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); +} +class Cartesian3dAxes extends (0, _axesJs.AxesBase) { + get size() { + return this._size; } - static setNormal(bufferView, index, value) { - const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - bufferView.setInt8(offset, value[0] * 0x7F); - bufferView.setInt8(offset + 1, value[1] * 0x7F); - bufferView.setInt8(offset + 2, value[2] * 0x7F); + get isDiscreteX() { + return this._isDiscrete[0]; } - static getColor(bufferView, index, value) { - const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF); + set isDiscreteX(value) { + if (value != this._isDiscrete[0]) { + this._isDiscrete[0] = value; + this._hasChanged = true; + } } - static setColor(bufferView, index, value) { - const offset = PositionNormalColorVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; - bufferView.setUint8(offset, value[0] * 0xFF); - bufferView.setUint8(offset + 1, value[1] * 0xFF); - bufferView.setUint8(offset + 2, value[2] * 0xFF); + get isDiscreteY() { + return this._isDiscrete[1]; } -} -PositionNormalColorVertex.SIZE_BYTES = 20; -PositionNormalColorVertex.POSITION_OFFSET_BYTES = 0; -PositionNormalColorVertex.NORMAL_OFFSET_BYTES = 12; -PositionNormalColorVertex.COLOR_OFFSET_BYTES = 16; -class PositionNormalTextureVertex { - static getPosition(bufferView, index, value) { - const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); + set isDiscreteY(value) { + if (value != this._isDiscrete[1]) { + this._isDiscrete[1] = value; + this._hasChanged = true; + } } - static setPosition(bufferView, index, value) { - const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.POSITION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); + get isDiscreteZ() { + return this._isDiscrete[2]; } - static getNormal(bufferView, index, value) { - const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); + set isDiscreteZ(value) { + if (value != this._isDiscrete[2]) { + this._isDiscrete[2] = value; + this._hasChanged = true; + } } - static setNormal(bufferView, index, value) { - const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - bufferView.setInt8(offset, value[0] * 0x7F); - bufferView.setInt8(offset + 1, value[1] * 0x7F); - bufferView.setInt8(offset + 2, value[2] * 0x7F); + get minBoundsX() { + return this._minBoundsX; } - static getTexCoord(bufferView, index, value) { - const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); + set minBoundsX(value) { + if (value != this._minBoundsX) { + this._minBoundsX = value; + this._hasChanged = true; + } } - static setTexCoord(bufferView, index, value) { - const offset = PositionNormalTextureVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - bufferView.setUint16(offset, value[0] * 0xFFFF, true); - bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); + get maxBoundsX() { + return this._maxBoundsX; } -} -PositionNormalTextureVertex.SIZE_BYTES = 20; -PositionNormalTextureVertex.POSITION_OFFSET_BYTES = 0; -PositionNormalTextureVertex.NORMAL_OFFSET_BYTES = 12; -PositionNormalTextureVertex.TEX_COORD_OFFSET_BYTES = 16; -class PickGridVertex { - static getTranslation(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); + set maxBoundsX(value) { + if (value != this._minBoundsX) { + this._maxBoundsX = value; + this._hasChanged = true; + } } - static setTranslation(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); + get minBoundsY() { + return this._minBoundsY; } - static getNormal(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getInt8(offset) / 0x7F, bufferView.getInt8(offset + 1) / 0x7F, bufferView.getInt8(offset + 2) / 0x7F); + set minBoundsY(value) { + if (value != this._minBoundsY) { + this._minBoundsY = value; + this._hasChanged = true; + } } - static setNormal(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.NORMAL_OFFSET_BYTES; - bufferView.setInt8(offset, value[0] * 0x7F); - bufferView.setInt8(offset + 1, value[1] * 0x7F); - bufferView.setInt8(offset + 2, value[2] * 0x7F); + get maxBoundsY() { + return this._maxBoundsY; } - static getIdColor(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; - (0, _glMatrix.vec4).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF, bufferView.getUint8(offset + 3) / 0xFF); + set maxBoundsY(value) { + if (value != this._minBoundsY) { + this._maxBoundsY = value; + this._hasChanged = true; + } } - static setIdColor(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; - bufferView.setUint8(offset, value[0] * 0xFF); - bufferView.setUint8(offset + 1, value[1] * 0xFF); - bufferView.setUint8(offset + 2, value[2] * 0xFF); - bufferView.setUint8(offset + 3, value[3] * 0xFF); + get minBoundsZ() { + return this._minBoundsZ; } - static getTexCoord(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - (0, _glMatrix.vec2).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF); + set minBoundsZ(value) { + if (value != this._minBoundsZ) { + this._minBoundsZ = value; + this._hasChanged = true; + } } - static setTexCoord(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.TEX_COORD_OFFSET_BYTES; - bufferView.setUint16(offset, value[0] * 0xFFFF, true); - bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); + get maxBoundsZ() { + return this._maxBoundsZ; } - static getBounds(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.BOUNDS_OFFSET_BYTES; - (0, _glMatrix.vec4).set(value, bufferView.getUint16(offset, true) / 0xFFFF, bufferView.getUint16(offset + 2, true) / 0xFFFF, bufferView.getUint16(offset + 4, true) / 0xFFFF, bufferView.getUint16(offset + 6, true) / 0xFFFF); + set maxBoundsZ(value) { + if (value != this._minBoundsZ) { + this._maxBoundsZ = value; + this._hasChanged = true; + } } - static setBounds(bufferView, index, value) { - const offset = PickGridVertex.SIZE_BYTES * index + this.BOUNDS_OFFSET_BYTES; - bufferView.setUint16(offset, value[0] * 0xFFFF, true); - bufferView.setUint16(offset + 2, value[1] * 0xFFFF, true); - bufferView.setUint16(offset + 4, value[2] * 0xFFFF, true); - bufferView.setUint16(offset + 6, value[3] * 0xFFFF, true); + getIsOutsideEdge(index) { + return this._isOutsideEdge[index]; } -} -PickGridVertex.SIZE_BYTES = 32; -PickGridVertex.TRANSLATION_OFFSET_BYTES = 0; -PickGridVertex.NORMAL_OFFSET_BYTES = 12; -PickGridVertex.ID_COLOR_OFFSET_BYTES = 16; -PickGridVertex.TEX_COORD_OFFSET_BYTES = 20; -PickGridVertex.BOUNDS_OFFSET_BYTES = 24; -class UnitVertex { - static getIdHover(bufferView, index) { - return bufferView.getFloat32(UnitVertex.SIZE_BYTES * index + this.ID_HOVER_OFFSET_BYTES, true); + getIsForwardFace(index) { + return this._isForwardFace[index]; } - static setIdHover(bufferView, index, value) { - bufferView.setFloat32(UnitVertex.SIZE_BYTES * index + this.ID_HOVER_OFFSET_BYTES, value, true); + get textVertices() { + return this._textVertices; } - static copyIdHover(fromBufferView, fromIndex, toBufferView, toIndex) { - toBufferView.setFloat32(UnitVertex.SIZE_BYTES * toIndex + this.ID_HOVER_OFFSET_BYTES, fromBufferView.getFloat32(UnitVertex.SIZE_BYTES * fromIndex + this.ID_HOVER_OFFSET_BYTES, true), true); + get textIndices() { + return this._textIndices; } - static getTranslation(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); + getLabelMMatrix(index) { + return this._labelMMatrices[index]; } - static setTranslation(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.TRANSLATION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); + setLabelPositions(index, value) { + if (this._labelPositions[index] != value) { + this._labelPositions[index] = value; + this._hasChanged = true; + } } - static copyTranslation(fromBufferView, fromIndex, toBufferView, toIndex) { - const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.TRANSLATION_OFFSET_BYTES; - const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.TRANSLATION_OFFSET_BYTES; - toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); - toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); - toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); + setLabels(index, value) { + if (this._labels[index] != value) { + this._labels[index] = value; + this._hasChanged = true; + } } - static getColor(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; - (0, _glMatrix.vec2).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF); + setLabelSizes(index, value) { + if (this._labelSizes[index] != value) { + this._labelSizes[index] = value; + this._hasChanged = true; + } } - static setColor(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.COLOR_OFFSET_BYTES; - bufferView.setUint8(offset, value[0] * 0xFF); - bufferView.setUint8(offset + 1, value[1] * 0xFF); + getLabelOrientation(index) { + return this._orientations[index]; } - static copyColor(fromBufferView, fromIndex, toBufferView, toIndex) { - const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.COLOR_OFFSET_BYTES; - const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.COLOR_OFFSET_BYTES; - toBufferView.setUint8(toOffset, fromBufferView.getUint8(fromOffset)); - toBufferView.setUint8(toOffset + 1, fromBufferView.getUint8(fromOffset + 1)); + setLabelOrientation(index, orientation) { + if (this._orientations[index] != orientation) { + this._orientations[index] = orientation; + this._hasChanged = true; + } } - static getOrder(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.ORDER_OFFSET_BYTES; - (0, _glMatrix.vec2).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true)); + getTitleIndexCount(index) { + return this._titleIndexCounts[index]; } - static setOrder(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.ORDER_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); + getTitleIndexOffset(index) { + return this._titleIndexOffsets[index]; } - static copyOrder(fromBufferView, fromIndex, toBufferView, toIndex) { - const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.ORDER_OFFSET_BYTES; - const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.ORDER_OFFSET_BYTES; - toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); - toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); + getTitleMMatrix(index) { + return this._titleMMatrices[index]; } - static getScale(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.SCALE_OFFSET_BYTES; - (0, _glMatrix.vec3).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true)); + setTitle(index, value) { + if (this._titles[index] != value) { + this._titles[index] = value; + this._hasChanged = true; + } } - static setScale(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.SCALE_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); + setTitleSize(index, value) { + if (this._titleSizes[index] != value) { + this._titleSizes[index] = value; + this._hasChanged = true; + } } - static copyScale(fromBufferView, fromIndex, toBufferView, toIndex) { - const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.SCALE_OFFSET_BYTES; - const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.SCALE_OFFSET_BYTES; - toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); - toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); - toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); + getHeadingIndexCount(index) { + return this._headingIndexCounts[index]; } - static getRotation(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.ROTATION_OFFSET_BYTES; - (0, _glMatrix.quat).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true), bufferView.getFloat32(offset + 12, true)); + getHeadingIndexOffset(index) { + return this._headingIndexOffsets[index]; } - static setRotation(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.ROTATION_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); - bufferView.setFloat32(offset + 12, value[3], true); + getHeadingMMatrix(index) { + return this._headingMMatrices[index]; } - static copyRotation(fromBufferView, fromIndex, toBufferView, toIndex) { - const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.ROTATION_OFFSET_BYTES; - const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.ROTATION_OFFSET_BYTES; - toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); - toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); - toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); - toBufferView.setFloat32(toOffset + 12, fromBufferView.getFloat32(fromOffset + 12, true), true); + setHeading(index, value) { + if (this._headings[index] != value) { + this._headings[index] = value; + this._hasChanged = true; + } } - static getTexCoord(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.TEXCOORD_OFFSET_BYTES; - (0, _glMatrix.quat).set(value, bufferView.getFloat32(offset, true), bufferView.getFloat32(offset + 4, true), bufferView.getFloat32(offset + 8, true), bufferView.getFloat32(offset + 12, true)); + setHeadingSize(index, value) { + if (this._headingSizes[index] != value) { + this._headingSizes[index] = value; + this._hasChanged = true; + } } - static setTexCoord(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.TEXCOORD_OFFSET_BYTES; - bufferView.setFloat32(offset, value[0], true); - bufferView.setFloat32(offset + 4, value[1], true); - bufferView.setFloat32(offset + 8, value[2], true); - bufferView.setFloat32(offset + 12, value[3], true); + getIsLeftToRightHorizontal(index) { + return this._isLeftToRightHorizontal[index]; } - static copyTexCoord(fromBufferView, fromIndex, toBufferView, toIndex) { - const fromOffset = UnitVertex.SIZE_BYTES * fromIndex + this.TEXCOORD_OFFSET_BYTES; - const toOffset = UnitVertex.SIZE_BYTES * toIndex + this.TEXCOORD_OFFSET_BYTES; - toBufferView.setFloat32(toOffset, fromBufferView.getFloat32(fromOffset, true), true); - toBufferView.setFloat32(toOffset + 4, fromBufferView.getFloat32(fromOffset + 4, true), true); - toBufferView.setFloat32(toOffset + 8, fromBufferView.getFloat32(fromOffset + 8, true), true); - toBufferView.setFloat32(toOffset + 12, fromBufferView.getFloat32(fromOffset + 12, true), true); + getIsLeftToRightVertical(index) { + return this._isLeftToRightVertical[index]; } - static getIdColor(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; - (0, _glMatrix.vec4).set(value, bufferView.getUint8(offset) / 0xFF, bufferView.getUint8(offset + 1) / 0xFF, bufferView.getUint8(offset + 2) / 0xFF, bufferView.getUint8(offset + 3) / 0xFF); + getAxesLeftToRightIndexCount(index) { + return this._axesLeftToRightIndexCounts[index]; } - static setIdColor(bufferView, index, value) { - const offset = UnitVertex.SIZE_BYTES * index + this.ID_COLOR_OFFSET_BYTES; - bufferView.setUint8(offset, value[0] * 0xFF); - bufferView.setUint8(offset + 1, value[1] * 0xFF); - bufferView.setUint8(offset + 2, value[2] * 0xFF); - bufferView.setUint8(offset + 3, value[3] * 0xFF); + getAxesRightToLeftIndexCount(index) { + return this._axesRightToLeftIndexCounts[index]; } - static getSelected(bufferView, index) { - return bufferView.getInt8(UnitVertex.SIZE_BYTES * index + this.SELECTED_OFFSET_BYTES) / 0x7F; + getAxesLeftToRightIndexOffset(index) { + return this._axesLeftToRightIndexOffsets[index]; } - static setSelected(bufferView, index, value) { - bufferView.setInt8(UnitVertex.SIZE_BYTES * index + this.SELECTED_OFFSET_BYTES, value * 0x7F); + getAxesRightToLeftIndexOffset(index) { + return this._axesRightToLeftIndexOffsets[index]; } - static copySelected(fromBufferView, fromIndex, toBufferView, toIndex) { - toBufferView.setInt8(UnitVertex.SIZE_BYTES * toIndex + this.SELECTED_OFFSET_BYTES, fromBufferView.getInt8(UnitVertex.SIZE_BYTES * fromIndex + this.SELECTED_OFFSET_BYTES)); + get gridVertices() { + return this._gridVertices; } - static getRounding(bufferView, index) { - return bufferView.getFloat32(UnitVertex.SIZE_BYTES * index + this.ROUNDING_OFFSET_BYTES, true); + get gridIndices() { + return this._gridIndices; } - static setRounding(bufferView, index, value) { - bufferView.setFloat32(UnitVertex.SIZE_BYTES * index + this.ROUNDING_OFFSET_BYTES, value, true); + getGridTicksIndexCount(index) { + return this._gridTicksIndexCounts[index]; } - static copyRounding(fromBufferView, fromIndex, toBufferView, toIndex) { - toBufferView.setFloat32(UnitVertex.SIZE_BYTES * toIndex + this.ROUNDING_OFFSET_BYTES, fromBufferView.getFloat32(UnitVertex.SIZE_BYTES * fromIndex + this.ROUNDING_OFFSET_BYTES, true), true); + getGridTicksIndexOffset(index) { + return this._gridTicksIndexOffsets[index]; } - static getMaterial(bufferView, index) { - return bufferView.getUint16(UnitVertex.SIZE_BYTES * index + this.MATERIAL_OFFSET_BYTES); + getGridFaceIndexCount(index) { + return this._gridFaceIndexCounts[index]; } - static setMaterial(bufferView, index, value) { - bufferView.setUint16(UnitVertex.SIZE_BYTES * index + this.MATERIAL_OFFSET_BYTES, value); + getGridFaceIndexOffset(index) { + return this._gridFaceIndexOffsets[index]; } - static copyMaterial(fromBufferView, fromIndex, toBufferView, toIndex) { - toBufferView.setUint16(UnitVertex.SIZE_BYTES * toIndex + this.MATERIAL_OFFSET_BYTES, fromBufferView.getUint16(UnitVertex.SIZE_BYTES * fromIndex + this.MATERIAL_OFFSET_BYTES, true), true); + getGridTicksMMatrix(index) { + return this._gridTicksMMatrices[index]; } -} -UnitVertex.SIZE_BYTES = 84; -UnitVertex.ID_HOVER_OFFSET_BYTES = 0; -UnitVertex.ID_COLOR_OFFSET_BYTES = 4; -UnitVertex.ORDER_OFFSET_BYTES = 8; -UnitVertex.STAGGER_ORDER_OFFSET_BYTES = 12; -UnitVertex.SELECTED_OFFSET_BYTES = 80; -UnitVertex.TRANSLATION_OFFSET_BYTES = 16; -UnitVertex.COLOR_OFFSET_BYTES = 28; -UnitVertex.MATERIAL_OFFSET_BYTES = 30; -UnitVertex.SCALE_OFFSET_BYTES = 32; -UnitVertex.ROUNDING_OFFSET_BYTES = 44; -UnitVertex.ROTATION_OFFSET_BYTES = 48; -UnitVertex.TEXCOORD_OFFSET_BYTES = 64; - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7rTMs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cube", ()=>Cube); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -class Cube { -} -Cube.POSITIONS = new Float32Array([ - -0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - -0.5, - 0.5, - -0.5, - -0.5, - 0.5, - -0.5, - 0.5, - -0.5, - 0.5, - 0.5, - -0.5, - 0.5, - -0.5, - -0.5, - -0.5, - -0.5, - -0.5 -]); -Cube.INDICES = new Uint16Array([ - 5, - 4, - 1, - 0, - 3, - 4, - 7, - 5, - 6, - 1, - 2, - 3, - 6, - 7 -]); -Cube.CUBE_MAP_INDICES = new Uint16Array([ - 2, - 3, - 1, - 0, - 4, - 3, - 7, - 2, - 6, - 1, - 5, - 4, - 6, - 7 -]); -Cube.FACE_NORMALS = [ - (0, _glMatrix.vec3).fromValues(0, 1, 0), - (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, -1, 0), - (0, _glMatrix.vec3).fromValues(-1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, 0, 1), - (0, _glMatrix.vec3).fromValues(0, 0, -1) -]; -Cube.FACE_POSITIONS = [ - (0, _glMatrix.vec3).fromValues(0.0, 0.5, 0.0), - (0, _glMatrix.vec3).fromValues(0.5, 0.0, 0.0), - (0, _glMatrix.vec3).fromValues(0.0, -0.5, 0.0), - (0, _glMatrix.vec3).fromValues(-0.5, 0.0, 0.0), - (0, _glMatrix.vec3).fromValues(0.0, 0.0, 0.5), - (0, _glMatrix.vec3).fromValues(0.0, 0.0, -0.5) -]; -Cube.FACE_ROTATIONS = [ - (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 0, -1, 0, 1, 0), - (0, _glMatrix.mat3).fromValues(0, 0, -1, 0, 1, 0, 1, 0, 0), - (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 0, 1, 0, -1, 0), - (0, _glMatrix.mat3).fromValues(0, 0, 1, 0, 1, 0, -1, 0, 0), - (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 1, 0, 0, 0, 1), - (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, -1, 0, 0, 0, -1) -]; -Cube.EDGE_POSITIONS = [ - (0, _glMatrix.vec3).fromValues(0, 0.5, 0.5), - (0, _glMatrix.vec3).fromValues(0.5, 0.5, 0), - (0, _glMatrix.vec3).fromValues(0, 0.5, -0.5), - (0, _glMatrix.vec3).fromValues(-0.5, 0.5, 0), - (0, _glMatrix.vec3).fromValues(0, -0.5, 0.5), - (0, _glMatrix.vec3).fromValues(0.5, -0.5, 0), - (0, _glMatrix.vec3).fromValues(0, -0.5, -0.5), - (0, _glMatrix.vec3).fromValues(-0.5, -0.5, 0), - (0, _glMatrix.vec3).fromValues(0.5, 0, 0.5), - (0, _glMatrix.vec3).fromValues(0.5, 0, -0.5), - (0, _glMatrix.vec3).fromValues(-0.5, 0, -0.5), - (0, _glMatrix.vec3).fromValues(-0.5, 0, 0.5) -]; -Cube.EDGE_NORMALS = [ - (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO) -]; -Cube.EDGE_CORNERS = [ - [ - 0, - 1 - ], - [ - 1, - 5 - ], - [ - 4, - 5 - ], - [ - 0, - 4 - ], - [ - 2, - 3 - ], - [ - 2, - 6 - ], - [ - 6, - 7 - ], - [ - 3, - 7 - ], - [ - 1, - 2 - ], - [ - 5, - 6 - ], - [ - 4, - 7 - ], - [ - 0, - 3 - ] -]; -Cube.EDGE_FACES = [ - [ - 0, - 4 - ], - [ - 0, - 1 - ], - [ - 0, - 5 - ], - [ - 0, - 3 - ], - [ - 2, - 4 - ], - [ - 2, - 1 - ], - [ - 2, - 5 - ], - [ - 2, - 3 - ], - [ - 1, - 4 - ], - [ - 1, - 5 - ], - [ - 3, - 5 - ], - [ - 3, - 4 - ] -]; -Cube.EDGE_AXIS = [ - 0, - 2, - 0, - 2, - 0, - 2, - 0, - 2, - 1, - 1, - 1, - 1 -]; -Cube.AXIS_EDGES = [ - [ - 0, - 2, - 4, - 6 - ], - [ - 8, - 9, - 10, - 11 - ], - [ - 1, - 3, - 5, - 7 - ] -]; -Cube.AXIS_FACES = [ - [ - 1, - 3 - ], - [ - 0, - 2 - ], - [ - 4, - 5 - ] -]; -Cube.OPPOSITE_FACES = [ - 2, - 3, - 0, - 1, - 5, - 4 -]; -Cube.EDGE_POSITIVES = [ - (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, 0, 1), - (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, 0, 1), - (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, 0, 1), - (0, _glMatrix.vec3).fromValues(1, 0, 0), - (0, _glMatrix.vec3).fromValues(0, 0, 1), - (0, _glMatrix.vec3).fromValues(0, 1, 0), - (0, _glMatrix.vec3).fromValues(0, 1, 0), - (0, _glMatrix.vec3).fromValues(0, 1, 0), - (0, _glMatrix.vec3).fromValues(0, 1, 0) -]; -Cube.EDGE_FORWARDS = [ - (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, (0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues((0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO), - (0, _glMatrix.vec3).fromValues(-(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO, 0, -(0, _constantsJs.Constants).ROOT_TWO_OVER_TWO) -]; - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8BmXc":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "AxisHelper", ()=>AxisHelper); -class AxisHelper { - static continuous(options) { - const labels = []; - const positions = []; - const fromValues = []; - const toValues = []; - const label = options.label || ((value)=>{ - return value.toString(); - }); - for(let i = 0; i <= options.divisions; i++){ - positions.push(options.divisions == 0 ? 0.5 : i / options.divisions); - const value = options.divisions == 0 ? (options.min + options.max) / 2 : options.min + i * (options.max - options.min) / options.divisions; - labels.push(label(value)); - if (i == 0) fromValues.push(options.min); - else if (i < options.divisions) { - toValues.push(value); - fromValues.push(value); - } + getGridFaceMMatrix(index) { + return this._gridFaceMMatrices[index]; + } + getGridTicksScale(index) { + return this._gridTicksScales[index]; + } + getGridFaceZero(index) { + return this._gridFaceZeros[index]; + } + getGridTicksZero(index) { + return this._gridTicksZeros[index]; + } + getGridFaceMinorGridlines(index) { + return this._gridFaceMinorGridlines[index]; + } + getGridTicksMinorGridlines(index) { + return this._gridTicksMinorGridlines[index]; + } + setTickPositions(index, value) { + if (this._gridTicksPositions[index] != value) { + this._gridTicksPositions[index] = value; + this._hasChanged = true; } - toValues.push(options.max); - return { - labels: labels, - positions: positions, - fromValues: fromValues, - toValues: toValues - }; } - static discrete(options) { - const divisions = options.maxDivisions !== undefined ? Math.min(options.divisions, options.maxDivisions) : options.divisions; - const divisionStep = 1 / options.divisions; - const labelStep = 1 / divisions; - const valueStep = (options.max - options.min + 1) / options.divisions; - let nextDivision, toValue, nextPosition; - const labels = []; - const labelPositions = []; - const tickPositions = []; - const fromValues = []; - const toValues = []; - const label = options.label || ((value)=>{ - return value.toString(); - }); - const fromToLabel = options.fromToLabel || ((fromValue, toValue)=>{ - return `${label(fromValue)}-${label(toValue)}`; - }); - for(let i = 0; i < divisions; i++){ - const division = Math.round(i * labelStep / divisionStep); - const tickPosition = division / options.divisions; - const fromValue = options.min + Math.ceil(division * valueStep); - if (i == divisions - 1) { - nextDivision = divisions; - nextPosition = 1; - toValue = options.max; - } else { - nextDivision = Math.round((i + 1) * labelStep / divisionStep); - nextPosition = nextDivision / options.divisions; - toValue = options.min + Math.ceil(nextDivision * valueStep) - 1; - } - labelPositions.push((tickPosition + nextPosition) / 2); - labels.push(fromValue == toValue ? label(fromValue) : fromToLabel(fromValue, toValue)); - fromValues.push(fromValue); - toValues.push(toValue); - tickPositions.push(tickPosition); + get scalingX() { + return this._scalingX; + } + set scalingX(value) { + if (value != this._scalingX) { + this._scalingX = value; + this._hasChanged = true; } - tickPositions.push(1); - return { - labels: labels, - labelPositions: labelPositions, - tickPositions: tickPositions, - fromValues: fromValues, - toValues: toValues - }; } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"l2V9O":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "TextHelper", ()=>TextHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _vertexJs = require("../vertex.js"); -var _quadJs = require("../meshes/quad.js"); -class TextHelper { - static truncate(text, length) { - return text.length > length ? `${text.substr(0, length - 1)}…` : text; + get scalingY() { + return this._scalingY; } - static measure(font, text, size) { - size.width = 0; - let maxDescent = 0; - for (const char of text){ - let glyph = font.glyphs[char]; - if (!glyph) { - font.addGlyph(char); - glyph = font.glyphs[char]; - } - size.width += glyph.advance; - size.maxTop = Math.max(glyph.top, size.maxTop); - maxDescent = Math.max(glyph.height - glyph.top, maxDescent); + set scalingY(value) { + if (value != this._scalingY) { + this._scalingY = value; + this._hasChanged = true; } - size.maxHeight = size.maxTop + maxDescent; } - static wrap(font, text, maxWidth) { - const lines = []; - let width = 0; - let start = 0; - let lastBreakingChar = -1; - let widthAfterLastBreakingChar = 0; - for(let i = 0; i < text.length; i++){ - let char = text.charAt(i); - let glyph = font.glyphs[char]; - if (!glyph) { - font.addGlyph(char); - glyph = font.glyphs[char]; - } - width += glyph.advance; - if (char == " " || char == "-") { - widthAfterLastBreakingChar = width; - lastBreakingChar = i; - } - if (width > maxWidth) { - if (lastBreakingChar == -1) { - lines.push(text.substring(start, i)); - start = i; - width += glyph.advance; - } else { - lines.push(text.substring(start, lastBreakingChar)); - start = lastBreakingChar + 1; - width -= widthAfterLastBreakingChar; - widthAfterLastBreakingChar = 0; - lastBreakingChar = -1; - } - } - } - lines.push(text.substring(start, text.length)); - return lines; - } - static addString(font, text, vertices, indices, index, position, scale, offset, rotation, idColor) { - for (const char of text)this.addGlyph(font, char, vertices, indices, index++, position, scale, offset, rotation, idColor); + get scalingZ() { + return this._scalingZ; } - static addGlyph(font, char, vertices, indices, index, position, scale, offset, rotation, idColor) { - let glyph = font.glyphs[char]; - if (!glyph) { - font.addGlyph(char); - glyph = font.glyphs[char]; - } - const vertexOffset = index * 4; - const width = glyph.width * scale; - const height = glyph.height * scale; - const top = glyph.top * scale; - const border = font.border * scale; - const x0 = offset[0] - border; - const x1 = offset[0] + width + border; - const y0 = offset[1] + top + border; - const y1 = offset[1] + top - height - border; - const z0 = offset[2]; - (0, _glMatrix.vec3).set(this._topLeft, x0, y0, z0); - (0, _glMatrix.vec3).set(this._topRight, x1, y0, z0); - (0, _glMatrix.vec3).set(this._bottomLeft, x0, y1, z0); - (0, _glMatrix.vec3).set(this._bottomRight, x1, y1, z0); - if (rotation) { - (0, _glMatrix.vec3).transformQuat(this._topLeft, this._topLeft, rotation); - (0, _glMatrix.vec3).transformQuat(this._topRight, this._topRight, rotation); - (0, _glMatrix.vec3).transformQuat(this._bottomLeft, this._bottomLeft, rotation); - (0, _glMatrix.vec3).transformQuat(this._bottomRight, this._bottomRight, rotation); + set scalingZ(value) { + if (value != this._scalingZ) { + this._scalingZ = value; + this._hasChanged = true; } - (0, _glMatrix.vec3).add(this._vec3, this._topLeft, position); - (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset, this._vec3); - (0, _glMatrix.vec3).add(this._vec3, this._topRight, position); - (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset + 1, this._vec3); - (0, _glMatrix.vec3).add(this._vec3, this._bottomLeft, position); - (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset + 2, this._vec3); - (0, _glMatrix.vec3).add(this._vec3, this._bottomRight, position); - (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset + 3, this._vec3); - (0, _glMatrix.vec2).set(this._vec2, glyph.u0, glyph.v0); - (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset, this._vec2); - (0, _glMatrix.vec2).set(this._vec2, glyph.u1, glyph.v0); - (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset + 1, this._vec2); - (0, _glMatrix.vec2).set(this._vec2, glyph.u0, glyph.v1); - (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset + 2, this._vec2); - (0, _glMatrix.vec2).set(this._vec2, glyph.u1, glyph.v1); - (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset + 3, this._vec2); - (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset, idColor); - (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset + 1, idColor); - (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset + 2, idColor); - (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset + 3, idColor); - offset[0] += glyph.advance * scale; - const indexTemplate = (0, _quadJs.Quad).INDICES; - const indexOffset = index * 6; - for(let i = 0; i < 6; i++)indices[indexOffset + i] = indexTemplate[i] + vertexOffset; - } -} -TextHelper._vec2 = (0, _glMatrix.vec2).create(); -TextHelper._vec3 = (0, _glMatrix.vec3).create(); -TextHelper._topLeft = (0, _glMatrix.vec3).create(); -TextHelper._topRight = (0, _glMatrix.vec3).create(); -TextHelper._bottomLeft = (0, _glMatrix.vec3).create(); -TextHelper._bottomRight = (0, _glMatrix.vec3).create(); - -},{"gl-matrix":"9GjEQ","../vertex.js":"ddAub","../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9zmDo":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "PickHelper", ()=>PickHelper); -class PickHelper { - static nextPickId() { - return this._pickId++; - } - static encodeNumber(number, type, color) { - const encoded = number | PickHelper.encodeType(type); - PickHelper.float32ToVec4(encoded, color); - } - static decodeNumber(color) { - return color[0] + (color[1] << 8) + (color[2] << 16); } - static encodeVec3(vec3, type, color) { - const encoded = vec3[0] | vec3[1] << 8 | vec3[2] << 16 | PickHelper.encodeType(type); - PickHelper.float32ToVec4(encoded, color); + get offsetX() { + return this._offset[12]; } - static decodeVec3(color, axes) { - axes[0] = color[0]; - axes[1] = color[1]; - axes[2] = color[2]; + set offsetX(value) { + if (value != this._offset[12]) this._offset[12] = value; } - static encodeType(type) { - return type << 24; + get offsetY() { + return this._offset[13]; } - static decodeType(color) { - return color[3]; + set offsetY(value) { + if (value != this._offset[13]) this._offset[13] = value; } - static float32ToVec4(number, color) { - color[0] = ((number & 0xFF) >>> 0) / 0xFF; - color[1] = ((number & 0xFF00) >>> 8) / 0xFF; - color[2] = ((number & 0xFF0000) >>> 16) / 0xFF; - color[3] = ((number & 0xFF000000) >>> 24) / 0xFF; + get offsetZ() { + return this._offset[14]; } - static uint8ArrayToNumber(color) { - return color[0] + (color[1] << 8) + (color[2] << 16) + (color[3] << 24); + set offsetZ(value) { + if (value != this._offset[14]) this._offset[14] = value; } -} -PickHelper._pickId = 1; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7HjCZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cartesian2dAxesHelper", ()=>Cartesian2dAxesHelper); -parcelHelpers.export(exports, "Cartesian2dAxes", ()=>Cartesian2dAxes); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../../constants.js"); -var _mainJs = require("../../main.js"); -var _axesJs = require("./axes.js"); -var _quadJs = require("../../meshes/quad.js"); -var _vertexJs = require("../../vertex.js"); -var _axesJs1 = require("../../helpers/axes.js"); -var _textJs = require("../../helpers/text.js"); -var _pickJs = require("../../helpers/pick.js"); -class Cartesian2dAxesHelper { - static create(core, options) { - const cartesian2dAxes = new Cartesian2dAxes(core); - const minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; - const minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; - const maxBoundsX = options.maxBoundsX === undefined ? 1 : options.maxBoundsX; - const maxBoundsY = options.maxBoundsY === undefined ? 1 : options.maxBoundsY; - const minValueX = options.minValueX === undefined ? 0 : options.minValueX; - const minValueY = options.minValueY === undefined ? 0 : options.minValueY; - const maxValueX = options.maxValueX === undefined ? 1 : options.maxValueX; - const maxValueY = options.maxValueY === undefined ? 1 : options.maxValueY; - const scaling = options.scaling === undefined ? 1 : options.scaling; - cartesian2dAxes.minBoundsX = minBoundsX; - cartesian2dAxes.minBoundsY = minBoundsY; - cartesian2dAxes.maxBoundsX = maxBoundsX; - cartesian2dAxes.maxBoundsY = maxBoundsY; - cartesian2dAxes.scalingX = scaling; - cartesian2dAxes.scalingY = scaling; - const maxLength = Math.max(maxBoundsX - minBoundsX, maxBoundsY - minBoundsY); - const requestedDivisions = [ - options.divisionsX == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsX - minBoundsX) / maxLength), 1) : options.divisionsX, - options.divisionsY == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsY - minBoundsY) / maxLength), 1) : options.divisionsY, - ]; - const minorGridlines = [ - options.minorGridlinesX == undefined ? 2 : options.minorGridlinesX, - options.minorGridlinesY == undefined ? 2 : options.minorGridlinesY, - ]; - const labelMajorSizes = [ - options.labelMajorSizeX === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeX, - options.labelMajorSizeY === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeY - ]; - const labelMinorSizes = [ - options.labelMinorSizeX === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeX, - options.labelMinorSizeY === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeY - ]; - cartesian2dAxes.isDiscreteX = options.isDiscreteX; - cartesian2dAxes.isDiscreteY = options.isDiscreteY; - cartesian2dAxes.isGridPickingEnabled = options.isGridPickingEnabled; - const isDivisionPickingEnabledArray = [ - options.isDivisionPickingEnabledX, - options.isDivisionPickingEnabledY, - ]; - const isLabelPickingEnabled = [ - options.isLabelPickingEnabledX, - options.isLabelPickingEnabledY, - ]; - const isAxisReversed = [ - options.reverseX, - options.reverseY - ]; - const labelsArray = [ - options.labelsX, - options.labelsY - ]; - const labelOrientationsArray = [ - options.labelOrientationX, - options.labelOrientationY - ]; - const labelOrientationDefaultArray = [ - (0, _mainJs.AxesTextOrientation).parallel, - (0, _mainJs.AxesTextOrientation).perpendicular, - (0, _mainJs.AxesTextOrientation).parallel - ]; - const arePickDivisionsVisibleArray = [ - options.arePickDivisionsVisibleX, - options.arePickDivisionsVisibleY - ]; - const minValueArray = [ - minValueX, - minValueY - ]; - const maxValueArray = [ - maxValueX, - maxValueY - ]; - const isDiscreteArray = [ - options.isDiscreteX, - options.isDiscreteY - ]; - const titleArray = [ - options.titleX, - options.titleY - ]; - const titleSizeArray = [ - options.titleSizeX, - options.titleSizeY - ]; - const headingArray = [ - options.headingX, - options.headingY - ]; - const headingSizeArray = [ - options.headingSizeX, - options.headingSizeY + constructor(core){ + super(core); + this._size = (0, _glMatrix.vec3).create(); + this._translation = (0, _glMatrix.vec3).create(); + this._normal = (0, _glMatrix.vec3).create(); + this._forward = (0, _glMatrix.vec3).create(); + this._right = (0, _glMatrix.vec3).create(); + this._up = (0, _glMatrix.vec3).create(); + this._texCoord = (0, _glMatrix.vec2).create(); + this._bounds = (0, _glMatrix.vec4).create(); + this._vec3 = (0, _glMatrix.vec3).create(); + this._vec4 = (0, _glMatrix.vec4).create(); + this._mat3 = (0, _glMatrix.mat3).create(); + this._isDiscrete = [ + false, + false, + false ]; - for(let axisId = 0; axisId < 2; axisId++){ - const label = labelsArray[axisId]; - const minValue = minValueArray[axisId]; - const maxValue = maxValueArray[axisId]; - const discrete = isDiscreteArray[axisId]; - if (discrete) { - const divisions = maxValue - minValue + 1; - const maxDivisions = Math.min(requestedDivisions[axisId], divisions); - const discreteAxisOptions = { - min: minValue, - max: maxValue, - divisions: divisions, - maxDivisions: maxDivisions, - label: label - }; - const discreteAxis = (0, _axesJs1.AxisHelper).discrete(discreteAxisOptions); - cartesian2dAxes.setTickPositions(axisId, discreteAxis.tickPositions); - cartesian2dAxes.setLabelPositions(axisId, discreteAxis.labelPositions); - cartesian2dAxes.setLabels(axisId, discreteAxis.labels); - cartesian2dAxes.setFromValues(axisId, discreteAxis.fromValues); - cartesian2dAxes.setToValues(axisId, discreteAxis.toValues); - cartesian2dAxes.setLabelSizes(axisId, Array(discreteAxis.labels.length).fill(labelMajorSizes[axisId])); - cartesian2dAxes.minorGridlines[axisId] = 1; - } else { - const divisions1 = requestedDivisions[axisId]; - const continuousAxisOptions = { - min: minValue, - max: maxValue, - divisions: divisions1, - label: label - }; - const continuousAxis = (0, _axesJs1.AxisHelper).continuous(continuousAxisOptions); - cartesian2dAxes.setTickPositions(axisId, continuousAxis.positions); - cartesian2dAxes.setLabelPositions(axisId, continuousAxis.positions); - cartesian2dAxes.setLabels(axisId, continuousAxis.labels); - cartesian2dAxes.setFromValues(axisId, continuousAxis.fromValues); - cartesian2dAxes.setToValues(axisId, continuousAxis.toValues); - const labelSizes = []; - for(let i = 0; i < continuousAxis.labels.length; i++)labelSizes.push(i == 0 || i == divisions1 ? labelMajorSizes[axisId] : labelMinorSizes[axisId]); - cartesian2dAxes.setLabelSizes(axisId, labelSizes); - cartesian2dAxes.minorGridlines[axisId] = minorGridlines[axisId]; - } - cartesian2dAxes.setLabelOrientation(axisId, labelOrientationsArray[axisId] === undefined ? labelOrientationDefaultArray[axisId] : labelOrientationsArray[axisId]); - cartesian2dAxes.setTitle(axisId, titleArray[axisId]); - cartesian2dAxes.setTitleSize(axisId, titleSizeArray[axisId] === undefined ? core.config.axesTextTitleSize : titleSizeArray[axisId]); - cartesian2dAxes.setHeading(axisId, headingArray[axisId]); - cartesian2dAxes.setHeadingSize(axisId, headingSizeArray[axisId] === undefined ? core.config.axesTextHeadingSize : headingSizeArray[axisId]); - cartesian2dAxes.arePickDivisionsVisible[axisId] = arePickDivisionsVisibleArray[axisId] === undefined ? true : arePickDivisionsVisibleArray[axisId]; - cartesian2dAxes.isDivisionPickingEnabled[axisId] = isDivisionPickingEnabledArray[axisId]; - cartesian2dAxes.isLabelPickingEnabled[axisId] = isLabelPickingEnabled[axisId]; - cartesian2dAxes.isAxisReversed[axisId] = isAxisReversed[axisId]; - if (minValue <= 0 && maxValue >= 0) cartesian2dAxes.zero[axisId] = -minValue / (maxValue - minValue); - else cartesian2dAxes.zero[axisId] = -Number.MAX_VALUE; + this._minBoundsX = 0; + this._minBoundsY = 0; + this._minBoundsZ = 0; + this._maxBoundsX = 0; + this._maxBoundsY = 0; + this._maxBoundsZ = 0; + this._isForwardFace = []; + this._isForwardEdge = []; + this._isOutsideEdge = []; + for(let i = 0; i < 6; i++)this._isForwardFace.push(false); + for(let i = 0; i < 12; i++){ + this._isForwardEdge.push(false); + this._isOutsideEdge.push(false); } - return cartesian2dAxes; - } -} -class Cartesian2dAxes extends (0, _axesJs.AxesBase) { - get size() { - return this._size; - } - get isDiscreteX() { - return this._isDiscrete[0]; - } - set isDiscreteX(value) { - if (value != this._isDiscrete[0]) { - this._isDiscrete[0] = value; - this._hasChanged = true; + this._textOffset = (0, _glMatrix.vec3).create(); + this._textPosition = (0, _glMatrix.vec3).create(); + this._distances = []; + for(let i = 0; i < 12; i++)this._distances.push(0); + this._labelPositions = []; + this._labels = []; + this._labelSizes = []; + this._maxLabelSize = []; + this._axesLeftToRightIndexCounts = []; + this._axesRightToLeftIndexCounts = []; + this._axesLeftToRightIndexOffsets = []; + this._axesRightToLeftIndexOffsets = []; + this._labelMMatrices = []; + this._orientations = []; + for(let i = 0; i < 3; i++){ + this._maxLabelSize.push((0, _glMatrix.vec2).create()); + this._orientations.push((0, _mainJs.AxesTextOrientation).parallel); + this._axesLeftToRightIndexCounts.push(0); + this._axesRightToLeftIndexCounts.push(0); + this._axesLeftToRightIndexOffsets.push(0); + this._axesRightToLeftIndexOffsets.push(0); } - } - get isDiscreteY() { - return this._isDiscrete[1]; - } - set isDiscreteY(value) { - if (value != this._isDiscrete[1]) { - this._isDiscrete[1] = value; - this._hasChanged = true; + for(let i = 0; i < 12; i++)this._labelMMatrices.push((0, _glMatrix.mat4).create()); + this._titles = []; + this._titleSizes = []; + this._titleIndexCounts = []; + this._titleIndexOffsets = []; + this._titleMMatrices = []; + for(let i = 0; i < 3; i++){ + this._titles.push(null); + this._titleSizes.push(core.config.axesTextTitleSize); + this._titleIndexCounts.push(0); + this._titleIndexOffsets.push(0); } - } - get minBoundsX() { - return this._minBoundsX; - } - set minBoundsX(value) { - if (value != this._minBoundsX) { - this._minBoundsX = value; - this._hasChanged = true; + for(let i = 0; i < 12; i++)this._titleMMatrices.push((0, _glMatrix.mat4).create()); + this._headings = []; + this._headingSizes = []; + this._headingIndexCounts = []; + this._headingIndexOffsets = []; + this._headingMMatrices = []; + this.isHeadingVisible = []; + for(let i = 0; i < 3; i++){ + this._headings.push(null); + this._headingSizes.push(core.config.axesTextHeadingSize); + this._headingIndexCounts.push(0); + this._headingIndexOffsets.push(0); } - } - get maxBoundsX() { - return this._maxBoundsX; - } - set maxBoundsX(value) { - if (value != this._minBoundsX) { - this._maxBoundsX = value; - this._hasChanged = true; + for(let i = 0; i < 12; i++){ + this._headingMMatrices.push((0, _glMatrix.mat4).create()); + this.isHeadingVisible.push(true); } - } - get minBoundsY() { - return this._minBoundsY; - } - set minBoundsY(value) { - if (value != this._minBoundsY) { - this._minBoundsY = value; - this._hasChanged = true; + this.isEdgeVisible = []; + this._edgePosition = (0, _glMatrix.vec3).create(); + this._edgePositive = (0, _glMatrix.vec3).create(); + this._edgeNormal = (0, _glMatrix.vec3).create(); + this._edgeNormalTemp = (0, _glMatrix.vec3).create(); + this._edgePositiveTemp = (0, _glMatrix.vec3).create(); + this._isLeftToRightHorizontal = []; + this._isLeftToRightVertical = []; + this._edgeHorizontalRight = []; + this._edgeHorizontalUp = []; + this._edgeHorizontalForward = []; + this._edgeVerticalRight = []; + this._edgeVerticalUp = []; + this._edgeVerticalForward = []; + for(let i = 0; i < 12; i++){ + this.isEdgeVisible.push(true); + this._isLeftToRightHorizontal.push(false); + this._isLeftToRightVertical.push(false); + this._edgeHorizontalRight.push((0, _glMatrix.vec3).create()); + this._edgeHorizontalUp.push((0, _glMatrix.vec3).create()); + this._edgeHorizontalForward.push((0, _glMatrix.vec3).create()); + this._edgeVerticalRight.push((0, _glMatrix.vec3).create()); + this._edgeVerticalUp.push((0, _glMatrix.vec3).create()); + this._edgeVerticalForward.push((0, _glMatrix.vec3).create()); } - } - get maxBoundsY() { - return this._maxBoundsY; - } - set maxBoundsY(value) { - if (value != this._minBoundsY) { - this._maxBoundsY = value; - this._hasChanged = true; + this.isFaceVisible = []; + for(let i = 0; i < 6; i++)this.isFaceVisible.push(true); + this.arePickDivisionsVisible = []; + this.areFacesVisible = []; + this._indexTemplate = (0, _quadJs.Quad).INDICES; + this.zero = (0, _glMatrix.vec3).create(); + this._gridTicksZeros = []; + this._gridFaceZeros = []; + this.minorGridlines = (0, _glMatrix.vec3).fromValues(1, 1, 1); + this._gridTicksMinorGridlines = []; + this._gridFaceMinorGridlines = []; + this._gridTicksPositions = []; + this._gridTicksScales = []; + this._gridTicksIndexCounts = []; + this._gridTicksIndexOffsets = []; + this._gridFaceScale = (0, _glMatrix.vec3).create(); + this._gridFaceIndexCounts = []; + this._gridFaceIndexOffsets = []; + this._gridFaceMMatrices = []; + this._gridTicksMMatrices = []; + this._gridTicksRotations = []; + for(let i = 0; i < 3; i++){ + this.arePickDivisionsVisible.push(true); + this.areFacesVisible.push(true); + this._gridTicksZeros.push((0, _glMatrix.vec2).create()); + this._gridFaceZeros.push((0, _glMatrix.vec2).create()); + this._gridTicksMinorGridlines.push((0, _glMatrix.vec2).create()); + this._gridFaceMinorGridlines.push((0, _glMatrix.vec2).create()); + this._gridTicksScales.push((0, _glMatrix.vec3).create()); + this._gridTicksIndexCounts.push(0); + this._gridTicksIndexOffsets.push(0); } - } - getIsOutsideEdge(index) { - return this._isOutsideEdge[index]; - } - getIsForwardFace(index) { - return this._isForwardFace[index]; - } - get textVertices() { - return this._textVertices; - } - get textIndices() { - return this._textIndices; - } - getLabelMMatrix(index) { - return this._labelMMatrices[index]; - } - setLabelPositions(index, value) { - if (this._labelPositions[index] != value) { - this._labelPositions[index] = value; - this._hasChanged = true; + for(let i = 0; i < 6; i++){ + this._gridFaceIndexCounts.push(0); + this._gridFaceIndexOffsets.push(0); + this._gridFaceMMatrices.push((0, _glMatrix.mat4).create()); } - } - setLabels(index, value) { - if (this._labels[index] != value) { - this._labels[index] = value; - this._hasChanged = true; - } - } - setLabelSizes(index, value) { - if (this._labelSizes[index] != value) { - this._labelSizes[index] = value; - this._hasChanged = true; - } - } - getLabelOrientation(index) { - return this._orientations[index]; - } - setLabelOrientation(index, orientation) { - if (this._orientations[index] != orientation) { - this._orientations[index] = orientation; - this._hasChanged = true; - } - } - getTitleIndexCount(index) { - return this._titleIndexCounts[index]; - } - getTitleIndexOffset(index) { - return this._titleIndexOffsets[index]; - } - getTitleMMatrix(index) { - return this._titleMMatrices[index]; - } - setTitle(index, value) { - if (this._titles[index] != value) { - this._titles[index] = value; - this._hasChanged = true; - } - } - setTitleSize(index, value) { - if (this._titleSizes[index] != value) { - this._titleSizes[index] = value; - this._hasChanged = true; - } - } - getHeadingIndexCount(index) { - return this._headingIndexCounts[index]; - } - getHeadingIndexOffset(index) { - return this._headingIndexOffsets[index]; - } - getHeadingMMatrix(index) { - return this._headingMMatrices[index]; - } - setHeading(index, value) { - if (this._headings[index] != value) { - this._headings[index] = value; - this._hasChanged = true; - } - } - setHeadingSize(index, value) { - if (this._headingSizes[index] != value) { - this._headingSizes[index] = value; - this._hasChanged = true; - } - } - getIsLeftToRightHorizontal(index) { - return this._isLeftToRightHorizontal[index]; - } - getIsLeftToRightVertical(index) { - return this._isLeftToRightVertical[index]; - } - getAxesLeftToRightIndexCount(index) { - return this._axesLeftToRightIndexCounts[index]; - } - getAxesRightToLeftIndexCount(index) { - return this._axesRightToLeftIndexCounts[index]; - } - getAxesLeftToRightIndexOffset(index) { - return this._axesLeftToRightIndexOffsets[index]; - } - getAxesRightToLeftIndexOffset(index) { - return this._axesRightToLeftIndexOffsets[index]; - } - get gridVertices() { - return this._gridVertices; - } - get gridIndices() { - return this._gridIndices; - } - getGridTicksIndexCount(index) { - return this._gridTicksIndexCounts[index]; - } - getGridTicksIndexOffset(index) { - return this._gridTicksIndexOffsets[index]; - } - getGridFaceIndexCount(index) { - return this._gridFaceIndexCounts[index]; - } - getGridFaceIndexOffset(index) { - return this._gridFaceIndexOffsets[index]; - } - getGridTicksMMatrix(index) { - return this._gridTicksMMatrices[index]; - } - getGridFaceMMatrix(index) { - return this._gridFaceMMatrices[index]; - } - getGridTicksScale(index) { - return this._gridTicksScales[index]; - } - getGridTicksZero(index) { - return this._gridTicksZeros[index]; - } - get gridFaceZero() { - return this._gridFaceZeros; - } - get gridFaceMinorGridlines() { - return this._gridFaceMinorGridlines; - } - getGridTicksMinorGridlines(index) { - return this._gridTicksMinorGridlines[index]; - } - setTickPositions(index, value) { - if (this._gridTicksPositions[index] != value) { - this._gridTicksPositions[index] = value; - this._hasChanged = true; - } - } - get scalingX() { - return this._scalingX; - } - set scalingX(value) { - if (value != this._scalingX) { - this._scalingX = value; - this._hasChanged = true; - } - } - get scalingY() { - return this._scalingY; - } - set scalingY(value) { - if (value != this._scalingY) { - this._scalingY = value; - this._hasChanged = true; - } - } - get offsetX() { - return this._offset[12]; - } - set offsetX(value) { - if (value != this._offset[12]) this._offset[12] = value; - } - get offsetY() { - return this._offset[13]; - } - set offsetY(value) { - if (value != this._offset[13]) this._offset[13] = value; - } - set rotation(value) { - if (this._rotation != value) { - this._rotation = value; - this._rMatrix = (0, _glMatrix.mat4).create(); - (0, _glMatrix.mat4).fromQuat(this._rMatrix, value); - } - } - constructor(core){ - super(core); - this._size = (0, _glMatrix.vec3).create(); - this._translation = (0, _glMatrix.vec3).create(); - this._normal = (0, _glMatrix.vec3).create(); - this._forward = (0, _glMatrix.vec3).create(); - this._right = (0, _glMatrix.vec3).create(); - this._up = (0, _glMatrix.vec3).create(); - this._texCoord = (0, _glMatrix.vec2).create(); - this._bounds = (0, _glMatrix.vec4).create(); - this._vec3 = (0, _glMatrix.vec3).create(); - this._vec4 = (0, _glMatrix.vec4).create(); - this._mat3 = (0, _glMatrix.mat3).create(); - this._isDiscrete = [ - false, - false - ]; - this._minBoundsX = 0; - this._minBoundsY = 0; - this._maxBoundsX = 0; - this._maxBoundsY = 0; - this._isForwardFace = []; - this._isForwardEdge = []; - this._isOutsideEdge = []; - for(let i = 0; i < 2; i++)this._isForwardFace.push(false); - for(let i1 = 0; i1 < 4; i1++){ - this._isForwardEdge.push(false); - this._isOutsideEdge.push(false); - } - this._textOffset = (0, _glMatrix.vec3).create(); - this._textPosition = (0, _glMatrix.vec3).create(); - this._distances = []; - for(let i2 = 0; i2 < 4; i2++)this._distances.push(0); - this._labelPositions = []; - this._labels = []; - this._labelSizes = []; - this._maxLabelSize = []; - this._axesLeftToRightIndexCounts = []; - this._axesRightToLeftIndexCounts = []; - this._axesLeftToRightIndexOffsets = []; - this._axesRightToLeftIndexOffsets = []; - this._labelMMatrices = []; - this._orientations = []; - for(let i3 = 0; i3 < 2; i3++){ - this._maxLabelSize.push((0, _glMatrix.vec2).create()); - this._orientations.push((0, _mainJs.AxesTextOrientation).parallel); - this._axesLeftToRightIndexCounts.push(0); - this._axesRightToLeftIndexCounts.push(0); - this._axesLeftToRightIndexOffsets.push(0); - this._axesRightToLeftIndexOffsets.push(0); - } - for(let i4 = 0; i4 < 4; i4++)this._labelMMatrices.push((0, _glMatrix.mat4).create()); - this._titles = []; - this._titleSizes = []; - this._titleIndexCounts = []; - this._titleIndexOffsets = []; - this._titleMMatrices = []; - for(let i5 = 0; i5 < 2; i5++){ - this._titles.push(null); - this._titleSizes.push(core.config.axesTextTitleSize); - this._titleIndexCounts.push(0); - this._titleIndexOffsets.push(0); - } - for(let i6 = 0; i6 < 4; i6++)this._titleMMatrices.push((0, _glMatrix.mat4).create()); - this._headings = []; - this._headingSizes = []; - this._headingIndexCounts = []; - this._headingIndexOffsets = []; - this._headingMMatrices = []; - this.isHeadingVisible = []; - for(let i7 = 0; i7 < 2; i7++){ - this._headings.push(null); - this._headingSizes.push(core.config.axesTextHeadingSize); - this._headingIndexCounts.push(0); - this._headingIndexOffsets.push(0); - } - for(let i8 = 0; i8 < 4; i8++){ - this._headingMMatrices.push((0, _glMatrix.mat4).create()); - this.isHeadingVisible.push(true); - } - this.isEdgeVisible = []; - this._edgePosition = (0, _glMatrix.vec3).create(); - this._edgePositive = (0, _glMatrix.vec3).create(); - this._edgeNormal = (0, _glMatrix.vec3).create(); - this._edgeNormalTemp = (0, _glMatrix.vec3).create(); - this._edgePositiveTemp = (0, _glMatrix.vec3).create(); - this._isLeftToRightHorizontal = []; - this._isLeftToRightVertical = []; - this._edgeHorizontalRight = []; - this._edgeHorizontalUp = []; - this._edgeHorizontalForward = []; - this._edgeVerticalRight = []; - this._edgeVerticalUp = []; - this._edgeVerticalForward = []; - for(let i9 = 0; i9 < 4; i9++){ - this.isEdgeVisible.push(true); - this._isLeftToRightHorizontal.push(false); - this._isLeftToRightVertical.push(false); - this._edgeHorizontalRight.push((0, _glMatrix.vec3).create()); - this._edgeHorizontalUp.push((0, _glMatrix.vec3).create()); - this._edgeHorizontalForward.push((0, _glMatrix.vec3).create()); - this._edgeVerticalRight.push((0, _glMatrix.vec3).create()); - this._edgeVerticalUp.push((0, _glMatrix.vec3).create()); - this._edgeVerticalForward.push((0, _glMatrix.vec3).create()); - } - this.isFaceVisible = []; - for(let i10 = 0; i10 < 2; i10++)this.isFaceVisible.push(true); - this.arePickDivisionsVisible = []; - this.areFacesVisible = []; - this._indexTemplate = (0, _quadJs.Quad).INDICES; - this.zero = (0, _glMatrix.vec3).create(); - this._gridTicksZeros = []; - this._gridFaceZeros = (0, _glMatrix.vec2).create(); - this.minorGridlines = (0, _glMatrix.vec3).fromValues(1, 1, 1); - this._gridTicksMinorGridlines = []; - this._gridFaceMinorGridlines = (0, _glMatrix.vec2).create(); - this._gridTicksPositions = []; - this._gridTicksScales = []; - this._gridTicksIndexCounts = []; - this._gridTicksIndexOffsets = []; - this._gridFaceScale = (0, _glMatrix.vec3).create(); - this._gridFaceIndexCounts = []; - this._gridFaceIndexOffsets = []; - this._gridFaceMMatrices = []; - this._gridTicksMMatrices = []; - this._gridTicksRotations = []; - for(let i11 = 0; i11 < 2; i11++){ - this.arePickDivisionsVisible.push(true); - this.areFacesVisible.push(true); - this._gridTicksZeros.push((0, _glMatrix.vec2).create()); - this._gridTicksMinorGridlines.push((0, _glMatrix.vec2).create()); - this._gridTicksScales.push((0, _glMatrix.vec3).create()); - this._gridTicksIndexCounts.push(0); - this._gridTicksIndexOffsets.push(0); - this._gridFaceIndexCounts.push(0); - this._gridFaceIndexOffsets.push(0); - this._gridFaceMMatrices.push((0, _glMatrix.mat4).create()); - } - for(let i12 = 0; i12 < 4; i12++){ - this._gridTicksMMatrices.push((0, _glMatrix.mat4).create()); - this._gridTicksRotations.push((0, _glMatrix.mat4).create()); - const _mat4 = this._gridTicksRotations[i12]; - _mat4[0] = (0, _quadJs.Quad).EDGE_POSITIVES[i12][0]; - _mat4[1] = (0, _quadJs.Quad).EDGE_POSITIVES[i12][1]; - _mat4[2] = (0, _quadJs.Quad).EDGE_POSITIVES[i12][2]; - _mat4[4] = (0, _quadJs.Quad).EDGE_NORMALS[i12][0]; - _mat4[5] = (0, _quadJs.Quad).EDGE_NORMALS[i12][1]; - _mat4[6] = (0, _quadJs.Quad).EDGE_NORMALS[i12][2]; - (0, _glMatrix.vec3).cross(this._vec3, (0, _quadJs.Quad).EDGE_POSITIVES[i12], (0, _quadJs.Quad).EDGE_NORMALS[i12]); - _mat4[8] = this._vec3[0]; - _mat4[9] = this._vec3[1]; - _mat4[10] = this._vec3[2]; + for(let i = 0; i < 12; i++){ + this._gridTicksMMatrices.push((0, _glMatrix.mat4).create()); + this._gridTicksRotations.push((0, _glMatrix.mat4).create()); + const _mat4 = this._gridTicksRotations[i]; + _mat4[0] = (0, _cubeJs.Cube).EDGE_POSITIVES[i][0]; + _mat4[1] = (0, _cubeJs.Cube).EDGE_POSITIVES[i][1]; + _mat4[2] = (0, _cubeJs.Cube).EDGE_POSITIVES[i][2]; + _mat4[4] = (0, _cubeJs.Cube).EDGE_NORMALS[i][0]; + _mat4[5] = (0, _cubeJs.Cube).EDGE_NORMALS[i][1]; + _mat4[6] = (0, _cubeJs.Cube).EDGE_NORMALS[i][2]; + (0, _glMatrix.vec3).cross(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIVES[i], (0, _cubeJs.Cube).EDGE_NORMALS[i]); + _mat4[8] = this._vec3[0]; + _mat4[9] = this._vec3[1]; + _mat4[10] = this._vec3[2]; } this._fromValues = [ + null, null, null ]; this._toValues = [ + null, null, null ]; this.isDivisionPickingEnabled = [ + false, false, false ]; this.isLabelPickingEnabled = [ + false, false, false ]; this.isTitlePickingEnabled = [ + false, false, false ]; this.isHeadingPickingEnabled = [ + false, false, false ]; this.isAxisReversed = [ + false, false, false ]; this._scalingX = 1; this._scalingY = 1; + this._scalingZ = 1; this._offset = (0, _glMatrix.mat4).create(); } initialize() { @@ -19376,123 +16807,137 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { if (this._hasChanged) { const start = window.performance.now(); this._hasChanged = false; - (0, _glMatrix.vec3).set(this._size, this._maxBoundsX - this._minBoundsX, this._maxBoundsY - this._minBoundsY, 0); - const maxBounds = Math.max(this._size[0], this._size[1]); + (0, _glMatrix.vec3).set(this._size, this._maxBoundsX - this._minBoundsX, this._maxBoundsY - this._minBoundsY, this._maxBoundsZ - this._minBoundsZ); + const maxBounds = Math.max(this._size[0], Math.max(this._size[1], this._size[2])); this._size[0] *= this._scalingX / maxBounds; this._size[1] *= this._scalingY / maxBounds; + this._size[2] *= this._scalingZ / maxBounds; this._updateGrids(this._size); this._updateText(this._size); if (this.hasChangedCallback) this.hasChangedCallback(); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d updated ${Math.round(window.performance.now() - start)}ms`); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d updated ${Math.round(window.performance.now() - start)}ms`); } - if (this._rMatrix) { - (0, _glMatrix.mat4).mul(this._mMatrix, this.mMatrix, this._rMatrix); - (0, _glMatrix.mat4).mul(this._mMatrix, this._mMatrix, this._offset); - } else (0, _glMatrix.mat4).multiply(this._mMatrix, this.mMatrix, this._offset); + (0, _glMatrix.mat4).multiply(this._mMatrix, this.mMatrix, this._offset); this._mvMatrix = (0, _glMatrix.mat4).create(); (0, _glMatrix.mat4).multiply(this._mvMatrix, this._vMatrix, this._mMatrix); (0, _glMatrix.mat3).fromMat4(this._mat3, this._mvMatrix); - for(let faceId = 0; faceId < 2; faceId++){ - (0, _glMatrix.vec3).transformMat4(this._forward, (0, _constantsJs.Constants).VECTOR3_ZERO, this._mvMatrix); - (0, _glMatrix.vec3).transformMat3(this._normal, (0, _quadJs.Quad).FACE_NORMALS[faceId], this._mat3); + for(let faceId = 0; faceId < 6; faceId++){ + (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).FACE_POSITIONS[faceId], this._size); + (0, _glMatrix.vec3).transformMat4(this._forward, this._vec3, this._mvMatrix); + (0, _glMatrix.vec3).transformMat3(this._normal, (0, _cubeJs.Cube).FACE_NORMALS[faceId], this._mat3); this._isForwardFace[faceId] = (0, _glMatrix.vec3).dot(this._normal, this._forward) > 0; } this._forward[0] = this._mat3[2]; this._forward[1] = this._mat3[5]; this._forward[2] = this._mat3[8]; - for(let edgeId = 0; edgeId < 4; edgeId++){ - this._isForwardEdge[edgeId] = (0, _glMatrix.vec3).dot((0, _quadJs.Quad).EDGE_FORWARDS[edgeId], this._forward) < 0; + for(let edgeId = 0; edgeId < 12; edgeId++){ + const faceIds = (0, _cubeJs.Cube).EDGE_FACES[edgeId]; + const forward1 = this._isForwardFace[faceIds[0]]; + const forward2 = this._isForwardFace[faceIds[1]]; + const outsideEdge = forward1 != forward2; + this._isOutsideEdge[edgeId] = outsideEdge; + if (outsideEdge) this._isForwardEdge[edgeId] = (0, _glMatrix.vec3).dot((0, _cubeJs.Cube).EDGE_FORWARDS[edgeId], this._forward) < 0; this._distances[edgeId] = 0; } - for(let axisId = 0; axisId < 2; axisId++)if (this.arePickDivisionsVisible[axisId]) { + for(let axisId = 0; axisId < 3; axisId++)if (this.arePickDivisionsVisible[axisId]) { (0, _glMatrix.vec2).set(this._gridTicksZeros[axisId], this.zero[axisId], -1); (0, _glMatrix.vec2).set(this._gridTicksMinorGridlines[axisId], this.minorGridlines[axisId], 1); const gridTicksScale = this._gridTicksScales[axisId]; - for(let edge = 0; edge < 2; edge++){ - const edgeId1 = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; - if (this.isEdgeVisible[edgeId1]) { - let distance = this._distances[edgeId1]; + for(let edge = 0; edge < 4; edge++){ + const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; + if (this._isOutsideEdge[edgeId] && this.isEdgeVisible[edgeId]) { + let distance = this._distances[edgeId]; distance += this._gridPickDivisionHeight * 0.5; - const gridTicksMMatrix = this._gridTicksMMatrices[edgeId1]; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId1], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId1], distance); + const gridTicksMMatrix = this._gridTicksMMatrices[edgeId]; + (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); (0, _glMatrix.mat4).translate(gridTicksMMatrix, this._mMatrix, this._vec3); - (0, _glMatrix.mat4).multiply(gridTicksMMatrix, gridTicksMMatrix, this._gridTicksRotations[edgeId1]); - if (!this._isForwardEdge[edgeId1]) (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, (0, _constantsJs.Constants).VECTOR3_REFLECTX); + (0, _glMatrix.mat4).multiply(gridTicksMMatrix, gridTicksMMatrix, this._gridTicksRotations[edgeId]); + if (!this._isForwardEdge[edgeId]) (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, (0, _constantsJs.Constants).VECTOR3_REFLECTX); (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, gridTicksScale); distance += this._gridPickDivisionHeight * 0.5; - this._distances[edgeId1] = distance; + this._distances[edgeId] = distance; } } } - (0, _glMatrix.vec2).set(this._gridFaceZeros, this.zero[0], this.zero[1]); - (0, _glMatrix.vec2).set(this._gridFaceMinorGridlines, this.minorGridlines[0], this.minorGridlines[1]); - for(let faceId1 = 0; faceId1 < 2; faceId1++)if (this._isForwardFace[faceId1]) { - const gridFaceMMatrix = this._gridFaceMMatrices[faceId1]; - (0, _glMatrix.mat4).scale(gridFaceMMatrix, this._mMatrix, this._gridFaceScale); - } - for(let axisId1 = 0; axisId1 < 2; axisId1++)for(let edge1 = 0; edge1 < 2; edge1++){ - const edgeId2 = (0, _quadJs.Quad).AXIS_EDGES[axisId1][edge1]; - (0, _glMatrix.vec3).multiply(this._edgePosition, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId2], this._size); - (0, _glMatrix.vec3).transformMat4(this._edgePosition, this._edgePosition, this._mvMatrix); - (0, _glMatrix.vec3).normalize(this._forward, this._edgePosition); - (0, _glMatrix.vec3).negate(this._forward, this._forward); - (0, _glMatrix.vec3).cross(this._right, (0, _constantsJs.Constants).VECTOR3_UNITY, this._forward); - (0, _glMatrix.vec3).normalize(this._right, this._right); - (0, _glMatrix.vec3).cross(this._up, this._forward, this._right); - (0, _glMatrix.vec3).transformMat3(this._edgeNormal, (0, _quadJs.Quad).EDGE_NORMALS[edgeId2], this._mat3); - (0, _glMatrix.vec3).transformMat3(this._edgePositive, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId2], this._mat3); - (0, _glMatrix.vec3).copy(this._edgeNormalTemp, this._edgeNormal); - (0, _glMatrix.vec3).copy(this._edgePositiveTemp, this._edgePositive); - const edgeHorizontalRight = this._edgeHorizontalRight[edgeId2]; - const edgeHorizontalUp = this._edgeHorizontalUp[edgeId2]; - const edgeHorizontalForward = this._edgeHorizontalForward[edgeId2]; - if ((0, _glMatrix.vec3).dot(this._edgeNormalTemp, this._up) > 0) (0, _glMatrix.vec3).copy(edgeHorizontalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId2]); - else { - (0, _glMatrix.vec3).negate(edgeHorizontalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgeNormalTemp, this._edgeNormalTemp); - } - if ((0, _glMatrix.vec3).dot(this._edgePositiveTemp, this._right) > 0) { - this._isLeftToRightHorizontal[edgeId2] = true; - (0, _glMatrix.vec3).copy(edgeHorizontalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId2]); - } else { - this._isLeftToRightHorizontal[edgeId2] = false; - (0, _glMatrix.vec3).negate(edgeHorizontalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgePositiveTemp, this._edgePositiveTemp); - } - (0, _glMatrix.vec3).cross(edgeHorizontalForward, this._edgePositiveTemp, this._edgeNormalTemp); - if ((0, _glMatrix.vec3).dot(edgeHorizontalForward, this._forward) < 0) { - this._isLeftToRightHorizontal[edgeId2] = !this._isLeftToRightHorizontal[edgeId2]; - (0, _glMatrix.vec3).negate(edgeHorizontalRight, edgeHorizontalRight); - } - (0, _glMatrix.vec3).cross(edgeHorizontalForward, edgeHorizontalRight, edgeHorizontalUp); - const edgeVerticalRight = this._edgeVerticalRight[edgeId2]; - const edgeVerticalUp = this._edgeVerticalUp[edgeId2]; - const edgeVerticalForward = this._edgeVerticalForward[edgeId2]; - if ((0, _glMatrix.vec3).dot(this._edgeNormal, this._right) < 0) (0, _glMatrix.vec3).copy(edgeVerticalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId2]); - else { - (0, _glMatrix.vec3).negate(edgeVerticalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgeNormal, this._edgeNormal); - } - if ((0, _glMatrix.vec3).dot(this._edgePositive, this._up) < 0) { - this._isLeftToRightVertical[edgeId2] = true; - (0, _glMatrix.vec3).copy(edgeVerticalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId2]); - } else { - this._isLeftToRightVertical[edgeId2] = false; - (0, _glMatrix.vec3).negate(edgeVerticalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId2]); - (0, _glMatrix.vec3).negate(this._edgePositive, this._edgePositive); - } - (0, _glMatrix.vec3).cross(edgeVerticalForward, this._edgePositive, this._edgeNormal); - if ((0, _glMatrix.vec3).dot(edgeVerticalForward, this._forward) < 0) { - this._isLeftToRightVertical[edgeId2] = !this._isLeftToRightVertical[edgeId2]; - (0, _glMatrix.vec3).negate(edgeVerticalRight, edgeVerticalRight); + for(let axisId = 0; axisId < 3; axisId++)if (this.areFacesVisible[axisId]) { + const axisId2 = axisId == 0 ? 1 : 0; + const axisId3 = axisId == 2 ? 1 : 2; + (0, _glMatrix.vec2).set(this._gridFaceZeros[axisId], this.zero[axisId2], this.zero[axisId3]); + (0, _glMatrix.vec2).set(this._gridFaceMinorGridlines[axisId], this.minorGridlines[axisId2], this.minorGridlines[axisId3]); + for(let face = 0; face < 2; face++){ + const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId][face]; + if (this._isForwardFace[faceId]) { + const gridFaceMMatrix = this._gridFaceMMatrices[faceId]; + (0, _glMatrix.mat4).scale(gridFaceMMatrix, this._mMatrix, this._gridFaceScale); + if (this._size[axisId] > 0) (0, _glMatrix.mat4).translate(gridFaceMMatrix, gridFaceMMatrix, (0, _cubeJs.Cube).FACE_POSITIONS[faceId]); + } } - (0, _glMatrix.vec3).cross(edgeVerticalForward, edgeVerticalRight, edgeVerticalUp); - if (this.isEdgeVisible[edgeId2]) { - if (this._labels[axisId1]) this._updateLabels(axisId1, edgeId2); - if (this._titles[axisId1]) this._updateTitle(axisId1, edgeId2); + } + for(let axisId = 0; axisId < 3; axisId++)for(let edge = 0; edge < 4; edge++){ + const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; + if (this._isOutsideEdge[edgeId]) { + (0, _glMatrix.vec3).multiply(this._edgePosition, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).transformMat4(this._edgePosition, this._edgePosition, this._mvMatrix); + (0, _glMatrix.vec3).normalize(this._forward, this._edgePosition); + (0, _glMatrix.vec3).negate(this._forward, this._forward); + (0, _glMatrix.vec3).cross(this._right, (0, _constantsJs.Constants).VECTOR3_UNITY, this._forward); + (0, _glMatrix.vec3).normalize(this._right, this._right); + (0, _glMatrix.vec3).cross(this._up, this._forward, this._right); + (0, _glMatrix.vec3).transformMat3(this._edgeNormal, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], this._mat3); + (0, _glMatrix.vec3).transformMat3(this._edgePositive, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId], this._mat3); + (0, _glMatrix.vec3).copy(this._edgeNormalTemp, this._edgeNormal); + (0, _glMatrix.vec3).copy(this._edgePositiveTemp, this._edgePositive); + const edgeHorizontalRight = this._edgeHorizontalRight[edgeId]; + const edgeHorizontalUp = this._edgeHorizontalUp[edgeId]; + const edgeHorizontalForward = this._edgeHorizontalForward[edgeId]; + if ((0, _glMatrix.vec3).dot(this._edgeNormalTemp, this._up) > 0) (0, _glMatrix.vec3).copy(edgeHorizontalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId]); + else { + (0, _glMatrix.vec3).negate(edgeHorizontalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId]); + (0, _glMatrix.vec3).negate(this._edgeNormalTemp, this._edgeNormalTemp); + } + if ((0, _glMatrix.vec3).dot(this._edgePositiveTemp, this._right) > 0) { + this._isLeftToRightHorizontal[edgeId] = true; + (0, _glMatrix.vec3).copy(edgeHorizontalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId]); + } else { + this._isLeftToRightHorizontal[edgeId] = false; + (0, _glMatrix.vec3).negate(edgeHorizontalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId]); + (0, _glMatrix.vec3).negate(this._edgePositiveTemp, this._edgePositiveTemp); + } + (0, _glMatrix.vec3).cross(edgeHorizontalForward, this._edgePositiveTemp, this._edgeNormalTemp); + if ((0, _glMatrix.vec3).dot(edgeHorizontalForward, this._forward) < 0) { + this._isLeftToRightHorizontal[edgeId] = !this._isLeftToRightHorizontal[edgeId]; + (0, _glMatrix.vec3).negate(edgeHorizontalRight, edgeHorizontalRight); + } + (0, _glMatrix.vec3).cross(edgeHorizontalForward, edgeHorizontalRight, edgeHorizontalUp); + const edgeVerticalRight = this._edgeVerticalRight[edgeId]; + const edgeVerticalUp = this._edgeVerticalUp[edgeId]; + const edgeVerticalForward = this._edgeVerticalForward[edgeId]; + if ((0, _glMatrix.vec3).dot(this._edgeNormal, this._right) < 0) (0, _glMatrix.vec3).copy(edgeVerticalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId]); + else { + (0, _glMatrix.vec3).negate(edgeVerticalUp, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId]); + (0, _glMatrix.vec3).negate(this._edgeNormal, this._edgeNormal); + } + if ((0, _glMatrix.vec3).dot(this._edgePositive, this._up) < 0) { + this._isLeftToRightVertical[edgeId] = true; + (0, _glMatrix.vec3).copy(edgeVerticalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId]); + } else { + this._isLeftToRightVertical[edgeId] = false; + (0, _glMatrix.vec3).negate(edgeVerticalRight, (0, _cubeJs.Cube).EDGE_POSITIVES[edgeId]); + (0, _glMatrix.vec3).negate(this._edgePositive, this._edgePositive); + } + (0, _glMatrix.vec3).cross(edgeVerticalForward, this._edgePositive, this._edgeNormal); + if ((0, _glMatrix.vec3).dot(edgeVerticalForward, this._forward) < 0) { + this._isLeftToRightVertical[edgeId] = !this._isLeftToRightVertical[edgeId]; + (0, _glMatrix.vec3).negate(edgeVerticalRight, edgeVerticalRight); + } + (0, _glMatrix.vec3).cross(edgeVerticalForward, edgeVerticalRight, edgeVerticalUp); + if (this.isEdgeVisible[edgeId]) { + if (this._labels[axisId]) this._updateLabels(axisId, edgeId); + if (this._titles[axisId]) this._updateTitle(axisId, edgeId); + } + if (this.isHeadingVisible[edgeId]) this._updateHeading(axisId, edgeId); } - if (this.isHeadingVisible[edgeId2]) this._updateHeading(axisId1, edgeId2); } } } @@ -19500,10 +16945,10 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { const orientation = this._orientations[axisId]; let distance = this._distances[edgeId]; let maxLabelSize = this._maxLabelSize[axisId][1]; - if (orientation == (0, _mainJs.AxesTextOrientation).parallel) maxLabelSize *= this._lineHeight; + if (orientation == (0, _mainJs.AxesTextOrientation).parallel) maxLabelSize *= this._core.config.axesTextLabelLineHeight; distance += maxLabelSize * 0.5; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); const labelMMatrix = this._labelMMatrices[edgeId]; labelMMatrix[12] = this._vec3[0]; labelMMatrix[13] = this._vec3[1]; @@ -19522,18 +16967,18 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { labelMMatrix[9] = forward[1]; labelMMatrix[10] = forward[2]; } else { - const right1 = this._edgeVerticalRight[edgeId]; - const up1 = this._edgeVerticalUp[edgeId]; - const forward1 = this._edgeVerticalForward[edgeId]; - labelMMatrix[0] = right1[0]; - labelMMatrix[1] = right1[1]; - labelMMatrix[2] = right1[2]; - labelMMatrix[4] = up1[0]; - labelMMatrix[5] = up1[1]; - labelMMatrix[6] = up1[2]; - labelMMatrix[8] = forward1[0]; - labelMMatrix[9] = forward1[1]; - labelMMatrix[10] = forward1[2]; + const right = this._edgeVerticalRight[edgeId]; + const up = this._edgeVerticalUp[edgeId]; + const forward = this._edgeVerticalForward[edgeId]; + labelMMatrix[0] = right[0]; + labelMMatrix[1] = right[1]; + labelMMatrix[2] = right[2]; + labelMMatrix[4] = up[0]; + labelMMatrix[5] = up[1]; + labelMMatrix[6] = up[2]; + labelMMatrix[8] = forward[0]; + labelMMatrix[9] = forward[1]; + labelMMatrix[10] = forward[2]; } (0, _glMatrix.mat4).multiply(labelMMatrix, this._mMatrix, labelMMatrix); if (orientation == (0, _mainJs.AxesTextOrientation).perpendicular) (0, _glMatrix.mat4).multiply(labelMMatrix, labelMMatrix, (0, _constantsJs.Constants).MAT4_ROTATION_MINUS_90); @@ -19542,10 +16987,10 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { } _updateTitle(axisId, edgeId) { let distance = this._distances[edgeId]; - const titleTextSize = this._titleSizes[axisId] * this._lineHeight; + const titleTextSize = this._titleSizes[axisId] * this._core.config.axesTextTitleLineHeight; distance += titleTextSize * 0.5; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); const titleMMatrix = this._titleMMatrices[edgeId]; titleMMatrix[12] = this._vec3[0]; titleMMatrix[13] = this._vec3[1]; @@ -19568,10 +17013,10 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { } _updateHeading(axisId, edgeId) { let distance = this._distances[edgeId]; - const headingTextSize = this._headingSizes[axisId] * this._lineHeight; + const headingTextSize = this._headingSizes[axisId] * this._core.config.axesTextHeadingLineHeight; distance += headingTextSize * 0.5; - (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); - (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + (0, _glMatrix.vec3).multiply(this._vec3, (0, _cubeJs.Cube).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _cubeJs.Cube).EDGE_NORMALS[edgeId], distance); const headingMMatrix = this._headingMMatrices[edgeId]; headingMMatrix[12] = this._vec3[0]; headingMMatrix[13] = this._vec3[1]; @@ -19598,27 +17043,29 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { this._pickGrid = []; const xDivisions = this._gridTicksPositions[0] ? this._gridTicksPositions[0].length - 1 : 0; const yDivisions = this._gridTicksPositions[1] ? this._gridTicksPositions[1].length - 1 : 0; - const count = 2 * (xDivisions * yDivisions) + xDivisions + yDivisions; + const zDivisions = this._gridTicksPositions[2] ? this._gridTicksPositions[2].length - 1 : 0; + const count = 2 * (xDivisions * yDivisions) + 2 * (xDivisions * zDivisions) + 2 * (yDivisions * zDivisions) + xDivisions + yDivisions + zDivisions; const byteLength = (0, _vertexJs.PickGridVertex).SIZE_BYTES * count * 4; if (!this._gridVertices || this._gridVertices.byteLength < byteLength) { this._gridVertices = new ArrayBuffer(byteLength); this._gridVerticesView = new DataView(this._gridVertices); this._gridIndices = new Uint16Array(count * 6); } - for(let axisId = 0; axisId < 2; axisId++){ + for(let axisId = 0; axisId < 3; axisId++){ const width = size[axisId]; (0, _glMatrix.vec3).set(this._gridTicksScales[axisId], width, this._gridPickDivisionHeight, 1); offset = this._updateGridTicks(axisId, this._gridVerticesView, this._gridIndices, offset); + for(let face = 0; face < 2; face++){ + const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId][face]; + offset = this._updateGridFace(axisId, faceId, this._gridVerticesView, this._gridIndices, offset); + } this._gridFaceScale[axisId] = size[axisId] == 0 ? 1 : size[axisId]; } - const axisId1 = 2; - this._gridFaceScale[axisId1] = 1; - for(let faceId = 0; faceId < 2; faceId++)offset = this._updateGridFace(axisId1, faceId, this._gridVerticesView, this._gridIndices, offset); } _updateText(size) { let glyphOffset = 0; let count = 0; - for(let axisId = 0; axisId < 2; axisId++){ + for(let axisId = 0; axisId < 3; axisId++){ const labels = this._labels[axisId]; if (labels) for(let i = 0; i < labels.length; i++)count += 2 * Math.min(labels[i].length, this._core.config.axesTextLabelMaxGlyphs); const title = this._titles[axisId]; @@ -19634,74 +17081,74 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { } this.pickLabelLookup = {}; this._pickLabel = []; - for(let axisId1 = 0; axisId1 < 2; axisId1++)if (this._labels[axisId1]) { - const width = size[axisId1]; - const maxLabelSize = this._maxLabelSize[axisId1]; - const orientation = this._orientations[axisId1]; + for(let axisId = 0; axisId < 3; axisId++)if (this._labels[axisId]) { + const width = size[axisId]; + const maxLabelSize = this._maxLabelSize[axisId]; + const orientation = this._orientations[axisId]; (0, _glMatrix.vec2).set(maxLabelSize, 0, 0); - this._axesLeftToRightIndexOffsets[axisId1] = glyphOffset * 6; - glyphOffset = this._updateLeftToRightAxisLabels(axisId1, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId1], this._labelPositions[axisId1], this._labelSizes[axisId1]); - this._axesLeftToRightIndexCounts[axisId1] = glyphOffset * 6 - this._axesLeftToRightIndexOffsets[axisId1]; - this._axesRightToLeftIndexOffsets[axisId1] = glyphOffset * 6; - glyphOffset = this._updateRightToLeftAxisLabels(axisId1, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId1], this._labelPositions[axisId1], this._labelSizes[axisId1]); - this._axesRightToLeftIndexCounts[axisId1] = glyphOffset * 6 - this._axesRightToLeftIndexOffsets[axisId1]; + this._axesLeftToRightIndexOffsets[axisId] = glyphOffset * 6; + glyphOffset = this._updateLeftToRightAxisLabels(axisId, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId], this._labelPositions[axisId], this._labelSizes[axisId]); + this._axesLeftToRightIndexCounts[axisId] = glyphOffset * 6 - this._axesLeftToRightIndexOffsets[axisId]; + this._axesRightToLeftIndexOffsets[axisId] = glyphOffset * 6; + glyphOffset = this._updateRightToLeftAxisLabels(axisId, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId], this._labelPositions[axisId], this._labelSizes[axisId]); + this._axesRightToLeftIndexCounts[axisId] = glyphOffset * 6 - this._axesRightToLeftIndexOffsets[axisId]; } else { - this._axesLeftToRightIndexOffsets[axisId1] = glyphOffset * 6; - this._axesRightToLeftIndexOffsets[axisId1] = glyphOffset * 6; - this._axesLeftToRightIndexCounts[axisId1] = 0; - this._axesRightToLeftIndexCounts[axisId1] = 0; - this._maxLabelSize[axisId1][0] = 0; - this._maxLabelSize[axisId1][1] = 0; + this._axesLeftToRightIndexOffsets[axisId] = glyphOffset * 6; + this._axesRightToLeftIndexOffsets[axisId] = glyphOffset * 6; + this._axesLeftToRightIndexCounts[axisId] = 0; + this._axesRightToLeftIndexCounts[axisId] = 0; + this._maxLabelSize[axisId][0] = 0; + this._maxLabelSize[axisId][1] = 0; } this.pickTitleLookup = {}; this._pickTitle = []; - for(let axisId2 = 0; axisId2 < 2; axisId2++)if (this._titles[axisId2]) { + for(let axisId = 0; axisId < 3; axisId++)if (this._titles[axisId]) { (0, _glMatrix.vec3).set(this._textPosition, 0, 0, 0); (0, _glMatrix.vec3).set(this._textOffset, 0, 0, 0); - this._titleIndexOffsets[axisId2] = glyphOffset * 6; - const text = (0, _textJs.TextHelper).truncate(this._titles[axisId2], this._core.config.axesTextTitleMaxGlyphs); - const scale = this._titleSizes[axisId2] / this._font.size; + this._titleIndexOffsets[axisId] = glyphOffset * 6; + const text = (0, _textJs.TextHelper).truncate(this._titles[axisId], this._core.config.axesTextTitleMaxGlyphs); + const scale = this._titleSizes[axisId] / this._font.size; (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); - const width1 = this._textMetric.width * scale; + const width = this._textMetric.width * scale; const maxGlyphTop = this._textMetric.maxTop * scale; const lineHeight = this._font.size * scale; - this._textOffset[0] -= width1 / 2; + this._textOffset[0] -= width / 2; this._textOffset[1] -= (lineHeight - maxGlyphTop) / 2; const pickId = (0, _pickJs.PickHelper).nextPickId(); (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesTitle, this._vec4); this.pickTitleLookup[pickId] = this._pickTitle.length; - this._pickTitle.push(axisId2); + this._pickTitle.push(axisId); (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); glyphOffset += text.length; - this._titleIndexCounts[axisId2] = glyphOffset * 6 - this._titleIndexOffsets[axisId2]; + this._titleIndexCounts[axisId] = glyphOffset * 6 - this._titleIndexOffsets[axisId]; } else { - this._titleIndexOffsets[axisId2] = glyphOffset * 6; - this._titleIndexCounts[axisId2] = 0; + this._titleIndexOffsets[axisId] = glyphOffset * 6; + this._titleIndexCounts[axisId] = 0; } this.pickHeadingLookup = {}; this._pickHeading = []; - for(let axisId3 = 0; axisId3 < 2; axisId3++)if (this._headings[axisId3]) { + for(let axisId = 0; axisId < 3; axisId++)if (this._headings[axisId]) { (0, _glMatrix.vec3).set(this._textPosition, 0, 0, 0); (0, _glMatrix.vec3).set(this._textOffset, 0, 0, 0); - this._headingIndexOffsets[axisId3] = glyphOffset * 6; - const text1 = (0, _textJs.TextHelper).truncate(this._headings[axisId3], this._core.config.axesTextHeadingMaxGlyphs); - const scale1 = this._headingSizes[axisId3] / this._font.size; - (0, _textJs.TextHelper).measure(this._font, text1, this._textMetric); - const width2 = this._textMetric.width * scale1; - const maxGlyphTop1 = this._textMetric.maxTop * scale1; - const lineHeight1 = this._font.size * scale1; - this._textOffset[0] -= width2 / 2; - this._textOffset[1] -= (lineHeight1 - maxGlyphTop1) / 2; - const pickId1 = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId1, (0, _mainJs.PickType).axesHeading, this._vec4); - this.pickHeadingLookup[pickId1] = this._pickHeading.length; - this._pickHeading.push(axisId3); - (0, _textJs.TextHelper).addString(this._font, text1, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale1, this._textOffset, null, this._vec4); - glyphOffset += text1.length; - this._headingIndexCounts[axisId3] = glyphOffset * 6 - this._headingIndexOffsets[axisId3]; + this._headingIndexOffsets[axisId] = glyphOffset * 6; + const text = (0, _textJs.TextHelper).truncate(this._headings[axisId], this._core.config.axesTextHeadingMaxGlyphs); + const scale = this._headingSizes[axisId] / this._font.size; + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + const width = this._textMetric.width * scale; + const maxGlyphTop = this._textMetric.maxTop * scale; + const lineHeight = this._font.size * scale; + this._textOffset[0] -= width / 2; + this._textOffset[1] -= (lineHeight - maxGlyphTop) / 2; + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesHeading, this._vec4); + this.pickHeadingLookup[pickId] = this._pickHeading.length; + this._pickHeading.push(axisId); + (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); + glyphOffset += text.length; + this._headingIndexCounts[axisId] = glyphOffset * 6 - this._headingIndexOffsets[axisId]; } else { - this._headingIndexOffsets[axisId3] = glyphOffset * 6; - this._headingIndexCounts[axisId3] = 0; + this._headingIndexOffsets[axisId] = glyphOffset * 6; + this._headingIndexCounts[axisId] = 0; } } _updateLeftToRightAxisLabels(axisId, size, maxSize, glyphOffset, orientation, labels, positions, scales) { @@ -19846,7 +17293,7 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { const axisId3 = axisId == 2 ? 1 : 2; if (this._gridTicksPositions[axisId2] && this._gridTicksPositions[axisId3]) { const axes = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).negate(this._normal, (0, _quadJs.Quad).FACE_NORMALS[faceId]); + (0, _glMatrix.vec3).negate(this._normal, (0, _cubeJs.Cube).FACE_NORMALS[faceId]); const positions2 = this._gridTicksPositions[axisId2]; const positions3 = this._gridTicksPositions[axisId3]; const isAxisReversed2 = this.isAxisReversed[axisId2]; @@ -19914,5938 +17361,5580 @@ class Cartesian2dAxes extends (0, _axesJs.AxesBase) { } } -},{"gl-matrix":"9GjEQ","../../constants.js":"2Scl5","../../main.js":"1Kju3","./axes.js":"duutq","../../meshes/quad.js":"jyd4s","../../vertex.js":"ddAub","../../helpers/axes.js":"8BmXc","../../helpers/text.js":"l2V9O","../../helpers/pick.js":"9zmDo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5CPIb":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Glyph", ()=>Glyph); -parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); -parcelHelpers.export(exports, "Font", ()=>Font); -parcelHelpers.export(exports, "FontAtlas", ()=>FontAtlas); -parcelHelpers.export(exports, "FontRasterizer", ()=>FontRasterizer); -parcelHelpers.export(exports, "GlyphRasterizer", ()=>GlyphRasterizer); +},{"gl-matrix":"5x28d","../../constants.js":"lD0bG","../../main.js":"f421K","./axes.js":"8Tmim","../../meshes/quad.js":"3PqJr","../../meshes/cube.js":"79I5N","../../vertex.js":"4J2YE","../../helpers/axes.js":"99ajO","../../helpers/text.js":"fG2oi","../../helpers/pick.js":"1t2sb","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8Tmim":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _mainJs = require("./main.js"); -class Glyph { - toJSON() { - return { - key: this.key, - char: this.char, - width: this.width, - height: this.height, - top: this.top, - left: this.left, - advance: this.advance, - u0: this.u0, - v0: this.v0, - u1: this.u1, - v1: this.v1 - }; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AxesVisual", ()=>AxesVisual); +parcelHelpers.export(exports, "AxesBase", ()=>AxesBase); +var _glMatrix = require("gl-matrix"); +class AxesVisual { + render(elapsedTime, xrFrame) {} + update(elapsedTime) {} + constructor(axes){ + this.axes = axes; } } -class FontVisual { - update() {} - constructor(font){ - this.font = font; +class AxesBase { + get isInitialized() { + return this._isInitialized; } -} -class Font { - get atlas() { - return this._rasterizer.fontAtlas; + set vMatrix(value) { + this._vMatrix = value; } - get count() { - return this._chars.size; + pickGrid(id) { + const offset = id * 3; + return { + divisionX: this._pickGrid[offset] - 1, + divisionY: this._pickGrid[offset + 1] - 1, + divisionZ: this._pickGrid[offset + 2] - 1 + }; } - constructor(core, rasterizer){ - this._core = core; - this._rasterizer = rasterizer; - this._chars = new Set(); - this._previousSize = 0; - this.glyphs = {}; + pickTitle(id) { + return { + axis: this._pickTitle[id] + }; } - addGlyph(char) { - if (!this._chars.has(char)) { - this._chars.add(char); - this._rasterizer.draw(char); + pickLabel(id) { + const offset = id * 2; + return { + axis: this._pickLabel[offset], + label: this._pickLabel[offset + 1] + }; + } + pickHeading(id) { + return { + axis: this._pickHeading[id] + }; + } + getFromValues(index) { + return this._fromValues[index]; + } + setFromValues(index, value) { + if (this._fromValues[index] != value) { + this._fromValues[index] = value; this._hasChanged = true; } } - update() { - if (this._hasChanged) { - this._hasChanged = false; - this._core.log.write((0, _mainJs.LogLevel).info, `${this.name} added ${this._chars.size - this._previousSize} new glyphs`); - this._previousSize = this._chars.size; - if (this.hasChangedCallback) this.hasChangedCallback(); - } + getToValues(index) { + return this._toValues[index]; } - toJSON() { - const glyphs = []; - for(let key in this.glyphs){ - const glyph = this.glyphs[key]; - glyphs.push(glyph.toJSON()); + setToValues(index, value) { + if (this._toValues[index] != value) { + this._toValues[index] = value; + this._hasChanged = true; } - return { - name: this.name, - size: this.size, - border: this.border, - glyphs: glyphs, - edgeValue: this.edgeValue - }; - } -} -class FontAtlas { - constructor(width, height){ - const canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - const context = canvas.getContext("2d"); - context.clearRect(0, 0, width, height); - this.imageData = context.getImageData(0, 0, width, height); - this.x = 0; - this.top = new Uint16Array(width); } -} -class FontRasterizer { get font() { return this._font; } - get fontAtlas() { - return this._fontAtlas; + set font(value) { + if (this._font != value) { + this._font = value; + this._hasChanged = true; + } } - constructor(core, options){ - let start = performance.now(); + get gridPickDivisionHeight() { + return this._gridPickDivisionHeight; + } + set gridPickDivisionHeight(value) { + if (this._gridPickDivisionHeight != value) { + this._gridPickDivisionHeight = value; + this._hasChanged = true; + } + } + constructor(core){ this._core = core; - this._fontAtlas = options.fontAtlas; - this._fontSize = options.fontSize; - this._border = options.border; - this._fontFamily = options.fontFamily; - this._fontWeight = options.fontWeight; - this._fontStyle = options.fontStyle; - this._baseline = options.baseline; - this._maxDistance = options.maxDistance; - this._edgeValue = options.edgeValue; - this._font = new Font(core, this); - this._font.name = `${this._fontFamily}${this._fontSize}${this._fontWeight == "normal" ? "" : this._fontWeight}${this._fontStyle == "normal" ? "" : this._fontStyle}`.replace(/[^a-z0-9,]/ig, "").toLowerCase(); - this._font.size = this._fontSize; - this._font.border = this._border; - this._font.edgeValue = this._edgeValue; - const glyphRasterizerOptions = { - baseline: this._baseline, - border: this._border, - edgeValue: this._edgeValue, - fontFamily: this._fontFamily, - fontSize: this._fontSize, - fontStyle: this._fontStyle, - fontWeight: this._fontWeight, - maxDistance: this._maxDistance + this._mMatrix = (0, _glMatrix.mat4).create(); + this._mvMatrix = (0, _glMatrix.mat4).create(); + this._textMetric = { + maxTop: 0, + width: 0, + maxHeight: 0 }; - this._glyphRasterizer = new GlyphRasterizer(core, glyphRasterizerOptions); - this._core.log.write((0, _mainJs.LogLevel).info, `font rasterizer ${Math.round(window.performance.now() - start)}ms`); + this._gridPickDivisionHeight = core.config.axesGridPickDivisionHeight; + this.textBorderWidth = core.config.textBorderWidth; + this.gamma = 0; + this.gridMajorThickness = core.config.axesGridMajorThickness; + this.gridMinorThickness = core.config.axesGridMinorThickness; + this.gridZeroThickness = core.config.axesGridZeroThickness; + this._font = core.font; + this.isGridPickingEnabled = false; } - draw(char) { - const glyph = this._glyphRasterizer.draw(char); - const texWidth = glyph.width + 2 * this._border; - const texHeight = glyph.height + 2 * this._border; - const width = this._fontAtlas.imageData.width; - const height = this._fontAtlas.imageData.height; - if (this._fontAtlas.x + texWidth > width) this._fontAtlas.x = 0; - let y = 0; - for(let x = this._fontAtlas.x; x < this._fontAtlas.x + texWidth; x++)y = Math.max(y, this._fontAtlas.top[x]); - if (y + texHeight > height) this._core.log.write((0, _mainJs.LogLevel).warn, `${this._font.name} height overflow`); - for(let x1 = this._fontAtlas.x; x1 < this._fontAtlas.x + texWidth; x1++)this._fontAtlas.top[x1] = y + texHeight; - glyph.u0 = this._fontAtlas.x / width; - glyph.v0 = y / height; - glyph.u1 = (this._fontAtlas.x + texWidth) / width; - glyph.v1 = (y + texHeight) / height; - this._font.glyphs[char] = glyph; - for(let i = 0; i < glyph.distances.length; i++){ - const distance = glyph.distances[i]; - const dataX = i % texWidth; - const dataY = Math.floor(i / texWidth); - const offset = (this._fontAtlas.x + dataX + (y + dataY) * width) * 4; - this._fontAtlas.imageData.data[offset + 0] = distance; - this._fontAtlas.imageData.data[offset + 1] = distance; - this._fontAtlas.imageData.data[offset + 2] = distance; - this._fontAtlas.imageData.data[offset + 3] = 0xff; + update(elapsedTime) {} +} + +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3PqJr":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Quad", ()=>Quad); +parcelHelpers.export(exports, "Grid", ()=>Grid); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _vertexJs = require("../vertex.js"); +class Quad { + static positions(transform) { + const positions = new Float32Array(12); + const position = (0, _glMatrix.vec3).create(); + for(let i = 0; i < 4; i++){ + (0, _glMatrix.vec3).set(position, this.POSITIONS[i * 3], this.POSITIONS[i * 3 + 1], this.POSITIONS[i * 3 + 2]); + (0, _glMatrix.vec3).transformMat4(position, position, transform); + positions[i * 3] = position[0]; + positions[i * 3 + 1] = position[1]; + positions[i * 3 + 2] = position[2]; } - this._fontAtlas.x += texWidth; + return positions; } -} -class GlyphRasterizer { - constructor(core, options){ - let start = performance.now(); - this._core = core; - this._fontSize = options.fontSize; - this._border = options.border; - this._fontFamily = options.fontFamily; - this._fontWeight = options.fontWeight; - this._fontStyle = options.fontStyle; - this._baseline = options.baseline; - this._maxDistance = options.maxDistance; - this._edgeValue = options.edgeValue; - this._size = this._fontSize + this._border * 2; - this._size += this._border * 2; - this._gridOuter = new Float64Array(this._size * this._size); - this._gridInner = new Float64Array(this._size * this._size); - this._f = new Float64Array(this._size); - this._z = new Float64Array(this._size + 1); - this._v = new Uint16Array(this._size); - const canvas = document.createElement("canvas"); - canvas.width = canvas.height = this._size; - this._context = canvas.getContext("2d", { - willReadFrequently: true - }); - this._context.font = `${this._fontStyle} ${this._fontWeight} ${this._fontSize}px ${this._fontFamily} `; - this._context.textBaseline = this._baseline; - this._context.textAlign = "left"; - this._context.fillStyle = "black"; - this._core.log.write((0, _mainJs.LogLevel).info, `glyph rasterizer ${Math.round(window.performance.now() - start)}ms`); + static textured(transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { + const positions = this.positions(transform); + const texCoords = this.TEX_COORDS; + const vertices = new ArrayBuffer((0, _vertexJs.PositionTextureVertex).SIZE_BYTES * positions.length / 3); + const verticesView = new DataView(vertices); + const position = (0, _glMatrix.vec3).create(); + const texCoord = (0, _glMatrix.vec2).create(); + for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ + (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); + (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, texTransform); + (0, _vertexJs.PositionTextureVertex).setPosition(verticesView, i, position); + (0, _vertexJs.PositionTextureVertex).setTexCoord(verticesView, i, texCoord); + } + return verticesView; } - draw(char) { - const textMetrics = this._context.measureText(char); - const glyphLeft = 0; - const glyphTop = Math.floor(textMetrics.actualBoundingBoxAscent); - let glyphWidth = Math.ceil(textMetrics.actualBoundingBoxRight); - let glyphHeight = Math.ceil(textMetrics.actualBoundingBoxAscent) + Math.ceil(textMetrics.actualBoundingBoxDescent); - glyphWidth = Math.min(this._size - this._border, glyphWidth); - glyphHeight = Math.min(this._size - this._border, glyphHeight); - const width = glyphWidth + 2 * this._border; - const height = glyphHeight + 2 * this._border; - const length = width * height; - const distances = new Uint8ClampedArray(length); - const gradientsX = new Uint8ClampedArray(length); - const gradientsY = new Uint8ClampedArray(length); - const pixels = new Uint8ClampedArray(length); - const glyph = new Glyph(); - glyph.char = char; - glyph.key = char.codePointAt(0); - glyph.distances = distances; - glyph.gradientsX = gradientsX; - glyph.gradientsY = gradientsY; - glyph.pixels = pixels; - glyph.width = glyphWidth; - glyph.height = glyphHeight; - glyph.top = glyphTop; - glyph.left = glyphLeft; - glyph.advance = textMetrics.width; - if (glyphWidth == 0 || glyphHeight == 0) return glyph; - this._context.clearRect(this._border, this._border, glyphWidth, glyphHeight); - this._context.fillText(char, this._border, this._border + glyphTop); - const imgData = this._context.getImageData(this._border, this._border, glyphWidth, glyphHeight); - for(let i = 0; i < length; i++){ - this._gridOuter[i] = Number.MAX_VALUE; - this._gridInner[i] = 0; + static normalTextured(transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { + const positions = this.positions(transform); + const texCoords = this.TEX_COORDS; + const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * positions.length / 3); + const verticesView = new DataView(vertices); + const position = (0, _glMatrix.vec3).create(); + const texCoord = (0, _glMatrix.vec2).create(); + const normal3 = (0, _glMatrix.vec3).create(); + const normal4 = (0, _glMatrix.vec4).create(); + for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ + (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); + (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, texTransform); + (0, _vertexJs.PositionNormalTextureVertex).setPosition(verticesView, i, position); + (0, _glMatrix.vec4).set(normal4, 0.0, 0.0, 1.0, 0.0); + (0, _glMatrix.vec4).transformMat4(normal4, normal4, transform); + (0, _glMatrix.vec3).set(normal3, normal4[0], normal4[1], normal4[2]); + (0, _glMatrix.vec3).normalize(normal3, normal3); + (0, _vertexJs.PositionNormalTextureVertex).setNormal(verticesView, i, normal3); + (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(verticesView, i, texCoord); } - for(let y = 0; y < glyphHeight; y++)for(let x = 0; x < glyphWidth; x++){ - const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 0xff; - if (a > 0) { - const j = (y + this._border) * width + x + this._border; - if (a == 1) { - this._gridOuter[j] = 0; - this._gridInner[j] = Number.MAX_VALUE; - } else { - const d = 0.5 - a; - this._gridOuter[j] = d > 0 ? d * d : 0; - this._gridInner[j] = d < 0 ? d * d : 0; - pixels[j] = 0xff; - } - } + return verticesView; + } +} +Quad.FACE_NORMALS = [ + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(0, 0, -1) +]; +Quad.FACE_ROTATIONS = [ + (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, 1, 0, 0, 0, 1), + (0, _glMatrix.mat3).fromValues(1, 0, 0, 0, -1, 0, 0, 0, -1) +]; +Quad.EDGE_POSITIONS = [ + (0, _glMatrix.vec3).fromValues(0, 0.5, 0), + (0, _glMatrix.vec3).fromValues(0.5, 0, 0), + (0, _glMatrix.vec3).fromValues(0, -0.5, 0), + (0, _glMatrix.vec3).fromValues(-0.5, 0, 0) +]; +Quad.EDGE_NORMALS = [ + (0, _glMatrix.vec3).fromValues(0, 1, 0), + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, -1, 0), + (0, _glMatrix.vec3).fromValues(-1, 0, 0) +]; +Quad.EDGE_POSITIVES = [ + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, 1, 0), + (0, _glMatrix.vec3).fromValues(1, 0, 0), + (0, _glMatrix.vec3).fromValues(0, 1, 0) +]; +Quad.EDGE_FORWARDS = [ + (0, _glMatrix.vec3).fromValues(0, 0, -1), + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(0, 0, 1), + (0, _glMatrix.vec3).fromValues(0, 0, -1) +]; +Quad.AXIS_EDGES = [ + [ + 0, + 2 + ], + [ + 1, + 3 + ] +]; +Quad.POSITIONS = new Float32Array([ + -0.5, + 0.5, + 0, + 0.5, + 0.5, + 0, + -0.5, + -0.5, + 0, + 0.5, + -0.5, + 0 +]); +Quad.INDICES = new Uint16Array([ + 0, + 2, + 1, + 1, + 2, + 3 +]); +Quad.TEX_COORDS = new Float32Array([ + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0 +]); +class Grid { + static positions(cols, rows, transform) { + const vertices = new Float32Array((cols + 1) * (rows + 1) * (0, _vertexJs.PositionVertex).SIZE); + const position = (0, _glMatrix.vec3).create(); + let index = 0; + for(let row = 0; row <= rows; row++)for(let col = 0; col <= cols; col++){ + (0, _glMatrix.vec3).set(position, col / cols - 0.5, 0.5 - row / rows, 0); + (0, _glMatrix.vec3).transformMat4(position, position, transform); + (0, _vertexJs.PositionVertex).setPosition(vertices, index++, position); } - this._edt(this._gridOuter, 0, 0, width, height, width, this._f, this._v, this._z); - this._edt(this._gridInner, this._border, this._border, glyphWidth, glyphHeight, width, this._f, this._v, this._z); - const distances2 = new Float32Array(length); - for(let i1 = 0; i1 < length; i1++){ - const distance = Math.sqrt(this._gridOuter[i1]) - Math.sqrt(this._gridInner[i1]); - distances[i1] = Math.round(this._edgeValue - distance * 0xff / this._maxDistance); - distances2[i1] = distance; - } - for(let i2 = 0; i2 < length; i2++){ - const x1 = i2 % width; - const y1 = Math.floor(i2 / width); - const d1 = distances2[i2]; - const sign = d1 < 0 ? -1 : 1; - const x0 = x1 > 0 ? distances2[i2 - 1] : Number.MAX_VALUE; - const x11 = x1 < width - 1 ? distances2[i2 + 1] : Number.MAX_VALUE; - const y0 = y1 > 0 ? distances2[i2 - width] : Number.MAX_VALUE; - const y11 = y1 < height - 1 ? distances2[i2 + width] : Number.MAX_VALUE; - let gradientX = sign * x0 < sign * x11 ? d1 - x0 : x11 - d1; - let gradientY = sign * y0 < sign * y11 ? y0 - d1 : d1 - y11; - gradientsX[i2] = Math.round((gradientX * 0.5 + 0.5) * 0xff); - gradientsY[i2] = Math.round((gradientY * 0.5 + 0.5) * 0xff); + return vertices; + } + static indices(cols, rows) { + const indices = new Uint16Array(cols * rows * 6); + let index = 0; + for(let row = 0; row < rows; row++)for(let col = 0; col < cols; col++){ + indices[index++] = col + row * (cols + 1); + indices[index++] = col + (row + 1) * (cols + 1); + indices[index++] = col + row * (cols + 1) + 1; + indices[index++] = col + row * (cols + 1) + 1; + indices[index++] = col + (row + 1) * (cols + 1); + indices[index++] = col + (row + 1) * (cols + 1) + 1; } - return glyph; + return indices; } - _edt(data, x0, y0, width, height, gridSize, f, v, z) { - for(let x = x0; x < x0 + width; x++)this._edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); - for(let y = y0; y < y0 + height; y++)this._edt1d(data, y * gridSize + x0, 1, width, f, v, z); + static textured(cols, rows, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { + const positions = this.positions(cols, rows, transform); + const texCoords = this._texCoords(cols, rows, texTransform); + const vertices = new ArrayBuffer((0, _vertexJs.PositionTextureVertex).SIZE_BYTES * positions.length / 3); + const verticesView = new DataView(vertices); + const position = (0, _glMatrix.vec3).create(); + const texCoord = (0, _glMatrix.vec2).create(); + let index = 0; + for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ + (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); + (0, _vertexJs.PositionTextureVertex).setPosition(verticesView, index, position); + (0, _vertexJs.PositionTextureVertex).setTexCoord(verticesView, index++, texCoord); + } + return verticesView; } - _edt1d(grid, offset, stride, n, f, v, z) { - v[0] = 0; - z[0] = -Number.MAX_VALUE; - z[1] = Number.MAX_VALUE; - f[0] = grid[offset]; - for(let q = 1, k = 0, s = 0; q < n; q++){ - f[q] = grid[offset + q * stride]; - const q2 = q * q; - do { - const r = v[k]; - s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; - }while (s <= z[k] && --k > -1); - k++; - v[k] = q; - z[k] = s; - z[k + 1] = Number.MAX_VALUE; + static normalTextured(cols, rows, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { + const positions = this.positions(cols, rows, transform); + const texCoords = this._texCoords(cols, rows, texTransform); + const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * positions.length / 3); + const verticesView = new DataView(vertices); + const position = (0, _glMatrix.vec3).create(); + const texCoord = (0, _glMatrix.vec2).create(); + let index = 0; + for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ + (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); + (0, _vertexJs.PositionNormalTextureVertex).setPosition(verticesView, index, position); + (0, _vertexJs.PositionNormalTextureVertex).setNormal(verticesView, index, (0, _constantsJs.Constants).VECTOR3_UNITZ); + (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(verticesView, index++, texCoord); } - for(let q1 = 0, k1 = 0; q1 < n; q1++){ - while(z[k1 + 1] < q1)k1++; - const r1 = v[k1]; - const qr = q1 - r1; - grid[offset + q1 * stride] = f[r1] + qr * qr; + return verticesView; + } + static _texCoords(cols, rows, transform) { + const texCoords = new Float32Array((cols + 1) * (rows + 1) * 2); + const texCoord = (0, _glMatrix.vec2).create(); + let index = 0; + for(let row = 0; row <= rows; row++)for(let col = 0; col <= cols; col++){ + (0, _glMatrix.vec2).set(texCoord, col / cols, 1 - row / rows); + (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, transform); + texCoords[index++] = texCoord[0]; + texCoords[index++] = texCoord[1]; } + return texCoords; } } -},{"./main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"75sHN":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Manager", ()=>Manager); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"99ajO":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -var _manipulationprocessorJs = require("./manipulationprocessor.js"); -var _mousewheelJs = require("./mousewheel.js"); -var _pointersJs = require("./pointers.js"); -var _animationJs = require("../helpers/animation.js"); -var _constantsJs = require("../constants.js"); -var _keyboardJs = require("./keyboard.js"); -class Manager { - constructor(core){ - this._manipulators = {}; - this._core = core; - this._vec3 = (0, _glMatrix.vec3).create(); - this._manipulationProcessor = new (0, _manipulationprocessorJs.ManipulationProcessor)(core); - this._manipulators = {}; - this._pointers = new (0, _pointersJs.Pointers)(core, this._manipulators); - this._pointers.initialize(core.container); - this._mouseWheel = new (0, _mousewheelJs.MouseWheel)(core); - this._mouseWheel.initialize(core.container); - this._keyboard = new (0, _keyboardJs.Keyboard)(core); - this._keyboard.initialize(core.container); - this.isPickingEnabled = true; - this.mouseWheelZoomScale = this._core.config.mouseWheelZoomScale; - this.mouseWheelRotationScale = this._core.config.mouseWheelRotationScale; - this.multiTouchZoomScale = this._core.config.multiTouchZoomScale; - this.pickHoldDelay = this._core.config.pickHoldDelay; - this.pickSelectDelay = this._core.config.pickSelectDelay; - const rightButton = 2; - this.singleTouchAction = (manipulator)=>{ - if (manipulator.type == "mouse" && manipulator.button == rightButton || manipulator.shiftKey || manipulator.ctrlKey) return (0, _mainJs.SingleTouchAction).translate; - else if (manipulator.altKey || manipulator.type == "pen" && manipulator.button == rightButton) return (0, _mainJs.SingleTouchAction).lasso; - else return (0, _mainJs.SingleTouchAction).rotate; - }; - this.mouseWheelAction = (keyboard)=>{ - if (this._keyboard.isKeyDown("Control")) return (0, _mainJs.MouseWheelAction).rotateY; - else return (0, _mainJs.MouseWheelAction).zoom; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AxisHelper", ()=>AxisHelper); +class AxisHelper { + static continuous(options) { + const labels = []; + const positions = []; + const fromValues = []; + const toValues = []; + const label = options.label || ((value)=>{ + return value.toString(); + }); + for(let i = 0; i <= options.divisions; i++){ + positions.push(options.divisions == 0 ? 0.5 : i / options.divisions); + const value = options.divisions == 0 ? (options.min + options.max) / 2 : options.min + i * (options.max - options.min) / options.divisions; + labels.push(label(value)); + if (i == 0) fromValues.push(options.min); + else if (i < options.divisions) { + toValues.push(value); + fromValues.push(value); + } + } + toValues.push(options.max); + return { + labels: labels, + positions: positions, + fromValues: fromValues, + toValues: toValues }; - this.lassoPickType = (0, _mainJs.PickType).data; - this._thumbstickX = 0; - this._previousControllerButtonPressed = [ - false, - false, - false, - false - ]; - this._quat0 = (0, _glMatrix.quat).create(); - this._quat1 = (0, _glMatrix.quat).create(); } - update(elapsedTime, xrFrame) { - if (xrFrame) { - const inputSources = this._core.webXRSession.inputSources; - if (inputSources.length > 0 && this._core.renderer.controllers.length > 0) { - const inputSource = inputSources[0]; - const controllerVisual = this._core.renderer.controllers[0]; - if (inputSource.gripSpace && inputSource.targetRayMode == "tracked-pointer") { - const gripPose = xrFrame.getPose(inputSource.gripSpace, this._core.renderer.webXRReferenceSpace); - if (gripPose) controllerVisual.mMatrix = gripPose.transform.matrix; - const gamepad = inputSource.gamepad; - this._core.renderer.isPickingEnabled = false; - const rayPose = xrFrame.getPose(inputSource.targetRaySpace, this._core.renderer.webXRReferenceSpace); - if (rayPose) { - controllerVisual.rayMMatrix = rayPose.transform.matrix; - if (gamepad.buttons[0].value > 0 && this.isPickingEnabled) { - this._core.renderer.pickVMatrix = rayPose.transform.inverse.matrix; - this._core.renderer.isPickingEnabled = true; - } - } - const threshold = 0.2; - const dampening = Math.min(0.015 * elapsedTime, 1); - this._thumbstickX = (0, _animationJs.AnimationHelper).damp(this._thumbstickX, gamepad.axes[2], threshold, dampening); - if (this._thumbstickX != 0) { - (0, _glMatrix.quat).setAxisAngle(this._quat0, (0, _constantsJs.Constants).VECTOR3_UNITY, 0.01 * this._thumbstickX * elapsedTime); - this._core.getModelRotation(this._quat1); - (0, _glMatrix.quat).multiply(this._quat1, this._quat0, this._quat1); - this._core.setModelRotation(this._quat1, true); - } - if (gamepad.buttons[2].pressed) { - if (!this._previousControllerButtonPressed[2]) { - this._previousControllerButtonPressed[2] = true; - if (this.controllerButtonPressedCallback) this.controllerButtonPressedCallback(2); - } - } else this._previousControllerButtonPressed[2] = false; - } - } - } else { - const camera = this._core.camera; - this._manipulationProcessor.update(elapsedTime, this._manipulators); - this._pointers.update(elapsedTime); - this._mouseWheel.update(elapsedTime); - this._keyboard.update(elapsedTime); - if (this._mouseWheel.delta != 0) switch(this.mouseWheelAction(this._keyboard)){ - case (0, _mainJs.MouseWheelAction).zoom: - if (this._pointers.hoverX, this._pointers.hoverY) camera.zoom(this._mouseWheel.delta * this.mouseWheelZoomScale, this._pointers.hoverX, this._pointers.hoverY); - break; - case (0, _mainJs.MouseWheelAction).rotateY: - (0, _glMatrix.quat).setAxisAngle(this._quat0, (0, _constantsJs.Constants).VECTOR3_UNITY, this._mouseWheel.delta * this.mouseWheelRotationScale); - camera.getOrbit(this._quat1); - (0, _glMatrix.quat).multiply(this._quat1, this._quat1, this._quat0); - camera.setOrbit(this._quat1, true); - break; - } - const count = this._manipulationProcessor.count; - if (count == 0) { - if (this._isLassoPicking) { - this._isLassoPicking = false; - this._core.renderer.isLassoPicking = false; - const x0 = Math.min(this._lassoX0, this._lassoX1); - const y0 = Math.min(this._lassoY0, this._lassoY1); - const x1 = Math.max(this._lassoX0, this._lassoX1); - const y1 = Math.max(this._lassoY0, this._lassoY1); - if (x1 - x0 > 0 && y1 - y0 > 0) { - const sets = this._core.pickLasso(x0, y0, x1, y1, this.lassoPickType); - const result = { - x0: x0, - y0: y0, - x1: x1, - y1: y1, - pickType: this.lassoPickType, - ids: sets, - manipulator: this._manipulator - }; - this.pickLassoCallback(result); - } - } - } else if (count == 1) { - const translationDelta = this._manipulationProcessor.translationDelta; - if (translationDelta[0] != 0 || translationDelta[1] != 0) { - const manipulators = this._manipulationProcessor.manipulators; - for(const key in manipulators){ - const manipulator = manipulators[key]; - switch(this.singleTouchAction(manipulator)){ - case (0, _mainJs.SingleTouchAction).rotate: - camera.rotate(translationDelta); - break; - case (0, _mainJs.SingleTouchAction).translate: - camera.translate(translationDelta); - break; - case (0, _mainJs.SingleTouchAction).lasso: - if (this.pickLassoCallback) { - if (!this._isLassoPicking) { - this._isLassoPicking = true; - this._core.renderer.isLassoPicking = true; - this._lassoX0 = manipulator.position[0]; - this._lassoY0 = manipulator.position[1]; - } - this._lassoX1 = manipulator.position[0]; - this._lassoY1 = manipulator.position[1]; - this._core.renderer.lassoX0 = Math.min(this._lassoX0, this._lassoX1); - this._core.renderer.lassoY0 = Math.min(this._lassoY0, this._lassoY1); - this._core.renderer.lassoX1 = Math.max(this._lassoX0, this._lassoX1); - this._core.renderer.lassoY1 = Math.max(this._lassoY0, this._lassoY1); - } - break; - } - break; - } - } - } else { - const translationDelta1 = this._manipulationProcessor.translationDelta; - const camera1 = this._core.camera; - if (translationDelta1[0] != 0 || translationDelta1[1] != 0) camera1.translate(translationDelta1); - if (this._manipulationProcessor.scaleDelta != 0) { - const distance = this._manipulationProcessor.scaleDelta * this.multiTouchZoomScale; - camera1.zoom(distance, this._manipulationProcessor.centroid[0], this._manipulationProcessor.centroid[1]); - } - if (this._manipulationProcessor.twistDelta != 0) camera1.twist(this._manipulationProcessor.twistDelta, this._manipulationProcessor.centroid[0], this._manipulationProcessor.centroid[1]); - } - if (this.isPickingEnabled && !this._manipulationProcessor.isDragging && !this._isLassoPicking) { - const camera2 = this._core.camera; - const renderer = this._core.renderer; - if (renderer.isCapturingPickImage) { - camera2.updatePickVMatrix(renderer.width / 2, renderer.height / 2); - renderer.pickVMatrix = camera2.pickVMatrix; - renderer.isPickingEnabled = true; - this._pickedTime = 0; - } else if (this._pointers.hoverId > -1) { - const pickingX = this._pointers.hoverX; - const pickingY = this._pointers.hoverY; - camera2.updatePickVMatrix(pickingX, pickingY); - renderer.pickVMatrix = camera2.pickVMatrix; - renderer.isPickingEnabled = true; - if (this._pickedId != renderer.pickedId) { - this._pickedId = renderer.pickedId; - this._pickedTime = 0; - } else if (this._manipulationProcessor.count == 1) { - this._pickedTime += elapsedTime; - for(const key1 in this._manipulators){ - this._manipulator = this._manipulators[key1]; - break; - } - } - if (this._pickedTime > 0) switch(renderer.pickedType){ - case (0, _mainJs.PickType).data: - if (this._pickedTime > this.pickHoldDelay) { - renderer.getVertexPosition(this._vec3, this._pickedId); - this._core.setModelManipulationOrigin(this._vec3); - this._pickedTime = 0; - } else if (this._manipulationProcessor.count == 0) { - if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.transitionBuffers.length; i++){ - const transitionBuffer = renderer.transitionBuffers[i]; - const id = transitionBuffer.pickIdLookup[this._pickedId]; - if (id > -1) { - const result1 = { - transitionBuffer: i, - id: id, - manipulator: this._manipulator - }; - this._core.log.write((0, _mainJs.LogLevel).info, `picked id ${result1.id}, transition buffer ${i}`); - if (this.pickItemCallback) this.pickItemCallback(result1); - break; - } - } - this._pickedTime = 0; - } - break; - case (0, _mainJs.PickType).label: - if (this._manipulationProcessor.count == 0) { - if (this._pickedTime > this.pickSelectDelay) for(let i1 = 0; i1 < renderer.labelSets.length; i1++){ - const labelSet = renderer.labelSets[i1].label; - const id1 = labelSet.pickIdLookup[this._pickedId]; - if (id1 > -1) { - const result2 = { - label: id1, - set: i1, - manipulator: this._manipulator - }; - this._core.log.write((0, _mainJs.LogLevel).info, `picked label ${result2.label}, set ${result2.set}`); - if (this.pickLabelSetCallback) this.pickLabelSetCallback(result2); - break; - } - } - this._pickedTime = 0; - } - break; - case (0, _mainJs.PickType).axesDivision: - if (this._manipulationProcessor.count == 0) { - if (this._pickedTime > this.pickSelectDelay) for(let i2 = 0; i2 < renderer.currentAxes.length; i2++){ - const axes = renderer.currentAxes[i2].axes; - const id2 = axes.pickGridLookup[this._pickedId]; - if (id2 > -1) { - const result3 = axes.pickGrid(id2); - result3.axes = i2; - result3.manipulator = this._manipulator; - this._core.log.write((0, _mainJs.LogLevel).info, `picked division (${result3.divisionX}, ${result3.divisionY}, ${result3.divisionZ}), axes ${result3.axes}`); - if (this.pickAxesGridCallback) this.pickAxesGridCallback(result3); - break; - } - } - this._pickedTime = 0; - } - break; - case (0, _mainJs.PickType).axesTitle: - if (this._manipulationProcessor.count == 0) { - if (this._pickedTime > this.pickSelectDelay) for(let i3 = 0; i3 < renderer.currentAxes.length; i3++){ - const axes1 = renderer.currentAxes[i3].axes; - const id3 = axes1.pickTitleLookup[this._pickedId]; - if (id3 > -1) { - const result4 = axes1.pickTitle(id3); - result4.axes = i3; - result4.manipulator = this._manipulator; - this._core.log.write((0, _mainJs.LogLevel).info, `picked title ${result4.axis}, axes ${result4.axes}`); - if (this.pickAxesTitleCallback) this.pickAxesTitleCallback(result4); - break; - } - } - this._pickedTime = 0; - } - break; - case (0, _mainJs.PickType).axesLabel: - if (this._manipulationProcessor.count == 0) { - if (this._pickedTime > this.pickSelectDelay) for(let i4 = 0; i4 < renderer.currentAxes.length; i4++){ - const axes2 = renderer.currentAxes[i4].axes; - const id4 = axes2.pickLabelLookup[this._pickedId]; - if (id4 > -1) { - const result5 = axes2.pickLabel(id4); - result5.axes = i4; - result5.manipulator = this._manipulator; - this._core.log.write((0, _mainJs.LogLevel).info, `picked label ${result5.label}, axis ${result5.axis}, axes ${result5.axes}`); - if (this.pickAxesLabelCallback) this.pickAxesLabelCallback(result5); - break; - } - } - this._pickedTime = 0; - } - break; - case (0, _mainJs.PickType).axesHeading: - if (this._manipulationProcessor.count == 0) { - if (this._pickedTime > this.pickSelectDelay) for(let i5 = 0; i5 < renderer.currentAxes.length; i5++){ - const axes3 = renderer.currentAxes[i5].axes; - const id5 = axes3.pickHeadingLookup[this._pickedId]; - if (id5 > -1) { - const result6 = axes3.pickHeading(id5); - result6.axes = i5; - result6.manipulator = this._manipulator; - this._core.log.write((0, _mainJs.LogLevel).info, `picked heading ${result6.axis}, axes ${result6.axes}`); - if (this.pickAxesHeadingCallback) this.pickAxesHeadingCallback(result6); - break; - } - } - this._pickedTime = 0; - } - break; - } - } else { - renderer.isPickingEnabled = false; - this._pickedTime = 0; - } + static discrete(options) { + const divisions = options.maxDivisions !== undefined ? Math.min(options.divisions, options.maxDivisions) : options.divisions; + const divisionStep = 1 / options.divisions; + const labelStep = 1 / divisions; + const valueStep = (options.max - options.min + 1) / options.divisions; + let nextDivision, toValue, nextPosition; + const labels = []; + const labelPositions = []; + const tickPositions = []; + const fromValues = []; + const toValues = []; + const label = options.label || ((value)=>{ + return value.toString(); + }); + const fromToLabel = options.fromToLabel || ((fromValue, toValue)=>{ + return `${label(fromValue)}-${label(toValue)}`; + }); + for(let i = 0; i < divisions; i++){ + const division = Math.round(i * labelStep / divisionStep); + const tickPosition = division / options.divisions; + const fromValue = options.min + Math.ceil(division * valueStep); + if (i == divisions - 1) { + nextDivision = divisions; + nextPosition = 1; + toValue = options.max; } else { - this._core.renderer.isPickingEnabled = false; - this._pickedTime = 0; + nextDivision = Math.round((i + 1) * labelStep / divisionStep); + nextPosition = nextDivision / options.divisions; + toValue = options.min + Math.ceil(nextDivision * valueStep) - 1; } + labelPositions.push((tickPosition + nextPosition) / 2); + labels.push(fromValue == toValue ? label(fromValue) : fromToLabel(fromValue, toValue)); + fromValues.push(fromValue); + toValues.push(toValue); + tickPositions.push(tickPosition); } - if (this._core.config.isDebugVisible) { - this._core.debugText.addLine(`man tot ${this._manipulationProcessor.count}`); - this._core.debugText.addLine(`pck key ${this._core.renderer.pickedId}`); - } + tickPositions.push(1); + return { + labels: labels, + labelPositions: labelPositions, + tickPositions: tickPositions, + fromValues: fromValues, + toValues: toValues + }; } } -},{"gl-matrix":"9GjEQ","../main.js":"1Kju3","./manipulationprocessor.js":"aEJdc","./mousewheel.js":"9by4z","./pointers.js":"1WwTm","../helpers/animation.js":"iA4Fe","../constants.js":"2Scl5","./keyboard.js":"7b1bp","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aEJdc":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ManipulationProcessor", ()=>ManipulationProcessor); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fG2oi":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mathJs = require("../helpers/math.js"); -var _angleJs = require("../helpers/angle.js"); -class ManipulationProcessor { - get manipulators() { - return this._manipulators; - } - get count() { - return this._count; - } - get isDragging() { - return this._isDragging; - } - constructor(core){ - this._core = core; - this._count = 0; - this._centroid = (0, _glMatrix.vec3).create(); - this._previousCentroid = (0, _glMatrix.vec3).create(); - this._relativePositionToCentroid = (0, _glMatrix.vec3).create(); - this._directionToCentroid = (0, _glMatrix.vec3).create(); - this._previousDirectionToCentroid = (0, _glMatrix.vec3).create(); - this._manipulators = {}; - this._removedManipulators = []; - this.cumulativeTranslation = (0, _glMatrix.vec3).create(); - this.translationDelta = (0, _glMatrix.vec3).create(); - this.centroid = (0, _glMatrix.vec3).create(); - this.maxScale = Number.MAX_VALUE; - this.twistAxis = (0, _glMatrix.vec3).fromValues(0, 0, 1); - this.initialize(); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "TextHelper", ()=>TextHelper); +var _glMatrix = require("gl-matrix"); +var _vertexJs = require("../vertex.js"); +var _quadJs = require("../meshes/quad.js"); +class TextHelper { + static truncate(text, length) { + return text.length > length ? `${text.substr(0, length - 1)}\u{2026}` : text; } - update(elapsedTime, manipulators) { - for(const key in this._manipulators){ - const manipulator = this._manipulators[key]; - if (!manipulators[manipulator.id]) { - if (this.removeManipulator) this.removeManipulator(manipulator); - this._removedManipulators.push(manipulator.id); - } - } - if (this._removedManipulators.length > 0) { - for(let i = 0; i < this._removedManipulators.length; i++){ - delete this._manipulators[this._removedManipulators[i]]; - this._count--; + static measure(font, text, size) { + size.width = 0; + let maxDescent = 0; + for (const char of text){ + let glyph = font.glyphs[char]; + if (!glyph) { + font.addGlyph(char); + glyph = font.glyphs[char]; } - this._removedManipulators = []; + size.width += glyph.advance; + size.maxTop = Math.max(glyph.top, size.maxTop); + maxDescent = Math.max(glyph.height - glyph.top, maxDescent); } - for(const key1 in manipulators){ - const manipulator1 = manipulators[key1]; - if (!this._manipulators[manipulator1.id]) { - if (!this.addManipulator || this.addManipulator(manipulator1)) { - (0, _glMatrix.vec3).copy(manipulator1.initialPosition, manipulator1.position); - this._manipulators[manipulator1.id] = manipulator1; - this._count++; - } + size.maxHeight = size.maxTop + maxDescent; + } + static wrap(font, text, maxWidth) { + const lines = []; + let width = 0; + let start = 0; + let lastBreakingChar = -1; + let widthAfterLastBreakingChar = 0; + for(let i = 0; i < text.length; i++){ + let char = text.charAt(i); + let glyph = font.glyphs[char]; + if (!glyph) { + font.addGlyph(char); + glyph = font.glyphs[char]; } - } - (0, _glMatrix.vec3).set(this.translationDelta, 0, 0, 0); - this.scaleDelta = 0; - this.twistDelta = 0; - if (this._count > 0) { - if (this._previousCount > 0) { - if (this.prepareManipulation) this.prepareManipulation(); - this._process(); - if (this.processManipulation) this.processManipulation(elapsedTime); - } else { - this.initialize(); - if (this.beginManipulation) this.beginManipulation(); + width += glyph.advance; + if (char == " " || char == "-") { + widthAfterLastBreakingChar = width; + lastBreakingChar = i; } - } else { - if (this._previousCount > 0) { - if (this.endManipulation) this.endManipulation(); + if (width > maxWidth) { + if (lastBreakingChar == -1) { + lines.push(text.substring(start, i)); + start = i; + width += glyph.advance; + } else { + lines.push(text.substring(start, lastBreakingChar)); + start = lastBreakingChar + 1; + width -= widthAfterLastBreakingChar; + widthAfterLastBreakingChar = 0; + lastBreakingChar = -1; + } } } - this._isDragging = this._count == 1 && (0, _glMatrix.vec3).squaredLength(this.cumulativeTranslation) > this._core.config.dragToleranceSquared || this._count > 1; - this._previousCount = this._count; + lines.push(text.substring(start, text.length)); + return lines; } - initialize() { - (0, _glMatrix.vec3).set(this.centroid, 0, 0, 0); - (0, _glMatrix.vec3).set(this.cumulativeTranslation, 0, 0, 0); - this.cumulativeScale = 1; - this.cumulativeTwist = 0; + static addString(font, text, vertices, indices, index, position, scale, offset, rotation, idColor) { + for (const char of text)this.addGlyph(font, char, vertices, indices, index++, position, scale, offset, rotation, idColor); } - _process() { - if (this._previousCount > 0) { - let persisted = 0; - for(const key in this._manipulators){ - const manipulator = this._manipulators[key]; - if (manipulator.isPersisted) persisted++; - } - const removed = this._previousCount - persisted; - if (persisted > 0) { - if (removed > 0) (0, _glMatrix.vec3).copy(this._centroid, this._previousCentroid); - else { - (0, _glMatrix.vec3).set(this._centroid, 0, 0, 0); - for(const key1 in this._manipulators){ - const manipulator1 = this._manipulators[key1]; - if (manipulator1.isPersisted) (0, _glMatrix.vec3).add(this._centroid, this._centroid, manipulator1.position); - } - (0, _glMatrix.vec3).scale(this._centroid, this._centroid, 1 / persisted); - } - for(const key2 in this._manipulators){ - const manipulator2 = this._manipulators[key2]; - if (manipulator2.isPersisted) { - manipulator2.maxTranslationSquared = Math.max(manipulator2.maxTranslationSquared, (0, _glMatrix.vec3).squaredDistance(manipulator2.position, manipulator2.initialPosition)); - (0, _glMatrix.vec3).add(this.translationDelta, this.translationDelta, manipulator2.position); - (0, _glMatrix.vec3).subtract(this.translationDelta, this.translationDelta, manipulator2.previousPosition); - (0, _glMatrix.vec3).subtract(this._relativePositionToCentroid, manipulator2.position, this._centroid); - const distanceToCentroidSquared = (0, _glMatrix.vec3).squaredLength(this._relativePositionToCentroid); - if (distanceToCentroidSquared < this._core.config.manipulatorMinRelativeDistanceSquared) this.scaleDelta += 1; - else { - const distanceToCentroid = Math.sqrt(distanceToCentroidSquared); - const previousDistanceToCentroidSquared = (0, _glMatrix.vec3).squaredLength(manipulator2.previousPositionRelativeToCentroid); - const previousDistanceToCentroid = Math.sqrt(previousDistanceToCentroidSquared); - this.scaleDelta += distanceToCentroid / previousDistanceToCentroid; - (0, _glMatrix.vec3).scale(this._directionToCentroid, this._relativePositionToCentroid, 1 / distanceToCentroid); - (0, _glMatrix.vec3).scale(this._previousDirectionToCentroid, manipulator2.previousPositionRelativeToCentroid, 1 / previousDistanceToCentroid); - this.twistDelta += (0, _angleJs.AngleHelper).signedAngleBetweenVectors(this._previousDirectionToCentroid, this._directionToCentroid, this.twistAxis); - } - } - } - (0, _glMatrix.vec3).scale(this.translationDelta, this.translationDelta, 1 / persisted); - (0, _glMatrix.vec3).add(this.cumulativeTranslation, this.cumulativeTranslation, this.translationDelta); - this.scaleDelta /= persisted; - this.cumulativeScale = (0, _mathJs.MathHelper).clamp(this.cumulativeScale * this.scaleDelta, this.minScale, this.maxScale); - this.scaleDelta -= 1; - this.twistDelta /= persisted; - this.cumulativeTwist += this.twistDelta; - } - } - (0, _glMatrix.vec3).set(this.centroid, 0, 0, 0); - for(const key3 in this._manipulators){ - const manipulator3 = this._manipulators[key3]; - (0, _glMatrix.vec3).add(this.centroid, this.centroid, manipulator3.position); - } - (0, _glMatrix.vec3).scale(this.centroid, this.centroid, 1 / this._count); - for(const key4 in this._manipulators){ - const manipulator4 = this._manipulators[key4]; - (0, _glMatrix.vec3).subtract(manipulator4.positionRelativeToCentroid, manipulator4.position, this.centroid); + static addGlyph(font, char, vertices, indices, index, position, scale, offset, rotation, idColor) { + let glyph = font.glyphs[char]; + if (!glyph) { + font.addGlyph(char); + glyph = font.glyphs[char]; } - (0, _glMatrix.vec3).copy(this._previousCentroid, this.centroid); - for(const key5 in this._manipulators){ - const manipulator5 = this._manipulators[key5]; - manipulator5.isPersisted = true; - (0, _glMatrix.vec3).copy(manipulator5.previousPosition, manipulator5.position); - (0, _glMatrix.vec3).copy(manipulator5.previousRotationAxis, manipulator5.rotationAxis); - (0, _glMatrix.vec3).copy(manipulator5.previousPositionRelativeToCentroid, manipulator5.positionRelativeToCentroid); + const vertexOffset = index * 4; + const width = glyph.width * scale; + const height = glyph.height * scale; + const top = glyph.top * scale; + const border = font.border * scale; + const x0 = offset[0] - border; + const x1 = offset[0] + width + border; + const y0 = offset[1] + top + border; + const y1 = offset[1] + top - height - border; + const z0 = offset[2]; + (0, _glMatrix.vec3).set(this._topLeft, x0, y0, z0); + (0, _glMatrix.vec3).set(this._topRight, x1, y0, z0); + (0, _glMatrix.vec3).set(this._bottomLeft, x0, y1, z0); + (0, _glMatrix.vec3).set(this._bottomRight, x1, y1, z0); + if (rotation) { + (0, _glMatrix.vec3).transformQuat(this._topLeft, this._topLeft, rotation); + (0, _glMatrix.vec3).transformQuat(this._topRight, this._topRight, rotation); + (0, _glMatrix.vec3).transformQuat(this._bottomLeft, this._bottomLeft, rotation); + (0, _glMatrix.vec3).transformQuat(this._bottomRight, this._bottomRight, rotation); } + (0, _glMatrix.vec3).add(this._vec3, this._topLeft, position); + (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset, this._vec3); + (0, _glMatrix.vec3).add(this._vec3, this._topRight, position); + (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset + 1, this._vec3); + (0, _glMatrix.vec3).add(this._vec3, this._bottomLeft, position); + (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset + 2, this._vec3); + (0, _glMatrix.vec3).add(this._vec3, this._bottomRight, position); + (0, _vertexJs.PositionTexturePickVertex).setPosition(vertices, vertexOffset + 3, this._vec3); + (0, _glMatrix.vec2).set(this._vec2, glyph.u0, glyph.v0); + (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset, this._vec2); + (0, _glMatrix.vec2).set(this._vec2, glyph.u1, glyph.v0); + (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset + 1, this._vec2); + (0, _glMatrix.vec2).set(this._vec2, glyph.u0, glyph.v1); + (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset + 2, this._vec2); + (0, _glMatrix.vec2).set(this._vec2, glyph.u1, glyph.v1); + (0, _vertexJs.PositionTexturePickVertex).setTexCoord(vertices, vertexOffset + 3, this._vec2); + (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset, idColor); + (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset + 1, idColor); + (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset + 2, idColor); + (0, _vertexJs.PositionTexturePickVertex).setIdColor(vertices, vertexOffset + 3, idColor); + offset[0] += glyph.advance * scale; + const indexTemplate = (0, _quadJs.Quad).INDICES; + const indexOffset = index * 6; + for(let i = 0; i < 6; i++)indices[indexOffset + i] = indexTemplate[i] + vertexOffset; } } +TextHelper._vec2 = (0, _glMatrix.vec2).create(); +TextHelper._vec3 = (0, _glMatrix.vec3).create(); +TextHelper._topLeft = (0, _glMatrix.vec3).create(); +TextHelper._topRight = (0, _glMatrix.vec3).create(); +TextHelper._bottomLeft = (0, _glMatrix.vec3).create(); +TextHelper._bottomRight = (0, _glMatrix.vec3).create(); -},{"gl-matrix":"9GjEQ","../helpers/math.js":"fOnPF","../helpers/angle.js":"eKtPm","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9by4z":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"gl-matrix":"5x28d","../vertex.js":"4J2YE","../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1t2sb":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "MouseWheel", ()=>MouseWheel); -class MouseWheel { - constructor(core){ - this._core = core; - this._previousTotal = 0; - this.total = 0; - } - initialize(element) { - element.addEventListener("wheel", (e)=>{ - e.preventDefault(); - const wheelEvent = e; - this.total += wheelEvent.deltaY; - }, { - passive: false - }); - } - update(elapsedTime) { - const total = this.total; - this.delta = total - this._previousTotal; - this._previousTotal = total; - if (this._core.config.isDebugVisible) this._core.debugText.addLine(`mse whl ${this.total < 0 ? "" : " "}${Math.round(this.total)}`); - } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1WwTm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Pointers", ()=>Pointers); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _manipulatorJs = require("../input/manipulator.js"); -class Pointers { - get hoverX() { - return this._hoverX; +parcelHelpers.export(exports, "PickHelper", ()=>PickHelper); +class PickHelper { + static nextPickId() { + return this._pickId++; } - get hoverY() { - return this._hoverY; + static encodeNumber(number, type, color) { + const encoded = number | PickHelper.encodeType(type); + PickHelper.float32ToVec4(encoded, color); } - get hoverId() { - return this._hoverId; + static decodeNumber(color) { + return color[0] + (color[1] << 8) + (color[2] << 16); } - constructor(core, manipulators){ - this._core = core; - this._manipulators = manipulators; + static encodeVec3(vec3, type, color) { + const encoded = vec3[0] | vec3[1] << 8 | vec3[2] << 16 | PickHelper.encodeType(type); + PickHelper.float32ToVec4(encoded, color); } - initialize(element) { - this._element = element; - element.addEventListener("pointerdown", (e)=>this._handlePointerDown(e), { - passive: true - }); - element.addEventListener("pointermove", (e)=>this._handlePointerMove(e), { - passive: true - }); - element.addEventListener("pointerup", (e)=>this._handlePointerUp(e), { - passive: true - }); - element.addEventListener("pointercancel", (e)=>this._handlePointerCancel(e), { - passive: true - }); - element.addEventListener("pointerleave", (e)=>this._handlePointerLeave(e), { - passive: true - }); - element.addEventListener("pointerout", (e)=>this._handlePointerOut(e), { - passive: true - }); - } - update(elapsedTime) { - if (this._core.config.isDebugVisible) { - this._core.debugText.addLine(`pen rot ${(this._tiltX | 0).toFixed(3)},${(this._tiltY | 0).toFixed(3)},${(this._twist | 0).toFixed(3)}`); - this._core.debugText.addLine(`hov pos ${this.hoverX ? `${this.hoverX.toFixed(3)},${this.hoverY.toFixed(3)}px` : ""}`); - } - } - _handlePointerDown(e) { - this._element.focus(); - const devicePixelRatio = this._core.renderer.devicePixelRatio; - const manipulator = new (0, _manipulatorJs.Manipulator)(); - const id = e.pointerId; - const x = e.offsetX * devicePixelRatio; - const y = e.offsetY * devicePixelRatio; - manipulator.id = id; - manipulator.position[0] = x; - manipulator.position[1] = y; - manipulator.type = e.pointerType; - manipulator.button = e.button; - manipulator.shiftKey = e.shiftKey; - manipulator.ctrlKey = e.ctrlKey; - manipulator.altKey = e.altKey; - manipulator.event = e; - this._manipulators[id] = manipulator; - this._hoverId = id; - this._hoverX = x; - this._hoverY = y; - } - _handlePointerMove(e) { - const devicePixelRatio = this._core.renderer.devicePixelRatio; - const x = e.offsetX * devicePixelRatio; - const y = e.offsetY * devicePixelRatio; - const id = e.pointerId; - const manipulator = this._manipulators[id]; - if (manipulator) { - manipulator.position[0] = x; - manipulator.position[1] = y; - manipulator.event = e; - } - switch(e.pointerType){ - case "mouse": - this._hoverId = id; - this._hoverX = x; - this._hoverY = y; - break; - case "pen": - this._hoverId = id; - this._hoverX = x; - this._hoverY = y; - this._tiltX = e.tiltX; - this._tiltY = e.tiltY; - this._twist = e.twist; - break; - } - } - _handlePointerUp(e) { - const manipulator = this._manipulators[e.pointerId]; - if (manipulator) manipulator.event = e; - this._remove(e.pointerId); - } - _handlePointerCancel(e) { - this._remove(e.pointerId); + static decodeVec3(color, axes) { + axes[0] = color[0]; + axes[1] = color[1]; + axes[2] = color[2]; } - _handlePointerLeave(e) { - this._resetHover(); - this._remove(e.pointerId); + static encodeType(type) { + return type << 24; } - _handlePointerOut(e) { - this._resetHover(); - this._remove(e.pointerId); + static decodeType(color) { + return color[3]; } - _resetHover() { - this._hoverId = null; - this._hoverX = null; - this._hoverY = null; + static float32ToVec4(number, color) { + color[0] = ((number & 0xFF) >>> 0) / 0xFF; + color[1] = ((number & 0xFF00) >>> 8) / 0xFF; + color[2] = ((number & 0xFF0000) >>> 16) / 0xFF; + color[3] = ((number & 0xFF000000) >>> 24) / 0xFF; } - _remove(pointerId) { - const manipulator = this._manipulators[pointerId]; - if (manipulator) delete this._manipulators[pointerId]; + static uint8ArrayToNumber(color) { + return color[0] + (color[1] << 8) + (color[2] << 16) + (color[3] << 24); } } +PickHelper._pickId = 1; -},{"../input/manipulator.js":"3mWz8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3mWz8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Manipulator", ()=>Manipulator); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"d0jS2":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class Manipulator { - constructor(){ - this.pickedIndex = 0; - this.maxTranslationSquared = 0; - this.initialPosition = (0, _glMatrix.vec3).create(); - this.position = (0, _glMatrix.vec3).create(); - this.previousPosition = (0, _glMatrix.vec3).create(); - this.holdOrigin = (0, _glMatrix.vec3).create(); - this.positionRelativeToCentroid = (0, _glMatrix.vec3).create(); - this.previousPositionRelativeToCentroid = (0, _glMatrix.vec3).create(); - this.rotationAxis = (0, _glMatrix.vec3).create(); - this.previousRotationAxis = (0, _glMatrix.vec3).create(); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cartesian2dAxesHelper", ()=>Cartesian2dAxesHelper); +parcelHelpers.export(exports, "Cartesian2dAxes", ()=>Cartesian2dAxes); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../../constants.js"); +var _mainJs = require("../../main.js"); +var _axesJs = require("./axes.js"); +var _quadJs = require("../../meshes/quad.js"); +var _vertexJs = require("../../vertex.js"); +var _axesJs1 = require("../../helpers/axes.js"); +var _textJs = require("../../helpers/text.js"); +var _pickJs = require("../../helpers/pick.js"); +class Cartesian2dAxesHelper { + static create(core, options) { + const cartesian2dAxes = new Cartesian2dAxes(core); + const minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; + const minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; + const maxBoundsX = options.maxBoundsX === undefined ? 1 : options.maxBoundsX; + const maxBoundsY = options.maxBoundsY === undefined ? 1 : options.maxBoundsY; + const minValueX = options.minValueX === undefined ? 0 : options.minValueX; + const minValueY = options.minValueY === undefined ? 0 : options.minValueY; + const maxValueX = options.maxValueX === undefined ? 1 : options.maxValueX; + const maxValueY = options.maxValueY === undefined ? 1 : options.maxValueY; + const scaling = options.scaling === undefined ? 1 : options.scaling; + cartesian2dAxes.minBoundsX = minBoundsX; + cartesian2dAxes.minBoundsY = minBoundsY; + cartesian2dAxes.maxBoundsX = maxBoundsX; + cartesian2dAxes.maxBoundsY = maxBoundsY; + cartesian2dAxes.scalingX = scaling; + cartesian2dAxes.scalingY = scaling; + const maxLength = Math.max(maxBoundsX - minBoundsX, maxBoundsY - minBoundsY); + const requestedDivisions = [ + options.divisionsX == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsX - minBoundsX) / maxLength), 1) : options.divisionsX, + options.divisionsY == undefined ? Math.max(Math.floor(core.config.axesGridDefaultDivisions * (maxBoundsY - minBoundsY) / maxLength), 1) : options.divisionsY + ]; + const minorGridlines = [ + options.minorGridlinesX == undefined ? 2 : options.minorGridlinesX, + options.minorGridlinesY == undefined ? 2 : options.minorGridlinesY + ]; + const labelMajorSizes = [ + options.labelMajorSizeX === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeX, + options.labelMajorSizeY === undefined ? core.config.axesTextLabelMajorSize : options.labelMajorSizeY + ]; + const labelMinorSizes = [ + options.labelMinorSizeX === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeX, + options.labelMinorSizeY === undefined ? core.config.axesTextLabelMinorSize : options.labelMinorSizeY + ]; + cartesian2dAxes.isDiscreteX = options.isDiscreteX; + cartesian2dAxes.isDiscreteY = options.isDiscreteY; + cartesian2dAxes.isGridPickingEnabled = options.isGridPickingEnabled; + const isDivisionPickingEnabledArray = [ + options.isDivisionPickingEnabledX, + options.isDivisionPickingEnabledY + ]; + const isLabelPickingEnabled = [ + options.isLabelPickingEnabledX, + options.isLabelPickingEnabledY + ]; + const isAxisReversed = [ + options.reverseX, + options.reverseY + ]; + const labelsArray = [ + options.labelsX, + options.labelsY + ]; + const labelOrientationsArray = [ + options.labelOrientationX, + options.labelOrientationY + ]; + const labelOrientationDefaultArray = [ + (0, _mainJs.AxesTextOrientation).parallel, + (0, _mainJs.AxesTextOrientation).perpendicular, + (0, _mainJs.AxesTextOrientation).parallel + ]; + const arePickDivisionsVisibleArray = [ + options.arePickDivisionsVisibleX, + options.arePickDivisionsVisibleY + ]; + const minValueArray = [ + minValueX, + minValueY + ]; + const maxValueArray = [ + maxValueX, + maxValueY + ]; + const isDiscreteArray = [ + options.isDiscreteX, + options.isDiscreteY + ]; + const titleArray = [ + options.titleX, + options.titleY + ]; + const titleSizeArray = [ + options.titleSizeX, + options.titleSizeY + ]; + const headingArray = [ + options.headingX, + options.headingY + ]; + const headingSizeArray = [ + options.headingSizeX, + options.headingSizeY + ]; + for(let axisId = 0; axisId < 2; axisId++){ + const label = labelsArray[axisId]; + const minValue = minValueArray[axisId]; + const maxValue = maxValueArray[axisId]; + const discrete = isDiscreteArray[axisId]; + if (discrete) { + const divisions = maxValue - minValue + 1; + const maxDivisions = Math.min(requestedDivisions[axisId], divisions); + const discreteAxisOptions = { + min: minValue, + max: maxValue, + divisions: divisions, + maxDivisions: maxDivisions, + label: label + }; + const discreteAxis = (0, _axesJs1.AxisHelper).discrete(discreteAxisOptions); + cartesian2dAxes.setTickPositions(axisId, discreteAxis.tickPositions); + cartesian2dAxes.setLabelPositions(axisId, discreteAxis.labelPositions); + cartesian2dAxes.setLabels(axisId, discreteAxis.labels); + cartesian2dAxes.setFromValues(axisId, discreteAxis.fromValues); + cartesian2dAxes.setToValues(axisId, discreteAxis.toValues); + cartesian2dAxes.setLabelSizes(axisId, Array(discreteAxis.labels.length).fill(labelMajorSizes[axisId])); + cartesian2dAxes.minorGridlines[axisId] = 1; + } else { + const divisions = requestedDivisions[axisId]; + const continuousAxisOptions = { + min: minValue, + max: maxValue, + divisions: divisions, + label: label + }; + const continuousAxis = (0, _axesJs1.AxisHelper).continuous(continuousAxisOptions); + cartesian2dAxes.setTickPositions(axisId, continuousAxis.positions); + cartesian2dAxes.setLabelPositions(axisId, continuousAxis.positions); + cartesian2dAxes.setLabels(axisId, continuousAxis.labels); + cartesian2dAxes.setFromValues(axisId, continuousAxis.fromValues); + cartesian2dAxes.setToValues(axisId, continuousAxis.toValues); + const labelSizes = []; + for(let i = 0; i < continuousAxis.labels.length; i++)labelSizes.push(i == 0 || i == divisions ? labelMajorSizes[axisId] : labelMinorSizes[axisId]); + cartesian2dAxes.setLabelSizes(axisId, labelSizes); + cartesian2dAxes.minorGridlines[axisId] = minorGridlines[axisId]; + } + cartesian2dAxes.setLabelOrientation(axisId, labelOrientationsArray[axisId] === undefined ? labelOrientationDefaultArray[axisId] : labelOrientationsArray[axisId]); + cartesian2dAxes.setTitle(axisId, titleArray[axisId]); + cartesian2dAxes.setTitleSize(axisId, titleSizeArray[axisId] === undefined ? core.config.axesTextTitleSize : titleSizeArray[axisId]); + cartesian2dAxes.setHeading(axisId, headingArray[axisId]); + cartesian2dAxes.setHeadingSize(axisId, headingSizeArray[axisId] === undefined ? core.config.axesTextHeadingSize : headingSizeArray[axisId]); + cartesian2dAxes.arePickDivisionsVisible[axisId] = arePickDivisionsVisibleArray[axisId] === undefined ? true : arePickDivisionsVisibleArray[axisId]; + cartesian2dAxes.isDivisionPickingEnabled[axisId] = isDivisionPickingEnabledArray[axisId]; + cartesian2dAxes.isLabelPickingEnabled[axisId] = isLabelPickingEnabled[axisId]; + cartesian2dAxes.isAxisReversed[axisId] = isAxisReversed[axisId]; + if (minValue <= 0 && maxValue >= 0 && minValue != maxValue) cartesian2dAxes.zero[axisId] = -minValue / (maxValue - minValue); + else cartesian2dAxes.zero[axisId] = -Number.MAX_VALUE; + } + return cartesian2dAxes; } } - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iA4Fe":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AnimationHelper", ()=>AnimationHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mathJs = require("./math.js"); -class AnimationHelper { - static smoothStep(value) { - return value * value * (3 - 2 * value); +class Cartesian2dAxes extends (0, _axesJs.AxesBase) { + get size() { + return this._size; } - static damp(value, target, threshold, dampening) { - if (Math.abs(target) < threshold) return (0, _mathJs.MathHelper).lerp(value, 0, dampening); - else return (0, _mathJs.MathHelper).lerp(value, target, dampening); + get isDiscreteX() { + return this._isDiscrete[0]; } -} - -},{"./math.js":"fOnPF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7b1bp":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Keyboard", ()=>Keyboard); -class Keyboard { - constructor(core){ - this._core = core; - this._pressedKeys = new Set(); - this._previousPressedKeys = new Set(); + set isDiscreteX(value) { + if (value != this._isDiscrete[0]) { + this._isDiscrete[0] = value; + this._hasChanged = true; + } } - initialize(element) { - element.addEventListener("keydown", (e)=>{ - this._handleKeyDown(e); - }, false); - element.addEventListener("keyup", (e)=>{ - this._handleKeyUp(e); - }, false); + get isDiscreteY() { + return this._isDiscrete[1]; } - update(elapsedTime) { - if (this._core.config.isDebugVisible) this._core.debugText.addLine(`key tot ${this._pressedKeys.size}`); + set isDiscreteY(value) { + if (value != this._isDiscrete[1]) { + this._isDiscrete[1] = value; + this._hasChanged = true; + } } - isKeyDown(key) { - return this._pressedKeys.has(key); + get minBoundsX() { + return this._minBoundsX; } - wasKeyReleased(key) { - if (this._pressedKeys.has(key)) { - if (!this._previousPressedKeys.has(key)) { - this._previousPressedKeys.add(key); - return true; - } - } else this._previousPressedKeys.delete(key); - return false; + set minBoundsX(value) { + if (value != this._minBoundsX) { + this._minBoundsX = value; + this._hasChanged = true; + } } - _handleKeyDown(e) { - const keyboardEvent = e; - const key = keyboardEvent.key; - if (!this._pressedKeys.has(key)) this._pressedKeys.add(key); + get maxBoundsX() { + return this._maxBoundsX; } - _handleKeyUp(e) { - const keyboardEvent = e; - const key = keyboardEvent.key; - if (this._pressedKeys.has(key)) this._pressedKeys.delete(key); + set maxBoundsX(value) { + if (value != this._minBoundsX) { + this._maxBoundsX = value; + this._hasChanged = true; + } } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9eIyY":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Log", ()=>Log); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("./main.js"); -class Log { - constructor(core){ - this._core = core; + get minBoundsY() { + return this._minBoundsY; } - write(level, value) { - if (level >= this._core.config.logLevel) switch(level){ - case (0, _mainJs.LogLevel).trace: - console.trace(value); - break; - case (0, _mainJs.LogLevel).debug: - console.debug(value); - break; - case (0, _mainJs.LogLevel).info: - console.info(value); - break; - case (0, _mainJs.LogLevel).warn: - console.warn(value); - break; - case (0, _mainJs.LogLevel).error: - console.error(value); - break; + set minBoundsY(value) { + if (value != this._minBoundsY) { + this._minBoundsY = value; + this._hasChanged = true; } } -} - -},{"./main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9htAN":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ObjMesh", ()=>ObjMesh); -parcelHelpers.export(exports, "ObjHelper", ()=>ObjHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -class ObjMesh { -} -class ObjHelper { - constructor(core){ - this._core = core; + get maxBoundsY() { + return this._maxBoundsY; } - read(data) { - const start = window.performance.now(); - const indices = []; - const positions = []; - const normals = []; - const texCoords = []; - const meshes = []; - const indexOffsets = []; - const indexCounts = []; - const faceLookup = {}; - const lines = data.split("\n"); - let faceCount = 0; - for(let i = 0; i < lines.length; i++){ - const parts = lines[i].trim().split(" "); - if (parts.length > 0) switch(parts[0]){ - case "o": - meshes.push(parts[1]); - indexOffsets.push(indices.length); - break; - case "v": - positions.push(parseFloat(parts[1])); - positions.push(parseFloat(parts[2])); - positions.push(parseFloat(parts[3])); - break; - case "vt": - texCoords.push(parseFloat(parts[1])); - texCoords.push(parseFloat(parts[2])); - break; - case "vn": - normals.push(parseFloat(parts[1])); - normals.push(parseFloat(parts[2])); - normals.push(parseFloat(parts[3])); - break; - case "f": - for(let i1 = 0; i1 < parts.length - 1; i1++){ - const part = parts[i1 + 1]; - if (faceLookup[part] == undefined) faceLookup[part] = faceCount++; - indices.push(faceLookup[part]); - } - break; - case "usemtl": - case "mtllib": - default: - break; - } + set maxBoundsY(value) { + if (value != this._minBoundsY) { + this._maxBoundsY = value; + this._hasChanged = true; } - for(let i2 = 0; i2 < meshes.length - 1; i2++)indexCounts.push(indexOffsets[i2 + 1] - indexOffsets[i2]); - indexCounts.push(indices.length - indexOffsets[meshes.length - 1]); - const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * Object.keys(faceLookup).length); - const dataView = new DataView(vertices); - let minX = Number.MAX_VALUE; - let minY = Number.MAX_VALUE; - let minZ = Number.MAX_VALUE; - let maxX = -Number.MAX_VALUE; - let maxY = -Number.MAX_VALUE; - let maxZ = -Number.MAX_VALUE; - const faces = Object.keys(faceLookup); - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - let hasTexCoords, hasNormals; - if (faces.length > 0) { - const faceParts = faces[0].split("/"); - hasTexCoords = faceParts.length > 1 && !isNaN(parseInt(faceParts[1])); - hasNormals = faceParts.length > 2 && !isNaN(parseInt(faceParts[2])); + } + getIsOutsideEdge(index) { + return this._isOutsideEdge[index]; + } + getIsForwardFace(index) { + return this._isForwardFace[index]; + } + get textVertices() { + return this._textVertices; + } + get textIndices() { + return this._textIndices; + } + getLabelMMatrix(index) { + return this._labelMMatrices[index]; + } + setLabelPositions(index, value) { + if (this._labelPositions[index] != value) { + this._labelPositions[index] = value; + this._hasChanged = true; } - for(let i3 = 0; i3 < faces.length; i3++){ - const faceParts1 = faces[i3].split("/"); - let index = (parseInt(faceParts1[0]) - 1) * 3; - const x = positions[index]; - const y = positions[index + 1]; - const z = positions[index + 2]; - (0, _glMatrix.vec3).set(_vec3, x, y, z); - (0, _vertexJs.PositionNormalTextureVertex).setPosition(dataView, i3, _vec3); - minX = Math.min(x, minX); - minY = Math.min(y, minY); - minZ = Math.min(z, minZ); - maxX = Math.max(x, maxX); - maxY = Math.max(y, maxY); - maxZ = Math.max(z, maxZ); - if (hasNormals) { - index = (parseInt(faceParts1[2]) - 1) * 3; - (0, _glMatrix.vec3).set(_vec3, normals[index], normals[index + 1], normals[index + 2]); - (0, _vertexJs.PositionNormalTextureVertex).setNormal(dataView, i3, _vec3); - } - if (hasTexCoords) { - index = (parseInt(faceParts1[1]) - 1) * 2; - (0, _glMatrix.vec2).set(_vec2, texCoords[index], texCoords[index + 1]); - (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(dataView, i3, _vec2); - } - } - const originX = (minX + maxX) / 2; - const originY = (minY + maxY) / 2; - const originZ = (minZ + maxZ) / 2; - const objMesh = new ObjMesh(); - objMesh.vertices = vertices; - objMesh.indices = new Uint16Array(indices); - objMesh.meshes = meshes; - objMesh.indexOffsets = indexOffsets; - objMesh.indexCounts = indexCounts; - objMesh.indexCount = indices.length; - objMesh.minX = minX; - objMesh.minY = minY; - objMesh.minZ = minZ; - objMesh.maxX = maxX; - objMesh.maxY = maxY; - objMesh.maxZ = maxZ; - objMesh.originX = originX; - objMesh.originY = originY; - objMesh.originZ = originZ; - this._core.log.write((0, _mainJs.LogLevel).info, `obj loaded ${Math.round(window.performance.now() - start)}ms`); - return objMesh; - } -} - -},{"gl-matrix":"9GjEQ","../main.js":"1Kju3","../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4IFc8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LabelVisual", ()=>LabelVisual); -parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); -parcelHelpers.export(exports, "LabelBase", ()=>LabelBase); -parcelHelpers.export(exports, "Label", ()=>Label); -parcelHelpers.export(exports, "LabelSet", ()=>LabelSet); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -var _textJs = require("../helpers/text.js"); -var _constantsJs = require("../constants.js"); -var _vertexJs = require("../vertex.js"); -var _pickJs = require("../helpers/pick.js"); -class LabelVisual { - render(elapsedTime, xrFrame) {} - update(elapsedTime) {} - constructor(label){ - this.label = label; - } -} -class LabelSetVisual { - render(elapsedTime, xrFrame) {} - update(elapsedTime) {} - constructor(labelSet){ - this.label = labelSet; - } -} -class LabelBase { - get material() { - return this._material; - } - get vertices() { - return this._vertices; } - get verticesView() { - return this._verticesView; - } - get indices() { - return this._indices; - } - get indexCount() { - return this._indexCount; - } - get isInitialized() { - return this._isInitialized; - } - get mMatrix() { - return this._mMatrix; - } - get scale() { - return this._scale; - } - set scale(value) { - if (this._scale != value) { - this._scale = value; + setLabels(index, value) { + if (this._labels[index] != value) { + this._labels[index] = value; this._hasChanged = true; } } - get font() { - return this._font; - } - set font(value) { - if (this._font != value) { - this._font = value; + setLabelSizes(index, value) { + if (this._labelSizes[index] != value) { + this._labelSizes[index] = value; this._hasChanged = true; } } - get rotation() { - return this._rotation; - } - set rotation(value) { - if (this._rotation != value) { - this._rotation = value; - this._hasChanged = true; - } + getLabelOrientation(index) { + return this._orientations[index]; } - set reverseX(value) { - if (this._reverseX != value) { - this._reverseX = value; + setLabelOrientation(index, orientation) { + if (this._orientations[index] != orientation) { + this._orientations[index] = orientation; this._hasChanged = true; } } - set reverseY(value) { - if (this._reverseY != value) { - this._reverseY = value; - this._hasChanged = true; - } + getTitleIndexCount(index) { + return this._titleIndexCounts[index]; } - set reverseZ(value) { - if (this._reverseZ != value) { - this._reverseZ = value; - this._hasChanged = true; - } + getTitleIndexOffset(index) { + return this._titleIndexOffsets[index]; } - get horizontalAlignment() { - return this._horizontalAlignment; + getTitleMMatrix(index) { + return this._titleMMatrices[index]; } - set horizontalAlignment(value) { - if (this._horizontalAlignment != value) { - this._horizontalAlignment = value; + setTitle(index, value) { + if (this._titles[index] != value) { + this._titles[index] = value; this._hasChanged = true; } } - get verticalAlignment() { - return this._verticalAlignment; - } - set verticalAlignment(value) { - if (this._verticalAlignment != value) { - this._verticalAlignment = value; + setTitleSize(index, value) { + if (this._titleSizes[index] != value) { + this._titleSizes[index] = value; this._hasChanged = true; } } - get offsetX() { - return this._offsetX; + getHeadingIndexCount(index) { + return this._headingIndexCounts[index]; } - set offsetX(value) { - if (this._offsetX != value) { - this._offsetX = value; - this._hasChanged = true; - } + getHeadingIndexOffset(index) { + return this._headingIndexOffsets[index]; } - get offsetY() { - return this._offsetY; + getHeadingMMatrix(index) { + return this._headingMMatrices[index]; } - set offsetY(value) { - if (this._offsetY != value) { - this._offsetY = value; + setHeading(index, value) { + if (this._headings[index] != value) { + this._headings[index] = value; this._hasChanged = true; } } - get offsetZ() { - return this._offsetZ; - } - set offsetZ(value) { - if (this._offsetZ != value) { - this._offsetZ = value; + setHeadingSize(index, value) { + if (this._headingSizes[index] != value) { + this._headingSizes[index] = value; this._hasChanged = true; } } - get maxGlyphTop() { - return this._maxGlyphTop; - } - set maxGlyphTop(value) { - if (this._maxGlyphTop != value) { - this._maxGlyphTop = value; - this._hasChanged = true; - } + getIsLeftToRightHorizontal(index) { + return this._isLeftToRightHorizontal[index]; } - get maxGlyphHeight() { - return this._maxGlyphHeight; + getIsLeftToRightVertical(index) { + return this._isLeftToRightVertical[index]; } - set maxGlyphHeight(value) { - if (this._maxGlyphHeight != value) { - this._maxGlyphHeight = value; - this._hasChanged = true; - } + getAxesLeftToRightIndexCount(index) { + return this._axesLeftToRightIndexCounts[index]; } - constructor(core, options){ - this._core = core; - this._offset = (0, _glMatrix.vec3).create(); - this._vec3 = (0, _glMatrix.vec3).create(); - this._vec4 = (0, _glMatrix.vec4).create(); - this._mMatrix = (0, _glMatrix.mat4).create(); - this._indexCount = 0; - this._maxGlyphs = options.maxGlyphs; - this._textMetric = { - width: 0, - maxHeight: 0, - maxTop: 0 - }; - this.scale = options.scale ? options.scale : 1; - this.offsetX = options.offsetX ? options.offsetX : 0; - this.offsetY = options.offsetY ? options.offsetY : 0; - this.offsetZ = options.offsetZ ? options.offsetZ : 0; - this.reverseX = options.reverseX; - this.reverseY = options.reverseY; - this.reverseZ = options.reverseZ; - this.rotation = options.rotation; - this.maxGlyphTop = options.maxGlyphTop; - this.horizontalAlignment = options.horizontalAlignment === undefined ? (0, _mainJs.HorizontalAlignment).center : options.horizontalAlignment; - this.verticalAlignment = options.verticalAlignment === undefined ? (0, _mainJs.VerticalAlignment).center : options.verticalAlignment; - this._material = options.material; - this.borderWidth = core.config.textBorderWidth; - this.gamma = 0; + getAxesRightToLeftIndexCount(index) { + return this._axesRightToLeftIndexCounts[index]; } - initialize() { - this._vertices = new ArrayBuffer((0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES * this._maxGlyphs * 4); - this._verticesView = new DataView(this._vertices); - this._indices = new Uint16Array(this._maxGlyphs * 6); - this._isInitialized = true; + getAxesLeftToRightIndexOffset(index) { + return this._axesLeftToRightIndexOffsets[index]; } - update(elapsedTime) {} -} -class Label extends LabelBase { - get textAlignment() { - return this._textAlignment; + getAxesRightToLeftIndexOffset(index) { + return this._axesRightToLeftIndexOffsets[index]; } - set textAlignment(value) { - if (this._textAlignment != value) { - this._textAlignment = value; - this._hasChanged = true; - } + get gridVertices() { + return this._gridVertices; } - get text() { - return this._text; + get gridIndices() { + return this._gridIndices; } - set text(value) { - if (this._text != value) { - this._text = value; - this._hasChanged = true; - } + getGridTicksIndexCount(index) { + return this._gridTicksIndexCounts[index]; } - constructor(core, options){ - super(core, options); - this._font = options.font || core.font; - this._text = options.text; - this._textAlignment = options.textAlignment === undefined ? (0, _mainJs.TextAlignment).left : options.textAlignment; + getGridTicksIndexOffset(index) { + return this._gridTicksIndexOffsets[index]; } - update(elapsedTime) { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - if (!this._text) { - this._indexCount = 0; - this.width = 0; - this.height = 0; - } else { - const widths = []; - const truncated = []; - let maxWidth = 0; - let maxGlyphHeight = 0; - let maxGlyphTop = 0; - let glyphs = 0; - for(let i = 0; i < this._text.length; i++){ - const text = (0, _textJs.TextHelper).truncate(this._text[i], this._maxGlyphs - glyphs); - (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); - widths.push(this._textMetric.width); - maxWidth = Math.max(this._textMetric.width, maxWidth); - maxGlyphHeight = Math.max(this._textMetric.maxHeight, maxGlyphHeight); - maxGlyphTop = Math.max(this._textMetric.maxTop, maxGlyphTop); - glyphs += text.length; - truncated.push(text); - if (glyphs >= this._maxGlyphs) break; - } - if (this._maxGlyphHeight) maxGlyphHeight = this._maxGlyphHeight; - if (this._maxGlyphTop) maxGlyphTop = this._maxGlyphTop; - const lineHeight = this._font.size; - const height = truncated.length * lineHeight; - switch(this._horizontalAlignment){ - case (0, _mainJs.HorizontalAlignment).left: - this._originX = this._offsetX + maxWidth / 2; - break; - case (0, _mainJs.HorizontalAlignment).center: - this._originX = this._offsetX; - break; - case (0, _mainJs.HorizontalAlignment).right: - this._originX = this._offsetX - maxWidth / 2; - break; - } - switch(this._verticalAlignment){ - case (0, _mainJs.VerticalAlignment).top: - this._originY = this._offsetY - height / 2; - break; - case (0, _mainJs.VerticalAlignment).center: - this._originY = this._offsetY; - break; - case (0, _mainJs.VerticalAlignment).bottom: - this._originY = this._offsetY + height / 2; - break; - } - glyphs = 0; - for(let i1 = 0; i1 < truncated.length; i1++){ - switch(this._textAlignment){ - case (0, _mainJs.TextAlignment).left: - this._offset[0] = this._originX - maxWidth / 2; - break; - case (0, _mainJs.TextAlignment).center: - this._offset[0] = this._originX - widths[i1] / 2; - break; - case (0, _mainJs.TextAlignment).right: - this._offset[0] = this._originX + maxWidth / 2 - widths[i1]; - break; - } - this._offset[1] = this._originY + height / 2 - i1 * lineHeight - lineHeight / 2 - maxGlyphTop / 2; - const pickingId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickingId, (0, _mainJs.PickType).label, this._vec4); - const text1 = truncated[i1]; - if (text1.length > 0) { - (0, _textJs.TextHelper).addString(this._font, text1, this._verticesView, this._indices, glyphs, (0, _constantsJs.Constants).VECTOR3_ZERO, 1, this._offset, null, this._vec4); - glyphs += text1.length; - } - } - const scaling = this._scale / this._font.size; - this.width = maxWidth * scaling; - this.height = height * scaling; - this._indexCount = glyphs * 6; - (0, _glMatrix.vec3).set(this._vec3, scaling, scaling, scaling); - (0, _glMatrix.mat4).fromScaling(this._mMatrix, this._vec3); - if (this.hasChangedCallback) this.hasChangedCallback(); - } - } + getGridFaceIndexCount(index) { + return this._gridFaceIndexCounts[index]; } -} -class LabelSet extends LabelBase { - get materials() { - return this._materials; + getGridFaceIndexOffset(index) { + return this._gridFaceIndexOffsets[index]; } - get minBoundsX() { - return this._minBoundsX; + getGridTicksMMatrix(index) { + return this._gridTicksMMatrices[index]; } - set minBoundsX(value) { - if (this._minBoundsX != value) { - this._minBoundsX = value; - this._hasChanged = true; - } + getGridFaceMMatrix(index) { + return this._gridFaceMMatrices[index]; } - get minBoundsY() { - return this._minBoundsY; + getGridTicksScale(index) { + return this._gridTicksScales[index]; } - set minBoundsY(value) { - if (this._minBoundsY != value) { - this._minBoundsY = value; - this._hasChanged = true; - } + getGridTicksZero(index) { + return this._gridTicksZeros[index]; } - get minBoundsZ() { - return this._minBoundsZ; + get gridFaceZero() { + return this._gridFaceZeros; } - set minBoundsZ(value) { - if (this._minBoundsZ != value) { - this._minBoundsZ = value; - this._hasChanged = true; - } + get gridFaceMinorGridlines() { + return this._gridFaceMinorGridlines; } - get maxBoundsX() { - return this._maxBoundsX; + getGridTicksMinorGridlines(index) { + return this._gridTicksMinorGridlines[index]; } - set maxBoundsX(value) { - if (this._maxBoundsX != value) { - this._maxBoundsX = value; + setTickPositions(index, value) { + if (this._gridTicksPositions[index] != value) { + this._gridTicksPositions[index] = value; this._hasChanged = true; } } - get maxBoundsY() { - return this._maxBoundsY; + get scalingX() { + return this._scalingX; } - set maxBoundsY(value) { - if (this._maxBoundsY != value) { - this._maxBoundsY = value; + set scalingX(value) { + if (value != this._scalingX) { + this._scalingX = value; this._hasChanged = true; } } - get maxBoundsZ() { - return this._maxBoundsZ; + get scalingY() { + return this._scalingY; } - set maxBoundsZ(value) { - if (this._maxBoundsZ != value) { - this._maxBoundsZ = value; + set scalingY(value) { + if (value != this._scalingY) { + this._scalingY = value; this._hasChanged = true; } } - get positionsX() { - return this._positionsX; - } - set positionsX(value) { - if (this._positionsX != value) { - this._positionsX = value; - this._hasChanged = true; - } + get offsetX() { + return this._offset[12]; } - get positionsY() { - return this._positionsY; + set offsetX(value) { + if (value != this._offset[12]) this._offset[12] = value; } - set positionsY(value) { - if (this._positionsY != value) { - this._positionsY = value; - this._hasChanged = true; - } + get offsetY() { + return this._offset[13]; } - get positionsZ() { - return this._positionsZ; + set offsetY(value) { + if (value != this._offset[13]) this._offset[13] = value; } - set positionsZ(value) { - if (this._positionsZ != value) { - this._positionsZ = value; - this._hasChanged = true; + set rotation(value) { + if (this._rotation != value) { + this._rotation = value; + this._rMatrix = (0, _glMatrix.mat4).create(); + (0, _glMatrix.mat4).fromQuat(this._rMatrix, value); } } - get positionScalingX() { - return this._positionScalingX; - } - set positionScalingX(value) { - if (this._positionScalingX != value) { - this._positionScalingX = value; - this._hasChanged = true; + constructor(core){ + super(core); + this._size = (0, _glMatrix.vec3).create(); + this._translation = (0, _glMatrix.vec3).create(); + this._normal = (0, _glMatrix.vec3).create(); + this._forward = (0, _glMatrix.vec3).create(); + this._right = (0, _glMatrix.vec3).create(); + this._up = (0, _glMatrix.vec3).create(); + this._texCoord = (0, _glMatrix.vec2).create(); + this._bounds = (0, _glMatrix.vec4).create(); + this._vec3 = (0, _glMatrix.vec3).create(); + this._vec4 = (0, _glMatrix.vec4).create(); + this._mat3 = (0, _glMatrix.mat3).create(); + this._isDiscrete = [ + false, + false + ]; + this._minBoundsX = 0; + this._minBoundsY = 0; + this._maxBoundsX = 0; + this._maxBoundsY = 0; + this._isForwardFace = []; + this._isForwardEdge = []; + this._isOutsideEdge = []; + for(let i = 0; i < 2; i++)this._isForwardFace.push(false); + for(let i = 0; i < 4; i++){ + this._isForwardEdge.push(false); + this._isOutsideEdge.push(false); } - } - get positionScalingY() { - return this._positionScalingY; - } - set positionScalingY(value) { - if (this._positionScalingY != value) { - this._positionScalingY = value; - this._hasChanged = true; + this._textOffset = (0, _glMatrix.vec3).create(); + this._textPosition = (0, _glMatrix.vec3).create(); + this._distances = []; + for(let i = 0; i < 4; i++)this._distances.push(0); + this._labelPositions = []; + this._labels = []; + this._labelSizes = []; + this._maxLabelSize = []; + this._axesLeftToRightIndexCounts = []; + this._axesRightToLeftIndexCounts = []; + this._axesLeftToRightIndexOffsets = []; + this._axesRightToLeftIndexOffsets = []; + this._labelMMatrices = []; + this._orientations = []; + for(let i = 0; i < 2; i++){ + this._maxLabelSize.push((0, _glMatrix.vec2).create()); + this._orientations.push((0, _mainJs.AxesTextOrientation).parallel); + this._axesLeftToRightIndexCounts.push(0); + this._axesRightToLeftIndexCounts.push(0); + this._axesLeftToRightIndexOffsets.push(0); + this._axesRightToLeftIndexOffsets.push(0); } - } - get positionScalingZ() { - return this._positionScalingZ; - } - set positionScalingZ(value) { - if (this._positionScalingZ != value) { - this._positionScalingZ = value; - this._hasChanged = true; + for(let i = 0; i < 4; i++)this._labelMMatrices.push((0, _glMatrix.mat4).create()); + this._titles = []; + this._titleSizes = []; + this._titleIndexCounts = []; + this._titleIndexOffsets = []; + this._titleMMatrices = []; + for(let i = 0; i < 2; i++){ + this._titles.push(null); + this._titleSizes.push(core.config.axesTextTitleSize); + this._titleIndexCounts.push(0); + this._titleIndexOffsets.push(0); } - } - get rotations() { - return this._rotations; - } - set rotations(value) { - if (this._rotations != value) { - this._rotations = value; - this._hasChanged = true; + for(let i = 0; i < 4; i++)this._titleMMatrices.push((0, _glMatrix.mat4).create()); + this._headings = []; + this._headingSizes = []; + this._headingIndexCounts = []; + this._headingIndexOffsets = []; + this._headingMMatrices = []; + this.isHeadingVisible = []; + for(let i = 0; i < 2; i++){ + this._headings.push(null); + this._headingSizes.push(core.config.axesTextHeadingSize); + this._headingIndexCounts.push(0); + this._headingIndexOffsets.push(0); } - } - get offsetsX() { - return this._offsetsX; - } - set offsetsX(value) { - if (this._offsetsX != value) { - this._offsetsX = value; - this._hasChanged = true; + for(let i = 0; i < 4; i++){ + this._headingMMatrices.push((0, _glMatrix.mat4).create()); + this.isHeadingVisible.push(true); } - } - get offsetsY() { - return this._offsetsY; - } - set offsetsY(value) { - if (this._offsetsY != value) { - this._offsetsY = value; - this._hasChanged = true; + this.isEdgeVisible = []; + this._edgePosition = (0, _glMatrix.vec3).create(); + this._edgePositive = (0, _glMatrix.vec3).create(); + this._edgeNormal = (0, _glMatrix.vec3).create(); + this._edgeNormalTemp = (0, _glMatrix.vec3).create(); + this._edgePositiveTemp = (0, _glMatrix.vec3).create(); + this._isLeftToRightHorizontal = []; + this._isLeftToRightVertical = []; + this._edgeHorizontalRight = []; + this._edgeHorizontalUp = []; + this._edgeHorizontalForward = []; + this._edgeVerticalRight = []; + this._edgeVerticalUp = []; + this._edgeVerticalForward = []; + for(let i = 0; i < 4; i++){ + this.isEdgeVisible.push(true); + this._isLeftToRightHorizontal.push(false); + this._isLeftToRightVertical.push(false); + this._edgeHorizontalRight.push((0, _glMatrix.vec3).create()); + this._edgeHorizontalUp.push((0, _glMatrix.vec3).create()); + this._edgeHorizontalForward.push((0, _glMatrix.vec3).create()); + this._edgeVerticalRight.push((0, _glMatrix.vec3).create()); + this._edgeVerticalUp.push((0, _glMatrix.vec3).create()); + this._edgeVerticalForward.push((0, _glMatrix.vec3).create()); } - } - get offsetsZ() { - return this._offsetsZ; - } - set offsetsZ(value) { - if (this._offsetsZ != value) { - this._offsetsZ = value; - this._hasChanged = true; + this.isFaceVisible = []; + for(let i = 0; i < 2; i++)this.isFaceVisible.push(true); + this.arePickDivisionsVisible = []; + this.areFacesVisible = []; + this._indexTemplate = (0, _quadJs.Quad).INDICES; + this.zero = (0, _glMatrix.vec3).create(); + this._gridTicksZeros = []; + this._gridFaceZeros = (0, _glMatrix.vec2).create(); + this.minorGridlines = (0, _glMatrix.vec3).fromValues(1, 1, 1); + this._gridTicksMinorGridlines = []; + this._gridFaceMinorGridlines = (0, _glMatrix.vec2).create(); + this._gridTicksPositions = []; + this._gridTicksScales = []; + this._gridTicksIndexCounts = []; + this._gridTicksIndexOffsets = []; + this._gridFaceScale = (0, _glMatrix.vec3).create(); + this._gridFaceIndexCounts = []; + this._gridFaceIndexOffsets = []; + this._gridFaceMMatrices = []; + this._gridTicksMMatrices = []; + this._gridTicksRotations = []; + for(let i = 0; i < 2; i++){ + this.arePickDivisionsVisible.push(true); + this.areFacesVisible.push(true); + this._gridTicksZeros.push((0, _glMatrix.vec2).create()); + this._gridTicksMinorGridlines.push((0, _glMatrix.vec2).create()); + this._gridTicksScales.push((0, _glMatrix.vec3).create()); + this._gridTicksIndexCounts.push(0); + this._gridTicksIndexOffsets.push(0); + this._gridFaceIndexCounts.push(0); + this._gridFaceIndexOffsets.push(0); + this._gridFaceMMatrices.push((0, _glMatrix.mat4).create()); } - } - get offsetScalingX() { - return this._offsetScalingX; - } - set offsetScalingX(value) { - if (this._offsetScalingX != value) { - this._offsetScalingX = value; - this._hasChanged = true; + for(let i = 0; i < 4; i++){ + this._gridTicksMMatrices.push((0, _glMatrix.mat4).create()); + this._gridTicksRotations.push((0, _glMatrix.mat4).create()); + const _mat4 = this._gridTicksRotations[i]; + _mat4[0] = (0, _quadJs.Quad).EDGE_POSITIVES[i][0]; + _mat4[1] = (0, _quadJs.Quad).EDGE_POSITIVES[i][1]; + _mat4[2] = (0, _quadJs.Quad).EDGE_POSITIVES[i][2]; + _mat4[4] = (0, _quadJs.Quad).EDGE_NORMALS[i][0]; + _mat4[5] = (0, _quadJs.Quad).EDGE_NORMALS[i][1]; + _mat4[6] = (0, _quadJs.Quad).EDGE_NORMALS[i][2]; + (0, _glMatrix.vec3).cross(this._vec3, (0, _quadJs.Quad).EDGE_POSITIVES[i], (0, _quadJs.Quad).EDGE_NORMALS[i]); + _mat4[8] = this._vec3[0]; + _mat4[9] = this._vec3[1]; + _mat4[10] = this._vec3[2]; } + this._fromValues = [ + null, + null + ]; + this._toValues = [ + null, + null + ]; + this.isDivisionPickingEnabled = [ + false, + false + ]; + this.isLabelPickingEnabled = [ + false, + false + ]; + this.isTitlePickingEnabled = [ + false, + false + ]; + this.isHeadingPickingEnabled = [ + false, + false + ]; + this.isAxisReversed = [ + false, + false + ]; + this._scalingX = 1; + this._scalingY = 1; + this._offset = (0, _glMatrix.mat4).create(); } - get offsetScalingY() { - return this._offsetScalingY; + initialize() { + this._isInitialized = true; } - set offsetScalingY(value) { - if (this._offsetScalingY != value) { - this._offsetScalingY = value; - this._hasChanged = true; + update(elapsedTime) { + if (this.isInitialized) { + if (this._hasChanged) { + const start = window.performance.now(); + this._hasChanged = false; + (0, _glMatrix.vec3).set(this._size, this._maxBoundsX - this._minBoundsX, this._maxBoundsY - this._minBoundsY, 0); + const maxBounds = Math.max(this._size[0], this._size[1]); + this._size[0] *= this._scalingX / maxBounds; + this._size[1] *= this._scalingY / maxBounds; + this._updateGrids(this._size); + this._updateText(this._size); + if (this.hasChangedCallback) this.hasChangedCallback(); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d updated ${Math.round(window.performance.now() - start)}ms`); + } + if (this._rMatrix) { + (0, _glMatrix.mat4).mul(this._mMatrix, this.mMatrix, this._rMatrix); + (0, _glMatrix.mat4).mul(this._mMatrix, this._mMatrix, this._offset); + } else (0, _glMatrix.mat4).multiply(this._mMatrix, this.mMatrix, this._offset); + this._mvMatrix = (0, _glMatrix.mat4).create(); + (0, _glMatrix.mat4).multiply(this._mvMatrix, this._vMatrix, this._mMatrix); + (0, _glMatrix.mat3).fromMat4(this._mat3, this._mvMatrix); + for(let faceId = 0; faceId < 2; faceId++){ + (0, _glMatrix.vec3).transformMat4(this._forward, (0, _constantsJs.Constants).VECTOR3_ZERO, this._mvMatrix); + (0, _glMatrix.vec3).transformMat3(this._normal, (0, _quadJs.Quad).FACE_NORMALS[faceId], this._mat3); + this._isForwardFace[faceId] = (0, _glMatrix.vec3).dot(this._normal, this._forward) > 0; + } + this._forward[0] = this._mat3[2]; + this._forward[1] = this._mat3[5]; + this._forward[2] = this._mat3[8]; + for(let edgeId = 0; edgeId < 4; edgeId++){ + this._isForwardEdge[edgeId] = (0, _glMatrix.vec3).dot((0, _quadJs.Quad).EDGE_FORWARDS[edgeId], this._forward) < 0; + this._distances[edgeId] = 0; + } + for(let axisId = 0; axisId < 2; axisId++)if (this.arePickDivisionsVisible[axisId]) { + (0, _glMatrix.vec2).set(this._gridTicksZeros[axisId], this.zero[axisId], -1); + (0, _glMatrix.vec2).set(this._gridTicksMinorGridlines[axisId], this.minorGridlines[axisId], 1); + const gridTicksScale = this._gridTicksScales[axisId]; + for(let edge = 0; edge < 2; edge++){ + const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; + if (this.isEdgeVisible[edgeId]) { + let distance = this._distances[edgeId]; + distance += this._gridPickDivisionHeight * 0.5; + const gridTicksMMatrix = this._gridTicksMMatrices[edgeId]; + (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + (0, _glMatrix.mat4).translate(gridTicksMMatrix, this._mMatrix, this._vec3); + (0, _glMatrix.mat4).multiply(gridTicksMMatrix, gridTicksMMatrix, this._gridTicksRotations[edgeId]); + if (!this._isForwardEdge[edgeId]) (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, (0, _constantsJs.Constants).VECTOR3_REFLECTX); + (0, _glMatrix.mat4).scale(gridTicksMMatrix, gridTicksMMatrix, gridTicksScale); + distance += this._gridPickDivisionHeight * 0.5; + this._distances[edgeId] = distance; + } + } + } + (0, _glMatrix.vec2).set(this._gridFaceZeros, this.zero[0], this.zero[1]); + (0, _glMatrix.vec2).set(this._gridFaceMinorGridlines, this.minorGridlines[0], this.minorGridlines[1]); + for(let faceId = 0; faceId < 2; faceId++)if (this._isForwardFace[faceId]) { + const gridFaceMMatrix = this._gridFaceMMatrices[faceId]; + (0, _glMatrix.mat4).scale(gridFaceMMatrix, this._mMatrix, this._gridFaceScale); + } + for(let axisId = 0; axisId < 2; axisId++)for(let edge = 0; edge < 2; edge++){ + const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; + (0, _glMatrix.vec3).multiply(this._edgePosition, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).transformMat4(this._edgePosition, this._edgePosition, this._mvMatrix); + (0, _glMatrix.vec3).normalize(this._forward, this._edgePosition); + (0, _glMatrix.vec3).negate(this._forward, this._forward); + (0, _glMatrix.vec3).cross(this._right, (0, _constantsJs.Constants).VECTOR3_UNITY, this._forward); + (0, _glMatrix.vec3).normalize(this._right, this._right); + (0, _glMatrix.vec3).cross(this._up, this._forward, this._right); + (0, _glMatrix.vec3).transformMat3(this._edgeNormal, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], this._mat3); + (0, _glMatrix.vec3).transformMat3(this._edgePositive, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId], this._mat3); + (0, _glMatrix.vec3).copy(this._edgeNormalTemp, this._edgeNormal); + (0, _glMatrix.vec3).copy(this._edgePositiveTemp, this._edgePositive); + const edgeHorizontalRight = this._edgeHorizontalRight[edgeId]; + const edgeHorizontalUp = this._edgeHorizontalUp[edgeId]; + const edgeHorizontalForward = this._edgeHorizontalForward[edgeId]; + if ((0, _glMatrix.vec3).dot(this._edgeNormalTemp, this._up) > 0) (0, _glMatrix.vec3).copy(edgeHorizontalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId]); + else { + (0, _glMatrix.vec3).negate(edgeHorizontalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId]); + (0, _glMatrix.vec3).negate(this._edgeNormalTemp, this._edgeNormalTemp); + } + if ((0, _glMatrix.vec3).dot(this._edgePositiveTemp, this._right) > 0) { + this._isLeftToRightHorizontal[edgeId] = true; + (0, _glMatrix.vec3).copy(edgeHorizontalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId]); + } else { + this._isLeftToRightHorizontal[edgeId] = false; + (0, _glMatrix.vec3).negate(edgeHorizontalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId]); + (0, _glMatrix.vec3).negate(this._edgePositiveTemp, this._edgePositiveTemp); + } + (0, _glMatrix.vec3).cross(edgeHorizontalForward, this._edgePositiveTemp, this._edgeNormalTemp); + if ((0, _glMatrix.vec3).dot(edgeHorizontalForward, this._forward) < 0) { + this._isLeftToRightHorizontal[edgeId] = !this._isLeftToRightHorizontal[edgeId]; + (0, _glMatrix.vec3).negate(edgeHorizontalRight, edgeHorizontalRight); + } + (0, _glMatrix.vec3).cross(edgeHorizontalForward, edgeHorizontalRight, edgeHorizontalUp); + const edgeVerticalRight = this._edgeVerticalRight[edgeId]; + const edgeVerticalUp = this._edgeVerticalUp[edgeId]; + const edgeVerticalForward = this._edgeVerticalForward[edgeId]; + if ((0, _glMatrix.vec3).dot(this._edgeNormal, this._right) < 0) (0, _glMatrix.vec3).copy(edgeVerticalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId]); + else { + (0, _glMatrix.vec3).negate(edgeVerticalUp, (0, _quadJs.Quad).EDGE_NORMALS[edgeId]); + (0, _glMatrix.vec3).negate(this._edgeNormal, this._edgeNormal); + } + if ((0, _glMatrix.vec3).dot(this._edgePositive, this._up) < 0) { + this._isLeftToRightVertical[edgeId] = true; + (0, _glMatrix.vec3).copy(edgeVerticalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId]); + } else { + this._isLeftToRightVertical[edgeId] = false; + (0, _glMatrix.vec3).negate(edgeVerticalRight, (0, _quadJs.Quad).EDGE_POSITIVES[edgeId]); + (0, _glMatrix.vec3).negate(this._edgePositive, this._edgePositive); + } + (0, _glMatrix.vec3).cross(edgeVerticalForward, this._edgePositive, this._edgeNormal); + if ((0, _glMatrix.vec3).dot(edgeVerticalForward, this._forward) < 0) { + this._isLeftToRightVertical[edgeId] = !this._isLeftToRightVertical[edgeId]; + (0, _glMatrix.vec3).negate(edgeVerticalRight, edgeVerticalRight); + } + (0, _glMatrix.vec3).cross(edgeVerticalForward, edgeVerticalRight, edgeVerticalUp); + if (this.isEdgeVisible[edgeId]) { + if (this._labels[axisId]) this._updateLabels(axisId, edgeId); + if (this._titles[axisId]) this._updateTitle(axisId, edgeId); + } + if (this.isHeadingVisible[edgeId]) this._updateHeading(axisId, edgeId); + } } } - get offsetScalingZ() { - return this._offsetScalingZ; - } - set offsetScalingZ(value) { - if (this._offsetScalingZ != value) { - this._offsetScalingZ = value; - this._hasChanged = true; + _updateLabels(axisId, edgeId) { + const orientation = this._orientations[axisId]; + let distance = this._distances[edgeId]; + let maxLabelSize = this._maxLabelSize[axisId][1]; + if (orientation == (0, _mainJs.AxesTextOrientation).parallel) maxLabelSize *= this._core.config.axesTextLabelLineHeight; + distance += maxLabelSize * 0.5; + (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + const labelMMatrix = this._labelMMatrices[edgeId]; + labelMMatrix[12] = this._vec3[0]; + labelMMatrix[13] = this._vec3[1]; + labelMMatrix[14] = this._vec3[2]; + if (orientation == (0, _mainJs.AxesTextOrientation).parallel) { + const right = this._edgeHorizontalRight[edgeId]; + const up = this._edgeHorizontalUp[edgeId]; + const forward = this._edgeHorizontalForward[edgeId]; + labelMMatrix[0] = right[0]; + labelMMatrix[1] = right[1]; + labelMMatrix[2] = right[2]; + labelMMatrix[4] = up[0]; + labelMMatrix[5] = up[1]; + labelMMatrix[6] = up[2]; + labelMMatrix[8] = forward[0]; + labelMMatrix[9] = forward[1]; + labelMMatrix[10] = forward[2]; + } else { + const right = this._edgeVerticalRight[edgeId]; + const up = this._edgeVerticalUp[edgeId]; + const forward = this._edgeVerticalForward[edgeId]; + labelMMatrix[0] = right[0]; + labelMMatrix[1] = right[1]; + labelMMatrix[2] = right[2]; + labelMMatrix[4] = up[0]; + labelMMatrix[5] = up[1]; + labelMMatrix[6] = up[2]; + labelMMatrix[8] = forward[0]; + labelMMatrix[9] = forward[1]; + labelMMatrix[10] = forward[2]; } + (0, _glMatrix.mat4).multiply(labelMMatrix, this._mMatrix, labelMMatrix); + if (orientation == (0, _mainJs.AxesTextOrientation).perpendicular) (0, _glMatrix.mat4).multiply(labelMMatrix, labelMMatrix, (0, _constantsJs.Constants).MAT4_ROTATION_MINUS_90); + distance += maxLabelSize * 0.5; + this._distances[edgeId] = distance; } - get text() { - return this._text; - } - set text(value) { - if (this._text != value) { - this._text = value; - this._hasChanged = true; - } + _updateTitle(axisId, edgeId) { + let distance = this._distances[edgeId]; + const titleTextSize = this._titleSizes[axisId] * this._core.config.axesTextTitleLineHeight; + distance += titleTextSize * 0.5; + (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + const titleMMatrix = this._titleMMatrices[edgeId]; + titleMMatrix[12] = this._vec3[0]; + titleMMatrix[13] = this._vec3[1]; + titleMMatrix[14] = this._vec3[2]; + const right = this._edgeHorizontalRight[edgeId]; + const up = this._edgeHorizontalUp[edgeId]; + const forward = this._edgeHorizontalForward[edgeId]; + titleMMatrix[0] = right[0]; + titleMMatrix[1] = right[1]; + titleMMatrix[2] = right[2]; + titleMMatrix[4] = up[0]; + titleMMatrix[5] = up[1]; + titleMMatrix[6] = up[2]; + titleMMatrix[8] = forward[0]; + titleMMatrix[9] = forward[1]; + titleMMatrix[10] = forward[2]; + (0, _glMatrix.mat4).multiply(titleMMatrix, this._mMatrix, titleMMatrix); + distance += titleTextSize * 0.5; + this._distances[edgeId] = distance; } - get horizontalAlignments() { - return this._horizontalAlignments; + _updateHeading(axisId, edgeId) { + let distance = this._distances[edgeId]; + const headingTextSize = this._headingSizes[axisId] * this._core.config.axesTextHeadingLineHeight; + distance += headingTextSize * 0.5; + (0, _glMatrix.vec3).multiply(this._vec3, (0, _quadJs.Quad).EDGE_POSITIONS[edgeId], this._size); + (0, _glMatrix.vec3).scaleAndAdd(this._vec3, this._vec3, (0, _quadJs.Quad).EDGE_NORMALS[edgeId], distance); + const headingMMatrix = this._headingMMatrices[edgeId]; + headingMMatrix[12] = this._vec3[0]; + headingMMatrix[13] = this._vec3[1]; + headingMMatrix[14] = this._vec3[2]; + const right = this._edgeHorizontalRight[edgeId]; + const up = this._edgeHorizontalUp[edgeId]; + const forward = this._edgeHorizontalForward[edgeId]; + headingMMatrix[0] = right[0]; + headingMMatrix[1] = right[1]; + headingMMatrix[2] = right[2]; + headingMMatrix[4] = up[0]; + headingMMatrix[5] = up[1]; + headingMMatrix[6] = up[2]; + headingMMatrix[8] = forward[0]; + headingMMatrix[9] = forward[1]; + headingMMatrix[10] = forward[2]; + (0, _glMatrix.mat4).multiply(headingMMatrix, this._mMatrix, headingMMatrix); + distance += headingTextSize * 0.5; + this._distances[edgeId] = distance; } - set horizontalAlignments(value) { - if (this._horizontalAlignments != value) { - this._horizontalAlignments = value; - this._hasChanged = true; + _updateGrids(size) { + let offset = 0; + this.pickGridLookup = {}; + this._pickGrid = []; + const xDivisions = this._gridTicksPositions[0] ? this._gridTicksPositions[0].length - 1 : 0; + const yDivisions = this._gridTicksPositions[1] ? this._gridTicksPositions[1].length - 1 : 0; + const count = 2 * (xDivisions * yDivisions) + xDivisions + yDivisions; + const byteLength = (0, _vertexJs.PickGridVertex).SIZE_BYTES * count * 4; + if (!this._gridVertices || this._gridVertices.byteLength < byteLength) { + this._gridVertices = new ArrayBuffer(byteLength); + this._gridVerticesView = new DataView(this._gridVertices); + this._gridIndices = new Uint16Array(count * 6); } + for(let axisId = 0; axisId < 2; axisId++){ + const width = size[axisId]; + (0, _glMatrix.vec3).set(this._gridTicksScales[axisId], width, this._gridPickDivisionHeight, 1); + offset = this._updateGridTicks(axisId, this._gridVerticesView, this._gridIndices, offset); + this._gridFaceScale[axisId] = size[axisId] == 0 ? 1 : size[axisId]; + } + const axisId = 2; + this._gridFaceScale[axisId] = 1; + for(let faceId = 0; faceId < 2; faceId++)offset = this._updateGridFace(axisId, faceId, this._gridVerticesView, this._gridIndices, offset); } - get verticalAlignments() { - return this._verticalAlignments; - } - set verticalAlignments(value) { - if (this._verticalAlignments != value) { - this._verticalAlignments = value; - this._hasChanged = true; + _updateText(size) { + let glyphOffset = 0; + let count = 0; + for(let axisId = 0; axisId < 2; axisId++){ + const labels = this._labels[axisId]; + if (labels) for(let i = 0; i < labels.length; i++)count += 2 * Math.min(labels[i].length, this._core.config.axesTextLabelMaxGlyphs); + const title = this._titles[axisId]; + if (title) count += Math.min(title.length, this._core.config.axesTextTitleMaxGlyphs); + const heading = this._headings[axisId]; + if (heading) count += Math.min(heading.length, this._core.config.axesTextHeadingMaxGlyphs); + } + const byteLength = (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES * count * 4; + if (!this._textVertices || this._textVertices.byteLength < byteLength) { + this._textVertices = new ArrayBuffer(byteLength); + this._textVerticesView = new DataView(this._textVertices); + this._textIndices = new Uint16Array(count * 6); + } + this.pickLabelLookup = {}; + this._pickLabel = []; + for(let axisId = 0; axisId < 2; axisId++)if (this._labels[axisId]) { + const width = size[axisId]; + const maxLabelSize = this._maxLabelSize[axisId]; + const orientation = this._orientations[axisId]; + (0, _glMatrix.vec2).set(maxLabelSize, 0, 0); + this._axesLeftToRightIndexOffsets[axisId] = glyphOffset * 6; + glyphOffset = this._updateLeftToRightAxisLabels(axisId, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId], this._labelPositions[axisId], this._labelSizes[axisId]); + this._axesLeftToRightIndexCounts[axisId] = glyphOffset * 6 - this._axesLeftToRightIndexOffsets[axisId]; + this._axesRightToLeftIndexOffsets[axisId] = glyphOffset * 6; + glyphOffset = this._updateRightToLeftAxisLabels(axisId, width, maxLabelSize, glyphOffset, orientation, this._labels[axisId], this._labelPositions[axisId], this._labelSizes[axisId]); + this._axesRightToLeftIndexCounts[axisId] = glyphOffset * 6 - this._axesRightToLeftIndexOffsets[axisId]; + } else { + this._axesLeftToRightIndexOffsets[axisId] = glyphOffset * 6; + this._axesRightToLeftIndexOffsets[axisId] = glyphOffset * 6; + this._axesLeftToRightIndexCounts[axisId] = 0; + this._axesRightToLeftIndexCounts[axisId] = 0; + this._maxLabelSize[axisId][0] = 0; + this._maxLabelSize[axisId][1] = 0; + } + this.pickTitleLookup = {}; + this._pickTitle = []; + for(let axisId = 0; axisId < 2; axisId++)if (this._titles[axisId]) { + (0, _glMatrix.vec3).set(this._textPosition, 0, 0, 0); + (0, _glMatrix.vec3).set(this._textOffset, 0, 0, 0); + this._titleIndexOffsets[axisId] = glyphOffset * 6; + const text = (0, _textJs.TextHelper).truncate(this._titles[axisId], this._core.config.axesTextTitleMaxGlyphs); + const scale = this._titleSizes[axisId] / this._font.size; + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + const width = this._textMetric.width * scale; + const maxGlyphTop = this._textMetric.maxTop * scale; + const lineHeight = this._font.size * scale; + this._textOffset[0] -= width / 2; + this._textOffset[1] -= (lineHeight - maxGlyphTop) / 2; + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesTitle, this._vec4); + this.pickTitleLookup[pickId] = this._pickTitle.length; + this._pickTitle.push(axisId); + (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); + glyphOffset += text.length; + this._titleIndexCounts[axisId] = glyphOffset * 6 - this._titleIndexOffsets[axisId]; + } else { + this._titleIndexOffsets[axisId] = glyphOffset * 6; + this._titleIndexCounts[axisId] = 0; + } + this.pickHeadingLookup = {}; + this._pickHeading = []; + for(let axisId = 0; axisId < 2; axisId++)if (this._headings[axisId]) { + (0, _glMatrix.vec3).set(this._textPosition, 0, 0, 0); + (0, _glMatrix.vec3).set(this._textOffset, 0, 0, 0); + this._headingIndexOffsets[axisId] = glyphOffset * 6; + const text = (0, _textJs.TextHelper).truncate(this._headings[axisId], this._core.config.axesTextHeadingMaxGlyphs); + const scale = this._headingSizes[axisId] / this._font.size; + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + const width = this._textMetric.width * scale; + const maxGlyphTop = this._textMetric.maxTop * scale; + const lineHeight = this._font.size * scale; + this._textOffset[0] -= width / 2; + this._textOffset[1] -= (lineHeight - maxGlyphTop) / 2; + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesHeading, this._vec4); + this.pickHeadingLookup[pickId] = this._pickHeading.length; + this._pickHeading.push(axisId); + (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); + glyphOffset += text.length; + this._headingIndexCounts[axisId] = glyphOffset * 6 - this._headingIndexOffsets[axisId]; + } else { + this._headingIndexOffsets[axisId] = glyphOffset * 6; + this._headingIndexCounts[axisId] = 0; } } - get scales() { - return this._scales; + _updateLeftToRightAxisLabels(axisId, size, maxSize, glyphOffset, orientation, labels, positions, scales) { + const isAxisReversed = this.isAxisReversed[axisId]; + for(let label = 0; label < labels.length; label++){ + const text = (0, _textJs.TextHelper).truncate(labels[label], this._core.config.axesTextLabelMaxGlyphs); + const lineHeight = scales[label]; + const scale = lineHeight / this._font.size; + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + const width = this._textMetric.width * scale; + const maxGlyphTop = this._textMetric.maxTop * scale; + const position = isAxisReversed ? 1 - positions[label] : positions[label]; + switch(orientation){ + case (0, _mainJs.AxesTextOrientation).parallel: + (0, _glMatrix.vec3).set(this._textPosition, (position - 0.5) * size, 0, 0); + if (this._isDiscrete[axisId]) this._textOffset[0] = -width / 2; + else this._textOffset[0] = position == 0 ? 0 : position == 1 ? -width : -width / 2; + this._textOffset[1] = (maxGlyphTop - lineHeight) / 2; + maxSize[0] = Math.max(width, maxSize[0]); + maxSize[1] = Math.max(lineHeight, maxSize[1]); + break; + case (0, _mainJs.AxesTextOrientation).perpendicular: + (0, _glMatrix.vec3).set(this._textPosition, 0, (position - 0.5) * size, 0); + this._textOffset[0] = -width / 2; + if (this._isDiscrete[axisId]) this._textOffset[1] = -maxGlyphTop / 2; + else this._textOffset[1] = position == 0 ? 0 : position == 1 ? -maxGlyphTop : -maxGlyphTop / 2; + maxSize[0] = Math.max(lineHeight, maxSize[0]); + maxSize[1] = Math.max(width, maxSize[1]); + break; + } + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesLabel, this._vec4); + this.pickLabelLookup[pickId] = this._pickLabel.length / 2; + this._pickLabel.push(axisId); + this._pickLabel.push(label); + (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); + glyphOffset += text.length; + } + return glyphOffset; } - set scales(value) { - if (this._scales != value) { - this._scales = value; - this._hasChanged = true; + _updateRightToLeftAxisLabels(axisId, size, maxSize, glyphOffset, orientation, labels, positions, scales) { + const isAxisReversed = this.isAxisReversed[axisId]; + for(let label = 0; label < labels.length; label++){ + const text = (0, _textJs.TextHelper).truncate(labels[label], this._core.config.axesTextLabelMaxGlyphs); + const lineHeight = scales[label]; + const scale = lineHeight / this._font.size; + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + const width = this._textMetric.width * scale; + const maxGlyphTop = this._textMetric.maxTop * scale; + const position = isAxisReversed ? 1 - positions[label] : positions[label]; + switch(orientation){ + case (0, _mainJs.AxesTextOrientation).parallel: + (0, _glMatrix.vec3).set(this._textPosition, (0.5 - position) * size, 0, 0); + if (this._isDiscrete[axisId]) this._textOffset[0] = -width / 2; + else this._textOffset[0] = label == 0 ? -width : label == labels.length - 1 ? 0 : -width / 2; + this._textOffset[1] = (maxGlyphTop - lineHeight) / 2; + break; + case (0, _mainJs.AxesTextOrientation).perpendicular: + (0, _glMatrix.vec3).set(this._textPosition, 0, (0.5 - position) * size, 0); + this._textOffset[0] = -width / 2; + if (this._isDiscrete[axisId]) this._textOffset[1] = -maxGlyphTop / 2; + else this._textOffset[1] = label == 0 ? -maxGlyphTop : label == labels.length - 1 ? 0 : -maxGlyphTop / 2; + break; + } + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesLabel, this._vec4); + this.pickLabelLookup[pickId] = this._pickLabel.length / 2; + this._pickLabel.push(axisId); + this._pickLabel.push(label); + (0, _textJs.TextHelper).addString(this._font, text, this._textVerticesView, this._textIndices, glyphOffset, this._textPosition, scale, this._textOffset, null, this._vec4); + glyphOffset += text.length; } + return glyphOffset; } - constructor(core, options){ - super(core, options); - this._quat = (0, _glMatrix.quat).create(); - this._materials = options.materials; - this.minBoundsX = options.minBoundsX ? options.minBoundsX : 0; - this.minBoundsY = options.minBoundsY ? options.minBoundsY : 0; - this.minBoundsZ = options.minBoundsZ ? options.minBoundsZ : 0; - this.maxBoundsX = options.maxBoundsX ? options.maxBoundsX : 1; - this.maxBoundsY = options.maxBoundsY ? options.maxBoundsY : 1; - this.maxBoundsZ = options.maxBoundsZ ? options.maxBoundsZ : 1; - this._font = options.font || core.font; - this.text = options.text; - this.positionsX = options.positionsX; - this.positionsY = options.positionsY; - this.positionsZ = options.positionsZ; - this.positionScalingX = options.positionScalingX ? options.positionScalingX : 1; - this.positionScalingY = options.positionScalingY ? options.positionScalingY : 1; - this.positionScalingZ = options.positionScalingZ ? options.positionScalingZ : 1; - this.rotations = options.rotations; - this.offsetsX = options.offsetsX; - this.offsetsY = options.offsetsY; - this.offsetsZ = options.offsetsZ; - this.offsetScalingX = options.offsetScalingX ? options.offsetScalingX : 1; - this.offsetScalingY = options.offsetScalingY ? options.offsetScalingY : 1; - this.offsetScalingZ = options.offsetScalingZ ? options.offsetScalingZ : 1; - if (options.horizontalAlignments) this.horizontalAlignments = options.horizontalAlignments; - if (options.verticalAlignments) this.verticalAlignments = options.verticalAlignments; - if (options.scales) this.scales = options.scales; + _updateGridTicks(axisId, dataView, indices, offset) { + this._gridTicksIndexOffsets[axisId] = offset * 6; + if (this._gridTicksPositions[axisId]) { + const axes = (0, _glMatrix.vec3).create(); + const positions = this._gridTicksPositions[axisId]; + const isAxisReversed = this.isAxisReversed[axisId]; + let vertexOffset = offset * 4; + for(let position = 0; position < positions.length - 1; position++){ + const left = isAxisReversed ? 1 - positions[position + 1] - 0.5 : positions[position] - 0.5; + const right = isAxisReversed ? 1 - positions[position] - 0.5 : positions[position + 1] - 0.5; + axes[axisId] = position + 1; + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesDivision, this._vec4); + this.pickGridLookup[pickId] = this._pickGrid.length / 3; + this._pickGrid.push(axes[0]); + this._pickGrid.push(axes[1]); + this._pickGrid.push(axes[2]); + let indexOffset = offset * 6; + for(let j = 0; j < this._indexTemplate.length; j++)indices[indexOffset++] = this._indexTemplate[j] + vertexOffset; + (0, _glMatrix.vec4).set(this._bounds, left + 0.5, 0, right + 0.5, 1); + this._translation[0] = left; + this._translation[1] = 0.5; + this._translation[2] = 0; + this._texCoord[0] = left + 0.5; + this._texCoord[1] = 1; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + this._translation[0] = right; + this._texCoord[0] = right + 0.5; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + this._translation[0] = left; + this._translation[1] = -0.5; + this._texCoord[0] = left + 0.5; + this._texCoord[1] = 0; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + this._translation[0] = right; + this._texCoord[0] = right + 0.5; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, (0, _constantsJs.Constants).VECTOR3_UNITZ); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + offset++; + } + } + this._gridTicksIndexCounts[axisId] = offset * 6 - this._gridTicksIndexOffsets[axisId]; + return offset; } - update(elapsedTime) { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - this.pickIdLookup = {}; - if (!this._text) this._indexCount = 0; - else { - const start = window.performance.now(); - const modelSizeX = this._maxBoundsX - this._minBoundsX; - const modelSizeY = this._maxBoundsY - this._minBoundsY; - const modelSizeZ = this._maxBoundsZ - this._minBoundsZ; - const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); - const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; - const modelOriginX = (this._minBoundsX + this._maxBoundsX) / 2; - const modelOriginY = (this._minBoundsY + this._maxBoundsY) / 2; - const modelOriginZ = (this._minBoundsZ + this._maxBoundsZ) / 2; - if (this._rotation) (0, _glMatrix.quat).set(this._quat, this._rotation[0], this._rotation[1], this._rotation[2], this._rotation[3]); - let glyphs = 0; - for(let i = 0; i < this._text.length; i++){ - const offsetX = (this._offsetsX ? this._offsetsX[i] / 2 : this._offsetX) * boundsScaling * this._offsetScalingX; - const offsetY = (this._offsetsY ? this._offsetsY[i] / 2 : this._offsetY) * boundsScaling * this._offsetScalingY; - const offsetZ = (this._offsetsZ ? this._offsetsZ[i] / 2 : this._offsetZ) * boundsScaling * this._offsetScalingZ; - const text = (0, _textJs.TextHelper).truncate(this._text[i], this._maxGlyphs - glyphs); - const scale = (this._scales ? this._scales[i] : this._scale) * boundsScaling / this._font.size; - (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); - const width = this._textMetric.width * scale; - const lineHeight = this._font.size * scale; - const maxGlyphTop = (this._maxGlyphTop ? this._maxGlyphTop : this._textMetric.maxTop) * scale; - const horizontalAlignment = this._horizontalAlignments ? this._horizontalAlignments[i] : this._horizontalAlignment; - switch(horizontalAlignment){ - case (0, _mainJs.HorizontalAlignment).left: - this._offset[0] = offsetX; - break; - case (0, _mainJs.HorizontalAlignment).center: - this._offset[0] = offsetX - width / 2; - break; - case (0, _mainJs.HorizontalAlignment).right: - this._offset[0] = offsetX - width; - break; - } - const verticalAlignment = this._verticalAlignments ? this._verticalAlignments[i] : this._verticalAlignment; - switch(verticalAlignment){ - case (0, _mainJs.VerticalAlignment).top: - this._offset[1] = offsetY - lineHeight / 2; - break; - case (0, _mainJs.VerticalAlignment).center: - this._offset[1] = offsetY; - break; - case (0, _mainJs.VerticalAlignment).bottom: - this._offset[1] = offsetY + lineHeight / 2; - break; - } - this._offset[1] -= maxGlyphTop / 2; - this._offset[2] = offsetZ; - let positionX = this.positionsX ? this.positionsX[i] * this.positionScalingX : 0; - let positionY = this.positionsY ? this.positionsY[i] * this.positionScalingY : 0; - let positionZ = this.positionsZ ? this.positionsZ[i] * this.positionScalingZ : 0; - if (this._reverseX) positionX = this.minBoundsX + this.maxBoundsX - positionX; - if (this._reverseY) positionY = this.minBoundsY + this.maxBoundsY - positionY; - if (this._reverseZ) positionZ = this.minBoundsZ + this.maxBoundsZ - positionZ; - (0, _glMatrix.vec3).set(this._vec3, (positionX - modelOriginX) * boundsScaling, (positionY - modelOriginY) * boundsScaling, (positionZ - modelOriginZ) * boundsScaling); - if (this._rotations) (0, _glMatrix.quat).set(this._quat, this._rotations[i * 4], this._rotations[i * 4 + 1], this._rotations[i * 4 + 2], this._rotations[i * 4 + 3]); + _updateGridFace(axisId, faceId, dataView, indices, offset) { + (0, _glMatrix.vec3).set(this._translation, 0, 0, 0); + this._gridFaceIndexOffsets[faceId] = offset * 6; + const axisId2 = axisId == 0 ? 1 : 0; + const axisId3 = axisId == 2 ? 1 : 2; + if (this._gridTicksPositions[axisId2] && this._gridTicksPositions[axisId3]) { + const axes = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).negate(this._normal, (0, _quadJs.Quad).FACE_NORMALS[faceId]); + const positions2 = this._gridTicksPositions[axisId2]; + const positions3 = this._gridTicksPositions[axisId3]; + const isAxisReversed2 = this.isAxisReversed[axisId2]; + const isAxisReversed3 = this.isAxisReversed[axisId3]; + for(let position2 = 0; position2 < positions2.length - 1; position2++){ + const min2 = isAxisReversed2 ? 1 - positions2[position2 + 1] - 0.5 : positions2[position2] - 0.5; + const max2 = isAxisReversed2 ? 1 - positions2[position2] - 0.5 : positions2[position2 + 1] - 0.5; + axes[axisId2] = position2 + 1; + let vertexOffset = offset * 4; + for(let position3 = 0; position3 < positions3.length - 1; position3++){ + const min3 = isAxisReversed3 ? 1 - positions3[position3 + 1] - 0.5 : positions3[position3] - 0.5; + const max3 = isAxisReversed3 ? 1 - positions3[position3] - 0.5 : positions3[position3 + 1] - 0.5; + axes[axisId3] = position3 + 1; const pickId = (0, _pickJs.PickHelper).nextPickId(); - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).label, this._vec4); - this.pickIdLookup[pickId] = i; - (0, _textJs.TextHelper).addString(this._font, text, this._verticesView, this._indices, glyphs, this._vec3, scale, this._offset, this._rotation || this._rotations ? this._quat : null, this._vec4); - glyphs += text.length; - if (glyphs >= this._maxGlyphs) { - glyphs = this._maxGlyphs; - break; - } + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).axesDivision, this._vec4); + this.pickGridLookup[pickId] = this._pickGrid.length / 3; + this._pickGrid.push(axes[0]); + this._pickGrid.push(axes[1]); + this._pickGrid.push(axes[2]); + let indexOffset = offset * 6; + for(let i = 0; i < this._indexTemplate.length; i++)indices[indexOffset++] = this._indexTemplate[i] + vertexOffset; + (0, _glMatrix.vec4).set(this._bounds, min2 + 0.5, min3 + 0.5, max2 + 0.5, max3 + 0.5); + this._translation[axisId2] = min2; + this._translation[axisId3] = max3; + this._texCoord[0] = min2 + 0.5; + this._texCoord[1] = max3 + 0.5; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + this._translation[axisId2] = max2; + this._texCoord[0] = max2 + 0.5; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + this._translation[axisId2] = min2; + this._translation[axisId3] = min3; + this._texCoord[0] = min2 + 0.5; + this._texCoord[1] = min3 + 0.5; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + this._translation[axisId2] = max2; + this._texCoord[0] = max2 + 0.5; + (0, _vertexJs.PickGridVertex).setTranslation(dataView, vertexOffset, this._translation); + (0, _vertexJs.PickGridVertex).setNormal(dataView, vertexOffset, this._normal); + (0, _vertexJs.PickGridVertex).setIdColor(dataView, vertexOffset, this._vec4); + (0, _vertexJs.PickGridVertex).setTexCoord(dataView, vertexOffset, this._texCoord); + (0, _vertexJs.PickGridVertex).setBounds(dataView, vertexOffset, this._bounds); + vertexOffset++; + offset++; } - this._indexCount = glyphs * 6; - this._core.log.write((0, _mainJs.LogLevel).info, `label set updated ${Math.round(window.performance.now() - start)}ms`); - if (this.hasChangedCallback) this.hasChangedCallback(); } } + this._gridFaceIndexCounts[faceId] = offset * 6 - this._gridFaceIndexOffsets[faceId]; + return offset; } } -},{"gl-matrix":"9GjEQ","../main.js":"1Kju3","../helpers/text.js":"l2V9O","../constants.js":"2Scl5","../vertex.js":"ddAub","../helpers/pick.js":"9zmDo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"llF9m":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); -parcelHelpers.export(exports, "ImageBase", ()=>ImageBase); -parcelHelpers.export(exports, "ImageQuad", ()=>ImageQuad); -parcelHelpers.export(exports, "ImageSphere", ()=>ImageSphere); +},{"gl-matrix":"5x28d","../../constants.js":"lD0bG","../../main.js":"f421K","./axes.js":"8Tmim","../../meshes/quad.js":"3PqJr","../../vertex.js":"4J2YE","../../helpers/axes.js":"99ajO","../../helpers/text.js":"fG2oi","../../helpers/pick.js":"1t2sb","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ibkbS":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _vertexJs = require("../vertex.js"); -var _quadJs = require("../meshes/quad.js"); -var _sphereJs = require("../meshes/sphere.js"); -var _constantsJs = require("../constants.js"); -class ImageVisual { - render(elapsedTime, xrFrame) {} - update(elapsedTime) {} - constructor(image){ - this.image = image; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Glyph", ()=>Glyph); +parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); +parcelHelpers.export(exports, "Font", ()=>Font); +parcelHelpers.export(exports, "FontAtlas", ()=>FontAtlas); +parcelHelpers.export(exports, "FontRasterizer", ()=>FontRasterizer); +parcelHelpers.export(exports, "GlyphRasterizer", ()=>GlyphRasterizer); +var _mainJs = require("./main.js"); +class Glyph { + toJSON() { + return { + key: this.key, + char: this.char, + width: this.width, + height: this.height, + top: this.top, + left: this.left, + advance: this.advance, + u0: this.u0, + v0: this.v0, + u1: this.u1, + v1: this.v1 + }; } } -class ImageBase { - get material() { - return this._material; - } - get vertices() { - return this._vertices; - } - get indices() { - return this._indices; - } - get indexCount() { - return this._indexCount; - } - get isInitialized() { - return this._isInitialized; - } - get mMatrix() { - return this._mMatrix; - } - get imageData() { - return this._imageData; - } - set imageData(value) { - if (this._imageData != value) { - this._imageData = value; - this._hasChanged = true; - } - } - get rotation() { - return this._rotation; - } - set rotation(value) { - if (!(0, _glMatrix.quat).equals(this._rotation, value)) { - (0, _glMatrix.quat).copy(this._rotation, value); - this._hasChanged = true; - } - } - get position() { - return this._position; - } - set position(value) { - if (!(0, _glMatrix.vec3).equals(this._position, value)) { - (0, _glMatrix.vec3).copy(this._position, value); - this._hasChanged = true; - } - } - get texCoord0() { - return this._texCoord0; - } - set texCoord0(value) { - if (!(0, _glMatrix.vec2).equals(this._texCoord0, value)) { - (0, _glMatrix.vec2).copy(this._texCoord0, value); - this._hasChanged = true; - } - } - get texCoord1() { - return this._texCoord1; - } - set texCoord1(value) { - if (!(0, _glMatrix.vec2).equals(this._texCoord1, value)) { - (0, _glMatrix.vec2).copy(this._texCoord1, value); - this._hasChanged = true; - } +class FontVisual { + update() {} + constructor(font){ + this.font = font; } - get minBoundsX() { - return this._minBoundsX; +} +class Font { + get atlas() { + return this._rasterizer.fontAtlas; } - set minBoundsX(value) { - if (this._minBoundsX != value) { - this._minBoundsX = value; - this._hasChanged = true; - } + get count() { + return this._chars.size; } - get minBoundsY() { - return this._minBoundsY; + constructor(core, rasterizer){ + this._core = core; + this._rasterizer = rasterizer; + this._chars = new Set(); + this._previousSize = 0; + this.glyphs = {}; } - set minBoundsY(value) { - if (this._minBoundsY != value) { - this._minBoundsY = value; + addGlyph(char) { + if (!this._chars.has(char)) { + this._chars.add(char); + this._rasterizer.draw(char); this._hasChanged = true; } } - get minBoundsZ() { - return this._minBoundsZ; - } - set minBoundsZ(value) { - if (this._minBoundsZ != value) { - this._minBoundsZ = value; - this._hasChanged = true; + update() { + if (this._hasChanged) { + this._hasChanged = false; + this._core.log.write((0, _mainJs.LogLevel).info, `${this.name} added ${this._chars.size - this._previousSize} new glyphs`); + this._previousSize = this._chars.size; + if (this.hasChangedCallback) this.hasChangedCallback(); } } - get maxBoundsX() { - return this._maxBoundsX; - } - set maxBoundsX(value) { - if (this._maxBoundsX != value) { - this._maxBoundsX = value; - this._hasChanged = true; + toJSON() { + const glyphs = []; + for(let key in this.glyphs){ + const glyph = this.glyphs[key]; + glyphs.push(glyph.toJSON()); } + return { + name: this.name, + size: this.size, + border: this.border, + glyphs: glyphs, + edgeValue: this.edgeValue + }; } - get maxBoundsY() { - return this._maxBoundsY; - } - set maxBoundsY(value) { - if (this._maxBoundsY != value) { - this._maxBoundsY = value; - this._hasChanged = true; - } +} +class FontAtlas { + constructor(width, height){ + const canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + const context = canvas.getContext("2d"); + context.clearRect(0, 0, width, height); + this.imageData = context.getImageData(0, 0, width, height); + this.x = 0; + this.top = new Uint16Array(width); } - get maxBoundsZ() { - return this._maxBoundsZ; +} +class FontRasterizer { + get font() { + return this._font; } - set maxBoundsZ(value) { - if (this._maxBoundsZ != value) { - this._maxBoundsZ = value; - this._hasChanged = true; - } + get fontAtlas() { + return this._fontAtlas; } constructor(core, options){ + let start = performance.now(); this._core = core; - this._mMatrix = (0, _glMatrix.mat4).create(); - this._origin = (0, _glMatrix.vec3).create(); - this._translation = (0, _glMatrix.vec3).create(); - this._scale = (0, _glMatrix.vec3).create(); - this._transform = (0, _glMatrix.mat4).create(); - this._imageData = options.imageData; - this._minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; - this._minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; - this._minBoundsZ = options.minBoundsZ === undefined ? 0 : options.minBoundsZ; - this._maxBoundsX = options.maxBoundsX === undefined ? 1 : options.maxBoundsX; - this._maxBoundsY = options.maxBoundsY === undefined ? 1 : options.maxBoundsY; - this._maxBoundsZ = options.maxBoundsZ === undefined ? 1 : options.maxBoundsZ; - this._position = options.position ? (0, _glMatrix.vec3).clone(options.position) : (0, _glMatrix.vec3).create(); - this._rotation = options.rotation ? (0, _glMatrix.quat).clone(options.rotation) : (0, _glMatrix.quat).create(); - this._texCoord0 = options.texCoord0 ? (0, _glMatrix.vec2).clone(options.texCoord0) : (0, _glMatrix.vec2).fromValues(0, 0); - this._texCoord1 = options.texCoord1 ? (0, _glMatrix.vec2).clone(options.texCoord1) : (0, _glMatrix.vec2).fromValues(1, 1); - this._material = options.material === undefined ? -1 : options.material; - this._hasChanged = true; - } -} -class ImageQuad extends ImageBase { - get width() { - return this._width; - } - set width(value) { - if (this._width != value) { - this._width = value; - this._hasChanged = true; - } - } - get height() { - return this._height; + this._fontAtlas = options.fontAtlas; + this._fontSize = options.fontSize; + this._border = options.border; + this._fontFamily = options.fontFamily; + this._fontWeight = options.fontWeight; + this._fontStyle = options.fontStyle; + this._baseline = options.baseline; + this._maxDistance = options.maxDistance; + this._edgeValue = options.edgeValue; + this._font = new Font(core, this); + this._font.name = `${this._fontFamily}${this._fontSize}${this._fontWeight == "normal" ? "" : this._fontWeight}${this._fontStyle == "normal" ? "" : this._fontStyle}`.replace(/[^a-z0-9,]/ig, "").toLowerCase(); + this._font.size = this._fontSize; + this._font.border = this._border; + this._font.edgeValue = this._edgeValue; + const glyphRasterizerOptions = { + baseline: this._baseline, + border: this._border, + edgeValue: this._edgeValue, + fontFamily: this._fontFamily, + fontSize: this._fontSize, + fontStyle: this._fontStyle, + fontWeight: this._fontWeight, + maxDistance: this._maxDistance + }; + this._glyphRasterizer = new GlyphRasterizer(core, glyphRasterizerOptions); + this._core.log.write((0, _mainJs.LogLevel).info, `font rasterizer ${Math.round(window.performance.now() - start)}ms`); } - set height(value) { - if (this._height != value) { - this._height = value; - this._hasChanged = true; - } - } - constructor(core, options){ - super(core, options); - this._width = options.width === undefined ? 1 : options.width; - this._height = options.height === undefined ? 1 : options.height; - this._texTransform = (0, _glMatrix.mat4).create(); - (0, _glMatrix.mat4).translate(this._texTransform, this._texTransform, (0, _glMatrix.vec3).fromValues(0, 1, 0)); - (0, _glMatrix.mat4).scale(this._texTransform, this._texTransform, (0, _glMatrix.vec3).fromValues(1, -1, 1)); - } - initialize() { - this._vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * 4); - this._indices = (0, _quadJs.Quad).INDICES; - this._indexCount = this._indices.length; - this._isInitialized = true; - } - update(elapsedTime) { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - const modelSizeX = this._maxBoundsX - this._minBoundsX; - const modelSizeY = this._maxBoundsY - this._minBoundsY; - const modelSizeZ = this._maxBoundsZ - this._minBoundsZ; - const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); - const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; - (0, _glMatrix.vec3).set(this._origin, (this._minBoundsX + this._maxBoundsX) / 2, (this._minBoundsY + this._maxBoundsY) / 2, (this._minBoundsZ + this._maxBoundsZ) / 2); - (0, _glMatrix.vec3).subtract(this._translation, this._position, this._origin); - (0, _glMatrix.vec3).scale(this._translation, this._translation, boundsScaling); - (0, _glMatrix.vec3).set(this._scale, this._width, this._height, 1); - (0, _glMatrix.vec3).scale(this._scale, this._scale, boundsScaling); - (0, _glMatrix.mat4).fromRotationTranslationScale(this._transform, this._rotation, this._translation, this._scale); - this._verticesView = (0, _quadJs.Quad).normalTextured(this._transform, this._texTransform); - this._vertices = this._verticesView.buffer; - if (this.hasChangedCallback) this.hasChangedCallback(); + draw(char) { + const glyph = this._glyphRasterizer.draw(char); + const texWidth = glyph.width + 2 * this._border; + const texHeight = glyph.height + 2 * this._border; + const width = this._fontAtlas.imageData.width; + const height = this._fontAtlas.imageData.height; + if (this._fontAtlas.x + texWidth > width) this._fontAtlas.x = 0; + let y = 0; + for(let x = this._fontAtlas.x; x < this._fontAtlas.x + texWidth; x++)y = Math.max(y, this._fontAtlas.top[x]); + if (y + texHeight > height) this._core.log.write((0, _mainJs.LogLevel).warn, `${this._font.name} height overflow`); + for(let x = this._fontAtlas.x; x < this._fontAtlas.x + texWidth; x++)this._fontAtlas.top[x] = y + texHeight; + glyph.u0 = this._fontAtlas.x / width; + glyph.v0 = y / height; + glyph.u1 = (this._fontAtlas.x + texWidth) / width; + glyph.v1 = (y + texHeight) / height; + this._font.glyphs[char] = glyph; + for(let i = 0; i < glyph.distances.length; i++){ + const distance = glyph.distances[i]; + const dataX = i % texWidth; + const dataY = Math.floor(i / texWidth); + const offset = (this._fontAtlas.x + dataX + (y + dataY) * width) * 4; + this._fontAtlas.imageData.data[offset + 0] = distance; + this._fontAtlas.imageData.data[offset + 1] = distance; + this._fontAtlas.imageData.data[offset + 2] = distance; + this._fontAtlas.imageData.data[offset + 3] = 0xff; } + this._fontAtlas.x += texWidth; } } -class ImageSphere extends ImageBase { - get radius() { - return this._radius; +class GlyphRasterizer { + constructor(core, options){ + let start = performance.now(); + this._core = core; + this._fontSize = options.fontSize; + this._border = options.border; + this._fontFamily = options.fontFamily; + this._fontWeight = options.fontWeight; + this._fontStyle = options.fontStyle; + this._baseline = options.baseline; + this._maxDistance = options.maxDistance; + this._edgeValue = options.edgeValue; + this._size = this._fontSize + this._border * 2; + this._size += this._border * 2; + this._gridOuter = new Float64Array(this._size * this._size); + this._gridInner = new Float64Array(this._size * this._size); + this._f = new Float64Array(this._size); + this._z = new Float64Array(this._size + 1); + this._v = new Uint16Array(this._size); + const canvas = document.createElement("canvas"); + canvas.width = canvas.height = this._size; + this._context = canvas.getContext("2d", { + willReadFrequently: true + }); + this._context.font = `${this._fontStyle} ${this._fontWeight} ${this._fontSize}px ${this._fontFamily} `; + this._context.textBaseline = this._baseline; + this._context.textAlign = "left"; + this._context.fillStyle = "black"; + this._core.log.write((0, _mainJs.LogLevel).info, `glyph rasterizer ${Math.round(window.performance.now() - start)}ms`); } - set radius(value) { - if (this._radius != value) { - this._radius = value; - this._hasChanged = true; + draw(char) { + const textMetrics = this._context.measureText(char); + const glyphLeft = 0; + const glyphTop = Math.floor(textMetrics.actualBoundingBoxAscent); + let glyphWidth = Math.ceil(textMetrics.actualBoundingBoxRight); + let glyphHeight = Math.ceil(textMetrics.actualBoundingBoxAscent) + Math.ceil(textMetrics.actualBoundingBoxDescent); + glyphWidth = Math.min(this._size - this._border, glyphWidth); + glyphHeight = Math.min(this._size - this._border, glyphHeight); + const width = glyphWidth + 2 * this._border; + const height = glyphHeight + 2 * this._border; + const length = width * height; + const distances = new Uint8ClampedArray(length); + const gradientsX = new Uint8ClampedArray(length); + const gradientsY = new Uint8ClampedArray(length); + const pixels = new Uint8ClampedArray(length); + const glyph = new Glyph(); + glyph.char = char; + glyph.key = char.codePointAt(0); + glyph.distances = distances; + glyph.gradientsX = gradientsX; + glyph.gradientsY = gradientsY; + glyph.pixels = pixels; + glyph.width = glyphWidth; + glyph.height = glyphHeight; + glyph.top = glyphTop; + glyph.left = glyphLeft; + glyph.advance = textMetrics.width; + if (glyphWidth == 0 || glyphHeight == 0) return glyph; + this._context.clearRect(this._border, this._border, glyphWidth, glyphHeight); + this._context.fillText(char, this._border, this._border + glyphTop); + const imgData = this._context.getImageData(this._border, this._border, glyphWidth, glyphHeight); + for(let i = 0; i < length; i++){ + this._gridOuter[i] = Number.MAX_VALUE; + this._gridInner[i] = 0; } + for(let y = 0; y < glyphHeight; y++)for(let x = 0; x < glyphWidth; x++){ + const a = imgData.data[4 * (y * glyphWidth + x) + 3] / 0xff; + if (a > 0) { + const j = (y + this._border) * width + x + this._border; + if (a == 1) { + this._gridOuter[j] = 0; + this._gridInner[j] = Number.MAX_VALUE; + } else { + const d = 0.5 - a; + this._gridOuter[j] = d > 0 ? d * d : 0; + this._gridInner[j] = d < 0 ? d * d : 0; + pixels[j] = 0xff; + } + } + } + this._edt(this._gridOuter, 0, 0, width, height, width, this._f, this._v, this._z); + this._edt(this._gridInner, this._border, this._border, glyphWidth, glyphHeight, width, this._f, this._v, this._z); + const distances2 = new Float32Array(length); + for(let i = 0; i < length; i++){ + const distance = Math.sqrt(this._gridOuter[i]) - Math.sqrt(this._gridInner[i]); + distances[i] = Math.round(this._edgeValue - distance * 0xff / this._maxDistance); + distances2[i] = distance; + } + for(let i = 0; i < length; i++){ + const x = i % width; + const y = Math.floor(i / width); + const d = distances2[i]; + const sign = d < 0 ? -1 : 1; + const x0 = x > 0 ? distances2[i - 1] : Number.MAX_VALUE; + const x1 = x < width - 1 ? distances2[i + 1] : Number.MAX_VALUE; + const y0 = y > 0 ? distances2[i - width] : Number.MAX_VALUE; + const y1 = y < height - 1 ? distances2[i + width] : Number.MAX_VALUE; + let gradientX = sign * x0 < sign * x1 ? d - x0 : x1 - d; + let gradientY = sign * y0 < sign * y1 ? y0 - d : d - y1; + gradientsX[i] = Math.round((gradientX * 0.5 + 0.5) * 0xff); + gradientsY[i] = Math.round((gradientY * 0.5 + 0.5) * 0xff); + } + return glyph; } - constructor(core, options){ - super(core, options); - this._radius = options.radius === undefined ? 0.5 : options.radius; - this._slices = options.slices === undefined ? 72 : options.slices; - this._stacks = options.stacks === undefined ? 36 : options.stacks; - } - initialize() { - this._sphere = new (0, _sphereJs.Sphere)(this._core); - this._vertices = this._sphere.normalTextured(this._slices, this._stacks, (0, _constantsJs.Constants).MAT4_IDENTITY).buffer; - this._indices = this._sphere.indices(this._slices, this._stacks); - this._indexCount = this._indices.length; - this._isInitialized = true; + _edt(data, x0, y0, width, height, gridSize, f, v, z) { + for(let x = x0; x < x0 + width; x++)this._edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); + for(let y = y0; y < y0 + height; y++)this._edt1d(data, y * gridSize + x0, 1, width, f, v, z); } - update(elapsedTime) { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - const modelSizeX = this._maxBoundsX - this._minBoundsX; - const modelSizeY = this._maxBoundsY - this._minBoundsY; - const modelSizeZ = this._maxBoundsZ - this._minBoundsZ; - const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); - const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; - (0, _glMatrix.vec3).set(this._origin, (this._minBoundsX + this._maxBoundsX) / 2, (this._minBoundsY + this._maxBoundsY) / 2, (this._minBoundsZ + this._maxBoundsZ) / 2); - (0, _glMatrix.vec3).set(this._scale, this._radius, this._radius, this._radius); - (0, _glMatrix.vec3).scale(this._scale, this._scale, boundsScaling); - (0, _glMatrix.mat4).fromRotationTranslationScaleOrigin(this._transform, this._rotation, this._position, this._scale, this._origin); - this._verticesView = this._sphere.normalTextured(this._slices, this._stacks, this._transform); - this._vertices = this._verticesView.buffer; - if (this.hasChangedCallback) this.hasChangedCallback(); + _edt1d(grid, offset, stride, n, f, v, z) { + v[0] = 0; + z[0] = -Number.MAX_VALUE; + z[1] = Number.MAX_VALUE; + f[0] = grid[offset]; + for(let q = 1, k = 0, s = 0; q < n; q++){ + f[q] = grid[offset + q * stride]; + const q2 = q * q; + do { + const r = v[k]; + s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; + }while (s <= z[k] && --k > -1); + k++; + v[k] = q; + z[k] = s; + z[k + 1] = Number.MAX_VALUE; + } + for(let q = 0, k = 0; q < n; q++){ + while(z[k + 1] < q)k++; + const r = v[k]; + const qr = q - r; + grid[offset + q * stride] = f[r] + qr * qr; } } } -},{"gl-matrix":"9GjEQ","../vertex.js":"ddAub","../meshes/quad.js":"jyd4s","../meshes/sphere.js":"j7wP0","../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"j7wP0":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Sphere", ()=>Sphere); +},{"./main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8nDg6":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Manager", ()=>Manager); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +var _manipulationprocessorJs = require("./manipulationprocessor.js"); +var _mousewheelJs = require("./mousewheel.js"); +var _pointersJs = require("./pointers.js"); +var _animationJs = require("../helpers/animation.js"); var _constantsJs = require("../constants.js"); -var _angleJs = require("../helpers/angle.js"); -var _vertexJs = require("../vertex.js"); -class Sphere { - constructor(core){} - positions(slices, stacks, transform) { - const vertices = new Float32Array((slices + 1) * (stacks + 1) * (0, _vertexJs.PositionVertex).SIZE); - const position = (0, _glMatrix.vec3).create(); - let index = 0; - for(let stack = 0; stack <= stacks; stack++){ - const latitude = 90 - 180 * stack / stacks; - for(let slice = 0; slice <= slices; slice++){ - const longitude = 360 * slice / slices - 180; - (0, _angleJs.AngleHelper).sphericalToCartesian(1, longitude, latitude, position); - (0, _glMatrix.vec3).transformMat4(position, position, transform); - (0, _vertexJs.PositionVertex).setPosition(vertices, index++, position); - } - } - return vertices; +var _keyboardJs = require("./keyboard.js"); +class Manager { + constructor(core){ + this._manipulators = {}; + this._core = core; + this._vec3 = (0, _glMatrix.vec3).create(); + this._manipulationProcessor = new (0, _manipulationprocessorJs.ManipulationProcessor)(core); + this._manipulators = {}; + this._pointers = new (0, _pointersJs.Pointers)(core, this._manipulators); + this._pointers.initialize(core.container); + this._mouseWheel = new (0, _mousewheelJs.MouseWheel)(core); + this._mouseWheel.initialize(core.container); + this._keyboard = new (0, _keyboardJs.Keyboard)(core); + this._keyboard.initialize(core.container); + this.isPickingEnabled = true; + this.mouseWheelZoomScale = this._core.config.mouseWheelZoomScale; + this.mouseWheelRotationScale = this._core.config.mouseWheelRotationScale; + this.multiTouchZoomScale = this._core.config.multiTouchZoomScale; + this.pickHoldDelay = this._core.config.pickHoldDelay; + this.pickSelectDelay = this._core.config.pickSelectDelay; + const rightButton = 2; + this.singleTouchAction = (manipulator)=>{ + if (manipulator.type == "mouse" && manipulator.button == rightButton || manipulator.shiftKey || manipulator.ctrlKey) return (0, _mainJs.SingleTouchAction).translate; + else if (manipulator.altKey || manipulator.type == "pen" && manipulator.button == rightButton) return (0, _mainJs.SingleTouchAction).lasso; + else return (0, _mainJs.SingleTouchAction).rotate; + }; + this.mouseWheelAction = (keyboard)=>{ + if (this._keyboard.isKeyDown("Control")) return (0, _mainJs.MouseWheelAction).rotateY; + else return (0, _mainJs.MouseWheelAction).zoom; + }; + this.lassoPickType = (0, _mainJs.PickType).data; + this._thumbstickX = 0; + this._previousControllerButtonPressed = [ + false, + false, + false, + false + ]; + this._quat0 = (0, _glMatrix.quat).create(); + this._quat1 = (0, _glMatrix.quat).create(); } - indices(slices, stacks) { - const indices = new Uint16Array(slices * stacks * 6); - let index = 0; - for(let stack = 0; stack < stacks; stack++){ - const top = stack * (slices + 1); - const bottom = (stack + 1) * (slices + 1); - for(let slice = 0; slice < slices; slice++){ - if (stack != 0) { - indices[index++] = top + slice; - indices[index++] = bottom + slice; - indices[index++] = top + slice + 1; + update(elapsedTime, xrFrame) { + if (xrFrame) { + const inputSources = this._core.webXRSession.inputSources; + if (inputSources.length > 0 && this._core.renderer.controllers.length > 0) { + const inputSource = inputSources[0]; + const controllerVisual = this._core.renderer.controllers[0]; + if (inputSource.gripSpace && inputSource.targetRayMode == "tracked-pointer") { + const gripPose = xrFrame.getPose(inputSource.gripSpace, this._core.renderer.webXRReferenceSpace); + if (gripPose) controllerVisual.mMatrix = gripPose.transform.matrix; + const gamepad = inputSource.gamepad; + this._core.renderer.isPickingEnabled = false; + const rayPose = xrFrame.getPose(inputSource.targetRaySpace, this._core.renderer.webXRReferenceSpace); + if (rayPose) { + controllerVisual.rayMMatrix = rayPose.transform.matrix; + if (gamepad.buttons[0].value > 0 && this.isPickingEnabled) { + this._core.renderer.pickVMatrix = rayPose.transform.inverse.matrix; + this._core.renderer.isPickingEnabled = true; + } + } + const threshold = 0.2; + const dampening = Math.min(0.015 * elapsedTime, 1); + this._thumbstickX = (0, _animationJs.AnimationHelper).damp(this._thumbstickX, gamepad.axes[2], threshold, dampening); + if (this._thumbstickX != 0) { + (0, _glMatrix.quat).setAxisAngle(this._quat0, (0, _constantsJs.Constants).VECTOR3_UNITY, 0.01 * this._thumbstickX * elapsedTime); + this._core.getModelRotation(this._quat1); + (0, _glMatrix.quat).multiply(this._quat1, this._quat0, this._quat1); + this._core.setModelRotation(this._quat1, true); + } + if (gamepad.buttons[2].pressed) { + if (!this._previousControllerButtonPressed[2]) { + this._previousControllerButtonPressed[2] = true; + if (this.controllerButtonPressedCallback) this.controllerButtonPressedCallback(2); + } + } else this._previousControllerButtonPressed[2] = false; } - if (stack != stacks - 1) { - indices[index++] = top + slice + 1; - indices[index++] = bottom + slice; - indices[index++] = bottom + slice + 1; + } + } else { + const camera = this._core.camera; + this._manipulationProcessor.update(elapsedTime, this._manipulators); + this._pointers.update(elapsedTime); + this._mouseWheel.update(elapsedTime); + this._keyboard.update(elapsedTime); + if (this._mouseWheel.delta != 0) switch(this.mouseWheelAction(this._keyboard)){ + case (0, _mainJs.MouseWheelAction).zoom: + if (this._pointers.hoverX, this._pointers.hoverY) camera.zoom(this._mouseWheel.delta * this.mouseWheelZoomScale, this._pointers.hoverX, this._pointers.hoverY); + break; + case (0, _mainJs.MouseWheelAction).rotateY: + (0, _glMatrix.quat).setAxisAngle(this._quat0, (0, _constantsJs.Constants).VECTOR3_UNITY, this._mouseWheel.delta * this.mouseWheelRotationScale); + camera.getOrbit(this._quat1); + (0, _glMatrix.quat).multiply(this._quat1, this._quat1, this._quat0); + camera.setOrbit(this._quat1, true); + break; + } + const count = this._manipulationProcessor.count; + if (count == 0) { + if (this._isLassoPicking) { + this._isLassoPicking = false; + this._core.renderer.isLassoPicking = false; + const x0 = Math.min(this._lassoX0, this._lassoX1); + const y0 = Math.min(this._lassoY0, this._lassoY1); + const x1 = Math.max(this._lassoX0, this._lassoX1); + const y1 = Math.max(this._lassoY0, this._lassoY1); + if (x1 - x0 > 0 && y1 - y0 > 0) { + const sets = this._core.pickLasso(x0, y0, x1, y1, this.lassoPickType); + const result = { + x0: x0, + y0: y0, + x1: x1, + y1: y1, + pickType: this.lassoPickType, + ids: sets, + manipulator: this._manipulator + }; + this.pickLassoCallback(result); + } + } + } else if (count == 1) { + const translationDelta = this._manipulationProcessor.translationDelta; + if (translationDelta[0] != 0 || translationDelta[1] != 0) { + const manipulators = this._manipulationProcessor.manipulators; + for(const key in manipulators){ + const manipulator = manipulators[key]; + switch(this.singleTouchAction(manipulator)){ + case (0, _mainJs.SingleTouchAction).rotate: + camera.rotate(translationDelta); + break; + case (0, _mainJs.SingleTouchAction).translate: + camera.translate(translationDelta); + break; + case (0, _mainJs.SingleTouchAction).lasso: + if (this.pickLassoCallback) { + if (!this._isLassoPicking) { + this._isLassoPicking = true; + this._core.renderer.isLassoPicking = true; + this._lassoX0 = manipulator.position[0]; + this._lassoY0 = manipulator.position[1]; + } + this._lassoX1 = manipulator.position[0]; + this._lassoY1 = manipulator.position[1]; + this._core.renderer.lassoX0 = Math.min(this._lassoX0, this._lassoX1); + this._core.renderer.lassoY0 = Math.min(this._lassoY0, this._lassoY1); + this._core.renderer.lassoX1 = Math.max(this._lassoX0, this._lassoX1); + this._core.renderer.lassoY1 = Math.max(this._lassoY0, this._lassoY1); + } + break; + } + break; + } + } + } else { + const translationDelta = this._manipulationProcessor.translationDelta; + const camera = this._core.camera; + if (translationDelta[0] != 0 || translationDelta[1] != 0) camera.translate(translationDelta); + if (this._manipulationProcessor.scaleDelta != 0) { + const distance = this._manipulationProcessor.scaleDelta * this.multiTouchZoomScale; + camera.zoom(distance, this._manipulationProcessor.centroid[0], this._manipulationProcessor.centroid[1]); } + if (this._manipulationProcessor.twistDelta != 0) camera.twist(this._manipulationProcessor.twistDelta, this._manipulationProcessor.centroid[0], this._manipulationProcessor.centroid[1]); + } + if (this.isPickingEnabled && !this._manipulationProcessor.isDragging && !this._isLassoPicking) { + const camera = this._core.camera; + const renderer = this._core.renderer; + if (renderer.isCapturingPickImage) { + camera.updatePickVMatrix(renderer.width / 2, renderer.height / 2); + renderer.pickVMatrix = camera.pickVMatrix; + renderer.isPickingEnabled = true; + this._pickedTime = 0; + } else if (this._pointers.hoverId > -1) { + const pickingX = this._pointers.hoverX; + const pickingY = this._pointers.hoverY; + camera.updatePickVMatrix(pickingX, pickingY); + renderer.pickVMatrix = camera.pickVMatrix; + renderer.isPickingEnabled = true; + if (this._pickedId != renderer.pickedId) { + this._pickedId = renderer.pickedId; + this._pickedTime = 0; + } else if (this._manipulationProcessor.count == 1) { + this._pickedTime += elapsedTime; + for(const key in this._manipulators){ + this._manipulator = this._manipulators[key]; + break; + } + } + if (this._pickedTime > 0) switch(renderer.pickedType){ + case (0, _mainJs.PickType).data: + if (this._pickedTime > this.pickHoldDelay) { + renderer.getVertexPosition(this._vec3, this._pickedId); + this._core.setModelManipulationOrigin(this._vec3); + this._pickedTime = 0; + } else if (this._manipulationProcessor.count == 0) { + if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.transitionBuffers.length; i++){ + const transitionBuffer = renderer.transitionBuffers[i]; + const id = transitionBuffer.pickIdLookup[this._pickedId]; + if (id > -1) { + const result = { + transitionBuffer: i, + id: id, + manipulator: this._manipulator + }; + this._core.log.write((0, _mainJs.LogLevel).info, `picked id ${result.id}, transition buffer ${i}`); + if (this.pickItemCallback) this.pickItemCallback(result); + break; + } + } + this._pickedTime = 0; + } + break; + case (0, _mainJs.PickType).label: + if (this._manipulationProcessor.count == 0) { + if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.labelSets.length; i++){ + const labelSet = renderer.labelSets[i].label; + const id = labelSet.pickIdLookup[this._pickedId]; + if (id > -1) { + const result = { + label: id, + set: i, + manipulator: this._manipulator + }; + this._core.log.write((0, _mainJs.LogLevel).info, `picked label ${result.label}, set ${result.set}`); + if (this.pickLabelSetCallback) this.pickLabelSetCallback(result); + break; + } + } + this._pickedTime = 0; + } + break; + case (0, _mainJs.PickType).axesDivision: + if (this._manipulationProcessor.count == 0) { + if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.currentAxes.length; i++){ + const axes = renderer.currentAxes[i].axes; + const id = axes.pickGridLookup[this._pickedId]; + if (id > -1) { + const result = axes.pickGrid(id); + result.axes = i; + result.manipulator = this._manipulator; + this._core.log.write((0, _mainJs.LogLevel).info, `picked division (${result.divisionX}, ${result.divisionY}, ${result.divisionZ}), axes ${result.axes}`); + if (this.pickAxesGridCallback) this.pickAxesGridCallback(result); + break; + } + } + this._pickedTime = 0; + } + break; + case (0, _mainJs.PickType).axesTitle: + if (this._manipulationProcessor.count == 0) { + if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.currentAxes.length; i++){ + const axes = renderer.currentAxes[i].axes; + const id = axes.pickTitleLookup[this._pickedId]; + if (id > -1) { + const result = axes.pickTitle(id); + result.axes = i; + result.manipulator = this._manipulator; + this._core.log.write((0, _mainJs.LogLevel).info, `picked title ${result.axis}, axes ${result.axes}`); + if (this.pickAxesTitleCallback) this.pickAxesTitleCallback(result); + break; + } + } + this._pickedTime = 0; + } + break; + case (0, _mainJs.PickType).axesLabel: + if (this._manipulationProcessor.count == 0) { + if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.currentAxes.length; i++){ + const axes = renderer.currentAxes[i].axes; + const id = axes.pickLabelLookup[this._pickedId]; + if (id > -1) { + const result = axes.pickLabel(id); + result.axes = i; + result.manipulator = this._manipulator; + this._core.log.write((0, _mainJs.LogLevel).info, `picked label ${result.label}, axis ${result.axis}, axes ${result.axes}`); + if (this.pickAxesLabelCallback) this.pickAxesLabelCallback(result); + break; + } + } + this._pickedTime = 0; + } + break; + case (0, _mainJs.PickType).axesHeading: + if (this._manipulationProcessor.count == 0) { + if (this._pickedTime > this.pickSelectDelay) for(let i = 0; i < renderer.currentAxes.length; i++){ + const axes = renderer.currentAxes[i].axes; + const id = axes.pickHeadingLookup[this._pickedId]; + if (id > -1) { + const result = axes.pickHeading(id); + result.axes = i; + result.manipulator = this._manipulator; + this._core.log.write((0, _mainJs.LogLevel).info, `picked heading ${result.axis}, axes ${result.axes}`); + if (this.pickAxesHeadingCallback) this.pickAxesHeadingCallback(result); + break; + } + } + this._pickedTime = 0; + } + break; + } + } else { + renderer.isPickingEnabled = false; + this._pickedTime = 0; + } + } else { + this._core.renderer.isPickingEnabled = false; + this._pickedTime = 0; } } - return indices; - } - textured(slices, stacks, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { - const positions = this.positions(slices, stacks, transform); - const texCoords = this._texCoords(slices, stacks, texTransform); - const vertices = new ArrayBuffer((0, _vertexJs.PositionTextureVertex).SIZE_BYTES * positions.length / 3); - const verticesView = new DataView(vertices); - const position = (0, _glMatrix.vec3).create(); - const texCoord = (0, _glMatrix.vec2).create(); - for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ - (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); - (0, _vertexJs.PositionTextureVertex).setPosition(verticesView, i, position); - (0, _vertexJs.PositionTextureVertex).setTexCoord(verticesView, i, texCoord); - } - return verticesView; - } - normalTextured(slices, stacks, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { - const positions = this.positions(slices, stacks, transform); - const texCoords = this._texCoords(slices, stacks, texTransform); - const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * positions.length / 3); - const verticesView = new DataView(vertices); - const position = (0, _glMatrix.vec3).create(); - const texCoord = (0, _glMatrix.vec2).create(); - const normal = (0, _glMatrix.vec3).create(); - for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ - (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); - (0, _vertexJs.PositionNormalTextureVertex).setPosition(verticesView, i, position); - (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(verticesView, i, texCoord); - (0, _glMatrix.vec3).set(normal, position[0] - transform[12], position[1] - transform[13], position[2] - transform[14]); - (0, _glMatrix.vec3).normalize(normal, normal); - (0, _vertexJs.PositionNormalTextureVertex).setNormal(verticesView, i, normal); - } - return verticesView; - } - _texCoords(slices, stacks, transform) { - const texCoords = new Float32Array((slices + 1) * (stacks + 1) * 2); - const texCoord = (0, _glMatrix.vec2).create(); - let index = 0; - for(let stack = 0; stack <= stacks; stack++)for(let slice = 0; slice <= slices; slice++){ - (0, _glMatrix.vec2).set(texCoord, slice / slices, stack / stacks); - (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, transform); - texCoords[index++] = texCoord[0]; - texCoords[index++] = texCoord[1]; + if (this._core.config.isDebugVisible) { + this._core.debugText.addLine(`man tot ${this._manipulationProcessor.count}`); + this._core.debugText.addLine(`pck key ${this._core.renderer.pickedId}`); } - return texCoords; } } -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/angle.js":"eKtPm","../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"21hIN":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "KeyVisual", ()=>KeyVisual); -parcelHelpers.export(exports, "KeyBase", ()=>KeyBase); -parcelHelpers.export(exports, "NominalKey", ()=>NominalKey); +},{"gl-matrix":"5x28d","../main.js":"f421K","./manipulationprocessor.js":"20HDq","./mousewheel.js":"dfHmP","./pointers.js":"7LFJO","../helpers/animation.js":"02nn8","../constants.js":"lD0bG","./keyboard.js":"fXys0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"20HDq":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -var _textJs = require("../helpers/text.js"); -var _scatterJs = require("../layouts/scatter.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ManipulationProcessor", ()=>ManipulationProcessor); +var _glMatrix = require("gl-matrix"); var _mathJs = require("../helpers/math.js"); -var _labelsJs = require("./labels.js"); -class KeyVisual { - render(elapsedTime, xrFrame) {} - update(elapsedTime) {} - constructor(key){ - this.key = key; - } -} -class KeyBase { - get isInitialized() { - return this._isInitialized; +var _angleJs = require("../helpers/angle.js"); +class ManipulationProcessor { + get manipulators() { + return this._manipulators; } - get minBoundsX() { - return this._minBoundsX; + get count() { + return this._count; } - set minBoundsX(value) { - if (value != this.minBoundsX) { - this._minBoundsX = value; - this._hasChanged = true; - } + get isDragging() { + return this._isDragging; } - get maxBoundsX() { - return this._maxBoundsX; + constructor(core){ + this._core = core; + this._count = 0; + this._centroid = (0, _glMatrix.vec3).create(); + this._previousCentroid = (0, _glMatrix.vec3).create(); + this._relativePositionToCentroid = (0, _glMatrix.vec3).create(); + this._directionToCentroid = (0, _glMatrix.vec3).create(); + this._previousDirectionToCentroid = (0, _glMatrix.vec3).create(); + this._manipulators = {}; + this._removedManipulators = []; + this.cumulativeTranslation = (0, _glMatrix.vec3).create(); + this.translationDelta = (0, _glMatrix.vec3).create(); + this.centroid = (0, _glMatrix.vec3).create(); + this.maxScale = Number.MAX_VALUE; + this.twistAxis = (0, _glMatrix.vec3).fromValues(0, 0, 1); + this.initialize(); } - set maxBoundsX(value) { - if (value != this.minBoundsX) { - this._maxBoundsX = value; - this._hasChanged = true; + update(elapsedTime, manipulators) { + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + if (!manipulators[manipulator.id]) { + if (this.removeManipulator) this.removeManipulator(manipulator); + this._removedManipulators.push(manipulator.id); + } } - } - get minBoundsY() { - return this._minBoundsY; - } - set minBoundsY(value) { - if (value != this.minBoundsY) { - this._minBoundsY = value; - this._hasChanged = true; + if (this._removedManipulators.length > 0) { + for(let i = 0; i < this._removedManipulators.length; i++){ + delete this._manipulators[this._removedManipulators[i]]; + this._count--; + } + this._removedManipulators = []; } - } - get maxBoundsY() { - return this._maxBoundsY; - } - set maxBoundsY(value) { - if (value != this.minBoundsY) { - this._maxBoundsY = value; - this._hasChanged = true; + for(const key in manipulators){ + const manipulator = manipulators[key]; + if (!this._manipulators[manipulator.id]) { + if (!this.addManipulator || this.addManipulator(manipulator)) { + (0, _glMatrix.vec3).copy(manipulator.initialPosition, manipulator.position); + this._manipulators[manipulator.id] = manipulator; + this._count++; + } + } } - } - get minBoundsZ() { - return this._minBoundsZ; - } - set minBoundsZ(value) { - if (value != this.minBoundsZ) { - this._minBoundsZ = value; - this._hasChanged = true; + (0, _glMatrix.vec3).set(this.translationDelta, 0, 0, 0); + this.scaleDelta = 0; + this.twistDelta = 0; + if (this._count > 0) { + if (this._previousCount > 0) { + if (this.prepareManipulation) this.prepareManipulation(); + this._process(); + if (this.processManipulation) this.processManipulation(elapsedTime); + } else { + this.initialize(); + if (this.beginManipulation) this.beginManipulation(); + } + } else { + if (this._previousCount > 0) { + if (this.endManipulation) this.endManipulation(); + } } + this._isDragging = this._count == 1 && (0, _glMatrix.vec3).squaredLength(this.cumulativeTranslation) > this._core.config.dragToleranceSquared || this._count > 1; + this._previousCount = this._count; } - get maxBoundsZ() { - return this._maxBoundsZ; + initialize() { + (0, _glMatrix.vec3).set(this.centroid, 0, 0, 0); + (0, _glMatrix.vec3).set(this.cumulativeTranslation, 0, 0, 0); + this.cumulativeScale = 1; + this.cumulativeTwist = 0; } - set maxBoundsZ(value) { - if (value != this.minBoundsZ) { - this._maxBoundsZ = value; - this._hasChanged = true; + _process() { + if (this._previousCount > 0) { + let persisted = 0; + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + if (manipulator.isPersisted) persisted++; + } + const removed = this._previousCount - persisted; + if (persisted > 0) { + if (removed > 0) (0, _glMatrix.vec3).copy(this._centroid, this._previousCentroid); + else { + (0, _glMatrix.vec3).set(this._centroid, 0, 0, 0); + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + if (manipulator.isPersisted) (0, _glMatrix.vec3).add(this._centroid, this._centroid, manipulator.position); + } + (0, _glMatrix.vec3).scale(this._centroid, this._centroid, 1 / persisted); + } + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + if (manipulator.isPersisted) { + manipulator.maxTranslationSquared = Math.max(manipulator.maxTranslationSquared, (0, _glMatrix.vec3).squaredDistance(manipulator.position, manipulator.initialPosition)); + (0, _glMatrix.vec3).add(this.translationDelta, this.translationDelta, manipulator.position); + (0, _glMatrix.vec3).subtract(this.translationDelta, this.translationDelta, manipulator.previousPosition); + (0, _glMatrix.vec3).subtract(this._relativePositionToCentroid, manipulator.position, this._centroid); + const distanceToCentroidSquared = (0, _glMatrix.vec3).squaredLength(this._relativePositionToCentroid); + if (distanceToCentroidSquared < this._core.config.manipulatorMinRelativeDistanceSquared) this.scaleDelta += 1; + else { + const distanceToCentroid = Math.sqrt(distanceToCentroidSquared); + const previousDistanceToCentroidSquared = (0, _glMatrix.vec3).squaredLength(manipulator.previousPositionRelativeToCentroid); + const previousDistanceToCentroid = Math.sqrt(previousDistanceToCentroidSquared); + this.scaleDelta += distanceToCentroid / previousDistanceToCentroid; + (0, _glMatrix.vec3).scale(this._directionToCentroid, this._relativePositionToCentroid, 1 / distanceToCentroid); + (0, _glMatrix.vec3).scale(this._previousDirectionToCentroid, manipulator.previousPositionRelativeToCentroid, 1 / previousDistanceToCentroid); + this.twistDelta += (0, _angleJs.AngleHelper).signedAngleBetweenVectors(this._previousDirectionToCentroid, this._directionToCentroid, this.twistAxis); + } + } + } + (0, _glMatrix.vec3).scale(this.translationDelta, this.translationDelta, 1 / persisted); + (0, _glMatrix.vec3).add(this.cumulativeTranslation, this.cumulativeTranslation, this.translationDelta); + this.scaleDelta /= persisted; + this.cumulativeScale = (0, _mathJs.MathHelper).clamp(this.cumulativeScale * this.scaleDelta, this.minScale, this.maxScale); + this.scaleDelta -= 1; + this.twistDelta /= persisted; + this.cumulativeTwist += this.twistDelta; + } } - } - get unitType() { - return this._unitType; - } - set unitType(value) { - if (this._unitType != value) { - this._unitType = value; - this._hasChanged = true; + (0, _glMatrix.vec3).set(this.centroid, 0, 0, 0); + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + (0, _glMatrix.vec3).add(this.centroid, this.centroid, manipulator.position); } - } - get palette() { - return this._palette; - } - set palette(value) { - if (this._palette != value) { - this._palette = value; - this._hasChanged = true; + (0, _glMatrix.vec3).scale(this.centroid, this.centroid, 1 / this._count); + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + (0, _glMatrix.vec3).subtract(manipulator.positionRelativeToCentroid, manipulator.position, this.centroid); } - } - get materials() { - return this._materials; - } - set materials(value) { - if (this._materials != value) { - this._materials = value; - this._hasChanged = true; + (0, _glMatrix.vec3).copy(this._previousCentroid, this.centroid); + for(const key in this._manipulators){ + const manipulator = this._manipulators[key]; + manipulator.isPersisted = true; + (0, _glMatrix.vec3).copy(manipulator.previousPosition, manipulator.position); + (0, _glMatrix.vec3).copy(manipulator.previousRotationAxis, manipulator.rotationAxis); + (0, _glMatrix.vec3).copy(manipulator.previousPositionRelativeToCentroid, manipulator.positionRelativeToCentroid); } } - get sizesX() { - return this._sizesX; - } - set sizesX(value) { - if (this._sizesX != value) { - this._sizesX = value; - this._hasChanged = true; - } +} + +},{"gl-matrix":"5x28d","../helpers/math.js":"f65d0","../helpers/angle.js":"53hwW","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dfHmP":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "MouseWheel", ()=>MouseWheel); +class MouseWheel { + constructor(core){ + this._core = core; + this._previousTotal = 0; + this.total = 0; } - get sizesY() { - return this._sizesY; + initialize(element) { + element.addEventListener("wheel", (e)=>{ + e.preventDefault(); + const wheelEvent = e; + this.total += wheelEvent.deltaY; + }, { + passive: false + }); } - set sizesY(value) { - if (this._sizesY != value) { - this._sizesY = value; - this._hasChanged = true; - } + update(elapsedTime) { + const total = this.total; + this.delta = total - this._previousTotal; + this._previousTotal = total; + if (this._core.config.isDebugVisible) this._core.debugText.addLine(`mse whl ${this.total < 0 ? "" : " "}${Math.round(this.total)}`); } - get sizesZ() { - return this._sizesZ; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7LFJO":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Pointers", ()=>Pointers); +var _manipulatorJs = require("../input/manipulator.js"); +class Pointers { + get hoverX() { + return this._hoverX; } - set sizesZ(value) { - if (this._sizesZ != value) { - this._sizesZ = value; - this._hasChanged = true; - } + get hoverY() { + return this._hoverY; } - get spacing() { - return this._spacing; + get hoverId() { + return this._hoverId; } - set spacing(value) { - if (this._spacing != value) { - this._spacing = value; - this._hasChanged = true; - } + constructor(core, manipulators){ + this._core = core; + this._manipulators = manipulators; } - get textVertices() { - return this._textVertices; + initialize(element) { + this._element = element; + element.addEventListener("pointerdown", (e)=>this._handlePointerDown(e), { + passive: true + }); + element.addEventListener("pointermove", (e)=>this._handlePointerMove(e), { + passive: true + }); + element.addEventListener("pointerup", (e)=>this._handlePointerUp(e), { + passive: true + }); + element.addEventListener("pointercancel", (e)=>this._handlePointerCancel(e), { + passive: true + }); + element.addEventListener("pointerleave", (e)=>this._handlePointerLeave(e), { + passive: true + }); + element.addEventListener("pointerout", (e)=>this._handlePointerOut(e), { + passive: true + }); } - get textIndices() { - return this._textIndices; + update(elapsedTime) { + if (this._core.config.isDebugVisible) { + this._core.debugText.addLine(`pen rot ${(this._tiltX | 0).toFixed(3)},${(this._tiltY | 0).toFixed(3)},${(this._twist | 0).toFixed(3)}`); + this._core.debugText.addLine(`hov pos ${this.hoverX ? `${this.hoverX.toFixed(3)},${this.hoverY.toFixed(3)}px` : ""}`); + } } - get labelMMatrix() { - return this._labelMMatrix; + _handlePointerDown(e) { + this._element.focus(); + const devicePixelRatio = this._core.renderer.devicePixelRatio; + const manipulator = new (0, _manipulatorJs.Manipulator)(); + const id = e.pointerId; + const x = e.offsetX * devicePixelRatio; + const y = e.offsetY * devicePixelRatio; + manipulator.id = id; + manipulator.position[0] = x; + manipulator.position[1] = y; + manipulator.type = e.pointerType; + manipulator.button = e.button; + manipulator.shiftKey = e.shiftKey; + manipulator.ctrlKey = e.ctrlKey; + manipulator.altKey = e.altKey; + manipulator.event = e; + this._manipulators[id] = manipulator; + this._hoverId = id; + this._hoverX = x; + this._hoverY = y; } - set labelPositions(value) { - if (this._labelPositions != value) { - this._labelPositions = value; - this._hasChanged = true; + _handlePointerMove(e) { + const devicePixelRatio = this._core.renderer.devicePixelRatio; + const x = e.offsetX * devicePixelRatio; + const y = e.offsetY * devicePixelRatio; + const id = e.pointerId; + const manipulator = this._manipulators[id]; + if (manipulator) { + manipulator.position[0] = x; + manipulator.position[1] = y; + manipulator.event = e; } - } - set labels(value) { - if (this._labels != value) { - this._labels = value; - this._hasChanged = true; + switch(e.pointerType){ + case "mouse": + this._hoverId = id; + this._hoverX = x; + this._hoverY = y; + break; + case "pen": + this._hoverId = id; + this._hoverX = x; + this._hoverY = y; + this._tiltX = e.tiltX; + this._tiltY = e.tiltY; + this._twist = e.twist; + break; } } - set labelSize(value) { - if (this._labelSize != value) { - this._labelSize = value; - this._hasChanged = true; - } + _handlePointerUp(e) { + const manipulator = this._manipulators[e.pointerId]; + if (manipulator) manipulator.event = e; + this._remove(e.pointerId); } - get labelOrientation() { - return this._orientation; + _handlePointerCancel(e) { + this._remove(e.pointerId); } - set labelOrientation(value) { - if (this._orientation != value) { - this._orientation = value; - this._hasChanged = true; - } + _handlePointerLeave(e) { + this._resetHover(); + this._remove(e.pointerId); } - get titleIndexCount() { - return this._titleIndexCount; + _handlePointerOut(e) { + this._resetHover(); + this._remove(e.pointerId); } - get titleIndexOffset() { - return this._titleIndexOffset; + _resetHover() { + this._hoverId = null; + this._hoverX = null; + this._hoverY = null; } - get titleMMatrix() { - return this._titleMMatrix; + _remove(pointerId) { + const manipulator = this._manipulators[pointerId]; + if (manipulator) delete this._manipulators[pointerId]; } - set title(value) { - if (this._title != value) { - this._title = value; - this._hasChanged = true; - } +} + +},{"../input/manipulator.js":"bYqKJ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bYqKJ":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Manipulator", ()=>Manipulator); +var _glMatrix = require("gl-matrix"); +class Manipulator { + constructor(){ + this.pickedIndex = 0; + this.maxTranslationSquared = 0; + this.initialPosition = (0, _glMatrix.vec3).create(); + this.position = (0, _glMatrix.vec3).create(); + this.previousPosition = (0, _glMatrix.vec3).create(); + this.holdOrigin = (0, _glMatrix.vec3).create(); + this.positionRelativeToCentroid = (0, _glMatrix.vec3).create(); + this.previousPositionRelativeToCentroid = (0, _glMatrix.vec3).create(); + this.rotationAxis = (0, _glMatrix.vec3).create(); + this.previousRotationAxis = (0, _glMatrix.vec3).create(); } - set titleSize(value) { - if (this._titleSize != value) { - this._titleSize = value; - this._hasChanged = true; - } +} + +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"02nn8":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AnimationHelper", ()=>AnimationHelper); +var _mathJs = require("./math.js"); +class AnimationHelper { + static smoothStep(value) { + return value * value * (3 - 2 * value); } - constructor(core, options){ + static damp(value, target, threshold, dampening) { + if (Math.abs(target) < threshold) return (0, _mathJs.MathHelper).lerp(value, 0, dampening); + else return (0, _mathJs.MathHelper).lerp(value, target, dampening); + } +} + +},{"./math.js":"f65d0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fXys0":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Keyboard", ()=>Keyboard); +class Keyboard { + constructor(core){ this._core = core; - this._textMetric = { - width: 0, - maxHeight: 0, - maxTop: 0 - }; + this._pressedKeys = new Set(); + this._previousPressedKeys = new Set(); } - initialize() { - this._isInitialized = true; + initialize(element) { + element.addEventListener("keydown", (e)=>{ + this._handleKeyDown(e); + }, false); + element.addEventListener("keyup", (e)=>{ + this._handleKeyUp(e); + }, false); } update(elapsedTime) { - if (this.isInitialized) { - if (this._hasChanged) { - const start = window.performance.now(); - this._hasChanged = false; - (0, _glMatrix.vec3).set(this._size, this._maxBoundsX - this._minBoundsX, this._maxBoundsY - this._minBoundsY, this._maxBoundsZ - this._minBoundsZ); - const maxBounds = Math.max(Math.max(this._size[0], this._size[1]), this._size[2]); - (0, _glMatrix.vec3).scale(this._size, this._size, 1 / maxBounds); - this._update(this._size); - if (this.hasChangedCallback) this.hasChangedCallback(); - this._core.log.write((0, _mainJs.LogLevel).info, `key updated ${Math.round(window.performance.now() - start)}ms`); + if (this._core.config.isDebugVisible) this._core.debugText.addLine(`key tot ${this._pressedKeys.size}`); + } + isKeyDown(key) { + return this._pressedKeys.has(key); + } + wasKeyReleased(key) { + if (this._pressedKeys.has(key)) { + if (!this._previousPressedKeys.has(key)) { + this._previousPressedKeys.add(key); + return true; } - } + } else this._previousPressedKeys.delete(key); + return false; + } + _handleKeyDown(e) { + const keyboardEvent = e; + const key = keyboardEvent.key; + if (!this._pressedKeys.has(key)) this._pressedKeys.add(key); + } + _handleKeyUp(e) { + const keyboardEvent = e; + const key = keyboardEvent.key; + if (this._pressedKeys.has(key)) this._pressedKeys.delete(key); } - _update(size) {} } -class NominalKey extends KeyBase { - constructor(core, options){ - super(core, options); - const minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; - const minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; - const minBoundsZ = options.minBoundsZ === undefined ? 0 : options.minBoundsZ; - const maxBoundsX = options.maxBoundsX === undefined ? 0 : options.maxBoundsX; - const maxBoundsY = options.maxBoundsY === undefined ? 0 : options.maxBoundsY; - const maxBoundsZ = options.maxBoundsZ === undefined ? 0 : options.maxBoundsZ; - const positionX = options.positionX === undefined ? 0 : options.positionX; - const positionY = options.positionY === undefined ? 0 : options.positionY; - const positionZ = options.positionZ === undefined ? 0 : options.positionZ; - const sizeX = options.sizeX === undefined ? 1 : options.sizeX; - const sizeY = options.sizeY === undefined ? 1 : options.sizeY; - const sizeZ = options.sizeZ === undefined ? 1 : options.sizeZ; - const spacing = options.spacing === undefined ? 1 : options.spacing; - const labelScale = options.labelScale === undefined ? 1 : options.labelScale; - const labelMaxGlyphs = options.labelMaxGlyphs === undefined ? this._core.config.keyLabelMaxGlyphs : options.labelMaxGlyphs; - const titleScale = options.titleScale === undefined ? 1 : options.titleScale; - const titleMaxGlyphs = options.titleMaxGlyphs === undefined ? this._core.config.keyTitleMaxGlyphs : options.titleMaxGlyphs; - const font = options.font ? options.font : this._core.font; - const horizontalAlignment = options.horizontalAlignment === undefined ? (0, _mainJs.HorizontalAlignment).center : options.horizontalAlignment; - const verticalAlignment = options.verticalAlignment === undefined ? (0, _mainJs.VerticalAlignment).center : options.verticalAlignment; - const orientation = options.orientation === undefined ? (0, _mainJs.Orientation).horizontal : options.orientation; - const labelPosition = options.labelPosition === undefined ? (0, _mainJs.Edge2D).right : options.labelPosition; - const labelOrientation = options.labelOrientation === undefined ? (0, _mainJs.Orientation).horizontal : options.labelOrientation; - const rotation = (0, _glMatrix.quat).create(); - let count = options.values.length; - const ids = new Uint32Array(count); - let minValue = Number.MAX_VALUE; - let maxValue = -Number.MAX_VALUE; - for(let i = 0; i < count; i++){ - ids[i] = i; - const value = options.values[i]; - minValue = Math.min(minValue, value); - maxValue = Math.max(maxValue, value); - } - const materialIds = new Uint32Array(count); - for(let i1 = 0; i1 < count; i1++)materialIds[i1] = (0, _mathJs.MathHelper).normalize(options.values[i1], minValue, maxValue, 0, options.palette.length / 4 - 1); - let glyphCount = 0; - let totalLabelWidth = 0; - let maxLabelWidth = 0; - for(let i2 = 0; i2 < count; i2++){ - const label = (0, _textJs.TextHelper).truncate(options.labels[i2], labelMaxGlyphs); - glyphCount += label.length; - (0, _textJs.TextHelper).measure(font, label, this._textMetric); - const width = this._textMetric.width; - totalLabelWidth += width; - maxLabelWidth = Math.max(width, maxLabelWidth); - } - let titleWidth = 0; - let title; - if (options.title) { - title = (0, _textJs.TextHelper).truncate(options.title, titleMaxGlyphs); - glyphCount += title.length; - (0, _textJs.TextHelper).measure(font, title, this._textMetric); - titleWidth = this._textMetric.width; - } - let width1; - let height; - switch(orientation){ - case (0, _mainJs.Orientation).horizontal: - switch(labelPosition){ - case (0, _mainJs.Edge2D).bottom: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - case (0, _mainJs.Edge2D).left: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - case (0, _mainJs.Edge2D).right: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - case (0, _mainJs.Edge2D).top: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - } - break; - case (0, _mainJs.Orientation).vertical: - switch(labelPosition){ - case (0, _mainJs.Edge2D).bottom: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - case (0, _mainJs.Edge2D).left: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - case (0, _mainJs.Edge2D).right: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - case (0, _mainJs.Edge2D).top: - switch(labelOrientation){ - case (0, _mainJs.Orientation).horizontal: - break; - case (0, _mainJs.Orientation).vertical: - break; - } - break; - } - break; - } - switch(orientation){ - case (0, _mainJs.Orientation).horizontal: - width1 = Math.max(sizeX * count + spacing * (count - 1) + totalLabelWidth, titleWidth); - height = sizeY; - if (options.title) height += titleScale; - break; - case (0, _mainJs.Orientation).vertical: - width1 = Math.max(sizeX + labelScale / 2 + maxLabelWidth, titleWidth); - height = sizeY * count + spacing * (count - 1); - if (options.title) height += titleScale; - break; - } - let originX = positionX; - let originY = positionY; - let originZ = positionZ; - switch(horizontalAlignment){ - case (0, _mainJs.HorizontalAlignment).center: - break; - case (0, _mainJs.HorizontalAlignment).left: - originX += width1 / 2; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"c6yiP":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Log", ()=>Log); +var _mainJs = require("./main.js"); +class Log { + constructor(core){ + this._core = core; + } + write(level, value) { + if (level >= this._core.config.logLevel) switch(level){ + case (0, _mainJs.LogLevel).trace: + console.trace(value); break; - case (0, _mainJs.HorizontalAlignment).right: - originX -= width1 / 2; + case (0, _mainJs.LogLevel).debug: + console.debug(value); break; - } - switch(verticalAlignment){ - case (0, _mainJs.VerticalAlignment).bottom: - originY += height / 2; + case (0, _mainJs.LogLevel).info: + console.info(value); break; - case (0, _mainJs.VerticalAlignment).center: + case (0, _mainJs.LogLevel).warn: + console.warn(value); break; - case (0, _mainJs.VerticalAlignment).top: - originY -= height / 2; + case (0, _mainJs.LogLevel).error: + console.error(value); break; } - const positionsX = new Float64Array(count); - const positionsY = new Float64Array(count); - const positionsZ = new Float64Array(count); - for(let i3 = 0; i3 < count; i3++){ - positionsX[i3] = originX - width1 / 2 + sizeX / 2; - positionsY[i3] = originY + height / 2 - i3 * (sizeY + spacing); - positionsZ[i3] = originZ + sizeZ / 2; - } - const scatter = new (0, _scatterJs.Scatter)(this._core); - const scatterLayoutOptions = { - positionsX: positionsX, - positionsY: positionsY, - positionsZ: positionsZ - }; - scatter.layout(this._transitionBuffer.currentBuffer, ids, scatterLayoutOptions); - const scatterVertexOptions = { - minBoundsX: minBoundsX, - minBoundsY: minBoundsY, - minBoundsZ: minBoundsZ, - maxBoundsX: maxBoundsX, - maxBoundsY: maxBoundsY, - maxBoundsZ: maxBoundsZ, - colors: options.values, - minColor: minValue, - maxColor: maxValue, - sizeScalingX: sizeX, - sizeScalingY: sizeY, - sizeScalingZ: sizeZ, - materials: materialIds - }; - scatter.update(this._transitionBuffer.currentBuffer, ids, scatterVertexOptions); - const labelSetOptions = { - text: options.labels, - maxGlyphs: glyphCount, - scale: labelScale, - font: font - }; - const labelSet = new (0, _labelsJs.LabelSet)(this._core, labelSetOptions); - if (options.title) count++; - const labelPositionsX = new Float64Array(count); - const labelPositionsY = new Float64Array(count); - const labelPositionsZ = new Float64Array(count); - for(let i4 = 0; i4 < (options.title ? count - 1 : count); i4++){ - labelPositionsX[i4] = originX - width1 / 2 + sizeX + labelScale / 2; - labelPositionsY[i4] = positionsY[i4]; - labelPositionsZ[i4] = originZ; - } - options.title; - labelSet.minBoundsX = minBoundsX; - labelSet.minBoundsY = minBoundsY; - labelSet.minBoundsZ = minBoundsZ; - labelSet.maxBoundsX = maxBoundsX; - labelSet.maxBoundsY = maxBoundsY; - labelSet.maxBoundsZ = maxBoundsZ; - labelSet.positionsX = positionsX; - labelSet.positionsY = positionsY; - labelSet.positionsZ = positionsZ; - labelSet.rotation = new Float64Array([ - rotation[0], - rotation[1], - rotation[2], - rotation[3] - ]); - labelSet.horizontalAlignment = (0, _mainJs.HorizontalAlignment).left; } } -},{"gl-matrix":"9GjEQ","../main.js":"1Kju3","../helpers/text.js":"l2V9O","../layouts/scatter.js":"i5SiV","../helpers/math.js":"fOnPF","./labels.js":"4IFc8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i5SiV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cYEeU":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Scatter", ()=>Scatter); +parcelHelpers.export(exports, "Colors", ()=>Colors); +var _glMatrix = require("gl-matrix"); +class Colors { +} +Colors.MediumVioletRed = (0, _glMatrix.vec3).fromValues(0xc7, 0x15, 0x85); +Colors.DeepPink = (0, _glMatrix.vec3).fromValues(0xff, 0x14, 0x93); +Colors.PaleVioletRed = (0, _glMatrix.vec3).fromValues(0xdb, 0x70, 0x93); +Colors.HotPink = (0, _glMatrix.vec3).fromValues(0xff, 0x69, 0xb4); +Colors.LightPink = (0, _glMatrix.vec3).fromValues(0xff, 0xb6, 0xc1); +Colors.Pink = (0, _glMatrix.vec3).fromValues(0xff, 0xc0, 0xcb); +Colors.DarkRed = (0, _glMatrix.vec3).fromValues(0x8b, 0x00, 0x00); +Colors.Red = (0, _glMatrix.vec3).fromValues(0xff, 0x00, 0x00); +Colors.Firebrick = (0, _glMatrix.vec3).fromValues(0xb2, 0x22, 0x22); +Colors.Crimson = (0, _glMatrix.vec3).fromValues(0xdc, 0x14, 0x3c); +Colors.IndianRed = (0, _glMatrix.vec3).fromValues(0xcd, 0x5c, 0x5c); +Colors.LightCoral = (0, _glMatrix.vec3).fromValues(0xf0, 0x80, 0x80); +Colors.Salmon = (0, _glMatrix.vec3).fromValues(0xfa, 0x80, 0x72); +Colors.DarkSalmon = (0, _glMatrix.vec3).fromValues(0xe9, 0x96, 0x7a); +Colors.LightSalmon = (0, _glMatrix.vec3).fromValues(0xff, 0xa0, 0x7a); +Colors.OrangeRed = (0, _glMatrix.vec3).fromValues(0xff, 0x45, 0x00); +Colors.Tomato = (0, _glMatrix.vec3).fromValues(0xff, 0x63, 0x47); +Colors.DarkOrange = (0, _glMatrix.vec3).fromValues(0xff, 0x8c, 0x00); +Colors.Coral = (0, _glMatrix.vec3).fromValues(0xff, 0x7f, 0x50); +Colors.Orange = (0, _glMatrix.vec3).fromValues(0xff, 0xa5, 0x00); +Colors.DarkKhaki = (0, _glMatrix.vec3).fromValues(0xbd, 0xb7, 0x6b); +Colors.Gold = (0, _glMatrix.vec3).fromValues(0xff, 0xd7, 0x00); +Colors.Khaki = (0, _glMatrix.vec3).fromValues(0xf0, 0xe6, 0x8c); +Colors.PeachPuff = (0, _glMatrix.vec3).fromValues(0xff, 0xda, 0xb9); +Colors.Yellow = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0x00); +Colors.PaleGoldenrod = (0, _glMatrix.vec3).fromValues(0xee, 0xe8, 0xaa); +Colors.Moccasin = (0, _glMatrix.vec3).fromValues(0xff, 0xe4, 0xb5); +Colors.PapayaWhip = (0, _glMatrix.vec3).fromValues(0xff, 0xef, 0xd5); +Colors.LightGoldenrodYellow = (0, _glMatrix.vec3).fromValues(0xfa, 0xfa, 0xd2); +Colors.LemonChiffon = (0, _glMatrix.vec3).fromValues(0xff, 0xfa, 0xcd); +Colors.LightYellow = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0xe0); +Colors.Maroon = (0, _glMatrix.vec3).fromValues(0x80, 0x00, 0x00); +Colors.Brown = (0, _glMatrix.vec3).fromValues(0xa5, 0x2a, 0x2a); +Colors.SaddleBrown = (0, _glMatrix.vec3).fromValues(0x8b, 0x45, 0x13); +Colors.Sienna = (0, _glMatrix.vec3).fromValues(0xa0, 0x52, 0x2d); +Colors.Chocolate = (0, _glMatrix.vec3).fromValues(0xd2, 0x69, 0x1e); +Colors.DarkGoldenrod = (0, _glMatrix.vec3).fromValues(0xb8, 0x86, 0x0b); +Colors.Peru = (0, _glMatrix.vec3).fromValues(0xcd, 0x85, 0x3f); +Colors.RosyBrown = (0, _glMatrix.vec3).fromValues(0xbc, 0x8f, 0x8f); +Colors.Goldenrod = (0, _glMatrix.vec3).fromValues(0xda, 0xa5, 0x20); +Colors.SandyBrown = (0, _glMatrix.vec3).fromValues(0xf4, 0xa4, 0x60); +Colors.Tan = (0, _glMatrix.vec3).fromValues(0xd2, 0xb4, 0x8c); +Colors.Burlywood = (0, _glMatrix.vec3).fromValues(0xde, 0xb8, 0x87); +Colors.Wheat = (0, _glMatrix.vec3).fromValues(0xf5, 0xde, 0xb3); +Colors.NavajoWhite = (0, _glMatrix.vec3).fromValues(0xff, 0xde, 0xad); +Colors.Bisque = (0, _glMatrix.vec3).fromValues(0xff, 0xe4, 0xc4); +Colors.BlanchedAlmond = (0, _glMatrix.vec3).fromValues(0xff, 0xeb, 0xcd); +Colors.Cornsilk = (0, _glMatrix.vec3).fromValues(0xff, 0xf8, 0xdc); +Colors.DarkGreen = (0, _glMatrix.vec3).fromValues(0x00, 0x64, 0x00); +Colors.Green = (0, _glMatrix.vec3).fromValues(0x00, 0x80, 0x00); +Colors.DarkOliveGreen = (0, _glMatrix.vec3).fromValues(0x55, 0x6b, 0x2f); +Colors.ForestGreen = (0, _glMatrix.vec3).fromValues(0x22, 0x8b, 0x22); +Colors.SeaGreen = (0, _glMatrix.vec3).fromValues(0x2e, 0x8b, 0x57); +Colors.Olive = (0, _glMatrix.vec3).fromValues(0x80, 0x80, 0x00); +Colors.OliveDrab = (0, _glMatrix.vec3).fromValues(0x6b, 0x8e, 0x23); +Colors.MediumSeaGreen = (0, _glMatrix.vec3).fromValues(0x3c, 0xb3, 0x71); +Colors.LimeGreen = (0, _glMatrix.vec3).fromValues(0x32, 0xcd, 0x32); +Colors.Lime = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0x00); +Colors.SpringGreen = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0x7f); +Colors.MediumSpringGreen = (0, _glMatrix.vec3).fromValues(0x00, 0xfa, 0x9a); +Colors.DarkSeaGreen = (0, _glMatrix.vec3).fromValues(0x8f, 0xbc, 0x8f); +Colors.MediumAquamarine = (0, _glMatrix.vec3).fromValues(0x66, 0xcd, 0xaa); +Colors.YellowGreen = (0, _glMatrix.vec3).fromValues(0x9a, 0xcd, 0x32); +Colors.LawnGreen = (0, _glMatrix.vec3).fromValues(0x7c, 0xfc, 0x00); +Colors.Chartreuse = (0, _glMatrix.vec3).fromValues(0x7f, 0xff, 0x00); +Colors.LightGreen = (0, _glMatrix.vec3).fromValues(0x90, 0xee, 0x90); +Colors.GreenYellow = (0, _glMatrix.vec3).fromValues(0xad, 0xff, 0x2f); +Colors.PaleGreen = (0, _glMatrix.vec3).fromValues(0x98, 0xfb, 0x98); +Colors.Teal = (0, _glMatrix.vec3).fromValues(0x00, 0x80, 0x80); +Colors.DarkCyan = (0, _glMatrix.vec3).fromValues(0x00, 0x8b, 0x8b); +Colors.LightSeaGreen = (0, _glMatrix.vec3).fromValues(0x20, 0xb2, 0xaa); +Colors.CadetBlue = (0, _glMatrix.vec3).fromValues(0x5f, 0x9e, 0xa0); +Colors.DarkTurquoise = (0, _glMatrix.vec3).fromValues(0x00, 0xce, 0xd1); +Colors.MediumTurquoise = (0, _glMatrix.vec3).fromValues(0x48, 0xd1, 0xcc); +Colors.Turquoise = (0, _glMatrix.vec3).fromValues(0x40, 0xe0, 0xd0); +Colors.Aqua = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0xff); +Colors.Cyan = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0xff); +Colors.Aquamarine = (0, _glMatrix.vec3).fromValues(0x7f, 0xff, 0xd4); +Colors.PaleTurquoise = (0, _glMatrix.vec3).fromValues(0xaf, 0xee, 0xee); +Colors.LightCyan = (0, _glMatrix.vec3).fromValues(0xe0, 0xff, 0xff); +Colors.Navy = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0x80); +Colors.DarkBlue = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0x8b); +Colors.MediumBlue = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0xcd); +Colors.Blue = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0xff); +Colors.MidnightBlue = (0, _glMatrix.vec3).fromValues(0x19, 0x19, 0x70); +Colors.RoyalBlue = (0, _glMatrix.vec3).fromValues(0x41, 0x69, 0xe1); +Colors.SteelBlue = (0, _glMatrix.vec3).fromValues(0x46, 0x82, 0xb4); +Colors.DodgerBlue = (0, _glMatrix.vec3).fromValues(0x1e, 0x90, 0xff); +Colors.DeepSkyBlue = (0, _glMatrix.vec3).fromValues(0x00, 0xbf, 0xff); +Colors.CornflowerBlue = (0, _glMatrix.vec3).fromValues(0x64, 0x95, 0xed); +Colors.SkyBlue = (0, _glMatrix.vec3).fromValues(0x87, 0xce, 0xeb); +Colors.LightSkyBlue = (0, _glMatrix.vec3).fromValues(0x87, 0xce, 0xfa); +Colors.LightSteelBlue = (0, _glMatrix.vec3).fromValues(0xb0, 0xc4, 0xde); +Colors.LightBlue = (0, _glMatrix.vec3).fromValues(0xad, 0xd8, 0xe6); +Colors.PowderBlue = (0, _glMatrix.vec3).fromValues(0xb0, 0xe0, 0xe6); +Colors.Indigo = (0, _glMatrix.vec3).fromValues(0x4b, 0x00, 0x82); +Colors.Purple = (0, _glMatrix.vec3).fromValues(0x80, 0x00, 0x80); +Colors.DarkMagenta = (0, _glMatrix.vec3).fromValues(0x8b, 0x00, 0x8b); +Colors.DarkViolet = (0, _glMatrix.vec3).fromValues(0x94, 0x00, 0xd3); +Colors.DarkSlateBlue = (0, _glMatrix.vec3).fromValues(0x48, 0x3d, 0x8b); +Colors.BlueViolet = (0, _glMatrix.vec3).fromValues(0x8a, 0x2b, 0xe2); +Colors.DarkOrchid = (0, _glMatrix.vec3).fromValues(0x99, 0x32, 0xcc); +Colors.Fuchsia = (0, _glMatrix.vec3).fromValues(0xff, 0x00, 0xff); +Colors.Magenta = (0, _glMatrix.vec3).fromValues(0xff, 0x00, 0xff); +Colors.SlateBlue = (0, _glMatrix.vec3).fromValues(0x6a, 0x5a, 0xcd); +Colors.MediumSlateBlue = (0, _glMatrix.vec3).fromValues(0x7b, 0x68, 0xee); +Colors.MediumOrchid = (0, _glMatrix.vec3).fromValues(0xba, 0x55, 0xd3); +Colors.MediumPurple = (0, _glMatrix.vec3).fromValues(0x93, 0x70, 0xdb); +Colors.Orchid = (0, _glMatrix.vec3).fromValues(0xda, 0x70, 0xd6); +Colors.Violet = (0, _glMatrix.vec3).fromValues(0xee, 0x82, 0xee); +Colors.Plum = (0, _glMatrix.vec3).fromValues(0xdd, 0xa0, 0xdd); +Colors.Thistle = (0, _glMatrix.vec3).fromValues(0xd8, 0xbf, 0xd8); +Colors.Lavender = (0, _glMatrix.vec3).fromValues(0xe6, 0xe6, 0xfa); +Colors.MistyRose = (0, _glMatrix.vec3).fromValues(0xff, 0xe4, 0xe1); +Colors.AntiqueWhite = (0, _glMatrix.vec3).fromValues(0xfa, 0xeb, 0xd7); +Colors.Linen = (0, _glMatrix.vec3).fromValues(0xfa, 0xf0, 0xe6); +Colors.Beige = (0, _glMatrix.vec3).fromValues(0xf5, 0xf5, 0xdc); +Colors.WhiteSmoke = (0, _glMatrix.vec3).fromValues(0xf5, 0xf5, 0xf5); +Colors.LavenderBlush = (0, _glMatrix.vec3).fromValues(0xff, 0xf0, 0xf5); +Colors.OldLace = (0, _glMatrix.vec3).fromValues(0xfd, 0xf5, 0xe6); +Colors.AliceBlue = (0, _glMatrix.vec3).fromValues(0xf0, 0xf8, 0xff); +Colors.Seashell = (0, _glMatrix.vec3).fromValues(0xff, 0xf5, 0xee); +Colors.GhostWhite = (0, _glMatrix.vec3).fromValues(0xf8, 0xf8, 0xff); +Colors.Honeydew = (0, _glMatrix.vec3).fromValues(0xf0, 0xff, 0xf0); +Colors.FloralWhite = (0, _glMatrix.vec3).fromValues(0xff, 0xfa, 0xf0); +Colors.Azure = (0, _glMatrix.vec3).fromValues(0xf0, 0xff, 0xff); +Colors.MintCream = (0, _glMatrix.vec3).fromValues(0xf5, 0xff, 0xfa); +Colors.Snow = (0, _glMatrix.vec3).fromValues(0xff, 0xfa, 0xfa); +Colors.Ivory = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0xf0); +Colors.White = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0xff); +Colors.Black = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0x00); +Colors.DarkSlateGray = (0, _glMatrix.vec3).fromValues(0x2f, 0x4f, 0x4f); +Colors.DimGray = (0, _glMatrix.vec3).fromValues(0x69, 0x69, 0x69); +Colors.SlateGray = (0, _glMatrix.vec3).fromValues(0x70, 0x80, 0x90); +Colors.Gray = (0, _glMatrix.vec3).fromValues(0x80, 0x80, 0x80); +Colors.LightSlateGray = (0, _glMatrix.vec3).fromValues(0x77, 0x88, 0x99); +Colors.DarkGray = (0, _glMatrix.vec3).fromValues(0xa9, 0xa9, 0xa9); +Colors.Silver = (0, _glMatrix.vec3).fromValues(0xc0, 0xc0, 0xc0); +Colors.LightGray = (0, _glMatrix.vec3).fromValues(0xd3, 0xd3, 0xd3); +Colors.Gainsboro = (0, _glMatrix.vec3).fromValues(0xdc, 0xdc, 0xdc); +Colors.Copper = (0, _glMatrix.vec3).fromValues(0xb8, 0x73, 0x33); +Colors.Bronze = (0, _glMatrix.vec3).fromValues(0xcd, 0x7f, 0x32); +Colors.Steel = (0, _glMatrix.vec3).fromValues(0xce, 0xd2, 0xd7); +Colors.Platinum = (0, _glMatrix.vec3).fromValues(0xe5, 0xe4, 0xe2); +Colors.Gunmetal = (0, _glMatrix.vec3).fromValues(0x5c, 0x5d, 0x5b); +Colors.Titanium = (0, _glMatrix.vec3).fromValues(0x87, 0x86, 0x81); +Colors.RoseGold = (0, _glMatrix.vec3).fromValues(0xcb, 0xa3, 0xb2); +Colors.AquaGlass = (0, _glMatrix.vec3).fromValues(0xd2, 0xe8, 0xdf); +Colors.BlueGlass = (0, _glMatrix.vec3).fromValues(0xc7, 0xe3, 0xe1); + +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5JhCv":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class Scatter extends (0, _layoutJs.LayoutBase) { - layout(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const positionScalingX = options.positionScalingX === undefined ? 1 : options.positionScalingX; - const positionScalingY = options.positionScalingY === undefined ? 1 : options.positionScalingY; - const positionScalingZ = options.positionScalingZ === undefined ? 1 : options.positionScalingZ; - if (!this._positions || this._positions.length < buffer.length * 3) this._positions = new Float32Array(buffer.length * 3); - this.minLayoutBoundsX = Number.MAX_VALUE; - this.minLayoutBoundsY = Number.MAX_VALUE; - this.minLayoutBoundsZ = Number.MAX_VALUE; - this.maxLayoutBoundsX = -Number.MAX_VALUE; - this.maxLayoutBoundsY = -Number.MAX_VALUE; - this.maxLayoutBoundsZ = -Number.MAX_VALUE; - const lookup = buffer.lookup; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = options.positionsX ? options.positionsX[id] * positionScalingX : 0; - let positionY = options.positionsY ? options.positionsY[id] * positionScalingY : 0; - let positionZ = options.positionsZ ? options.positionsZ[id] * positionScalingZ : 0; - this._positions[index * 3] = positionX; - this._positions[index * 3 + 1] = positionY; - this._positions[index * 3 + 2] = positionZ; - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, positionX); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, positionY); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, positionZ); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, positionX); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, positionY); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, positionZ); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "MapItem", ()=>MapItem); +parcelHelpers.export(exports, "MapVisual", ()=>MapVisual); +parcelHelpers.export(exports, "Map", ()=>Map); +parcelHelpers.export(exports, "MapAtlas", ()=>MapAtlas); +parcelHelpers.export(exports, "MapRasterizer", ()=>MapRasterizer); +parcelHelpers.export(exports, "GeoJSONRasterizer", ()=>GeoJSONRasterizer); +var _mapJs = require("./helpers/map.js"); +var _mainJs = require("./main.js"); +class MapItem { + toJSON() { + return { + key: this.key, + scale: this.scale, + minLat: this.minLat, + maxLat: this.maxLat, + minLon: this.minLon, + maxLon: this.maxLon, + u0: this.u0, + v0: this.v0, + u1: this.u1, + v1: this.v1 + }; + } +} +class MapVisual { + update() {} + constructor(map){ + this.map = map; + } +} +class Map { + get atlas() { + return this._rasterizer.atlas; + } + get count() { + return this._keys.size; + } + constructor(core, rasterizer){ + this._core = core; + this._rasterizer = rasterizer; + this._keys = new Set(); + this._previousSize = 0; + this.items = {}; + } + add(key) { + if (!this._keys.has(key)) { + if (this._rasterizer.draw(key) !== null) { + this._keys.add(key); + this._hasChanged = true; + } } - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - update(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _vec4 = (0, _glMatrix.vec4).create(); - const _quat = (0, _glMatrix.quat).create(); - const sizeScalingX = options.sizeScaling === undefined ? options.sizeScalingX === undefined ? 1 : options.sizeScalingX : options.sizeScaling; - const sizeScalingY = options.sizeScaling === undefined ? options.sizeScalingY === undefined ? 1 : options.sizeScalingY : options.sizeScaling; - const sizeScalingZ = options.sizeScaling === undefined ? options.sizeScalingZ === undefined ? 1 : options.sizeScalingZ : options.sizeScaling; - const sizesX = options.sizes ? options.sizes : options.sizesX; - const sizesY = options.sizes ? options.sizes : options.sizesY; - const sizesZ = options.sizes ? options.sizes : options.sizesZ; - const minSize = options.minSize === undefined ? 0 : options.minSize; - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - if (options.rotation) { - _quat[0] = options.rotation[0]; - _quat[1] = options.rotation[1]; - _quat[2] = options.rotation[2]; - _quat[3] = options.rotation[3]; - } else (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); - if (options.texCoord) { - _vec4[0] = options.texCoord[0]; - _vec4[1] = options.texCoord[1]; - _vec4[2] = options.texCoord[2]; - _vec4[3] = options.texCoord[3]; + update() { + if (this._hasChanged) { + this._hasChanged = false; + this._core.log.write((0, _mainJs.LogLevel).info, `${this.key} added ${this._keys.size - this._previousSize} new items`); + this._previousSize = this._keys.size; + if (this.hasChangedCallback) this.hasChangedCallback(); } - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; - } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = Math.max((sizesX ? Math.abs(sizesX[id]) : 1) * sizeScalingX, minSize) * this._boundsScaling; - _vec3[1] = Math.max((sizesY ? Math.abs(sizesY[id]) : 1) * sizeScalingY, minSize) * this._boundsScaling; - _vec3[2] = Math.max((sizesZ ? Math.abs(sizesZ[id]) : 1) * sizeScalingZ, minSize) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - if (options.rotations) { - _quat[0] = options.rotations[id * 4]; - _quat[1] = options.rotations[id * 4 + 1]; - _quat[2] = options.rotations[id * 4 + 2]; - _quat[3] = options.rotations[id * 4 + 3]; - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - } else (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - if (options.colors1) { - const color1 = (0, _mathJs.MathHelper).normalize(options.colors1[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color1); - } else (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); - if (options.texCoords) { - _vec4[0] = options.texCoords[id * 4]; - _vec4[1] = options.texCoords[id * 4 + 1]; - _vec4[2] = options.texCoords[id * 4 + 2]; - _vec4[3] = options.texCoords[id * 4 + 3]; - (0, _vertexJs.UnitVertex).setTexCoord(dataView, index, _vec4); - } else (0, _vertexJs.UnitVertex).setTexCoord(dataView, index, _vec4); + } + toJSON() { + const items = []; + for(let key in this.items){ + const item = this.items[key]; + items.push(item.toJSON()); } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); + return { + key: this.key, + items: items + }; } } - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"liYq1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LayoutBase", ()=>LayoutBase); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _boundsJs = require("../helpers/bounds.js"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -class LayoutBase { - get facetScaling() { - return this._facetScaling; +class MapAtlas { + constructor(width, height){ + const canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + const context = canvas.getContext("2d"); + context.clearRect(0, 0, width, height); + this.imageData = context.getImageData(0, 0, width, height); + this.x = 0; + this.top = new Uint16Array(width); } - offsetX(facetCoordX) { - return ((facetCoordX + 0.5) / this._facetsX - 0.5) * (this.maxModelBoundsX - this.minModelBoundsX) / this._maxBounds; +} +class MapRasterizer { + get map() { + return this._map; } - offsetY(facetCoordY) { - return ((facetCoordY + 0.5) / this._facetsY - 0.5) * (this.maxModelBoundsY - this.minModelBoundsY) / this._maxBounds; + get atlas() { + return this._atlas; } - offsetZ(facetCoordZ) { - return ((facetCoordZ + 0.5) / this._facetsZ - 0.5) * (this.maxModelBoundsZ - this.minModelBoundsZ) / this._maxBounds; + get scale() { + return this._scale; } - constructor(core){ + set scale(value) { + this._scale = value; + this._geoJSONRasterizer.scale = value; + } + get geoJSON() { + return this._geoJSON; + } + set geoJSON(value) { + this._geoJSON = value; + this._geoJSONRasterizer.geoJSON = value; + } + get property() { + return this._property; + } + set property(value) { + this._property = value; + this._geoJSONRasterizer.property = value; + } + get mapProjection() { + return this._mapProjection; + } + set mapProjection(value) { + this._mapProjection = value; + this._geoJSONRasterizer.mapProjection = value; + } + get scaleFactor() { + return this._scaleFactor; + } + set scaleFactor(value) { + this._scaleFactor = value; + this._geoJSONRasterizer.scaleFactor = this._scaleFactor; + } + get minLongitude() { + return this._minLogitude; + } + set minLongitude(value) { + this._minLogitude = value; + this._geoJSONRasterizer.minLongitude = this._minLogitude; + } + get maxLongitude() { + return this._maxLongitude; + } + set maxLongitude(value) { + this._maxLongitude = value; + this._geoJSONRasterizer.maxLongitude = this._maxLongitude; + } + get minLatitude() { + return this._minLatitude; + } + set minLatitude(value) { + this._minLatitude = value; + this._geoJSONRasterizer.minLatitude = this._minLatitude; + } + get maxLatitude() { + return this._maxLatitude; + } + set maxLatitude(value) { + this._maxLatitude = value; + this._geoJSONRasterizer.maxLatitude = this._maxLatitude; + } + constructor(core, options){ + let start = performance.now(); this._core = core; - this.modelOriginX = 0; - this.modelOriginY = 0; - this.modelOriginZ = 0; - this.minModelBoundsX = 0; - this.minModelBoundsY = 0; - this.minModelBoundsZ = 0; - this.maxModelBoundsX = 0; - this.maxModelBoundsY = 0; - this.maxModelBoundsZ = 0; - this.minLayoutBoundsX = 0; - this.minLayoutBoundsY = 0; - this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = 0; - this.maxLayoutBoundsY = 0; - this.maxLayoutBoundsZ = 0; - this._facetSpacingX = 0; - this._facetSpacingY = 0; - this._facetSpacingZ = 0; - this._facetSizeX = 0; - this._facetSizeY = 0; - this._facetSizeZ = 0; - this._facetsX = 1; - this._facetsY = 1; - this._facetsZ = 1; + this._atlas = options.atlas; + this._geoJSON = options.geoJSON; + this._scale = options.scale; + this._property = options.property; + this._border = options.border; + this._maxDistance = options.maxDistance; + this._edgeValue = options.edgeValue; + this._key = options.key; + this._mapProjection = options.mapProjection; + this._map = new Map(core, this); + this._map.key = this._key; + const geoJSONRasterizerOptions = { + border: this._border, + edgeValue: this._edgeValue, + maxDistance: this._maxDistance, + geoJSON: this._geoJSON, + scale: this._scale, + property: this._property, + mapProjection: this._mapProjection + }; + this._geoJSONRasterizer = new GeoJSONRasterizer(core, geoJSONRasterizerOptions); + this._core.log.write((0, _mainJs.LogLevel).info, `map rasterizer ${Math.round(window.performance.now() - start)}ms`); } - _updateModelBounds(options) { - this.minModelBoundsX = options.minBoundsX === undefined ? this.minLayoutBoundsX : options.minBoundsX; - this.minModelBoundsY = options.minBoundsY === undefined ? this.minLayoutBoundsY : options.minBoundsY; - this.minModelBoundsZ = options.minBoundsZ === undefined ? this.minLayoutBoundsZ : options.minBoundsZ; - this.maxModelBoundsX = options.maxBoundsX === undefined ? this.maxLayoutBoundsX : options.maxBoundsX; - this.maxModelBoundsY = options.maxBoundsY === undefined ? this.maxLayoutBoundsY : options.maxBoundsY; - this.maxModelBoundsZ = options.maxBoundsZ === undefined ? this.maxLayoutBoundsZ : options.maxBoundsZ; - this._isFacetted = options.facetsX !== undefined && options.facetsX > 1 && options.facetCoordsX != null || options.facetsY !== undefined && options.facetsY > 1 && options.facetCoordsY != null || options.facetsZ !== undefined && options.facetsZ > 1 && options.facetCoordsZ != null; - this._facetSpacingX = options.facetSpacingX === undefined ? 0 : options.facetSpacingX; - this._facetSpacingY = options.facetSpacingY === undefined ? 0 : options.facetSpacingY; - this._facetSpacingZ = options.facetSpacingZ === undefined ? 0 : options.facetSpacingZ; - let modelSizeX = this.maxModelBoundsX - this.minModelBoundsX; - let modelSizeY = this.maxModelBoundsY - this.minModelBoundsY; - let modelSizeZ = this.maxModelBoundsZ - this.minModelBoundsZ; - const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); - this._facetSizeX = modelSizeX; - this._facetSizeY = modelSizeY; - this._facetSizeZ = modelSizeZ; - this._facetsX = options.facetCoordsX ? options.facetsX : 1; - this._facetsY = options.facetCoordsY ? options.facetsY : 1; - this._facetsZ = options.facetCoordsZ ? options.facetsZ : 1; - this.minModelBoundsX -= this._facetSizeX * this._facetSpacingX / 2; - this.minModelBoundsY -= this._facetSizeY * this._facetSpacingY / 2; - this.minModelBoundsZ -= this._facetSizeZ * this._facetSpacingZ / 2; - this.maxModelBoundsX = this.minModelBoundsX + this._facetsX * this._facetSizeX * (1 + this._facetSpacingX); - this.maxModelBoundsY = this.minModelBoundsY + this._facetsY * this._facetSizeY * (1 + this._facetSpacingY); - this.maxModelBoundsZ = this.minModelBoundsZ + this._facetsZ * this._facetSizeZ * (1 + this._facetSpacingZ); - this.modelOriginX = (this.minModelBoundsX + this.maxModelBoundsX) / 2; - this.modelOriginY = (this.minModelBoundsY + this.maxModelBoundsY) / 2; - this.modelOriginZ = (this.minModelBoundsZ + this.maxModelBoundsZ) / 2; - modelSizeX = this.maxModelBoundsX - this.minModelBoundsX; - modelSizeY = this.maxModelBoundsY - this.minModelBoundsY; - modelSizeZ = this.maxModelBoundsZ - this.minModelBoundsZ; - this._maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); - this._boundsScaling = this._maxBounds == 0 ? 1 : 1 / this._maxBounds; - this._facetScaling = maxBounds / this._maxBounds; + draw(key) { + const item = this._geoJSONRasterizer.draw(key); + if (item) { + const texWidth = item.width + 2 * this._border; + const texHeight = item.height + 2 * this._border; + const width = this._atlas.imageData.width; + const height = this.atlas.imageData.height; + if (this._atlas.x + texWidth > width - 1) this._atlas.x = 0; + let y = 0; + for(let x = this._atlas.x; x < this._atlas.x + texWidth; x++)y = Math.max(y, this._atlas.top[x]); + if (y + texHeight > height - 1) this._core.log.write((0, _mainJs.LogLevel).warn, `${this._map.key} height overflow`); + for(let x = this._atlas.x; x < this._atlas.x + texWidth; x++)this._atlas.top[x] = y + texHeight; + const halfTexelOffsetX = 0.5 / width; + const halfTexelOffsetY = 0.5 / height; + item.u0 = this._atlas.x / width + halfTexelOffsetX; + item.v0 = y / height + halfTexelOffsetY; + item.u1 = (this._atlas.x + texWidth) / width - halfTexelOffsetX; + item.v1 = (y + texHeight) / height - halfTexelOffsetY; + this._map.items[key] = item; + for(let i = 0; i < item.distances.length; i++){ + const distance = item.distances[i]; + const dataX = i % texWidth; + const dataY = Math.floor(i / texWidth); + const offset = (this._atlas.x + dataX + (y + dataY) * width) * 4; + this._atlas.imageData.data[offset + 0] = distance; + this._atlas.imageData.data[offset + 1] = distance; + this._atlas.imageData.data[offset + 2] = distance; + this._atlas.imageData.data[offset + 3] = 0xff; + } + this._atlas.x += texWidth; + } + return item; } - resetCumulativeLayoutBounds() { - this.minCumulativeLayoutBoundsX = undefined; - this.minCumulativeLayoutBoundsY = undefined; - this.minCumulativeLayoutBoundsZ = undefined; - this.maxCumulativeLayoutBoundsX = undefined; - this.maxCumulativeLayoutBoundsY = undefined; - this.maxCumulativeLayoutBoundsZ = undefined; +} +class GeoJSONRasterizer { + get scale() { + return this._scale; } - _updateCumulativeLayoutBounds() { - this.minCumulativeLayoutBoundsX = this.minCumulativeLayoutBoundsX === undefined ? this.minLayoutBoundsX : Math.min(this.minCumulativeLayoutBoundsX, this.minLayoutBoundsX); - this.minCumulativeLayoutBoundsY = this.minCumulativeLayoutBoundsY === undefined ? this.minLayoutBoundsY : Math.min(this.minCumulativeLayoutBoundsY, this.minLayoutBoundsY); - this.minCumulativeLayoutBoundsZ = this.minCumulativeLayoutBoundsZ === undefined ? this.minLayoutBoundsZ : Math.min(this.minCumulativeLayoutBoundsZ, this.minLayoutBoundsZ); - this.maxCumulativeLayoutBoundsX = this.maxCumulativeLayoutBoundsX === undefined ? this.maxLayoutBoundsX : Math.max(this.maxCumulativeLayoutBoundsX, this.maxLayoutBoundsX); - this.maxCumulativeLayoutBoundsY = this.maxCumulativeLayoutBoundsY === undefined ? this.maxLayoutBoundsY : Math.max(this.maxCumulativeLayoutBoundsY, this.maxLayoutBoundsY); - this.maxCumulativeLayoutBoundsZ = this.maxCumulativeLayoutBoundsZ === undefined ? this.maxLayoutBoundsZ : Math.max(this.maxCumulativeLayoutBoundsZ, this.maxLayoutBoundsZ); + set scale(value) { + this._scale = value; } - unitToModelSize(unitSize) { - return unitSize / this._boundsScaling; + get geoJSON() { + return this._geoJSON; } - unitToModelPositionX(unitPositionX) { - return this.unitToModelSize(unitPositionX) + this.modelOriginX; + set geoJSON(value) { + this._geoJSON = value; } - unitToModelPositionY(unitPositionY) { - return this.unitToModelSize(unitPositionY) + this.modelOriginY; + get property() { + return this._property; } - unitToModelPositionZ(unitPositionZ) { - return this.unitToModelSize(unitPositionZ) + this.modelOriginZ; + set property(value) { + this._property = value; } - unitToModelPosition(unitPosition, modelPosition) { - modelPosition[0] = this.unitToModelPositionX(unitPosition[0]); - modelPosition[1] = this.unitToModelPositionY(unitPosition[1]); - modelPosition[2] = this.unitToModelPositionZ(unitPosition[2]); + get mapProjection() { + return this._mapProjection; } - modelToUnitSize(modelSize) { - return modelSize * this._boundsScaling; + set mapProjection(value) { + this._mapProjection = value; } - modelToUnitPositionX(modelPositionX) { - return (modelPositionX - this.modelOriginX) * this._boundsScaling; + get scaleFactor() { + return this._scaleFactor; } - modelToUnitPositionY(modelPositionY) { - return (modelPositionY - this.modelOriginY) * this._boundsScaling; + set scaleFactor(value) { + this._scaleFactor = value; } - modelToUnitPositionZ(modelPositionZ) { - return (modelPositionZ - this.modelOriginZ) * this._boundsScaling; + get minLongitude() { + return this._minLongitude; } - modelToUnitPosition(modelPosition, unitPosition) { - unitPosition[0] = this.modelToUnitPositionX(modelPosition[0]); - unitPosition[1] = this.modelToUnitPositionY(modelPosition[1]); - unitPosition[2] = this.modelToUnitPositionZ(modelPosition[2]); + set minLongitude(value) { + this._minLongitude = value; } - inclusiveUnitBounds(buffer, ids, unitType, offset, count, minBounds, maxBounds) { - (0, _glMatrix.vec3).set(minBounds, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); - (0, _glMatrix.vec3).set(maxBounds, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - const unitScale = (0, _glMatrix.vec3).create(); - const unitRotation = (0, _glMatrix.quat).create(); - const unitTranslation = (0, _glMatrix.vec3).create(); - const lookup = buffer.lookup; - const dataView = buffer.dataView; - let minBounds0; - let maxBounds0; - let minBounds1; - let maxBounds1; - switch(unitType){ - case (0, _mainJs.UnitType).sphere: - case (0, _mainJs.UnitType).sphereSdf: - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - (0, _vertexJs.UnitVertex).getTranslation(dataView, index, unitTranslation); - (0, _vertexJs.UnitVertex).getScale(dataView, index, unitScale); - const radius = unitScale[0] / 2; - minBounds[0] = Math.min(minBounds[0], unitTranslation[0] - radius); - minBounds[1] = Math.min(minBounds[1], unitTranslation[1] - radius); - minBounds[2] = Math.min(minBounds[2], unitTranslation[2] - radius); - maxBounds[0] = Math.max(maxBounds[0], unitTranslation[0] + radius); - maxBounds[1] = Math.max(maxBounds[1], unitTranslation[1] + radius); - maxBounds[2] = Math.max(maxBounds[2], unitTranslation[2] + radius); - } - break; - case (0, _mainJs.UnitType).hexPrism: - case (0, _mainJs.UnitType).hexPrismSdf: - case (0, _mainJs.UnitType).block: - case (0, _mainJs.UnitType).blockSdf: - minBounds0 = (0, _glMatrix.vec3).create(); - maxBounds0 = (0, _glMatrix.vec3).create(); - minBounds1 = (0, _glMatrix.vec3).create(); - maxBounds1 = (0, _glMatrix.vec3).create(); - for(let i1 = 0; i1 < count; i1++){ - const id1 = ids[i1 + offset]; - const index1 = lookup[id1]; - (0, _vertexJs.UnitVertex).getTranslation(dataView, index1, unitTranslation); - (0, _vertexJs.UnitVertex).getRotation(dataView, index1, unitRotation); - (0, _vertexJs.UnitVertex).getScale(dataView, index1, unitScale); - minBounds0[0] = unitTranslation[0] - unitScale[0] / 2; - minBounds0[1] = unitTranslation[1] - unitScale[1] / 2; - minBounds0[2] = unitTranslation[2] - unitScale[2] / 2; - maxBounds0[0] = unitTranslation[0] + unitScale[0] / 2; - maxBounds0[1] = unitTranslation[1] + unitScale[1] / 2; - maxBounds0[2] = unitTranslation[2] + unitScale[2] / 2; - (0, _boundsJs.BoundsHelper).rotateBounds(minBounds0, maxBounds0, unitRotation, minBounds1, maxBounds1); - (0, _glMatrix.vec3).min(minBounds, minBounds, minBounds1); - (0, _glMatrix.vec3).max(maxBounds, maxBounds, maxBounds1); - } - break; - case (0, _mainJs.UnitType).cylinder: - case (0, _mainJs.UnitType).cylinderSdf: - minBounds0 = (0, _glMatrix.vec3).create(); - maxBounds0 = (0, _glMatrix.vec3).create(); - const pa = (0, _glMatrix.vec3).create(); - const pb = (0, _glMatrix.vec3).create(); - const identityRotation = (0, _constantsJs.Constants).VECTOR3_UNITY; - let ca; - for(let i2 = 0; i2 < count; i2++){ - const id2 = ids[i2 + offset]; - const index2 = lookup[id2]; - (0, _vertexJs.UnitVertex).getTranslation(dataView, index2, unitTranslation); - (0, _vertexJs.UnitVertex).getRotation(dataView, index2, unitRotation); - (0, _vertexJs.UnitVertex).getScale(dataView, index2, unitScale); - const length = unitScale[1]; - const radius1 = Math.max(unitScale[0], unitScale[2]); - if (length != 0 && radius1 != 0) { - if ((0, _glMatrix.quat).equals(unitRotation, (0, _constantsJs.Constants).QUAT_IDENTITY)) ca = identityRotation; - else { - ca = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).transformQuat(ca, identityRotation, unitRotation); + get maxLongitude() { + return this._maxLongitude; + } + set maxLongitude(value) { + this._maxLongitude = value; + } + get minLatitude() { + return this._minLatitude; + } + set minLatitude(value) { + this._minLatitude = value; + } + get maxLatitude() { + return this._maxLatitude; + } + set maxLatitude(value) { + this._maxLatitude = value; + } + constructor(core, options){ + let start = performance.now(); + this._core = core; + this._geoJSON = options.geoJSON; + this._scale = options.scale; + this._property = options.property; + this._border = options.border; + this._maxDistance = options.maxDistance; + this._edgeValue = options.edgeValue; + this._mapProjection = options.mapProjection; + this._lonLat = [ + 0, + 0 + ]; + this._geoJSONHelper = new (0, _mapJs.GeoJSONHelper)(); + this._core.log.write((0, _mainJs.LogLevel).info, `geoJSON rasterizer ${Math.round(window.performance.now() - start)}ms`); + } + draw(key) { + let feature = this._geoJSONHelper.feature(this._geoJSON, this._property, key); + if (feature) { + let geometry = feature.geometry; + const clip = { + minLon: this._minLongitude, + maxLon: this._maxLongitude, + minLat: this._minLatitude, + maxLat: this._maxLatitude + }; + const bounds = this._geoJSONHelper.bounds(geometry, clip, this._mapProjection); + if (bounds) { + let minX = bounds.minX; + let maxX = bounds.maxX; + let minY = bounds.minY; + let maxY = bounds.maxY; + let sizeX = bounds.maxX - bounds.minX; + let sizeY = bounds.maxY - bounds.minY; + if (sizeX > 0 && sizeY > 0) { + const scale = this._scale * this._scaleFactor; + sizeX = Math.ceil(sizeX * scale); + sizeY = Math.ceil(sizeY * scale); + const canvas = document.createElement("canvas"); + const width = sizeX + 2 * this._border; + const height = sizeY + 2 * this._border; + canvas.width = width; + canvas.height = height; + const ctx = canvas.getContext("2d", { + willReadFrequently: true + }); + let length = width * height; + this._gridOuter = new Float64Array(length); + this._gridInner = new Float64Array(length); + length = Math.max(width, height); + this._f = new Float64Array(length); + this._z = new Float64Array(length + 1); + this._v = new Uint16Array(length); + length = width * height; + const distances = new Uint8ClampedArray(length); + const gradientsX = new Uint8ClampedArray(length); + const gradientsY = new Uint8ClampedArray(length); + const pixels = new Uint8ClampedArray(length); + const item = new MapItem(); + item.key = key; + item.distances = distances; + item.gradientsX = gradientsX; + item.gradientsY = gradientsY; + item.pixels = pixels; + item.width = sizeX; + item.height = sizeY; + item.minLon = minX; + item.maxLon = maxX; + item.minLat = minY; + item.maxLat = maxY; + item.scale = this._scaleFactor; + ctx.clearRect(this._border, this._border, sizeX, sizeY); + switch(geometry.type){ + case "Polygon": + const polygon = geometry; + const outer = polygon.coordinates[0]; + ctx.fillStyle = "black"; + ctx.beginPath(); + this._lonLat[0] = outer[0][0]; + this._lonLat[1] = outer[0][1]; + if (this._lonLat[0] < clip.minLon || this._lonLat[0] > clip.maxLon || this._lonLat[1] < clip.minLat || this._lonLat[1] > clip.maxLat) break; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.moveTo(x, y); + for(let k = 1; k < outer.length; k++){ + this._lonLat[0] = outer[k][0]; + this._lonLat[1] = outer[k][1]; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.lineTo(x, y); + } + ctx.fill(); + for(let k = 1; k < polygon.coordinates.length; k++){ + const inner = polygon.coordinates[k]; + ctx.fillStyle = "transparent"; + ctx.beginPath(); + this._lonLat[0] = inner[0][0]; + this._lonLat[1] = inner[0][1]; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.moveTo(x, y); + for(let l = 1; l < inner.length; l++){ + this._lonLat[0] = inner[l][0]; + this._lonLat[1] = inner[l][1]; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.lineTo(x, y); + } + ctx.fill(); + } + break; + case "MultiPolygon": + const multiPolygon = geometry; + for(let j = 0; j < multiPolygon.coordinates.length; j++){ + const polygon = multiPolygon.coordinates[j]; + const outer = polygon[0]; + ctx.fillStyle = "black"; + ctx.beginPath(); + this._lonLat[0] = outer[0][0]; + this._lonLat[1] = outer[0][1]; + if (this._lonLat[0] < clip.minLon || this._lonLat[0] > clip.maxLon || this._lonLat[1] < clip.minLat || this._lonLat[1] > clip.maxLat) continue; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.moveTo(x, y); + for(let k = 1; k < outer.length; k++){ + this._lonLat[0] = outer[k][0]; + this._lonLat[1] = outer[k][1]; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.lineTo(x, y); + } + ctx.fill(); + for(let k = 1; k < polygon.length; k++){ + const inner = polygon[k]; + ctx.fillStyle = "transparent"; + ctx.beginPath(); + this._lonLat[0] = inner[0][0]; + this._lonLat[1] = inner[0][1]; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.moveTo(x, y); + for(let l = 1; l < inner.length; l++){ + this._lonLat[0] = inner[l][0]; + this._lonLat[1] = inner[l][1]; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (this._mapProjection) this._mapProjection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + const x = (this._lonLat[0] - minX) * scale - sizeX / 2 + width / 2; + const y = height / 2 - (this._lonLat[1] - minY) * scale + sizeY / 2; + ctx.lineTo(x, y); + } + ctx.fill(); + } + } + break; + } + const imgData = ctx.getImageData(this._border, this._border, sizeX, sizeY); + for(let i = 0; i < length; i++){ + this._gridOuter[i] = Number.MAX_VALUE; + this._gridInner[i] = 0; + } + for(let y = 0; y < sizeY; y++)for(let x = 0; x < sizeX; x++){ + const a = imgData.data[4 * (y * sizeX + x) + 3] / 0xff; + if (a > 0) { + const j = (y + this._border) * width + x + this._border; + if (a == 1) { + this._gridOuter[j] = 0; + this._gridInner[j] = Number.MAX_VALUE; + pixels[j] = 0xff; + } else { + const d = 0.5 - a; + this._gridOuter[j] = d > 0 ? d * d : 0; + this._gridInner[j] = d < 0 ? d * d : 0; + } } - (0, _glMatrix.vec3).scaleAndAdd(pa, unitTranslation, ca, -length * 0.5); - (0, _glMatrix.vec3).scaleAndAdd(pb, unitTranslation, ca, length * 0.5); - (0, _boundsJs.BoundsHelper).cylinder(pa, pb, radius1, minBounds0, maxBounds0); - (0, _glMatrix.vec3).min(minBounds, minBounds, minBounds0); - (0, _glMatrix.vec3).max(maxBounds, maxBounds, maxBounds0); } + this._edt(this._gridOuter, 0, 0, width, height, width, this._f, this._v, this._z); + this._edt(this._gridInner, this._border, this._border, sizeX, sizeY, width, this._f, this._v, this._z); + const distances2 = new Float32Array(length); + for(let i = 0; i < length; i++){ + const distance = Math.sqrt(this._gridOuter[i]) - Math.sqrt(this._gridInner[i]); + distances[i] = Math.round(this._edgeValue - distance * 0xff / this._maxDistance); + distances2[i] = distance; + } + for(let i = 0; i < length; i++){ + const x = i % width; + const y = Math.floor(i / width); + const d = distances2[i]; + const sign = d < 0 ? -1 : 1; + const x0 = x > 0 ? distances2[i - 1] : Number.MAX_VALUE; + const x1 = x < width - 1 ? distances2[i + 1] : Number.MAX_VALUE; + const y0 = y > 0 ? distances2[i - width] : Number.MAX_VALUE; + const y1 = y < height - 1 ? distances2[i + width] : Number.MAX_VALUE; + let gradientX = sign * x0 < sign * x1 ? d - x0 : x1 - d; + let gradientY = sign * y0 < sign * y1 ? y0 - d : d - y1; + gradientsX[i] = Math.round((gradientX * 0.5 + 0.5) * 0xff); + gradientsY[i] = Math.round((gradientY * 0.5 + 0.5) * 0xff); + } + return item; } - break; + } } + if (!feature) this._core.log.write((0, _mainJs.LogLevel).warn, `geoJSON rasterizer ${key} not found`); + return null; } -} - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/bounds.js":"coSRO","../main.js":"1Kju3","../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"coSRO":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "BoundsHelper", ()=>BoundsHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _cubeJs = require("../meshes/cube.js"); -class BoundsHelper { - static rotateBounds(minBounds, maxBounds, rotation, rotatedMinBounds, rotatedMaxBounds) { - const sizeX = maxBounds[0] - minBounds[0]; - const sizeY = maxBounds[1] - minBounds[1]; - const sizeZ = maxBounds[2] - minBounds[2]; - const min = rotatedMinBounds; - const max = rotatedMaxBounds; - (0, _glMatrix.vec3).set(min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); - (0, _glMatrix.vec3).set(max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - const vertices = (0, _cubeJs.Cube).POSITIONS; - const position = (0, _glMatrix.vec3).create(); - for(let i = 0; i < 8; i++){ - (0, _glMatrix.vec3).set(position, vertices[i * 3] * sizeX, vertices[i * 3 + 1] * sizeY, vertices[i * 3 + 2] * sizeZ); - (0, _glMatrix.vec3).transformQuat(position, position, rotation); - (0, _glMatrix.vec3).min(min, min, position); - (0, _glMatrix.vec3).max(max, max, position); - } - (0, _glMatrix.vec3).add(position, minBounds, maxBounds); - (0, _glMatrix.vec3).scale(position, position, 0.5); - (0, _glMatrix.vec3).add(min, min, position); - (0, _glMatrix.vec3).add(max, max, position); + _edt(data, x0, y0, width, height, gridSize, f, v, z) { + for(let x = x0; x < x0 + width; x++)this._edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); + for(let y = y0; y < y0 + height; y++)this._edt1d(data, y * gridSize + x0, 1, width, f, v, z); } - static cylinder(pa, pb, radius, minBounds, maxBounds) { - const a = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).subtract(a, pb, pa); - const aa = (0, _glMatrix.vec3).dot(a, a); - const ex = radius * Math.sqrt(1 - a[0] * a[0] / aa); - const ey = radius * Math.sqrt(1 - a[1] * a[1] / aa); - const ez = radius * Math.sqrt(1 - a[2] * a[2] / aa); - minBounds[0] = Math.min(pa[0] - ex, pb[0] - ex); - minBounds[1] = Math.min(pa[1] - ey, pb[1] - ey); - minBounds[2] = Math.min(pa[2] - ez, pb[2] - ez); - maxBounds[0] = Math.max(pa[0] + ex, pb[0] + ex); - maxBounds[1] = Math.max(pa[1] + ey, pb[1] + ey); - maxBounds[2] = Math.max(pa[2] + ez, pb[2] + ez); + _edt1d(grid, offset, stride, n, f, v, z) { + v[0] = 0; + z[0] = -Number.MAX_VALUE; + z[1] = Number.MAX_VALUE; + f[0] = grid[offset]; + for(let q = 1, k = 0, s = 0; q < n; q++){ + f[q] = grid[offset + q * stride]; + const q2 = q * q; + do { + const r = v[k]; + s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; + }while (s <= z[k] && --k > -1); + k++; + v[k] = q; + z[k] = s; + z[k + 1] = Number.MAX_VALUE; + } + for(let q = 0, k = 0; q < n; q++){ + while(z[k + 1] < q)k++; + const r = v[k]; + const qr = q - r; + grid[offset + q * stride] = f[r] + qr * qr; + } } } -},{"gl-matrix":"9GjEQ","../meshes/cube.js":"7rTMs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gZn9D":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./helpers/map.js":"27ECm","./main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"27ECm":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "AxesBase", ()=>(0, _axesJs.AxesBase)); -parcelHelpers.export(exports, "Cartesian2dAxes", ()=>(0, _cartesian2DJs.Cartesian2dAxes)); -parcelHelpers.export(exports, "Cartesian2dAxesHelper", ()=>(0, _cartesian2DJs.Cartesian2dAxesHelper)); -parcelHelpers.export(exports, "Cartesian3dAxes", ()=>(0, _cartesian3DJs.Cartesian3dAxes)); -parcelHelpers.export(exports, "Cartesian3dAxesHelper", ()=>(0, _cartesian3DJs.Cartesian3dAxesHelper)); -var _axesJs = require("./axes.js"); -var _cartesian2DJs = require("./cartesian2d.js"); -var _cartesian3DJs = require("./cartesian3d.js"); - -},{"./axes.js":"duutq","./cartesian2d.js":"7HjCZ","./cartesian3d.js":"7VqSF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fBjC9":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "AngleHelper", ()=>(0, _angleJs.AngleHelper)); -parcelHelpers.export(exports, "AnimationHelper", ()=>(0, _animationJs.AnimationHelper)); -parcelHelpers.export(exports, "ArrayHelper", ()=>(0, _arrayJs.ArrayHelper)); -parcelHelpers.export(exports, "AxisHelper", ()=>(0, _axesJs.AxisHelper)); -parcelHelpers.export(exports, "Base64Helper", ()=>(0, _base64Js.Base64Helper)); -parcelHelpers.export(exports, "BinHelper", ()=>(0, _binJs.BinHelper)); -parcelHelpers.export(exports, "ColorHelper", ()=>(0, _colorJs.ColorHelper)); -parcelHelpers.export(exports, "CsvHelper", ()=>(0, _csvJs.CsvHelper)); -parcelHelpers.export(exports, "FacetHelper", ()=>(0, _facetJs.FacetHelper)); -parcelHelpers.export(exports, "HexHelper", ()=>(0, _hexJs.HexHelper)); -parcelHelpers.export(exports, "HexBinHelper", ()=>(0, _hexbinJs.HexBinHelper)); -parcelHelpers.export(exports, "LineHelper", ()=>(0, _lineJs.LineHelper)); -parcelHelpers.export(exports, "MathHelper", ()=>(0, _mathJs.MathHelper)); -parcelHelpers.export(exports, "PseudoRandom", ()=>(0, _mathJs.PseudoRandom)); -parcelHelpers.export(exports, "MatrixHelper", ()=>(0, _matrixJs.MatrixHelper)); -parcelHelpers.export(exports, "MercatorHelper", ()=>(0, _mapJs.MercatorHelper)); -parcelHelpers.export(exports, "PaletteHelper", ()=>(0, _paletteJs.PaletteHelper)); -parcelHelpers.export(exports, "PathHelper", ()=>(0, _pathJs.PathHelper)); -parcelHelpers.export(exports, "PickHelper", ()=>(0, _pickJs.PickHelper)); -parcelHelpers.export(exports, "TableHelper", ()=>(0, _tableJs.TableHelper)); -parcelHelpers.export(exports, "TextHelper", ()=>(0, _textJs.TextHelper)); -parcelHelpers.export(exports, "TextureHelper", ()=>(0, _textureJs.TextureHelper)); -parcelHelpers.export(exports, "SetHelper", ()=>(0, _setJs.SetHelper)); -parcelHelpers.export(exports, "SdfHelper", ()=>(0, _sdfJs.SdfHelper)); -parcelHelpers.export(exports, "VectorHelper", ()=>(0, _vectorJs.VectorHelper)); -var _angleJs = require("./angle.js"); -var _animationJs = require("./animation.js"); -var _arrayJs = require("./array.js"); -var _axesJs = require("./axes.js"); -var _base64Js = require("./base64.js"); -var _binJs = require("./bin.js"); -var _colorJs = require("./color.js"); -var _csvJs = require("./csv.js"); -var _facetJs = require("./facet.js"); -var _hexJs = require("./hex.js"); -var _hexbinJs = require("./hexbin.js"); -var _lineJs = require("./line.js"); +parcelHelpers.export(exports, "MercatorHelper", ()=>MercatorHelper); +parcelHelpers.export(exports, "AlbersHelper", ()=>AlbersHelper); +parcelHelpers.export(exports, "GeoJSONHelper", ()=>GeoJSONHelper); var _mathJs = require("./math.js"); -var _matrixJs = require("./matrix.js"); -var _mapJs = require("./map.js"); -var _paletteJs = require("./palette.js"); -var _pathJs = require("./path.js"); -var _pickJs = require("./pick.js"); -var _tableJs = require("./table.js"); -var _textJs = require("./text.js"); -var _textureJs = require("./texture.js"); -var _setJs = require("./set.js"); -var _sdfJs = require("./sdf.js"); -var _vectorJs = require("./vector.js"); - -},{"./angle.js":"eKtPm","./animation.js":"iA4Fe","./array.js":"3GbDy","./axes.js":"8BmXc","./base64.js":"h3Pjh","./bin.js":"iwbqp","./color.js":"eUJOG","./csv.js":"lgH3H","./facet.js":"izKmq","./hex.js":"fhlqr","./hexbin.js":"3xoe6","./line.js":"ckdqy","./math.js":"fOnPF","./matrix.js":"cQEMs","./map.js":"haUyw","./palette.js":"gotPg","./path.js":"dofsD","./pick.js":"9zmDo","./table.js":"h48Ba","./text.js":"l2V9O","./texture.js":"bUBAh","./set.js":"db5XP","./sdf.js":"a6P8U","./vector.js":"i0I1g","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3GbDy":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "ArrayHelper", ()=>ArrayHelper); -class ArrayHelper { - static minIndex(orderedValues, offset, length, value) { - let index = ArrayHelper.binarySearch(orderedValues, offset, length, value); - if (index < 0) { - index = ~index; - index = Math.max(0, index); - } else while(index > 0 && orderedValues[index - 1] == value)index--; - return index; +var _angleJs = require("./angle.js"); +var _constantsJs = require("../constants.js"); +class MercatorHelper { + constructor(){ + this.minLatitude = -85.05112878; + this.maxLatitude = 85.05112878; + this.minLongitude = -180; + this.maxLongitude = 180; + this.minX = -1; + this.minY = -1; + this.maxX = 1; + this.maxY = 1; + } + project(longitude, latitude, xy) { + const x = longitude / 180; + latitude = (0, _mathJs.MathHelper).clamp(latitude, this.minLatitude, this.maxLatitude); + latitude = (0, _angleJs.AngleHelper).degreesToRadians(latitude); + const sinLatitude = Math.sin(latitude); + let y = Math.log((1 + sinLatitude) / (1 - sinLatitude)) / 2; + y = (0, _mathJs.MathHelper).clamp(y / Math.PI, this.minY, this.maxY); + xy[0] = x; + xy[1] = y; } - static maxIndex(orderedValues, offset, length, value) { - let index = ArrayHelper.binarySearch(orderedValues, offset, length, value); - if (index < 0) index = ~index - 1; - else { - while(index < length - 1 && orderedValues[index + 1] == value)index++; - index = Math.min(length, index); + unproject(x, y, lonLat) { + const longitude = x * 180; + y *= Math.PI; + let latitude = (0, _constantsJs.Constants).PI_OVER_TWO - 2 * Math.atan(Math.exp(-y)); + latitude = (0, _angleJs.AngleHelper).radiansToDegrees(latitude); + lonLat[0] = longitude; + lonLat[1] = latitude; + } +} +class AlbersHelper { + constructor(){ + this._phi1 = 29.5; + this._phi2 = 45.5; + this._lat0 = 37.5; + this._lon0 = -96; + } + get standardParallel1() { + return this._phi1; + } + set standardParallel1(value) { + this._phi1 = value; + } + get standardParallel2() { + return this._phi2; + } + set standardParallel2(value) { + this._phi2 = value; + } + get latitudeOfOrigin() { + return this._lat0; + } + set latitudeOfOrigin(value) { + this._lat0 = value; + } + get centralMeridian() { + return this._lon0; + } + set centralMeridian(value) { + this._lon0 = value; + } + project(lon, lat, xy) { + const phi1 = (0, _angleJs.AngleHelper).degreesToRadians(this._phi1); + const phi2 = (0, _angleJs.AngleHelper).degreesToRadians(this._phi2); + const lat0 = (0, _angleJs.AngleHelper).degreesToRadians(this._lat0); + const lon0 = (0, _angleJs.AngleHelper).degreesToRadians(this._lon0); + lat = (0, _angleJs.AngleHelper).degreesToRadians(lat); + lon = (0, _angleJs.AngleHelper).degreesToRadians(lon); + const n = 0.5 * (Math.sin(phi1) + Math.sin(phi2)); + const c = Math.cos(phi1); + const C = c * c + 2 * n * Math.sin(phi1); + const p0 = Math.sqrt(C - 2 * n * Math.sin(lat0)) / n; + const theta = n * (lon - lon0); + const p = Math.sqrt(C - 2 * n * Math.sin(lat)) / n; + const x = p * Math.sin(theta); + const y = p0 - p * Math.cos(theta); + xy[0] = x; + xy[1] = y; + } + unproject(x, y, lonLat) { + const phi1 = (0, _angleJs.AngleHelper).degreesToRadians(this._phi1); + const phi2 = (0, _angleJs.AngleHelper).degreesToRadians(this._phi2); + const lat0 = (0, _angleJs.AngleHelper).degreesToRadians(this._lat0); + const lon0 = (0, _angleJs.AngleHelper).degreesToRadians(this._lon0); + const n = 0.5 * (Math.sin(phi1) + Math.sin(phi2)); + const c = Math.cos(phi1); + const C = c * c + 2 * n * Math.sin(phi1); + const p0 = Math.sqrt(C - 2 * n * Math.sin(lat0)) / n; + let theta = Math.atan(x / Math.abs(p0 - y) * Math.sign(p0 - y)); + if ((p0 - y) * n < 0) theta -= Math.PI * Math.sign(x) * Math.sign(p0 - y); + const p = Math.sqrt(x * x + Math.pow(p0 - y, 2)); + const lon = lon0 + theta / n; + const lat = Math.asin((C - p * p * n * n) / (2 * n)); + lonLat[0] = (0, _angleJs.AngleHelper).radiansToDegrees(lon); + lonLat[1] = (0, _angleJs.AngleHelper).radiansToDegrees(lat); + } +} +class GeoJSONHelper { + constructor(){ + this._lonLat = [ + 0, + 0 + ]; + } + feature(geoJSON, property, key) { + for(let i = 0; i < geoJSON.features.length; i++){ + let feature = geoJSON.features[i]; + if (feature.properties[property] == key) return feature; } - return index; + return null; } - static binarySearch(array, index, length, value) { - let low = index; - let high = index + length - 1; - while(low <= high){ - const mid = low + (high - low >> 1); - if (array[mid] == value) return mid; - if (array[mid] <= value) low = mid + 1; - else high = mid - 1; + bounds(geometry, clip, projection) { + let minX = Number.MAX_VALUE; + let maxX = -Number.MAX_VALUE; + let minY = Number.MAX_VALUE; + let maxY = -Number.MAX_VALUE; + switch(geometry.type){ + case "Polygon": + const polygon = geometry; + const outer = polygon.coordinates[0]; + for(let k = 0; k < outer.length; k++){ + this._lonLat[0] = outer[k][0]; + this._lonLat[1] = outer[k][1]; + if (this._lonLat[0] < clip.minLon || this._lonLat[0] > clip.maxLon || this._lonLat[1] < clip.minLat || this._lonLat[1] > clip.maxLat) break; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (projection) projection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + minX = Math.min(minX, this._lonLat[0]); + maxX = Math.max(maxX, this._lonLat[0]); + minY = Math.min(minY, this._lonLat[1]); + maxY = Math.max(maxY, this._lonLat[1]); + } + break; + case "MultiPolygon": + const multiPolygon = geometry; + for(let j = 0; j < multiPolygon.coordinates.length; j++){ + const polygon = multiPolygon.coordinates[j]; + const outer = polygon[0]; + for(let k = 0; k < outer.length; k++){ + this._lonLat[0] = outer[k][0]; + this._lonLat[1] = outer[k][1]; + if (this._lonLat[0] < clip.minLon || this._lonLat[0] > clip.maxLon || this._lonLat[1] < clip.minLat || this._lonLat[1] > clip.maxLat) continue; + if (this._lonLat[0] > 0) this._lonLat[0] -= 360; + if (projection) projection.project(this._lonLat[0], this._lonLat[1], this._lonLat); + minX = Math.min(minX, this._lonLat[0]); + maxX = Math.max(maxX, this._lonLat[0]); + minY = Math.min(minY, this._lonLat[1]); + maxY = Math.max(maxY, this._lonLat[1]); + } + } + break; } - return ~low; + if (minX == Number.MAX_VALUE) { + minX = 0; + maxX = 0; + minY = 0; + maxY = 0; + } + return { + minX: minX, + maxX: maxX, + minY: minY, + maxY: maxY + }; } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"h3Pjh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./math.js":"f65d0","./angle.js":"53hwW","../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lPq9g":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Base64Helper", ()=>Base64Helper); -class Base64Helper { - uint6ToB64(nUint6) { - return nUint6 < 26 ? nUint6 + 65 : nUint6 < 52 ? nUint6 + 71 : nUint6 < 62 ? nUint6 - 4 : nUint6 === 62 ? 43 : nUint6 === 63 ? 47 : 65; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Icon", ()=>Icon); +parcelHelpers.export(exports, "IconsVisual", ()=>IconsVisual); +parcelHelpers.export(exports, "Icons", ()=>Icons); +parcelHelpers.export(exports, "IconsAtlas", ()=>IconsAtlas); +parcelHelpers.export(exports, "IconsRasterizer", ()=>IconsRasterizer); +parcelHelpers.export(exports, "IconRasterizer", ()=>IconRasterizer); +var _mainJs = require("./main.js"); +class Icon { + toJSON() { + return { + key: this.key, + u0: this.u0, + v0: this.v0, + u1: this.u1, + v1: this.v1 + }; } - base64EncArr(aBytes) { - let nMod3 = 2; - let sB64Enc = ""; - let nLen = aBytes.byteLength; - let nUint24 = 0; - for(let nIdx = 0; nIdx < nLen; nIdx++){ - nMod3 = nIdx % 3; - if (nIdx > 0 && nIdx * 4 / 3 % 76 === 0) sB64Enc += "\r\n"; - nUint24 |= aBytes.getUint8(nIdx) << (16 >>> nMod3 & 24); - if (nMod3 === 2 || aBytes.byteLength - nIdx === 1) { - sB64Enc += String.fromCharCode(this.uint6ToB64(nUint24 >>> 18 & 63), this.uint6ToB64(nUint24 >>> 12 & 63), this.uint6ToB64(nUint24 >>> 6 & 63), this.uint6ToB64(nUint24 & 63)); - nUint24 = 0; +} +class IconsVisual { + update() {} + constructor(icons){ + this.icons = icons; + } +} +class Icons { + get atlas() { + return this._rasterizer.atlas; + } + get count() { + return this._keys.size; + } + constructor(core, rasterizer){ + this._core = core; + this._rasterizer = rasterizer; + this._keys = new Set(); + this._previousSize = 0; + this.items = {}; + } + add(key, imgData) { + if (!this._keys.has(key)) { + this._keys.add(key); + this._rasterizer.draw(key, imgData); + } + } + update() { + if (this._hasChanged) { + this._hasChanged = false; + this._core.log.write((0, _mainJs.LogLevel).info, `${this.key} added ${this._keys.size - this._previousSize} new items`); + this._previousSize = this._keys.size; + if (this.hasChangedCallback) this.hasChangedCallback(); + } + } + toJSON() { + const items = []; + for(let key in this.items){ + const item = this.items[key]; + items.push(item.toJSON()); + } + return { + key: this.key, + items: items + }; + } +} +class IconsAtlas { + constructor(width, height){ + const canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + const context = canvas.getContext("2d"); + context.clearRect(0, 0, width, height); + this.imageData = context.getImageData(0, 0, width, height); + this.x = 0; + this.top = new Uint16Array(width); + } +} +class IconsRasterizer { + get icons() { + return this._icons; + } + get atlas() { + return this._atlas; + } + constructor(core, options){ + let start = performance.now(); + this._core = core; + this._atlas = options.atlas; + this._border = options.border; + this._maxDistance = options.maxDistance; + this._edgeValue = options.edgeValue; + this._key = options.key; + this._icons = new Icons(core, this); + this._icons.key = this._key; + const iconRasterizerOptions = { + border: this._border, + edgeValue: this._edgeValue, + maxDistance: this._maxDistance + }; + this._iconRasterizer = new IconRasterizer(core, iconRasterizerOptions); + this._core.log.write((0, _mainJs.LogLevel).info, `icons rasterizer ${Math.round(window.performance.now() - start)}ms`); + } + draw(key, imgData) { + const item = this._iconRasterizer.draw(key, imgData); + if (item) { + const texWidth = item.width + 2 * this._border; + const texHeight = item.height + 2 * this._border; + const width = this._atlas.imageData.width; + const height = this.atlas.imageData.height; + if (this._atlas.x + texWidth > width - 1) this._atlas.x = 0; + let y = 0; + for(let x = this._atlas.x; x < this._atlas.x + texWidth; x++)y = Math.max(y, this._atlas.top[x]); + if (y + texHeight > height - 1) this._core.log.write((0, _mainJs.LogLevel).warn, `${this._icons.key} height overflow`); + for(let x = this._atlas.x; x < this._atlas.x + texWidth; x++)this._atlas.top[x] = y + texHeight; + const halfTexelOffsetX = 0.5 / width; + const halfTexelOffsetY = 0.5 / height; + item.u0 = this._atlas.x / width + halfTexelOffsetX; + item.v0 = y / height + halfTexelOffsetY; + item.u1 = (this._atlas.x + texWidth) / width - halfTexelOffsetX; + item.v1 = (y + texHeight) / height - halfTexelOffsetY; + this._icons.items[key] = item; + for(let i = 0; i < item.distances.length; i++){ + const distance = item.distances[i]; + const dataX = i % texWidth; + const dataY = Math.floor(i / texWidth); + const offset = (this._atlas.x + dataX + (y + dataY) * width) * 4; + this._atlas.imageData.data[offset + 0] = distance; + this._atlas.imageData.data[offset + 1] = distance; + this._atlas.imageData.data[offset + 2] = distance; + this._atlas.imageData.data[offset + 3] = 0xff; } + this._atlas.x += texWidth; } - return sB64Enc.substr(0, sB64Enc.length - 2 + nMod3) + (nMod3 === 2 ? "" : nMod3 === 1 ? "=" : "=="); } } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iwbqp":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "BinHelper", ()=>BinHelper); -class BinHelper { - static quantile(options) { - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? options.ids.length : options.count; - const itemsPerBin = count / options.bins; - let bin = 0; - if (options.froms && options.tos) { - const firstId = options.ids[offset]; - options.froms[0] = options.values[firstId]; +class IconRasterizer { + constructor(core, options){ + let start = performance.now(); + this._core = core; + this._border = options.border; + this._maxDistance = options.maxDistance; + this._edgeValue = options.edgeValue; + this._core.log.write((0, _mainJs.LogLevel).info, `icon rasterizer ${Math.round(window.performance.now() - start)}ms`); + } + draw(key, imgData0) { + const sizeX = imgData0.width; + const sizeY = imgData0.height; + const canvas = document.createElement("canvas"); + const width = sizeX + 2 * this._border; + const height = sizeY + 2 * this._border; + canvas.width = width; + canvas.height = height; + let length = width * height; + this._gridOuter = new Float64Array(length); + this._gridInner = new Float64Array(length); + length = Math.max(width, height); + this._f = new Float64Array(length); + this._z = new Float64Array(length + 1); + this._v = new Uint16Array(length); + length = width * height; + const distances = new Uint8ClampedArray(length); + const gradientsX = new Uint8ClampedArray(length); + const gradientsY = new Uint8ClampedArray(length); + const pixels = new Uint8ClampedArray(length); + const item = new Icon(); + item.key = key; + item.distances = distances; + item.gradientsX = gradientsX; + item.gradientsY = gradientsY; + item.pixels = pixels; + item.width = sizeX; + item.height = sizeY; + const ctx = canvas.getContext("2d", { + willReadFrequently: true + }); + ctx.clearRect(this._border, this._border, sizeX, sizeY); + ctx.putImageData(imgData0, this._border, this._border); + const imgData1 = ctx.getImageData(this._border, this._border, sizeX, sizeY); + for(let i = 0; i < length; i++){ + this._gridOuter[i] = Number.MAX_VALUE; + this._gridInner[i] = 0; } - for(let i = 0; i < count; i++){ - const id = options.ids[i + offset]; - if (i > Math.floor(itemsPerBin * (bin + 1))) { - bin++; - if (options.froms && options.tos) { - options.tos[bin - 1] = options.values[id]; - const nextId = options.ids[i + offset + 1]; - options.froms[bin] = options.values[nextId]; + for(let y = 0; y < sizeY; y++)for(let x = 0; x < sizeX; x++){ + const a = imgData1.data[4 * (y * sizeX + x) + 3] / 0xff; + if (a > 0) { + const j = (y + this._border) * width + x + this._border; + if (a == 1) { + this._gridOuter[j] = 0; + this._gridInner[j] = Number.MAX_VALUE; + pixels[j] = 0xff; + } else { + const d = 0.5 - a; + this._gridOuter[j] = d > 0 ? d * d : 0; + this._gridInner[j] = d < 0 ? d * d : 0; } } - options.binIds[id] = bin; } - if (options.froms && options.tos) { - const lastId = options.ids[count - 1 + offset]; - options.tos[options.bins - 1] = options.values[lastId]; + this._edt(this._gridOuter, 0, 0, width, height, width, this._f, this._v, this._z); + this._edt(this._gridInner, this._border, this._border, sizeX, sizeY, width, this._f, this._v, this._z); + const distances2 = new Float32Array(length); + for(let i = 0; i < length; i++){ + const distance = Math.sqrt(this._gridOuter[i]) - Math.sqrt(this._gridInner[i]); + distances[i] = Math.round(this._edgeValue - distance * 0xff / this._maxDistance); + distances2[i] = distance; } - return Math.floor(itemsPerBin); - } - static bin(options) { - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? options.ids.length : options.count; - const counts = options.counts ? options.counts : new Float64Array(options.bins); - let minValue = options.minValue; - let maxValue = options.maxValue; - if (options.isDiscrete || maxValue == minValue) { - minValue -= 0.5; - maxValue += 0.5; + for(let i = 0; i < length; i++){ + const x = i % width; + const y = Math.floor(i / width); + const d = distances2[i]; + const sign = d < 0 ? -1 : 1; + const x0 = x > 0 ? distances2[i - 1] : Number.MAX_VALUE; + const x1 = x < width - 1 ? distances2[i + 1] : Number.MAX_VALUE; + const y0 = y > 0 ? distances2[i - width] : Number.MAX_VALUE; + const y1 = y < height - 1 ? distances2[i + width] : Number.MAX_VALUE; + let gradientX = sign * x0 < sign * x1 ? d - x0 : x1 - d; + let gradientY = sign * y0 < sign * y1 ? y0 - d : d - y1; + gradientsX[i] = Math.round((gradientX * 0.5 + 0.5) * 0xff); + gradientsY[i] = Math.round((gradientY * 0.5 + 0.5) * 0xff); } - const binSize = (maxValue - minValue) / options.bins; - let maxCount = 0; - for(let i = 0; i < count; i++){ - const id = options.ids[i + offset]; - const value = options.values[id]; - const binId = Math.max(Math.min(Math.floor((value - minValue) / binSize), options.bins - 1), 0); - options.binIds[id] = binId; - counts[binId]++; - maxCount = Math.max(counts[binId], maxCount); + return item; + } + _edt(data, x0, y0, width, height, gridSize, f, v, z) { + for(let x = x0; x < x0 + width; x++)this._edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); + for(let y = y0; y < y0 + height; y++)this._edt1d(data, y * gridSize + x0, 1, width, f, v, z); + } + _edt1d(grid, offset, stride, n, f, v, z) { + v[0] = 0; + z[0] = -Number.MAX_VALUE; + z[1] = Number.MAX_VALUE; + f[0] = grid[offset]; + for(let q = 1, k = 0, s = 0; q < n; q++){ + f[q] = grid[offset + q * stride]; + const q2 = q * q; + do { + const r = v[k]; + s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; + }while (s <= z[k] && --k > -1); + k++; + v[k] = q; + z[k] = s; + z[k + 1] = Number.MAX_VALUE; } - if (options.froms && options.tos) { - for(let i1 = 0; i1 < options.bins; i1++)if (options.isDiscrete || maxValue == minValue) { - options.froms[i1] = Math.ceil(minValue + binSize * i1); - options.tos[i1] = Math.floor(minValue + binSize * (i1 + 1)); - } else { - options.froms[i1] = minValue + binSize * i1; - options.tos[i1] = minValue + binSize * (i1 + 1); - } + for(let q = 0, k = 0; q < n; q++){ + while(z[k + 1] < q)k++; + const r = v[k]; + const qr = q - r; + grid[offset + q * stride] = f[r] + qr * qr; } - return maxCount; - } - static maxBins(minValue, maxValue, isDiscrete, maxBins) { - if (isDiscrete) return Math.min(maxValue - minValue + 1, maxBins); - else return maxBins; } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eUJOG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5C4Hk":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ColorHelper", ()=>ColorHelper); +parcelHelpers.export(exports, "Controller", ()=>(0, _controllerJs.Controller)); +parcelHelpers.export(exports, "ControllerVisual", ()=>(0, _controllerJs.ControllerVisual)); +parcelHelpers.export(exports, "Label", ()=>(0, _labelsJs.Label)); +parcelHelpers.export(exports, "LabelVisual", ()=>(0, _labelsJs.LabelVisual)); +parcelHelpers.export(exports, "LabelSet", ()=>(0, _labelsJs.LabelSet)); +parcelHelpers.export(exports, "TransitionLabelSet", ()=>(0, _labelsJs.TransitionLabelSet)); +parcelHelpers.export(exports, "LabelSetVisual", ()=>(0, _labelsJs.LabelSetVisual)); +parcelHelpers.export(exports, "ImageVisual", ()=>(0, _imageJs.ImageVisual)); +parcelHelpers.export(exports, "ImageQuad", ()=>(0, _imageJs.ImageQuad)); +parcelHelpers.export(exports, "ImageSphere", ()=>(0, _imageJs.ImageSphere)); +parcelHelpers.export(exports, "NominalKey", ()=>(0, _keysJs.NominalKey)); +var _controllerJs = require("./controller.js"); +var _labelsJs = require("./labels.js"); +var _imageJs = require("./image.js"); +var _keysJs = require("./keys.js"); + +},{"./controller.js":"f5tIG","./labels.js":"PwNrz","./image.js":"kwtZG","./keys.js":"bmBQh","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"PwNrz":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class ColorHelper { - static luminance(rgb) { - return rgb[0] * ColorHelper.LUMINANCE[0] + rgb[1] * ColorHelper.LUMINANCE[1] + rgb[2] * ColorHelper.LUMINANCE[2]; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LabelVisual", ()=>LabelVisual); +parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); +parcelHelpers.export(exports, "LabelBase", ()=>LabelBase); +parcelHelpers.export(exports, "Label", ()=>Label); +parcelHelpers.export(exports, "LabelSet", ()=>LabelSet); +parcelHelpers.export(exports, "TransitionLabelSet", ()=>TransitionLabelSet); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +var _textJs = require("../helpers/text.js"); +var _constantsJs = require("../constants.js"); +var _vertexJs = require("../vertex.js"); +var _pickJs = require("../helpers/pick.js"); +var _mathJs = require("../helpers/math.js"); +class LabelVisual { + render(elapsedTime, xrFrame) {} + update(elapsedTime) {} + constructor(label){ + this.label = label; } - static rgbToHex(r, g, b) { - const r2 = `0${Math.round(r * 255).toString(16)}`; - const g2 = `0${Math.round(g * 255).toString(16)}`; - const b2 = `0${Math.round(b * 255).toString(16)}`; - return `#${r2.substr(r2.length - 2, 2)}${g2.substr(g2.length - 2, 2)}${b2.substr(b2.length - 2, 2)}`; +} +class LabelSetVisual { + render(elapsedTime, xrFrame) {} + update(elapsedTime) {} + constructor(labelSet){ + this.label = labelSet; } - static rgbToHsv(r, g, b, hsv) { - let h, s, v, delta; - const min = Math.min(Math.min(r, g), b); - const max = Math.max(Math.max(r, g), b); - delta = max - min; - v = max; - if (delta == 0) { - h = -1; - if (max == 0) s = -1; - else s = 0; - hsv[0] = h; - hsv[1] = s; - hsv[2] = v; - } - s = delta / max; - if (r == max) h = (g - b) / delta; - else if (g == max) h = 2 + (b - r) / delta; - else h = 4 + (r - g) / delta; - h *= 60; - if (h < 0) h += 360; - hsv[0] = h; - hsv[1] = s; - hsv[2] = v; +} +class LabelBase { + get material() { + return this._material; } - static hsvToRgb(h, s, v, rgb) { - let sextant, r, g, b; - if (s == 0) { - r = g = b = v; - rgb[0] = r; - rgb[1] = g; - rgb[2] = b; - } - let frac, p, q, t; - h %= 360; - h /= 60; - sextant = Math.floor(h); - frac = h - sextant; - p = v * (1 - s); - q = v * (1 - s * frac); - t = v * (1 - s * (1 - frac)); - switch(sextant){ - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - default: - r = v; - g = p; - b = q; - break; - } - rgb[0] = r; - rgb[1] = g; - rgb[2] = b; + get vertices() { + return this._vertices; } -} -ColorHelper.LUMINANCE = (0, _glMatrix.vec3).fromValues(0.2126, 0.7152, 0.0722); - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lgH3H":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "CsvHelper", ()=>CsvHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("../main.js"); -class CsvHelper { - constructor(core){ - this.QUOTE = '"'; - this.DELIMETER = ","; - this.LINE_BREAKS = [ - "\n", - "\r" - ]; - this._core = core; + get verticesView() { + return this._verticesView; } - readline(text, row) { - return this.read(text, row, 1)[0]; + get indices() { + return this._indices; } - read(text, firstRow = 0, maxRows = Number.MAX_VALUE) { - const start = window.performance.now(); - const rows = []; - let rowBuffer = []; - let row = 0; - let columnBuffer = ""; - let quoted = false; - for(let i = 0; i < text.length; i++){ - const char = text.charAt(i); - if (char == this.QUOTE) { - if (text.charAt(i + 1) == this.QUOTE) { - i++; - columnBuffer += this.QUOTE; - } else quoted = !quoted; - } else if (quoted) columnBuffer += char; - else { - if (char == this.DELIMETER) { - rowBuffer.push(columnBuffer); - columnBuffer = ""; - } else if (this.LINE_BREAKS.indexOf(char) > -1) { - rowBuffer.push(columnBuffer); - columnBuffer = ""; - i++; - while(this.LINE_BREAKS.indexOf(text.charAt(i + 1)) > -1)i++; - if ((row++) >= firstRow) rows.push(rowBuffer); - rowBuffer = []; - if (rows.length == maxRows) break; - } else columnBuffer += char; - } - } - if (columnBuffer != "") rowBuffer.push(columnBuffer); - if (rowBuffer.length > 0) rows.push(rowBuffer); - if (maxRows > 1) this._core.log.write((0, _mainJs.LogLevel).info, `csv ${rows.length} rows ${Math.round(window.performance.now() - start)}ms`); - return rows; + get indexCount() { + return this._indexCount; } -} - -},{"../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"izKmq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FacetHelper", ()=>FacetHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("../main.js"); -class FacetHelper { - constructor(core){ - this._core = core; + get isInitialized() { + return this._isInitialized; } - split1d(ids, facetsX, valuesX, orderedIds, facetIds, offsets, counts) { - this.split3d(ids, facetsX, undefined, undefined, valuesX, null, null, orderedIds, facetIds, offsets, counts); + get mMatrix() { + return this._mMatrix; } - split2d(ids, facetsX, facetsY, valuesX, valuesY, orderedIds, facetIds, offsets, counts) { - this.split3d(ids, facetsX, facetsY, undefined, valuesX, valuesY, null, orderedIds, facetIds, offsets, counts); + get scale() { + return this._scale; } - split3d(ids, facetsX, facetsY, facetsZ, valuesX, valuesY, valuesZ, orderedIds, facetIds, offsets, counts) { - if (valuesX && facetIds.length != valuesX.length) this._core.log.write((0, _mainJs.LogLevel).warn, "facet helper split1d facetIds should be same length as facetValuesX"); - if (valuesY && facetIds.length != valuesY.length) this._core.log.write((0, _mainJs.LogLevel).warn, "facet helper split1d facetIds should be same length as facetValuesY"); - if (valuesZ && facetIds.length != valuesY.length) this._core.log.write((0, _mainJs.LogLevel).warn, "facet helper split1d facetIds should be same length as facetValuesY"); - const start = window.performance.now(); - if (facetsX === undefined) facetsX = 1; - if (facetsY === undefined) facetsY = 1; - if (facetsZ === undefined) facetsZ = 1; - const maxFacetId = facetsX * facetsY * facetsZ - 1; - for(let i = 0; i < ids.length; i++){ - const id = ids[i]; - const valueX = valuesX ? valuesX[id] : 0; - const valueY = valuesY ? valuesY[id] : 0; - const valueZ = valuesZ ? valuesZ[id] : 0; - const facetId = valueX + valueY * facetsX + valueZ * facetsX * facetsZ; - facetIds[id] = facetId; - if (facetId > maxFacetId) this._core.log.write((0, _mainJs.LogLevel).warn, "facet overflow"); - counts[facetId]++; + set scale(value) { + if (this._scale != value) { + this._scale = value; + this._hasChanged = true; } - let offset = 0; - for(let i1 = 0; i1 < offsets.length; i1++){ - const count = counts[i1]; - offsets[i1] = offset; - offset += count; + } + get font() { + return this._font; + } + set font(value) { + if (this._font != value) { + this._font = value; + this._hasChanged = true; } - const tempOffsets = new Uint32Array(offsets); - for(let i2 = 0; i2 < ids.length; i2++){ - const id1 = ids[i2]; - const facetId1 = facetIds[id1]; - offset = tempOffsets[facetId1]++; - orderedIds[offset] = id1; + } + get rotation() { + return this._rotation; + } + set rotation(value) { + if (this._rotation != value) { + this._rotation = value; + this._hasChanged = true; } - this._core.log.write((0, _mainJs.LogLevel).info, `facet split ${Math.round(window.performance.now() - start)}ms`); } - wrap1d(ids, values, columns, coordsX, coordsY) { - const start = window.performance.now(); - let rows = 0; - for(let i = 0; i < ids.length; i++){ - const id = ids[i]; - const value = values[id]; - coordsX[id] = value % columns; - const row = Math.floor(value / columns); - coordsY[id] = row; - rows = Math.max(row, rows); + set reverseX(value) { + if (this._reverseX != value) { + this._reverseX = value; + this._hasChanged = true; } - this._core.log.write((0, _mainJs.LogLevel).info, `facet wrap ${Math.round(window.performance.now() - start)}ms`); - return rows + 1; } -} - -},{"../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fhlqr":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "HexHelper", ()=>HexHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mainJs = require("../main.js"); -var _angleJs = require("./angle.js"); -class HexHelper { - static width(size, orientation) { - if (orientation == (0, _mainJs.HexOrientation).pointyTop) return (0, _constantsJs.Constants).ROOT_THREE * size; - else return 2 * size; + set reverseY(value) { + if (this._reverseY != value) { + this._reverseY = value; + this._hasChanged = true; + } } - static height(size, orientation) { - if (orientation == (0, _mainJs.HexOrientation).pointyTop) return 2 * size; - else return (0, _constantsJs.Constants).ROOT_THREE * size; + set reverseZ(value) { + if (this._reverseZ != value) { + this._reverseZ = value; + this._hasChanged = true; + } } - static pointyHexCorner(center, size, i, position) { - const angle = (0, _angleJs.AngleHelper).degreesToRadians(60 * i - 30); - position[0] = center[0] + size * Math.cos(angle); - position[1] = center[1] + size * Math.sin(angle); + get horizontalAlignment() { + return this._horizontalAlignment; } - static cubeToAxial(cube, hex) { - hex[0] = cube[0]; - hex[1] = cube[2]; + set horizontalAlignment(value) { + if (this._horizontalAlignment != value) { + this._horizontalAlignment = value; + this._hasChanged = true; + } } - static axialToCube(hex, cube) { - const x = hex[0]; - const z = hex[1]; - const y = -x - z; - cube[0] = x; - cube[1] = y; - cube[2] = z; + get verticalAlignment() { + return this._verticalAlignment; } - static cubeToOddr(cube, hex) { - const col = cube[0] + (cube[2] - (cube[2] & 1)) / 2; - const row = cube[2]; - hex[0] = col; - hex[1] = row; + set verticalAlignment(value) { + if (this._verticalAlignment != value) { + this._verticalAlignment = value; + this._hasChanged = true; + } } - static oddrToCube(hex, cube) { - const x = hex[0] - (hex[1] - (hex[1] & 1)) / 2; - const z = hex[1]; - const y = -x - z; - cube[0] = x; - cube[1] = y; - cube[2] = z; + get offsetX() { + return this._offsetX; } - static pointyHexToPixel(hex, size, point) { - point[0] = size * ((0, _constantsJs.Constants).ROOT_THREE * hex[0] + (0, _constantsJs.Constants).ROOT_THREE / 2 * hex[1]); - point[1] = size * (1.5 * hex[1]); + set offsetX(value) { + if (this._offsetX != value) { + this._offsetX = value; + this._hasChanged = true; + } } - static pixelToPointyHex(point, size, hex) { - hex[0] = ((0, _constantsJs.Constants).ROOT_THREE / 3 * point[0] - 1 / 3 * point[1]) / size; - hex[1] = 2 / 3 * point[1] / size; - this.hexRound(hex, hex); + get offsetY() { + return this._offsetY; } - static hexRound(hex, hexRound) { - const cube = this._vec3; - this.axialToCube(hex, cube); - this.cubeRound(cube, cube); - this.cubeToAxial(cube, hexRound); + set offsetY(value) { + if (this._offsetY != value) { + this._offsetY = value; + this._hasChanged = true; + } } - static cubeRound(cube, cubeRound) { - let rx = Math.round(cube[0]); - let ry = Math.round(cube[1]); - let rz = Math.round(cube[2]); - const x_diff = Math.abs(rx - cube[0]); - const y_diff = Math.abs(ry - cube[1]); - const z_diff = Math.abs(rz - cube[2]); - if (x_diff > y_diff && x_diff > z_diff) rx = -ry - rz; - else if (y_diff > z_diff) ry = -rx - rz; - else rz = -rx - ry; - cubeRound[0] = rx; - cubeRound[1] = ry; - cubeRound[2] = rz; + get offsetZ() { + return this._offsetZ; } -} -HexHelper._vec3 = (0, _glMatrix.vec3).create(); - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../main.js":"1Kju3","./angle.js":"eKtPm","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3xoe6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "HexBinHelper", ()=>HexBinHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mainJs = require("../main.js"); -var _hexJs = require("./hex.js"); -class HexBinHelper { - static bin(options) { - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? options.ids.length : options.count; - const width = (options.maxValueX - options.minValueX) / options.binsX; - const minValueX = options.minValueX - width / 2; - const binsX = options.binsX + 1; - const size = width / (0, _constantsJs.Constants).ROOT_THREE; - const height = 2 * size; - const heightBetweenCenters = 3 * height / 4; - const binsY = Math.ceil((options.maxValueY - options.minValueY) / heightBetweenCenters) + 1; - const minValueY = options.minValueY; - const minQ = -Math.floor(binsY / 2); - const maxBins = (binsX - minQ) * binsY; - const binCounts = new Float64Array(maxBins); - const binLookup = new Uint32Array(maxBins); - const point = (0, _glMatrix.vec2).create(); - const hex = (0, _glMatrix.vec2).create(); - let nonEmptyBins = 0; - let minCount = Number.MAX_VALUE; - let maxCount = -Number.MAX_VALUE; - for(let i = 0; i < count; i++){ - const id = options.ids[i + offset]; - point[0] = options.valuesX[id] - minValueX; - point[1] = options.valuesY[id] - minValueY; - (0, _hexJs.HexHelper).pixelToPointyHex(point, size, hex); - const q = hex[0] - minQ; - const r = hex[1]; - const binId = q + r * (binsX - minQ); - if (binCounts[binId] == 0) { - binLookup[binId] = nonEmptyBins; - nonEmptyBins++; - } - binCounts[binId]++; - options.binIds[id] = binId; - minCount = Math.min(minCount, binCounts[binId]); - maxCount = Math.max(maxCount, binCounts[binId]); - } - const positionsX = new Float64Array(nonEmptyBins); - const positionsY = new Float64Array(nonEmptyBins); - const counts = new Uint32Array(nonEmptyBins); - const lookup = {}; - for(let i1 = 0; i1 < maxBins; i1++){ - const count1 = binCounts[i1]; - if (count1 > 0) { - const index = binLookup[i1]; - lookup[i1] = index; - counts[index] = count1; - const q1 = i1 % (binsX - minQ); - const r1 = Math.floor(i1 / (binsX - minQ)); - hex[0] = q1 + minQ; - hex[1] = r1; - (0, _hexJs.HexHelper).pointyHexToPixel(hex, size, point); - positionsX[index] = point[0] + minValueX; - positionsY[index] = point[1] + minValueY; - } + set offsetZ(value) { + if (this._offsetZ != value) { + this._offsetZ = value; + this._hasChanged = true; } - const result = { - binIds: options.binIds, - positionsX: positionsX, - positionsY: positionsY, - counts: counts, - minCount: minCount, - maxCount: maxCount, - orientation: (0, _mainJs.HexOrientation).pointyTop, - size: size, - lookup: lookup, - binsY: binsY - }; - return result; } -} - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../main.js":"1Kju3","./hex.js":"fhlqr","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ckdqy":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LineHelper", ()=>LineHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("../main.js"); -class LineHelper { - constructor(core){ - this._core = core; + get maxGlyphTop() { + return this._maxGlyphTop; } - connect(orderedIds, series, toIds, offset = 0, count = orderedIds.length) { - const start = window.performance.now(); - const lines = new Set(); - const lookup = {}; - for(let i = offset; i < count; i++){ - const id = orderedIds[i + offset]; - const value = series[id]; - const fromId = lookup[value]; - if (fromId != null) { - toIds[fromId] = id; - lines.add(value); - } - lookup[value] = id; - toIds[id] = id; + set maxGlyphTop(value) { + if (this._maxGlyphTop != value) { + this._maxGlyphTop = value; + this._hasChanged = true; } - this._core.log.write((0, _mainJs.LogLevel).info, `${lines.size} lines connected ${Math.round(window.performance.now() - start)}ms`); - return lines.size; } -} - -},{"../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"haUyw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "MercatorHelper", ()=>MercatorHelper); -parcelHelpers.export(exports, "AlbersHelper", ()=>AlbersHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mathJs = require("./math.js"); -var _angleJs = require("./angle.js"); -var _constantsJs = require("../constants.js"); -class MercatorHelper { - static project(longitude, latitude, xy) { - const x = longitude / 180; - latitude = (0, _mathJs.MathHelper).clamp(latitude, this.minLatitude, this.maxLatitude); - latitude = (0, _angleJs.AngleHelper).degreesToRadians(latitude); - const sinLatitude = Math.sin(latitude); - let y = Math.log((1 + sinLatitude) / (1 - sinLatitude)) / 2; - y = (0, _mathJs.MathHelper).clamp(y / Math.PI, this.minY, this.maxY); - xy[0] = x; - xy[1] = y; + get maxGlyphHeight() { + return this._maxGlyphHeight; } - static unproject(x, y, lonLat) { - const longitude = x * 180; - y *= Math.PI; - let latitude = (0, _constantsJs.Constants).PI_OVER_TWO - 2 * Math.atan(Math.exp(-y)); - latitude = (0, _angleJs.AngleHelper).radiansToDegrees(latitude); - lonLat[0] = longitude; - lonLat[1] = latitude; + set maxGlyphHeight(value) { + if (this._maxGlyphHeight != value) { + this._maxGlyphHeight = value; + this._hasChanged = true; + } } -} -MercatorHelper.minLatitude = -85.05112878; -MercatorHelper.maxLatitude = 85.05112878; -MercatorHelper.minLongitude = -180; -MercatorHelper.maxLongitude = 180; -MercatorHelper.minX = -1; -MercatorHelper.minY = -1; -MercatorHelper.maxX = 1; -MercatorHelper.maxY = 1; -class AlbersHelper { - static project(longitude, latitude, xy) { - const lat1 = (0, _angleJs.AngleHelper).degreesToRadians(latitude); - const lon1 = (0, _angleJs.AngleHelper).degreesToRadians(longitude); - const n = 0.5 * (Math.sin(this._phi1) + Math.sin(this._phi2)); - const c = Math.cos(this._phi1); - const C = c * c + 2 * n * Math.sin(this._phi1); - const p0 = Math.sqrt(C - 2 * n * Math.sin(this._lat0)) / n; - const theta = n * (lon1 - this._lon0); - const p = Math.sqrt(C - 2 * n * Math.sin(lat1)) / n; - const x = p * Math.sin(theta); - const y = p0 - p * Math.cos(theta); - xy[0] = x; - xy[1] = y; + constructor(core, options){ + this._core = core; + this._offset = (0, _glMatrix.vec3).create(); + this._vec3 = (0, _glMatrix.vec3).create(); + this._vec4 = (0, _glMatrix.vec4).create(); + this._mMatrix = (0, _glMatrix.mat4).create(); + this._indexCount = 0; + this._maxGlyphs = options.maxGlyphs; + this._textMetric = { + width: 0, + maxHeight: 0, + maxTop: 0 + }; + this.scale = options.scale ? options.scale : 1; + this.offsetX = options.offsetX ? options.offsetX : 0; + this.offsetY = options.offsetY ? options.offsetY : 0; + this.offsetZ = options.offsetZ ? options.offsetZ : 0; + this.reverseX = options.reverseX; + this.reverseY = options.reverseY; + this.reverseZ = options.reverseZ; + this.rotation = options.rotation; + this.maxGlyphTop = options.maxGlyphTop; + this.horizontalAlignment = options.horizontalAlignment === undefined ? (0, _mainJs.HorizontalAlignment).center : options.horizontalAlignment; + this.verticalAlignment = options.verticalAlignment === undefined ? (0, _mainJs.VerticalAlignment).center : options.verticalAlignment; + this._material = options.material; + this.borderWidth = core.config.textBorderWidth; + this.gamma = 0; } - static unproject(x, y, lonLat) { - const n = 0.5 * (Math.sin(this._phi1) + Math.sin(this._phi2)); - const c = Math.cos(this._phi1); - const C = c * c + 2 * n * Math.sin(this._phi1); - const p0 = Math.sqrt(C - 2 * n * Math.sin(this._lat0)) / n; - const theta = Math.atan(x / (p0 - y)); - const p = Math.sqrt(x * y + Math.pow(p0 - y, 2)); - const longitude = this._lon0 + theta / n; - const latitude = Math.asin((C - p * p * n * n) / (2 * n)); - lonLat[0] = (0, _angleJs.AngleHelper).radiansToDegrees(longitude); - lonLat[1] = (0, _angleJs.AngleHelper).radiansToDegrees(latitude); + initialize() { + this._vertices = new ArrayBuffer((0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES * this._maxGlyphs * 4); + this._verticesView = new DataView(this._vertices); + this._indices = new Uint32Array(this._maxGlyphs * 6); + this._isInitialized = true; } + update(elapsedTime) {} } -AlbersHelper._phi1 = (0, _angleJs.AngleHelper).degreesToRadians(29.5); -AlbersHelper._phi2 = (0, _angleJs.AngleHelper).degreesToRadians(45.5); -AlbersHelper._lat0 = (0, _angleJs.AngleHelper).degreesToRadians(37.5); -AlbersHelper._lon0 = (0, _angleJs.AngleHelper).degreesToRadians(-96); - -},{"./math.js":"fOnPF","./angle.js":"eKtPm","../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gotPg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "PaletteHelper", ()=>PaletteHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _colorJs = require("./color.js"); -var _mathJs = require("./math.js"); -class PaletteHelper { - static resample(colorsIn, divisionsOut, reverse) { - const divisionsIn = colorsIn.length / 3; - const colorsOut = new Uint8Array(divisionsOut * 4); - for(let i = 0; i < divisionsOut; i++){ - const positionOut = (i + 0.5) / divisionsOut; - const positionIn = positionOut * (divisionsIn - 1); - const stepIn = Math.floor(positionIn); - const fractIn = positionIn - stepIn; - const j = reverse ? divisionsOut - i - 1 : i; - colorsOut[j * 4] = (0, _mathJs.MathHelper).lerp(colorsIn[stepIn * 3], colorsIn[(stepIn + 1) * 3], fractIn); - colorsOut[j * 4 + 1] = (0, _mathJs.MathHelper).lerp(colorsIn[stepIn * 3 + 1], colorsIn[(stepIn + 1) * 3 + 1], fractIn); - colorsOut[j * 4 + 2] = (0, _mathJs.MathHelper).lerp(colorsIn[stepIn * 3 + 2], colorsIn[(stepIn + 1) * 3 + 2], fractIn); - colorsOut[j * 4 + 3] = 255; +class Label extends LabelBase { + get textAlignment() { + return this._textAlignment; + } + set textAlignment(value) { + if (this._textAlignment != value) { + this._textAlignment = value; + this._hasChanged = true; } - return colorsOut; } - static truncate(colorsIn, divisionsOut, reverse) { - const divisionsIn = colorsIn.length / 3; - const colorsOut = new Uint8Array(divisionsOut * 4); - for(let i = 0; i < Math.min(divisionsIn, divisionsOut); i++){ - const j = reverse ? divisionsOut - i - 1 : i; - colorsOut[j * 4] = colorsIn[i * 3]; - colorsOut[j * 4 + 1] = colorsIn[i * 3 + 1]; - colorsOut[j * 4 + 2] = colorsIn[i * 3 + 2]; - colorsOut[j * 4 + 3] = 255; + get text() { + return this._text; + } + set text(value) { + if (this._text != value) { + this._text = value; + this._hasChanged = true; } - return colorsOut; } - static resampleStops(stops, divisions, reverse) { - const colorsOut = new Uint8Array(divisions * 4); - let from = 0; - let to = 0; - for(let i = 0; i < divisions; i++){ - const positionOut = (i + 0.5) / divisions; - while(stops[from].position < positionOut && from < stops.length - 1)from++; - from = Math.max(from - 1, 0); - to = Math.min(from + 1, stops.length - 1); - const fromStop = stops[from]; - const toStop = stops[to]; - const fract = from == to ? 0 : (positionOut - fromStop.position) / (toStop.position - fromStop.position); - const j = reverse ? divisions - i - 1 : i; - colorsOut[j * 4] = (0, _mathJs.MathHelper).lerp(fromStop.r, toStop.r, fract); - colorsOut[j * 4 + 1] = (0, _mathJs.MathHelper).lerp(fromStop.g, toStop.g, fract); - colorsOut[j * 4 + 2] = (0, _mathJs.MathHelper).lerp(fromStop.b, toStop.b, fract); - colorsOut[j * 4 + 3] = 255; + constructor(core, options){ + super(core, options); + this._font = options.font || core.font; + this._text = options.text; + this._textAlignment = options.textAlignment === undefined ? (0, _mainJs.TextAlignment).left : options.textAlignment; + } + update(elapsedTime) { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + if (!this._text) { + this._indexCount = 0; + this.width = 0; + this.height = 0; + } else { + const widths = []; + const truncated = []; + let maxWidth = 0; + let maxGlyphHeight = 0; + let maxGlyphTop = 0; + let glyphs = 0; + for(let i = 0; i < this._text.length; i++){ + const text = (0, _textJs.TextHelper).truncate(this._text[i], this._maxGlyphs - glyphs); + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + widths.push(this._textMetric.width); + maxWidth = Math.max(this._textMetric.width, maxWidth); + maxGlyphHeight = Math.max(this._textMetric.maxHeight, maxGlyphHeight); + maxGlyphTop = Math.max(this._textMetric.maxTop, maxGlyphTop); + glyphs += text.length; + truncated.push(text); + if (glyphs >= this._maxGlyphs) break; + } + if (this._maxGlyphHeight) maxGlyphHeight = this._maxGlyphHeight; + if (this._maxGlyphTop) maxGlyphTop = this._maxGlyphTop; + const lineHeight = this._font.size; + const height = truncated.length * lineHeight; + switch(this._horizontalAlignment){ + case (0, _mainJs.HorizontalAlignment).left: + this._originX = this._offsetX + maxWidth / 2; + break; + case (0, _mainJs.HorizontalAlignment).center: + this._originX = this._offsetX; + break; + case (0, _mainJs.HorizontalAlignment).right: + this._originX = this._offsetX - maxWidth / 2; + break; + } + switch(this._verticalAlignment){ + case (0, _mainJs.VerticalAlignment).top: + this._originY = this._offsetY - height / 2; + break; + case (0, _mainJs.VerticalAlignment).center: + this._originY = this._offsetY; + break; + case (0, _mainJs.VerticalAlignment).bottom: + this._originY = this._offsetY + height / 2; + break; + } + glyphs = 0; + for(let i = 0; i < truncated.length; i++){ + switch(this._textAlignment){ + case (0, _mainJs.TextAlignment).left: + this._offset[0] = this._originX - maxWidth / 2; + break; + case (0, _mainJs.TextAlignment).center: + this._offset[0] = this._originX - widths[i] / 2; + break; + case (0, _mainJs.TextAlignment).right: + this._offset[0] = this._originX + maxWidth / 2 - widths[i]; + break; + } + this._offset[1] = this._originY + height / 2 - i * lineHeight - lineHeight / 2 - maxGlyphTop / 2; + const pickingId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickingId, (0, _mainJs.PickType).label, this._vec4); + const text = truncated[i]; + if (text.length > 0) { + (0, _textJs.TextHelper).addString(this._font, text, this._verticesView, this._indices, glyphs, (0, _constantsJs.Constants).VECTOR3_ZERO, 1, this._offset, null, this._vec4); + glyphs += text.length; + } + } + const scaling = this._scale / this._font.size; + this.width = maxWidth * scaling; + this.height = height * scaling; + this._indexCount = glyphs * 6; + (0, _glMatrix.vec3).set(this._vec3, scaling, scaling, scaling); + (0, _glMatrix.mat4).fromScaling(this._mMatrix, this._vec3); + if (this.hasChangedCallback) this.hasChangedCallback(); + } } - return colorsOut; } - static lerpRgb(from, to, divisions) { - const colors = new Uint8Array(divisions * 4); - for(let i = 0; i < divisions; i++){ - const amount = i / (divisions - 1); - colors[i * 4] = (0, _mathJs.MathHelper).lerp(from[0], to[0], amount); - colors[i * 4 + 1] = (0, _mathJs.MathHelper).lerp(from[1], to[1], amount); - colors[i * 4 + 2] = (0, _mathJs.MathHelper).lerp(from[2], to[2], amount); - colors[i * 4 + 3] = 0xff; +} +class LabelSet extends LabelBase { + get materials() { + return this._materials; + } + get minBoundsX() { + return this._minBoundsX; + } + set minBoundsX(value) { + if (this._minBoundsX != value) { + this._minBoundsX = value; + this._hasChanged = true; } - return colors; } - static lerpHsv(from, to, divisions) { - const colors = new Uint8Array(divisions * 4); - for(let i = 0; i < divisions; i++){ - const amount = i / (divisions - 1); - const h = (0, _mathJs.MathHelper).lerp(from[0], to[0], amount); - const s = (0, _mathJs.MathHelper).lerp(from[1], to[1], amount); - const v = (0, _mathJs.MathHelper).lerp(from[2], to[2], amount); - (0, _colorJs.ColorHelper).hsvToRgb(h, s, v, PaletteHelper._rgb); - colors[i * 4] = PaletteHelper._rgb[0] * 0xff; - colors[i * 4 + 1] = PaletteHelper._rgb[1] * 0xff; - colors[i * 4 + 2] = PaletteHelper._rgb[2] * 0xff; - colors[i * 4 + 3] = 0xff; + get minBoundsY() { + return this._minBoundsY; + } + set minBoundsY(value) { + if (this._minBoundsY != value) { + this._minBoundsY = value; + this._hasChanged = true; } - return colors; } -} -PaletteHelper._rgb = (0, _glMatrix.vec3).create(); - -},{"gl-matrix":"9GjEQ","./color.js":"eUJOG","./math.js":"fOnPF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dofsD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "PathHelper", ()=>PathHelper); -class PathHelper { - static getFilenameWithoutExtension(path) { - const dot = path.lastIndexOf("."); - if (dot == -1) return path; - else { - const start = path.lastIndexOf("/") == -1 ? 0 : path.lastIndexOf("/") + 1; - return path.substring(start, dot); + get minBoundsZ() { + return this._minBoundsZ; + } + set minBoundsZ(value) { + if (this._minBoundsZ != value) { + this._minBoundsZ = value; + this._hasChanged = true; } } - static getExtension(path) { - const dot = path.lastIndexOf("."); - if (dot == -1 || dot == path.length - 1) return null; - else return path.substring(dot + 1, path.length); + get maxBoundsX() { + return this._maxBoundsX; } - static getFilename(path) { - if (path.lastIndexOf("/") == -1) return path; - else { - const start = path.lastIndexOf("/") + 1; - return path.substring(start, path.length); + set maxBoundsX(value) { + if (this._maxBoundsX != value) { + this._maxBoundsX = value; + this._hasChanged = true; } } - static getPath(path) { - if (path.lastIndexOf("/") == -1) return ""; - else return path.substring(0, path.lastIndexOf("/")); + get maxBoundsY() { + return this._maxBoundsY; } - static combine(first, second) { - const seperator = first.lastIndexOf("/") == first.length - 1; - if (second.indexOf("/") == 0) { - if (seperator) return first.substring(0, first.length - 1) + second; - else return first + second; - } else { - if (seperator) return first + second; - else return first + "/" + second; + set maxBoundsY(value) { + if (this._maxBoundsY != value) { + this._maxBoundsY = value; + this._hasChanged = true; } } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"h48Ba":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "TableHelper", ()=>TableHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("../main.js"); -var _tableJs = require("../tables/table.js"); -class TableHelper { - constructor(core){ - this._core = core; + get maxBoundsZ() { + return this._maxBoundsZ; } - compatibleTypes(data, firstRow = 0, maxRows = Number.MAX_VALUE) { - const start = window.performance.now(); - const types = []; - const integers = []; - let values = data[firstRow]; - let parsedFloat, parsedDate; - for(let i = 0; i < values.length; i++){ - const value = values[i]; - parsedFloat = Number(value); - parsedDate = Date.parse(value); - let integer = false; - let type; - if (!isNaN(parsedFloat)) { - type = (0, _tableJs.ColumnType).float; - integer = Number.isSafeInteger(parsedFloat); - } else if (!isNaN(parsedDate)) type = (0, _tableJs.ColumnType).date; - else type = (0, _tableJs.ColumnType).string; - types.push(type); - integers.push(integer); + set maxBoundsZ(value) { + if (this._maxBoundsZ != value) { + this._maxBoundsZ = value; + this._hasChanged = true; } - for(let i1 = firstRow + 1; i1 < Math.min(data.length, firstRow + maxRows); i1++){ - values = data[i1]; - for(let j = 0; j < values.length; j++)if (types[j] != (0, _tableJs.ColumnType).string) { - const value1 = values[j]; - parsedFloat = Number(value1); - if (types[j] == (0, _tableJs.ColumnType).float) { - if (isNaN(parsedFloat)) { - types[j] = (0, _tableJs.ColumnType).string; - integers[j] = false; - } else if (integers[j]) integers[j] = Number.isSafeInteger(parsedFloat); - } else if (types[j] == (0, _tableJs.ColumnType).date) { - parsedDate = Date.parse(value1); - if (isNaN(parsedDate)) types[j] = (0, _tableJs.ColumnType).string; - } - } + } + get positionsX() { + return this._positionsX; + } + set positionsX(value) { + if (this._positionsX != value) { + this._positionsX = value; + this._hasChanged = true; } - const compatibleTypes = []; - for(let i2 = 0; i2 < types.length; i2++){ - let compatible = types[i2] | (0, _tableJs.ColumnType).string; - if (integers[i2]) compatible |= (0, _tableJs.ColumnType).integer; - compatibleTypes.push(compatible); + } + get positionsY() { + return this._positionsY; + } + set positionsY(value) { + if (this._positionsY != value) { + this._positionsY = value; + this._hasChanged = true; } - this._core.log.write((0, _mainJs.LogLevel).info, `compatible types ${Math.round(window.performance.now() - start)}ms`); - return compatibleTypes; } - inferTypes(data, firstRow = 0, maxRows = Number.MAX_VALUE) { - const columnTypes = []; - const compatibleTypes = this.compatibleTypes(data, firstRow, maxRows); - for(let i = 0; i < compatibleTypes.length; i++){ - let columnType; - const compatibleType = compatibleTypes[i]; - if (compatibleType & (0, _tableJs.ColumnType).integer) columnType = (0, _tableJs.ColumnType).integer; - else if (compatibleType & (0, _tableJs.ColumnType).float) columnType = (0, _tableJs.ColumnType).float; - else if (compatibleType & (0, _tableJs.ColumnType).date) columnType = (0, _tableJs.ColumnType).date; - else columnType = (0, _tableJs.ColumnType).string; - columnTypes.push(columnType); + get positionsZ() { + return this._positionsZ; + } + set positionsZ(value) { + if (this._positionsZ != value) { + this._positionsZ = value; + this._hasChanged = true; } - return columnTypes; } -} - -},{"../main.js":"1Kju3","../tables/table.js":"gsKwH","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gsKwH":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Table", ()=>Table); -parcelHelpers.export(exports, "ColumnType", ()=>ColumnType); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _filterJs = require("./filter.js"); -class Table { - get headings() { - return this._headings; + get positionScalingX() { + return this._positionScalingX; } - get all() { - return this._all; + set positionScalingX(value) { + if (this._positionScalingX != value) { + this._positionScalingX = value; + this._hasChanged = true; + } } - get isInitialized() { - return this._isInitialized; + get positionScalingY() { + return this._positionScalingY; } - get filter() { - return this._filter; + set positionScalingY(value) { + if (this._positionScalingY != value) { + this._positionScalingY = value; + this._hasChanged = true; + } } - set filter(value) { - if (this._filter !== value) { - this._filter = value; - if (this.filterChangedCallback) this.filterChangedCallback(); + get positionScalingZ() { + return this._positionScalingZ; + } + set positionScalingZ(value) { + if (this._positionScalingZ != value) { + this._positionScalingZ = value; + this._hasChanged = true; } } - getColumnType(column) { - return this._columnTypes[column]; + get rotations() { + return this._rotations; } - isColumnDiscrete(column) { - return (this._columnTypes[column] & ColumnType.discrete) > 0; + set rotations(value) { + if (this._rotations != value) { + this._rotations = value; + this._hasChanged = true; + } } - isColumnNumeric(column) { - return (this._columnTypes[column] & ColumnType.numeric) > 0; + get offsetsX() { + return this._offsetsX; } - isColumnContinuous(column) { - return (this._columnTypes[column] & ColumnType.continuous) > 0; + set offsetsX(value) { + if (this._offsetsX != value) { + this._offsetsX = value; + this._hasChanged = true; + } } - constructor(core, headings, data, columnTypes){ - this._core = core; - this._headings = headings; - this._data = data; - this._columnTypes = columnTypes; - this._numericValues = Array(columnTypes.length).fill(null); - const indices = new Uint32Array(data.length); - for(let i = 0; i < indices.length; i++)indices[i] = i; - this._all = new (0, _filterJs.Filter)(core, indices, data, headings, columnTypes, this._numericValues); - this._isInitialized = true; + get offsetsY() { + return this._offsetsY; } - createFilter(ids) { - return new (0, _filterJs.Filter)(this._core, ids, this._data, this._headings, this._columnTypes, this._numericValues); + set offsetsY(value) { + if (this._offsetsY != value) { + this._offsetsY = value; + this._hasChanged = true; + } } -} -const ColumnType = { - none: 0, - float: 1, - integer: 2, - string: 4, - date: 8, - continuous: 9, - discrete: 6, - numeric: 11 -}; - -},{"./filter.js":"gwwV8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gwwV8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Filter", ()=>Filter); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("../main.js"); -var _tableJs = require("./table.js"); -class Filter { - get ids() { - return this._ids; + get offsetsZ() { + return this._offsetsZ; } - constructor(core, ids, data, headings, columnTypes, numericValues){ - this._core = core; - this._ids = ids; - this._data = data; - this._columnTypes = columnTypes; - this._numericValues = numericValues; - this._stringValues = Array(columnTypes.length).fill(null); - this._hasMinMaxValues = Array(columnTypes.length).fill(false); - this._minValues = Array(columnTypes.length).fill(0); - this._maxValues = Array(columnTypes.length).fill(0); - this._distinctStrings = Array(columnTypes.length).fill(null); - this._orderedIds = Array(columnTypes.length).fill(null); - this._orderedValues = Array(columnTypes.length).fill(null); + set offsetsZ(value) { + if (this._offsetsZ != value) { + this._offsetsZ = value; + this._hasChanged = true; + } } - columnValues(column) { - if (this._columnTypes[column] == (0, _tableJs.ColumnType).string) return this._createStringValues(column); - else return this._createNumericValues(column); + get offsetScalingX() { + return this._offsetScalingX; } - minValue(column) { - this._createMinMaxValues(column); - return this._minValues[column]; + set offsetScalingX(value) { + if (this._offsetScalingX != value) { + this._offsetScalingX = value; + this._hasChanged = true; + } } - maxValue(column) { - this._createMinMaxValues(column); - return this._maxValues[column]; + get offsetScalingY() { + return this._offsetScalingY; } - distinctStrings(column) { - if (this._columnTypes[column] == (0, _tableJs.ColumnType).string) { - this._createStringValues(column); - return this._distinctStrings[column]; - } else return null; + set offsetScalingY(value) { + if (this._offsetScalingY != value) { + this._offsetScalingY = value; + this._hasChanged = true; + } } - toJSON(ids, columns) { - const rows = []; - for(let i = 0; i < ids.length; i++){ - const rowIndex = ids[i]; - const row = []; - for(let j = 0; j < columns.length; j++){ - const columnIndex = columns[j]; - switch(this._columnTypes[columnIndex]){ - case (0, _tableJs.ColumnType).date: - case (0, _tableJs.ColumnType).string: - row.push(this._data[rowIndex][columnIndex]); - break; - case (0, _tableJs.ColumnType).integer: - case (0, _tableJs.ColumnType).float: - const numericValues = this._createNumericValues(columnIndex); - row.push(numericValues[rowIndex]); - break; - } - } - rows.push(row); + get offsetScalingZ() { + return this._offsetScalingZ; + } + set offsetScalingZ(value) { + if (this._offsetScalingZ != value) { + this._offsetScalingZ = value; + this._hasChanged = true; } - return JSON.stringify(rows); } - orderedIds(column) { - if (!this._orderedIds[column]) { - const start = window.performance.now(); - const orderedIds = new Uint32Array(this._ids); - const values = this._columnTypes[column] == (0, _tableJs.ColumnType).string ? this._createStringValues(column) : this._createNumericValues(column); - orderedIds.sort(function(a, b) { - return values[a] - values[b]; - }); - this._orderedIds[column] = orderedIds; - this._core.log.write((0, _mainJs.LogLevel).info, `ordered ids ${column} ${Math.round(window.performance.now() - start)}ms`); + get text() { + return this._text; + } + set text(value) { + if (this._text != value) { + this._text = value; + this._hasChanged = true; } - return this._orderedIds[column]; } - orderedValues(column) { - if (!this._orderedValues[column]) { - const start = window.performance.now(); - const values = this._columnTypes[column] == (0, _tableJs.ColumnType).string ? this._createStringValues(column) : this._createNumericValues(column); - const orderedIds = this.orderedIds(column); - const orderedValues = new Float64Array(this._ids.length); - for(let i = 0; i < this._ids.length; i++)orderedValues[i] = values[orderedIds[i]]; - this._orderedValues[column] = orderedValues; - this._core.log.write((0, _mainJs.LogLevel).info, `ordered values ${column} ${Math.round(window.performance.now() - start)}ms`); + get horizontalAlignments() { + return this._horizontalAlignments; + } + set horizontalAlignments(value) { + if (this._horizontalAlignments != value) { + this._horizontalAlignments = value; + this._hasChanged = true; } - return this._orderedValues[column]; } - distinctStringsOrdered(ids, column, stringValues) { - if (this._columnTypes[column] == (0, _tableJs.ColumnType).string) { - const distinctStrings = []; - const distinctStringValues = {}; - const set = new Set(); - for(let i = 0; i < ids.length; i++){ - const id = ids[i]; - const string = this._data[id][column]; - let value; - if (!set.has(string)) { - distinctStrings.push(string); - value = set.size; - distinctStringValues[string] = value; - set.add(string); - } else value = distinctStringValues[string]; - stringValues[id] = value; - } - return distinctStrings; - } else return null; + get verticalAlignments() { + return this._verticalAlignments; } - _createMinMaxValues(column) { - if (!this._hasMinMaxValues[column]) { - const type = this._columnTypes[column]; - let min, max; - if (type == (0, _tableJs.ColumnType).string) { - this._createStringValues(column); - min = 0; - max = this._distinctStrings[column].length - 1; - } else { - const numericValues = this._createNumericValues(column); - min = Number.MAX_VALUE; - max = -Number.MAX_VALUE; - for(let i = 0; i < this._ids.length; i++){ - const id = this._ids[i]; - const value = numericValues[id]; - min = Math.min(min, value); - max = Math.max(max, value); - } - } - this._minValues[column] = min; - this._maxValues[column] = max; - this._hasMinMaxValues[column] = true; + set verticalAlignments(value) { + if (this._verticalAlignments != value) { + this._verticalAlignments = value; + this._hasChanged = true; } } - _createNumericValues(column) { - if (!this._numericValues[column]) { - const numericValues = new Float64Array(this._data.length); - const type = this._columnTypes[column]; - let min = Number.MAX_VALUE; - let max = -Number.MAX_VALUE; - if (type == (0, _tableJs.ColumnType).float) for(let i = 0; i < this._data.length; i++){ - const value = parseFloat(this._data[i][column]); - min = Math.min(min, value); - max = Math.max(max, value); - numericValues[i] = value; - } - else if (type == (0, _tableJs.ColumnType).integer) for(let i1 = 0; i1 < this._data.length; i1++){ - const value1 = parseInt(this._data[i1][column]); - min = Math.min(min, value1); - max = Math.max(max, value1); - numericValues[i1] = value1; - } - else if (type == (0, _tableJs.ColumnType).date) for(let i2 = 0; i2 < this._data.length; i2++){ - const value2 = Date.parse(this._data[i2][column]); - min = Math.min(min, value2); - max = Math.max(max, value2); - numericValues[i2] = value2; - } - this._minValues[column] = min; - this._maxValues[column] = max; - this._hasMinMaxValues[column] = true; - this._numericValues[column] = numericValues; - } - return this._numericValues[column]; + get scales() { + return this._scales; } - _createStringValues(column) { - if (!this._stringValues[column]) { - this._stringValues[column] = new Float64Array(this._data.length); - this._distinctStrings[column] = this.distinctStringsOrdered(this._ids, column, this._stringValues[column]); - this._minValues[column] = 0; - this._maxValues[column] = this._distinctStrings[column].length - 1; - this._hasMinMaxValues[column] = true; + set scales(value) { + if (this._scales != value) { + this._scales = value; + this._hasChanged = true; } - return this._stringValues[column]; - } -} - -},{"../main.js":"1Kju3","./table.js":"gsKwH","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bUBAh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "TextureHelper", ()=>TextureHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mathJs = require("./math.js"); -class TextureHelper { - static create(gl, width, height, format, type, filter, bytes, internalFormat = format) { - const texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter); - gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, bytes); - return texture; } - static fromImage(gl, image, mipmaps, filter) { - const texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); - if (mipmaps && (0, _mathJs.MathHelper).isPowerOf2(image.width) && (0, _mathJs.MathHelper).isPowerOf2(image.height)) gl.generateMipmap(gl.TEXTURE_2D); - else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter); - } - gl.bindTexture(gl.TEXTURE_2D, null); - return texture; + get scalesScaling() { + return this._scalesScaling; } - static cubemapFromImages(gl, images) { - const texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); - const targets = [ - gl.TEXTURE_CUBE_MAP_POSITIVE_X, - gl.TEXTURE_CUBE_MAP_NEGATIVE_X, - gl.TEXTURE_CUBE_MAP_POSITIVE_Y, - gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, - gl.TEXTURE_CUBE_MAP_POSITIVE_Z, - gl.TEXTURE_CUBE_MAP_NEGATIVE_Z - ]; - for(let i = 0; i < 6; i++){ - gl.texImage2D(targets[i], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, images[i]); - gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + set scalesScaling(value) { + if (this._scalesScaling != value) { + this._scalesScaling = value; + this._hasChanged = true; } - gl.generateMipmap(gl.TEXTURE_CUBE_MAP); - gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); - return texture; - } -} - -},{"./math.js":"fOnPF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"db5XP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "SetHelper", ()=>SetHelper); -class SetHelper { - static new(a, b) { - a.clear(); - for (let item of b)a.add(item); - } - static union(a, b) { - for (let item of b)a.add(item); - } - static intersection(a, b) { - const c = new Set(b); - for (let item of a)if (!c.has(item)) a.delete(item); - for (let item1 of b)if (!a.has(item1)) a.delete(item1); - } - static symmetricDifference(a, b) { - for (let item of b)if (a.has(item)) a.delete(item); - else a.add(item); - } - static difference(a, b) { - for (let item of b)a.delete(item); - } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"a6P8U":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "SdfHelper", ()=>SdfHelper); -class SdfHelper { - static _circle(px, py, r) { - return Math.sqrt(px * px + py * py) - r; } - static _box(px, py, bx, by) { - const dx0 = Math.abs(px) - bx; - const dy0 = Math.abs(py) - by; - const dx1 = Math.max(dx0, 0); - const dy1 = Math.max(dy0, 0); - return Math.sqrt(dx1 * dx1 + dy1 * dy1) + Math.min(Math.max(dx0, dy0), 0); + constructor(core, options){ + super(core, options); + this._quat = (0, _glMatrix.quat).create(); + this._materials = options.materials; + this.minBoundsX = options.minBoundsX ? options.minBoundsX : 0; + this.minBoundsY = options.minBoundsY ? options.minBoundsY : 0; + this.minBoundsZ = options.minBoundsZ ? options.minBoundsZ : 0; + this.maxBoundsX = options.maxBoundsX ? options.maxBoundsX : 1; + this.maxBoundsY = options.maxBoundsY ? options.maxBoundsY : 1; + this.maxBoundsZ = options.maxBoundsZ ? options.maxBoundsZ : 1; + this._font = options.font || core.font; + this.text = options.text; + this.positionsX = options.positionsX; + this.positionsY = options.positionsY; + this.positionsZ = options.positionsZ; + this.positionScalingX = options.positionScalingX ? options.positionScalingX : 1; + this.positionScalingY = options.positionScalingY ? options.positionScalingY : 1; + this.positionScalingZ = options.positionScalingZ ? options.positionScalingZ : 1; + this.rotations = options.rotations; + this.offsetsX = options.offsetsX; + this.offsetsY = options.offsetsY; + this.offsetsZ = options.offsetsZ; + this.offsetScalingX = options.offsetScalingX ? options.offsetScalingX : 1; + this.offsetScalingY = options.offsetScalingY ? options.offsetScalingY : 1; + this.offsetScalingZ = options.offsetScalingZ ? options.offsetScalingZ : 1; + if (options.horizontalAlignments) this.horizontalAlignments = options.horizontalAlignments; + if (options.verticalAlignments) this.verticalAlignments = options.verticalAlignments; + if (options.scales) this.scales = options.scales; + this.scalesScaling = options.scalesScaling ? options.scalesScaling : 1; } - static _create(width, height, edge, sdf) { - const pixels = new Uint8ClampedArray(width * height * 4); - for(let y = 0; y < height; y++)for(let x = 0; x < width; x++){ - const d = edge - sdf(x - width / 2, y - height / 2); - const offset = (x + y * height) * 4; - pixels[offset] = d; - pixels[offset + 1] = d; - pixels[offset + 2] = d; - pixels[offset + 3] = 0xff; + update(elapsedTime) { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + this.pickIdLookup = {}; + if (!this._text) this._indexCount = 0; + else { + const start = window.performance.now(); + const modelSizeX = this._maxBoundsX - this._minBoundsX; + const modelSizeY = this._maxBoundsY - this._minBoundsY; + const modelSizeZ = this._maxBoundsZ - this._minBoundsZ; + const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; + const modelOriginX = (this._minBoundsX + this._maxBoundsX) / 2; + const modelOriginY = (this._minBoundsY + this._maxBoundsY) / 2; + const modelOriginZ = (this._minBoundsZ + this._maxBoundsZ) / 2; + if (this._rotation) (0, _glMatrix.quat).set(this._quat, this._rotation[0], this._rotation[1], this._rotation[2], this._rotation[3]); + let glyphs = 0; + for(let i = 0; i < this._text.length; i++){ + const offsetX = (this._offsetsX ? this._offsetsX[i] / 2 : this._offsetX) * boundsScaling * this._offsetScalingX; + const offsetY = (this._offsetsY ? this._offsetsY[i] / 2 : this._offsetY) * boundsScaling * this._offsetScalingY; + const offsetZ = (this._offsetsZ ? this._offsetsZ[i] / 2 : this._offsetZ) * boundsScaling * this._offsetScalingZ; + const text = (0, _textJs.TextHelper).truncate(this._text[i], this._maxGlyphs - glyphs); + const scale = (this._scales ? this._scales[i] * this._scalesScaling : this._scale) * boundsScaling / this._font.size; + (0, _textJs.TextHelper).measure(this._font, text, this._textMetric); + const width = this._textMetric.width * scale; + const lineHeight = this._font.size * scale; + const maxGlyphTop = (this._maxGlyphTop ? this._maxGlyphTop : this._textMetric.maxTop) * scale; + const horizontalAlignment = this._horizontalAlignments ? this._horizontalAlignments[i] : this._horizontalAlignment; + switch(horizontalAlignment){ + case (0, _mainJs.HorizontalAlignment).left: + this._offset[0] = offsetX; + break; + case (0, _mainJs.HorizontalAlignment).center: + this._offset[0] = offsetX - width / 2; + break; + case (0, _mainJs.HorizontalAlignment).right: + this._offset[0] = offsetX - width; + break; + } + const verticalAlignment = this._verticalAlignments ? this._verticalAlignments[i] : this._verticalAlignment; + switch(verticalAlignment){ + case (0, _mainJs.VerticalAlignment).top: + this._offset[1] = offsetY - lineHeight / 2; + break; + case (0, _mainJs.VerticalAlignment).center: + this._offset[1] = offsetY; + break; + case (0, _mainJs.VerticalAlignment).bottom: + this._offset[1] = offsetY + lineHeight / 2; + break; + } + this._offset[1] -= maxGlyphTop / 2; + this._offset[2] = offsetZ; + let positionX = this.positionsX ? this.positionsX[i] * this.positionScalingX : 0; + let positionY = this.positionsY ? this.positionsY[i] * this.positionScalingY : 0; + let positionZ = this.positionsZ ? this.positionsZ[i] * this.positionScalingZ : 0; + if (this._reverseX) positionX = this.minBoundsX + this.maxBoundsX - positionX; + if (this._reverseY) positionY = this.minBoundsY + this.maxBoundsY - positionY; + if (this._reverseZ) positionZ = this.minBoundsZ + this.maxBoundsZ - positionZ; + (0, _glMatrix.vec3).set(this._vec3, (positionX - modelOriginX) * boundsScaling, (positionY - modelOriginY) * boundsScaling, (positionZ - modelOriginZ) * boundsScaling); + if (this._rotations) (0, _glMatrix.quat).set(this._quat, this._rotations[i * 4], this._rotations[i * 4 + 1], this._rotations[i * 4 + 2], this._rotations[i * 4 + 3]); + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).label, this._vec4); + this.pickIdLookup[pickId] = i; + (0, _textJs.TextHelper).addString(this._font, text, this._verticesView, this._indices, glyphs, this._vec3, scale, this._offset, this._rotation || this._rotations ? this._quat : null, this._vec4); + glyphs += text.length; + if (glyphs >= this._maxGlyphs) { + glyphs = this._maxGlyphs; + break; + } + } + this._indexCount = glyphs * 6; + this._core.log.write((0, _mainJs.LogLevel).info, `label set updated ${Math.round(window.performance.now() - start)}ms`); + if (this.hasChangedCallback) this.hasChangedCallback(); + } } - return new ImageData(pixels, width, height); - } - static circle(imageWidth, imageHeight, radius, edgeValue) { - const sdf = (x, y)=>this._circle(x, y, radius); - return this._create(imageWidth, imageHeight, edgeValue, sdf); - } - static box(imageWidth, imageHeight, boxWidth, boxHeight, edgeValue, rounding = 0) { - const sdf = (x, y)=>this._box(x, y, boxWidth - rounding, boxHeight - rounding) - rounding; - return this._create(imageWidth, imageHeight, edgeValue, sdf); - } -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i0I1g":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "VectorHelper", ()=>VectorHelper); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -class VectorHelper { - static orthonormalBasis(n, b1, b2) { - if (n[0] > 0.9) (0, _glMatrix.vec3).copy(b1, (0, _constantsJs.Constants).VECTOR3_UNITY); - else (0, _glMatrix.vec3).copy(b1, (0, _constantsJs.Constants).VECTOR3_UNITX); - (0, _glMatrix.vec3).scaleAndAdd(b1, b1, n, -(0, _glMatrix.vec3).dot(b1, n)); - (0, _glMatrix.vec3).normalize(b1, b1); - (0, _glMatrix.vec3).cross(b2, n, b1); } } - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8NW4M":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Bar", ()=>(0, _barJs.Bar)); -parcelHelpers.export(exports, "Cube", ()=>(0, _cubeJs.Cube)); -parcelHelpers.export(exports, "Line", ()=>(0, _lineJs.Line)); -parcelHelpers.export(exports, "Tree", ()=>(0, _treeJs.Tree)); -parcelHelpers.export(exports, "PythagorasTree", ()=>(0, _treeJs.PythagorasTree)); -parcelHelpers.export(exports, "Scatter", ()=>(0, _scatterJs.Scatter)); -parcelHelpers.export(exports, "Sheet", ()=>(0, _sheetJs.Sheet)); -parcelHelpers.export(exports, "SquarifiedTreeMap", ()=>(0, _treemapJs.SquarifiedTreeMap)); -parcelHelpers.export(exports, "CubifiedTreeMap", ()=>(0, _treemapJs.CubifiedTreeMap)); -parcelHelpers.export(exports, "Stack", ()=>(0, _stackJs.Stack)); -parcelHelpers.export(exports, "StackTreeMap", ()=>(0, _stackJs.StackTreeMap)); -var _barJs = require("./bar.js"); -var _cubeJs = require("./cube.js"); -var _lineJs = require("./line.js"); -var _treeJs = require("./tree.js"); -var _scatterJs = require("./scatter.js"); -var _sheetJs = require("./sheet.js"); -var _treemapJs = require("./treemap.js"); -var _stackJs = require("./stack.js"); - -},{"./bar.js":"LXgxf","./cube.js":"ho56K","./line.js":"bN4IX","./tree.js":"cKKYC","./scatter.js":"i5SiV","./sheet.js":"8WJgN","./treemap.js":"dMHbq","./stack.js":"ip4E8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"LXgxf":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Bar", ()=>Bar); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class Bar extends (0, _layoutJs.LayoutBase) { - layout(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const positionScalingX = options.positionScalingX === undefined ? 1 : options.positionScalingX; - const positionScalingZ = options.positionScalingZ === undefined ? 1 : options.positionScalingZ; - const heightScaling = options.heightScaling === undefined ? 1 : options.heightScaling; - const minHeight = options.minHeight === undefined ? 0 : options.minHeight; - const paddingX = options.paddingX == undefined ? 0 : options.paddingX * positionScalingX; - const paddingZ = options.paddingZ == undefined ? 0 : options.paddingZ * positionScalingZ; - if (!this._positions || this._positions.length < buffer.length * 3) { - this._positions = new Float32Array(buffer.length * 3); - this._sizes = new Float32Array(buffer.length * 3); - } - this.minLayoutBoundsX = Number.MAX_VALUE; - this.minLayoutBoundsY = Number.MAX_VALUE; - this.minLayoutBoundsZ = Number.MAX_VALUE; - this.maxLayoutBoundsX = -Number.MAX_VALUE; - this.maxLayoutBoundsY = -Number.MAX_VALUE; - this.maxLayoutBoundsZ = -Number.MAX_VALUE; - let positionX, positionY, positionZ; - let sizeX, sizeY, sizeZ; - const lookup = buffer.lookup; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - const height = Math.max(options.heights ? options.heights[id] * heightScaling : heightScaling, minHeight); - positionX = options.positionsX ? options.positionsX[id] * positionScalingX : 0; - positionY = height / 2; - positionZ = options.positionsZ ? options.positionsZ[id] * positionScalingZ : 0; - this._positions[index * 3] = positionX; - this._positions[index * 3 + 1] = positionY; - this._positions[index * 3 + 2] = positionZ; - sizeX = (options.sizeX === undefined ? options.sizesX ? options.sizesX[id] : 1 : options.sizeX) * positionScalingX; - sizeY = Math.abs(height); - sizeZ = (options.sizeZ === undefined ? options.sizesZ ? options.sizesZ[id] : 1 : options.sizeZ) * positionScalingZ; - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, positionX - sizeX / 2); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, positionY - sizeY / 2); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, positionZ - sizeZ / 2); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, positionX + sizeX / 2); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, positionY + sizeY / 2); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, positionZ + sizeZ / 2); - this._sizes[index * 3] = Math.max(sizeX - paddingX, 0); - this._sizes[index * 3 + 1] = sizeY; - this._sizes[index * 3 + 2] = Math.max(sizeZ - paddingZ, 0); - } - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); +class TransitionLabelSet { + constructor(core){ + this._core = core; + this._vec2 = (0, _glMatrix.vec2).create(); + this._vec3 = (0, _glMatrix.vec3).create(); + this._vec4 = (0, _glMatrix.vec4).create(); + this._quat = (0, _glMatrix.quat).create(); + this._textMetric = { + width: 0, + maxHeight: 0, + maxTop: 0 + }; + this._topLeft = (0, _glMatrix.vec3).create(); + this._topRight = (0, _glMatrix.vec3).create(); + this._bottomLeft = (0, _glMatrix.vec3).create(); + this._bottomRight = (0, _glMatrix.vec3).create(); + this._offset = (0, _glMatrix.vec3).create(); } - update(buffer, ids, options) { + update(buffer, labelIds, options) { const start = window.performance.now(); const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; + const count = options.count === undefined ? options.text.length : options.count; const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minBoundsX = options.minBoundsX ? options.minBoundsX : 0; + const minBoundsY = options.minBoundsY ? options.minBoundsY : 0; + const minBoundsZ = options.minBoundsZ ? options.minBoundsZ : 0; + const maxBoundsX = options.maxBoundsX ? options.maxBoundsX : 1; + const maxBoundsY = options.maxBoundsY ? options.maxBoundsY : 1; + const maxBoundsZ = options.maxBoundsZ ? options.maxBoundsZ : 1; + const positionScalingX = options.positionScalingX ? options.positionScalingX : 1; + const positionScalingY = options.positionScalingY ? options.positionScalingY : 1; + const positionScalingZ = options.positionScalingZ ? options.positionScalingZ : 1; + const offsetX = options.offsetX ? options.offsetX : 0; + const offsetY = options.offsetY ? options.offsetY : 0; + const offsetZ = options.offsetZ ? options.offsetZ : 0; + const offsetScalingX = options.offsetScalingX ? options.offsetScalingX : 1; + const offsetScalingY = options.offsetScalingY ? options.offsetScalingY : 1; + const offsetScalingZ = options.offsetScalingZ ? options.offsetScalingZ : 1; + const horizontalAlignment = options.horizontalAlignment === undefined ? (0, _mainJs.HorizontalAlignment).center : options.horizontalAlignment; + const verticalAlignment = options.verticalAlignment === undefined ? (0, _mainJs.VerticalAlignment).center : options.verticalAlignment; + const scale = options.scale ? options.scale : 1; + const scalesScaling = options.scalesScaling ? options.scalesScaling : 1; + const font = options.font || this._core.font; const minOrder = options.minOrder === undefined ? 0 : options.minOrder; const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; + const modelSizeX = maxBoundsX - minBoundsX; + const modelSizeY = maxBoundsY - minBoundsY; + const modelSizeZ = maxBoundsZ - minBoundsZ; + const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; + const modelOriginX = (minBoundsX + maxBoundsX) / 2; + const modelOriginY = (minBoundsY + maxBoundsY) / 2; + const modelOriginZ = (minBoundsZ + maxBoundsZ) / 2; + if (options.rotation) { + this._quat[0] = options.rotation[0]; + this._quat[1] = options.rotation[1]; + this._quat[2] = options.rotation[2]; + this._quat[3] = options.rotation[3]; + } else (0, _glMatrix.quat).rotationTo(this._quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + this.pickIdLookup = {}; for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + const labelIndex = labelIds[i + offset]; + const _offsetX = (options.offsetsX ? options.offsetsX[labelIndex] / 2 : offsetX) * boundsScaling * offsetScalingX; + const _offsetY = (options.offsetsY ? options.offsetsY[labelIndex] / 2 : offsetY) * boundsScaling * offsetScalingY; + const _offsetZ = (options.offsetsZ ? options.offsetsZ[labelIndex] / 2 : offsetZ) * boundsScaling * offsetScalingZ; + const label = options.text[labelIndex]; + const _scale = (options.scales ? options.scales[labelIndex] * scalesScaling : scale) * boundsScaling / font.size; + (0, _textJs.TextHelper).measure(font, label, this._textMetric); + const width = this._textMetric.width * _scale; + const lineHeight = font.size * _scale; + const _maxGlyphTop = (options.maxGlyphTop ? options.maxGlyphTop : this._textMetric.maxTop) * _scale; + const _horizontalAlignment = options.horizontalAlignments ? options.horizontalAlignments[labelIndex] : horizontalAlignment; + switch(_horizontalAlignment){ + case (0, _mainJs.HorizontalAlignment).left: + this._offset[0] = _offsetX; + break; + case (0, _mainJs.HorizontalAlignment).center: + this._offset[0] = _offsetX - width / 2; + break; + case (0, _mainJs.HorizontalAlignment).right: + this._offset[0] = _offsetX - width; + break; } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = this._sizes[index * 3] * this._boundsScaling; - _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; - _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - if (options.colors1) { - const color1 = (0, _mathJs.MathHelper).normalize(options.colors1[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color1); - } else (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + const _verticalAlignment = options.verticalAlignments ? options.verticalAlignments[labelIndex] : verticalAlignment; + switch(_verticalAlignment){ + case (0, _mainJs.VerticalAlignment).top: + this._offset[1] = _offsetY - lineHeight / 2; + break; + case (0, _mainJs.VerticalAlignment).center: + this._offset[1] = _offsetY; + break; + case (0, _mainJs.VerticalAlignment).bottom: + this._offset[1] = _offsetY + lineHeight / 2; + break; + } + this._offset[1] -= _maxGlyphTop / 2; + this._offset[2] = _offsetZ; + let positionX = options.positionsX ? options.positionsX[labelIndex] * positionScalingX : 0; + let positionY = options.positionsY ? options.positionsY[labelIndex] * positionScalingY : 0; + let positionZ = options.positionsZ ? options.positionsZ[labelIndex] * positionScalingZ : 0; + if (options.reverseX) positionX = minBoundsX + maxBoundsX - positionX; + if (options.reverseY) positionY = minBoundsY + maxBoundsY - positionY; + if (options.reverseZ) positionZ = minBoundsZ + maxBoundsZ - positionZ; + positionX = (positionX - modelOriginX) * boundsScaling; + positionY = (positionY - modelOriginY) * boundsScaling; + positionZ = (positionZ - modelOriginZ) * boundsScaling; + if (options.rotations) (0, _glMatrix.quat).set(this._quat, options.rotations[labelIndex * 4], options.rotations[labelIndex * 4 + 1], options.rotations[labelIndex * 4 + 2], options.rotations[labelIndex * 4 + 3]); + const pickId = (0, _pickJs.PickHelper).nextPickId(); + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).label, this._vec4); + this.pickIdLookup[pickId] = labelIndex; if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + const order = (0, _mathJs.MathHelper).normalize(options.order[labelIndex], minOrder, maxOrder, 0, 1); + this._vec2[0] = orderReverse ? 1 - order : order; + } else this._vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) this._vec2[1] = options.staggerOrder; else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[labelIndex], minStaggerOrder, maxStaggerOrder, 0, 1); + this._vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else this._vec2[1] = count == 1 ? 0 : i / (count - 1); + let glyphIndex = options.glyphOffsets[labelIndex]; + for (const char of label){ + let glyph = font.glyphs[char]; + if (!glyph) { + font.addGlyph(char); + glyph = font.glyphs[char]; + } + const width = glyph.width * _scale; + const height = glyph.height * _scale; + const top = glyph.top * _scale; + const border = font.border * _scale; + const x0 = this._offset[0] - border; + const x1 = this._offset[0] + width + border; + const y0 = this._offset[1] + top + border; + const y1 = this._offset[1] + top - height - border; + const z0 = this._offset[2]; + (0, _glMatrix.vec3).set(this._topLeft, x0, y0, z0); + (0, _glMatrix.vec3).set(this._topRight, x1, y0, z0); + (0, _glMatrix.vec3).set(this._bottomLeft, x0, y1, z0); + (0, _glMatrix.vec3).set(this._bottomRight, x1, y1, z0); + if (options.rotation || options.rotations) { + (0, _glMatrix.vec3).transformQuat(this._topLeft, this._topLeft, this._quat); + (0, _glMatrix.vec3).transformQuat(this._topRight, this._topRight, this._quat); + (0, _glMatrix.vec3).transformQuat(this._bottomLeft, this._bottomLeft, this._quat); + (0, _glMatrix.vec3).transformQuat(this._bottomRight, this._bottomRight, this._quat); + } + (0, _vertexJs.UnitVertex).setRotation(dataView, glyphIndex, this._quat); + this._vec3[0] = positionX + (this._topLeft[0] + this._bottomRight[0]) / 2; + this._vec3[1] = positionY + (this._topLeft[1] + this._bottomRight[1]) / 2; + this._vec3[2] = positionZ + (this._topLeft[2] + this._bottomRight[2]) / 2; + (0, _vertexJs.UnitVertex).setTranslation(dataView, glyphIndex, this._vec3); + this._vec3[0] = Math.abs(x1 - x0); + this._vec3[1] = Math.abs(y1 - y0); + this._vec3[2] = 0.001; + (0, _vertexJs.UnitVertex).setScale(dataView, glyphIndex, this._vec3); + this._vec4[0] = glyph.u0; + this._vec4[1] = glyph.v0; + this._vec4[2] = glyph.u1; + this._vec4[3] = glyph.v1; + (0, _vertexJs.UnitVertex).setTexCoord(dataView, glyphIndex, this._vec4); + (0, _vertexJs.UnitVertex).setIdHover(dataView, glyphIndex, options.hover ? options.hover[labelIndex] : labelIndex); + (0, _vertexJs.UnitVertex).setOrder(dataView, glyphIndex, this._vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, glyphIndex, options.material ? options.material : options.materials ? options.materials[labelIndex] : 0); + (0, _vertexJs.UnitVertex).setTexture(dataView, glyphIndex, 1); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, glyphIndex, this._core.config.sdfBuffer); + this._offset[0] += glyph.advance * _scale; + glyphIndex++; + } } buffer.update(); this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } } -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ho56K":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cube", ()=>Cube); +},{"gl-matrix":"5x28d","../main.js":"f421K","../helpers/text.js":"fG2oi","../constants.js":"lD0bG","../vertex.js":"4J2YE","../helpers/pick.js":"1t2sb","../helpers/math.js":"f65d0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kwtZG":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); +parcelHelpers.export(exports, "ImageBase", ()=>ImageBase); +parcelHelpers.export(exports, "ImageQuad", ()=>ImageQuad); +parcelHelpers.export(exports, "ImageSphere", ()=>ImageSphere); +var _glMatrix = require("gl-matrix"); var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class Cube extends (0, _layoutJs.LayoutBase) { - layout(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const side = options.side === undefined ? Math.ceil(Math.cbrt(count)) : options.side; - if (!this._positions || this._positions.length < buffer.length * 3) this._positions = new Float32Array(buffer.length * 3); - this.minLayoutBoundsX = 0; - this.minLayoutBoundsY = 0; - this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = 0; - this.maxLayoutBoundsY = 0; - this.maxLayoutBoundsZ = 0; - const lookup = buffer.lookup; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - const y = Math.floor(i / (side * side)); - const z = Math.floor((i - y * side * side) / side); - const x = i - y * side * side - z * side; - this._positions[index * 3] = x; - this._positions[index * 3 + 1] = y; - this._positions[index * 3 + 2] = z; - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, x); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, y); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, z); - } - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); - } - update(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const padding = options.padding === undefined ? 0 : options.padding; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - const scale = (0, _glMatrix.vec3).fromValues((1 - padding) * this._boundsScaling, (1 - padding) * this._boundsScaling, (1 - padding) * this._boundsScaling); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; - } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setScale(dataView, index, scale); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, (0, _constantsJs.Constants).QUAT_IDENTITY); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - _vec2[0] = color; - _vec2[1] = color; - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); - } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)} ms`); +var _quadJs = require("../meshes/quad.js"); +var _sphereJs = require("../meshes/sphere.js"); +var _constantsJs = require("../constants.js"); +class ImageVisual { + render(elapsedTime, xrFrame) {} + update(elapsedTime) {} + constructor(image){ + this.image = image; } } - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bN4IX":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Line", ()=>Line); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class Line extends (0, _layoutJs.LayoutBase) { - layout(buffer, ids, fromIds, toIds, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const positionScalingX = options.positionScalingX === undefined ? 1 : options.positionScalingX; - const positionScalingY = options.positionScalingY === undefined ? 1 : options.positionScalingY; - const positionScalingZ = options.positionScalingZ === undefined ? 1 : options.positionScalingZ; - const sizeScalingX = options.sizeScaling === undefined ? options.sizeScalingX === undefined ? 1 : options.sizeScalingX : options.sizeScaling; - const sizeScalingY = options.sizeScaling === undefined ? options.sizeScalingY === undefined ? 1 : options.sizeScalingY : options.sizeScaling; - const sizeScalingZ = options.sizeScaling === undefined ? options.sizeScalingZ === undefined ? 1 : options.sizeScalingZ : options.sizeScaling; - const minSize = options.minSize === undefined ? 0 : options.minSize; - const offsetScaling = options.offsetScaling === undefined ? 1 : options.offsetScaling; - if (!this._positions || this._positions.length < buffer.length * 3) { - this._positions = new Float32Array(buffer.length * 3); - this._sizes = new Float32Array(buffer.length * 3); - this._rotations = new Float32Array(buffer.length * 4); +class ImageBase { + get material() { + return this._material; + } + get vertices() { + return this._vertices; + } + get indices() { + return this._indices; + } + get indexCount() { + return this._indexCount; + } + get isInitialized() { + return this._isInitialized; + } + get mMatrix() { + return this._mMatrix; + } + get imageData() { + return this._imageData; + } + set imageData(value) { + if (this._imageData != value) { + this._imageData = value; + this._hasChanged = true; } - this.minLayoutBoundsX = Number.MAX_VALUE; - this.minLayoutBoundsY = Number.MAX_VALUE; - this.minLayoutBoundsZ = Number.MAX_VALUE; - this.maxLayoutBoundsX = -Number.MAX_VALUE; - this.maxLayoutBoundsY = -Number.MAX_VALUE; - this.maxLayoutBoundsZ = -Number.MAX_VALUE; - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const direction = (0, _glMatrix.vec3).create(); - const lookup = buffer.lookup; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const fromId = fromIds[i + offset]; - const toId = toIds[i + offset]; - const index = lookup[id]; - let toPositionX = options.positionsX ? options.positionsX[toId] * positionScalingX : 0; - let toPositionY = options.positionsY ? options.positionsY[toId] * positionScalingY : 0; - let toPositionZ = options.positionsZ ? options.positionsZ[toId] * positionScalingZ : 0; - let fromPositionX = options.positionsX ? options.positionsX[fromId] * positionScalingX : 0; - let fromPositionY = options.positionsY ? options.positionsY[fromId] * positionScalingY : 0; - let fromPositionZ = options.positionsZ ? options.positionsZ[fromId] * positionScalingZ : 0; - if (fromId == toId) { - this._sizes[index * 3] = 0; - this._sizes[index * 3 + 1] = 0; - this._sizes[index * 3 + 2] = 0; - this._rotations[index * 4] = 0; - this._rotations[index * 4 + 1] = 0; - this._rotations[index * 4 + 2] = 0; - this._rotations[index * 4 + 3] = 1; - } else { - direction[0] = toPositionX - fromPositionX; - direction[1] = toPositionY - fromPositionY; - direction[2] = toPositionZ - fromPositionZ; - let length = (0, _glMatrix.vec3).length(direction); - (0, _glMatrix.vec3).scale(direction, direction, 1 / length); - (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, direction); - this._rotations[index * 4] = _quat[0]; - this._rotations[index * 4 + 1] = _quat[1]; - this._rotations[index * 4 + 2] = _quat[2]; - this._rotations[index * 4 + 3] = _quat[3]; - if (options.offsets) { - const fromOffset = options.offsets[fromId] * offsetScaling / 2; - const toOffset = options.offsets[toId] * offsetScaling / 2; - toPositionX -= direction[0] * toOffset; - toPositionY -= direction[1] * toOffset; - toPositionZ -= direction[2] * toOffset; - fromPositionX += direction[0] * fromOffset; - fromPositionY += direction[1] * fromOffset; - fromPositionZ += direction[2] * fromOffset; - length = Math.max(length - toOffset - fromOffset, minSize); - } - this._sizes[index * 3 + 1] = Math.max(length * sizeScalingY, minSize); - if (options.lineSizes) { - this._sizes[index * 3] = Math.max(options.lineSizes[id] * sizeScalingX, minSize); - this._sizes[index * 3 + 2] = Math.max(options.lineSizes[id] * sizeScalingZ, minSize); - } else if (options.endSizes) { - this._sizes[index * 3] = Math.max(options.endSizes[fromId] * sizeScalingX, minSize); - this._sizes[index * 3 + 2] = Math.max(options.endSizes[toId] * sizeScalingZ, minSize); - } else { - this._sizes[index * 3] = sizeScalingX; - this._sizes[index * 3 + 2] = sizeScalingZ; - } - } - _vec3[0] = (fromPositionX + toPositionX) / 2; - _vec3[1] = (fromPositionY + toPositionY) / 2; - _vec3[2] = (fromPositionZ + toPositionZ) / 2; - this._positions[index * 3] = _vec3[0]; - this._positions[index * 3 + 1] = _vec3[1]; - this._positions[index * 3 + 2] = _vec3[2]; - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, fromPositionX); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, fromPositionY); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, fromPositionZ); - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, toPositionX); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, toPositionY); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, toPositionZ); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, fromPositionX); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, fromPositionY); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, fromPositionZ); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, toPositionX); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, toPositionY); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, toPositionZ); + } + get rotation() { + return this._rotation; + } + set rotation(value) { + if (!(0, _glMatrix.quat).equals(this._rotation, value)) { + (0, _glMatrix.quat).copy(this._rotation, value); + this._hasChanged = true; } - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - update(buffer, ids, fromIds, toIds, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const endMinColor = options.endMinColor === undefined ? 0 : options.endMinColor; - const endMaxColor = options.endMaxColor === undefined ? 1 : options.endMaxColor; - const lineMinColor = options.lineMinColor === undefined ? 0 : options.lineMinColor; - const lineMaxColor = options.lineMaxColor === undefined ? 1 : options.lineMaxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const fromId = fromIds[i + offset]; - const toId = toIds[i + offset]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; - } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = this._sizes[index * 3] * this._boundsScaling; - _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; - _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - _quat[0] = this._rotations[index * 4]; - _quat[1] = this._rotations[index * 4 + 1]; - _quat[2] = this._rotations[index * 4 + 2]; - _quat[3] = this._rotations[index * 4 + 3]; - if (reverseX) { - _quat[1] = -_quat[1]; - _quat[2] = -_quat[2]; - } - if (reverseY) { - _quat[0] = -_quat[0]; - _quat[2] = -_quat[2]; - } - if (reverseZ) { - _quat[0] = -_quat[0]; - _quat[1] = -_quat[1]; - } - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - let size; - if (options.endColors) { - size = 1 / (endMaxColor - endMinColor + 1); - const fromColor = (0, _mathJs.MathHelper).normalize(options.endColors[fromId], endMinColor, endMaxColor, size / 2, 1 - size / 2); - const toColor = (0, _mathJs.MathHelper).normalize(options.endColors[toId], endMinColor, endMaxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, fromColor, toColor); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else if (options.lineColors) { - size = 1 / (lineMaxColor - lineMinColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.lineColors[id], lineMinColor, lineMaxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + get position() { + return this._position; + } + set position(value) { + if (!(0, _glMatrix.vec3).equals(this._position, value)) { + (0, _glMatrix.vec3).copy(this._position, value); + this._hasChanged = true; } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } -} - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cKKYC":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "PythagorasTree", ()=>PythagorasTree); -parcelHelpers.export(exports, "Tree", ()=>Tree); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _angleJs = require("../helpers/angle.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class PythagorasTree extends (0, _layoutJs.LayoutBase) { - get levels() { - return this._levels; + get texCoord0() { + return this._texCoord0; } - get maxLevel() { - return this._maxLevel; + set texCoord0(value) { + if (!(0, _glMatrix.vec2).equals(this._texCoord0, value)) { + (0, _glMatrix.vec2).copy(this._texCoord0, value); + this._hasChanged = true; + } } - get volumes() { - return this._volumes; + get texCoord1() { + return this._texCoord1; } - constructor(core){ - super(core); - this._vec3 = (0, _glMatrix.vec3).create(); - this._quat = (0, _glMatrix.quat).create(); - this._parentRight = (0, _glMatrix.vec3).create(); - this._parentUp = (0, _glMatrix.vec3).create(); - this._parentForward = (0, _glMatrix.vec3).create(); - this._parentTranslation = (0, _glMatrix.vec3).create(); - this._parentScale = (0, _glMatrix.vec3).create(); - this._parentRotation = (0, _glMatrix.quat).create(); - this._parentTwist = (0, _glMatrix.quat).create(); - this._childRotation = (0, _glMatrix.quat).create(); + set texCoord1(value) { + if (!(0, _glMatrix.vec2).equals(this._texCoord1, value)) { + (0, _glMatrix.vec2).copy(this._texCoord1, value); + this._hasChanged = true; + } } - static calculateTotalVertices(level) { - return (2 << level) - 1; + get minBoundsX() { + return this._minBoundsX; } - static calculateMaxLevel(vertices) { - return Math.ceil(Math.log2(vertices + 1)) - 1; + set minBoundsX(value) { + if (this._minBoundsX != value) { + this._minBoundsX = value; + this._hasChanged = true; + } } - layout(buffer, ids, options) { - const start = window.performance.now(); - const scalingX = options.scalingX === undefined ? 1 : options.scalingX; - const scalingY = options.scalingY === undefined ? 1 : options.scalingY; - const scalingZ = options.scalingZ === undefined ? 1 : options.scalingZ; - this._angle = options.angle === undefined ? (0, _angleJs.AngleHelper).degreesToRadians(45) : options.angle; - this._randomAngle = options.randomAngle === undefined ? 0 : options.randomAngle; - this._twist = options.twist === undefined ? 0 : options.twist; - this._randomTwist = options.randomTwist === undefined ? 0 : options.randomTwist; - if (!this._positions || this._positions.length < buffer.length * 3) { - this._positions = new Float32Array(buffer.length * 3); - this._sizes = new Float32Array(buffer.length * 3); - this._rotations = new Float32Array(buffer.length * 4); - this._levels = new Uint32Array(buffer.length); - this._volumes = new Float64Array(buffer.length); + get minBoundsY() { + return this._minBoundsY; + } + set minBoundsY(value) { + if (this._minBoundsY != value) { + this._minBoundsY = value; + this._hasChanged = true; } - this._maxLevel = PythagorasTree.calculateMaxLevel(ids.length); - const lookup = buffer.lookup; - const id = ids[0]; - const index = lookup[id]; - this._levels[index] = 0; - this._positions[index * 3] = 0; - this._positions[index * 3 + 1] = 0; - this._positions[index * 3 + 2] = 0; - this.minLayoutBoundsX = 0; - this.minLayoutBoundsY = 0; - this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = 0; - this.maxLayoutBoundsY = 0; - this.maxLayoutBoundsZ = 0; - this._rotations[index * 4] = 0; - this._rotations[index * 4 + 1] = 0; - this._rotations[index * 4 + 2] = 0; - this._rotations[index * 4 + 3] = 1; - this._sizes[index * 3] = scalingX; - this._sizes[index * 3 + 1] = scalingY; - this._sizes[index * 3 + 2] = scalingZ; - this._volumes[index] = scalingX * scalingY * scalingZ; - this._count = 1; - const pseudoRandom = new (0, _mathJs.PseudoRandom)(0); - this._branch(index, ids, lookup, pseudoRandom); - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - update(buffer, ids, options) { - const start = window.performance.now(); - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < ids.length; i++){ - const id = ids[i]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (reverseX) positionX = this.modelOriginX + this.modelOriginX - positionX; - if (reverseY) positionY = this.modelOriginY + this.modelOriginY - positionY; - if (reverseZ) positionZ = this.modelOriginZ + this.modelOriginZ - positionZ; - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = this._sizes[index * 3] * this._boundsScaling; - _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; - _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - _quat[0] = this._rotations[index * 4]; - _quat[1] = this._rotations[index * 4 + 1]; - _quat[2] = this._rotations[index * 4 + 2]; - _quat[3] = this._rotations[index * 4 + 3]; - if (reverseX) { - _quat[1] = -_quat[1]; - _quat[2] = -_quat[2]; - } - if (reverseY) { - _quat[0] = -_quat[0]; - _quat[2] = -_quat[2]; - } - if (reverseZ) { - _quat[0] = -_quat[0]; - _quat[1] = -_quat[1]; - } - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = i / (ids.length - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = i / (ids.length - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + get minBoundsZ() { + return this._minBoundsZ; + } + set minBoundsZ(value) { + if (this._minBoundsZ != value) { + this._minBoundsZ = value; + this._hasChanged = true; } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - _branch(parentIndex, ids, lookup, pseudoRandom) { - const parentLevel = this._levels[parentIndex]; - if (parentLevel < this._maxLevel && this._count < ids.length) { - let angle = this._angle + (pseudoRandom.nextFloat() * 2 - 1) * this._randomAngle; - let twist = this._twist + (pseudoRandom.nextFloat() * 2 - 1) * this._randomTwist; - angle = (0, _mathJs.MathHelper).clamp(angle, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); - twist = (0, _mathJs.MathHelper).clamp(twist, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); - this._parentTranslation[0] = this._positions[parentIndex * 3]; - this._parentTranslation[1] = this._positions[parentIndex * 3 + 1]; - this._parentTranslation[2] = this._positions[parentIndex * 3 + 2]; - this._parentRotation[0] = this._rotations[parentIndex * 4]; - this._parentRotation[1] = this._rotations[parentIndex * 4 + 1]; - this._parentRotation[2] = this._rotations[parentIndex * 4 + 2]; - this._parentRotation[3] = this._rotations[parentIndex * 4 + 3]; - this._parentScale[0] = this._sizes[parentIndex * 3]; - this._parentScale[1] = this._sizes[parentIndex * 3 + 1]; - this._parentScale[2] = this._sizes[parentIndex * 3 + 2]; - (0, _glMatrix.vec3).transformQuat(this._parentUp, (0, _constantsJs.Constants).VECTOR3_UNITY, this._parentRotation); - (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentUp, twist); - (0, _glMatrix.quat).multiply(this._parentTwist, this._quat, this._parentRotation); - (0, _glMatrix.vec3).transformQuat(this._parentRight, (0, _constantsJs.Constants).VECTOR3_UNITX, this._parentTwist); - (0, _glMatrix.vec3).transformQuat(this._parentForward, (0, _constantsJs.Constants).VECTOR3_UNITZ, this._parentTwist); - const childId1 = ids[this._count++]; - const childIndex1 = lookup[childId1]; - let cos = Math.cos(angle); - this._sizes[childIndex1 * 3] = this._parentScale[0] * cos; - this._sizes[childIndex1 * 3 + 1] = this._parentScale[1] * cos; - this._sizes[childIndex1 * 3 + 2] = this._parentScale[2] * cos; - (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentForward, angle); - (0, _glMatrix.quat).multiply(this._childRotation, this._quat, this._parentTwist); - this._rotations[childIndex1 * 4] = this._childRotation[0]; - this._rotations[childIndex1 * 4 + 1] = this._childRotation[1]; - this._rotations[childIndex1 * 4 + 2] = this._childRotation[2]; - this._rotations[childIndex1 * 4 + 3] = this._childRotation[3]; - const halfparentScaleX = this._parentScale[0] * 0.5; - const halfparentScaleY = this._parentScale[1] * 0.5; - this._vec3[0] = this._parentUp[0] * halfparentScaleY * cos + this._parentRight[0] * halfparentScaleX * cos; - this._vec3[1] = this._parentUp[1] * halfparentScaleY * cos + this._parentRight[1] * halfparentScaleX * cos; - this._vec3[2] = this._parentUp[2] * halfparentScaleY * cos + this._parentRight[2] * halfparentScaleX * cos; - (0, _glMatrix.vec3).transformQuat(this._vec3, this._vec3, this._quat); - const childTranslationX = this._parentTranslation[0] + this._vec3[0] + this._parentUp[0] * halfparentScaleY - this._parentRight[0] * halfparentScaleX; - const childTranslationY = this._parentTranslation[1] + this._vec3[1] + this._parentUp[1] * halfparentScaleY - this._parentRight[1] * halfparentScaleX; - const childTranslationZ = this._parentTranslation[2] + this._vec3[2] + this._parentUp[2] * halfparentScaleY - this._parentRight[2] * halfparentScaleX; - this._positions[childIndex1 * 3] = childTranslationX; - this._positions[childIndex1 * 3 + 1] = childTranslationY; - this._positions[childIndex1 * 3 + 2] = childTranslationZ; - this._levels[childIndex1] = parentLevel + 1; - this._volumes[childIndex1] = this._sizes[childIndex1 * 3] * this._sizes[childIndex1 * 3 + 1] * this._sizes[childIndex1 * 3 + 2]; - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, childTranslationX); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, childTranslationY); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, childTranslationZ); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, childTranslationX); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, childTranslationY); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, childTranslationZ); - if (this._count < ids.length) { - const childId2 = ids[this._count++]; - const childIndex2 = lookup[childId2]; - cos = Math.cos((0, _constantsJs.Constants).PI_OVER_TWO - angle); - this._sizes[childIndex2 * 3] = this._parentScale[0] * cos; - this._sizes[childIndex2 * 3 + 1] = this._parentScale[1] * cos; - this._sizes[childIndex2 * 3 + 2] = this._parentScale[2] * cos; - (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentForward, angle - (0, _constantsJs.Constants).PI_OVER_TWO); - (0, _glMatrix.quat).multiply(this._childRotation, this._quat, this._parentTwist); - this._rotations[childIndex2 * 4] = this._childRotation[0]; - this._rotations[childIndex2 * 4 + 1] = this._childRotation[1]; - this._rotations[childIndex2 * 4 + 2] = this._childRotation[2]; - this._rotations[childIndex2 * 4 + 3] = this._childRotation[3]; - this._vec3[0] = this._parentUp[0] * halfparentScaleY * cos - this._parentRight[0] * halfparentScaleX * cos; - this._vec3[1] = this._parentUp[1] * halfparentScaleY * cos - this._parentRight[1] * halfparentScaleX * cos; - this._vec3[2] = this._parentUp[2] * halfparentScaleY * cos - this._parentRight[2] * halfparentScaleX * cos; - (0, _glMatrix.vec3).transformQuat(this._vec3, this._vec3, this._quat); - const childTranslationX1 = this._parentTranslation[0] + this._vec3[0] + this._parentUp[0] * halfparentScaleY + this._parentRight[0] * halfparentScaleX; - const childTranslationY1 = this._parentTranslation[1] + this._vec3[1] + this._parentUp[1] * halfparentScaleY + this._parentRight[1] * halfparentScaleX; - const childTranslationZ1 = this._parentTranslation[2] + this._vec3[2] + this._parentUp[2] * halfparentScaleY + this._parentRight[2] * halfparentScaleX; - this._positions[childIndex2 * 3] = childTranslationX1; - this._positions[childIndex2 * 3 + 1] = childTranslationY1; - this._positions[childIndex2 * 3 + 2] = childTranslationZ1; - this._levels[childIndex2] = parentLevel + 1; - this._volumes[childIndex2] = this._sizes[childIndex2 * 3] * this._sizes[childIndex2 * 3 + 1] * this._sizes[childIndex2 * 3 + 2]; - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, childTranslationX1); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, childTranslationY1); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, childTranslationZ1); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, childTranslationX1); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, childTranslationY1); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, childTranslationZ1); - this._branch(childIndex1, ids, lookup, pseudoRandom); - this._branch(childIndex2, ids, lookup, pseudoRandom); - } + get maxBoundsX() { + return this._maxBoundsX; + } + set maxBoundsX(value) { + if (this._maxBoundsX != value) { + this._maxBoundsX = value; + this._hasChanged = true; + } + } + get maxBoundsY() { + return this._maxBoundsY; + } + set maxBoundsY(value) { + if (this._maxBoundsY != value) { + this._maxBoundsY = value; + this._hasChanged = true; + } + } + get maxBoundsZ() { + return this._maxBoundsZ; + } + set maxBoundsZ(value) { + if (this._maxBoundsZ != value) { + this._maxBoundsZ = value; + this._hasChanged = true; } } + constructor(core, options){ + this._core = core; + this._mMatrix = (0, _glMatrix.mat4).create(); + this._origin = (0, _glMatrix.vec3).create(); + this._translation = (0, _glMatrix.vec3).create(); + this._scale = (0, _glMatrix.vec3).create(); + this._transform = (0, _glMatrix.mat4).create(); + this._imageData = options.imageData; + this._minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; + this._minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; + this._minBoundsZ = options.minBoundsZ === undefined ? 0 : options.minBoundsZ; + this._maxBoundsX = options.maxBoundsX === undefined ? 1 : options.maxBoundsX; + this._maxBoundsY = options.maxBoundsY === undefined ? 1 : options.maxBoundsY; + this._maxBoundsZ = options.maxBoundsZ === undefined ? 1 : options.maxBoundsZ; + this._position = options.position ? (0, _glMatrix.vec3).clone(options.position) : (0, _glMatrix.vec3).create(); + this._rotation = options.rotation ? (0, _glMatrix.quat).clone(options.rotation) : (0, _glMatrix.quat).create(); + this._texCoord0 = options.texCoord0 ? (0, _glMatrix.vec2).clone(options.texCoord0) : (0, _glMatrix.vec2).fromValues(0, 0); + this._texCoord1 = options.texCoord1 ? (0, _glMatrix.vec2).clone(options.texCoord1) : (0, _glMatrix.vec2).fromValues(1, 1); + this._material = options.material === undefined ? -1 : options.material; + this._hasChanged = true; + } } -class Tree extends (0, _layoutJs.LayoutBase) { - constructor(core){ - super(core); - this._vec3 = (0, _glMatrix.vec3).create(); - this._quat = (0, _glMatrix.quat).create(); - this._childRotation = (0, _glMatrix.quat).create(); - this._parentRight = (0, _glMatrix.vec3).create(); - this._parentUp = (0, _glMatrix.vec3).create(); - this._parentForward = (0, _glMatrix.vec3).create(); - this._parentRotation = (0, _glMatrix.quat).create(); - this._parentTwist = (0, _glMatrix.quat).create(); +class ImageQuad extends ImageBase { + get width() { + return this._width; } - layout(buffer, ids, options) { - const start = window.performance.now(); - const sizeX = options.sizeX === undefined ? 1 : options.sizeX; - const sizeY = options.sizeY === undefined ? 1 : options.sizeY; - const sizeZ = options.sizeZ === undefined ? 1 : options.sizeZ; - this._angle = options.angle === undefined ? (0, _angleJs.AngleHelper).degreesToRadians(45) : options.angle; - this._randomAngle = options.randomAngle === undefined ? 0 : options.randomAngle; - this._twist = options.twist === undefined ? 0 : options.twist; - this._lengthScaling = options.lengthScaling === undefined ? 1 : options.lengthScaling; - this._thicknessScaling = options.thicknessScaling === undefined ? 1 : options.thicknessScaling; - this._randomTwist = options.randomTwist === undefined ? 0 : options.randomTwist; - this._randomSplit = options.randomSplit === undefined ? 0 : options.randomSplit; - this._randomLengthScaling = options.randomLengthScaling === undefined ? 0 : options.randomLengthScaling; - this._randomThicknessScaling = options.randomThicknessScaling === undefined ? 0 : options.randomThicknessScaling; - this._minLength = options.minLength === undefined ? 0 : options.minLength; - this._minThickness = options.minThickness === undefined ? 0 : options.minThickness; - if (!this._positions || this._positions.length < buffer.length * 3) { - this._positions = new Float32Array(buffer.length * 3); - this._sizes = new Float32Array(buffer.length * 3); - this._rotations = new Float32Array(buffer.length * 4); - this._parentRights = new Float32Array(buffer.length * 3); - this._parentUps = new Float32Array(buffer.length * 3); - this._parentForwards = new Float32Array(buffer.length * 3); - this._parentTwists = new Float32Array(buffer.length * 4); + set width(value) { + if (this._width != value) { + this._width = value; + this._hasChanged = true; } - let rootId; - const lookup = buffer.lookup; - const indices = {}; - const children = {}; - for(let i = 0; i < ids.length; i++){ - const id = ids[i]; - const index = lookup[id]; - const parentId = options.parentIds[index]; - const childId = options.childIds[index]; - indices[childId] = index; - if (children[parentId] === undefined) children[parentId] = []; - if (parentId == childId) rootId = parentId; - else children[parentId].push(childId); - } - const index1 = indices[rootId]; - this._positions[index1 * 3] = 0; - this._positions[index1 * 3 + 1] = 0; - this._positions[index1 * 3 + 2] = 0; - this.minLayoutBoundsX = 0; - this.minLayoutBoundsY = 0; - this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = 0; - this.maxLayoutBoundsY = 0; - this.maxLayoutBoundsZ = 0; - this._rotations[index1 * 4] = 0; - this._rotations[index1 * 4 + 1] = 0; - this._rotations[index1 * 4 + 2] = 0; - this._rotations[index1 * 4 + 3] = 1; - this._sizes[index1 * 3] = sizeX; - this._sizes[index1 * 3 + 1] = sizeY; - this._sizes[index1 * 3 + 2] = sizeZ; - const pseudoRandom = new (0, _mathJs.PseudoRandom)(0); - this._branch(rootId, indices, children, pseudoRandom); - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - update(buffer, ids, options) { - const start = window.performance.now(); - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < ids.length; i++){ - const id = ids[i]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (reverseX) positionX = this.modelOriginX + this.modelOriginX - positionX; - if (reverseY) positionY = this.modelOriginY + this.modelOriginY - positionY; - if (reverseZ) positionZ = this.modelOriginZ + this.modelOriginZ - positionZ; - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = this._sizes[index * 3] * this._boundsScaling; - _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; - _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - _quat[0] = this._rotations[index * 4]; - _quat[1] = this._rotations[index * 4 + 1]; - _quat[2] = this._rotations[index * 4 + 2]; - _quat[3] = this._rotations[index * 4 + 3]; - if (reverseX) { - _quat[1] = -_quat[1]; - _quat[2] = -_quat[2]; - } - if (reverseY) { - _quat[0] = -_quat[0]; - _quat[2] = -_quat[2]; - } - if (reverseZ) { - _quat[0] = -_quat[0]; - _quat[1] = -_quat[1]; - } - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = i / (ids.length - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = i / (ids.length - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + get height() { + return this._height; + } + set height(value) { + if (this._height != value) { + this._height = value; + this._hasChanged = true; } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - _branch(parentId, indices, children, pseudoRandom) { - const childIds = children[parentId]; - const parentIndex = indices[parentId]; - this._parentRotation[0] = this._rotations[parentIndex * 4]; - this._parentRotation[1] = this._rotations[parentIndex * 4 + 1]; - this._parentRotation[2] = this._rotations[parentIndex * 4 + 2]; - this._parentRotation[3] = this._rotations[parentIndex * 4 + 3]; - (0, _glMatrix.vec3).transformQuat(this._parentUp, (0, _constantsJs.Constants).VECTOR3_UNITY, this._parentRotation); - this._parentUps[parentIndex * 3] = this._parentUp[0]; - this._parentUps[parentIndex * 3 + 1] = this._parentUp[1]; - this._parentUps[parentIndex * 3 + 2] = this._parentUp[2]; - let twist = this._twist + (pseudoRandom.nextFloat() * 2 - 1) * this._randomTwist; - twist = (0, _mathJs.MathHelper).clamp(twist, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); - (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentUp, twist); - (0, _glMatrix.quat).multiply(this._parentTwist, this._quat, this._parentRotation); - this._parentTwists[parentIndex * 4] = this._parentTwist[0]; - this._parentTwists[parentIndex * 4 + 1] = this._parentTwist[1]; - this._parentTwists[parentIndex * 4 + 2] = this._parentTwist[2]; - this._parentTwists[parentIndex * 4 + 3] = this._parentTwist[3]; - (0, _glMatrix.vec3).transformQuat(this._parentRight, (0, _constantsJs.Constants).VECTOR3_UNITX, this._parentTwist); - this._parentRights[parentIndex * 3] = this._parentRight[0]; - this._parentRights[parentIndex * 3 + 1] = this._parentRight[1]; - this._parentRights[parentIndex * 3 + 2] = this._parentRight[2]; - (0, _glMatrix.vec3).transformQuat(this._parentForward, (0, _constantsJs.Constants).VECTOR3_UNITZ, this._parentTwist); - this._parentForwards[parentIndex * 3] = this._parentForward[0]; - this._parentForwards[parentIndex * 3 + 1] = this._parentForward[1]; - this._parentForwards[parentIndex * 3 + 2] = this._parentForward[2]; - for(let i = 0; i < childIds.length; i++){ - const childId = childIds[i]; - const childIndex = indices[childId]; - const parentScaleX = this._sizes[parentIndex * 3]; - const parentScaleY = this._sizes[parentIndex * 3 + 1]; - const parentScaleZ = this._sizes[parentIndex * 3 + 2]; - this._parentUp[0] = this._parentUps[parentIndex * 3]; - this._parentUp[1] = this._parentUps[parentIndex * 3 + 1]; - this._parentUp[2] = this._parentUps[parentIndex * 3 + 2]; - this._parentTwist[0] = this._parentTwists[parentIndex * 4]; - this._parentTwist[1] = this._parentTwists[parentIndex * 4 + 1]; - this._parentTwist[2] = this._parentTwists[parentIndex * 4 + 2]; - this._parentTwist[3] = this._parentTwists[parentIndex * 4 + 3]; - let lengthScale = this._lengthScaling + (pseudoRandom.nextFloat() * 2.0 - 1.0) * this._randomLengthScaling; - let thicknessScale = this._thicknessScaling + (pseudoRandom.nextFloat() * 2.0 - 1.0) * this._randomThicknessScaling; - lengthScale = Math.max(0.01, lengthScale); - thicknessScale = Math.max(0.01, thicknessScale); - this._sizes[childIndex * 3] = Math.max(parentScaleX * thicknessScale, this._minThickness); - this._sizes[childIndex * 3 + 1] = Math.max(parentScaleY * lengthScale, this._minLength); - this._sizes[childIndex * 3 + 2] = Math.max(parentScaleZ * thicknessScale, this._minThickness); - let split = (0, _constantsJs.Constants).TWO_PI * i / childIds.length + (pseudoRandom.nextFloat() * 2 - 1) * this._randomSplit; - (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentUp, split); - (0, _glMatrix.quat).multiply(this._childRotation, this._quat, this._parentTwist); - let angle = this._angle + (pseudoRandom.nextFloat() * 2 - 1) * this._randomAngle; - angle = (0, _mathJs.MathHelper).clamp(angle, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); - (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITX, angle); - (0, _glMatrix.quat).multiply(this._childRotation, this._childRotation, this._quat); - this._rotations[childIndex * 4] = this._childRotation[0]; - this._rotations[childIndex * 4 + 1] = this._childRotation[1]; - this._rotations[childIndex * 4 + 2] = this._childRotation[2]; - this._rotations[childIndex * 4 + 3] = this._childRotation[3]; - const halfParentScaleY = parentScaleY * 0.5; - const halfChildScaleY = this._sizes[childIndex * 3 + 1] * 0.5; - (0, _glMatrix.vec3).transformQuat(this._vec3, (0, _constantsJs.Constants).VECTOR3_UNITY, this._childRotation); - const childTranslationX = this._positions[parentIndex * 3] + this._parentUp[0] * halfParentScaleY + this._vec3[0] * halfChildScaleY; - const childTranslationY = this._positions[parentIndex * 3 + 1] + this._parentUp[1] * halfParentScaleY + this._vec3[1] * halfChildScaleY; - const childTranslationZ = this._positions[parentIndex * 3 + 2] + this._parentUp[2] * halfParentScaleY + this._vec3[2] * halfChildScaleY; - this._positions[childIndex * 3] = childTranslationX; - this._positions[childIndex * 3 + 1] = childTranslationY; - this._positions[childIndex * 3 + 2] = childTranslationZ; - this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, childTranslationX); - this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, childTranslationY); - this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, childTranslationZ); - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, childTranslationX); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, childTranslationY); - this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, childTranslationZ); - if (children[childId]) this._branch(childId, indices, children, pseudoRandom); + constructor(core, options){ + super(core, options); + this._width = options.width === undefined ? 1 : options.width; + this._height = options.height === undefined ? 1 : options.height; + this._texTransform = (0, _glMatrix.mat4).create(); + (0, _glMatrix.mat4).translate(this._texTransform, this._texTransform, (0, _glMatrix.vec3).fromValues(0, 1, 0)); + (0, _glMatrix.mat4).scale(this._texTransform, this._texTransform, (0, _glMatrix.vec3).fromValues(1, -1, 1)); + } + initialize() { + this._vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * 4); + this._indices = (0, _quadJs.Quad).INDICES; + this._indexCount = this._indices.length; + this._isInitialized = true; + } + update(elapsedTime) { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + const modelSizeX = this._maxBoundsX - this._minBoundsX; + const modelSizeY = this._maxBoundsY - this._minBoundsY; + const modelSizeZ = this._maxBoundsZ - this._minBoundsZ; + const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; + (0, _glMatrix.vec3).set(this._origin, (this._minBoundsX + this._maxBoundsX) / 2, (this._minBoundsY + this._maxBoundsY) / 2, (this._minBoundsZ + this._maxBoundsZ) / 2); + (0, _glMatrix.vec3).subtract(this._translation, this._position, this._origin); + (0, _glMatrix.vec3).scale(this._translation, this._translation, boundsScaling); + (0, _glMatrix.vec3).set(this._scale, this._width, this._height, 1); + (0, _glMatrix.vec3).scale(this._scale, this._scale, boundsScaling); + (0, _glMatrix.mat4).fromRotationTranslationScale(this._transform, this._rotation, this._translation, this._scale); + this._verticesView = (0, _quadJs.Quad).normalTextured(this._transform, this._texTransform); + this._vertices = this._verticesView.buffer; + if (this.hasChangedCallback) this.hasChangedCallback(); } } } - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/angle.js":"eKtPm","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8WJgN":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Sheet", ()=>Sheet); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); -var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class Sheet extends (0, _layoutJs.LayoutBase) { - layout(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const side = options.side === undefined ? Math.ceil(Math.sqrt(count)) : options.side; - if (!this._positions || this._positions.length < buffer.length * 3) this._positions = new Float32Array(buffer.length * 3); - this.minLayoutBoundsX = 0; - this.minLayoutBoundsY = 0; - this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = 0; - this.maxLayoutBoundsY = 0; - this.maxLayoutBoundsZ = 0; - const lookup = buffer.lookup; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - const y = Math.floor(i / side); - const x = i - y * side; - this._positions[index * 3] = x; - this._positions[index * 3 + 1] = y; - this._positions[index * 3 + 2] = 0; - this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, x); - this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, y); +class ImageSphere extends ImageBase { + get radius() { + return this._radius; + } + set radius(value) { + if (this._radius != value) { + this._radius = value; + this._hasChanged = true; } - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - update(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const padding = options.padding === undefined ? 0 : options.padding; - const thickness = options.thickness === undefined ? 1 : options.thickness; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - const scale = (0, _glMatrix.vec3).fromValues((1 - padding) * this._boundsScaling, (1 - padding) * this._boundsScaling, thickness * this._boundsScaling); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = this._positions[index * 3]; - let positionY = this._positions[index * 3 + 1]; - let positionZ = this._positions[index * 3 + 2]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; - } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setScale(dataView, index, scale); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, (0, _constantsJs.Constants).QUAT_IDENTITY); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : 0 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + constructor(core, options){ + super(core, options); + this._radius = options.radius === undefined ? 0.5 : options.radius; + this._slices = options.slices === undefined ? 72 : options.slices; + this._stacks = options.stacks === undefined ? 36 : options.stacks; + } + initialize() { + this._sphere = new (0, _sphereJs.Sphere)(this._core); + this._vertices = this._sphere.normalTextured(this._slices, this._stacks, (0, _constantsJs.Constants).MAT4_IDENTITY).buffer; + this._indices = this._sphere.indices(this._slices, this._stacks); + this._indexCount = this._indices.length; + this._isInitialized = true; + } + update(elapsedTime) { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + const modelSizeX = this._maxBoundsX - this._minBoundsX; + const modelSizeY = this._maxBoundsY - this._minBoundsY; + const modelSizeZ = this._maxBoundsZ - this._minBoundsZ; + const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; + (0, _glMatrix.vec3).set(this._origin, (this._minBoundsX + this._maxBoundsX) / 2, (this._minBoundsY + this._maxBoundsY) / 2, (this._minBoundsZ + this._maxBoundsZ) / 2); + (0, _glMatrix.vec3).set(this._scale, this._radius, this._radius, this._radius); + (0, _glMatrix.vec3).scale(this._scale, this._scale, boundsScaling); + (0, _glMatrix.mat4).fromRotationTranslationScaleOrigin(this._transform, this._rotation, this._position, this._scale, this._origin); + this._verticesView = this._sphere.normalTextured(this._slices, this._stacks, this._transform); + this._vertices = this._verticesView.buffer; + if (this.hasChangedCallback) this.hasChangedCallback(); } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)} ms`); } } -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dMHbq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SquarifiedTreeMap", ()=>SquarifiedTreeMap); -parcelHelpers.export(exports, "CubifiedTreeMap", ()=>CubifiedTreeMap); -parcelHelpers.export(exports, "TreeMapHelper", ()=>TreeMapHelper); +},{"gl-matrix":"5x28d","../vertex.js":"4J2YE","../meshes/quad.js":"3PqJr","../meshes/sphere.js":"aj6T2","../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aj6T2":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Sphere", ()=>Sphere); +var _glMatrix = require("gl-matrix"); var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _mainJs = require("../main.js"); +var _angleJs = require("../helpers/angle.js"); var _vertexJs = require("../vertex.js"); -var _layoutJs = require("./layout.js"); -class SquarifiedTreeMap extends (0, _layoutJs.LayoutBase) { - get positionsX() { - return this._positionsX; - } - get positionsY() { - return this._positionsY; - } - get sizesX() { - return this._sizesX; - } - get sizesY() { - return this._sizesY; - } - layout(buffer, ids, options) { - const start = window.performance.now(); - const size = options.size == undefined ? 1 : options.size; - let offset = options.offset === undefined ? 0 : options.offset; - let count = options.count === undefined ? ids.length : options.count; - this.minLayoutBoundsX = options.minBoundsX; - this.minLayoutBoundsY = options.minBoundsY; - this.minLayoutBoundsZ = options.minBoundsZ; - this.maxLayoutBoundsX = options.maxBoundsX; - this.maxLayoutBoundsY = options.maxBoundsY; - this.maxLayoutBoundsZ = options.maxBoundsZ; - const sizeX = this.maxLayoutBoundsX - this.minLayoutBoundsX; - const sizeY = this.maxLayoutBoundsY - this.minLayoutBoundsY; - if (options.sizes) { - for(let i = 0; i < count; i++){ - if (options.sizes[ids[offset]] > 0) break; - offset++; - count--; +class Sphere { + constructor(core){} + positions(slices, stacks, transform) { + const vertices = new Float32Array((slices + 1) * (stacks + 1) * (0, _vertexJs.PositionVertex).SIZE); + const position = (0, _glMatrix.vec3).create(); + let index = 0; + for(let stack = 0; stack <= stacks; stack++){ + const latitude = 90 - 180 * stack / stacks; + for(let slice = 0; slice <= slices; slice++){ + const longitude = 360 * slice / slices - 180; + (0, _angleJs.AngleHelper).sphericalToCartesian(1, longitude, latitude, position); + (0, _glMatrix.vec3).transformMat4(position, position, transform); + (0, _vertexJs.PositionVertex).setPosition(vertices, index++, position); } - if (count == 0) return; - } else if (size <= 0) return; - if (!this._positionsX || this._positionsX.length < buffer.length) { - this._positionsX = new Float32Array(buffer.length); - this._positionsY = new Float32Array(buffer.length); - this._sizesX = new Float32Array(buffer.length); - this._sizesY = new Float32Array(buffer.length); } - TreeMapHelper.squarifiedLayout(ids, options.sizes, this._positionsX, this._positionsY, this._sizesX, this._sizesY, offset, offset + count - 1, this.minLayoutBoundsX, this.minLayoutBoundsY, sizeX, sizeY, buffer.lookup); - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); + return vertices; } - update(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const heights = options.heights; - const minHeight = options.minHeight === undefined ? 0 : options.minHeight; - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const padding = options.padding === undefined ? 0 : options.padding; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); - let maxHeight; - if (heights) { - maxHeight = 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - maxHeight = Math.max(heights[id], maxHeight); - } - } else maxHeight = 1; - const heightScaling = (this.maxLayoutBoundsZ - this.minLayoutBoundsZ) / maxHeight; - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i1 = 0; i1 < count; i1++){ - const id1 = ids[i1 + offset]; - const index = lookup[id1]; - const height = Math.max(heights ? heights[id1] * heightScaling : heightScaling, minHeight); - let positionX = this._positionsX[index]; - let positionY = this._positionsY[index]; - let positionZ = this.minLayoutBoundsZ + height / 2; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id1] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id1] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id1] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + indices(slices, stacks) { + const indices = new Uint16Array(slices * stacks * 6); + let index = 0; + for(let stack = 0; stack < stacks; stack++){ + const top = stack * (slices + 1); + const bottom = (stack + 1) * (slices + 1); + for(let slice = 0; slice < slices; slice++){ + if (stack != 0) { + indices[index++] = top + slice; + indices[index++] = bottom + slice; + indices[index++] = top + slice + 1; + } + if (stack != stacks - 1) { + indices[index++] = top + slice + 1; + indices[index++] = bottom + slice; + indices[index++] = bottom + slice + 1; + } } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = Math.max((this._sizesX[index] - padding) * this._boundsScaling, 0); - _vec3[1] = Math.max((this._sizesY[index] - padding) * this._boundsScaling, 0); - _vec3[2] = height * this._boundsScaling; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id1], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id1] : id1); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id1) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id1], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i1 / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id1], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i1 / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id1] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id1] * this._boundsScaling : 0); } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); + return indices; } -} -class CubifiedTreeMap extends (0, _layoutJs.LayoutBase) { - layout(buffer, ids, options) { - const start = window.performance.now(); - const isTopToBottom = options.isTopToBottom === undefined ? false : options.isTopToBottom; - let offset = options.offset === undefined ? 0 : options.offset; - let count = options.count === undefined ? ids.length : options.count; - this.minLayoutBoundsX = options.minBoundsX; - this.minLayoutBoundsY = options.minBoundsY; - this.minLayoutBoundsZ = options.minBoundsZ; - this.maxLayoutBoundsX = options.maxBoundsX; - this.maxLayoutBoundsY = options.maxBoundsY; - this.maxLayoutBoundsZ = options.maxBoundsZ; - if (options.sizes) { - for(let i = 0; i < count; i++){ - if (options.sizes[ids[offset]] > 0) break; - offset++; - count--; - } - if (count == 0) return; + textured(slices, stacks, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { + const positions = this.positions(slices, stacks, transform); + const texCoords = this._texCoords(slices, stacks, texTransform); + const vertices = new ArrayBuffer((0, _vertexJs.PositionTextureVertex).SIZE_BYTES * positions.length / 3); + const verticesView = new DataView(vertices); + const position = (0, _glMatrix.vec3).create(); + const texCoord = (0, _glMatrix.vec2).create(); + for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ + (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); + (0, _vertexJs.PositionTextureVertex).setPosition(verticesView, i, position); + (0, _vertexJs.PositionTextureVertex).setTexCoord(verticesView, i, texCoord); } - const sizeX = this.maxLayoutBoundsX - this.minLayoutBoundsX; - const sizeY = this.maxLayoutBoundsY - this.minLayoutBoundsY; - const sizeZ = this.maxLayoutBoundsZ - this.minLayoutBoundsZ; - const minHeight = this._core.config.minCubifiedTreeMapSlice / sizeY; - const side = Math.sqrt(sizeX * sizeZ); - const total = options.sizes ? TreeMapHelper.totalSize(ids, options.sizes, offset, offset + count - 1) : count; - if (!this._positionsX || this._positionsX.length < buffer.length) { - this._positionsX = new Float32Array(buffer.length); - this._positionsY = new Float32Array(buffer.length); - this._positionsZ = new Float32Array(buffer.length); - this._sizesX = new Float32Array(buffer.length); - this._sizesY = new Float32Array(buffer.length); - this._sizesZ = new Float32Array(buffer.length); + return verticesView; + } + normalTextured(slices, stacks, transform, texTransform = (0, _constantsJs.Constants).MAT4_IDENTITY) { + const positions = this.positions(slices, stacks, transform); + const texCoords = this._texCoords(slices, stacks, texTransform); + const vertices = new ArrayBuffer((0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES * positions.length / 3); + const verticesView = new DataView(vertices); + const position = (0, _glMatrix.vec3).create(); + const texCoord = (0, _glMatrix.vec2).create(); + const normal = (0, _glMatrix.vec3).create(); + for(let i = 0; i < positions.length / (0, _vertexJs.PositionVertex).SIZE; i++){ + (0, _glMatrix.vec3).set(position, positions[i * (0, _vertexJs.PositionVertex).SIZE], positions[i * (0, _vertexJs.PositionVertex).SIZE + 1], positions[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec2).set(texCoord, texCoords[i * 2], texCoords[i * 2 + 1]); + (0, _vertexJs.PositionNormalTextureVertex).setPosition(verticesView, i, position); + (0, _vertexJs.PositionNormalTextureVertex).setTexCoord(verticesView, i, texCoord); + (0, _glMatrix.vec3).set(normal, position[0] - transform[12], position[1] - transform[13], position[2] - transform[14]); + (0, _glMatrix.vec3).normalize(normal, normal); + (0, _vertexJs.PositionNormalTextureVertex).setNormal(verticesView, i, normal); } - TreeMapHelper.cubifiedLayout(ids, options.sizes, this._positionsX, this._positionsY, this._positionsZ, this._sizesX, this._sizesY, this._sizesZ, offset, offset + count - 1, this.minLayoutBoundsX, this.minLayoutBoundsY, this.minLayoutBoundsZ, sizeX, sizeY, sizeZ, side, total, minHeight, isTopToBottom, buffer.lookup); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); + return verticesView; } - update(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const padding = options.padding === undefined ? 0 : options.padding; - const paddingZ = options.thickness === undefined ? padding : 0; - const thickness = options.thickness === undefined ? 1 : options.thickness; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = this._positionsX[index]; - let positionY = this._positionsY[index]; - let positionZ = this._positionsZ[index]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; - } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = Math.max((this._sizesX[index] - padding) * this._boundsScaling, 0); - _vec3[1] = Math.max((this._sizesY[index] - padding) * this._boundsScaling, 0); - _vec3[2] = Math.max((this._sizesZ[index] - paddingZ) * this._boundsScaling, 0) * thickness; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, (0, _constantsJs.Constants).QUAT_IDENTITY); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + _texCoords(slices, stacks, transform) { + const texCoords = new Float32Array((slices + 1) * (stacks + 1) * 2); + const texCoord = (0, _glMatrix.vec2).create(); + let index = 0; + for(let stack = 0; stack <= stacks; stack++)for(let slice = 0; slice <= slices; slice++){ + (0, _glMatrix.vec2).set(texCoord, slice / slices, stack / stacks); + (0, _glMatrix.vec2).transformMat4(texCoord, texCoord, transform); + texCoords[index++] = texCoord[0]; + texCoords[index++] = texCoord[1]; } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); + return texCoords; } } -class TreeMapHelper { - static squarifiedLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, to, x, y, width, height, lookup) { - if (from > to) return; - if (to - from < 2) { - TreeMapHelper._sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, to, x, y, width, height, lookup); - return; - } - const totalSize = sizes ? TreeMapHelper.totalSize(ids, sizes, from, to) : to - from + 1; - const a = sizes ? sizes[ids[to]] / totalSize : 1 / totalSize; - let b = a; - let mid = to; - if (width < height) { - while(mid > from){ - const aspect = TreeMapHelper._aspect(height, width, a, b); - const q = sizes ? sizes[ids[mid - 1]] / totalSize : 1 / totalSize; - if (TreeMapHelper._aspect(height, width, a, b + q) > aspect) break; - mid--; - b += q; - } - TreeMapHelper._sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, mid, to, x, y, width, height * b, lookup); - TreeMapHelper.squarifiedLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, mid - 1, x, y + height * b, width, height * (1 - b), lookup); - } else { - while(mid > from){ - const aspect1 = TreeMapHelper._aspect(width, height, a, b); - const q1 = sizes ? sizes[ids[mid - 1]] / totalSize : 1 / totalSize; - if (TreeMapHelper._aspect(width, height, a, b + q1) > aspect1) break; - mid--; - b += q1; - } - TreeMapHelper._sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, mid, to, x, y, width * b, height, lookup); - TreeMapHelper.squarifiedLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, mid - 1, x + width * b, y, width * (1 - b), height, lookup); + +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/angle.js":"53hwW","../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bmBQh":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "KeyVisual", ()=>KeyVisual); +parcelHelpers.export(exports, "KeyBase", ()=>KeyBase); +parcelHelpers.export(exports, "NominalKey", ()=>NominalKey); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +var _textJs = require("../helpers/text.js"); +var _scatterJs = require("../layouts/scatter.js"); +var _mathJs = require("../helpers/math.js"); +var _labelsJs = require("./labels.js"); +class KeyVisual { + render(elapsedTime, xrFrame) {} + update(elapsedTime) {} + constructor(key){ + this.key = key; + } +} +class KeyBase { + get isInitialized() { + return this._isInitialized; + } + get minBoundsX() { + return this._minBoundsX; + } + set minBoundsX(value) { + if (value != this.minBoundsX) { + this._minBoundsX = value; + this._hasChanged = true; } } - static totalSize(ids, sizes, from, to) { - let size = 0; - for(let i = from; i <= to; i++)size += sizes[ids[i]]; - return size; + get maxBoundsX() { + return this._maxBoundsX; } - static _sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, to, x, y, width, height, lookup) { - const totalSize = sizes ? TreeMapHelper.totalSize(ids, sizes, from, to) : to - from + 1; - let a = 0; - for(let i = to; i >= from; i--){ - const id = ids[i]; - const index = lookup[id]; - const b = sizes ? sizes[id] / totalSize : 1 / totalSize; - if (width > height) { - sizesY[index] = height; - sizesX[index] = width * b; - positionsY[index] = y + height / 2; - positionsX[index] = x + width * a + width * b / 2; - } else { - sizesX[index] = width; - sizesY[index] = height * b; - positionsX[index] = x + width / 2; - positionsY[index] = y + height * a + height * b / 2; - } - a += b; + set maxBoundsX(value) { + if (value != this.minBoundsX) { + this._maxBoundsX = value; + this._hasChanged = true; } } - static _aspect(big, small, a, b) { - const x = big * b / (small * a / b); - if (x < 1) return 1 / x; - return x; + get minBoundsY() { + return this._minBoundsY; } - static cubifiedLayout(ids, sizes, positionsX, positionsY, positionsZ, sizesX, sizesY, sizesZ, from, to, x, y, z, width, height, depth, side, total, minHeight, isTopToBottom, lookup) { - if (from > to) return; - let sliceHeight = 0; - let sliceTotal = 0; - let previousAspect = 0; - let mid = to; - while(mid >= from){ - const itemSize = sizes ? sizes[ids[mid]] : 1; - sliceTotal += itemSize; - sliceHeight = height * sliceTotal / total; - const remainingHeight = height - sliceHeight; - if (remainingHeight < minHeight) { - mid = from; - const totalSize = sizes ? this.totalSize(ids, sizes, mid, to) : to - from + 1; - sliceHeight = height * totalSize / total; - break; - } - const itemSide = Math.sqrt(itemSize / sliceTotal) * side; - const aspect = itemSide > sliceHeight ? sliceHeight / itemSide : itemSide / sliceHeight; - if (aspect < previousAspect || mid == from) break; - previousAspect = aspect; - mid--; + set minBoundsY(value) { + if (value != this.minBoundsY) { + this._minBoundsY = value; + this._hasChanged = true; } - TreeMapHelper.squarifiedLayout(ids, sizes, positionsX, positionsZ, sizesX, sizesZ, mid, to, x, z, width, depth, lookup); - for(let j = mid; j <= to; j++){ - const id = ids[j]; - const index = lookup[id]; - sizesY[index] = Math.max(sliceHeight, 0.01); - positionsY[index] = isTopToBottom ? positionsY[index] = y + sliceHeight / 2 : y + height - sliceHeight / 2; + } + get maxBoundsY() { + return this._maxBoundsY; + } + set maxBoundsY(value) { + if (value != this.minBoundsY) { + this._maxBoundsY = value; + this._hasChanged = true; } - TreeMapHelper.cubifiedLayout(ids, sizes, positionsX, positionsY, positionsZ, sizesX, sizesY, sizesZ, from, mid - 1, x, isTopToBottom ? y + sliceHeight : y, z, width, height - sliceHeight, depth, side, total - sliceTotal, minHeight, isTopToBottom, lookup); } -} - -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../main.js":"1Kju3","../vertex.js":"ddAub","./layout.js":"liYq1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ip4E8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "StackBase", ()=>StackBase); -parcelHelpers.export(exports, "Stack", ()=>Stack); -parcelHelpers.export(exports, "StackTreeMap", ()=>StackTreeMap); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _constantsJs = require("../constants.js"); -var _mathJs = require("../helpers/math.js"); -var _vertexJs = require("../vertex.js"); -var _treemapJs = require("./treemap.js"); -var _layoutJs = require("./layout.js"); -var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -class StackBase extends (0, _layoutJs.LayoutBase) { - get maxCount() { - return this._maxCount; + get minBoundsZ() { + return this._minBoundsZ; } - get levels() { - return this._levels; + set minBoundsZ(value) { + if (value != this.minBoundsZ) { + this._minBoundsZ = value; + this._hasChanged = true; + } } - get binCounts() { - return this._binCounts; + get maxBoundsZ() { + return this._maxBoundsZ; } - getPositionX(index) { - return this._positionsX[index]; + set maxBoundsZ(value) { + if (value != this.minBoundsZ) { + this._maxBoundsZ = value; + this._hasChanged = true; + } } - getPositionY(index) { - return this._positionsY[index]; + get unitType() { + return this._unitType; } - getPositionZ(index) { - return this._positionsZ[index]; + set unitType(value) { + if (this._unitType != value) { + this._unitType = value; + this._hasChanged = true; + } } -} -class Stack extends StackBase { - get maxLevel() { - return this._maxLevel; + get palette() { + return this._palette; } - layout(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - this._maxLevel = 0; - const sizeX = options.sizeX == undefined ? 1 : options.sizeX; - const sizeZ = options.sizeZ == undefined ? 1 : options.sizeZ; - const spacingX = options.spacingX == undefined ? 0 : options.spacingX; - const spacingZ = options.spacingZ == undefined ? 0 : options.spacingZ; - const binsX = options.binsX == undefined ? 1 : options.binsX; - const binsZ = options.binsZ == undefined ? 1 : options.binsZ; - this._height = options.height == undefined ? 1 : options.height; - if (!this._positionsX || this._positionsX.length < buffer.length) { - this._positionsX = new Float32Array(buffer.length); - this._positionsY = new Float32Array(buffer.length); - this._positionsZ = new Float32Array(buffer.length); - this._levels = new Uint32Array(buffer.length); + set palette(value) { + if (this._palette != value) { + this._palette = value; + this._hasChanged = true; } - this._binCounts = new Uint32Array(binsX * binsZ); - let maxBinCount = 0; - let maxBinLevel = 0; - let positionX, positionY, positionZ; + } + get materials() { + return this._materials; + } + set materials(value) { + if (this._materials != value) { + this._materials = value; + this._hasChanged = true; + } + } + get sizesX() { + return this._sizesX; + } + set sizesX(value) { + if (this._sizesX != value) { + this._sizesX = value; + this._hasChanged = true; + } + } + get sizesY() { + return this._sizesY; + } + set sizesY(value) { + if (this._sizesY != value) { + this._sizesY = value; + this._hasChanged = true; + } + } + get sizesZ() { + return this._sizesZ; + } + set sizesZ(value) { + if (this._sizesZ != value) { + this._sizesZ = value; + this._hasChanged = true; + } + } + get spacing() { + return this._spacing; + } + set spacing(value) { + if (this._spacing != value) { + this._spacing = value; + this._hasChanged = true; + } + } + get textVertices() { + return this._textVertices; + } + get textIndices() { + return this._textIndices; + } + get labelMMatrix() { + return this._labelMMatrix; + } + set labelPositions(value) { + if (this._labelPositions != value) { + this._labelPositions = value; + this._hasChanged = true; + } + } + set labels(value) { + if (this._labels != value) { + this._labels = value; + this._hasChanged = true; + } + } + set labelSize(value) { + if (this._labelSize != value) { + this._labelSize = value; + this._hasChanged = true; + } + } + get labelOrientation() { + return this._orientation; + } + set labelOrientation(value) { + if (this._orientation != value) { + this._orientation = value; + this._hasChanged = true; + } + } + get titleIndexCount() { + return this._titleIndexCount; + } + get titleIndexOffset() { + return this._titleIndexOffset; + } + get titleMMatrix() { + return this._titleMMatrix; + } + set title(value) { + if (this._title != value) { + this._title = value; + this._hasChanged = true; + } + } + set titleSize(value) { + if (this._titleSize != value) { + this._titleSize = value; + this._hasChanged = true; + } + } + constructor(core, options){ + this._core = core; + this._textMetric = { + width: 0, + maxHeight: 0, + maxTop: 0 + }; + } + initialize() { + this._isInitialized = true; + } + update(elapsedTime) { + if (this.isInitialized) { + if (this._hasChanged) { + const start = window.performance.now(); + this._hasChanged = false; + (0, _glMatrix.vec3).set(this._size, this._maxBoundsX - this._minBoundsX, this._maxBoundsY - this._minBoundsY, this._maxBoundsZ - this._minBoundsZ); + const maxBounds = Math.max(Math.max(this._size[0], this._size[1]), this._size[2]); + (0, _glMatrix.vec3).scale(this._size, this._size, 1 / maxBounds); + this._update(this._size); + if (this.hasChangedCallback) this.hasChangedCallback(); + this._core.log.write((0, _mainJs.LogLevel).info, `key updated ${Math.round(window.performance.now() - start)}ms`); + } + } + } + _update(size) {} +} +class NominalKey extends KeyBase { + constructor(core, options){ + super(core, options); + const minBoundsX = options.minBoundsX === undefined ? 0 : options.minBoundsX; + const minBoundsY = options.minBoundsY === undefined ? 0 : options.minBoundsY; + const minBoundsZ = options.minBoundsZ === undefined ? 0 : options.minBoundsZ; + const maxBoundsX = options.maxBoundsX === undefined ? 0 : options.maxBoundsX; + const maxBoundsY = options.maxBoundsY === undefined ? 0 : options.maxBoundsY; + const maxBoundsZ = options.maxBoundsZ === undefined ? 0 : options.maxBoundsZ; + const positionX = options.positionX === undefined ? 0 : options.positionX; + const positionY = options.positionY === undefined ? 0 : options.positionY; + const positionZ = options.positionZ === undefined ? 0 : options.positionZ; + const sizeX = options.sizeX === undefined ? 1 : options.sizeX; + const sizeY = options.sizeY === undefined ? 1 : options.sizeY; + const sizeZ = options.sizeZ === undefined ? 1 : options.sizeZ; + const spacing = options.spacing === undefined ? 1 : options.spacing; + const labelScale = options.labelScale === undefined ? 1 : options.labelScale; + const labelMaxGlyphs = options.labelMaxGlyphs === undefined ? this._core.config.keyLabelMaxGlyphs : options.labelMaxGlyphs; + const titleScale = options.titleScale === undefined ? 1 : options.titleScale; + const titleMaxGlyphs = options.titleMaxGlyphs === undefined ? this._core.config.keyTitleMaxGlyphs : options.titleMaxGlyphs; + const font = options.font ? options.font : this._core.font; + const horizontalAlignment = options.horizontalAlignment === undefined ? (0, _mainJs.HorizontalAlignment).center : options.horizontalAlignment; + const verticalAlignment = options.verticalAlignment === undefined ? (0, _mainJs.VerticalAlignment).center : options.verticalAlignment; + const orientation = options.orientation === undefined ? (0, _mainJs.Orientation).horizontal : options.orientation; + const labelPosition = options.labelPosition === undefined ? (0, _mainJs.Edge2D).right : options.labelPosition; + const labelOrientation = options.labelOrientation === undefined ? (0, _mainJs.Orientation).horizontal : options.labelOrientation; + const rotation = (0, _glMatrix.quat).create(); + let count = options.values.length; + const ids = new Uint32Array(count); + let minValue = Number.MAX_VALUE; + let maxValue = -Number.MAX_VALUE; + for(let i = 0; i < count; i++){ + ids[i] = i; + const value = options.values[i]; + minValue = Math.min(minValue, value); + maxValue = Math.max(maxValue, value); + } + const materialIds = new Uint32Array(count); + for(let i = 0; i < count; i++)materialIds[i] = (0, _mathJs.MathHelper).normalize(options.values[i], minValue, maxValue, 0, options.palette.length / 4 - 1); + let glyphCount = 0; + let totalLabelWidth = 0; + let maxLabelWidth = 0; + for(let i = 0; i < count; i++){ + const label = (0, _textJs.TextHelper).truncate(options.labels[i], labelMaxGlyphs); + glyphCount += label.length; + (0, _textJs.TextHelper).measure(font, label, this._textMetric); + const width = this._textMetric.width; + totalLabelWidth += width; + maxLabelWidth = Math.max(width, maxLabelWidth); + } + let titleWidth = 0; + let title; + if (options.title) { + title = (0, _textJs.TextHelper).truncate(options.title, titleMaxGlyphs); + glyphCount += title.length; + (0, _textJs.TextHelper).measure(font, title, this._textMetric); + titleWidth = this._textMetric.width; + } + let width; + let height; + switch(orientation){ + case (0, _mainJs.Orientation).horizontal: + switch(labelPosition){ + case (0, _mainJs.Edge2D).bottom: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + case (0, _mainJs.Edge2D).left: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + case (0, _mainJs.Edge2D).right: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + case (0, _mainJs.Edge2D).top: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + } + break; + case (0, _mainJs.Orientation).vertical: + switch(labelPosition){ + case (0, _mainJs.Edge2D).bottom: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + case (0, _mainJs.Edge2D).left: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + case (0, _mainJs.Edge2D).right: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + case (0, _mainJs.Edge2D).top: + switch(labelOrientation){ + case (0, _mainJs.Orientation).horizontal: + break; + case (0, _mainJs.Orientation).vertical: + break; + } + break; + } + break; + } + switch(orientation){ + case (0, _mainJs.Orientation).horizontal: + width = Math.max(sizeX * count + spacing * (count - 1) + totalLabelWidth, titleWidth); + height = sizeY; + if (options.title) height += titleScale; + break; + case (0, _mainJs.Orientation).vertical: + width = Math.max(sizeX + labelScale / 2 + maxLabelWidth, titleWidth); + height = sizeY * count + spacing * (count - 1); + if (options.title) height += titleScale; + break; + } + let originX = positionX; + let originY = positionY; + let originZ = positionZ; + switch(horizontalAlignment){ + case (0, _mainJs.HorizontalAlignment).center: + break; + case (0, _mainJs.HorizontalAlignment).left: + originX += width / 2; + break; + case (0, _mainJs.HorizontalAlignment).right: + originX -= width / 2; + break; + } + switch(verticalAlignment){ + case (0, _mainJs.VerticalAlignment).bottom: + originY += height / 2; + break; + case (0, _mainJs.VerticalAlignment).center: + break; + case (0, _mainJs.VerticalAlignment).top: + originY -= height / 2; + break; + } + const positionsX = new Float64Array(count); + const positionsY = new Float64Array(count); + const positionsZ = new Float64Array(count); + for(let i = 0; i < count; i++){ + positionsX[i] = originX - width / 2 + sizeX / 2; + positionsY[i] = originY + height / 2 - i * (sizeY + spacing); + positionsZ[i] = originZ + sizeZ / 2; + } + const scatter = new (0, _scatterJs.Scatter)(this._core); + const scatterLayoutOptions = { + positionsX: positionsX, + positionsY: positionsY, + positionsZ: positionsZ + }; + scatter.layout(this._transitionBuffer.currentBuffer, ids, scatterLayoutOptions); + const scatterVertexOptions = { + minBoundsX: minBoundsX, + minBoundsY: minBoundsY, + minBoundsZ: minBoundsZ, + maxBoundsX: maxBoundsX, + maxBoundsY: maxBoundsY, + maxBoundsZ: maxBoundsZ, + colors: options.values, + minColor: minValue, + maxColor: maxValue, + sizeScalingX: sizeX, + sizeScalingY: sizeY, + sizeScalingZ: sizeZ, + materials: materialIds + }; + scatter.update(this._transitionBuffer.currentBuffer, ids, scatterVertexOptions); + const labelSetOptions = { + text: options.labels, + maxGlyphs: glyphCount, + scale: labelScale, + font: font + }; + const labelSet = new (0, _labelsJs.LabelSet)(this._core, labelSetOptions); + if (options.title) count++; + const labelPositionsX = new Float64Array(count); + const labelPositionsY = new Float64Array(count); + const labelPositionsZ = new Float64Array(count); + for(let i = 0; i < (options.title ? count - 1 : count); i++){ + labelPositionsX[i] = originX - width / 2 + sizeX + labelScale / 2; + labelPositionsY[i] = positionsY[i]; + labelPositionsZ[i] = originZ; + } + options.title; + labelSet.minBoundsX = minBoundsX; + labelSet.minBoundsY = minBoundsY; + labelSet.minBoundsZ = minBoundsZ; + labelSet.maxBoundsX = maxBoundsX; + labelSet.maxBoundsY = maxBoundsY; + labelSet.maxBoundsZ = maxBoundsZ; + labelSet.positionsX = positionsX; + labelSet.positionsY = positionsY; + labelSet.positionsZ = positionsZ; + labelSet.rotation = new Float64Array([ + rotation[0], + rotation[1], + rotation[2], + rotation[3] + ]); + labelSet.horizontalAlignment = (0, _mainJs.HorizontalAlignment).left; + } +} + +},{"gl-matrix":"5x28d","../main.js":"f421K","../helpers/text.js":"fG2oi","../layouts/scatter.js":"bwpY2","../helpers/math.js":"f65d0","./labels.js":"PwNrz","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bwpY2":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Scatter", ()=>Scatter); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class Scatter extends (0, _layoutJs.LayoutBase) { + layout(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const positionScalingX = options.positionScalingX === undefined ? 1 : options.positionScalingX; + const positionScalingY = options.positionScalingY === undefined ? 1 : options.positionScalingY; + const positionScalingZ = options.positionScalingZ === undefined ? 1 : options.positionScalingZ; + if (!this._positions || this._positions.length < buffer.length * 3) this._positions = new Float32Array(buffer.length * 3); + this.minLayoutBoundsX = Number.MAX_VALUE; + this.minLayoutBoundsY = Number.MAX_VALUE; + this.minLayoutBoundsZ = Number.MAX_VALUE; + this.maxLayoutBoundsX = -Number.MAX_VALUE; + this.maxLayoutBoundsY = -Number.MAX_VALUE; + this.maxLayoutBoundsZ = -Number.MAX_VALUE; const lookup = buffer.lookup; for(let i = 0; i < count; i++){ const id = ids[i + offset]; const index = lookup[id]; - const binIdX = options.binIdsX ? options.binIdsX[id] : 0; - const binIdZ = options.binIdsZ ? options.binIdsZ[id] : 0; - const binId = binIdX + binIdZ * binsX; - if (binId > this._binCounts.length - 1) this._core.log.write((0, _mainJs.LogLevel).warn, "bin overflow"); - const binCount = this._binCounts[binId]; - const level = Math.floor(binCount / sizeX / sizeZ); - this._levels[index] = level; - const levelCount = binCount - level * sizeX * sizeZ; - const itemZ = Math.floor(levelCount / sizeX); - const itemX = levelCount - itemZ * sizeX; - positionX = spacingX / 2 + binIdX * (sizeX + spacingX) + itemX + 0.5; - positionY = this._height * (level + 0.5); - positionZ = spacingZ / 2 + binIdZ * (sizeZ + spacingZ) + itemZ + 0.5; - this._positionsX[index] = positionX; - this._positionsY[index] = positionY; - this._positionsZ[index] = positionZ; - this._binCounts[binId]++; - maxBinCount = Math.max(maxBinCount, this._binCounts[binId]); - maxBinLevel = Math.max(maxBinLevel, level); + let positionX = options.positionsX ? options.positionsX[id] * positionScalingX : 0; + let positionY = options.positionsY ? options.positionsY[id] * positionScalingY : 0; + let positionZ = options.positionsZ ? options.positionsZ[id] * positionScalingZ : 0; + this._positions[index * 3] = positionX; + this._positions[index * 3 + 1] = positionY; + this._positions[index * 3 + 2] = positionZ; + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, positionX); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, positionY); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, positionZ); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, positionX); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, positionY); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, positionZ); } - this._maxLevel = maxBinLevel + 1; - this._maxCount = maxBinCount; - this.minLayoutBoundsX = 0; - this.minLayoutBoundsY = 0; - this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = binsX * (sizeX + spacingX); - this.maxLayoutBoundsY = this._maxLevel * this._height; - this.maxLayoutBoundsZ = binsZ * (sizeZ + spacingZ); this._updateCumulativeLayoutBounds(); this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } @@ -25858,6 +22947,13 @@ class Stack extends StackBase { const _vec3 = (0, _glMatrix.vec3).create(); const _vec4 = (0, _glMatrix.vec4).create(); const _quat = (0, _glMatrix.quat).create(); + const sizeScalingX = options.sizeScaling === undefined ? options.sizeScalingX === undefined ? 1 : options.sizeScalingX : options.sizeScaling; + const sizeScalingY = options.sizeScaling === undefined ? options.sizeScalingY === undefined ? 1 : options.sizeScalingY : options.sizeScaling; + const sizeScalingZ = options.sizeScaling === undefined ? options.sizeScalingZ === undefined ? 1 : options.sizeScalingZ : options.sizeScaling; + const sizesX = options.sizes ? options.sizes : options.sizesX; + const sizesY = options.sizes ? options.sizes : options.sizesY; + const sizesZ = options.sizes ? options.sizes : options.sizesZ; + const minSize = options.minSize === undefined ? 0 : options.minSize; const minColor = options.minColor === undefined ? 0 : options.minColor; const maxColor = options.maxColor === undefined ? 1 : options.maxColor; const minOrder = options.minOrder === undefined ? 0 : options.minOrder; @@ -25866,28 +22962,30 @@ class Stack extends StackBase { const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const padding = options.padding === undefined ? 0 : options.padding; - const thickness = options.thickness === undefined ? 1 - padding : options.thickness; const reverseX = options.reverseX === undefined ? false : options.reverseX; const reverseY = options.reverseY === undefined ? false : options.reverseY; const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; this._updateModelBounds(options); - (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + if (options.rotation) { + _quat[0] = options.rotation[0]; + _quat[1] = options.rotation[1]; + _quat[2] = options.rotation[2]; + _quat[3] = options.rotation[3]; + } else (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); if (options.texCoord) { _vec4[0] = options.texCoord[0]; _vec4[1] = options.texCoord[1]; _vec4[2] = options.texCoord[2]; _vec4[3] = options.texCoord[3]; } - const scale = (0, _glMatrix.vec3).fromValues((1 - padding) * this._boundsScaling, (this._height - padding) * this._boundsScaling, thickness * this._boundsScaling); const lookup = buffer.lookup; const selection = options.selected && options.selected.size > 0; for(let i = 0; i < count; i++){ const id = ids[i + offset]; const index = lookup[id]; - let positionX = this._positionsX[index]; - let positionY = this._positionsY[index]; - let positionZ = this._positionsZ[index]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; if (this._isFacetted) { if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; @@ -25907,12 +23005,24 @@ class Stack extends StackBase { _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setScale(dataView, index, scale); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + _vec3[0] = Math.max((sizesX ? Math.abs(sizesX[id]) : 1) * sizeScalingX, minSize) * this._boundsScaling; + _vec3[1] = Math.max((sizesY ? Math.abs(sizesY[id]) : 1) * sizeScalingY, minSize) * this._boundsScaling; + _vec3[2] = Math.max((sizesZ ? Math.abs(sizesZ[id]) : 1) * sizeScalingZ, minSize) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + if (options.rotations) { + _quat[0] = options.rotations[id * 4]; + _quat[1] = options.rotations[id * 4 + 1]; + _quat[2] = options.rotations[id * 4 + 2]; + _quat[3] = options.rotations[id * 4 + 3]; + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + } else (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); if (options.colors) { const size = 1 / (maxColor - minColor + 1); const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); + if (options.colors1) { + const color1 = (0, _mathJs.MathHelper).normalize(options.colors1[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color1); + } else (0, _glMatrix.vec2).set(_vec2, color, color); (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); @@ -25929,6 +23039,10 @@ class Stack extends StackBase { (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setParameter1(dataView, index, options.parameter1 ? options.parameter1 : options.parameters1 ? options.parameters1[id] : 0); + (0, _vertexJs.UnitVertex).setParameter2(dataView, index, options.parameter2 ? options.parameter2 : options.parameters2 ? options.parameters2[id] : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); if (options.texCoords) { _vec4[0] = options.texCoords[id * 4]; _vec4[1] = options.texCoords[id * 4 + 1]; @@ -25941,4313 +23055,4994 @@ class Stack extends StackBase { this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } } -class StackTreeMap extends StackBase { - get maxTotal() { - return this._maxTotal; + +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kYBiT":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LayoutBase", ()=>LayoutBase); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _boundsJs = require("../helpers/bounds.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +class LayoutBase { + get facetScaling() { + return this._facetScaling; } - get binGroupIds() { - return this._binGroupIds; + offsetX(facetCoordX) { + return ((facetCoordX + 0.5) / this._facetsX - 0.5) * (this.maxModelBoundsX - this.minModelBoundsX) / this._maxBounds; } - layout(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const isNormalized = options.isNormalized === undefined ? false : options.isNormalized; - const minHeight = options.minHeight === undefined ? 0 : options.minHeight; - const maxHeight = options.maxHeight === undefined ? 0 : options.maxHeight; - const isTopToBottom = options.isTopToBottom === undefined ? false : options.isTopToBottom; - const sizeX = options.sizeX == undefined ? 1 : options.sizeX; - const sizeZ = options.sizeZ == undefined ? 1 : options.sizeZ; - const spacingX = options.spacingX == undefined ? 0 : options.spacingX; - const spacingZ = options.spacingZ == undefined ? 0 : options.spacingZ; - const binsX = options.binsX == undefined ? 1 : options.binsX; - const binsZ = options.binsZ == undefined ? 1 : options.binsZ; - if (!this._positionsX || this._positionsX.length < buffer.length) { - this._positionsX = new Float32Array(buffer.length); - this._positionsY = new Float32Array(buffer.length); - this._positionsZ = new Float32Array(buffer.length); - this._sizesX = new Float32Array(buffer.length); - this._sizesY = new Float32Array(buffer.length); - this._sizesZ = new Float32Array(buffer.length); - this._binIds = new Uint32Array(buffer.length); - this._binGroupIds = new Float64Array(buffer.length); - } - this._binCounts = new Uint32Array(binsX * binsZ); - this._binTotals = new Float64Array(binsX * binsZ); - let maxBinCount = 0; - let maxBinTotal = 0; - let height; - const lookup = buffer.lookup; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - const binIdX = options.binIdsX ? options.binIdsX[id] : 0; - const binIdZ = options.binIdsZ ? options.binIdsZ[id] : 0; - const binId = binIdX + binIdZ * binsX; - this._binIds[index] = binId; - if (binId > this._binCounts.length - 1) this._core.log.write((0, _mainJs.LogLevel).warn, "bin overflow"); - this._binCounts[binId]++; - maxBinCount = Math.max(maxBinCount, this._binCounts[binId]); - this._binTotals[binId] += options.sizes ? options.sizes[id] : 1; - maxBinTotal = Math.max(maxBinTotal, this._binTotals[binId]); - } - if (maxHeight - minHeight > 0) height = maxHeight - minHeight; - else height = Math.ceil(maxBinCount / options.sizeX / options.sizeZ); - if (!this._orderedIds || this._orderedIds.length < buffer.length) this._orderedIds = new Uint32Array(buffer.length); - let ids2; - if (options.groupIds || options.sizes) { - if (count == ids.length) this._ids = new Uint32Array(ids); - else { - this._ids = new Uint32Array(count); - for(let i1 = 0; i1 < count; i1++)this._ids[i1] = ids[offset + i1]; - } - if (options.groupIds && options.sizes) { - this._ids.sort(function(a, b) { - return options.groupIds[a] == options.groupIds[b] ? options.sizes[a] - options.sizes[b] : options.groupIds[a] - options.groupIds[b]; - }); - ids2 = this._ids; - } else if (options.groupIds) { - this._ids.sort(function(a, b) { - return options.groupIds[a] - options.groupIds[b]; - }); - ids2 = this._ids; - } else if (options.sizes) { - this._ids.sort(function(a, b) { - return options.sizes[a] - options.sizes[b]; - }); - ids2 = this._ids; - } - } else ids2 = ids; - const binOffsets = new Uint32Array(this._binCounts.length); - let binOffset = 0; - for(let i2 = 0; i2 < this._binCounts.length; i2++){ - const binCount = this._binCounts[i2]; - binOffsets[i2] = binOffset; - binOffset += binCount; - } - for(let i3 = 0; i3 < count; i3++){ - const id1 = ids2[i3]; - const index1 = lookup[id1]; - const binId1 = this._binIds[index1]; - binOffset = binOffsets[binId1]++; - this._orderedIds[binOffset + offset] = id1; - } - const minSliceHeight = this._core.config.minCubifiedTreeMapSlice * height; - const side = Math.sqrt(sizeX * sizeZ); - let from = offset; - let isLastInGroup = false; - let isLastInBin = false; - let groupCount = 0; - let groupTotal = 0; - let positionY = 0; - for(let i4 = 0; i4 < count; i4++){ - const id2 = this._orderedIds[i4 + offset]; - const index2 = lookup[id2]; - groupCount++; - groupTotal += options.sizes ? options.sizes[id2] : 1; - const binId2 = this._binIds[index2]; - const groupId = options.groupIds ? options.groupIds[id2] : 0; - if (i4 == count - 1) { - isLastInBin = true; - isLastInGroup = true; - } else { - const nextId = this._orderedIds[i4 + 1 + offset]; - const nextIndex = lookup[nextId]; - const nextBinId = this._binIds[nextIndex]; - const nextGroupId = options.groupIds ? options.groupIds[nextId] : 0; - isLastInBin = binId2 != nextBinId; - isLastInGroup = groupId != nextGroupId; - } - if (isLastInBin || isLastInGroup) { - const mid = i4 + offset; - const binIdX1 = options.binIdsX ? options.binIdsX[id2] : 0; - const binIdZ1 = options.binIdsZ ? options.binIdsZ[id2] : 0; - let groupValue, binValue; - if (options.sizes) { - groupValue = groupTotal; - binValue = isNormalized ? this._binTotals[binId2] : maxBinTotal; - } else { - groupValue = groupCount; - binValue = isNormalized ? this._binCounts[binId2] : maxBinCount; - } - const groupHeight = height * groupValue / binValue; - if (sizeZ == 1) { - const positionX = spacingX / 2 + binIdX1 * (sizeX + spacingX); - (0, _treemapJs.TreeMapHelper).squarifiedLayout(this._orderedIds, options.sizes, this._positionsX, this._positionsY, this._sizesX, this._sizesY, from, mid, positionX, positionY, sizeX, groupHeight, lookup); - const isRightToLeft = true; - for(let i5 = from; i5 <= mid; i5++){ - const id3 = this._orderedIds[i5]; - const index3 = lookup[id3]; - this._sizesZ[index3] = sizeZ; - this._positionsZ[index3] = (binIdZ1 + 0.5) * (sizeZ + spacingZ); - if (isRightToLeft) this._positionsX[index3] = positionX + sizeX - this._positionsX[index3] + positionX; - if (!isTopToBottom) this._positionsY[index3] = positionY + groupHeight - this._positionsY[index3] + positionY; - } - } else (0, _treemapJs.TreeMapHelper).cubifiedLayout(this._orderedIds, options.sizes, this._positionsX, this._positionsY, this._positionsZ, this._sizesX, this._sizesY, this._sizesZ, from, mid, spacingX / 2 + binIdX1 * (sizeX + spacingX), positionY, spacingZ / 2 + binIdZ1 * (sizeZ + spacingZ), sizeX, groupHeight, sizeZ, side, groupValue, minSliceHeight, isTopToBottom, lookup); - if (isLastInGroup) { - isLastInGroup = false; - positionY += groupHeight; - } - if (isLastInBin) { - isLastInBin = false; - positionY = 0; - } - groupCount = 0; - groupTotal = 0; - from = mid + 1; - } - } - this._maxCount = maxBinCount; - this._maxTotal = maxBinTotal; + offsetY(facetCoordY) { + return ((facetCoordY + 0.5) / this._facetsY - 0.5) * (this.maxModelBoundsY - this.minModelBoundsY) / this._maxBounds; + } + offsetZ(facetCoordZ) { + return ((facetCoordZ + 0.5) / this._facetsZ - 0.5) * (this.maxModelBoundsZ - this.minModelBoundsZ) / this._maxBounds; + } + constructor(core){ + this._core = core; + this.modelOriginX = 0; + this.modelOriginY = 0; + this.modelOriginZ = 0; + this.minModelBoundsX = 0; + this.minModelBoundsY = 0; + this.minModelBoundsZ = 0; + this.maxModelBoundsX = 0; + this.maxModelBoundsY = 0; + this.maxModelBoundsZ = 0; this.minLayoutBoundsX = 0; this.minLayoutBoundsY = 0; this.minLayoutBoundsZ = 0; - this.maxLayoutBoundsX = binsX * (sizeX + spacingX); - this.maxLayoutBoundsY = height; - this.maxLayoutBoundsZ = binsZ * (sizeZ + spacingZ); - this._updateCumulativeLayoutBounds(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); + this.maxLayoutBoundsX = 0; + this.maxLayoutBoundsY = 0; + this.maxLayoutBoundsZ = 0; + this._facetSpacingX = 0; + this._facetSpacingY = 0; + this._facetSpacingZ = 0; + this._facetSizeX = 0; + this._facetSizeY = 0; + this._facetSizeZ = 0; + this._facetsX = 1; + this._facetsY = 1; + this._facetsZ = 1; } - update(buffer, ids, options) { - const start = window.performance.now(); - const offset = options.offset === undefined ? 0 : options.offset; - const count = options.count === undefined ? ids.length : options.count; - const dataView = buffer.dataView; - const _vec2 = (0, _glMatrix.vec2).create(); - const _vec3 = (0, _glMatrix.vec3).create(); - const _quat = (0, _glMatrix.quat).create(); - const minColor = options.minColor === undefined ? 0 : options.minColor; - const maxColor = options.maxColor === undefined ? 1 : options.maxColor; - const minOrder = options.minOrder === undefined ? 0 : options.minOrder; - const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; - const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; - const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; - const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; - const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; - const padding = options.padding === undefined ? 0 : options.padding; - const paddingZ = options.thickness === undefined ? padding : 0; - const thickness = options.thickness === undefined ? 1 : options.thickness; - const reverseX = options.reverseX === undefined ? false : options.reverseX; - const reverseY = options.reverseY === undefined ? false : options.reverseY; - const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; - this._updateModelBounds(options); - (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + _updateModelBounds(options) { + this.minModelBoundsX = options.minBoundsX === undefined ? this.minLayoutBoundsX : options.minBoundsX; + this.minModelBoundsY = options.minBoundsY === undefined ? this.minLayoutBoundsY : options.minBoundsY; + this.minModelBoundsZ = options.minBoundsZ === undefined ? this.minLayoutBoundsZ : options.minBoundsZ; + this.maxModelBoundsX = options.maxBoundsX === undefined ? this.maxLayoutBoundsX : options.maxBoundsX; + this.maxModelBoundsY = options.maxBoundsY === undefined ? this.maxLayoutBoundsY : options.maxBoundsY; + this.maxModelBoundsZ = options.maxBoundsZ === undefined ? this.maxLayoutBoundsZ : options.maxBoundsZ; + this._isFacetted = options.facetsX !== undefined && options.facetsX > 1 && options.facetCoordsX != null || options.facetsY !== undefined && options.facetsY > 1 && options.facetCoordsY != null || options.facetsZ !== undefined && options.facetsZ > 1 && options.facetCoordsZ != null; + this._facetSpacingX = options.facetSpacingX === undefined ? 0 : options.facetSpacingX; + this._facetSpacingY = options.facetSpacingY === undefined ? 0 : options.facetSpacingY; + this._facetSpacingZ = options.facetSpacingZ === undefined ? 0 : options.facetSpacingZ; + let modelSizeX = this.maxModelBoundsX - this.minModelBoundsX; + let modelSizeY = this.maxModelBoundsY - this.minModelBoundsY; + let modelSizeZ = this.maxModelBoundsZ - this.minModelBoundsZ; + const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + this._facetSizeX = modelSizeX; + this._facetSizeY = modelSizeY; + this._facetSizeZ = modelSizeZ; + this._facetsX = options.facetCoordsX ? options.facetsX : 1; + this._facetsY = options.facetCoordsY ? options.facetsY : 1; + this._facetsZ = options.facetCoordsZ ? options.facetsZ : 1; + this.minModelBoundsX -= this._facetSizeX * this._facetSpacingX / 2; + this.minModelBoundsY -= this._facetSizeY * this._facetSpacingY / 2; + this.minModelBoundsZ -= this._facetSizeZ * this._facetSpacingZ / 2; + this.maxModelBoundsX = this.minModelBoundsX + this._facetsX * this._facetSizeX * (1 + this._facetSpacingX); + this.maxModelBoundsY = this.minModelBoundsY + this._facetsY * this._facetSizeY * (1 + this._facetSpacingY); + this.maxModelBoundsZ = this.minModelBoundsZ + this._facetsZ * this._facetSizeZ * (1 + this._facetSpacingZ); + this.modelOriginX = (this.minModelBoundsX + this.maxModelBoundsX) / 2; + this.modelOriginY = (this.minModelBoundsY + this.maxModelBoundsY) / 2; + this.modelOriginZ = (this.minModelBoundsZ + this.maxModelBoundsZ) / 2; + modelSizeX = this.maxModelBoundsX - this.minModelBoundsX; + modelSizeY = this.maxModelBoundsY - this.minModelBoundsY; + modelSizeZ = this.maxModelBoundsZ - this.minModelBoundsZ; + this._maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + this._boundsScaling = this._maxBounds == 0 ? 1 : 1 / this._maxBounds; + this._facetScaling = maxBounds / this._maxBounds; + } + resetCumulativeLayoutBounds() { + this.minCumulativeLayoutBoundsX = undefined; + this.minCumulativeLayoutBoundsY = undefined; + this.minCumulativeLayoutBoundsZ = undefined; + this.maxCumulativeLayoutBoundsX = undefined; + this.maxCumulativeLayoutBoundsY = undefined; + this.maxCumulativeLayoutBoundsZ = undefined; + } + _updateCumulativeLayoutBounds() { + this.minCumulativeLayoutBoundsX = this.minCumulativeLayoutBoundsX === undefined ? this.minLayoutBoundsX : Math.min(this.minCumulativeLayoutBoundsX, this.minLayoutBoundsX); + this.minCumulativeLayoutBoundsY = this.minCumulativeLayoutBoundsY === undefined ? this.minLayoutBoundsY : Math.min(this.minCumulativeLayoutBoundsY, this.minLayoutBoundsY); + this.minCumulativeLayoutBoundsZ = this.minCumulativeLayoutBoundsZ === undefined ? this.minLayoutBoundsZ : Math.min(this.minCumulativeLayoutBoundsZ, this.minLayoutBoundsZ); + this.maxCumulativeLayoutBoundsX = this.maxCumulativeLayoutBoundsX === undefined ? this.maxLayoutBoundsX : Math.max(this.maxCumulativeLayoutBoundsX, this.maxLayoutBoundsX); + this.maxCumulativeLayoutBoundsY = this.maxCumulativeLayoutBoundsY === undefined ? this.maxLayoutBoundsY : Math.max(this.maxCumulativeLayoutBoundsY, this.maxLayoutBoundsY); + this.maxCumulativeLayoutBoundsZ = this.maxCumulativeLayoutBoundsZ === undefined ? this.maxLayoutBoundsZ : Math.max(this.maxCumulativeLayoutBoundsZ, this.maxLayoutBoundsZ); + } + unitToModelSize(unitSize) { + return unitSize / this._boundsScaling; + } + unitToModelPositionX(unitPositionX) { + return this.unitToModelSize(unitPositionX) + this.modelOriginX; + } + unitToModelPositionY(unitPositionY) { + return this.unitToModelSize(unitPositionY) + this.modelOriginY; + } + unitToModelPositionZ(unitPositionZ) { + return this.unitToModelSize(unitPositionZ) + this.modelOriginZ; + } + unitToModelPosition(unitPosition, modelPosition) { + modelPosition[0] = this.unitToModelPositionX(unitPosition[0]); + modelPosition[1] = this.unitToModelPositionY(unitPosition[1]); + modelPosition[2] = this.unitToModelPositionZ(unitPosition[2]); + } + modelToUnitSize(modelSize) { + return modelSize * this._boundsScaling; + } + modelToUnitPositionX(modelPositionX) { + return (modelPositionX - this.modelOriginX) * this._boundsScaling; + } + modelToUnitPositionY(modelPositionY) { + return (modelPositionY - this.modelOriginY) * this._boundsScaling; + } + modelToUnitPositionZ(modelPositionZ) { + return (modelPositionZ - this.modelOriginZ) * this._boundsScaling; + } + modelToUnitPosition(modelPosition, unitPosition) { + unitPosition[0] = this.modelToUnitPositionX(modelPosition[0]); + unitPosition[1] = this.modelToUnitPositionY(modelPosition[1]); + unitPosition[2] = this.modelToUnitPositionZ(modelPosition[2]); + } + inclusiveUnitBounds(buffer, ids, unitType, offset, count, minBounds, maxBounds) { + (0, _glMatrix.vec3).set(minBounds, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + (0, _glMatrix.vec3).set(maxBounds, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); + const unitScale = (0, _glMatrix.vec3).create(); + const unitRotation = (0, _glMatrix.quat).create(); + const unitTranslation = (0, _glMatrix.vec3).create(); const lookup = buffer.lookup; - const selection = options.selected && options.selected.size > 0; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = lookup[id]; - let positionX = this._positionsX[index]; - let positionY = this._positionsY[index]; - let positionZ = this._positionsZ[index]; - if (this._isFacetted) { - if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; - const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; - const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; - const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; - positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); - positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); - positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); - } else { - if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; - if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; - if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; - } - _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; - _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; - _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; - (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); - _vec3[0] = Math.max((this._sizesX[index] - padding) * this._boundsScaling, 0); - _vec3[1] = Math.max((this._sizesY[index] - padding) * this._boundsScaling, 0); - _vec3[2] = Math.max((this._sizesZ[index] - paddingZ) * this._boundsScaling, 0) * thickness; - (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); - (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); - if (options.colors) { - const size = 1 / (maxColor - minColor + 1); - const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); - (0, _glMatrix.vec2).set(_vec2, color, color); - (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); - } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); - (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); - if (options.order !== undefined) { - const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); - _vec2[0] = orderReverse ? 1 - order : order; - } else _vec2[0] = count == 1 ? 0 : i / (count - 1); - if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; - else if (options.staggerOrders) { - const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); - _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; - } else _vec2[1] = count == 1 ? 0 : i / (count - 1); - (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); - (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); - (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + const dataView = buffer.dataView; + let minBounds0; + let maxBounds0; + let minBounds1; + let maxBounds1; + switch(unitType){ + case (0, _mainJs.UnitType).sphere: + case (0, _mainJs.UnitType).sphereSdf: + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + (0, _vertexJs.UnitVertex).getTranslation(dataView, index, unitTranslation); + (0, _vertexJs.UnitVertex).getScale(dataView, index, unitScale); + const radius = unitScale[0] / 2; + minBounds[0] = Math.min(minBounds[0], unitTranslation[0] - radius); + minBounds[1] = Math.min(minBounds[1], unitTranslation[1] - radius); + minBounds[2] = Math.min(minBounds[2], unitTranslation[2] - radius); + maxBounds[0] = Math.max(maxBounds[0], unitTranslation[0] + radius); + maxBounds[1] = Math.max(maxBounds[1], unitTranslation[1] + radius); + maxBounds[2] = Math.max(maxBounds[2], unitTranslation[2] + radius); + } + break; + case (0, _mainJs.UnitType).hexPrism: + case (0, _mainJs.UnitType).hexPrismSdf: + case (0, _mainJs.UnitType).block: + case (0, _mainJs.UnitType).blockSdf: + minBounds0 = (0, _glMatrix.vec3).create(); + maxBounds0 = (0, _glMatrix.vec3).create(); + minBounds1 = (0, _glMatrix.vec3).create(); + maxBounds1 = (0, _glMatrix.vec3).create(); + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + (0, _vertexJs.UnitVertex).getTranslation(dataView, index, unitTranslation); + (0, _vertexJs.UnitVertex).getRotation(dataView, index, unitRotation); + (0, _vertexJs.UnitVertex).getScale(dataView, index, unitScale); + minBounds0[0] = unitTranslation[0] - unitScale[0] / 2; + minBounds0[1] = unitTranslation[1] - unitScale[1] / 2; + minBounds0[2] = unitTranslation[2] - unitScale[2] / 2; + maxBounds0[0] = unitTranslation[0] + unitScale[0] / 2; + maxBounds0[1] = unitTranslation[1] + unitScale[1] / 2; + maxBounds0[2] = unitTranslation[2] + unitScale[2] / 2; + (0, _boundsJs.BoundsHelper).rotateBounds(minBounds0, maxBounds0, unitRotation, minBounds1, maxBounds1, (0, _constantsJs.Constants).VECTOR3_ZERO); + (0, _glMatrix.vec3).min(minBounds, minBounds, minBounds1); + (0, _glMatrix.vec3).max(maxBounds, maxBounds, maxBounds1); + } + break; + case (0, _mainJs.UnitType).cylinder: + case (0, _mainJs.UnitType).cylinderSdf: + minBounds0 = (0, _glMatrix.vec3).create(); + maxBounds0 = (0, _glMatrix.vec3).create(); + const pa = (0, _glMatrix.vec3).create(); + const pb = (0, _glMatrix.vec3).create(); + const identityRotation = (0, _constantsJs.Constants).VECTOR3_UNITY; + let ca; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + (0, _vertexJs.UnitVertex).getTranslation(dataView, index, unitTranslation); + (0, _vertexJs.UnitVertex).getRotation(dataView, index, unitRotation); + (0, _vertexJs.UnitVertex).getScale(dataView, index, unitScale); + const length = unitScale[1]; + const radius = Math.max(unitScale[0], unitScale[2]); + if (length != 0 && radius != 0) { + if ((0, _glMatrix.quat).equals(unitRotation, (0, _constantsJs.Constants).QUAT_IDENTITY)) ca = identityRotation; + else { + ca = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).transformQuat(ca, identityRotation, unitRotation); + } + (0, _glMatrix.vec3).scaleAndAdd(pa, unitTranslation, ca, -length * 0.5); + (0, _glMatrix.vec3).scaleAndAdd(pb, unitTranslation, ca, length * 0.5); + (0, _boundsJs.BoundsHelper).cylinder(pa, pb, radius, minBounds0, maxBounds0); + (0, _glMatrix.vec3).min(minBounds, minBounds, minBounds0); + (0, _glMatrix.vec3).max(maxBounds, maxBounds, maxBounds0); + } + } + break; } - buffer.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${ids.length} ${Math.round(window.performance.now() - start)}ms`); } } -},{"../constants.js":"2Scl5","../helpers/math.js":"fOnPF","../vertex.js":"ddAub","./treemap.js":"dMHbq","./layout.js":"liYq1","gl-matrix":"9GjEQ","../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2TO94":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/bounds.js":"beD2A","../main.js":"f421K","../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"beD2A":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Keyboard", ()=>(0, _keyboardJs.Keyboard)); -parcelHelpers.export(exports, "MouseWheel", ()=>(0, _mousewheelJs.MouseWheel)); -parcelHelpers.export(exports, "Pointers", ()=>(0, _pointersJs.Pointers)); -parcelHelpers.export(exports, "Manipulator", ()=>(0, _manipulatorJs.Manipulator)); -parcelHelpers.export(exports, "ManipulationProcessor", ()=>(0, _manipulationprocessorJs.ManipulationProcessor)); -parcelHelpers.export(exports, "Manager", ()=>(0, _managerJs.Manager)); -var _keyboardJs = require("./keyboard.js"); -var _mousewheelJs = require("./mousewheel.js"); -var _pointersJs = require("./pointers.js"); -var _manipulatorJs = require("./manipulator.js"); -var _manipulationprocessorJs = require("./manipulationprocessor.js"); -var _managerJs = require("./manager.js"); - -},{"./keyboard.js":"7b1bp","./mousewheel.js":"9by4z","./pointers.js":"1WwTm","./manipulator.js":"3mWz8","./manipulationprocessor.js":"aEJdc","./manager.js":"75sHN","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hlPw6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "BoundsHelper", ()=>BoundsHelper); +var _glMatrix = require("gl-matrix"); +var _cubeJs = require("../meshes/cube.js"); +class BoundsHelper { + static rotateBounds(minBounds, maxBounds, rotation, rotatedMinBounds, rotatedMaxBounds, offset) { + const sizeX = maxBounds[0] - minBounds[0]; + const sizeY = maxBounds[1] - minBounds[1]; + const sizeZ = maxBounds[2] - minBounds[2]; + const min = rotatedMinBounds; + const max = rotatedMaxBounds; + (0, _glMatrix.vec3).set(min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + (0, _glMatrix.vec3).set(max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); + const vertices = (0, _cubeJs.Cube).POSITIONS; + const position = (0, _glMatrix.vec3).create(); + for(let i = 0; i < 8; i++){ + (0, _glMatrix.vec3).set(position, vertices[i * 3] * sizeX, vertices[i * 3 + 1] * sizeY, vertices[i * 3 + 2] * sizeZ); + (0, _glMatrix.vec3).add(position, position, offset); + (0, _glMatrix.vec3).transformQuat(position, position, rotation); + (0, _glMatrix.vec3).subtract(position, position, offset); + (0, _glMatrix.vec3).min(min, min, position); + (0, _glMatrix.vec3).max(max, max, position); + } + (0, _glMatrix.vec3).add(position, minBounds, maxBounds); + (0, _glMatrix.vec3).scale(position, position, 0.5); + (0, _glMatrix.vec3).add(min, min, position); + (0, _glMatrix.vec3).add(max, max, position); + } + static cylinder(pa, pb, radius, minBounds, maxBounds) { + const a = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).subtract(a, pb, pa); + const aa = (0, _glMatrix.vec3).dot(a, a); + const ex = radius * Math.sqrt(1 - a[0] * a[0] / aa); + const ey = radius * Math.sqrt(1 - a[1] * a[1] / aa); + const ez = radius * Math.sqrt(1 - a[2] * a[2] / aa); + minBounds[0] = Math.min(pa[0] - ex, pb[0] - ex); + minBounds[1] = Math.min(pa[1] - ey, pb[1] - ey); + minBounds[2] = Math.min(pa[2] - ez, pb[2] - ez); + maxBounds[0] = Math.max(pa[0] + ex, pb[0] + ex); + maxBounds[1] = Math.max(pa[1] + ey, pb[1] + ey); + maxBounds[2] = Math.max(pa[2] + ez, pb[2] + ez); + } +} + +},{"gl-matrix":"5x28d","../meshes/cube.js":"79I5N","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eiGCN":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "LocalFile", ()=>(0, _fileJs.LocalFile)); -parcelHelpers.export(exports, "XmlHttp", ()=>(0, _xmlHttpJs.XmlHttp)); -var _fileJs = require("./file.js"); -var _xmlHttpJs = require("./xmlHttp.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AxesBase", ()=>(0, _axesJs.AxesBase)); +parcelHelpers.export(exports, "Cartesian2dAxes", ()=>(0, _cartesian2DJs.Cartesian2dAxes)); +parcelHelpers.export(exports, "Cartesian2dAxesHelper", ()=>(0, _cartesian2DJs.Cartesian2dAxesHelper)); +parcelHelpers.export(exports, "Cartesian3dAxes", ()=>(0, _cartesian3DJs.Cartesian3dAxes)); +parcelHelpers.export(exports, "Cartesian3dAxesHelper", ()=>(0, _cartesian3DJs.Cartesian3dAxesHelper)); +var _axesJs = require("./axes.js"); +var _cartesian2DJs = require("./cartesian2d.js"); +var _cartesian3DJs = require("./cartesian3d.js"); -},{"./file.js":"5InrC","./xmlHttp.js":"gi4jD","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5InrC":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./axes.js":"8Tmim","./cartesian2d.js":"d0jS2","./cartesian3d.js":"jfjef","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9v1at":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AngleHelper", ()=>(0, _angleJs.AngleHelper)); +parcelHelpers.export(exports, "AnimationHelper", ()=>(0, _animationJs.AnimationHelper)); +parcelHelpers.export(exports, "ArrayHelper", ()=>(0, _arrayJs.ArrayHelper)); +parcelHelpers.export(exports, "AxisHelper", ()=>(0, _axesJs.AxisHelper)); +parcelHelpers.export(exports, "Base64Helper", ()=>(0, _base64Js.Base64Helper)); +parcelHelpers.export(exports, "BinHelper", ()=>(0, _binJs.BinHelper)); +parcelHelpers.export(exports, "ColorHelper", ()=>(0, _colorJs.ColorHelper)); +parcelHelpers.export(exports, "CsvHelper", ()=>(0, _csvJs.CsvHelper)); +parcelHelpers.export(exports, "FacetHelper", ()=>(0, _facetJs.FacetHelper)); +parcelHelpers.export(exports, "ForceDirectHelper", ()=>(0, _forcedirectJs.ForceDirectHelper)); +parcelHelpers.export(exports, "HexHelper", ()=>(0, _hexJs.HexHelper)); +parcelHelpers.export(exports, "HexBinHelper", ()=>(0, _hexbinJs.HexBinHelper)); +parcelHelpers.export(exports, "LineHelper", ()=>(0, _lineJs.LineHelper)); +parcelHelpers.export(exports, "MathHelper", ()=>(0, _mathJs.MathHelper)); +parcelHelpers.export(exports, "PseudoRandom", ()=>(0, _mathJs.PseudoRandom)); +parcelHelpers.export(exports, "MatrixHelper", ()=>(0, _matrixJs.MatrixHelper)); +parcelHelpers.export(exports, "MercatorHelper", ()=>(0, _mapJs.MercatorHelper)); +parcelHelpers.export(exports, "AlbersHelper", ()=>(0, _mapJs.AlbersHelper)); +parcelHelpers.export(exports, "GeoJSONHelper", ()=>(0, _mapJs.GeoJSONHelper)); +parcelHelpers.export(exports, "OctTreeHelper", ()=>(0, _octtreeJs.OctTreeHelper)); +parcelHelpers.export(exports, "PaletteHelper", ()=>(0, _paletteJs.PaletteHelper)); +parcelHelpers.export(exports, "PathHelper", ()=>(0, _pathJs.PathHelper)); +parcelHelpers.export(exports, "PickHelper", ()=>(0, _pickJs.PickHelper)); +parcelHelpers.export(exports, "TableHelper", ()=>(0, _tableJs.TableHelper)); +parcelHelpers.export(exports, "TextHelper", ()=>(0, _textJs.TextHelper)); +parcelHelpers.export(exports, "TextureHelper", ()=>(0, _textureJs.TextureHelper)); +parcelHelpers.export(exports, "TreeHelper", ()=>(0, _treeJs.TreeHelper)); +parcelHelpers.export(exports, "SetHelper", ()=>(0, _setJs.SetHelper)); +parcelHelpers.export(exports, "SdfHelper", ()=>(0, _sdfJs.SdfHelper)); +parcelHelpers.export(exports, "VectorHelper", ()=>(0, _vectorJs.VectorHelper)); +var _angleJs = require("./angle.js"); +var _animationJs = require("./animation.js"); +var _arrayJs = require("./array.js"); +var _axesJs = require("./axes.js"); +var _base64Js = require("./base64.js"); +var _binJs = require("./bin.js"); +var _colorJs = require("./color.js"); +var _csvJs = require("./csv.js"); +var _facetJs = require("./facet.js"); +var _forcedirectJs = require("./forcedirect.js"); +var _hexJs = require("./hex.js"); +var _hexbinJs = require("./hexbin.js"); +var _lineJs = require("./line.js"); +var _mathJs = require("./math.js"); +var _matrixJs = require("./matrix.js"); +var _mapJs = require("./map.js"); +var _octtreeJs = require("./octtree.js"); +var _paletteJs = require("./palette.js"); +var _pathJs = require("./path.js"); +var _pickJs = require("./pick.js"); +var _tableJs = require("./table.js"); +var _textJs = require("./text.js"); +var _textureJs = require("./texture.js"); +var _treeJs = require("./tree.js"); +var _setJs = require("./set.js"); +var _sdfJs = require("./sdf.js"); +var _vectorJs = require("./vector.js"); + +},{"./angle.js":"53hwW","./animation.js":"02nn8","./array.js":"9Rnft","./axes.js":"99ajO","./base64.js":"e5eoY","./bin.js":"5rVTq","./color.js":"4LgMf","./csv.js":"g6LJR","./facet.js":"iYn0I","./forcedirect.js":"gazw2","./hex.js":"ahk7A","./hexbin.js":"bm0M4","./line.js":"iEeyT","./math.js":"f65d0","./matrix.js":"7gWc5","./map.js":"27ECm","./octtree.js":"lv4D9","./palette.js":"7fuDW","./path.js":"dvdia","./pick.js":"1t2sb","./table.js":"cn0Qv","./text.js":"fG2oi","./texture.js":"bUoBU","./tree.js":"4ts5g","./set.js":"7s3Z5","./sdf.js":"2PdqK","./vector.js":"2r8XP","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9Rnft":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "LocalFile", ()=>LocalFile); -class LocalFile { - constructor(core){} - loadText(file, completed, failed) { - const reader = new FileReader(); - reader.onload = (event)=>{ - const text = event.target.result; - completed(text); - }; - reader.onerror = (event)=>{ - const error = event.target.error; - failed(error.message); - }; - reader.readAsText(file); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ArrayHelper", ()=>ArrayHelper); +class ArrayHelper { + static minIndex(orderedValues, offset, length, value) { + let index = ArrayHelper.binarySearch(orderedValues, offset, length, value); + if (index < 0) { + index = ~index; + index = Math.max(0, index); + } else while(index > 0 && orderedValues[index - 1] == value)index--; + return index; } - loadImage(file, completed, failed) { - const image = new Image(); - image.onload = ()=>completed(image); - image.onerror = (event)=>{ - const error = event.message; - failed(error); - }; - const reader = new FileReader(); - reader.onload = (event)=>{ - const text = event.target.result; - image.src = text; - }; - reader.onerror = (event)=>{ - const error = event.target.error; - failed(error.message); - }; - reader.readAsDataURL(file); + static maxIndex(orderedValues, offset, length, value) { + let index = ArrayHelper.binarySearch(orderedValues, offset, length, value); + if (index < 0) index = ~index - 1; + else { + while(index < length - 1 && orderedValues[index + 1] == value)index++; + index = Math.min(length, index); + } + return index; } - loadArrayBuffer(file, completed, failed) { - const reader = new FileReader(); - reader.onload = (event)=>{ - const arrayBuffer = event.target.result; - completed(arrayBuffer); - }; - reader.onerror = (event)=>{ - const error = event.target.error; - failed(error.message); - }; - reader.readAsArrayBuffer(file); + static binarySearch(array, index, length, value) { + let low = index; + let high = index + length - 1; + while(low <= high){ + const mid = low + (high - low >> 1); + if (array[mid] == value) return mid; + if (array[mid] <= value) low = mid + 1; + else high = mid - 1; + } + return ~low; } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gi4jD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e5eoY":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "XmlHttp", ()=>XmlHttp); -class XmlHttp { - constructor(core){} - loadText(url, completed, failed) { - const request = new XMLHttpRequest(); - request.open("GET", url); - request.onreadystatechange = ()=>{ - if (request.readyState == XMLHttpRequest.DONE) switch(request.status){ - case 200: - completed(request.responseText); - break; - default: - failed(request.statusText); - break; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Base64Helper", ()=>Base64Helper); +class Base64Helper { + uint6ToB64(nUint6) { + return nUint6 < 26 ? nUint6 + 65 : nUint6 < 52 ? nUint6 + 71 : nUint6 < 62 ? nUint6 - 4 : nUint6 === 62 ? 43 : nUint6 === 63 ? 47 : 65; + } + base64EncArr(aBytes) { + let nMod3 = 2; + let sB64Enc = ""; + let nLen = aBytes.byteLength; + let nUint24 = 0; + for(let nIdx = 0; nIdx < nLen; nIdx++){ + nMod3 = nIdx % 3; + if (nIdx > 0 && nIdx * 4 / 3 % 76 === 0) sB64Enc += "\r\n"; + nUint24 |= aBytes.getUint8(nIdx) << (16 >>> nMod3 & 24); + if (nMod3 === 2 || aBytes.byteLength - nIdx === 1) { + sB64Enc += String.fromCharCode(this.uint6ToB64(nUint24 >>> 18 & 63), this.uint6ToB64(nUint24 >>> 12 & 63), this.uint6ToB64(nUint24 >>> 6 & 63), this.uint6ToB64(nUint24 & 63)); + nUint24 = 0; } - }; - request.send(); + } + return sB64Enc.substring(0, sB64Enc.length - 2 + nMod3) + (nMod3 === 2 ? "" : nMod3 === 1 ? "=" : "=="); } - loadImage(url, completed, failed) { - const image = new Image(); - image.onload = ()=>completed(image); - image.onerror = (event)=>{ - const error = event.message; - failed(error); - }; - image.src = url; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5rVTq":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "BinHelper", ()=>BinHelper); +class BinHelper { + static quantile(options) { + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? options.ids.length : options.count; + const itemsPerBin = count / options.bins; + let bin = 0; + if (options.froms && options.tos) { + const firstId = options.ids[offset]; + options.froms[0] = options.values[firstId]; + } + for(let i = 0; i < count; i++){ + const id = options.ids[i + offset]; + if (i > Math.floor(itemsPerBin * (bin + 1))) { + bin++; + if (options.froms && options.tos) { + options.tos[bin - 1] = options.values[id]; + const nextId = options.ids[i + offset + 1]; + options.froms[bin] = options.values[nextId]; + } + } + options.binIds[id] = bin; + } + if (options.froms && options.tos) { + const lastId = options.ids[count - 1 + offset]; + options.tos[options.bins - 1] = options.values[lastId]; + } + return Math.floor(itemsPerBin); } - loadArrayBuffer(url, completed, failed) { - const request = new XMLHttpRequest(); - request.open("GET", url); - request.responseType = "arraybuffer"; - request.onreadystatechange = ()=>{ - if (request.readyState == XMLHttpRequest.DONE) switch(request.status){ - case 200: - completed(request.response); - break; - default: - failed(request.statusText); - break; + static bin(options) { + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? options.ids.length : options.count; + const counts = options.counts ? options.counts : new Float64Array(options.bins); + let minValue = options.minValue; + let maxValue = options.maxValue; + if (options.isDiscrete || maxValue == minValue) { + minValue -= 0.5; + maxValue += 0.5; + } + const binSize = (maxValue - minValue) / options.bins; + let maxCount = 0; + for(let i = 0; i < count; i++){ + const id = options.ids[i + offset]; + const value = options.values[id]; + const binId = Math.max(Math.min(Math.floor((value - minValue) / binSize), options.bins - 1), 0); + options.binIds[id] = binId; + counts[binId]++; + maxCount = Math.max(counts[binId], maxCount); + } + if (options.froms && options.tos) { + for(let i = 0; i < options.bins; i++)if (options.isDiscrete || maxValue == minValue) { + options.froms[i] = Math.ceil(minValue + binSize * i); + options.tos[i] = Math.floor(minValue + binSize * (i + 1)); + } else { + options.froms[i] = minValue + binSize * i; + options.tos[i] = minValue + binSize * (i + 1); } - }; - request.send(); + } + return maxCount; + } + static maxBins(minValue, maxValue, isDiscrete, maxBins) { + if (isDiscrete) return Math.min(maxValue - minValue + 1, maxBins); + else return maxBins; } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dI7q8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4LgMf":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Quad", ()=>(0, _quadJs.Quad)); -parcelHelpers.export(exports, "Cube", ()=>(0, _cubeJs.Cube)); -parcelHelpers.export(exports, "Sphere", ()=>(0, _sphereJs.Sphere)); -var _quadJs = require("./quad.js"); -var _cubeJs = require("./cube.js"); -var _sphereJs = require("./sphere.js"); - -},{"./quad.js":"jyd4s","./cube.js":"7rTMs","./sphere.js":"j7wP0","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bvOAu":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ColorHelper", ()=>ColorHelper); +var _glMatrix = require("gl-matrix"); +class ColorHelper { + static luminance(rgb) { + return rgb[0] * ColorHelper.LUMINANCE[0] + rgb[1] * ColorHelper.LUMINANCE[1] + rgb[2] * ColorHelper.LUMINANCE[2]; + } + static rgbToHex(r, g, b) { + const r2 = `0${Math.round(r * 255).toString(16)}`; + const g2 = `0${Math.round(g * 255).toString(16)}`; + const b2 = `0${Math.round(b * 255).toString(16)}`; + return `#${r2.substr(r2.length - 2, 2)}${g2.substr(g2.length - 2, 2)}${b2.substr(b2.length - 2, 2)}`; + } + static rgbToHsv(r, g, b, hsv) { + let h, s, v, delta; + const min = Math.min(Math.min(r, g), b); + const max = Math.max(Math.max(r, g), b); + delta = max - min; + v = max; + if (delta == 0) { + h = -1; + if (max == 0) s = -1; + else s = 0; + hsv[0] = h; + hsv[1] = s; + hsv[2] = v; + } + s = delta / max; + if (r == max) h = (g - b) / delta; + else if (g == max) h = 2 + (b - r) / delta; + else h = 4 + (r - g) / delta; + h *= 60; + if (h < 0) h += 360; + hsv[0] = h; + hsv[1] = s; + hsv[2] = v; + } + static hsvToRgb(h, s, v, rgb) { + let sextant, r, g, b; + if (s == 0) { + r = g = b = v; + rgb[0] = r; + rgb[1] = g; + rgb[2] = b; + } + let frac, p, q, t; + h %= 360; + h /= 60; + sextant = Math.floor(h); + frac = h - sextant; + p = v * (1 - s); + q = v * (1 - s * frac); + t = v * (1 - s * (1 - frac)); + switch(sextant){ + case 0: + r = v; + g = t; + b = p; + break; + case 1: + r = q; + g = v; + b = p; + break; + case 2: + r = p; + g = v; + b = t; + break; + case 3: + r = p; + g = q; + b = v; + break; + case 4: + r = t; + g = p; + b = v; + break; + default: + r = v; + g = p; + b = q; + break; + } + rgb[0] = r; + rgb[1] = g; + rgb[2] = b; + } +} +ColorHelper.LUMINANCE = (0, _glMatrix.vec3).fromValues(0.2126, 0.7152, 0.0722); + +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g6LJR":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "RendererBase", ()=>(0, _rendererJs.RendererBase)); -parcelHelpers.export(exports, "Basic", ()=>_indexJs); -parcelHelpers.export(exports, "Advanced", ()=>_indexJs1); -parcelHelpers.export(exports, "RayTraceWebGPU", ()=>_indexJs2); -var _indexJs = require("./basic/index.js"); -var _indexJs1 = require("./advanced/index.js"); -var _indexJs2 = require("./raytracewebgpu/index.js"); -var _rendererJs = require("./renderer.js"); - -},{"./basic/index.js":"4hxGv","./advanced/index.js":"fgt6s","./raytracewebgpu/index.js":"jCrZa","./renderer.js":"gKWdZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4hxGv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "CsvHelper", ()=>CsvHelper); +var _mainJs = require("../main.js"); +class CsvHelper { + constructor(core){ + this.QUOTE = '"'; + this.DELIMETER = ','; + this.LINE_BREAKS = [ + '\n', + '\r' + ]; + this._core = core; + } + readline(text, row) { + return this.read(text, row, 1)[0]; + } + read(text, firstRow = 0, maxRows = Number.MAX_VALUE) { + const start = window.performance.now(); + const rows = []; + let rowBuffer = []; + let row = 0; + let columnBuffer = ""; + let quoted = false; + for(let i = 0; i < text.length; i++){ + const char = text.charAt(i); + if (char == this.QUOTE) { + if (text.charAt(i + 1) == this.QUOTE) { + i++; + columnBuffer += this.QUOTE; + } else quoted = !quoted; + } else if (quoted) columnBuffer += char; + else { + if (char == this.DELIMETER) { + rowBuffer.push(columnBuffer); + columnBuffer = ""; + } else if (this.LINE_BREAKS.indexOf(char) > -1) { + rowBuffer.push(columnBuffer); + columnBuffer = ""; + while(this.LINE_BREAKS.indexOf(text.charAt(i + 1)) > -1)i++; + if (row++ >= firstRow) rows.push(rowBuffer); + rowBuffer = []; + if (rows.length == maxRows) break; + } else columnBuffer += char; + } + } + if (columnBuffer != "") rowBuffer.push(columnBuffer); + if (rowBuffer.length > 0) rows.push(rowBuffer); + if (maxRows > 1) this._core.log.write((0, _mainJs.LogLevel).info, `csv ${rows.length} rows ${Math.round(window.performance.now() - start)}ms`); + return rows; + } + writeLine(data) { + let text = ""; + for(let i = 0; i < data.length; i++){ + let column = data[i]; + if (column) { + const quotes = column.indexOf(this.DELIMETER) > -1 || column.indexOf(this.QUOTE) > -1; + column = column.replace(/"/g, '""'); + if (quotes) column = `${this.QUOTE}${column}${this.QUOTE}`; + } + text += column; + if (i < data.length - 1) text += this.DELIMETER; + } + return text; + } + writeAsJavaScriptArray(headings, data) { + let text = "[["; + for (let column of headings)text += `"${column}",`; + text = text.slice(0, -1); + text += "]\n"; + let row; + for(let i = 0; i < data.length; i++){ + const line = data[i]; + row = "["; + for(let j = 0; j < line.length; j++){ + const column = line[j]; + row += `"${column.replace(/"/g, '\\"')}",`; + } + row = row.slice(0, -1); + row += "],\n"; + text += row; + } + text += "];"; + return text; + } +} + +},{"../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iYn0I":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Main", ()=>(0, _mainJs.Main)); -var _mainJs = require("./main.js"); - -},{"./main.js":"615If","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"615If":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Main", ()=>Main); +parcelHelpers.export(exports, "FacetHelper", ()=>FacetHelper); +var _mainJs = require("../main.js"); +class FacetHelper { + constructor(core){ + this._core = core; + } + split1d(ids, facetsX, valuesX, orderedIds, facetIds, offsets, counts) { + this.split3d(ids, facetsX, undefined, undefined, valuesX, null, null, orderedIds, facetIds, offsets, counts); + } + split2d(ids, facetsX, facetsY, valuesX, valuesY, orderedIds, facetIds, offsets, counts) { + this.split3d(ids, facetsX, facetsY, undefined, valuesX, valuesY, null, orderedIds, facetIds, offsets, counts); + } + split3d(ids, facetsX, facetsY, facetsZ, valuesX, valuesY, valuesZ, orderedIds, facetIds, offsets, counts) { + if (valuesX && facetIds.length != valuesX.length) this._core.log.write((0, _mainJs.LogLevel).warn, "facet helper split1d facetIds should be same length as facetValuesX"); + if (valuesY && facetIds.length != valuesY.length) this._core.log.write((0, _mainJs.LogLevel).warn, "facet helper split1d facetIds should be same length as facetValuesY"); + if (valuesZ && facetIds.length != valuesY.length) this._core.log.write((0, _mainJs.LogLevel).warn, "facet helper split1d facetIds should be same length as facetValuesY"); + const start = window.performance.now(); + if (facetsX === undefined) facetsX = 1; + if (facetsY === undefined) facetsY = 1; + if (facetsZ === undefined) facetsZ = 1; + const maxFacetId = facetsX * facetsY * facetsZ - 1; + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const valueX = valuesX ? valuesX[id] : 0; + const valueY = valuesY ? valuesY[id] : 0; + const valueZ = valuesZ ? valuesZ[id] : 0; + const facetId = valueX + valueY * facetsX + valueZ * facetsX * facetsZ; + facetIds[id] = facetId; + if (facetId > maxFacetId) this._core.log.write((0, _mainJs.LogLevel).warn, "facet overflow"); + counts[facetId]++; + } + let offset = 0; + for(let i = 0; i < offsets.length; i++){ + const count = counts[i]; + offsets[i] = offset; + offset += count; + } + const tempOffsets = new Uint32Array(offsets); + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const facetId = facetIds[id]; + offset = tempOffsets[facetId]++; + orderedIds[offset] = id; + } + this._core.log.write((0, _mainJs.LogLevel).info, `facet split ${Math.round(window.performance.now() - start)}ms`); + } + wrap1d(ids, values, columns, coordsX, coordsY) { + const start = window.performance.now(); + let rows = 0; + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const value = values[id]; + coordsX[id] = value % columns; + const row = Math.floor(value / columns); + coordsY[id] = row; + rows = Math.max(row, rows); + } + this._core.log.write((0, _mainJs.LogLevel).info, `facet wrap ${Math.round(window.performance.now() - start)}ms`); + return rows + 1; + } +} + +},{"../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gazw2":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../../main.js"); -var _rendererJs = require("../renderer.js"); -var _quadJs = require("./components/quad.js"); -var _bufferJs = require("./buffer.js"); -var _configJs = require("./config.js"); -var _shaderJs = require("./shaders/shader.js"); -var _colorJs = require("./shaders/color.js"); -var _textureJs = require("./shaders/texture.js"); -var _lassoJs = require("./shaders/lasso.js"); -var _modelJs = require("./shaders/model.js"); -var _sdftextJs = require("./shaders/sdftext.js"); -var _pickgridJs = require("./shaders/pickgrid.js"); -var _unitblockJs = require("./shaders/unitblock.js"); -var _unitsphereJs = require("./shaders/unitsphere.js"); -var _unitcylinderJs = require("./shaders/unitcylinder.js"); -var _unithexprismJs = require("./shaders/unithexprism.js"); -var _unitsdfJs = require("./shaders/unitsdf.js"); -var _anaglyphJs = require("./shaders/anaglyph.js"); -var _textureJs1 = require("../../helpers/texture.js"); -var _pickJs = require("../../helpers/pick.js"); -var _debugJs = require("./components/debug.js"); -var _cartesian2DJs = require("./components/axes/cartesian2d.js"); -var _cartesian3DJs = require("./components/axes/cartesian3d.js"); -var _controllerJs = require("./components/controller.js"); -var _imageJs = require("./components/image.js"); -var _vertexJs = require("../../vertex.js"); -var _labelsJs = require("./components/labels.js"); -var _fontJs = require("./font.js"); -var _lassoJs1 = require("./components/lasso.js"); -class Main extends (0, _rendererJs.RendererBase) { - get shaderResources() { - return this._shaderResources; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ForceDirectHelper", ()=>ForceDirectHelper); +var _octtreeJs = require("./octtree.js"); +class ForceDirectHelper { + set gravity(value) { + this._gravity = value; } - get colorShader() { - return this._colorShader; + get gravity() { + return this._gravity; } - get textureShader() { - return this._textureShader; + set attraction(value) { + this._attraction = value; } - get lassoShader() { - return this._lassoShader; + get attraction() { + return this._attraction; } - get modelShader() { - return this._modelShader; + set repulsion(value) { + this._repulsion = value; } - get sdfTextShader() { - return this._sdfTextShader; + get repulsion() { + return this._repulsion; } - get gridShader() { - return this._gridShader; + set interval(value) { + this._interval = value; } - get blockShader() { - return this._blockShader; + get interval() { + return this._interval; } - get sphereShader() { - return this._sphereShader; + set maxDistance(value) { + this._maxDistance = value; } - get cyclinderShader() { - return this._cylinderShader; + get maxDistance() { + return this._maxDistance; } - get hexPrismShader() { - return this._hexPrismShader; + set iterationsPerLayout(value) { + this._iteractionsPerLayout = value; } - get sdfShader() { - return this._sdfShader; + get iterationsPerLayout() { + return this._iteractionsPerLayout; } - get anaglyphShader() { - return this._anaglyphShader; + set edgeWeightPower(value) { + this._edgeWeightPower = value; } - get currentAxes() { - return this._isAxes1Current ? this._axes1 : this._axes2; + get edgeWeightPower() { + return this._edgeWeightPower; } - set currentAxes(value) { - if (this._isAxes1Current) this._axes1 = value; - else this._axes2 = value; + set theta(value) { + this._theta = value; } - get previousAxes() { - return this._isAxes1Current ? this._axes2 : this._axes1; + get theta() { + return this._theta; } - set previousAxes(value) { - if (this._isAxes1Current) this._axes2 = value; - else this._axes1 = value; + get iterations() { + return this._totalIterations; } - get config() { - return this._config; + get totalRepulsion() { + return this._totalRepulsion; } - constructor(options){ - super(options); - this._config = new (0, _configJs.Config)(); - this._quad = new (0, _quadJs.Quad)(); - this._lasso = new (0, _lassoJs1.Lasso)(); - this._pickedPixels = new Uint8Array(4); - this._pickedIdColor = (0, _glMatrix.vec4).create(); - this._mat3 = (0, _glMatrix.mat3).create(); - this._directionToCamera = (0, _glMatrix.vec3).create(); - this._directionToLight = (0, _glMatrix.vec3).create(); - this._halfAngle = (0, _glMatrix.vec3).create(); - this._cameraPosition = (0, _glMatrix.vec3).create(); - this._modelPosition = (0, _glMatrix.vec3).create(); - this.depthEnabled = true; + get nodePositionsX() { + return this._nodePositionsX; } - get isSupported() { - return this._createContext(document.createElement("canvas")) !== null; + get nodePositionsY() { + return this._nodePositionsY; } - get isWebXRSupported() { - return true; + get nodePositionsZ() { + return this._nodePositionsZ; } - initialize(core) { - super.initialize(core); - this._shaderResources = new (0, _shaderJs.Resources)(); - this._colorShader = new (0, _colorJs.Color)(this._core, this); - this._textureShader = new (0, _textureJs.Texture)(this._core, this); - this._lassoShader = new (0, _lassoJs.Lasso)(this._core, this); - this._modelShader = new (0, _modelJs.Model)(this._core, this); - this._sdfTextShader = new (0, _sdftextJs.SdfText)(this._core, this); - this._gridShader = new (0, _pickgridJs.PickGrid)(this._core, this); - this._anaglyphShader = new (0, _anaglyphJs.Anaglyph)(this._core, this); - this._blockShader = new (0, _unitblockJs.UnitBlock)(this._core, this); - this._sphereShader = new (0, _unitsphereJs.UnitSphere)(this._core, this); - this._cylinderShader = new (0, _unitcylinderJs.UnitCylinder)(this._core, this); - this._hexPrismShader = new (0, _unithexprismJs.UnitHexPrism)(this._core, this); - this._sdfShader = new (0, _unitsdfJs.UnitSdf)(this._core, this); - this._initializeContext(this._createContext(this._canvas)); - this._canvas.addEventListener("webglcontextlost", (event)=>{ - this._core.log.write((0, _mainJs.LogLevel).warn, "WebGL context lost"); - this._isInitialized = false; - event.preventDefault(); - }, false); - this._canvas.addEventListener("webglcontextrestored", ()=>{ - this._initializeContext(this._createContext(this._canvas)); - this._isInitialized = true; - this._core.log.write((0, _mainJs.LogLevel).info, "WebGL context restored"); - }, false); - this._isInitialized = true; + get lockX() { + return this._lockX; } - _initializeContext(gl) { - this._gl = gl; - for(const key in this.fonts){ - const fontVisual = this.fonts[key]; - fontVisual.initializeContext(gl); - } - this._shaderResources.initializeContext(this._gl); - this._colorShader.initializeContext(this._gl); - this._textureShader.initializeContext(this._gl); - this._lassoShader.initializeContext(this._gl); - this._modelShader.initializeContext(this._gl); - this._sdfTextShader.initializeContext(this._gl); - this._gridShader.initializeContext(this._gl); - this._anaglyphShader.initializeContext(this._gl); - this._blockShader.initializeContext(this._gl); - this._sphereShader.initializeContext(this._gl); - this._cylinderShader.initializeContext(this._gl); - this._hexPrismShader.initializeContext(this._gl); - this._sdfShader.initializeContext(this._gl); - this._quad.initializeContext(this._gl); - this._lasso.initializeContext(this._gl); - this._debugAxesVisual.initializeContext(this._gl); - this._framebuffers = [ - null, - null - ]; - const texture = (0, _textureJs1.TextureHelper).create(this._gl, this._core.config.pickWidth, this._core.config.pickHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); - const renderBuffer = this._gl.createRenderbuffer(); - this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); - this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT16, this._core.config.pickWidth, this._core.config.pickHeight); - const framebuffer = this._gl.createFramebuffer(); - this._shaderResources.bindFramebuffer(framebuffer); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, texture, 0); - this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); - this._pickFrameBuffer = framebuffer; - this._anaglyphTextures = [ - null, - null - ]; - this.anaglyphFramebuffers = [ - null, - null - ]; - for(let i = 0; i < this.transitionBuffers.length; i++)this.transitionBuffers[i].initializeContext(this._gl); - if (this._axes1) for(let i1 = 0; i1 < this._axes1.length; i1++)this._axes1[i1].initializeContext(this._gl); - if (this._axes2) for(let i2 = 0; i2 < this._axes2.length; i2++)this._axes2[i2].initializeContext(this._gl); - for(let i3 = 0; i3 < this.labelSets.length; i3++)this.labelSets[i3].initializeContext(this._gl); - for(let i4 = 0; i4 < this.images.length; i4++)this.images[i4].initializeContext(this._gl); - for(let i5 = 0; i5 < this.controllers.length; i5++)this.controllers[i5].initializeContext(this._gl); + set lockX(value) { + this._lockX = value; } - _resize(width, height) { - super._resize(width, height); - for(let i = 0; i < 2; i++){ - const texture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); - const renderBuffer = this._gl.createRenderbuffer(); - this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); - this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT16, width, height); - const framebuffer = this._gl.createFramebuffer(); - this._shaderResources.bindFramebuffer(framebuffer); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, texture, 0); - this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); - this._anaglyphTextures[i] = texture; - this.anaglyphFramebuffers[i] = framebuffer; - } - this._core.log.write((0, _mainJs.LogLevel).info, `buffers resized ${width},${height}`); + get lockY() { + return this._lockY; } - _createContext(canvas) { - const antialias = this._options ? this._options.antialias === undefined ? true : this._options.antialias : true; - return canvas.getContext("webgl", { - stencil: true, - alpha: false, - antialias: antialias - }); + set lockY(value) { + this._lockY = value; } - initializeWebXR(session) { - const promise = new Promise((resolve, reject)=>{ - this._gl.makeXRCompatible().then(()=>{ - session.updateRenderState({ - baseLayer: new XRWebGLLayer(session, this._gl), - depthNear: this._core.config.nearPlane, - depthFar: this._core.config.farPlane - }); - session.requestReferenceSpace("local").then((refSpace)=>{ - this._webXRReferenceSpace = refSpace; - resolve(); - }); - }); - }); - return promise; + get lockZ() { + return this._lockZ; } - prepare(xrFrame) { - if (xrFrame) { - const pose = xrFrame.getViewerPose(this._webXRReferenceSpace); - if (pose) { - const glLayer = xrFrame.session.renderState.baseLayer; - for(let i = 0; i < pose.views.length; i++){ - const view = pose.views[i]; - this.vMatrices[i] = view.transform.inverse.matrix; - this.inverseVMatrices[i] = view.transform.matrix; - (0, _glMatrix.mat4).multiply(this._mvMatrices[i], this.vMatrices[i], this.mMatrix); - this.mvMatrices[i] = this._mvMatrices[i]; - this.pMatrices[i] = view.projectionMatrix; - const viewport = glLayer.getViewport(view); - this._viewports[i].x = viewport.x; - this._viewports[i].y = viewport.y; - this._viewports[i].width = viewport.width; - this._viewports[i].height = viewport.height; - this._framebuffers[i] = glLayer.framebuffer; + set lockZ(value) { + this._lockZ = value; + } + constructor(options){ + this._forcesX = new Float64Array(options.nodeIds.length); + this._forcesY = new Float64Array(options.nodeIds.length); + this._forcesZ = new Float64Array(options.nodeIds.length); + this._totalIterations = 0; + this._totalRepulsion = 0; + this._repulsion = options.repulsion || 1; + this._attraction = options.attraction || 1; + this._gravity = options.gravity || 1; + this._interval = options.interval || 1; + this._maxDistance = options.maxDistance || 1; + this._iteractionsPerLayout = options.iterationsPerLayout || 1; + this._theta = options.theta || 1; + this._nodeIds = options.nodeIds; + this._nodePositionsX = options.nodePositionsX; + this._nodePositionsY = options.nodePositionsY; + this._nodePositionsZ = options.nodePositionsZ; + this._nodeWeights = options.nodeWeights || new Float64Array(this._nodeIds.length).fill(1); + this._edgeIds = options.edgeIds; + this._edgeFromIds = options.edgeFromIds; + this._edgeToIds = options.edgeToIds; + this._edgeWeights = options.edgeWeights || new Float64Array(this._edgeIds.length).fill(1); + this._edgeWeightPower = options.edgeWeightPower || 1; + } + layout() { + this._minBoundsX = Number.MAX_VALUE; + this._minBoundsY = Number.MAX_VALUE; + this._minBoundsZ = Number.MAX_VALUE; + this._maxBoundsX = -Number.MAX_VALUE; + this._maxBoundsY = -Number.MAX_VALUE; + this._maxBoundsZ = -Number.MAX_VALUE; + for(let i = 0; i < this._nodeIds.length; i++){ + this._minBoundsX = Math.min(this._minBoundsX, this._nodePositionsX[i]); + this._minBoundsY = Math.min(this._minBoundsY, this._nodePositionsY[i]); + this._minBoundsZ = Math.min(this._minBoundsZ, this._nodePositionsZ[i]); + this._maxBoundsX = Math.max(this._maxBoundsX, this._nodePositionsX[i]); + this._maxBoundsY = Math.max(this._maxBoundsY, this._nodePositionsY[i]); + this._maxBoundsZ = Math.max(this._maxBoundsZ, this._nodePositionsZ[i]); + } + for(let iteration = 0; iteration < this._iteractionsPerLayout; iteration++){ + for(let i = 0; i < this._nodeIds.length; i++){ + const id = this._nodeIds[i]; + this._forcesX[id] = 0; + this._forcesY[id] = 0; + this._forcesZ[id] = 0; + } + for(let i = 0; i < this._nodeIds.length; i++){ + const id = this._nodeIds[i]; + let dx = this._nodePositionsX[id]; + let dy = this._nodePositionsY[id]; + let dz = this._nodePositionsZ[id]; + const distanceSquared = dx * dx + dy * dy + dz * dz; + if (distanceSquared > 0) { + const distance = Math.sqrt(distanceSquared); + dx /= distance; + dy /= distance; + dz /= distance; + const magnitude = -this._nodeWeights[id] * this._gravity; + this._forcesX[id] += magnitude * dx; + this._forcesY[id] += magnitude * dy; + this._forcesZ[id] += magnitude * dz; } } - this._viewportOffset = 0; - this._viewportCount = 2; - } else { - let viewport1; - switch(this._core.config.stereoMode){ - case (0, _mainJs.StereoMode).none: - viewport1 = this._viewports[0]; - viewport1.x = 0; - viewport1.y = 0; - viewport1.width = this._canvas.width; - viewport1.height = this._canvas.height; - this._viewportOffset = 0; - this._viewportCount = 1; - this._framebuffers[0] = null; - break; - case (0, _mainJs.StereoMode).left: - viewport1 = this._viewports[0]; - viewport1.x = 0; - viewport1.y = 0; - viewport1.width = this._canvas.width; - viewport1.height = this._canvas.height; - this._viewportOffset = 0; - this._viewportCount = 1; - this._framebuffers[0] = null; - break; - case (0, _mainJs.StereoMode).right: - viewport1 = this._viewports[1]; - viewport1.x = 0; - viewport1.y = 0; - viewport1.width = this._canvas.width; - viewport1.height = this._canvas.height; - this._viewportOffset = 1; - this._viewportCount = 1; - this._framebuffers[1] = null; - break; - case (0, _mainJs.StereoMode).anaglyph: - viewport1 = this._viewports[0]; - viewport1.x = 0; - viewport1.y = 0; - viewport1.width = this._canvas.width; - viewport1.height = this._canvas.height; - viewport1 = this._viewports[1]; - viewport1.x = 0; - viewport1.y = 0; - viewport1.width = this._canvas.width; - viewport1.height = this._canvas.height; - this._viewportOffset = 0; - this._viewportCount = 2; - this._framebuffers[0] = this.anaglyphFramebuffers[0]; - this._framebuffers[1] = this.anaglyphFramebuffers[1]; - break; - case (0, _mainJs.StereoMode).split: - viewport1 = this._viewports[0]; - viewport1.x = 0; - viewport1.y = 0; - viewport1.width = this._canvas.width / 2; - viewport1.height = this._canvas.height; - viewport1 = this._viewports[1]; - viewport1.x = this._canvas.width / 2; - viewport1.y = 0; - viewport1.width = this._canvas.width / 2; - viewport1.height = this._canvas.height; - this._viewportOffset = 0; - this._viewportCount = 2; - this._framebuffers[0] = null; - this._framebuffers[1] = null; - break; + for(let i = 0; i < this._edgeIds.length; i++){ + const id = this._edgeIds[i]; + const fromId = this._edgeFromIds[id]; + const toId = this._edgeToIds[id]; + const x1 = this._nodePositionsX[fromId]; + const y1 = this._nodePositionsY[fromId]; + const z1 = this._nodePositionsZ[fromId]; + const x2 = this._nodePositionsX[toId]; + const y2 = this._nodePositionsY[toId]; + const z2 = this._nodePositionsZ[toId]; + let dx = x1 - x2; + let dy = y1 - y2; + let dz = z1 - z2; + const distanceSquared = dx * dx + dy * dy + dz * dz; + if (distanceSquared > 0) { + let distance = Math.sqrt(distanceSquared); + dx /= distance; + dy /= distance; + dz /= distance; + const magnitude = -distance * this._attraction * Math.pow(this._edgeWeights[id], this._edgeWeightPower); + this._forcesX[fromId] += magnitude * dx; + this._forcesY[fromId] += magnitude * dy; + this._forcesZ[fromId] += magnitude * dz; + this._forcesX[toId] -= magnitude * dx; + this._forcesY[toId] -= magnitude * dy; + this._forcesZ[toId] -= magnitude * dz; + } + } + const minBounds = Math.min(Math.min(this._minBoundsX, this._minBoundsY), this._minBoundsZ); + const maxBounds = Math.max(Math.max(this._maxBoundsX, this._maxBoundsY), this._maxBoundsZ); + const size = maxBounds - minBounds; + const maxLevel = 10; + const minBoundsX = minBounds; + const minBoundsY = minBounds; + const minBoundsZ = minBounds; + const maxBoundsX = maxBounds; + const maxBoundsY = maxBounds; + const maxBoundsZ = maxBounds; + const octTreeOptions = { + minBoundsX: minBoundsX, + minBoundsY: minBoundsY, + minBoundsZ: minBoundsZ, + maxBoundsX: maxBoundsX, + maxBoundsY: maxBoundsY, + maxBoundsZ: maxBoundsZ, + maxLevel: maxLevel, + ids: this._nodeIds, + positionsX: this._nodePositionsX, + positionsY: this._nodePositionsY, + positionsZ: this._nodePositionsZ, + masses: this._nodeWeights + }; + const octTree = new (0, _octtreeJs.OctTreeHelper)(octTreeOptions); + this._totalRepulsion = 0; + for(let i = 0; i < this._nodeIds.length; i++){ + const id = this._nodeIds[i]; + this._forceX = 0; + this._forceY = 0; + this._forceZ = 0; + this.calculateRepulsion(octTree.root, id); + this._forcesX[id] += this._forceX; + this._forcesY[id] += this._forceY; + this._forcesZ[id] += this._forceZ; + this._totalRepulsion += Math.sqrt(this._forceX * this._forceX + this._forceY * this._forceY + this._forceZ * this._forceZ); + } + const timeSquared = this._interval * this._interval; + for(let i = 0; i < this._nodeIds.length; i++){ + const id = this._nodeIds[i]; + const mass = this._nodeWeights[id]; + const ax = this._forcesX[id] / mass; + const ay = this._forcesY[id] / mass; + const az = this._forcesZ[id] / mass; + let dx = ax * timeSquared / 2; + let dy = ay * timeSquared / 2; + let dz = az * timeSquared / 2; + const distanceSquared = dx * dx + dy * dy + dz * dz; + const distance = Math.sqrt(distanceSquared); + if (distance > this._maxDistance * size) { + dx *= this._maxDistance * size / distance; + dy *= this._maxDistance * size / distance; + dz *= this._maxDistance * size / distance; + } + if (!this._lockX) this._nodePositionsX[id] += dx; + if (!this._lockY) this._nodePositionsY[id] += dy; + if (!this._lockZ) this._nodePositionsZ[id] += dz; + } + } + if (this.layoutCallback) this.layoutCallback(); + } + calculateRepulsion(parent, id1) { + const x1 = this._nodePositionsX[id1]; + const y1 = this._nodePositionsY[id1]; + const z1 = this._nodePositionsZ[id1]; + for(let k = 0; k < parent.children.length; k++){ + const child = parent.children[k]; + if (!child.children) for(let i = 0; i < child.ids.length; i++){ + const id2 = child.ids[i]; + if (id1 != id2) { + const x2 = this._nodePositionsX[id2]; + const y2 = this._nodePositionsY[id2]; + const z2 = this._nodePositionsZ[id2]; + let dx = x1 - x2; + let dy = y1 - y2; + let dz = z1 - z2; + let distanceSquared = dx * dx + dy * dy + dz * dz; + if (distanceSquared > 0) { + let distance = Math.sqrt(distanceSquared); + dx /= distance; + dy /= distance; + dz /= distance; + const magnitude = this._repulsion * this._nodeWeights[id1] * this._nodeWeights[id2] / distanceSquared; + this._forceX += dx * magnitude; + this._forceY += dy * magnitude; + this._forceZ += dz * magnitude; + } + } + } + else { + let dx = x1 - child.centerOfMassX; + let dy = y1 - child.centerOfMassY; + let dz = z1 - child.centerOfMassZ; + const distanceSquared = dx * dx + dy * dy + dz * dz; + if (distanceSquared > 0) { + const distance = Math.sqrt(distanceSquared); + dx /= distance; + dy /= distance; + dz /= distance; + const width = child.maxBoundsX - child.minBoundsX; + if (width / distance < this._theta) { + const magnitude = this._repulsion * this._nodeWeights[id1] * child.mass / distanceSquared; + this._forceX += dx * magnitude; + this._forceY += dy * magnitude; + this._forceZ += dz * magnitude; + } else this.calculateRepulsion(child, id1); + } } } } - createTransitionBuffer(ids) { - const buffer = new (0, _bufferJs.TransitionBuffer)(this._core, ids); - buffer.initializeContext(this._gl); - return buffer; +} + +},{"./octtree.js":"lv4D9","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lv4D9":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "OctTreeNode", ()=>OctTreeNode); +parcelHelpers.export(exports, "OctTreeHelper", ()=>OctTreeHelper); +class OctTreeNode { +} +class OctTreeHelper { + constructor(options){ + this._ids = options.ids; + this._positionsX = options.positionsX; + this._positionsY = options.positionsY; + this._positionsZ = options.positionsZ; + this._masses = options.masses; + this._maxLevel = options.maxLevel; + this.root = new OctTreeNode(); + this.root.minBoundsX = options.minBoundsX; + this.root.minBoundsY = options.minBoundsY; + this.root.minBoundsZ = options.minBoundsZ; + this.root.maxBoundsX = options.maxBoundsX; + this.root.maxBoundsY = options.maxBoundsY; + this.root.maxBoundsZ = options.maxBoundsZ; + this.root.level = 0; + this.root.octKey = ""; + this._buildTree(this.root, this._ids); + } + _buildTree(parent, ids) { + const centerX = (parent.minBoundsX + parent.maxBoundsX) / 2; + const centerY = (parent.minBoundsY + parent.maxBoundsY) / 2; + const centerZ = (parent.minBoundsZ + parent.maxBoundsZ) / 2; + const minBoundsX = []; + const minBoundsY = []; + const minBoundsZ = []; + const maxBoundsX = []; + const maxBoundsY = []; + const maxBoundsZ = []; + minBoundsX.push(parent.minBoundsX); + minBoundsY.push(parent.minBoundsY); + minBoundsZ.push(parent.minBoundsZ); + maxBoundsX.push(centerX); + maxBoundsY.push(centerY); + maxBoundsZ.push(centerZ); + minBoundsX.push(centerX); + minBoundsY.push(parent.minBoundsY); + minBoundsZ.push(parent.minBoundsZ); + maxBoundsX.push(parent.maxBoundsX); + maxBoundsY.push(centerY); + maxBoundsZ.push(centerZ); + minBoundsX.push(centerX); + minBoundsY.push(parent.minBoundsY); + minBoundsZ.push(centerZ); + maxBoundsX.push(parent.maxBoundsX); + maxBoundsY.push(centerY); + maxBoundsZ.push(parent.maxBoundsZ); + minBoundsX.push(parent.minBoundsX); + minBoundsY.push(parent.minBoundsY); + minBoundsZ.push(centerZ); + maxBoundsX.push(centerX); + maxBoundsY.push(centerY); + maxBoundsZ.push(parent.maxBoundsZ); + minBoundsX.push(parent.minBoundsX); + minBoundsY.push(centerY); + minBoundsZ.push(parent.minBoundsZ); + maxBoundsX.push(centerX); + maxBoundsY.push(parent.maxBoundsY); + maxBoundsZ.push(centerZ); + minBoundsX.push(centerX); + minBoundsY.push(centerY); + minBoundsZ.push(parent.minBoundsZ); + maxBoundsX.push(parent.maxBoundsX); + maxBoundsY.push(parent.maxBoundsY); + maxBoundsZ.push(centerZ); + minBoundsX.push(centerX); + minBoundsY.push(centerY); + minBoundsZ.push(centerZ); + maxBoundsX.push(parent.maxBoundsX); + maxBoundsY.push(parent.maxBoundsY); + maxBoundsZ.push(parent.maxBoundsZ); + minBoundsX.push(parent.minBoundsX); + minBoundsY.push(centerY); + minBoundsZ.push(centerZ); + maxBoundsX.push(centerX); + maxBoundsY.push(parent.maxBoundsY); + maxBoundsZ.push(parent.maxBoundsZ); + const masses = new Float64Array(8); + const centerOfMassesX = new Float64Array(8); + const centerOfMassesY = new Float64Array(8); + const centerOfMassesZ = new Float64Array(8); + const buckets = [ + [], + [], + [], + [], + [], + [], + [], + [] + ]; + for(let i = 0; i < ids.length; i++){ + const index = ids[i]; + const x = this._positionsX[index]; + const y = this._positionsY[index]; + const z = this._positionsZ[index]; + const mass = this._masses[index]; + for(let j = 0; j < 8; j++)if (minBoundsX[j] <= x && maxBoundsX[j] >= x && minBoundsY[j] <= y && maxBoundsY[j] >= y && minBoundsZ[j] <= z && maxBoundsZ[j] >= z) { + buckets[j].push(index); + masses[j] += mass; + centerOfMassesX[j] += x * mass; + centerOfMassesY[j] += y * mass; + centerOfMassesZ[j] += z * mass; + break; + } + } + parent.children = []; + for(let i = 0; i < 8; i++)if (buckets[i].length > 0) { + const child = new OctTreeNode(); + child.minBoundsX = minBoundsX[i]; + child.minBoundsY = minBoundsY[i]; + child.minBoundsZ = minBoundsZ[i]; + child.maxBoundsX = maxBoundsX[i]; + child.maxBoundsY = maxBoundsY[i]; + child.maxBoundsZ = maxBoundsZ[i]; + child.mass = masses[i]; + child.centerOfMassX = centerOfMassesX[i] / masses[i]; + child.centerOfMassY = centerOfMassesY[i] / masses[i]; + child.centerOfMassZ = centerOfMassesZ[i] / masses[i]; + child.level = parent.level + 1; + child.octKey += i.toString(); + child.parent = parent; + child.ids = new Uint32Array(buckets[i]); + parent.children.push(child); + if (child.ids.length > 1 && child.level < this._maxLevel) this._buildTree(child, child.ids); + } } - createControllerVisual(controller) { - const visual = new (0, _controllerJs.ControllerVisual)(this._core, this, controller); - visual.initializeContext(this._gl); - return visual; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ahk7A":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "HexHelper", ()=>HexHelper); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mainJs = require("../main.js"); +var _angleJs = require("./angle.js"); +class HexHelper { + static width(size, orientation) { + if (orientation == (0, _mainJs.HexOrientation).pointyTop) return (0, _constantsJs.Constants).ROOT_THREE * size; + else return 2 * size; } - createCartesian2dAxesVisual(axes) { - const visual = new (0, _cartesian2DJs.Cartesian2dVisual)(this._core, this, axes); - visual.initializeContext(this._gl); - return visual; + static height(size, orientation) { + if (orientation == (0, _mainJs.HexOrientation).pointyTop) return 2 * size; + else return (0, _constantsJs.Constants).ROOT_THREE * size; } - createCartesian3dAxesVisual(axes) { - const visual = new (0, _cartesian3DJs.Cartesian3dVisual)(this._core, this, axes); - visual.initializeContext(this._gl); - return visual; + static pointyHexCorner(center, size, i, position) { + const angle = (0, _angleJs.AngleHelper).degreesToRadians(60 * i - 30); + position[0] = center[0] + size * Math.cos(angle); + position[1] = center[1] + size * Math.sin(angle); } - _createDebugAxesVisual(debugAxes) { - return new (0, _debugJs.DebugAxesVisual)(this._core, this, debugAxes); + static cubeToAxial(cube, hex) { + hex[0] = cube[0]; + hex[1] = cube[2]; } - _createLabelVisual(label) { - return new (0, _labelsJs.LabelVisual)(this._core, this, label); + static axialToCube(hex, cube) { + const x = hex[0]; + const z = hex[1]; + const y = -x - z; + cube[0] = x; + cube[1] = y; + cube[2] = z; } - createLabelSetVisual(labelSet) { - const visual = new (0, _labelsJs.LabelSetVisual)(this._core, this, labelSet); - visual.initializeContext(this._gl); - return visual; + static cubeToOddr(cube, hex) { + const col = cube[0] + (cube[2] - (cube[2] & 1)) / 2; + const row = cube[2]; + hex[0] = col; + hex[1] = row; } - createImageVisual(image) { - const visual = new (0, _imageJs.ImageVisual)(this._core, this, image); - visual.initializeContext(this._gl); - return visual; + static oddrToCube(hex, cube) { + const x = hex[0] - (hex[1] - (hex[1] & 1)) / 2; + const z = hex[1]; + const y = -x - z; + cube[0] = x; + cube[1] = y; + cube[2] = z; } - createFontVisual(font) { - const visual = new (0, _fontJs.FontVisual)(this._core, font); - visual.initializeContext(this._gl); - return visual; + static pointyHexToPixel(hex, size, point) { + point[0] = size * ((0, _constantsJs.Constants).ROOT_THREE * hex[0] + (0, _constantsJs.Constants).ROOT_THREE / 2 * hex[1]); + point[1] = size * (1.5 * hex[1]); } - getDataUrl(mimeType) { - return this._canvas.toDataURL(mimeType); + static pixelToPointyHex(point, size, hex) { + hex[0] = ((0, _constantsJs.Constants).ROOT_THREE / 3 * point[0] - 1 / 3 * point[1]) / size; + hex[1] = 2 / 3 * point[1] / size; + this.hexRound(hex, hex); } - render(elapsedTime, xrFrame) { - if (this.depthEnabled) this._gl.enable(this._gl.DEPTH_TEST); - else this._gl.disable(this._gl.DEPTH_TEST); - this._gl.enable(this._gl.CULL_FACE); - this._gl.disable(this._gl.BLEND); - if (this.isPickingEnabled) { - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.clearColor(0, 0, 0, 0); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); - } - const backgroundColor = this._backgroundColor || this._core.config.backgroundColor; - this._gl.clearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], 1); - if (xrFrame) { - const glLayer = xrFrame.session.renderState.baseLayer; - this._shaderResources.bindFramebuffer(glLayer.framebuffer); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); - } else if (this._core.config.stereoMode == (0, _mainJs.StereoMode).anaglyph) { - for(let i = 0; i < 2; i++){ - this._shaderResources.bindFramebuffer(this.anaglyphFramebuffers[i]); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); + static hexRound(hex, hexRound) { + const cube = this._vec3; + this.axialToCube(hex, cube); + this.cubeRound(cube, cube); + this.cubeToAxial(cube, hexRound); + } + static cubeRound(cube, cubeRound) { + let rx = Math.round(cube[0]); + let ry = Math.round(cube[1]); + let rz = Math.round(cube[2]); + const x_diff = Math.abs(rx - cube[0]); + const y_diff = Math.abs(ry - cube[1]); + const z_diff = Math.abs(rz - cube[2]); + if (x_diff > y_diff && x_diff > z_diff) rx = -ry - rz; + else if (y_diff > z_diff) ry = -rx - rz; + else rz = -rx - ry; + cubeRound[0] = rx; + cubeRound[1] = ry; + cubeRound[2] = rz; + } +} +HexHelper._vec3 = (0, _glMatrix.vec3).create(); + +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../main.js":"f421K","./angle.js":"53hwW","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bm0M4":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "HexBinHelper", ()=>HexBinHelper); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mainJs = require("../main.js"); +var _hexJs = require("./hex.js"); +class HexBinHelper { + static bin(options) { + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? options.ids.length : options.count; + const width = (options.maxValueX - options.minValueX) / options.binsX; + const minValueX = options.minValueX - width / 2; + const binsX = options.binsX + 1; + const size = width / (0, _constantsJs.Constants).ROOT_THREE; + const height = 2 * size; + const heightBetweenCenters = 3 * height / 4; + const binsY = Math.ceil((options.maxValueY - options.minValueY) / heightBetweenCenters) + 1; + const minValueY = options.minValueY; + const minQ = -Math.floor(binsY / 2); + const maxBins = (binsX - minQ) * binsY; + const binCounts = new Float64Array(maxBins); + const binLookup = new Uint32Array(maxBins); + const point = (0, _glMatrix.vec2).create(); + const hex = (0, _glMatrix.vec2).create(); + let nonEmptyBins = 0; + let minCount = Number.MAX_VALUE; + let maxCount = -Number.MAX_VALUE; + for(let i = 0; i < count; i++){ + const id = options.ids[i + offset]; + point[0] = options.valuesX[id] - minValueX; + point[1] = options.valuesY[id] - minValueY; + (0, _hexJs.HexHelper).pixelToPointyHex(point, size, hex); + const q = hex[0] - minQ; + const r = hex[1]; + const binId = q + r * (binsX - minQ); + if (binCounts[binId] == 0) { + binLookup[binId] = nonEmptyBins; + nonEmptyBins++; } - this._shaderResources.bindFramebuffer(null); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); - } else { - this._shaderResources.bindFramebuffer(null); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); + binCounts[binId]++; + options.binIds[id] = binId; + minCount = Math.min(minCount, binCounts[binId]); + maxCount = Math.max(maxCount, binCounts[binId]); } - if (this._core.config.isDebugVisible) { - this._debugAxesVisual.framebuffers = this._framebuffers; - this._debugAxesVisual.render(elapsedTime, xrFrame); + const positionsX = new Float64Array(nonEmptyBins); + const positionsY = new Float64Array(nonEmptyBins); + const counts = new Uint32Array(nonEmptyBins); + const lookup = {}; + for(let i = 0; i < maxBins; i++){ + const count = binCounts[i]; + if (count > 0) { + const index = binLookup[i]; + lookup[i] = index; + counts[index] = count; + const q = i % (binsX - minQ); + const r = Math.floor(i / (binsX - minQ)); + hex[0] = q + minQ; + hex[1] = r; + (0, _hexJs.HexHelper).pointyHexToPixel(hex, size, point); + positionsX[index] = point[0] + minValueX; + positionsY[index] = point[1] + minValueY; + } } - const axesVisuals = this.axesVisibility == (0, _mainJs.AxesVisibility).current ? this.currentAxes : this.axesVisibility == (0, _mainJs.AxesVisibility).previous ? this.previousAxes : null; - if (axesVisuals) for(let i1 = 0; i1 < axesVisuals.length; i1++){ - const axesVisual = axesVisuals[i1]; - if (axesVisual.isVisible) { - axesVisual.pickedIdColor = this._pickedIdColor; - axesVisual.pickFramebuffer = this._pickFrameBuffer; - axesVisual.framebuffers = this._framebuffers; - axesVisual.render(elapsedTime, xrFrame); + const result = { + binIds: options.binIds, + positionsX: positionsX, + positionsY: positionsY, + counts: counts, + minCount: minCount, + maxCount: maxCount, + orientation: (0, _mainJs.HexOrientation).pointyTop, + size: size, + lookup: lookup, + binsY: binsY + }; + return result; + } +} + +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../main.js":"f421K","./hex.js":"ahk7A","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iEeyT":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LineHelper", ()=>LineHelper); +var _mainJs = require("../main.js"); +class LineHelper { + constructor(core){ + this._core = core; + } + connect(orderedIds, series, toIds, offset = 0, count = orderedIds.length) { + const start = window.performance.now(); + const lines = new Set(); + const lookup = {}; + for(let i = offset; i < count; i++){ + const id = orderedIds[i + offset]; + const value = series[id]; + const fromId = lookup[value]; + if (fromId != null) { + toIds[fromId] = id; + lines.add(value); } + lookup[value] = id; + toIds[id] = id; } - for(let i2 = 0; i2 < this.transitionBuffers.length; i2++){ - const transitionBuffer = this.transitionBuffers[i2]; - if (transitionBuffer.isVisible) this._renderTransitionBuffer(xrFrame, transitionBuffer); + this._core.log.write((0, _mainJs.LogLevel).info, `${lines.size} lines connected ${Math.round(window.performance.now() - start)}ms`); + return lines.size; + } +} + +},{"../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7fuDW":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PaletteHelper", ()=>PaletteHelper); +var _glMatrix = require("gl-matrix"); +var _colorJs = require("./color.js"); +var _mathJs = require("./math.js"); +class PaletteHelper { + static resample(colorsIn, divisionsOut, reverse) { + const divisionsIn = colorsIn.length / 3; + const colorsOut = new Uint8Array(divisionsOut * 4); + for(let i = 0; i < divisionsOut; i++){ + const positionOut = (i + 0.5) / divisionsOut; + const positionIn = positionOut * (divisionsIn - 1); + const stepIn = Math.floor(positionIn); + const fractIn = positionIn - stepIn; + const j = reverse ? divisionsOut - i - 1 : i; + colorsOut[j * 4] = (0, _mathJs.MathHelper).lerp(colorsIn[stepIn * 3], colorsIn[(stepIn + 1) * 3], fractIn); + colorsOut[j * 4 + 1] = (0, _mathJs.MathHelper).lerp(colorsIn[stepIn * 3 + 1], colorsIn[(stepIn + 1) * 3 + 1], fractIn); + colorsOut[j * 4 + 2] = (0, _mathJs.MathHelper).lerp(colorsIn[stepIn * 3 + 2], colorsIn[(stepIn + 1) * 3 + 2], fractIn); + colorsOut[j * 4 + 3] = 255; } - if (this.areLabelsVisible) for(let i3 = 0; i3 < this.labelSets.length; i3++){ - const labelSetVisual = this.labelSets[i3]; - if (labelSetVisual.isVisible) { - labelSetVisual.pickedIdColor = this._pickedIdColor; - labelSetVisual.pickFramebuffer = this._pickFrameBuffer; - labelSetVisual.framebuffers = this._framebuffers; - labelSetVisual.render(elapsedTime, xrFrame); - } + return colorsOut; + } + static truncate(colorsIn, divisionsOut, reverse) { + const divisionsIn = colorsIn.length / 3; + const colorsOut = new Uint8Array(divisionsOut * 4); + for(let i = 0; i < Math.min(divisionsIn, divisionsOut); i++){ + const j = reverse ? divisionsOut - i - 1 : i; + colorsOut[j * 4] = colorsIn[i * 3]; + colorsOut[j * 4 + 1] = colorsIn[i * 3 + 1]; + colorsOut[j * 4 + 2] = colorsIn[i * 3 + 2]; + colorsOut[j * 4 + 3] = 255; } - if (this.areImagesVisible) for(let i4 = 0; i4 < this.images.length; i4++){ - const imageVisual = this.images[i4]; - if (imageVisual.isVisible) { - imageVisual.framebuffers = this._framebuffers; - imageVisual.pickFramebuffer = this._pickFrameBuffer; - imageVisual.isPickingEnabled = this.isPickingEnabled; - imageVisual.render(elapsedTime, xrFrame); - } + return colorsOut; + } + static resampleStops(stops, divisions, reverse) { + const colorsOut = new Uint8Array(divisions * 4); + let from = 0; + let to = 0; + for(let i = 0; i < divisions; i++){ + const positionOut = (i + 0.5) / divisions; + while(stops[from].position < positionOut && from < stops.length - 1)from++; + from = Math.max(from - 1, 0); + to = Math.min(from + 1, stops.length - 1); + const fromStop = stops[from]; + const toStop = stops[to]; + const fract = from == to ? 0 : (positionOut - fromStop.position) / (toStop.position - fromStop.position); + const j = reverse ? divisions - i - 1 : i; + colorsOut[j * 4] = (0, _mathJs.MathHelper).lerp(fromStop.r, toStop.r, fract); + colorsOut[j * 4 + 1] = (0, _mathJs.MathHelper).lerp(fromStop.g, toStop.g, fract); + colorsOut[j * 4 + 2] = (0, _mathJs.MathHelper).lerp(fromStop.b, toStop.b, fract); + colorsOut[j * 4 + 3] = 255; } - for(let i5 = 0; i5 < this.controllers.length; i5++){ - const controllerVisual = this.controllers[i5]; - if (controllerVisual.isVisible) { - controllerVisual.isRayVisible = this.isPickingEnabled; - controllerVisual.framebuffers = this._framebuffers; - controllerVisual.render(elapsedTime, xrFrame); - } - } - if (this.isPickingEnabled) { - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.readPixels(this._core.config.pickWidth / 2, this._core.config.pickHeight / 2, 1, 1, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._pickedPixels); - this._pickedType = (0, _pickJs.PickHelper).decodeType(this._pickedPixels); - (0, _glMatrix.vec4).set(this._pickedIdColor, this._pickedPixels[0] / 0xff, this._pickedPixels[1] / 0xff, this._pickedPixels[2] / 0xff, this._pickedPixels[3] / 0xff); - this._pickedId = (0, _pickJs.PickHelper).decodeNumber(this._pickedPixels); - if (this._isCapturingPickImage && this.capturePickImageCallback) { - this._isCapturingPickImage = false; - const data = new Uint8ClampedArray(this._core.config.pickWidth * this._core.config.pickHeight * 4); - this._gl.readPixels(0, 0, this._core.config.pickWidth, this._core.config.pickHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data); - for(let i6 = 0; i6 < data.length / 4; i6++)if (data[i6 * 4 + 3] == (0, _mainJs.PickType).data) data[i6 * 4 + 3] = 255; - else { - data[i6 * 4] = 0; - data[i6 * 4 + 1] = 0; - data[i6 * 4 + 2] = 0; - data[i6 * 4 + 3] = 0; - } - const length = this._core.config.pickWidth * this._core.config.pickHeight * 4; - const row = this._core.config.pickWidth * 4; - const end = (this._core.config.pickHeight - 1) * row; - const flipped = new Uint8ClampedArray(length); - for(let i7 = 0; i7 < length; i7 += row)flipped.set(data.subarray(i7, i7 + row), end - i7); - this.capturePickImageCallback(flipped, this._core.config.pickWidth, this._core.config.pickHeight); - } + return colorsOut; + } + static lerpRgb(from, to, divisions) { + const colors = new Uint8Array(divisions * 4); + for(let i = 0; i < divisions; i++){ + const amount = i / (divisions - 1); + colors[i * 4] = (0, _mathJs.MathHelper).lerp(from[0], to[0], amount); + colors[i * 4 + 1] = (0, _mathJs.MathHelper).lerp(from[1], to[1], amount); + colors[i * 4 + 2] = (0, _mathJs.MathHelper).lerp(from[2], to[2], amount); + colors[i * 4 + 3] = 0xff; + } + return colors; + } + static lerpHsv(from, to, divisions) { + const colors = new Uint8Array(divisions * 4); + for(let i = 0; i < divisions; i++){ + const amount = i / (divisions - 1); + const h = (0, _mathJs.MathHelper).lerp(from[0], to[0], amount); + const s = (0, _mathJs.MathHelper).lerp(from[1], to[1], amount); + const v = (0, _mathJs.MathHelper).lerp(from[2], to[2], amount); + (0, _colorJs.ColorHelper).hsvToRgb(h, s, v, PaletteHelper._rgb); + colors[i * 4] = PaletteHelper._rgb[0] * 0xff; + colors[i * 4 + 1] = PaletteHelper._rgb[1] * 0xff; + colors[i * 4 + 2] = PaletteHelper._rgb[2] * 0xff; + colors[i * 4 + 3] = 0xff; + } + return colors; + } +} +PaletteHelper._rgb = (0, _glMatrix.vec3).create(); + +},{"gl-matrix":"5x28d","./color.js":"4LgMf","./math.js":"f65d0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dvdia":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PathHelper", ()=>PathHelper); +class PathHelper { + static getFilenameWithoutExtension(path) { + const dot = path.lastIndexOf('.'); + if (dot == -1) return path; + else { + const start = path.lastIndexOf('/') == -1 ? 0 : path.lastIndexOf('/') + 1; + return path.substring(start, dot); + } + } + static getExtension(path) { + const dot = path.lastIndexOf('.'); + if (dot == -1 || dot == path.length - 1) return null; + else return path.substring(dot + 1, path.length); + } + static getFilename(path) { + if (path.lastIndexOf('/') == -1) return path; + else { + const start = path.lastIndexOf('/') + 1; + return path.substring(start, path.length); + } + } + static getPath(path) { + if (path.lastIndexOf('/') == -1) return ""; + else return path.substring(0, path.lastIndexOf('/')); + } + static combine(first, second) { + const seperator = first.lastIndexOf('/') == first.length - 1; + if (second.indexOf('/') == 0) { + if (seperator) return first.substring(0, first.length - 1) + second; + else return first + second; } else { - (0, _glMatrix.vec4).set(this._pickedIdColor, 0, 0, 0, 0); - this._pickedId = 0; - } - if (this.isLassoPicking && this._lassoShader.isInitialized) { - this._lassoShader.vertexBuffer = this._lasso.vertexBuffer; - this._lassoShader.indexBuffer = this._lasso.indexBuffer; - const lassoWidth = this.lassoX1 - this.lassoX0; - const lassoHeight = this.lassoY1 - this.lassoY0; - this._lassoShader.prepare(); - this._lassoShader.color = this.lassoColor ? this.lassoColor : this._core.config.lassoColor; - this._lassoShader.dashWidth = this.lassoDashWidth ? this.lassoDashWidth : this._core.config.lassoDashWidth; - this._lassoShader.apply(); - const lassoThickness = this.lassoThickness ? this.lassoThickness : this._core.config.lassoThickness; - for(let i8 = 0; i8 < this._viewportCount; i8++){ - const viewportIndex = i8 + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewportIndex]); - const viewport = this._viewports[viewportIndex]; - this._gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); - this._lassoMMatrix[0] = lassoWidth * 2 / viewport.width; - this._lassoMMatrix[5] = lassoHeight * 2 / viewport.height; - this._lassoMMatrix[10] = 1; - this._lassoMMatrix[12] = (this.lassoX0 + lassoWidth / 2) / viewport.width * 2 - 1; - this._lassoMMatrix[13] = 1 - (this.lassoY0 + lassoHeight / 2) / viewport.height * 2; - this._lassoShader.mMatrix = this._lassoMMatrix; - (0, _glMatrix.vec2).set(this._lassoThickness, lassoThickness / lassoWidth, lassoThickness / lassoHeight); - this._lassoShader.thickness = this._lassoThickness; - this._lassoShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._lasso.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - } - if (this._core.config.stereoMode == (0, _mainJs.StereoMode).anaglyph && this._anaglyphShader.isInitialized && this._quad.isInitialized) { - this._shaderResources.bindFramebuffer(null); - this._gl.viewport(this._viewports[0].x, this._viewports[0].y, this._viewports[0].width, this._viewports[0].height); - this._anaglyphShader.vertexBuffer = this._quad.vertexBuffer; - this._anaglyphShader.indexBuffer = this._quad.indexBuffer; - this._anaglyphShader.texture2D1 = this._anaglyphTextures[0]; - this._anaglyphShader.texture2D2 = this._anaglyphTextures[1]; - this._anaglyphShader.prepare(); - this._anaglyphShader.viewport = this._viewports[0]; - this._anaglyphShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + if (seperator) return first + second; + else return first + '/' + second; } } - _renderTransitionBuffer(xrFrame, transitionBuffer) { - const currentBuffer = transitionBuffer.currentBuffer; - const previousBuffer = transitionBuffer.previousBuffer; - const currentPalette = transitionBuffer.currentPalette; - const previousPalette = transitionBuffer.previousPalette; - const currentAtlas = transitionBuffer.currentAtlas; - const previousAtlas = transitionBuffer.previousAtlas; - const unitType = transitionBuffer.unitType === undefined ? currentBuffer.unitType : transitionBuffer.unitType; - const id = currentBuffer.lookup[transitionBuffer.pickIdLookup[this._pickedId]]; - const hoverId = id > -1 ? (0, _vertexJs.UnitVertex).getIdHover(currentBuffer.dataView, id) : -1; - const activeId = transitionBuffer.activeId; - if (this._blockShader.isInitialized && (unitType == (0, _mainJs.UnitType).block || unitType == (0, _mainJs.UnitType).blockSdf)) { - this._blockShader.instanceBuffer = currentBuffer.vertexBuffer; - this._blockShader.previousInstanceBuffer = previousBuffer.vertexBuffer; - this._blockShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; - this._blockShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; - this._blockShader.prepare(); - this._blockShader.mMatrix = this.mMatrix; - this._blockShader.time = this.transitionTime; - this._blockShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._blockShader.rangeMin = 0; - this._blockShader.rangeMax = transitionBuffer.length - 1; - this._blockShader.hover = hoverId; - this._blockShader.active = activeId; - this._blockShader.selectedColor = this._core.config.selectionColor; - this._blockShader.hoverColor = this._core.config.hoverColor; - this._blockShader.activeColor = this._core.config.activeColor; - this._blockShader.highlightMode = this._core.config.highlightMode; - this._blockShader.specularPower = this._config.specularPower; - this._blockShader.specularIntensity = this._config.specularIntensity; - this._blockShader.apply(); - this._blockShader.isPickShader = false; - for(let i = 0; i < this._viewportCount; i++){ - const viewport = i + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewport]); - this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); - const vMatrix = this.vMatrices[viewport]; - if (xrFrame) { - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); - const inverseVMatrix = this.inverseVMatrices[viewport]; - (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix[12], inverseVMatrix[13], inverseVMatrix[14]); - (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); - (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); - (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); - (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix); - (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); - (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); - this._blockShader.directionToLight = this._directionToLight; - this._blockShader.halfAngle = this._halfAngle; - } else { - this._blockShader.directionToLight = this._config.directionToLight; - this._blockShader.halfAngle = this._config.halfAngle; - } - this._blockShader.vMatrix = vMatrix; - this._blockShader.pMatrix = this.pMatrices[viewport]; - this._blockShader.applyView(); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { - this._blockShader.isPickShader = true; - this._blockShader.pMatrix = this.pickPMatrix; - this._blockShader.vMatrix = this.pickVMatrix; - this._blockShader.applyView(); - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - } else if (this._sphereShader.isInitialized && (unitType == (0, _mainJs.UnitType).sphere || unitType == (0, _mainJs.UnitType).sphereSdf)) { - this._sphereShader.instanceBuffer = currentBuffer.vertexBuffer; - this._sphereShader.previousInstanceBuffer = previousBuffer.vertexBuffer; - this._sphereShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; - this._sphereShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; - this._sphereShader.prepare(); - this._sphereShader.mMatrix = this.mMatrix; - this._sphereShader.time = this.transitionTime; - this._sphereShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._sphereShader.rangeMin = 0; - this._sphereShader.rangeMax = transitionBuffer.length - 1; - this._sphereShader.hover = hoverId; - this._sphereShader.active = activeId; - this._sphereShader.selectedColor = this._core.config.selectionColor; - this._sphereShader.hoverColor = this._core.config.hoverColor; - this._sphereShader.activeColor = this._core.config.activeColor; - this._sphereShader.highlightMode = this._core.config.highlightMode; - this._sphereShader.specularPower = this._config.specularPower; - this._sphereShader.specularIntensity = this._config.specularIntensity; - this._sphereShader.apply(); - this._sphereShader.isPickShader = false; - for(let i1 = 0; i1 < this._viewportCount; i1++){ - const viewport1 = i1 + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewport1]); - this._gl.viewport(this._viewports[viewport1].x, this._viewports[viewport1].y, this._viewports[viewport1].width, this._viewports[viewport1].height); - const vMatrix1 = this.vMatrices[viewport1]; - if (xrFrame) { - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); - const inverseVMatrix1 = this.inverseVMatrices[viewport1]; - (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix1[12], inverseVMatrix1[13], inverseVMatrix1[14]); - (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); - (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); - (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); - (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix1); - (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); - (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); - this._sphereShader.directionToLight = this._directionToLight; - this._sphereShader.halfAngle = this._halfAngle; - } else { - this._sphereShader.directionToLight = this._config.directionToLight; - this._sphereShader.halfAngle = this._config.halfAngle; - } - this._sphereShader.vMatrix = vMatrix1; - this._sphereShader.pMatrix = this.pMatrices[viewport1]; - this._sphereShader.applyView(); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { - this._sphereShader.isPickShader = true; - this._sphereShader.pMatrix = this.pickPMatrix; - this._sphereShader.vMatrix = this.pickVMatrix; - this._sphereShader.applyView(); - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - } else if (this._cylinderShader.isInitialized && (unitType == (0, _mainJs.UnitType).cylinder || unitType == (0, _mainJs.UnitType).cylinderSdf)) { - this._cylinderShader.instanceBuffer = currentBuffer.vertexBuffer; - this._cylinderShader.previousInstanceBuffer = previousBuffer.vertexBuffer; - this._cylinderShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; - this._cylinderShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; - this._cylinderShader.prepare(); - this._cylinderShader.mMatrix = this.mMatrix; - this._cylinderShader.time = this.transitionTime; - this._cylinderShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._cylinderShader.rangeMin = 0; - this._cylinderShader.rangeMax = transitionBuffer.length - 1; - this._cylinderShader.hover = hoverId; - this._cylinderShader.active = activeId; - this._cylinderShader.selectedColor = this._core.config.selectionColor; - this._cylinderShader.hoverColor = this._core.config.hoverColor; - this._cylinderShader.activeColor = this._core.config.activeColor; - this._cylinderShader.highlightMode = this._core.config.highlightMode; - this._cylinderShader.specularPower = this._config.specularPower; - this._cylinderShader.specularIntensity = this._config.specularIntensity; - this._cylinderShader.apply(); - this._cylinderShader.isPickShader = false; - for(let i2 = 0; i2 < this._viewportCount; i2++){ - const viewport2 = i2 + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewport2]); - this._gl.viewport(this._viewports[viewport2].x, this._viewports[viewport2].y, this._viewports[viewport2].width, this._viewports[viewport2].height); - const vMatrix2 = this.vMatrices[viewport2]; - if (xrFrame) { - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); - const inverseVMatrix2 = this.inverseVMatrices[viewport2]; - (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix2[12], inverseVMatrix2[13], inverseVMatrix2[14]); - (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); - (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); - (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); - (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix2); - (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); - (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); - this._cylinderShader.directionToLight = this._directionToLight; - this._cylinderShader.halfAngle = this._halfAngle; - } else { - this._cylinderShader.directionToLight = this._config.directionToLight; - this._cylinderShader.halfAngle = this._config.halfAngle; - } - this._cylinderShader.vMatrix = vMatrix2; - this._cylinderShader.pMatrix = this.pMatrices[viewport2]; - this._cylinderShader.applyView(); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { - this._cylinderShader.isPickShader = true; - this._cylinderShader.pMatrix = this.pickPMatrix; - this._cylinderShader.vMatrix = this.pickVMatrix; - this._cylinderShader.applyView(); - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - } else if (this._hexPrismShader.isInitialized && (unitType == (0, _mainJs.UnitType).hexPrism || unitType == (0, _mainJs.UnitType).hexPrismSdf)) { - this._hexPrismShader.instanceBuffer = currentBuffer.vertexBuffer; - this._hexPrismShader.previousInstanceBuffer = previousBuffer.vertexBuffer; - this._hexPrismShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; - this._hexPrismShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; - this._hexPrismShader.prepare(); - this._hexPrismShader.mMatrix = this.mMatrix; - this._hexPrismShader.time = this.transitionTime; - this._hexPrismShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._hexPrismShader.rangeMin = 0; - this._hexPrismShader.rangeMax = transitionBuffer.length - 1; - this._hexPrismShader.hover = hoverId; - this._hexPrismShader.active = activeId; - this._hexPrismShader.selectedColor = this._core.config.selectionColor; - this._hexPrismShader.hoverColor = this._core.config.hoverColor; - this._hexPrismShader.activeColor = this._core.config.activeColor; - this._hexPrismShader.highlightMode = this._core.config.highlightMode; - this._hexPrismShader.specularPower = this._config.specularPower; - this._hexPrismShader.specularIntensity = this._config.specularIntensity; - this._hexPrismShader.apply(); - this._hexPrismShader.isPickShader = false; - for(let i3 = 0; i3 < this._viewportCount; i3++){ - const viewport3 = i3 + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewport3]); - this._gl.viewport(this._viewports[viewport3].x, this._viewports[viewport3].y, this._viewports[viewport3].width, this._viewports[viewport3].height); - const vMatrix3 = this.vMatrices[viewport3]; - if (xrFrame) { - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); - const inverseVMatrix3 = this.inverseVMatrices[viewport3]; - (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix3[12], inverseVMatrix3[13], inverseVMatrix3[14]); - (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); - (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); - (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); - (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix3); - (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); - (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); - this._hexPrismShader.directionToLight = this._directionToLight; - this._hexPrismShader.halfAngle = this._halfAngle; - } else { - this._hexPrismShader.directionToLight = this._config.directionToLight; - this._hexPrismShader.halfAngle = this._config.halfAngle; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cn0Qv":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "TableHelper", ()=>TableHelper); +var _mainJs = require("../main.js"); +var _tableJs = require("../tables/table.js"); +class TableHelper { + constructor(core){ + this._core = core; + } + compatibleTypes(data, firstRow = 0, maxRows = Number.MAX_VALUE) { + const start = window.performance.now(); + const types = []; + const integers = []; + let values = data[firstRow]; + let parsedFloat, parsedDate; + for(let i = 0; i < values.length; i++){ + const value = values[i]; + parsedFloat = Number(value); + parsedDate = Date.parse(value); + let integer = false; + let type; + if (!isNaN(parsedFloat)) { + type = (0, _tableJs.ColumnType).float; + integer = Number.isSafeInteger(parsedFloat); + } else if (!isNaN(parsedDate)) type = (0, _tableJs.ColumnType).date; + else type = (0, _tableJs.ColumnType).string; + types.push(type); + integers.push(integer); + } + for(let i = firstRow + 1; i < Math.min(data.length, firstRow + maxRows); i++){ + values = data[i]; + for(let j = 0; j < values.length; j++)if (types[j] != (0, _tableJs.ColumnType).string) { + const value = values[j]; + parsedFloat = Number(value); + if (types[j] == (0, _tableJs.ColumnType).float) { + if (isNaN(parsedFloat)) { + types[j] = (0, _tableJs.ColumnType).string; + integers[j] = false; + } else if (integers[j]) integers[j] = Number.isSafeInteger(parsedFloat); + } else if (types[j] == (0, _tableJs.ColumnType).date) { + parsedDate = Date.parse(value); + if (isNaN(parsedDate)) types[j] = (0, _tableJs.ColumnType).string; } - this._hexPrismShader.vMatrix = vMatrix3; - this._hexPrismShader.pMatrix = this.pMatrices[viewport3]; - this._hexPrismShader.applyView(); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._hexPrismShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { - this._hexPrismShader.isPickShader = true; - this._hexPrismShader.pMatrix = this.pickPMatrix; - this._hexPrismShader.vMatrix = this.pickVMatrix; - this._hexPrismShader.applyView(); - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._hexPrismShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - } else if (this._sdfShader.isInitialized && unitType == (0, _mainJs.UnitType).sdf) { - this._sdfShader.instanceBuffer = currentBuffer.vertexBuffer; - this._sdfShader.previousInstanceBuffer = previousBuffer.vertexBuffer; - this._sdfShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; - this._sdfShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; - this._sdfShader.sdfTexture = currentAtlas.texture || currentAtlas.defaultTexture; - this._sdfShader.previousSdfTexture = previousAtlas.texture || previousAtlas.defaultTexture; - this._sdfShader.prepare(); - this._sdfShader.mMatrix = this.mMatrix; - this._sdfShader.time = this.transitionTime; - this._sdfShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._sdfShader.rangeMin = 0; - this._sdfShader.rangeMax = transitionBuffer.length - 1; - this._sdfShader.hover = hoverId; - this._sdfShader.active = activeId; - this._sdfShader.selectedColor = this._core.config.selectionColor; - this._sdfShader.hoverColor = this._core.config.hoverColor; - this._sdfShader.activeColor = this._core.config.activeColor; - this._sdfShader.highlightMode = this._core.config.highlightMode; - this._sdfShader.sdfBuffer = (this.sdfBuffer || this._core.config.sdfBuffer) / 0xff; - this._sdfShader.sdfBackgroundColor = this.sdfBackgroundColor || this._core.config.backgroundColor; - this._sdfShader.specularPower = this._config.specularPower; - this._sdfShader.specularIntensity = this._config.specularIntensity; - this._sdfShader.apply(); - this._sdfShader.isPickShader = false; - for(let i4 = 0; i4 < this._viewportCount; i4++){ - const viewport4 = i4 + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewport4]); - this._gl.viewport(this._viewports[viewport4].x, this._viewports[viewport4].y, this._viewports[viewport4].width, this._viewports[viewport4].height); - const vMatrix4 = this.vMatrices[viewport4]; - if (xrFrame) { - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); - const inverseVMatrix4 = this.inverseVMatrices[viewport4]; - (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix4[12], inverseVMatrix4[13], inverseVMatrix4[14]); - (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); - (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); - (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); - (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); - (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix4); - (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); - (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); - this._sdfShader.directionToLight = this._directionToLight; - this._sdfShader.halfAngle = this._halfAngle; - } else { - this._sdfShader.directionToLight = this._config.directionToLight; - this._sdfShader.halfAngle = this._config.halfAngle; + } + const compatibleTypes = []; + for(let i = 0; i < types.length; i++){ + let compatible = types[i] | (0, _tableJs.ColumnType).string; + if (integers[i]) compatible |= (0, _tableJs.ColumnType).integer; + compatibleTypes.push(compatible); + } + this._core.log.write((0, _mainJs.LogLevel).info, `compatible types ${Math.round(window.performance.now() - start)}ms`); + return compatibleTypes; + } + inferTypes(data, firstRow = 0, maxRows = Number.MAX_VALUE) { + const columnTypes = []; + const compatibleTypes = this.compatibleTypes(data, firstRow, maxRows); + for(let i = 0; i < compatibleTypes.length; i++){ + let columnType; + const compatibleType = compatibleTypes[i]; + if (compatibleType & (0, _tableJs.ColumnType).integer) columnType = (0, _tableJs.ColumnType).integer; + else if (compatibleType & (0, _tableJs.ColumnType).float) columnType = (0, _tableJs.ColumnType).float; + else if (compatibleType & (0, _tableJs.ColumnType).date) columnType = (0, _tableJs.ColumnType).date; + else columnType = (0, _tableJs.ColumnType).string; + columnTypes.push(columnType); + } + return columnTypes; + } + convertToObject(table) { + const headings = table.headings; + const jsonObject = []; + for(let i = 0; i < table.all.ids.length; i++){ + const row = {}; + for(let j = 0; j < headings.length; j++){ + const column = headings[j]; + const value = table.all.columnValues(j)[i]; + switch(table.getColumnType(j)){ + case (0, _tableJs.ColumnType).integer: + case (0, _tableJs.ColumnType).float: + row[column] = value; + break; + case (0, _tableJs.ColumnType).string: + case (0, _tableJs.ColumnType).date: + default: + row[column] = table.data[i][j]; + break; } - this._sdfShader.vMatrix = vMatrix4; - this._sdfShader.pMatrix = this.pMatrices[viewport4]; - this._sdfShader.applyView(); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { - this._sdfShader.isPickShader = true; - this._sdfShader.pMatrix = this.pickPMatrix; - this._sdfShader.vMatrix = this.pickVMatrix; - this._sdfShader.applyView(); - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + jsonObject.push(row); } } + return jsonObject; } } -},{"gl-matrix":"9GjEQ","../../main.js":"1Kju3","../renderer.js":"gKWdZ","./components/quad.js":"i1OvI","./buffer.js":"fYclR","./config.js":"joCj5","./shaders/shader.js":"5rKvk","./shaders/color.js":"3UKx9","./shaders/texture.js":"caAA8","./shaders/lasso.js":"lw4z7","./shaders/model.js":"jDhUl","./shaders/sdftext.js":"dbvo6","./shaders/pickgrid.js":"3RavI","./shaders/unitblock.js":"eXg0e","./shaders/unitsphere.js":"8zbGd","./shaders/unitcylinder.js":"kkt7L","./shaders/unithexprism.js":"gOp7C","./shaders/unitsdf.js":"ga6lZ","./shaders/anaglyph.js":"5atqZ","../../helpers/texture.js":"bUBAh","../../helpers/pick.js":"9zmDo","./components/debug.js":"Csa08","./components/axes/cartesian2d.js":"hO56R","./components/axes/cartesian3d.js":"jewgl","./components/controller.js":"ciHaP","./components/image.js":"fpCMV","../../vertex.js":"ddAub","./components/labels.js":"kba4Q","./font.js":"5ax1N","./components/lasso.js":"46fmv","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gKWdZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "RendererConfig", ()=>RendererConfig); -parcelHelpers.export(exports, "RendererBase", ()=>RendererBase); +},{"../main.js":"f421K","../tables/table.js":"1Nyfw","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1Nyfw":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _mainJs = require("../main.js"); -var _axesJs = require("../components/axes/axes.js"); -var _bufferJs = require("../buffer.js"); -var _vertexJs = require("../vertex.js"); -var _labelsJs = require("../components/labels.js"); -var _debugJs = require("../components/debug.js"); -var _controllerJs = require("../components/controller.js"); -var _imageJs = require("../components/image.js"); -var _fontJs = require("../font.js"); -class RendererConfig { - reset() {} -} -class RendererBase { - get isInitialized() { - return this._isInitialized; - } - get config() { - return this._config; - } - get devicePixelRatio() { - return this._devicePixelRatio; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Table", ()=>Table); +parcelHelpers.export(exports, "ColumnType", ()=>ColumnType); +var _filterJs = require("./filter.js"); +class Table { + get data() { + return this._data; } - get width() { - return this._canvas.width; + get headings() { + return this._headings; } - set width(value) { - this._options.width = value; + get all() { + return this._all; } - get height() { - return this._canvas.height; + get isInitialized() { + return this._isInitialized; } - set height(value) { - this._options.height = value; + get filter() { + return this._filter; } - get webXRReferenceSpace() { - return this._webXRReferenceSpace; + set filter(value) { + if (this._filter !== value) { + this._filter = value; + if (this.filterChangedCallback) this.filterChangedCallback(); + } } - get pickedType() { - return this._pickedType; + getColumnType(column) { + return this._columnTypes[column]; } - get pickedId() { - return this._pickedId; + isColumnDiscrete(column) { + return (this._columnTypes[column] & ColumnType.discrete) > 0; } - get isCapturingPickImage() { - return this._isCapturingPickImage; + isColumnNumeric(column) { + return (this._columnTypes[column] & ColumnType.numeric) > 0; } - capturePickImage() { - this._isCapturingPickImage = true; + isColumnContinuous(column) { + return (this._columnTypes[column] & ColumnType.continuous) > 0; } - get backgroundColor() { - return this._backgroundColor; + constructor(core, headings, data, columnTypes){ + this._core = core; + this._headings = headings; + this._data = data; + this._columnTypes = columnTypes; + this._numericValues = Array(columnTypes.length).fill(null); + const indices = new Uint32Array(data.length); + for(let i = 0; i < indices.length; i++)indices[i] = i; + this._all = new (0, _filterJs.Filter)(core, indices, data, headings, columnTypes, this._numericValues); + this._isInitialized = true; } - set backgroundColor(value) { - if (!(0, _glMatrix.vec3).exactEquals(value, this._backgroundColor)) this._backgroundColor = value; + createFilter(ids) { + return new (0, _filterJs.Filter)(this._core, ids, this._data, this._headings, this._columnTypes, this._numericValues); } - get currentAxes() { - return this._isAxes1Current ? this._axes1 : this._axes2; +} +const ColumnType = { + none: 0, + float: 1, + integer: 2, + string: 4, + date: 8, + continuous: 9, + discrete: 6, + numeric: 11 +}; + +},{"./filter.js":"b6FuS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"b6FuS":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Filter", ()=>Filter); +var _mainJs = require("../main.js"); +var _tableJs = require("./table.js"); +class Filter { + get ids() { + return this._ids; } - set currentAxes(value) { - if (this._isAxes1Current) this._axes1 = value; - else this._axes2 = value; + constructor(core, ids, data, headings, columnTypes, numericValues){ + this._core = core; + this._ids = ids; + this._data = data; + this._columnTypes = columnTypes; + this._numericValues = numericValues; + this._stringValues = Array(columnTypes.length).fill(null); + this._hasMinMaxValues = Array(columnTypes.length).fill(false); + this._minValues = Array(columnTypes.length).fill(0); + this._maxValues = Array(columnTypes.length).fill(0); + this._distinctStrings = Array(columnTypes.length).fill(null); + this._orderedIds = Array(columnTypes.length).fill(null); + this._orderedValues = Array(columnTypes.length).fill(null); } - get previousAxes() { - return this._isAxes1Current ? this._axes2 : this._axes1; + columnValues(column) { + if (this._columnTypes[column] == (0, _tableJs.ColumnType).string) return this._createStringValues(column); + else return this._createNumericValues(column); } - set previousAxes(value) { - if (this._isAxes1Current) this._axes2 = value; - else this._axes1 = value; + minValue(column) { + this._createMinMaxValues(column); + return this._minValues[column]; } - swapAxes() { - this._isAxes1Current = !this._isAxes1Current; + maxValue(column) { + this._createMinMaxValues(column); + return this._maxValues[column]; } - createCartesian2dAxesVisual(axes) { - return new (0, _axesJs.AxesVisual)(axes); + distinctStrings(column) { + if (this._columnTypes[column] == (0, _tableJs.ColumnType).string) { + this._createStringValues(column); + return this._distinctStrings[column]; + } else return null; } - createCartesian3dAxesVisual(axes) { - return new (0, _axesJs.AxesVisual)(axes); + toJSON(ids, columns) { + const rows = []; + for(let i = 0; i < ids.length; i++){ + const rowIndex = ids[i]; + const row = []; + for(let j = 0; j < columns.length; j++){ + const columnIndex = columns[j]; + switch(this._columnTypes[columnIndex]){ + case (0, _tableJs.ColumnType).date: + case (0, _tableJs.ColumnType).string: + row.push(this._data[rowIndex][columnIndex]); + break; + case (0, _tableJs.ColumnType).integer: + case (0, _tableJs.ColumnType).float: + const numericValues = this._createNumericValues(columnIndex); + row.push(numericValues[rowIndex]); + break; + } + } + rows.push(row); + } + return JSON.stringify(rows); } - _createDebugAxesVisual(debugAxes) { - return null; + orderedIds(column) { + if (!this._orderedIds[column]) { + const start = window.performance.now(); + const orderedIds = new Uint32Array(this._ids); + const values = this._columnTypes[column] == (0, _tableJs.ColumnType).string ? this._createStringValues(column) : this._createNumericValues(column); + orderedIds.sort(function(a, b) { + return values[a] - values[b]; + }); + this._orderedIds[column] = orderedIds; + this._core.log.write((0, _mainJs.LogLevel).info, `ordered ids ${column} ${Math.round(window.performance.now() - start)}ms`); + } + return this._orderedIds[column]; } - createLabelSetVisual(labelSet) { - return new (0, _labelsJs.LabelSetVisual)(labelSet); + orderedValues(column) { + if (!this._orderedValues[column]) { + const start = window.performance.now(); + const values = this._columnTypes[column] == (0, _tableJs.ColumnType).string ? this._createStringValues(column) : this._createNumericValues(column); + const orderedIds = this.orderedIds(column); + const orderedValues = new Float64Array(this._ids.length); + for(let i = 0; i < this._ids.length; i++)orderedValues[i] = values[orderedIds[i]]; + this._orderedValues[column] = orderedValues; + this._core.log.write((0, _mainJs.LogLevel).info, `ordered values ${column} ${Math.round(window.performance.now() - start)}ms`); + } + return this._orderedValues[column]; } - createControllerVisual(controller) { - return new (0, _controllerJs.ControllerVisual)(controller); + distinctStringsOrdered(ids, column, stringValues) { + if (this._columnTypes[column] == (0, _tableJs.ColumnType).string) { + const distinctStrings = []; + const distinctStringValues = {}; + const set = new Set(); + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const string = this._data[id][column]; + let value; + if (!set.has(string)) { + distinctStrings.push(string); + value = set.size; + distinctStringValues[string] = value; + set.add(string); + } else value = distinctStringValues[string]; + stringValues[id] = value; + } + return distinctStrings; + } else return null; } - createTransitionBuffer(ids) { - return new (0, _bufferJs.TransitionBuffer)(this._core, ids); - } - createImageVisual(image) { - return new (0, _imageJs.ImageVisual)(image); - } - createFontVisual(font) { - return new (0, _fontJs.FontVisual)(font); - } - constructor(options){ - this._options = options; - this.fonts = {}; - } - get isWebXRSupported() { - return false; - } - initialize(core) { - this._core = core; - this._canvas = document.createElement("canvas"); - const contextmenu = this._options && this._options.contextmenu; - if (!contextmenu) this._canvas.addEventListener("contextmenu", (e)=>{ - e.preventDefault(); - }); - this._canvas.tabIndex = this._core.container.tabIndex; - this._canvas.style.display = "block"; - this._canvas.style.touchAction = "none"; - this._core.container.appendChild(this._canvas); - this._mvMatrices = [ - (0, _glMatrix.mat4).create(), - (0, _glMatrix.mat4).create() - ]; - this.pickPMatrix = (0, _glMatrix.mat4).create(); - this.axesVisibility = (0, _mainJs.AxesVisibility).current; - this._debugAxes = new (0, _debugJs.DebugAxes)(); - this._debugAxesVisual = this._createDebugAxesVisual(this._debugAxes); - this.transitionTime = 1; - this.transitionBuffers = []; - this.areLabelsVisible = true; - this.labelSets = []; - this.controllers = []; - this.areImagesVisible = true; - this.images = []; - this._viewports = [ - new DOMRect(), - new DOMRect() - ]; - this.isPickingEnabled = false; - this._pickedType = (0, _mainJs.PickType).none; - this._pickedId = 0; - this._lassoMMatrix = (0, _glMatrix.mat4).create(); - this._lassoThickness = (0, _glMatrix.vec2).create(); - this._resizeMinimumDelay = -1; - this._previousResizeWidth = -1; - this._previousResizeHeight = -1; - } - remove() { - this._core.container.removeChild(this._canvas); - } - finalize() { - this._isInitialized = false; - } - setSize(elapsedTime) { - if (this._options && this._options.width && this._options.height) { - this._devicePixelRatio = 1; - this._resizeWidth = this._options.width; - this._resizeHeight = this._options.height; - } else { - this._devicePixelRatio = window.devicePixelRatio || 1; - this._resizeWidth = this._core.container.clientWidth * devicePixelRatio; - this._resizeHeight = this._core.container.clientHeight * devicePixelRatio; - } - if (this._resizeWidth != this._previousResizeWidth || this._resizeHeight != this._previousResizeHeight) { - this._previousResizeWidth = this._resizeWidth; - this._previousResizeHeight = this._resizeHeight; - this._isResizing = true; - this._resizeElapsedTime = elapsedTime; - } - if (this._isResizing) { - if (this._resizeElapsedTime > this._resizeMinimumDelay && this._isInitialized) { - this._isResizing = false; - this._resizeMinimumDelay = this._core.config.resizeMinimumDelay; - this._resize(this._resizeWidth, this._resizeHeight); - } else this._resizeElapsedTime += elapsedTime; - } - } - _resize(width, height) { - this._canvas.style.width = `${Math.floor(width / this._devicePixelRatio)}px`; - this._canvas.style.height = `${Math.floor(height / this._devicePixelRatio)}px`; - width = Math.floor(width); - height = Math.floor(height); - this._canvas.width = width; - this._canvas.height = height; - } - update(elapsedTime) { - for(let i = 0; i < this.transitionBuffers.length; i++){ - const transitionBuffer = this.transitionBuffers[i]; - if (transitionBuffer.isVisible) { - const previous = transitionBuffer.previousPalette; - const current = transitionBuffer.currentPalette; - if (previous) previous.update(); - if (current) current.update(); - } - } - for(let i1 = 0; i1 < this.transitionBuffers.length; i1++){ - const transitionBuffer1 = this.transitionBuffers[i1]; - if (transitionBuffer1.isVisible) { - const previous1 = transitionBuffer1.previousAtlas; - const current1 = transitionBuffer1.currentAtlas; - if (previous1) previous1.update(); - if (current1) current1.update(); - } - } - if (this._core.config.isDebugVisible) { - if (this._debugAxesVisual) { - this._debugAxesVisual.mMatrix = this.mMatrix; - this._debugAxesVisual.vMatrices = this.vMatrices; - this._debugAxesVisual.pMatrices = this.pMatrices; - this._debugAxesVisual.viewports = this._viewports; - this._debugAxesVisual.viewportOffset = this._viewportOffset; - this._debugAxesVisual.viewportCount = this._viewportCount; - } - } - if (this.areLabelsVisible) for(let i2 = 0; i2 < this.labelSets.length; i2++){ - const labelSetVisual = this.labelSets[i2]; - if (labelSetVisual.isVisible) { - this.labelSets[i2].label.update(elapsedTime); - labelSetVisual.mMatrix = this.mMatrix; - labelSetVisual.vMatrices = this.vMatrices; - labelSetVisual.pMatrices = this.pMatrices; - labelSetVisual.isPickingEnabled = this.isPickingEnabled; - labelSetVisual.pickPMatrix = this.pickPMatrix; - labelSetVisual.pickVMatrix = this.pickVMatrix; - labelSetVisual.viewports = this._viewports; - labelSetVisual.viewportOffset = this._viewportOffset; - labelSetVisual.viewportCount = this._viewportCount; - labelSetVisual.update(elapsedTime); + _createMinMaxValues(column) { + if (!this._hasMinMaxValues[column]) { + const type = this._columnTypes[column]; + let min, max; + if (type == (0, _tableJs.ColumnType).string) { + this._createStringValues(column); + min = 0; + max = this._distinctStrings[column].length - 1; + } else { + const numericValues = this._createNumericValues(column); + min = Number.MAX_VALUE; + max = -Number.MAX_VALUE; + for(let i = 0; i < this._ids.length; i++){ + const id = this._ids[i]; + const value = numericValues[id]; + min = Math.min(min, value); + max = Math.max(max, value); + } } + this._minValues[column] = min; + this._maxValues[column] = max; + this._hasMinMaxValues[column] = true; } - if (this.areImagesVisible) for(let i3 = 0; i3 < this.images.length; i3++){ - const imageVisual = this.images[i3]; - if (imageVisual && imageVisual.isVisible) { - const image = this.images[i3].image; - image.update(elapsedTime); - imageVisual.mMatrix = this.mMatrix; - imageVisual.vMatrices = this.vMatrices; - imageVisual.pMatrices = this.pMatrices; - imageVisual.isPickingEnabled = this.isPickingEnabled; - imageVisual.pickPMatrix = this.pickPMatrix; - imageVisual.pickVMatrix = this.pickVMatrix; - imageVisual.viewports = this._viewports; - imageVisual.viewportOffset = this._viewportOffset; - imageVisual.viewportCount = this._viewportCount; - imageVisual.update(elapsedTime); + } + _createNumericValues(column) { + if (!this._numericValues[column]) { + const numericValues = new Float64Array(this._data.length); + const type = this._columnTypes[column]; + if (type == (0, _tableJs.ColumnType).float) for(let i = 0; i < this._data.length; i++){ + const value = parseFloat(this._data[i][column]); + numericValues[i] = value; } - } - for(let i4 = 0; i4 < this.controllers.length; i4++){ - const controllerVisual = this.controllers[i4]; - if (controllerVisual.isVisible) { - const controller = this.controllers[i4].controller; - controller.update(elapsedTime); - controllerVisual.vMatrices = this.vMatrices; - controllerVisual.inverseVMatrices = this.vMatrices; - controllerVisual.pMatrices = this.pMatrices; - controllerVisual.viewports = this._viewports; - controllerVisual.viewportOffset = this._viewportOffset; - controllerVisual.viewportCount = this._viewportCount; - controllerVisual.update(elapsedTime); + else if (type == (0, _tableJs.ColumnType).integer) for(let i = 0; i < this._data.length; i++){ + const value = parseInt(this._data[i][column]); + numericValues[i] = value; } - } - const axesVisuals = this.axesVisibility == (0, _mainJs.AxesVisibility).current ? this.currentAxes : this.axesVisibility == (0, _mainJs.AxesVisibility).previous ? this.previousAxes : null; - if (axesVisuals) for(let i5 = 0; i5 < axesVisuals.length; i5++){ - const axesVisual = axesVisuals[i5]; - if (axesVisual.isVisible) { - const axes = axesVisual.axes; - axes.mMatrix = this.mMatrix; - axes.vMatrix = this.vMatrices[0]; - axes.update(elapsedTime); - axesVisual.vMatrices = this.vMatrices; - axesVisual.pMatrices = this.pMatrices; - axesVisual.isPickingEnabled = this.isPickingEnabled; - axesVisual.pickPMatrix = this.pickPMatrix; - axesVisual.pickVMatrix = this.pickVMatrix; - axesVisual.viewports = this._viewports; - axesVisual.viewportOffset = this._viewportOffset; - axesVisual.viewportCount = this._viewportCount; - axesVisual.update(elapsedTime); + else if (type == (0, _tableJs.ColumnType).date) for(let i = 0; i < this._data.length; i++){ + const value = Date.parse(this._data[i][column]); + numericValues[i] = value; } + this._numericValues[column] = numericValues; } - for(const key in this.fonts){ - const fontVisual = this.fonts[key]; - const font = fontVisual.font; - font.update(); - fontVisual.update(); - } + return this._numericValues[column]; } - getVertexPosition(position, pickedId) { - for(let i = 0; i < this.transitionBuffers.length; i++){ - const transitionBuffer = this.transitionBuffers[i]; - const id = transitionBuffer.pickIdLookup[pickedId]; - if (id > -1) { - const index = transitionBuffer.currentBuffer.lookup[id]; - const dataView = transitionBuffer.currentBuffer.dataView; - (0, _vertexJs.UnitVertex).getTranslation(dataView, index, position); - break; - } + _createStringValues(column) { + if (!this._stringValues[column]) { + this._stringValues[column] = new Float64Array(this._data.length); + this._distinctStrings[column] = this.distinctStringsOrdered(this._ids, column, this._stringValues[column]); + this._minValues[column] = 0; + this._maxValues[column] = this._distinctStrings[column].length - 1; + this._hasMinMaxValues[column] = true; } - } - render(elapsedTime, xrFrame) {} - prepare(xrFrame) {} - initializeWebXR(session) { - return null; + return this._stringValues[column]; } } -},{"gl-matrix":"9GjEQ","../main.js":"1Kju3","../components/axes/axes.js":"duutq","../buffer.js":"k3bT1","../vertex.js":"ddAub","../components/labels.js":"4IFc8","../components/debug.js":"7qz3c","../components/controller.js":"jirYv","../components/image.js":"llF9m","../font.js":"5CPIb","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"k3bT1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "BufferBase", ()=>BufferBase); -parcelHelpers.export(exports, "TransitionBufferBase", ()=>TransitionBufferBase); -parcelHelpers.export(exports, "Buffer", ()=>Buffer); -parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); +},{"../main.js":"f421K","./table.js":"1Nyfw","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bUoBU":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("./constants.js"); -var _paletteJs = require("./palette.js"); -var _vertexJs = require("./vertex.js"); -var _pickJs = require("./helpers/pick.js"); -var _mainJs = require("./main.js"); -var _atlasJs = require("./atlas.js"); -class BufferBase { - get isInitialized() { - return this._isInitialized; - } - get ids() { - return this._ids; - } - get dataView() { - return this._dataView; - } - get vertices() { - return this._vertices; - } - get lookup() { - return this._lookup; - } - get length() { - return this._length; - } - get selected() { - return this._selected; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "TextureHelper", ()=>TextureHelper); +var _mathJs = require("./math.js"); +class TextureHelper { + static create(gl, width, height, format, type, filter, bytes, internalFormat = format) { + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter); + gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, width, height, 0, format, type, bytes); + return texture; } - constructor(core, ids){ - this._core = core; - this._ids = ids; - this._length = ids.length; - this._vertices = new ArrayBuffer(this._length * (0, _vertexJs.UnitVertex).SIZE_BYTES); - this._dataView = new DataView(this._vertices); - this._selected = new Set(); - this.from = 0; - this.to = 1; - this.unitType = (0, _mainJs.UnitType).block; - this._lookup = {}; - for(let i = 0; i < this._length; i++){ - const id = ids[i]; - this._lookup[id] = i; + static fromImage(gl, image, mipmaps, filter) { + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + if (mipmaps && (0, _mathJs.MathHelper).isPowerOf2(image.width) && (0, _mathJs.MathHelper).isPowerOf2(image.height)) gl.generateMipmap(gl.TEXTURE_2D); + else { + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter); } + gl.bindTexture(gl.TEXTURE_2D, null); + return texture; } - createShared() { - const buffer = Object.create(this); - buffer._vertices = new ArrayBuffer(buffer._vertices.byteLength); - buffer._dataView = new DataView(buffer._vertices); - return buffer; - } - copyFrom(buffer) { - const start = window.performance.now(); - const fromDataView = buffer.dataView; - const toDataView = this._dataView; - const lookup = buffer.lookup; - for(let i = 0; i < this._length; i++){ - const index = lookup[this._ids[i]]; - if (index != null) { - (0, _vertexJs.UnitVertex).copyIdHover(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyTranslation(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyScale(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyRotation(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyColor(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copySelected(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyMaterial(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyRounding(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyOrder(fromDataView, index, toDataView, i); - (0, _vertexJs.UnitVertex).copyTexCoord(fromDataView, index, toDataView, i); - } else (0, _vertexJs.UnitVertex).setRotation(toDataView, i, (0, _constantsJs.Constants).QUAT_IDENTITY); + static cubemapFromImages(gl, images) { + const texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); + const targets = [ + gl.TEXTURE_CUBE_MAP_POSITIVE_X, + gl.TEXTURE_CUBE_MAP_NEGATIVE_X, + gl.TEXTURE_CUBE_MAP_POSITIVE_Y, + gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, + gl.TEXTURE_CUBE_MAP_POSITIVE_Z, + gl.TEXTURE_CUBE_MAP_NEGATIVE_Z + ]; + for(let i = 0; i < 6; i++){ + gl.texImage2D(targets[i], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, images[i]); + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); } - this.unitType = buffer.unitType; - this._selected = buffer.selected; - this._core.log.write((0, _mainJs.LogLevel).info, `buffer copied ${this._length} ${Math.round(window.performance.now() - start)}ms`); + gl.generateMipmap(gl.TEXTURE_CUBE_MAP); + gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); + return texture; } - update() {} - updateSelection(options) { - const start = window.performance.now(); - const ids = options && options.ids ? options.ids : this._ids; - const offset = options && options.offset !== undefined ? options.offset : 0; - const count = options && options.count !== undefined ? options.count : ids.length; - const selection = this._selected.size > 0; - const dataView = this._dataView; - for(let i = 0; i < count; i++){ - const id = ids[i + offset]; - const index = this._lookup[id]; - (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? this._selected.has(id) ? 1 : -1 : 0); +} + +},{"./math.js":"f65d0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4ts5g":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "TreeHelper", ()=>TreeHelper); +class TreeHelper { + static parentChildren(ids, parentIds, childIds) { + const rootIds = []; + const degrees = new Uint32Array(ids.length); + const indices = {}; + const children = {}; + for(let i = 0; i < ids.length; i++){ + const index = ids[i]; + const parentId = parentIds[index]; + const childId = childIds[index]; + indices[childId] = index; + if (children[parentId] === undefined) { + children[parentId] = []; + degrees[index] = 1; + } + if (parentId < 0 || parentId == childId) rootIds.push(parentId); + else { + children[parentId].push(childId); + degrees[index]++; + } } - this.update(); - this._core.log.write((0, _mainJs.LogLevel).info, `buffer update selection ${count} ${Math.round(window.performance.now() - start)}ms`); + return { + rootIds: rootIds, + indices: indices, + children: children, + degrees: degrees + }; + } + static tree(rootId, indices, children, positions, widths, descendents) { + let nextId = 0; + const idsArray = []; + let maxDescendents = 0; + const buildTree = (parentId)=>{ + const index = indices[parentId]; + idsArray.push(index); + const childIds = children[parentId]; + if (childIds !== undefined) { + const start = nextId; + let total = 0; + for(let i = 0; i < childIds.length; i++){ + buildTree(childIds[i]); + total += descendents[indices[childIds[i]]] + 1; + } + const end = nextId - 1; + positions[index] = (start + end) / 2; + descendents[index] = total; + maxDescendents = Math.max(maxDescendents, total); + widths[index] = end - start + 1; + } else { + widths[index] = 1; + positions[index] = nextId++; + } + }; + buildTree(rootId); + const maxPosition = nextId - 1; + return { + ids: new Uint32Array(idsArray), + maxDescendents: maxDescendents, + maxPosition: maxPosition + }; } } -class TransitionBufferBase { - get pickIdLookup() { - return this._pickIdLookup; - } - get currentBuffer() { - return this._isBuffer1Current ? this._buffer1 : this._buffer2; - } - get previousBuffer() { - return this._isBuffer1Current ? this._buffer2 : this._buffer1; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7s3Z5":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "SetHelper", ()=>SetHelper); +class SetHelper { + static new(a, b) { + a.clear(); + for (let item of b)a.add(item); } - get currentPalette() { - return this._isBuffer1Current ? this._palette1 : this._palette2; + static union(a, b) { + for (let item of b)a.add(item); } - get previousPalette() { - return this._isBuffer1Current ? this._palette2 : this._palette1; + static intersection(a, b) { + const c = new Set(b); + for (let item of a)if (!c.has(item)) a.delete(item); + for (let item of b)if (!a.has(item)) a.delete(item); } - get currentAtlas() { - return this._isBuffer1Current ? this._atlas1 : this._atlas2; + static symmetricDifference(a, b) { + for (let item of b)if (a.has(item)) a.delete(item); + else a.add(item); } - get previousAtlas() { - return this._isBuffer1Current ? this._atlas2 : this._atlas1; + static difference(a, b) { + for (let item of b)a.delete(item); } - get isInitialized() { - return this._isInitialized; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2PdqK":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "SdfHelper", ()=>SdfHelper); +class SdfHelper { + static _circle(px, py, r) { + return Math.sqrt(px * px + py * py) - r; } - get length() { - return this._length; + static _box(px, py, bx, by) { + const dx0 = Math.abs(px) - bx; + const dy0 = Math.abs(py) - by; + const dx1 = Math.max(dx0, 0); + const dy1 = Math.max(dy0, 0); + return Math.sqrt(dx1 * dx1 + dy1 * dy1) + Math.min(Math.max(dx0, dy0), 0); } - constructor(core, ids, bufferType, paletteType, atlasType){ - this.bufferType = bufferType; - this.paletteType = paletteType; - this.atlasType = atlasType; - this._core = core; - this._length = ids.length; - this.id = TransitionBufferBase._id++; - this.isVisible = true; - this.transitionTime = 1; - this.activeId = -1; - const start = window.performance.now(); - this._buffer1 = new bufferType(core, ids); - this._buffer2 = this._buffer1.createShared(); - this._palette1 = new paletteType(); - this._palette2 = new paletteType(); - this._atlas1 = new atlasType(); - this._atlas2 = new atlasType(); - this.isPickingEnabled = true; - this._pickIdLookup = {}; - const dataView1 = this._buffer1.dataView; - const dataView2 = this._buffer2.dataView; - const _vec4 = (0, _glMatrix.vec4).create(); - for(let i = 0; i < this._length; i++){ - const id = ids[i]; - const pickId = (0, _pickJs.PickHelper).nextPickId(); - this._pickIdLookup[pickId] = id; - (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).data, _vec4); - (0, _vertexJs.UnitVertex).setIdColor(dataView1, i, _vec4); - (0, _vertexJs.UnitVertex).setIdColor(dataView2, i, _vec4); + static _create(width, height, edge, sdf) { + const pixels = new Uint8ClampedArray(width * height * 4); + for(let y = 0; y < height; y++)for(let x = 0; x < width; x++){ + const d = edge - sdf(x - width / 2, y - height / 2); + const offset = (x + y * height) * 4; + pixels[offset] = d; + pixels[offset + 1] = d; + pixels[offset + 2] = d; + pixels[offset + 3] = 0xff; } - this._core.log.write((0, _mainJs.LogLevel).info, `transition buffer created ${this._length} ${Math.round(window.performance.now() - start)}ms`); - } - swap() { - this._isBuffer1Current = !this._isBuffer1Current; - } - copyFrom(transitionBuffer) { - const start = window.performance.now(); - this.key = transitionBuffer.key; - this.isVisible = transitionBuffer.isVisible; - this.transitionTime = transitionBuffer.transitionTime; - this.isPickingEnabled = transitionBuffer.isPickingEnabled; - this.unitType = transitionBuffer.unitType; - this.activeId = transitionBuffer.activeId; - this.currentBuffer.copyFrom(transitionBuffer.currentBuffer); - this.previousBuffer.copyFrom(transitionBuffer.previousBuffer); - this.currentBuffer.update(); - this.previousBuffer.update(); - this.currentPalette.copyFrom(transitionBuffer.currentPalette); - this.previousPalette.copyFrom(transitionBuffer.previousPalette); - this.currentAtlas.copyFrom(transitionBuffer.currentAtlas); - this.previousAtlas.copyFrom(transitionBuffer.previousAtlas); - this._core.log.write((0, _mainJs.LogLevel).info, `transition buffer copied ${this._length} ${Math.round(window.performance.now() - start)}ms`); + return new ImageData(pixels, width, height); } -} -TransitionBufferBase._id = 1; -class Buffer extends BufferBase { - constructor(core, ids){ - super(core, ids); + static circle(imageWidth, imageHeight, radius, edgeValue) { + const sdf = (x, y)=>this._circle(x, y, radius); + return this._create(imageWidth, imageHeight, edgeValue, sdf); } -} -class TransitionBuffer extends TransitionBufferBase { - constructor(core, ids){ - super(core, ids, Buffer, (0, _paletteJs.Palette), (0, _atlasJs.Atlas)); + static box(imageWidth, imageHeight, boxWidth, boxHeight, edgeValue, rounding = 0) { + const sdf = (x, y)=>this._box(x, y, boxWidth - rounding, boxHeight - rounding) - rounding; + return this._create(imageWidth, imageHeight, edgeValue, sdf); } } -},{"gl-matrix":"9GjEQ","./constants.js":"2Scl5","./palette.js":"8zxgm","./vertex.js":"ddAub","./helpers/pick.js":"9zmDo","./main.js":"1Kju3","./atlas.js":"duwwc","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"duwwc":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2r8XP":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "AtlasBase", ()=>AtlasBase); -parcelHelpers.export(exports, "Atlas", ()=>Atlas); -class AtlasBase { - get imageData() { - return this._imageData; - } - set imageData(value) { - if (this._imageData != value) { - this._imageData = value; - this._changed = true; - } - } - constructor(){ - this._imageData = null; - } - copyFrom(atlas) { - if (atlas.imageData) { - this._imageData = atlas.imageData; - this._changed = true; - } else this.imageData = null; - } - update() {} -} -class Atlas extends AtlasBase { -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7qz3c":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DebugAxes", ()=>DebugAxes); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); +parcelHelpers.export(exports, "VectorHelper", ()=>VectorHelper); +var _glMatrix = require("gl-matrix"); var _constantsJs = require("../constants.js"); -var _cubeJs = require("../meshes/cube.js"); -var _vertexJs = require("../vertex.js"); -class DebugAxes { - get vertices() { - return this._vertices; - } - get indices() { - return this._indices; - } - get indexCount() { - return this._indexCount; - } - get isInitialized() { - return this._isInitialized; - } - initialize() { - let vertexOffset = 0; - let indexOffset = 0; - const axisVertices = (0, _cubeJs.Cube).POSITIONS; - const axisIndices = (0, _cubeJs.Cube).INDICES; - this._vertices = new ArrayBuffer(3 * (0, _vertexJs.PositionColorVertex).SIZE_BYTES * axisVertices.length / (0, _vertexJs.PositionVertex).SIZE); - const verticesView = new DataView(this._vertices); - this._indices = new Uint16Array(3 * axisIndices.length + 4); - const vertexCount = axisVertices.length / (0, _vertexJs.PositionVertex).SIZE; - const indexCount = axisIndices.length; - const transform = (0, _glMatrix.mat4).create(); - const length = 1; - const width = 0.01; - transform[0] = length; - transform[5] = width; - transform[10] = width; - transform[12] = 0.5; - transform[13] = 0; - transform[14] = 0; - this._createAxis(axisVertices, axisIndices, verticesView, this._indices, (0, _constantsJs.Constants).VECTOR3_UNITX, transform, vertexOffset, indexOffset); - indexOffset += indexCount; - this._indices[indexOffset++] = axisIndices[indexCount - 1] + vertexOffset; - vertexOffset += vertexCount; - this._indices[indexOffset++] = axisIndices[0] + vertexOffset; - transform[0] = width; - transform[5] = length; - transform[10] = width; - transform[12] = 0; - transform[13] = 0.5; - transform[14] = 0; - this._createAxis(axisVertices, axisIndices, verticesView, this._indices, (0, _constantsJs.Constants).VECTOR3_UNITY, transform, vertexOffset, indexOffset); - indexOffset += indexCount; - this._indices[indexOffset++] = axisIndices[indexCount - 1] + vertexOffset; - vertexOffset += vertexCount; - this._indices[indexOffset++] = axisIndices[0] + vertexOffset; - transform[0] = width; - transform[5] = width; - transform[10] = length; - transform[12] = 0; - transform[13] = 0; - transform[14] = 0.5; - this._createAxis(axisVertices, axisIndices, verticesView, this._indices, (0, _constantsJs.Constants).VECTOR3_UNITZ, transform, vertexOffset, indexOffset); - this._indexCount = this._indices.length; - this._isInitialized = true; - } - update(elapsedTime) {} - _createAxis(axisVertices, axisIndices, verticesView, indices, color, transform, vertexOffset, indexOffset) { - const position = (0, _glMatrix.vec3).create(); - const vertexCount = axisVertices.length / (0, _vertexJs.PositionVertex).SIZE; - const indexCount = axisIndices.length; - for(let i = 0; i < vertexCount; i++){ - (0, _glMatrix.vec3).set(position, axisVertices[i * (0, _vertexJs.PositionVertex).SIZE], axisVertices[i * (0, _vertexJs.PositionVertex).SIZE + 1], axisVertices[i * (0, _vertexJs.PositionVertex).SIZE + 2]); - (0, _glMatrix.vec3).transformMat4(position, position, transform); - (0, _vertexJs.PositionColorVertex).setPosition(verticesView, vertexOffset + i, position); - (0, _vertexJs.PositionColorVertex).setColor(verticesView, vertexOffset + i, color); - } - for(let i1 = 0; i1 < indexCount; i1++)indices[indexOffset + i1] = axisIndices[i1] + vertexOffset; +class VectorHelper { + static orthonormalBasis(n, b1, b2) { + if (n[0] > 0.9) (0, _glMatrix.vec3).copy(b1, (0, _constantsJs.Constants).VECTOR3_UNITY); + else (0, _glMatrix.vec3).copy(b1, (0, _constantsJs.Constants).VECTOR3_UNITX); + (0, _glMatrix.vec3).scaleAndAdd(b1, b1, n, -(0, _glMatrix.vec3).dot(b1, n)); + (0, _glMatrix.vec3).normalize(b1, b1); + (0, _glMatrix.vec3).cross(b2, n, b1); } } -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","../meshes/cube.js":"7rTMs","../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i1OvI":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Quad", ()=>Quad); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"duBHP":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _quadJs = require("../../../meshes/quad.js"); -class Quad { - get isInitialized() { - return this._isInitialized; - } - get vertexBuffer() { - return this._vertexBuffer; - } - get indexBuffer() { - return this._indexBuffer; - } - get indexCount() { - return this._indexCount; - } - initializeContext(gl) { - const _vec3 = (0, _glMatrix.vec3).fromValues(2, 2, 2); - const _mat4 = (0, _glMatrix.mat4).create(); - (0, _glMatrix.mat4).fromScaling(_mat4, _vec3); - const vertices = (0, _quadJs.Quad).positions(_mat4); - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); - const indices = (0, _quadJs.Quad).INDICES; - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); - this._indexCount = indices.length; - this._isInitialized = true; - } -} - -},{"gl-matrix":"9GjEQ","../../../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fYclR":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Buffer", ()=>Buffer); -parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _bufferJs = require("../../buffer.js"); -var _mainJs = require("../../main.js"); -var _atlasJs = require("./atlas.js"); -var _paletteJs = require("./palette.js"); -class Buffer extends (0, _bufferJs.BufferBase) { - get vertexBuffer() { - return this._vertexBuffer; - } - initializeContext(gl) { - this._gl = gl; - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.STATIC_DRAW); - this._isInitialized = true; - } - update() { - if (this._isInitialized) { - const start = window.performance.now(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._vertices); - this._core.log.write((0, _mainJs.LogLevel).info, `buffer updated ${this._length} ${Math.round(window.performance.now() - start)}ms`); - } - } -} -class TransitionBuffer extends (0, _bufferJs.TransitionBufferBase) { - constructor(core, ids){ - super(core, ids, Buffer, (0, _paletteJs.Palette), (0, _atlasJs.Atlas)); - } - initializeContext(gl) { - this._buffer1.initializeContext(gl); - this._buffer2.initializeContext(gl); - this._palette1.initializeContext(this._core, gl); - this._palette2.initializeContext(this._core, gl); - this._atlas1.initializeContext(this._core, gl); - this._atlas2.initializeContext(this._core, gl); - this._isInitialized = true; - } -} +parcelHelpers.export(exports, "Bar", ()=>(0, _barJs.Bar)); +parcelHelpers.export(exports, "Cube", ()=>(0, _cubeJs.Cube)); +parcelHelpers.export(exports, "Line", ()=>(0, _lineJs.Line)); +parcelHelpers.export(exports, "Tree", ()=>(0, _treeJs.Tree)); +parcelHelpers.export(exports, "PythagorasTree", ()=>(0, _treeJs.PythagorasTree)); +parcelHelpers.export(exports, "Scatter", ()=>(0, _scatterJs.Scatter)); +parcelHelpers.export(exports, "Sheet", ()=>(0, _sheetJs.Sheet)); +parcelHelpers.export(exports, "SquarifiedTreeMap", ()=>(0, _treemapJs.SquarifiedTreeMap)); +parcelHelpers.export(exports, "CubifiedTreeMap", ()=>(0, _treemapJs.CubifiedTreeMap)); +parcelHelpers.export(exports, "Stack", ()=>(0, _stackJs.Stack)); +parcelHelpers.export(exports, "StackTreeMap", ()=>(0, _stackJs.StackTreeMap)); +var _barJs = require("./bar.js"); +var _cubeJs = require("./cube.js"); +var _lineJs = require("./line.js"); +var _treeJs = require("./tree.js"); +var _scatterJs = require("./scatter.js"); +var _sheetJs = require("./sheet.js"); +var _treemapJs = require("./treemap.js"); +var _stackJs = require("./stack.js"); -},{"../../buffer.js":"k3bT1","../../main.js":"1Kju3","./atlas.js":"aV60x","./palette.js":"9ezMr","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aV60x":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Atlas", ()=>Atlas); +},{"./bar.js":"6wdpr","./cube.js":"g6aRn","./line.js":"a7d6z","./tree.js":"2Odry","./scatter.js":"bwpY2","./sheet.js":"fGQjs","./treemap.js":"1HzJp","./stack.js":"f8244","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6wdpr":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _textureJs = require("../../helpers/texture.js"); -var _atlasJs = require("../../atlas.js"); -class Atlas extends (0, _atlasJs.AtlasBase) { - get texture() { - return this._texture; - } - get defaultTexture() { - return this._defaultTexture; - } - initializeContext(core, gl) { - this._gl = gl; - this._defaultTexture = (0, _textureJs.TextureHelper).create(gl, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, gl.NEAREST, new Uint8Array([ - 0xff, - 0xff, - 0xff, - 0xff - ])); - this._updateTexture(); - } - update() { - super.update(); - if (this._changed) { - this._changed = false; - this._updateTexture(); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Bar", ()=>Bar); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class Bar extends (0, _layoutJs.LayoutBase) { + layout(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const positionScalingX = options.positionScalingX === undefined ? 1 : options.positionScalingX; + const positionScalingZ = options.positionScalingZ === undefined ? 1 : options.positionScalingZ; + const heightScaling = options.heightScaling === undefined ? 1 : options.heightScaling; + const minHeight = options.minHeight === undefined ? 0 : options.minHeight; + const paddingX = options.paddingX == undefined ? 0 : options.paddingX * positionScalingX; + const paddingZ = options.paddingZ == undefined ? 0 : options.paddingZ * positionScalingZ; + if (!this._positions || this._positions.length < buffer.length * 3) { + this._positions = new Float32Array(buffer.length * 3); + this._sizes = new Float32Array(buffer.length * 3); + } + this.minLayoutBoundsX = Number.MAX_VALUE; + this.minLayoutBoundsY = Number.MAX_VALUE; + this.minLayoutBoundsZ = Number.MAX_VALUE; + this.maxLayoutBoundsX = -Number.MAX_VALUE; + this.maxLayoutBoundsY = -Number.MAX_VALUE; + this.maxLayoutBoundsZ = -Number.MAX_VALUE; + let positionX, positionY, positionZ; + let sizeX, sizeY, sizeZ; + const lookup = buffer.lookup; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + const height = Math.max(options.heights ? options.heights[id] * heightScaling : heightScaling, minHeight); + positionX = options.positionsX ? options.positionsX[id] * positionScalingX : 0; + positionY = height / 2; + positionZ = options.positionsZ ? options.positionsZ[id] * positionScalingZ : 0; + this._positions[index * 3] = positionX; + this._positions[index * 3 + 1] = positionY; + this._positions[index * 3 + 2] = positionZ; + sizeX = (options.sizeX === undefined ? options.sizesX ? options.sizesX[id] : 1 : options.sizeX) * positionScalingX; + sizeY = Math.abs(height); + sizeZ = (options.sizeZ === undefined ? options.sizesZ ? options.sizesZ[id] : 1 : options.sizeZ) * positionScalingZ; + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, positionX - sizeX / 2); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, positionY - sizeY / 2); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, positionZ - sizeZ / 2); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, positionX + sizeX / 2); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, positionY + sizeY / 2); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, positionZ + sizeZ / 2); + this._sizes[index * 3] = Math.max(sizeX - paddingX, 0); + this._sizes[index * 3 + 1] = sizeY; + this._sizes[index * 3 + 2] = Math.max(sizeZ - paddingZ, 0); } + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - _updateTexture() { - if (this._imageData) this._texture = (0, _textureJs.TextureHelper).fromImage(this._gl, this._imageData, false, this._gl.LINEAR); - else this._texture = null; + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = this._sizes[index * 3] * this._boundsScaling; + _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; + _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + if (options.colors1) { + const color1 = (0, _mathJs.MathHelper).normalize(options.colors1[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color1); + } else (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } } -},{"../../helpers/texture.js":"bUBAh","../../atlas.js":"duwwc","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9ezMr":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Palette", ()=>Palette); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g6aRn":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _textureJs = require("../../helpers/texture.js"); -var _paletteJs = require("../../palette.js"); -class Palette extends (0, _paletteJs.PaletteBase) { - get texture() { - return this._texture; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cube", ()=>Cube); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class Cube extends (0, _layoutJs.LayoutBase) { + getPositionX(index) { + return this._positions[index * 3]; } - get defaultTexture() { - return this._defaultTexture; + getPositionY(index) { + return this._positions[index * 3 + 1]; } - initializeContext(core, gl) { - this._gl = gl; - this._defaultTexture = (0, _textureJs.TextureHelper).create(gl, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, gl.NEAREST, core.config.paletteColor); - this._updateTexture(); + getPositionZ(index) { + return this._positions[index * 3 + 2]; } - update() { - super.update(); - if (this._changed) { - this._changed = false; - this._updateTexture(); + layout(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const side = options.side === undefined ? Math.ceil(Math.cbrt(count)) : options.side; + if (!this._positions || this._positions.length < buffer.length * 3) this._positions = new Float32Array(buffer.length * 3); + this.minLayoutBoundsX = 0; + this.minLayoutBoundsY = 0; + this.minLayoutBoundsZ = 0; + this.maxLayoutBoundsX = 0; + this.maxLayoutBoundsY = 0; + this.maxLayoutBoundsZ = 0; + const lookup = buffer.lookup; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + const y = Math.floor(i / (side * side)); + const z = Math.floor((i - y * side * side) / side); + const x = i - y * side * side - z * side; + this._positions[index * 3] = x; + this._positions[index * 3 + 1] = y; + this._positions[index * 3 + 2] = z; + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, x); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, y); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, z); } + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - _updateTexture() { - if (this._colors) { - const colors = new Uint8Array(this._colors); - for(let i = 0; i < colors.length; i++)colors[i] = Math.pow(colors[i] / 0xff, 2.2) * 0xff; - this._texture = (0, _textureJs.TextureHelper).create(this._gl, this._colors.length / 4, 1, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.NEAREST, colors); - } else this._texture = null; + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const padding = options.padding === undefined ? 0 : options.padding; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + const scale = (0, _glMatrix.vec3).fromValues((1 - padding) * this._boundsScaling, (1 - padding) * this._boundsScaling, (1 - padding) * this._boundsScaling); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setScale(dataView, index, scale); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, (0, _constantsJs.Constants).QUAT_IDENTITY); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + _vec2[0] = color; + _vec2[1] = color; + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)} ms`); } } -},{"../../helpers/texture.js":"bUBAh","../../palette.js":"8zxgm","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"joCj5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Config", ()=>Config); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"a7d6z":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../../constants.js"); -var _angleJs = require("../../helpers/angle.js"); -var _rendererJs = require("../renderer.js"); -class Config extends (0, _rendererJs.RendererConfig) { - constructor(){ - super(); - this.reset(); - } - reset() { - this.specularIntensity = 0.15; - this.specularPower = 150; - this.lightPosition = (0, _glMatrix.vec3).fromValues(-0.5, 0.5, 0); - const _quat1 = (0, _glMatrix.quat).create(); - const _quat2 = (0, _glMatrix.quat).create(); - let angle = (0, _angleJs.AngleHelper).degreesToRadians(15); - (0, _glMatrix.quat).setAxisAngle(_quat1, (0, _constantsJs.Constants).VECTOR3_UNITX, angle); - (0, _glMatrix.quat).multiply(_quat2, _quat1, _quat2); - angle = (0, _angleJs.AngleHelper).degreesToRadians(-15); - (0, _glMatrix.quat).setAxisAngle(_quat1, (0, _constantsJs.Constants).VECTOR3_UNITY, angle); - (0, _glMatrix.quat).multiply(_quat2, _quat2, _quat1); - this.directionToLight = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).transformQuat(this.directionToLight, (0, _constantsJs.Constants).VECTOR3_UNITZ, _quat2); - this.halfAngle = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).add(this.halfAngle, (0, _constantsJs.Constants).VECTOR3_UNITZ, this.directionToLight); - (0, _glMatrix.vec3).normalize(this.halfAngle, this.halfAngle); - this.isFxaaEnabled = false; - } -} - -},{"gl-matrix":"9GjEQ","../../constants.js":"2Scl5","../../helpers/angle.js":"eKtPm","../renderer.js":"gKWdZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5rKvk":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Resources", ()=>Resources); -parcelHelpers.export(exports, "ShaderBase", ()=>ShaderBase); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _pathJs = require("../../../helpers/path.js"); -var _mainJs = require("../../../main.js"); -class Resources { - bindFramebuffer(framebuffer) { - if (this.framebuffer != framebuffer) { - this.framebuffer = framebuffer; - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer); - } - } - initializeContext(gl) { - this._gl = gl; - this.framebuffer = this._gl.createFramebuffer(); - this.ANGLE_instanced_arrays = gl.getExtension("ANGLE_instanced_arrays"); - this.OES_standard_derivatives = gl.getExtension("OES_standard_derivatives"); - this.EXT_frag_depth = gl.getExtension("EXT_frag_depth"); - this.WEBGL_lose_context = gl.getExtension("WEBGL_lose_context"); - } -} -Resources.glsl = { - "anaglyph.fragment.fx": '#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform vec4 uViewport;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nconst vec3 LEFT_MASK = vec3(1.0, 0.0, 0.0);\nconst vec3 RIGHT_MASK = vec3(0.0, 1.0, 1.0);\nvoid main() {\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec3 color = LEFT_MASK * dot(texture2D(uSampler1, texCoords).rgb, LUMINANCE);\ncolor += RIGHT_MASK * dot(texture2D(uSampler2, texCoords).rgb, LUMINANCE);\ngl_FragColor = vec4(color, 1.0);\n}\n', - "color.fragment.fx": '#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nvarying lowp vec3 vColor;\nvoid main(void)\n{\ngl_FragColor = vec4(pow(vColor, GAMMA), 1.0);\n}\n', - "color.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute lowp vec3 aColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nvarying lowp vec3 vColor;\nvoid main(void) {\ngl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aPosition, 1.0);\nvColor = aColor;\n}\n", - "lasso.fragment.fx": '#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform vec3 uColor;\nuniform vec2 uThickness;\nuniform float uDashWidth;\nvarying mediump vec2 vTexCoord;\nvoid main(void)\n{\nvec2 distance = min(vTexCoord, 1.0 - vTexCoord);\nif (distance.x > uThickness.x && distance.y > uThickness.y) {\ndiscard;\n}\nvec2 texCoord = vec2(vTexCoord.x, 1.0 - vTexCoord.y);\nvec2 thickness = uThickness * uDashWidth;\nvec2 b = mod(floor(texCoord / thickness), 2.0);\nif (b.x > 0.0 && texCoord.x < 1.0 - thickness.x) {\ndiscard;\n}\nif (b.y > 0.0 && texCoord.y < 1.0 - thickness.y) {\ndiscard;\n}\ngl_FragColor = vec4(pow(uColor, GAMMA), 1.0);\n}\n', - "lasso.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nvarying mediump vec2 vTexCoord;\nvoid main(void) {\ngl_Position = uMMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\n}\n", - "model.fragment.fx": '#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform sampler2D uSampler;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nvarying mediump vec3 vNormal;\nvarying mediump vec2 vTexCoord;\nvoid main(void)\n{\ngl_FragColor = vec4(pow(texture2D(uSampler, vTexCoord).xyz, GAMMA), 1.0);\nvec3 color = texture2D(uSampler, vTexCoord).xyz;\nfloat ambient = 0.01;\nvec3 normal = normalize(vNormal);\nfloat diffuse = 0.5 * max(dot(uDirectionToLight, normal), 0.0);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (ambient + diffuse);\ncolor += specular;\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n', - "model.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute mediump vec3 aNormal;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nvarying mediump vec3 vNormal;\nvarying mediump vec2 vTexCoord;\nvoid main(void) {\nvTexCoord = aTexCoord;\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = vec3(mvMatrix * vec4(aNormal, 0.0));\ngl_Position = uPMatrix * mvMatrix * vec4(aPosition, 1.0);\n}\n", - "pickgrid.fragment.fx": '#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\n#define Derivatives\nuniform bool uPick;\nuniform vec2 uFaceSize;\nuniform vec3 uMajorColor;\nuniform vec3 uMinorColor;\nuniform vec3 uZeroColor;\nuniform float uMajorThickness;\nuniform float uMinorThickness;\nuniform float uZeroThickness;\nuniform vec2 uZero;\nuniform vec2 uMinorGridlines;\nuniform vec3 uDirectionToLight;\nvarying lowp vec4 vColor;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec4 vBounds;\nvarying mediump vec3 vNormal;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void) {\nif (uPick)\n{\ngl_FragColor = vColor;\n}\nelse\n{\nvec2 buffer;\n#ifdef Derivatives\nbuffer = fwidth(vTexCoord);\n#else\nbuffer = vec2(0.002);\n#endif\nvec2 distance, thickness, step;\nvec4 color = vColor;\nvec2 width = vBounds.zw - vBounds.xy;\ndistance = (vTexCoord - vBounds.xy) / width;\ndistance = min(abs(distance - floor(uMinorGridlines * distance) / uMinorGridlines), abs(distance - ceil(uMinorGridlines * distance) / uMinorGridlines));\ndistance *= width;\nthickness = vec2(uMinorThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMinorColor, color.xyz, min(step.x, step.y));\nthickness = vec2(uMajorThickness) / uFaceSize;\ndistance = min(vTexCoord - vBounds.xy, vBounds.zw - vTexCoord);\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMajorColor, color.xyz, min(step.x, step.y));\ndistance = abs(vTexCoord - uZero);\nthickness = vec2(uZeroThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uZeroColor, color.xyz, min(step.x, step.y));\nfloat diffuse = 0.2 * max(dot(uDirectionToLight, vNormal), 0.0);\nfloat ambient = 0.8;\ncolor.xyz *= (ambient + diffuse);\ncolor.xyz = pow(color.xyz, GAMMA);\ngl_FragColor = color;\n}\n}\n', - "pickgrid.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute lowp vec4 aIdColor;\nattribute mediump vec2 aTexCoord;\nattribute mediump vec3 aNormal;\nattribute mediump vec4 aBounds;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform bool uPick;\nuniform vec4 uPickedIdColor;\nuniform vec3 uBackground;\nuniform vec3 uHighlight;\nvarying lowp vec4 vColor;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec4 vBounds;\nvarying mediump vec3 vNormal;\nvoid main(void) {\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize(vec3(mvMatrix * vec4(aNormal, 0.0)));\nvTexCoord = aTexCoord;\nvBounds = aBounds;\ngl_Position = uPMatrix * mvMatrix * vec4(aPosition, 1.0);\nif (uPick)\n{\nvColor = aIdColor;\n}\nelse\n{\nvColor = uPickedIdColor == aIdColor ? vec4(uHighlight, 1.0) : vColor = vec4(uBackground, 1.0);\n}\n}\n", - "sdftext.fragment.fx": '#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\n#define Derivatives\nuniform sampler2D uSampler;\nuniform bool uPick;\nuniform vec3 uColor;\nuniform vec3 uHoverColor;\nuniform float uGamma;\nuniform vec3 uBorderColor;\nuniform float uBuffer;\nuniform float uBorderWidth;\nvarying mediump vec2 vTexCoord;\nvarying lowp vec4 vIdColor;\nvarying lowp float vHover;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void) {\nif (uPick) {\ngl_FragColor = vIdColor;\n}\nelse {\nfloat distance = texture2D(uSampler, vTexCoord).r;\nif (distance < uBuffer - uBorderWidth) {\ndiscard;\n}\nfloat gamma;\n#ifdef Derivatives\ngamma = fwidth(distance);\n#else\ngamma = uGamma;\n#endif\nfloat value = smoothstep(uBuffer - gamma, uBuffer + gamma, distance);\ngl_FragColor = vec4(pow(mix(uBorderColor, mix(uColor, uHoverColor, vHover), value), GAMMA), 1.0);\n}\n}\n', - "sdftext.vertex.fx": "#version 100\nattribute lowp vec4 aIdColor;\nattribute vec3 aPosition;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform vec4 uPickedIdColor;\nvarying mediump vec2 vTexCoord;\nvarying lowp vec4 vIdColor;\nvarying lowp float vHover;\nvoid main(void) {\ngl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\nvIdColor = aIdColor;\nvHover = uPickedIdColor == aIdColor ? 1.0 : 0.0;\n}\n", - "simple.vertex.fx": "#version 100\nattribute vec3 aPosition;\nvoid main(void) {\ngl_Position = vec4(aPosition, 1.0);\n}\n", - "texture.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform bool uPick;\nvarying mediump vec2 vTexCoord;\nvoid main(void)\n{\nif (uPick) {\ngl_FragColor = vec4(0.0);\n}\nelse {\ngl_FragColor = vec4(texture2D(uSampler, vTexCoord).xyz, 1.0);\n}\n}\n", - "texture.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute mediump vec3 aNormal;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nvarying mediump vec3 vNormal;\nvarying mediump vec2 vTexCoord;\nvoid main(void) {\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize((mvMatrix * vec4(aNormal, 0.0)).xyz);\ngl_Position = uPMatrix * mvMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\n}\n", - "unitblock.fragment.fx": '#version 100\n#define Derivatives\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void)\n{\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat ambient = 0.01;\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nfloat diffuse, specular;\n#ifdef Derivatives\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\ndiffuse = dot(uDirectionToLight, normal);\nspecular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\n#else\ndiffuse = 1.0;\nspecular = 0.0;\n#endif\ncolor *= (ambient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n', - "unitblock.vertex.fx": '#version 100\n#include "quat.include.fx"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\ngl_Position = vec4(0.0);\n#ifdef Derivatives\nvViewPosition = vec3(0.0);\n#endif\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\n#ifdef Derivatives\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\n#else\ngl_Position = uPMatrix * mvMatrix * vec4(position, 1.0);\n#endif\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n', - "unitcylinder.fragment.fx": '#version 100\n#define FragDepth\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec4 vCircle1;\nvarying vec4 vCircle2;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\n#ifdef FragDepth\n#extension GL_EXT_frag_depth : enable\n#endif\nfloat dot2(in vec2 v) { return dot(v, v); }\nfloat dot2(in vec3 v) { return dot(v, v); }\nvec4 iCappedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(oa, ba);\nfloat m2 = dot(ob, ba);\nfloat m3 = dot(rd, ba);\nif (m1 < 0.0) { if (dot2(oa * m3 - rd * m1) < (ra * ra * m3 * m3)) return vec4(-m1 / m3, -ba * inversesqrt(m0)); }\nelse if (m2 > 0.0) { if (dot2(ob * m3 - rd * m2) < (rb * rb * m3 * m3)) return vec4(-m2 / m3, ba * inversesqrt(m0)); }\nfloat m4 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat rr = ra - rb;\nfloat hy = m0 + rr * rr;\nfloat k2 = m0 * m0 - m3 * m3 * hy;\nfloat k1 = m0 * m0 * m4 - m1 * m3 * hy + m0 * ra * (rr * m3 * 1.0);\nfloat k0 = m0 * m0 * m5 - m1 * m1 * hy + m0 * ra * (rr * m1 * 2.0 - m0 * ra);\nfloat h = k1 * k1 - k2 * k0;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-k1 - sqrt(h)) / k2;\nfloat y = m1 + t * m3;\nif (y > 0.0 && y < m0)\n{\nreturn vec4(t, normalize(m0 * (m0 * (oa + t * rd) + rr * ba * ra) - ba * hy * y));\n}\nreturn vec4(-1.0);\n}\nvec4 iRoundedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat rr = ra - rb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(ba, oa);\nfloat m2 = dot(ba, rd);\nfloat m3 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat m6 = dot(ob, rd);\nfloat m7 = dot(ob, ob);\nfloat d2 = m0 - rr * rr;\nfloat k2 = d2 - m2 * m2;\nfloat k1 = d2 * m3 - m1 * m2 + m2 * rr * ra;\nfloat k0 = d2 * m5 - m1 * m1 + m1 * rr * ra * 2.0 - m0 * ra * ra;\nfloat h = k1 * k1 - k0 * k2;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-sqrt(h) - k1) / k2;\nfloat y = m1 - ra * rr + t * m2;\nif (y > 0.0 && y < d2)\n{\nreturn vec4(t, normalize(d2 * (oa + t * rd) - ba * y));\n}\nfloat h1 = m3 * m3 - m5 + ra * ra;\nfloat h2 = m6 * m6 - m7 + rb * rb;\nif (max(h1, h2) < 0.0) return vec4(-1.0);\nvec4 r = vec4(1e20);\nif (h1 > 0.0)\n{\nt = -m3 - sqrt(h1);\nr = vec4(t, (oa + t * rd) / ra);\n}\nif (h2 > 0.0)\n{\nt = -m6 - sqrt(h2);\nif (t < r.x)\nr = vec4(t, (ob + t * rd) / rb);\n}\nreturn r;\n}\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 tnor = iCappedCone(ro, rd, vCircle1.xyz, vCircle2.xyz, vCircle1.w, vCircle2.w);\nfloat t = tnor.x;\nif (t < 0.0)\n{\ndiscard;\n}\nelse\n{\nvec3 viewPosition = rd * t;\n#ifdef FragDepth\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepthEXT = ndcDepth * 0.5 + 0.5;\n#endif\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat ambient = 0.01;\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = tnor.yzw;\nfloat diffuse = dot(uDirectionToLight, normal);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (ambient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n}\n', - "unitcylinder.vertex.fx": '#version 100\n#include "common.include.fx"\n#include "quat.include.fx"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nuniform vec3 uIdentityRotation;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec4 vCircle1;\nvarying vec4 vCircle2;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvCircle1 = vec4(0.0);\nvCircle2 = vec4(0.0);\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec3 viewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition;\nposition.xz *= max(scale.x, scale.z);\nposition.y *= scale.y;\nvec3 direction = IDENTITY_ROTATION;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\ndirection = rotate(direction, quat);\n}\nvec3 viewDirection = (mvMatrix * vec4(direction, 0.0)).xyz;\nvec3 h = viewDirection * scale.y * 0.5;\nfloat r1 = length(viewDirection) * 0.5;\nfloat r2 = r1 * scale.z;\nr1 *= scale.x;\nvCircle1 = vec4(viewCenter - h, r1);\nvCircle2 = vec4(viewCenter + h, r2);\nvec4 viewPosition = mvMatrix * vec4(position + translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n', - "unithexprism.fragment.fx": '#version 100\n#define FragDepth\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvarying float vRadius;\nvarying float vHeight;\nvarying float vScaling;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\nuniform mat4 uVMatrix;\n#ifdef FragDepth\n#extension GL_EXT_frag_depth : enable\n#endif\nvec4 iHexPrism( in vec3 ro, in vec3 rd, in float ra, in float he )\n{\nconst vec3 n1 = vec3( 1.0,0.0,0.0);\nconst vec3 n2 = vec3( 0.5,0.0,ROOT_THREE_OVER_TWO);\nconst vec3 n3 = vec3(-0.5,0.0,ROOT_THREE_OVER_TWO);\nconst vec3 n4 = vec3( 0.0,1.0,0.0);\nvec3 t1 = vec3((vec2(ra,-ra)-dot(ro,n1))/dot(rd,n1), 1.0);\nvec3 t2 = vec3((vec2(ra,-ra)-dot(ro,n2))/dot(rd,n2), 1.0);\nvec3 t3 = vec3((vec2(ra,-ra)-dot(ro,n3))/dot(rd,n3), 1.0);\nvec3 t4 = vec3((vec2(he,-he)-dot(ro,n4))/dot(rd,n4), 1.0);\nif( t1.y<t1.x ) t1=vec3(t1.yx,-1.0);\nif( t2.y<t2.x ) t2=vec3(t2.yx,-1.0);\nif( t3.y<t3.x ) t3=vec3(t3.yx,-1.0);\nif( t4.y<t4.x ) t4=vec3(t4.yx,-1.0);\nvec4 tN=vec4(t1.x,t1.z*n1);\nif( t2.x>tN.x ) tN=vec4(t2.x,t2.z*n2);\nif( t3.x>tN.x ) tN=vec4(t3.x,t3.z*n3);\nif( t4.x>tN.x ) tN=vec4(t4.x,t4.z*n4);\nfloat tF = min(min(t1.y,t2.y),min(t3.y,t4.y));\nif( tN.x>tF || tF<0.0) return vec4(-1.0);\nreturn tN;\n}\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = -vViewCenter;\nmat3 rot = mat3(uVMatrix);\nvec3 rdd = rd * rot;\nvec3 roo = ro * rot;\nvec4 tnor = iHexPrism(roo, rdd, vRadius * vScaling, vHeight * vScaling);\nfloat t = tnor.x;\nif (t < 0.0)\n{\ndiscard;\n}\nelse\n{\nvec3 viewPosition = rd * t;\n#ifdef FragDepth\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepthEXT = ndcDepth * 0.5 + 0.5;\n#endif\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat ambient = 0.01;\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = rot * tnor.yzw;\nfloat diffuse = dot(uDirectionToLight, normal);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (ambient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n}\n', - "unithexprism.vertex.fx": '#version 100\n#include "common.include.fx"\n#include "quat.include.fx"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nuniform vec3 uIdentityRotation;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvarying float vRadius;\nvarying float vHeight;\nvarying float vScaling;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvRadius = 0.0;\nvHeight = 0.0;\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvViewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvRadius = scale.x * ROOT_THREE_OVER_TWO;\nvHeight = scale.y;\nvec3 position = aPosition;\nposition.y *= scale.y;\nposition.z *= scale.x;\nposition.x *= scale.x * ROOT_THREE_OVER_TWO;\nvec3 direction = IDENTITY_ROTATION;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\ndirection = rotate(direction, quat);\n}\nvec3 viewDirection = (mvMatrix * vec4(direction, 0.0)).xyz;\nvec4 viewPosition = mvMatrix * vec4(position + translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvScaling = length(uMMatrix[0].xyz) / 2.0;\n}\n}\n', - "unitsdf.fragment.fx": '#version 100\n#define Derivatives\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec2 vPreviousTexCoord;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform sampler2D uSampler1;\nuniform sampler2D uPreviousSampler1;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\nuniform vec3 uBackgroundColor;\nuniform float uBuffer;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void) {\nfloat distance = mix(texture2D(uPreviousSampler1, vPreviousTexCoord).r, texture2D(uSampler1, vTexCoord).r, vAnimation);\nif (distance < uBuffer) {\ndiscard;\n}\nif (uPick) {\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat ambient = 0.01;\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nfloat diffuse, specular;\n#ifdef Derivatives\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\ndiffuse = dot(uDirectionToLight, normal);\nspecular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\n#else\ndiffuse = 1.0;\nspecular = 0.0;\n#endif\ncolor *= (ambient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\nfloat uGamma = 0.0;\nfloat gamma;\n#ifdef Derivatives\ngamma = fwidth(distance);\n#else\ngamma = uGamma;\n#endif\nfloat value = smoothstep(uBuffer + gamma, uBuffer, distance);\ngl_FragColor = vec4(mix(color, uBackgroundColor, value), 1.0);\n}\n}\n', - "unitsdf.vertex.fx": '#version 100\n#include "quat.include.fx"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute mediump vec4 aTexCoord;\nattribute mediump vec4 aPreviousTexCoord;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec2 vPreviousTexCoord;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\ngl_Position = vec4(0.0);\n#ifdef Derivatives\nvViewPosition = vec3(0.0);\n#endif\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\n#ifdef Derivatives\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\n#else\ngl_Position = uPMatrix * mvMatrix * vec4(position, 1.0);\n#endif\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvPreviousTexCoord.x = aPosition.x < 0.0 ? aPreviousTexCoord.x : aPreviousTexCoord.z;\nvPreviousTexCoord.y = aPosition.y > 0.0 ? aPreviousTexCoord.y : aPreviousTexCoord.w;\nvTexCoord.x = aPosition.x < 0.0 ? aTexCoord.x : aTexCoord.z;\nvTexCoord.y = aPosition.y > 0.0 ? aTexCoord.y : aTexCoord.w;\n}\n}\n', - "unitsphere.fragment.fx": '#version 100\n#define FragDepth\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvarying mediump float vRadius;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\n#ifdef FragDepth\n#extension GL_EXT_frag_depth : enable\n#endif\nfloat sphIntersect(in vec3 ro, in vec3 rd, in vec4 sph)\n{\nvec3 oc = ro - sph.xyz;\nfloat b = dot(oc, rd);\nfloat c = dot(oc, oc) - sph.w * sph.w;\nfloat h = b * b - c;\nif (h < 0.0) return -1.0;\nreturn -b - sqrt(h);\n}\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 s = vec4(vViewCenter, vRadius);\nfloat t = sphIntersect(ro, rd, s);\nif (t < 0.0)\n{\ndiscard;\n}\nelse\n{\nvec3 viewPosition = rd * t;\n#ifdef FragDepth\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepthEXT = ndcDepth * 0.5 + 0.5;\n#endif\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat ambient = 0.01;\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = (viewPosition - vViewCenter) / s.w;\nfloat diffuse = dot(uDirectionToLight, normal);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (ambient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n}\n', - "unitsphere.vertex.fx": '#version 100\n#include "common.include.fx"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute lowp float aColor;\nattribute lowp float aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying mediump float vRadius;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvViewCenter = vec3(0.0);\nvRadius = 0.0;\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nfloat scale = mix(min(aPreviousScale.x, min(aPreviousScale.y, aPreviousScale.z)), min(aScale.x, min(aScale.y, aScale.z)), animation);\nvec4 translation = vec4(mix(aPreviousTranslation, aTranslation, animation), 1.0);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvViewCenter = (mvMatrix * translation).xyz;\ntranslation.xyz += aPosition * scale;\nvViewPosition = (mvMatrix * translation).xyz;\ngl_Position = uPMatrix * vec4(vViewPosition, 1.0);\nvVertexColor = vec2(aColor, aPreviousColor);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvRadius = distance(vViewPosition, vViewCenter) / ROOT_THREE;\n}\n}\n', - "common.include.fx": "const float NEAR_PLANE = 0.01;\nconst float FAR_PLANE = 100.0;\nconst float DEPTH_A = 1.0002000200020003;\nconst float DEPTH_B = 0.020002000200020003;\nconst vec3 GAMMA = vec3(0.45454545454545453);\nconst vec3 INV_GAMMA = vec3(2.2);\nconst vec3 LUMINANCE = vec3(0.2126, 0.7152, 0.0722);\nconst float PI = 3.1415926538;\nconst float ROOT_TWO = 1.4142135624;\nconst float ROOT_TWO_OVER_TWO = 0.7071067811865476;\nconst float ROOT_THREE = 1.7320508075688772;\nconst float ROOT_THREE_OVER_TWO = 0.8660254037844386;\nconst vec3 IDENTITY_ROTATION = vec3(0.0, 1.0, 0.0);\nmat3 transpose(in mat3 mat) {\nvec3 i0 = mat[0];\nvec3 i1 = mat[1];\nvec3 i2 = mat[2];\nreturn mat3\n(\nvec3(i0.x, i1.x, i2.x),\nvec3(i0.y, i1.y, i2.y),\nvec3(i0.z, i1.z, i2.z)\n);\n}\n", - "quat.include.fx": "const float EPSILON = 0.000001;\nmat3 fromQuat(in vec4 q) {\nfloat x = q.x;\nfloat y = q.y;\nfloat z = q.z;\nfloat w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat yx = y * x2;\nfloat yy = y * y2;\nfloat zx = z * x2;\nfloat zy = z * y2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nmat3 m;\nm[0][0] = 1.0 - yy - zz;\nm[0][1] = yx - wz;\nm[0][2] = zx + wy;\nm[1][0] = yx + wz;\nm[1][1] = 1.0 - xx - zz;\nm[1][2] = zy - wx;\nm[2][0] = zx - wy;\nm[2][1] = zy + wx;\nm[2][2] = 1.0 - xx - yy;\nreturn m;\n}\nvec3 rotate(in vec3 p, in vec4 q) {\nreturn p + 2.0 * cross(q.xyz, cross(q.xyz, p) + q.w * p);\n}\nvec4 slerp(in vec4 a, in vec4 b, in float t) {\nfloat cosom = dot(a, b);\nif (cosom < 0.0) {\ncosom = -cosom;\nb = -b;\n}\nfloat scale0, scale1;\nif (1.0 - cosom > EPSILON) {\nfloat omega = acos(cosom);\nfloat sinom = sin(omega);\nscale0 = sin((1.0 - t) * omega) / sinom;\nscale1 = sin(t * omega) / sinom;\n}\nelse {\nscale0 = 1.0 - t;\nscale1 = t;\n}\nreturn vec4(scale0 * a + scale1 * b);\n}\n" -}; -class ShaderBase { - get isInitialized() { - return this._isInitialized; - } - get vertexBuffer() { - return this._vertexBuffer; - } - set vertexBuffer(value) { - if (this._vertexBuffer != value) { - this._vertexBuffer = value; - this._haveBuffersChanged = true; - } - } - get indexBuffer() { - return this._indexBuffer; - } - set indexBuffer(value) { - if (this._indexBuffer != value) { - this._indexBuffer = value; - this._haveBuffersChanged = true; +parcelHelpers.export(exports, "Line", ()=>Line); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class Line extends (0, _layoutJs.LayoutBase) { + layout(buffer, ids, fromIds, toIds, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const positionScalingX = options.positionScalingX === undefined ? 1 : options.positionScalingX; + const positionScalingY = options.positionScalingY === undefined ? 1 : options.positionScalingY; + const positionScalingZ = options.positionScalingZ === undefined ? 1 : options.positionScalingZ; + const sizeScalingX = options.sizeScaling === undefined ? options.sizeScalingX === undefined ? 1 : options.sizeScalingX : options.sizeScaling; + const sizeScalingY = options.sizeScaling === undefined ? options.sizeScalingY === undefined ? 1 : options.sizeScalingY : options.sizeScaling; + const sizeScalingZ = options.sizeScaling === undefined ? options.sizeScalingZ === undefined ? 1 : options.sizeScalingZ : options.sizeScaling; + const minSize = options.minSize === undefined ? 0 : options.minSize; + const offsetScaling = options.offsetScaling === undefined ? 1 : options.offsetScaling; + if (!this._positions || this._positions.length < buffer.length * 3) { + this._positions = new Float32Array(buffer.length * 3); + this._sizes = new Float32Array(buffer.length * 3); + this._rotations = new Float32Array(buffer.length * 4); } - } - constructor(core, main){ - this._core = core; - this._main = main; - } - initializeContext(gl) { - this._gl = gl; - } - _createProgram(vs, fs) { - const program = this._gl.createProgram(); - this._gl.attachShader(program, vs); - this._gl.attachShader(program, fs); - this._gl.linkProgram(program); - if (!this._gl.getProgramParameter(program, this._gl.LINK_STATUS)) this._core.log.write((0, _mainJs.LogLevel).error, this._gl.getProgramInfoLog(program)); - return program; - } - _compileShader(source, type) { - const shader = this._gl.createShader(type); - this._gl.shaderSource(shader, source); - this._gl.compileShader(shader); - if (!this._gl.getShaderParameter(shader, this._gl.COMPILE_STATUS)) this._core.log.write((0, _mainJs.LogLevel).error, this._gl.getShaderInfoLog(shader)); - return shader; - } - _removeDirective(shaderSource, directive) { - const remove = `#define ${directive}`; - const index = shaderSource.indexOf(remove); - shaderSource = index == -1 ? shaderSource : shaderSource.substring(0, index) + shaderSource.substring(index + remove.length); - return shaderSource; - } - prepare() { - if (this._program != this._main.shaderResources.currentProgram) { - if (this._main.shaderResources.currentShader) this._main.shaderResources.currentShader.disableProgram(); - this.enableProgram(this._program); - this.updateBuffers(); - this.updateTextures(); - } else { - if (this._haveBuffersChanged) this.updateBuffers(); - if (this._haveTexturesChanged) this.updateTextures(); + this.minLayoutBoundsX = Number.MAX_VALUE; + this.minLayoutBoundsY = Number.MAX_VALUE; + this.minLayoutBoundsZ = Number.MAX_VALUE; + this.maxLayoutBoundsX = -Number.MAX_VALUE; + this.maxLayoutBoundsY = -Number.MAX_VALUE; + this.maxLayoutBoundsZ = -Number.MAX_VALUE; + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const direction = (0, _glMatrix.vec3).create(); + const lookup = buffer.lookup; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const fromId = fromIds[id]; + const toId = toIds[id]; + const index = lookup[id]; + let toPositionX = options.positionsX ? options.positionsX[toId] * positionScalingX : 0; + let toPositionY = options.positionsY ? options.positionsY[toId] * positionScalingY : 0; + let toPositionZ = options.positionsZ ? options.positionsZ[toId] * positionScalingZ : 0; + let fromPositionX = options.positionsX ? options.positionsX[fromId] * positionScalingX : 0; + let fromPositionY = options.positionsY ? options.positionsY[fromId] * positionScalingY : 0; + let fromPositionZ = options.positionsZ ? options.positionsZ[fromId] * positionScalingZ : 0; + if (fromId == toId) { + this._sizes[index * 3] = 0; + this._sizes[index * 3 + 1] = 0; + this._sizes[index * 3 + 2] = 0; + this._rotations[index * 4] = 0; + this._rotations[index * 4 + 1] = 0; + this._rotations[index * 4 + 2] = 0; + this._rotations[index * 4 + 3] = 1; + } else { + direction[0] = toPositionX - fromPositionX; + direction[1] = toPositionY - fromPositionY; + direction[2] = toPositionZ - fromPositionZ; + let length = (0, _glMatrix.vec3).length(direction); + (0, _glMatrix.vec3).scale(direction, direction, 1 / length); + (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, direction); + this._rotations[index * 4] = _quat[0]; + this._rotations[index * 4 + 1] = _quat[1]; + this._rotations[index * 4 + 2] = _quat[2]; + this._rotations[index * 4 + 3] = _quat[3]; + if (options.offsets) { + const fromOffset = options.offsets[fromId] * offsetScaling / 2; + const toOffset = options.offsets[toId] * offsetScaling / 2; + toPositionX -= direction[0] * toOffset; + toPositionY -= direction[1] * toOffset; + toPositionZ -= direction[2] * toOffset; + fromPositionX += direction[0] * fromOffset; + fromPositionY += direction[1] * fromOffset; + fromPositionZ += direction[2] * fromOffset; + length = Math.max(length - toOffset - fromOffset, minSize); + } + this._sizes[index * 3 + 1] = Math.max(length * sizeScalingY, minSize); + if (options.lineSizes) { + this._sizes[index * 3] = Math.max(options.lineSizes[id] * sizeScalingX, minSize); + this._sizes[index * 3 + 2] = Math.max(options.lineSizes[id] * sizeScalingZ, minSize); + } else if (options.endSizes) { + this._sizes[index * 3] = Math.max(options.endSizes[fromId] * sizeScalingX, minSize); + this._sizes[index * 3 + 2] = Math.max(options.endSizes[toId] * sizeScalingZ, minSize); + } else { + this._sizes[index * 3] = sizeScalingX; + this._sizes[index * 3 + 2] = sizeScalingZ; + } + } + _vec3[0] = (fromPositionX + toPositionX) / 2; + _vec3[1] = (fromPositionY + toPositionY) / 2; + _vec3[2] = (fromPositionZ + toPositionZ) / 2; + this._positions[index * 3] = _vec3[0]; + this._positions[index * 3 + 1] = _vec3[1]; + this._positions[index * 3 + 2] = _vec3[2]; + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, fromPositionX); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, fromPositionY); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, fromPositionZ); + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, toPositionX); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, toPositionY); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, toPositionZ); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, fromPositionX); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, fromPositionY); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, fromPositionZ); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, toPositionX); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, toPositionY); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, toPositionZ); } + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - apply() {} - applyModel() {} - applyView() {} - enableProgram(program) { - this._gl.useProgram(program); - this._main.shaderResources.currentProgram = program; - this._main.shaderResources.currentShader = this; - } - updateBuffers() { - this._haveBuffersChanged = false; - } - updateTextures() { - this._haveTexturesChanged = false; - } - disableProgram() { - this._main.shaderResources.currentShader = null; - this._main.shaderResources.currentProgram = null; - } - _shaderFromFile(vsName, fsName, callback) { - callback(this._includesFromFile(Resources.glsl[vsName]), this._includesFromFile(Resources.glsl[fsName])); - } - _shaderFromUrl(vsName, fsName, callback) { - this._sourceFromUrl(vsName, (vsSource)=>{ - this._includesFromUrl(vsSource, 0, (vsIncSource)=>{ - this._sourceFromUrl(fsName, (fsSource)=>{ - this._includesFromUrl(fsSource, 0, (fsIncSource)=>{ - callback(vsIncSource, fsIncSource); - }); - }); - }); - }); - } - _sourceFromUrl(url, callback) { - const request = new XMLHttpRequest(); - request.open("GET", (0, _pathJs.PathHelper).combine(this._core.config.shaderPath, url)); - request.onreadystatechange = ()=>{ - if (request.readyState == XMLHttpRequest.DONE && request.status == 200) callback(request.responseText); - }; - request.send(); - } - _includesFromFile(source) { - let index = 0; - do { - index = source.indexOf("#include", index); - if (index != -1) { - const start = source.indexOf('"', index); - const end = source.indexOf('"', start + 1); - const name = source.substring(start + 1, end); - const inc = Resources.glsl[name]; - source = source.substring(0, index) + inc + source.substring(end + 1); + update(buffer, ids, fromIds, toIds, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const endMinColor = options.endMinColor === undefined ? 0 : options.endMinColor; + const endMaxColor = options.endMaxColor === undefined ? 1 : options.endMaxColor; + const lineMinColor = options.lineMinColor === undefined ? 0 : options.lineMinColor; + const lineMaxColor = options.lineMaxColor === undefined ? 1 : options.lineMaxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const fromId = fromIds[id]; + const toId = toIds[id]; + const index = lookup[id]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; } - }while (index != -1); - return source; - } - _includesFromUrl(source, index, callback) { - index = source.indexOf("#include", index); - if (index != -1) { - const start = source.indexOf('"', index); - const end = source.indexOf('"', start + 1); - const name = source.substring(start + 1, end); - this._sourceFromUrl((0, _pathJs.PathHelper).combine("inc", name), (include)=>{ - source = source.substring(0, index) + include + source.substring(end + 1); - this._includesFromUrl(source, index, callback); - }); - } else callback(source); + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = this._sizes[index * 3] * this._boundsScaling; + _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; + _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + _quat[0] = this._rotations[index * 4]; + _quat[1] = this._rotations[index * 4 + 1]; + _quat[2] = this._rotations[index * 4 + 2]; + _quat[3] = this._rotations[index * 4 + 3]; + if (reverseX) { + _quat[1] = -_quat[1]; + _quat[2] = -_quat[2]; + } + if (reverseY) { + _quat[0] = -_quat[0]; + _quat[2] = -_quat[2]; + } + if (reverseZ) { + _quat[0] = -_quat[0]; + _quat[1] = -_quat[1]; + } + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + let size; + if (options.endColors) { + size = 1 / (endMaxColor - endMinColor + 1); + const fromColor = (0, _mathJs.MathHelper).normalize(options.endColors[fromId], endMinColor, endMaxColor, size / 2, 1 - size / 2); + const toColor = (0, _mathJs.MathHelper).normalize(options.endColors[toId], endMinColor, endMaxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, fromColor, toColor); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else if (options.lineColors) { + size = 1 / (lineMaxColor - lineMinColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.lineColors[id], lineMinColor, lineMaxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } } -},{"../../../helpers/path.js":"dofsD","../../../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3UKx9":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Color", ()=>Color); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2Odry":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Color extends (0, _shaderJs.ShaderBase) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("color.vertex.fx", "color.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PythagorasTree", ()=>PythagorasTree); +parcelHelpers.export(exports, "Tree", ()=>Tree); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _angleJs = require("../helpers/angle.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class PythagorasTree extends (0, _layoutJs.LayoutBase) { + get levels() { + return this._levels; } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._colorAttribute = gl.getAttribLocation(this._program, "aColor"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._isInitialized = true; + get maxLevel() { + return this._maxLevel; } - apply() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + get volumes() { + return this._volumes; } - applyView() { - this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + constructor(core){ + super(core); + this._vec3 = (0, _glMatrix.vec3).create(); + this._quat = (0, _glMatrix.quat).create(); + this._parentRight = (0, _glMatrix.vec3).create(); + this._parentUp = (0, _glMatrix.vec3).create(); + this._parentForward = (0, _glMatrix.vec3).create(); + this._parentTranslation = (0, _glMatrix.vec3).create(); + this._parentScale = (0, _glMatrix.vec3).create(); + this._parentRotation = (0, _glMatrix.quat).create(); + this._parentTwist = (0, _glMatrix.quat).create(); + this._childRotation = (0, _glMatrix.quat).create(); } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionColorVertex).SIZE_BYTES, (0, _vertexJs.PositionColorVertex).POSITION_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.vertexAttribPointer(this._colorAttribute, 3, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.PositionColorVertex).SIZE_BYTES, (0, _vertexJs.PositionColorVertex).COLOR_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._colorAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + static calculateTotalVertices(level) { + return (2 << level) - 1; } -} - -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"caAA8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Texture", ()=>Texture); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Texture extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; + static calculateMaxLevel(vertices) { + return Math.ceil(Math.log2(vertices + 1)) - 1; } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; + layout(buffer, ids, options) { + const start = window.performance.now(); + const scalingX = options.scalingX === undefined ? 1 : options.scalingX; + const scalingY = options.scalingY === undefined ? 1 : options.scalingY; + const scalingZ = options.scalingZ === undefined ? 1 : options.scalingZ; + this._angle = options.angle === undefined ? (0, _angleJs.AngleHelper).degreesToRadians(45) : options.angle; + this._randomAngle = options.randomAngle === undefined ? 0 : options.randomAngle; + this._twist = options.twist === undefined ? 0 : options.twist; + this._randomTwist = options.randomTwist === undefined ? 0 : options.randomTwist; + if (!this._positions || this._positions.length < buffer.length * 3) { + this._positions = new Float64Array(buffer.length * 3); + this._sizes = new Float64Array(buffer.length * 3); + this._rotations = new Float64Array(buffer.length * 4); + this._levels = new Uint32Array(buffer.length); + this._volumes = new Float64Array(buffer.length); } + this._maxLevel = PythagorasTree.calculateMaxLevel(ids.length); + const lookup = buffer.lookup; + const id = ids[0]; + const index = lookup[id]; + this._levels[index] = 0; + this._positions[index * 3] = 0; + this._positions[index * 3 + 1] = 0; + this._positions[index * 3 + 2] = 0; + this.minLayoutBoundsX = 0; + this.minLayoutBoundsY = 0; + this.minLayoutBoundsZ = 0; + this.maxLayoutBoundsX = 0; + this.maxLayoutBoundsY = 0; + this.maxLayoutBoundsZ = 0; + this._rotations[index * 4] = 0; + this._rotations[index * 4 + 1] = 0; + this._rotations[index * 4 + 2] = 0; + this._rotations[index * 4 + 3] = 1; + this._sizes[index * 3] = scalingX; + this._sizes[index * 3 + 1] = scalingY; + this._sizes[index * 3 + 2] = scalingZ; + this._volumes[index] = scalingX * scalingY * scalingZ; + this._count = 1; + const pseudoRandom = new (0, _mathJs.PseudoRandom)(0); + this._branch(index, ids, lookup, pseudoRandom); + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("texture.vertex.fx", "texture.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); + update(buffer, ids, options) { + const start = window.performance.now(); + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const index = lookup[id]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; + if (reverseX) positionX = this.modelOriginX + this.modelOriginX - positionX; + if (reverseY) positionY = this.modelOriginY + this.modelOriginY - positionY; + if (reverseZ) positionZ = this.modelOriginZ + this.modelOriginZ - positionZ; + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = this._sizes[index * 3] * this._boundsScaling; + _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; + _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + _quat[0] = this._rotations[index * 4]; + _quat[1] = this._rotations[index * 4 + 1]; + _quat[2] = this._rotations[index * 4 + 2]; + _quat[3] = this._rotations[index * 4 + 3]; + if (reverseX) { + _quat[1] = -_quat[1]; + _quat[2] = -_quat[2]; + } + if (reverseY) { + _quat[0] = -_quat[0]; + _quat[2] = -_quat[2]; + } + if (reverseZ) { + _quat[0] = -_quat[0]; + _quat[1] = -_quat[1]; + } + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = i / (ids.length - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = i / (ids.length - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); - this._normalAttribute = gl.getAttribLocation(this._program, "aNormal"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._pickUniform = gl.getUniformLocation(this._program, "uPick"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._isInitialized = true; + _branch(parentIndex, ids, lookup, pseudoRandom) { + const parentLevel = this._levels[parentIndex]; + if (parentLevel < this._maxLevel && this._count < ids.length) { + let angle = this._angle + (pseudoRandom.nextFloat() * 2 - 1) * this._randomAngle; + let twist = this._twist + (pseudoRandom.nextFloat() * 2 - 1) * this._randomTwist; + angle = (0, _mathJs.MathHelper).clamp(angle, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); + twist = (0, _mathJs.MathHelper).clamp(twist, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); + this._parentTranslation[0] = this._positions[parentIndex * 3]; + this._parentTranslation[1] = this._positions[parentIndex * 3 + 1]; + this._parentTranslation[2] = this._positions[parentIndex * 3 + 2]; + this._parentRotation[0] = this._rotations[parentIndex * 4]; + this._parentRotation[1] = this._rotations[parentIndex * 4 + 1]; + this._parentRotation[2] = this._rotations[parentIndex * 4 + 2]; + this._parentRotation[3] = this._rotations[parentIndex * 4 + 3]; + this._parentScale[0] = this._sizes[parentIndex * 3]; + this._parentScale[1] = this._sizes[parentIndex * 3 + 1]; + this._parentScale[2] = this._sizes[parentIndex * 3 + 2]; + (0, _glMatrix.vec3).transformQuat(this._parentUp, (0, _constantsJs.Constants).VECTOR3_UNITY, this._parentRotation); + (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentUp, twist); + (0, _glMatrix.quat).normalize(this._quat, this._quat); + (0, _glMatrix.quat).multiply(this._parentTwist, this._quat, this._parentRotation); + (0, _glMatrix.vec3).transformQuat(this._parentRight, (0, _constantsJs.Constants).VECTOR3_UNITX, this._parentTwist); + (0, _glMatrix.vec3).transformQuat(this._parentForward, (0, _constantsJs.Constants).VECTOR3_UNITZ, this._parentTwist); + const childId1 = ids[this._count++]; + const childIndex1 = lookup[childId1]; + let cos = Math.cos(angle); + this._sizes[childIndex1 * 3] = this._parentScale[0] * cos; + this._sizes[childIndex1 * 3 + 1] = this._parentScale[1] * cos; + this._sizes[childIndex1 * 3 + 2] = this._parentScale[2] * cos; + (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentForward, angle); + (0, _glMatrix.quat).normalize(this._quat, this._quat); + (0, _glMatrix.quat).multiply(this._childRotation, this._quat, this._parentTwist); + this._rotations[childIndex1 * 4] = this._childRotation[0]; + this._rotations[childIndex1 * 4 + 1] = this._childRotation[1]; + this._rotations[childIndex1 * 4 + 2] = this._childRotation[2]; + this._rotations[childIndex1 * 4 + 3] = this._childRotation[3]; + const halfparentScaleX = this._parentScale[0] * 0.5; + const halfparentScaleY = this._parentScale[1] * 0.5; + this._vec3[0] = this._parentUp[0] * halfparentScaleY * cos + this._parentRight[0] * halfparentScaleX * cos; + this._vec3[1] = this._parentUp[1] * halfparentScaleY * cos + this._parentRight[1] * halfparentScaleX * cos; + this._vec3[2] = this._parentUp[2] * halfparentScaleY * cos + this._parentRight[2] * halfparentScaleX * cos; + (0, _glMatrix.vec3).transformQuat(this._vec3, this._vec3, this._quat); + const childTranslationX = this._parentTranslation[0] + this._vec3[0] + this._parentUp[0] * halfparentScaleY - this._parentRight[0] * halfparentScaleX; + const childTranslationY = this._parentTranslation[1] + this._vec3[1] + this._parentUp[1] * halfparentScaleY - this._parentRight[1] * halfparentScaleX; + const childTranslationZ = this._parentTranslation[2] + this._vec3[2] + this._parentUp[2] * halfparentScaleY - this._parentRight[2] * halfparentScaleX; + this._positions[childIndex1 * 3] = childTranslationX; + this._positions[childIndex1 * 3 + 1] = childTranslationY; + this._positions[childIndex1 * 3 + 2] = childTranslationZ; + this._levels[childIndex1] = parentLevel + 1; + this._volumes[childIndex1] = this._sizes[childIndex1 * 3] * this._sizes[childIndex1 * 3 + 1] * this._sizes[childIndex1 * 3 + 2]; + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, childTranslationX); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, childTranslationY); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, childTranslationZ); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, childTranslationX); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, childTranslationY); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, childTranslationZ); + if (this._count < ids.length) { + const childId2 = ids[this._count++]; + const childIndex2 = lookup[childId2]; + cos = Math.cos((0, _constantsJs.Constants).PI_OVER_TWO - angle); + this._sizes[childIndex2 * 3] = this._parentScale[0] * cos; + this._sizes[childIndex2 * 3 + 1] = this._parentScale[1] * cos; + this._sizes[childIndex2 * 3 + 2] = this._parentScale[2] * cos; + (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentForward, angle - (0, _constantsJs.Constants).PI_OVER_TWO); + (0, _glMatrix.quat).normalize(this._quat, this._quat); + (0, _glMatrix.quat).multiply(this._childRotation, this._quat, this._parentTwist); + this._rotations[childIndex2 * 4] = this._childRotation[0]; + this._rotations[childIndex2 * 4 + 1] = this._childRotation[1]; + this._rotations[childIndex2 * 4 + 2] = this._childRotation[2]; + this._rotations[childIndex2 * 4 + 3] = this._childRotation[3]; + this._vec3[0] = this._parentUp[0] * halfparentScaleY * cos - this._parentRight[0] * halfparentScaleX * cos; + this._vec3[1] = this._parentUp[1] * halfparentScaleY * cos - this._parentRight[1] * halfparentScaleX * cos; + this._vec3[2] = this._parentUp[2] * halfparentScaleY * cos - this._parentRight[2] * halfparentScaleX * cos; + (0, _glMatrix.vec3).transformQuat(this._vec3, this._vec3, this._quat); + const childTranslationX = this._parentTranslation[0] + this._vec3[0] + this._parentUp[0] * halfparentScaleY + this._parentRight[0] * halfparentScaleX; + const childTranslationY = this._parentTranslation[1] + this._vec3[1] + this._parentUp[1] * halfparentScaleY + this._parentRight[1] * halfparentScaleX; + const childTranslationZ = this._parentTranslation[2] + this._vec3[2] + this._parentUp[2] * halfparentScaleY + this._parentRight[2] * halfparentScaleX; + this._positions[childIndex2 * 3] = childTranslationX; + this._positions[childIndex2 * 3 + 1] = childTranslationY; + this._positions[childIndex2 * 3 + 2] = childTranslationZ; + this._levels[childIndex2] = parentLevel + 1; + this._volumes[childIndex2] = this._sizes[childIndex2 * 3] * this._sizes[childIndex2 * 3 + 1] * this._sizes[childIndex2 * 3 + 2]; + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, childTranslationX); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, childTranslationY); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, childTranslationZ); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, childTranslationX); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, childTranslationY); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, childTranslationZ); + this._branch(childIndex1, ids, lookup, pseudoRandom); + this._branch(childIndex2, ids, lookup, pseudoRandom); + } + } } - apply() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); - this._gl.uniform1i(this._samplerUniform, 0); +} +class Tree extends (0, _layoutJs.LayoutBase) { + getPositionX(index) { + return this._positions[index * 3]; } - applyView() { - this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); - this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + getPositionY(index) { + return this._positions[index * 3 + 1]; } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).POSITION_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.vertexAttribPointer(this._normalAttribute, 3, this._gl.BYTE, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).NORMAL_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._normalAttribute); - this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).TEX_COORD_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._texCoordAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + getPositionZ(index) { + return this._positions[index * 3 + 2]; } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + getSizeX(index) { + return this._sizes[index * 3]; } -} - -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lw4z7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Lasso", ()=>Lasso); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Lasso extends (0, _shaderJs.ShaderBase) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("lasso.vertex.fx", "lasso.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); + getSizeY(index) { + return this._sizes[index * 3 + 1]; } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._colorUniform = gl.getUniformLocation(this._program, "uColor"); - this._thicknessUniform = gl.getUniformLocation(this._program, "uThickness"); - this._dashWidthUniform = gl.getUniformLocation(this._program, "uDashWidth"); - this._isInitialized = true; + getSizeZ(index) { + return this._sizes[index * 3 + 2]; } - apply() { - this._gl.uniform3fv(this._colorUniform, this.color); - this._gl.uniform1f(this._dashWidthUniform, this.dashWidth); + constructor(core){ + super(core); + this._vec3 = (0, _glMatrix.vec3).create(); + this._quat = (0, _glMatrix.quat).create(); + this._childRotation = (0, _glMatrix.quat).create(); + this._parentRight = (0, _glMatrix.vec3).create(); + this._parentUp = (0, _glMatrix.vec3).create(); + this._parentForward = (0, _glMatrix.vec3).create(); + this._parentRotation = (0, _glMatrix.quat).create(); + this._parentTwist = (0, _glMatrix.quat).create(); } - applyView() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); - this._gl.uniform2fv(this._thicknessUniform, this.thickness); + layout(buffer, ids, options) { + const start = window.performance.now(); + const rootId = options.rootId; + this._sizeX = options.sizeX === undefined ? 1 : options.sizeX; + this._sizeY = options.sizeY === undefined ? 1 : options.sizeY; + this._sizeZ = options.sizeZ === undefined ? 1 : options.sizeZ; + this._angle = options.angle === undefined ? (0, _angleJs.AngleHelper).degreesToRadians(45) : options.angle; + this._randomAngle = options.randomAngle === undefined ? 0 : options.randomAngle; + this._twist = options.twist === undefined ? 0 : options.twist; + this._lengthScaling = options.lengthScaling === undefined ? 1 : options.lengthScaling; + this._thicknessScaling = options.thicknessScaling === undefined ? 1 : options.thicknessScaling; + this._randomTwist = options.randomTwist === undefined ? 0 : options.randomTwist; + this._randomSplit = options.randomSplit === undefined ? 0 : options.randomSplit; + this._randomLengthScaling = options.randomLengthScaling === undefined ? 0 : options.randomLengthScaling; + this._randomThicknessScaling = options.randomThicknessScaling === undefined ? 0 : options.randomThicknessScaling; + this._minLength = options.minLength === undefined ? 0 : options.minLength; + this._minThickness = options.minThickness === undefined ? 0 : options.minThickness; + this._lengthScalings = options.lengthScalings; + this._thicknessScalings = options.thicknessScalings; + this._splitAngles = options.splitAngles; + this._angles = options.angles; + if (!this._positions || this._positions.length < buffer.length * 3) { + this._positions = new Float64Array(buffer.length * 3); + this._sizes = new Float64Array(buffer.length * 3); + this._rotations = new Float64Array(buffer.length * 4); + this._parentRights = new Float64Array(buffer.length * 3); + this._parentUps = new Float64Array(buffer.length * 3); + this._parentForwards = new Float64Array(buffer.length * 3); + this._parentTwists = new Float64Array(buffer.length * 4); + } + const lookup = buffer.lookup; + const indices = {}; + const children = {}; + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const index = lookup[id]; + const parentId = options.parentIds[index]; + const childId = options.childIds[index]; + indices[childId] = index; + if (childId === rootId) children[rootId] = []; + else { + if (children[parentId] === undefined) children[parentId] = []; + children[parentId].push(childId); + } + } + const index = indices[rootId]; + this._positions[index * 3] = 0; + this._positions[index * 3 + 1] = 0; + this._positions[index * 3 + 2] = 0; + this.minLayoutBoundsX = 0; + this.minLayoutBoundsY = 0; + this.minLayoutBoundsZ = 0; + this.maxLayoutBoundsX = 0; + this.maxLayoutBoundsY = 0; + this.maxLayoutBoundsZ = 0; + this._rotations[index * 4] = 0; + this._rotations[index * 4 + 1] = 0; + this._rotations[index * 4 + 2] = 0; + this._rotations[index * 4 + 3] = 1; + this._sizes[index * 3 + 1] = this._sizeY; + this._sizes[index * 3] = this._sizeX; + this._sizes[index * 3 + 2] = this._sizeZ; + if (this._lengthScalings) { + this._lengthScaling = this._lengthScalings[index]; + this._sizes[index * 3 + 1] *= this._lengthScaling; + } + if (this._thicknessScalings) { + this._thicknessScaling = this._thicknessScalings[index]; + this._sizes[index * 3] *= this._thicknessScaling; + this._sizes[index * 3 + 2] *= this._thicknessScaling; + } + const pseudoRandom = new (0, _mathJs.PseudoRandom)(0); + this._branch(rootId, indices, children, pseudoRandom); + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionTextureVertex).POSITION_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionTextureVertex).TEX_COORD_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._texCoordAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + update(buffer, ids, options) { + const start = window.performance.now(); + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < ids.length; i++){ + const id = ids[i]; + const index = lookup[id]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; + if (reverseX) positionX = this.modelOriginX + this.modelOriginX - positionX; + if (reverseY) positionY = this.modelOriginY + this.modelOriginY - positionY; + if (reverseZ) positionZ = this.modelOriginZ + this.modelOriginZ - positionZ; + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = this._sizes[index * 3] * this._boundsScaling; + _vec3[1] = this._sizes[index * 3 + 1] * this._boundsScaling; + _vec3[2] = this._sizes[index * 3 + 2] * this._boundsScaling; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + _quat[0] = this._rotations[index * 4]; + _quat[1] = this._rotations[index * 4 + 1]; + _quat[2] = this._rotations[index * 4 + 2]; + _quat[3] = this._rotations[index * 4 + 3]; + if (reverseX) { + _quat[1] = -_quat[1]; + _quat[2] = -_quat[2]; + } + if (reverseY) { + _quat[0] = -_quat[0]; + _quat[2] = -_quat[2]; + } + if (reverseZ) { + _quat[0] = -_quat[0]; + _quat[1] = -_quat[1]; + } + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = i / (ids.length - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = i / (ids.length - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${ids.length} vertices ${Math.round(window.performance.now() - start)}ms`); + } + _branch(parentId, indices, children, pseudoRandom) { + const childIds = children[parentId]; + const parentIndex = indices[parentId]; + this._parentRotation[0] = this._rotations[parentIndex * 4]; + this._parentRotation[1] = this._rotations[parentIndex * 4 + 1]; + this._parentRotation[2] = this._rotations[parentIndex * 4 + 2]; + this._parentRotation[3] = this._rotations[parentIndex * 4 + 3]; + (0, _glMatrix.vec3).transformQuat(this._parentUp, (0, _constantsJs.Constants).VECTOR3_UNITY, this._parentRotation); + this._parentUps[parentIndex * 3] = this._parentUp[0]; + this._parentUps[parentIndex * 3 + 1] = this._parentUp[1]; + this._parentUps[parentIndex * 3 + 2] = this._parentUp[2]; + let twist = this._twist + (pseudoRandom.nextFloat() * 2 - 1) * this._randomTwist; + twist = (0, _mathJs.MathHelper).clamp(twist, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); + (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentUp, twist); + (0, _glMatrix.quat).normalize(this._quat, this._quat); + (0, _glMatrix.quat).multiply(this._parentTwist, this._quat, this._parentRotation); + this._parentTwists[parentIndex * 4] = this._parentTwist[0]; + this._parentTwists[parentIndex * 4 + 1] = this._parentTwist[1]; + this._parentTwists[parentIndex * 4 + 2] = this._parentTwist[2]; + this._parentTwists[parentIndex * 4 + 3] = this._parentTwist[3]; + (0, _glMatrix.vec3).transformQuat(this._parentRight, (0, _constantsJs.Constants).VECTOR3_UNITX, this._parentTwist); + this._parentRights[parentIndex * 3] = this._parentRight[0]; + this._parentRights[parentIndex * 3 + 1] = this._parentRight[1]; + this._parentRights[parentIndex * 3 + 2] = this._parentRight[2]; + (0, _glMatrix.vec3).transformQuat(this._parentForward, (0, _constantsJs.Constants).VECTOR3_UNITZ, this._parentTwist); + this._parentForwards[parentIndex * 3] = this._parentForward[0]; + this._parentForwards[parentIndex * 3 + 1] = this._parentForward[1]; + this._parentForwards[parentIndex * 3 + 2] = this._parentForward[2]; + for(let i = 0; i < childIds.length; i++){ + const childId = childIds[i]; + const childIndex = indices[childId]; + const parentScaleX = this._sizes[parentIndex * 3]; + const parentScaleY = this._sizes[parentIndex * 3 + 1]; + const parentScaleZ = this._sizes[parentIndex * 3 + 2]; + this._parentUp[0] = this._parentUps[parentIndex * 3]; + this._parentUp[1] = this._parentUps[parentIndex * 3 + 1]; + this._parentUp[2] = this._parentUps[parentIndex * 3 + 2]; + this._parentTwist[0] = this._parentTwists[parentIndex * 4]; + this._parentTwist[1] = this._parentTwists[parentIndex * 4 + 1]; + this._parentTwist[2] = this._parentTwists[parentIndex * 4 + 2]; + this._parentTwist[3] = this._parentTwists[parentIndex * 4 + 3]; + if (this._lengthScalings) { + const lengthScale = this._lengthScalings[childIndex] + (pseudoRandom.nextFloat() * 2 - 1) * this._randomLengthScaling; + this._sizes[childIndex * 3 + 1] = Math.max(this._sizeY * lengthScale, this._minLength); + } else { + const lengthScale = this._lengthScaling + (pseudoRandom.nextFloat() * 2 - 1) * this._randomLengthScaling; + this._sizes[childIndex * 3 + 1] = Math.max(parentScaleY * lengthScale, this._minLength); + } + if (this._thicknessScalings) { + const thicknessScale = this._thicknessScalings[childIndex] + (pseudoRandom.nextFloat() * 2 - 1) * this._randomThicknessScaling; + this._sizes[childIndex * 3] = Math.max(this._sizeX * thicknessScale, this._minThickness); + this._sizes[childIndex * 3 + 2] = Math.max(this._sizeZ * thicknessScale, this._minThickness); + } else { + const thicknessScale = this._thicknessScaling + (pseudoRandom.nextFloat() * 2 - 1) * this._randomThicknessScaling; + this._sizes[childIndex * 3] = Math.max(parentScaleX * thicknessScale, this._minThickness); + this._sizes[childIndex * 3 + 2] = Math.max(parentScaleZ * thicknessScale, this._minThickness); + } + let split; + if (this._splitAngles) split = this._splitAngles[childIndex]; + else split = (0, _constantsJs.Constants).TWO_PI * i / childIds.length; + split += (pseudoRandom.nextFloat() * 2 - 1) * this._randomSplit; + (0, _glMatrix.quat).setAxisAngle(this._quat, this._parentUp, split); + (0, _glMatrix.quat).normalize(this._quat, this._quat); + (0, _glMatrix.quat).multiply(this._childRotation, this._quat, this._parentTwist); + let angle; + if (this._angles) angle = this._angles[childIndex]; + else angle = this._angle; + angle += (pseudoRandom.nextFloat() * 2 - 1) * this._randomAngle; + angle = (0, _mathJs.MathHelper).clamp(angle, -(0, _constantsJs.Constants).PI_OVER_TWO, (0, _constantsJs.Constants).PI_OVER_TWO); + (0, _glMatrix.quat).setAxisAngle(this._quat, (0, _constantsJs.Constants).VECTOR3_UNITX, angle); + (0, _glMatrix.quat).normalize(this._quat, this._quat); + (0, _glMatrix.quat).multiply(this._childRotation, this._childRotation, this._quat); + this._rotations[childIndex * 4] = this._childRotation[0]; + this._rotations[childIndex * 4 + 1] = this._childRotation[1]; + this._rotations[childIndex * 4 + 2] = this._childRotation[2]; + this._rotations[childIndex * 4 + 3] = this._childRotation[3]; + const halfParentScaleY = parentScaleY * 0.5; + const halfChildScaleY = this._sizes[childIndex * 3 + 1] * 0.5; + (0, _glMatrix.vec3).transformQuat(this._vec3, (0, _constantsJs.Constants).VECTOR3_UNITY, this._childRotation); + const childTranslationX = this._positions[parentIndex * 3] + this._parentUp[0] * halfParentScaleY + this._vec3[0] * halfChildScaleY; + const childTranslationY = this._positions[parentIndex * 3 + 1] + this._parentUp[1] * halfParentScaleY + this._vec3[1] * halfChildScaleY; + const childTranslationZ = this._positions[parentIndex * 3 + 2] + this._parentUp[2] * halfParentScaleY + this._vec3[2] * halfChildScaleY; + this._positions[childIndex * 3] = childTranslationX; + this._positions[childIndex * 3 + 1] = childTranslationY; + this._positions[childIndex * 3 + 2] = childTranslationZ; + this.minLayoutBoundsX = Math.min(this.minLayoutBoundsX, childTranslationX); + this.minLayoutBoundsY = Math.min(this.minLayoutBoundsY, childTranslationY); + this.minLayoutBoundsZ = Math.min(this.minLayoutBoundsZ, childTranslationZ); + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, childTranslationX); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, childTranslationY); + this.maxLayoutBoundsZ = Math.max(this.maxLayoutBoundsZ, childTranslationZ); + if (children[childId]) this._branch(childId, indices, children, pseudoRandom); + } } } -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jDhUl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Model", ()=>Model); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/angle.js":"53hwW","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fGQjs":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Model extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; - } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; - } - } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("model.vertex.fx", "model.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); - this._normalAttribute = gl.getAttribLocation(this._program, "aNormal"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._directionToLightUniform = gl.getUniformLocation(this._program, "uDirectionToLight"); - this._halfAngleUniform = gl.getUniformLocation(this._program, "uHalfAngle"); - this._specularPowerUniform = gl.getUniformLocation(this._program, "uSpecularPower"); - this._specularIntensityUniform = gl.getUniformLocation(this._program, "uSpecularIntensity"); - this._isInitialized = true; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Sheet", ()=>Sheet); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class Sheet extends (0, _layoutJs.LayoutBase) { + getPositionX(index) { + return this._positions[index * 3]; } - apply() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); - this._gl.uniform1i(this._samplerUniform, 0); - this._gl.uniform1f(this._specularPowerUniform, this.specularPower); - this._gl.uniform1f(this._specularIntensityUniform, this.specularIntensity); + getPositionY(index) { + return this._positions[index * 3 + 1]; } - applyView() { - this._gl.uniform3fv(this._directionToLightUniform, this.directionToLight); - this._gl.uniform3fv(this._halfAngleUniform, this.halfAngle); - this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + getPositionZ(index) { + return this._positions[index * 3 + 2]; } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).POSITION_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.vertexAttribPointer(this._normalAttribute, 3, this._gl.BYTE, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).NORMAL_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._normalAttribute); - this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).TEX_COORD_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._texCoordAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); - } -} - -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dbvo6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SdfText", ()=>SdfText); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class SdfText extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; - } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; + layout(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const side = options.side === undefined ? Math.ceil(Math.sqrt(count)) : options.side; + if (!this._positions || this._positions.length < buffer.length * 3) this._positions = new Float32Array(buffer.length * 3); + this.minLayoutBoundsX = 0; + this.minLayoutBoundsY = 0; + this.minLayoutBoundsZ = 0; + this.maxLayoutBoundsX = 0; + this.maxLayoutBoundsY = 0; + this.maxLayoutBoundsZ = 0; + const lookup = buffer.lookup; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + const y = Math.floor(i / side); + const x = i - y * side; + this._positions[index * 3] = x; + this._positions[index * 3 + 1] = y; + this._positions[index * 3 + 2] = 0; + this.maxLayoutBoundsX = Math.max(this.maxLayoutBoundsX, x); + this.maxLayoutBoundsY = Math.max(this.maxLayoutBoundsY, y); } + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("sdftext.vertex.fx", "sdftext.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.OES_standard_derivatives == null) fsSource = this._removeDirective(fsSource, "Derivatives"); - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._idColorAttribute = gl.getAttribLocation(this._program, "aIdColor"); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._colorUniform = gl.getUniformLocation(this._program, "uColor"); - this._hoverColorUniform = gl.getUniformLocation(this._program, "uHoverColor"); - this._pickUniform = gl.getUniformLocation(this._program, "uPick"); - this._pickedIdColorUniform = gl.getUniformLocation(this._program, "uPickedIdColor"); - this._borderColorUniform = gl.getUniformLocation(this._program, "uBorderColor"); - this._bufferUniform = gl.getUniformLocation(this._program, "uBuffer"); - this._borderWidthUniform = gl.getUniformLocation(this._program, "uBorderWidth"); - this._gammaUniform = gl.getUniformLocation(this._program, "uGamma"); - this._isInitialized = true; - } - apply() { - this._gl.uniform1i(this._samplerUniform, 0); - this._gl.uniform3fv(this._colorUniform, this.color); - this._gl.uniform3fv(this._hoverColorUniform, this.hoverColor); - this._gl.uniform3fv(this._borderColorUniform, this.borderColor); - this._gl.uniform1f(this._gammaUniform, this.gamma); - this._gl.uniform1f(this._bufferUniform, this.buffer); - this._gl.uniform1f(this._borderWidthUniform, this.borderWidth); - this._gl.uniform4fv(this._pickedIdColorUniform, this.pickedIdColor); - } - applyModel() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); - } - applyView() { - this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); - this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES, (0, _vertexJs.PositionTexturePickVertex).ID_COLOR_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._idColorAttribute); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES, (0, _vertexJs.PositionTexturePickVertex).POSITION_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES, (0, _vertexJs.PositionTexturePickVertex).TEX_COORD_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._texCoordAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const padding = options.padding === undefined ? 0 : options.padding; + const thickness = options.thickness === undefined ? 1 : options.thickness; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + const scale = (0, _glMatrix.vec3).fromValues((1 - padding) * this._boundsScaling, (1 - padding) * this._boundsScaling, thickness * this._boundsScaling); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + let positionX = this._positions[index * 3]; + let positionY = this._positions[index * 3 + 1]; + let positionZ = this._positions[index * 3 + 2]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setScale(dataView, index, scale); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, (0, _constantsJs.Constants).QUAT_IDENTITY); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)} ms`); } } -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3RavI":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "PickGrid", ()=>PickGrid); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1HzJp":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class PickGrid extends (0, _shaderJs.ShaderBase) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("pickgrid.vertex.fx", "pickgrid.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.OES_standard_derivatives == null) fsSource = this._removeDirective(fsSource, "Derivatives"); - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = this._gl.getAttribLocation(this._program, "aPosition"); - this._idColorAttribute = this._gl.getAttribLocation(this._program, "aIdColor"); - this._texCoordAttribute = this._gl.getAttribLocation(this._program, "aTexCoord"); - this._normalAttribute = this._gl.getAttribLocation(this._program, "aNormal"); - this._boundsAttribute = this._gl.getAttribLocation(this._program, "aBounds"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); - this._pickUniform = gl.getUniformLocation(this._program, "uPick"); - this._majorColorUniform = gl.getUniformLocation(this._program, "uMajorColor"); - this._minorColorUniform = gl.getUniformLocation(this._program, "uMinorColor"); - this._zeroColorUniform = gl.getUniformLocation(this._program, "uZeroColor"); - this._backgroundUniform = gl.getUniformLocation(this._program, "uBackground"); - this._highlightUniform = gl.getUniformLocation(this._program, "uHighlight"); - this._pickedIdColorUniform = gl.getUniformLocation(this._program, "uPickedIdColor"); - this._faceSizeUniform = gl.getUniformLocation(this._program, "uFaceSize"); - this._majorThicknessUniform = gl.getUniformLocation(this._program, "uMajorThickness"); - this._minorThicknessUniform = gl.getUniformLocation(this._program, "uMinorThickness"); - this._zeroThicknessUniform = gl.getUniformLocation(this._program, "uZeroThickness"); - this._zeroUniform = gl.getUniformLocation(this._program, "uZero"); - this._minorGridlinesUniform = gl.getUniformLocation(this._program, "uMinorGridlines"); - this._directionToLightUniform = gl.getUniformLocation(this._program, "uDirectionToLight"); - this._isInitialized = true; - } - apply() { - this._gl.uniform1f(this._majorThicknessUniform, this.majorThickness); - this._gl.uniform1f(this._minorThicknessUniform, this.minorThickness); - this._gl.uniform1f(this._zeroThicknessUniform, this.zeroThickness); - this._gl.uniform3fv(this._backgroundUniform, this.backgroundColor); - this._gl.uniform3fv(this._highlightUniform, this.highlightColor); - this._gl.uniform3fv(this._majorColorUniform, this.majorColor); - this._gl.uniform3fv(this._minorColorUniform, this.minorColor); - this._gl.uniform3fv(this._zeroColorUniform, this.zeroColor); - this._gl.uniform3fv(this._directionToLightUniform, this.directionToLight); - this._gl.uniform4fv(this._pickedIdColorUniform, this.pickedIdColor); - } - applyView() { - this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); - this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); - } - ApplyFace() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); - this._gl.uniform2f(this._faceSizeUniform, this.faceWidth, this.faceHeight); - this._gl.uniform2fv(this._zeroUniform, this.zero); - this._gl.uniform2fv(this._minorGridlinesUniform, this.minorGridlines); - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).TRANSLATION_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.vertexAttribPointer(this._normalAttribute, 3, this._gl.BYTE, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).NORMAL_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._normalAttribute); - this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).TEX_COORD_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._texCoordAttribute); - this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).ID_COLOR_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._idColorAttribute); - this._gl.vertexAttribPointer(this._boundsAttribute, 4, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).BOUNDS_OFFSET_BYTES); - this._gl.enableVertexAttribArray(this._boundsAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } -} - -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eXg0e":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitBlock", ()=>UnitBlock); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); -var _unitshaderJs = require("./unitshader.js"); -class UnitBlock extends (0, _unitshaderJs.UnitShader) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("unitblock.vertex.fx", "unitblock.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.OES_standard_derivatives == null) { - vsSource = this._removeDirective(vsSource, "Derivatives"); - fsSource = this._removeDirective(fsSource, "Derivatives"); - } - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - super._initializeShader(gl, vsSource, fsSource); - this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); - this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); - this._isInitialized = true; - } - _updateCurrentBuffer() { - super._updateCurrentBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); - this._gl.enableVertexAttribArray(this._rotationAttribute); - this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); - this._gl.enableVertexAttribArray(this._colorAttribute); +parcelHelpers.export(exports, "SquarifiedTreeMap", ()=>SquarifiedTreeMap); +parcelHelpers.export(exports, "CubifiedTreeMap", ()=>CubifiedTreeMap); +parcelHelpers.export(exports, "TreeMapHelper", ()=>TreeMapHelper); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _mainJs = require("../main.js"); +var _vertexJs = require("../vertex.js"); +var _layoutJs = require("./layout.js"); +class SquarifiedTreeMap extends (0, _layoutJs.LayoutBase) { + get positionsX() { + return this._positionsX; } - _updatePreviousBuffer() { - super._updatePreviousBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); - this._gl.enableVertexAttribArray(this._previousRotationAttribute); - this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); - this._gl.enableVertexAttribArray(this._previousColorAttribute); + get positionsY() { + return this._positionsY; } - disableProgram() { - super.disableProgram(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); + get sizesX() { + return this._sizesX; } -} - -},{"../../../vertex.js":"ddAub","./unitshader.js":"1xLHD","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1xLHD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitShader", ()=>UnitShader); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _cubeJs = require("../../../meshes/cube.js"); -var _vertexJs = require("../../../vertex.js"); -var _mainJs = require("../../../main.js"); -class UnitShader extends (0, _shaderJs.ShaderBase) { - get paletteTexture() { - return this._paletteTexture; + get sizesY() { + return this._sizesY; } - set paletteTexture(value) { - if (this._paletteTexture != value) { - this._paletteTexture = value; - this._haveTexturesChanged = true; + layout(buffer, ids, options) { + const start = window.performance.now(); + const size = options.size == undefined ? 1 : options.size; + let offset = options.offset === undefined ? 0 : options.offset; + let count = options.count === undefined ? ids.length : options.count; + this.minLayoutBoundsX = options.minBoundsX; + this.minLayoutBoundsY = options.minBoundsY; + this.minLayoutBoundsZ = options.minBoundsZ; + this.maxLayoutBoundsX = options.maxBoundsX; + this.maxLayoutBoundsY = options.maxBoundsY; + this.maxLayoutBoundsZ = options.maxBoundsZ; + const sizeX = this.maxLayoutBoundsX - this.minLayoutBoundsX; + const sizeY = this.maxLayoutBoundsY - this.minLayoutBoundsY; + if (options.sizes) { + for(let i = 0; i < count; i++){ + if (options.sizes[ids[offset]] > 0) break; + offset++; + count--; + } + if (count == 0) return; + } else if (size <= 0) return; + if (!this._positionsX || this._positionsX.length < buffer.length) { + this._positionsX = new Float32Array(buffer.length); + this._positionsY = new Float32Array(buffer.length); + this._sizesX = new Float32Array(buffer.length); + this._sizesY = new Float32Array(buffer.length); } + TreeMapHelper.squarifiedLayout(ids, options.sizes, this._positionsX, this._positionsY, this._sizesX, this._sizesY, offset, offset + count - 1, this.minLayoutBoundsX, this.minLayoutBoundsY, sizeX, sizeY, buffer.lookup); + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - get previousPaletteTexture() { - return this._previousPaletteTexture; - } - set previousPaletteTexture(value) { - if (this._previousPaletteTexture != value) { - this._previousPaletteTexture = value; - this._haveTexturesChanged = true; + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const heights = options.heights; + const minHeight = options.minHeight === undefined ? 0 : options.minHeight; + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const padding = options.padding === undefined ? 0 : options.padding; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + let maxHeight; + if (heights) { + maxHeight = 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + maxHeight = Math.max(heights[id], maxHeight); + } + } else maxHeight = 1; + const heightScaling = (this.maxLayoutBoundsZ - this.minLayoutBoundsZ) / maxHeight; + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + const height = Math.max(heights ? heights[id] * heightScaling : heightScaling, minHeight); + let positionX = this._positionsX[index]; + let positionY = this._positionsY[index]; + let positionZ = this.minLayoutBoundsZ + height / 2; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = Math.max((this._sizesX[index] - padding) * this._boundsScaling, 0); + _vec3[1] = Math.max((this._sizesY[index] - padding) * this._boundsScaling, 0); + _vec3[2] = height * this._boundsScaling; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } - get sdfTexture() { - return this._sdfTexture; - } - set sdfTexture(value) { - if (this._sdfTexture != value) { - this._sdfTexture = value; - this._haveTexturesChanged = true; +} +class CubifiedTreeMap extends (0, _layoutJs.LayoutBase) { + layout(buffer, ids, options) { + const start = window.performance.now(); + const isTopToBottom = options.isTopToBottom === undefined ? false : options.isTopToBottom; + let offset = options.offset === undefined ? 0 : options.offset; + let count = options.count === undefined ? ids.length : options.count; + this.minLayoutBoundsX = options.minBoundsX; + this.minLayoutBoundsY = options.minBoundsY; + this.minLayoutBoundsZ = options.minBoundsZ; + this.maxLayoutBoundsX = options.maxBoundsX; + this.maxLayoutBoundsY = options.maxBoundsY; + this.maxLayoutBoundsZ = options.maxBoundsZ; + if (options.sizes) { + for(let i = 0; i < count; i++){ + if (options.sizes[ids[offset]] > 0) break; + offset++; + count--; + } + if (count == 0) return; } - } - get previousSdfTexture() { - return this._previousSdfTexture; - } - set previousSdfTexture(value) { - if (this._previousSdfTexture != value) { - this._previousSdfTexture = value; - this._haveTexturesChanged = true; + const sizeX = this.maxLayoutBoundsX - this.minLayoutBoundsX; + const sizeY = this.maxLayoutBoundsY - this.minLayoutBoundsY; + const sizeZ = this.maxLayoutBoundsZ - this.minLayoutBoundsZ; + const minHeight = this._core.config.minCubifiedTreeMapSlice / sizeY; + const side = Math.sqrt(sizeX * sizeZ); + const total = options.sizes ? TreeMapHelper.totalSize(ids, options.sizes, offset, offset + count - 1) : count; + if (!this._positionsX || this._positionsX.length < buffer.length) { + this._positionsX = new Float32Array(buffer.length); + this._positionsY = new Float32Array(buffer.length); + this._positionsZ = new Float32Array(buffer.length); + this._sizesX = new Float32Array(buffer.length); + this._sizesY = new Float32Array(buffer.length); + this._sizesZ = new Float32Array(buffer.length); } + TreeMapHelper.cubifiedLayout(ids, options.sizes, this._positionsX, this._positionsY, this._positionsZ, this._sizesX, this._sizesY, this._sizesZ, offset, offset + count - 1, this.minLayoutBoundsX, this.minLayoutBoundsY, this.minLayoutBoundsZ, sizeX, sizeY, sizeZ, side, total, minHeight, isTopToBottom, buffer.lookup); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - set instanceBuffer(value) { - if (this._instanceBuffer != value) { - this._instanceBuffer = value; - this._haveBuffersChanged = true; + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const padding = options.padding === undefined ? 0 : options.padding; + const paddingZ = options.thickness === undefined ? padding : 0; + const thickness = options.thickness === undefined ? 1 : options.thickness; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + let positionX = this._positionsX[index]; + let positionY = this._positionsY[index]; + let positionZ = this._positionsZ[index]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; + } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = Math.max((this._sizesX[index] - padding) * this._boundsScaling, 0); + _vec3[1] = Math.max((this._sizesY[index] - padding) * this._boundsScaling, 0); + _vec3[2] = Math.max((this._sizesZ[index] - paddingZ) * this._boundsScaling, 0) * thickness; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, (0, _constantsJs.Constants).QUAT_IDENTITY); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } - set previousInstanceBuffer(value) { - if (this._previousInstanceBuffer != value) { - this._previousInstanceBuffer = value; - this._haveBuffersChanged = true; +} +class TreeMapHelper { + static squarifiedLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, to, x, y, width, height, lookup) { + if (from > to) return; + if (to - from < 2) { + TreeMapHelper._sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, to, x, y, width, height, lookup); + return; + } + const totalSize = sizes ? TreeMapHelper.totalSize(ids, sizes, from, to) : to - from + 1; + const a = sizes ? sizes[ids[to]] / totalSize : 1 / totalSize; + let b = a; + let mid = to; + if (width < height) { + while(mid > from){ + const aspect = TreeMapHelper._aspect(height, width, a, b); + const q = sizes ? sizes[ids[mid - 1]] / totalSize : 1 / totalSize; + if (TreeMapHelper._aspect(height, width, a, b + q) > aspect) break; + mid--; + b += q; + } + TreeMapHelper._sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, mid, to, x, y, width, height * b, lookup); + TreeMapHelper.squarifiedLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, mid - 1, x, y + height * b, width, height * (1 - b), lookup); + } else { + while(mid > from){ + const aspect = TreeMapHelper._aspect(width, height, a, b); + const q = sizes ? sizes[ids[mid - 1]] / totalSize : 1 / totalSize; + if (TreeMapHelper._aspect(width, height, a, b + q) > aspect) break; + mid--; + b += q; + } + TreeMapHelper._sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, mid, to, x, y, width * b, height, lookup); + TreeMapHelper.squarifiedLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, mid - 1, x + width * b, y, width * (1 - b), height, lookup); } } - initializeData() { - this._areBuffersInitialized = false; - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._translationAttribute = gl.getAttribLocation(this._program, "aTranslation"); - this._previousTranslationAttribute = gl.getAttribLocation(this._program, "aPreviousTranslation"); - this._scaleAttribute = gl.getAttribLocation(this._program, "aScale"); - this._previousScaleAttribute = gl.getAttribLocation(this._program, "aPreviousScale"); - this._colorAttribute = gl.getAttribLocation(this._program, "aColor"); - this._previousColorAttribute = gl.getAttribLocation(this._program, "aPreviousColor"); - this._selectedAttribute = gl.getAttribLocation(this._program, "aSelected"); - this._previousSelectedAttribute = gl.getAttribLocation(this._program, "aPreviousSelected"); - this._orderAttribute = gl.getAttribLocation(this._program, "aOrder"); - this._idAttribute = gl.getAttribLocation(this._program, "aId"); - this._idColorAttribute = gl.getAttribLocation(this._program, "aIdColor"); - this._sampler0Uniform = gl.getUniformLocation(this._program, "uSampler"); - this._previousSampler0Uniform = gl.getUniformLocation(this._program, "uPreviousSampler"); - this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); - this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._timeUniform = gl.getUniformLocation(this._program, "uTime"); - this._durationUniform = gl.getUniformLocation(this._program, "uDuration"); - this._fromOrderUniform = gl.getUniformLocation(this._program, "uOrderFrom"); - this._toOrderUniform = gl.getUniformLocation(this._program, "uOrderTo"); - this._hoverUniform = gl.getUniformLocation(this._program, "uHover"); - this._activeUniform = gl.getUniformLocation(this._program, "uActive"); - this._pickUniform = gl.getUniformLocation(this._program, "uPick"); - this._directionToLightUniform = gl.getUniformLocation(this._program, "uDirectionToLight"); - this._halfAngleUniform = gl.getUniformLocation(this._program, "uHalfAngle"); - this._specularPowerUniform = gl.getUniformLocation(this._program, "uSpecularPower"); - this._specularIntensityUniform = gl.getUniformLocation(this._program, "uSpecularIntensity"); - this._hoverColorUniform = gl.getUniformLocation(this._program, "uHoverColor"); - this._activeColorUniform = gl.getUniformLocation(this._program, "uActiveColor"); - this._selectedColorUniform = gl.getUniformLocation(this._program, "uSelectedColor"); - this._highlightModeUniform = gl.getUniformLocation(this._program, "uHighlightMode"); - const vertices = (0, _cubeJs.Cube).POSITIONS; - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); - const indices = (0, _cubeJs.Cube).INDICES; - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); - this.indexCount = indices.length; - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, 12, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._updateCurrentBuffer(); - this._updatePreviousBuffer(); - } - _updateCurrentBuffer() { - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._instanceBuffer); - this._gl.vertexAttribPointer(this._idAttribute, 1, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ID_HOVER_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idAttribute, 1); - this._gl.enableVertexAttribArray(this._idAttribute); - this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ID_COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idColorAttribute, 1); - this._gl.enableVertexAttribArray(this._idColorAttribute); - this._gl.vertexAttribPointer(this._translationAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TRANSLATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._translationAttribute, 1); - this._gl.enableVertexAttribArray(this._translationAttribute); - this._gl.vertexAttribPointer(this._scaleAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SCALE_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._scaleAttribute, 1); - this._gl.enableVertexAttribArray(this._scaleAttribute); - this._gl.vertexAttribPointer(this._selectedAttribute, 1, this._gl.BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SELECTED_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._selectedAttribute, 1); - this._gl.enableVertexAttribArray(this._selectedAttribute); - this._gl.vertexAttribPointer(this._orderAttribute, 2, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ORDER_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._orderAttribute, 1); - this._gl.enableVertexAttribArray(this._orderAttribute); - } - _updatePreviousBuffer() { - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - if (this._previousInstanceBuffer != this._instanceBuffer) this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._previousInstanceBuffer); - this._gl.vertexAttribPointer(this._previousTranslationAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TRANSLATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTranslationAttribute, 1); - this._gl.enableVertexAttribArray(this._previousTranslationAttribute); - this._gl.vertexAttribPointer(this._previousScaleAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SCALE_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousScaleAttribute, 1); - this._gl.enableVertexAttribArray(this._previousScaleAttribute); - this._gl.vertexAttribPointer(this._previousSelectedAttribute, 1, this._gl.BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SELECTED_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousSelectedAttribute, 1); - this._gl.enableVertexAttribArray(this._previousSelectedAttribute); - } - apply() { - this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); - this._gl.uniform1f(this._timeUniform, this.time); - this._gl.uniform1f(this._durationUniform, this.duration); - this._gl.uniform1f(this._fromOrderUniform, this.rangeMin); - this._gl.uniform1f(this._toOrderUniform, this.rangeMax); - this._gl.uniform1i(this._previousSampler0Uniform, 0); - this._gl.uniform1i(this._sampler0Uniform, 1); - this._gl.uniform1f(this._specularPowerUniform, this.specularPower); - this._gl.uniform1f(this._specularIntensityUniform, this.specularIntensity); - this._gl.uniform3fv(this._hoverColorUniform, this.hoverColor); - this._gl.uniform3fv(this._activeColorUniform, this.activeColor); - this._gl.uniform3fv(this._selectedColorUniform, this.selectedColor); - this._gl.uniform1f(this._hoverUniform, this.hover); - this._gl.uniform1f(this._activeUniform, this.active); - this._gl.uniform1f(this._highlightModeUniform, this.highlightMode == (0, _mainJs.HighlightMode).luminance ? 0.0 : 1.0); + static totalSize(ids, sizes, from, to) { + let size = 0; + for(let i = from; i <= to; i++)size += sizes[ids[i]]; + return size; } - applyView() { - this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); - this._gl.uniform3fv(this._directionToLightUniform, this.directionToLight); - this._gl.uniform3fv(this._halfAngleUniform, this.halfAngle); - this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); + static _sliceLayout(ids, sizes, positionsX, positionsY, sizesX, sizesY, from, to, x, y, width, height, lookup) { + const totalSize = sizes ? TreeMapHelper.totalSize(ids, sizes, from, to) : to - from + 1; + let a = 0; + for(let i = to; i >= from; i--){ + const id = ids[i]; + const index = lookup[id]; + const b = sizes ? sizes[id] / totalSize : 1 / totalSize; + if (width > height) { + sizesY[index] = height; + sizesX[index] = width * b; + positionsY[index] = y + height / 2; + positionsX[index] = x + width * a + width * b / 2; + } else { + sizesX[index] = width; + sizesY[index] = height * b; + positionsX[index] = x + width / 2; + positionsY[index] = y + height * a + height * b / 2; + } + a += b; + } } - updateTextures() { - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._previousPaletteTexture); - this._gl.activeTexture(this._gl.TEXTURE1); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._paletteTexture); + static _aspect(big, small, a, b) { + const x = big * b / (small * a / b); + if (x < 1) return 1 / x; + return x; } - disableProgram() { - super.disableProgram(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._translationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTranslationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._scaleAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousScaleAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._selectedAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousSelectedAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._orderAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idColorAttribute, 0); + static cubifiedLayout(ids, sizes, positionsX, positionsY, positionsZ, sizesX, sizesY, sizesZ, from, to, x, y, z, width, height, depth, side, total, minHeight, isTopToBottom, lookup) { + if (from > to) return; + let sliceHeight = 0; + let sliceTotal = 0; + let previousAspect = 0; + let mid = to; + while(mid >= from){ + const itemSize = sizes ? sizes[ids[mid]] : 1; + sliceTotal += itemSize; + sliceHeight = height * sliceTotal / total; + const remainingHeight = height - sliceHeight; + if (remainingHeight < minHeight) { + mid = from; + const totalSize = sizes ? this.totalSize(ids, sizes, mid, to) : to - from + 1; + sliceHeight = height * totalSize / total; + break; + } + const itemSide = Math.sqrt(itemSize / sliceTotal) * side; + const aspect = itemSide > sliceHeight ? sliceHeight / itemSide : itemSide / sliceHeight; + if (aspect < previousAspect || mid == from) break; + previousAspect = aspect; + mid--; + } + TreeMapHelper.squarifiedLayout(ids, sizes, positionsX, positionsZ, sizesX, sizesZ, mid, to, x, z, width, depth, lookup); + for(let j = mid; j <= to; j++){ + const id = ids[j]; + const index = lookup[id]; + sizesY[index] = Math.max(sliceHeight, 0.01); + positionsY[index] = isTopToBottom ? positionsY[index] = y + sliceHeight / 2 : y + height - sliceHeight / 2; + } + TreeMapHelper.cubifiedLayout(ids, sizes, positionsX, positionsY, positionsZ, sizesX, sizesY, sizesZ, from, mid - 1, x, isTopToBottom ? y + sliceHeight : y, z, width, height - sliceHeight, depth, side, total - sliceTotal, minHeight, isTopToBottom, lookup); } } -},{"./shader.js":"5rKvk","../../../meshes/cube.js":"7rTMs","../../../vertex.js":"ddAub","../../../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8zbGd":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitSphere", ()=>UnitSphere); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../helpers/math.js":"f65d0","../main.js":"f421K","../vertex.js":"4J2YE","./layout.js":"kYBiT","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"f8244":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); -var _unitshaderJs = require("./unitshader.js"); -class UnitSphere extends (0, _unitshaderJs.UnitShader) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("unitsphere.vertex.fx", "unitsphere.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.EXT_frag_depth == null) fsSource = this._removeDirective(fsSource, "FragDepth"); - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - super._initializeShader(gl, vsSource, fsSource); - this._isInitialized = true; - } - _updateCurrentBuffer() { - super._updateCurrentBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._colorAttribute, 1, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); - this._gl.enableVertexAttribArray(this._colorAttribute); - } - _updatePreviousBuffer() { - super._updatePreviousBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._previousColorAttribute, 1, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); - this._gl.enableVertexAttribArray(this._previousColorAttribute); - } -} - -},{"../../../vertex.js":"ddAub","./unitshader.js":"1xLHD","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kkt7L":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitCylinder", ()=>UnitCylinder); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); -var _unitshaderJs = require("./unitshader.js"); -class UnitCylinder extends (0, _unitshaderJs.UnitShader) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("unitcylinder.vertex.fx", "unitcylinder.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.EXT_frag_depth == null) fsSource = this._removeDirective(fsSource, "FragDepth"); - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - super._initializeShader(gl, vsSource, fsSource); - this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); - this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); - this._isInitialized = true; - } - _updateCurrentBuffer() { - super._updateCurrentBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); - this._gl.enableVertexAttribArray(this._rotationAttribute); - this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); - this._gl.enableVertexAttribArray(this._colorAttribute); - } - _updatePreviousBuffer() { - super._updatePreviousBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); - this._gl.enableVertexAttribArray(this._previousRotationAttribute); - this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); - this._gl.enableVertexAttribArray(this._previousColorAttribute); - } - disableProgram() { - super.disableProgram(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); +parcelHelpers.export(exports, "StackBase", ()=>StackBase); +parcelHelpers.export(exports, "Stack", ()=>Stack); +parcelHelpers.export(exports, "StackTreeMap", ()=>StackTreeMap); +var _constantsJs = require("../constants.js"); +var _mathJs = require("../helpers/math.js"); +var _vertexJs = require("../vertex.js"); +var _treemapJs = require("./treemap.js"); +var _layoutJs = require("./layout.js"); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +class StackBase extends (0, _layoutJs.LayoutBase) { + get maxCount() { + return this._maxCount; } -} - -},{"../../../vertex.js":"ddAub","./unitshader.js":"1xLHD","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gOp7C":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitHexPrism", ()=>UnitHexPrism); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); -var _unitshaderJs = require("./unitshader.js"); -class UnitHexPrism extends (0, _unitshaderJs.UnitShader) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("unithexprism.vertex.fx", "unithexprism.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.EXT_frag_depth == null) fsSource = this._removeDirective(fsSource, "FragDepth"); - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); + get levels() { + return this._levels; } - _initializeShader(gl, vsSource, fsSource) { - super._initializeShader(gl, vsSource, fsSource); - this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); - this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); - this._isInitialized = true; + get binCounts() { + return this._binCounts; } - _updateCurrentBuffer() { - super._updateCurrentBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); - this._gl.enableVertexAttribArray(this._rotationAttribute); - this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); - this._gl.enableVertexAttribArray(this._colorAttribute); + getPositionX(index) { + return this._positionsX[index]; } - _updatePreviousBuffer() { - super._updatePreviousBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); - this._gl.enableVertexAttribArray(this._previousRotationAttribute); - this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); - this._gl.enableVertexAttribArray(this._previousColorAttribute); + getPositionY(index) { + return this._positionsY[index]; } - disableProgram() { - super.disableProgram(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); + getPositionZ(index) { + return this._positionsZ[index]; } } - -},{"../../../vertex.js":"ddAub","./unitshader.js":"1xLHD","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ga6lZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitSdf", ()=>UnitSdf); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); -var _unitshaderJs = require("./unitshader.js"); -class UnitSdf extends (0, _unitshaderJs.UnitShader) { - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("unitsdf.vertex.fx", "unitsdf.fragment.fx", (vsSource, fsSource)=>{ - if (this._main.shaderResources.OES_standard_derivatives == null) { - vsSource = this._removeDirective(vsSource, "Derivatives"); - fsSource = this._removeDirective(fsSource, "Derivatives"); - } - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); +class Stack extends StackBase { + get maxLevel() { + return this._maxLevel; } - _initializeShader(gl, vsSource, fsSource) { - super._initializeShader(gl, vsSource, fsSource); - this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); - this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); - this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); - this._previousTexCoordAttribute = gl.getAttribLocation(this._program, "aPreviousTexCoord"); - this._sampler1Uniform = gl.getUniformLocation(this._program, "uSampler1"); - this._previousSampler1Uniform = gl.getUniformLocation(this._program, "uPreviousSampler1"); - this._sdfBufferUniform = gl.getUniformLocation(this._program, "uBuffer"); - this._sdfBackgroundColorUniform = gl.getUniformLocation(this._program, "uBackgroundColor"); - this._isInitialized = true; - } - _updateCurrentBuffer() { - super._updateCurrentBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); - this._gl.enableVertexAttribArray(this._rotationAttribute); - this._gl.vertexAttribPointer(this._texCoordAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TEXCOORD_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._texCoordAttribute, 1); - this._gl.enableVertexAttribArray(this._texCoordAttribute); - this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); - this._gl.enableVertexAttribArray(this._colorAttribute); - } - _updatePreviousBuffer() { - super._updatePreviousBuffer(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); - this._gl.enableVertexAttribArray(this._previousRotationAttribute); - this._gl.vertexAttribPointer(this._previousTexCoordAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TEXCOORD_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTexCoordAttribute, 1); - this._gl.enableVertexAttribArray(this._previousTexCoordAttribute); - this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); - this._gl.enableVertexAttribArray(this._previousColorAttribute); - } - apply() { - super.apply(); - this._gl.uniform1i(this._previousSampler1Uniform, 2); - this._gl.uniform1i(this._sampler1Uniform, 3); - this._gl.uniform1f(this._sdfBufferUniform, this.sdfBuffer); - this._gl.uniform3fv(this._sdfBackgroundColorUniform, this.sdfBackgroundColor); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE2); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._previousSdfTexture); - this._gl.activeTexture(this._gl.TEXTURE3); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._sdfTexture); - } - disableProgram() { - super.disableProgram(); - const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._texCoordAttribute, 0); - ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTexCoordAttribute, 0); - } -} - -},{"../../../vertex.js":"ddAub","./unitshader.js":"1xLHD","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5atqZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Anaglyph", ()=>Anaglyph); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Anaglyph extends (0, _shaderJs.ShaderBase) { - get texture2D1() { - return this._texture2D1; - } - set texture2D1(value) { - if (this._texture2D1 != value) { - this._texture2D1 = value; - this._haveTexturesChanged = true; + layout(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + this._maxLevel = 0; + const sizeX = options.sizeX == undefined ? 1 : options.sizeX; + const sizeZ = options.sizeZ == undefined ? 1 : options.sizeZ; + const spacingX = options.spacingX == undefined ? 0 : options.spacingX; + const spacingZ = options.spacingZ == undefined ? 0 : options.spacingZ; + const binsX = options.binsX == undefined ? 1 : options.binsX; + const binsZ = options.binsZ == undefined ? 1 : options.binsZ; + this._height = options.height == undefined ? 1 : options.height; + if (!this._positionsX || this._positionsX.length < buffer.length) { + this._positionsX = new Float32Array(buffer.length); + this._positionsY = new Float32Array(buffer.length); + this._positionsZ = new Float32Array(buffer.length); + this._levels = new Uint32Array(buffer.length); } - } - get texture2D2() { - return this._texture2D2; - } - set texture2D2(value) { - if (this._texture2D2 != value) { - this._texture2D2 = value; - this._haveTexturesChanged = true; + this._binCounts = new Uint32Array(binsX * binsZ); + let maxBinCount = 0; + let maxBinLevel = 0; + let positionX, positionY, positionZ; + const lookup = buffer.lookup; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + const binIdX = options.binIdsX ? options.binIdsX[id] : 0; + const binIdZ = options.binIdsZ ? options.binIdsZ[id] : 0; + const binId = binIdX + binIdZ * binsX; + if (binId > this._binCounts.length - 1) this._core.log.write((0, _mainJs.LogLevel).warn, "bin overflow"); + const binCount = this._binCounts[binId]; + const level = Math.floor(binCount / sizeX / sizeZ); + this._levels[index] = level; + const levelCount = binCount - level * sizeX * sizeZ; + const itemZ = Math.floor(levelCount / sizeX); + const itemX = levelCount - itemZ * sizeX; + positionX = spacingX / 2 + binIdX * (sizeX + spacingX) + itemX + 0.5; + positionY = this._height * (level + 0.5); + positionZ = spacingZ / 2 + binIdZ * (sizeZ + spacingZ) + itemZ + 0.5; + this._positionsX[index] = positionX; + this._positionsY[index] = positionY; + this._positionsZ[index] = positionZ; + this._binCounts[binId]++; + maxBinCount = Math.max(maxBinCount, this._binCounts[binId]); + maxBinLevel = Math.max(maxBinLevel, level); } + this._maxLevel = maxBinLevel + 1; + this._maxCount = maxBinCount; + this.minLayoutBoundsX = 0; + this.minLayoutBoundsY = 0; + this.minLayoutBoundsZ = 0; + this.maxLayoutBoundsX = binsX * (sizeX + spacingX); + this.maxLayoutBoundsY = this._maxLevel * this._height; + this.maxLayoutBoundsZ = binsZ * (sizeZ + spacingZ); + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "anaglyph.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); - this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); - this._isInitialized = true; - } - apply() { - this._gl.uniform4f(this._viewportUniform, this.viewport.x, this.viewport.y, this.viewport.width, this.viewport.height); - this._gl.uniform1i(this._samplerUniform1, 0); - this._gl.uniform1i(this._samplerUniform2, 1); - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); - this._gl.activeTexture(this._gl.TEXTURE1); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); - this._gl.activeTexture(this._gl.TEXTURE2); - } -} - -},{"./shader.js":"5rKvk","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"Csa08":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "DebugAxesVisual", ()=>DebugAxesVisual); -class DebugAxesVisual { - get isInitialized() { - return this._isInitialized && this._main.colorShader.isInitialized; - } - constructor(core, main, debugAxes){ - this._main = main; - this._debugAxes = debugAxes; - this.isVisible = true; - } - initializeContext(gl) { - if (!this._debugAxes.isInitialized) this._debugAxes.initialize(); - this._gl = gl; - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._debugAxes.vertices, gl.STATIC_DRAW); - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._debugAxes.indices, gl.STATIC_DRAW); - this._isInitialized = true; - } - update(elapsedTime) {} - render(elapsedTime, xrFrame) { - if (this.isInitialized) { - const colorShader = this._main.colorShader; - const shaderResources = this._main.shaderResources; - colorShader.vertexBuffer = this._vertexBuffer; - colorShader.indexBuffer = this._indexBuffer; - colorShader.prepare(); - colorShader.mMatrix = this.mMatrix; - colorShader.apply(); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - colorShader.vMatrix = this.vMatrices[viewport]; - colorShader.pMatrix = this.pMatrices[viewport]; - colorShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLE_STRIP, this._debugAxes.indexCount, this._gl.UNSIGNED_SHORT, 0); + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _vec4 = (0, _glMatrix.vec4).create(); + const _quat = (0, _glMatrix.quat).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const padding = options.padding === undefined ? 0 : options.padding; + const thickness = options.thickness === undefined ? 1 - padding : options.thickness; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + if (options.texCoord) { + _vec4[0] = options.texCoord[0]; + _vec4[1] = options.texCoord[1]; + _vec4[2] = options.texCoord[2]; + _vec4[3] = options.texCoord[3]; + } + const scale = (0, _glMatrix.vec3).fromValues((1 - padding) * this._boundsScaling, (this._height - padding) * this._boundsScaling, thickness * this._boundsScaling); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + let positionX = this._positionsX[index]; + let positionY = this._positionsY[index]; + let positionZ = this._positionsZ[index]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setScale(dataView, index, scale); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); + if (options.texCoords) { + _vec4[0] = options.texCoords[id * 4]; + _vec4[1] = options.texCoords[id * 4 + 1]; + _vec4[2] = options.texCoords[id * 4 + 2]; + _vec4[3] = options.texCoords[id * 4 + 3]; + (0, _vertexJs.UnitVertex).setTexCoord(dataView, index, _vec4); + } else (0, _vertexJs.UnitVertex).setTexCoord(dataView, index, _vec4); } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${count} ${Math.round(window.performance.now() - start)}ms`); } } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hO56R":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cartesian2dVisual", ()=>Cartesian2dVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _axesJs = require("./axes.js"); -var _mainJs = require("../../../../main.js"); -var _constantsJs = require("../../../../constants.js"); -var _quadJs = require("../../../../meshes/quad.js"); -class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { - get isInitialized() { - return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; +class StackTreeMap extends StackBase { + get maxTotal() { + return this._maxTotal; } - constructor(core, main, cartesian2dAxes){ - super(core); - this._main = main; - this._axes = cartesian2dAxes; - this._axes.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; + get binGroupIds() { + return this._binGroupIds; } - initializeContext(gl) { - super.initializeContext(gl); - const axes = this._axes; - if (!axes.isInitialized) axes.initialize(); - if (axes.gridVertices) this._createGridBuffers(); - if (axes.textVertices) this._createTextBuffers(); - this._isInitialized = true; + getSizeX(index) { + return this._sizesX[index]; } - _createGridBuffers() { - const axes = this._axes; - this._gridVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); - this._gridIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); - this._gridBufferSize = axes.gridVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers created`); + getSizeY(index) { + return this._sizesY[index]; } - _createTextBuffers() { - const axes = this._axes; - this._textVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); - this._textIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); - this._textBufferSize = axes.textVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers created`); + getSizeZ(index) { + return this._sizesZ[index]; } - update(elapsedTime) { - if (this._hasChanged) { - this._hasChanged = false; - const axes = this._axes; - if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); + layout(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const isNormalized = options.isNormalized === undefined ? false : options.isNormalized; + const minHeight = options.minHeight === undefined ? 0 : options.minHeight; + const maxHeight = options.maxHeight === undefined ? 0 : options.maxHeight; + const isTopToBottom = options.isTopToBottom === undefined ? false : options.isTopToBottom; + const sizeX = options.sizeX == undefined ? 1 : options.sizeX; + const sizeZ = options.sizeZ == undefined ? 1 : options.sizeZ; + const spacingX = options.spacingX == undefined ? 0 : options.spacingX; + const spacingZ = options.spacingZ == undefined ? 0 : options.spacingZ; + const binsX = options.binsX == undefined ? 1 : options.binsX; + const binsZ = options.binsZ == undefined ? 1 : options.binsZ; + if (!this._positionsX || this._positionsX.length < buffer.length) { + this._positionsX = new Float32Array(buffer.length); + this._positionsY = new Float32Array(buffer.length); + this._positionsZ = new Float32Array(buffer.length); + this._sizesX = new Float32Array(buffer.length); + this._sizesY = new Float32Array(buffer.length); + this._sizesZ = new Float32Array(buffer.length); + this._binIds = new Uint32Array(buffer.length); + this._binGroupIds = new Float64Array(buffer.length); + } + this._binCounts = new Uint32Array(binsX * binsZ); + this._binTotals = new Float64Array(binsX * binsZ); + let maxBinCount = 0; + let maxBinTotal = 0; + let height; + const lookup = buffer.lookup; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + const binIdX = options.binIdsX ? options.binIdsX[id] : 0; + const binIdZ = options.binIdsZ ? options.binIdsZ[id] : 0; + const binId = binIdX + binIdZ * binsX; + this._binIds[index] = binId; + if (binId > this._binCounts.length - 1) this._core.log.write((0, _mainJs.LogLevel).warn, "bin overflow"); + this._binCounts[binId]++; + maxBinCount = Math.max(maxBinCount, this._binCounts[binId]); + this._binTotals[binId] += options.sizes ? options.sizes[id] : 1; + maxBinTotal = Math.max(maxBinTotal, this._binTotals[binId]); + } + if (maxHeight - minHeight > 0) height = maxHeight - minHeight; + else height = Math.ceil(maxBinCount / sizeX / sizeZ); + if (!this._orderedIds || this._orderedIds.length < buffer.length) this._orderedIds = new Uint32Array(buffer.length); + let ids2; + if (options.groupIds || options.sizes) { + if (count == ids.length) this._ids = new Uint32Array(ids); else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers updated`); + this._ids = new Uint32Array(count); + for(let i = 0; i < count; i++)this._ids[i] = ids[offset + i]; } - if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers updated`); + if (options.groupIds && options.sizes) { + this._ids.sort(function(a, b) { + return options.groupIds[a] == options.groupIds[b] ? options.sizes[a] - options.sizes[b] : options.groupIds[a] - options.groupIds[b]; + }); + ids2 = this._ids; + } else if (options.groupIds) { + this._ids.sort(function(a, b) { + return options.groupIds[a] - options.groupIds[b]; + }); + ids2 = this._ids; + } else if (options.sizes) { + this._ids.sort(function(a, b) { + return options.sizes[a] - options.sizes[b]; + }); + ids2 = this._ids; } - this._main.shaderResources.currentProgram = null; + } else ids2 = ids; + const binOffsets = new Uint32Array(this._binCounts.length); + let binOffset = 0; + for(let i = 0; i < this._binCounts.length; i++){ + const binCount = this._binCounts[i]; + binOffsets[i] = binOffset; + binOffset += binCount; } - } - _renderText() { - const axes = this._axes; - const shader = this._main.sdfTextShader; - const shaderResources = this._main.shaderResources; - const fontVisual = this._main.fonts[axes.font.name]; - shader.vertexBuffer = this._textVertexBuffer; - shader.indexBuffer = this._textIndexBuffer; - shader.texture2D = fontVisual.texture; - shader.prepare(); - shader.buffer = fontVisual.font.edgeValue / 0xff; - shader.gamma = axes.gamma; - shader.borderWidth = axes.textBorderWidth; - shader.color = axes.textColor || this._core.config.axesTextColor; - shader.hoverColor = axes.textHoverColor || this._core.config.axesTextHoverColor; - shader.borderColor = axes.textBorderColor || this._core.config.textBorderColor; - shader.pickedIdColor = this.pickedIdColor; - shader.apply(); - let indexCount, indexOffset; - for(let axisId = 0; axisId < 2; axisId++){ - const orientation = axes.getLabelOrientation(axisId); - for(let edge = 0; edge < 2; edge++){ - const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; - if (axes.isEdgeVisible[edgeId]) { - if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { - indexCount = axes.getAxesLeftToRightIndexCount(axisId); - indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); - } else { - indexCount = axes.getAxesRightToLeftIndexCount(axisId); - indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); - } - if (indexCount > 0) { - shader.mMatrix = axes.getLabelMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - shader.vMatrix = this.vMatrices[viewport]; - shader.pMatrix = this.pMatrices[viewport]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - indexCount = axes.getTitleIndexCount(axisId); - if (indexCount > 0) { - indexOffset = axes.getTitleIndexOffset(axisId); - shader.mMatrix = axes.getTitleMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - for(let i1 = 0; i1 < this.viewportCount; i1++){ - const viewport1 = i1 + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport1]); - this._gl.viewport(this.viewports[viewport1].x, this.viewports[viewport1].y, this.viewports[viewport1].width, this.viewports[viewport1].height); - shader.vMatrix = this.vMatrices[viewport1]; - shader.pMatrix = this.pMatrices[viewport1]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } + for(let i = 0; i < count; i++){ + const id = ids2[i]; + const index = lookup[id]; + const binId = this._binIds[index]; + binOffset = binOffsets[binId]++; + this._orderedIds[binOffset + offset] = id; + } + const minSliceHeight = this._core.config.minCubifiedTreeMapSlice * height; + const side = Math.sqrt(sizeX * sizeZ); + let from = offset; + let isLastInGroup = false; + let isLastInBin = false; + let groupCount = 0; + let groupTotal = 0; + let positionY = 0; + for(let i = 0; i < count; i++){ + const id = this._orderedIds[i + offset]; + const index = lookup[id]; + groupCount++; + groupTotal += options.sizes ? options.sizes[id] : 1; + const binId = this._binIds[index]; + const groupId = options.groupIds ? options.groupIds[id] : 0; + if (i == count - 1) { + isLastInBin = true; + isLastInGroup = true; + } else { + const nextId = this._orderedIds[i + 1 + offset]; + const nextIndex = lookup[nextId]; + const nextBinId = this._binIds[nextIndex]; + const nextGroupId = options.groupIds ? options.groupIds[nextId] : 0; + isLastInBin = binId != nextBinId; + isLastInGroup = groupId != nextGroupId; + } + if (isLastInBin || isLastInGroup) { + const mid = i + offset; + const binIdX = options.binIdsX ? options.binIdsX[id] : 0; + const binIdZ = options.binIdsZ ? options.binIdsZ[id] : 0; + let groupValue, binValue; + if (options.sizes) { + groupValue = groupTotal; + binValue = isNormalized ? this._binTotals[binId] : maxBinTotal; + } else { + groupValue = groupCount; + binValue = isNormalized ? this._binCounts[binId] : maxBinCount; + } + const groupHeight = height * groupValue / binValue; + if (sizeZ == 1) { + const positionX = spacingX / 2 + binIdX * (sizeX + spacingX); + (0, _treemapJs.TreeMapHelper).squarifiedLayout(this._orderedIds, options.sizes, this._positionsX, this._positionsY, this._sizesX, this._sizesY, from, mid, positionX, positionY, sizeX, groupHeight, lookup); + const isRightToLeft = true; + for(let i = from; i <= mid; i++){ + const id = this._orderedIds[i]; + const index = lookup[id]; + this._sizesZ[index] = sizeZ; + this._positionsZ[index] = (binIdZ + 0.5) * (sizeZ + spacingZ); + if (isRightToLeft) this._positionsX[index] = positionX + sizeX - this._positionsX[index] + positionX; + if (!isTopToBottom) this._positionsY[index] = positionY + groupHeight - this._positionsY[index] + positionY; } + } else (0, _treemapJs.TreeMapHelper).cubifiedLayout(this._orderedIds, options.sizes, this._positionsX, this._positionsY, this._positionsZ, this._sizesX, this._sizesY, this._sizesZ, from, mid, spacingX / 2 + binIdX * (sizeX + spacingX), positionY, spacingZ / 2 + binIdZ * (sizeZ + spacingZ), sizeX, groupHeight, sizeZ, side, groupValue, minSliceHeight, isTopToBottom, lookup); + if (isLastInGroup) { + isLastInGroup = false; + positionY += groupHeight; } - indexCount = axes.getHeadingIndexCount(axisId); - if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { - indexOffset = axes.getHeadingIndexOffset(axisId); - shader.mMatrix = axes.getHeadingMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - for(let i2 = 0; i2 < this.viewportCount; i2++){ - const viewport2 = i2 + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport2]); - this._gl.viewport(this.viewports[viewport2].x, this.viewports[viewport2].y, this.viewports[viewport2].width, this.viewports[viewport2].height); - shader.vMatrix = this.vMatrices[viewport2]; - shader.pMatrix = this.pMatrices[viewport2]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } + if (isLastInBin) { + isLastInBin = false; + positionY = 0; } + groupCount = 0; + groupTotal = 0; + from = mid + 1; } } + this._maxCount = maxBinCount; + this._maxTotal = maxBinTotal; + this.minLayoutBoundsX = 0; + this.minLayoutBoundsY = 0; + this.minLayoutBoundsZ = 0; + this.maxLayoutBoundsX = binsX * (sizeX + spacingX); + this.maxLayoutBoundsY = height; + this.maxLayoutBoundsZ = binsZ * (sizeZ + spacingZ); + this._updateCumulativeLayoutBounds(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} layout ${count} ${Math.round(window.performance.now() - start)}ms`); } - _renderGrid() { - const axes = this._axes; - const gridShader = this._main.gridShader; - gridShader.vertexBuffer = this._gridVertexBuffer; - gridShader.indexBuffer = this._gridIndexBuffer; - gridShader.prepare(); - gridShader.majorThickness = axes.gridMajorThickness; - gridShader.minorThickness = axes.gridMinorThickness; - gridShader.zeroThickness = axes.gridZeroThickness; - gridShader.backgroundColor = axes.gridBackgroundColor || this._core.config.axesGridBackgroundColor; - gridShader.highlightColor = axes.gridHighlightColor || this._core.config.axesGridHighlightColor; - gridShader.majorColor = axes.gridMajorColor || this._core.config.axesGridMajorColor; - gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; - gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; - gridShader.pickedIdColor = this.pickedIdColor; - gridShader.directionToLight = (0, _constantsJs.Constants).VECTOR3_UNITZ; - gridShader.apply(); - for(let axisId = 0; axisId < 2; axisId++)if (axes.arePickDivisionsVisible[axisId]) { - const gridTicksScale = axes.getGridTicksScale(axisId); - const width = gridTicksScale[0]; - const height = gridTicksScale[1]; - gridShader.zero = axes.getGridTicksZero(axisId); - gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); - for(let edge = 0; edge < 2; edge++){ - const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; - if (axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); + update(buffer, ids, options) { + const start = window.performance.now(); + const offset = options.offset === undefined ? 0 : options.offset; + const count = options.count === undefined ? ids.length : options.count; + const dataView = buffer.dataView; + const _vec2 = (0, _glMatrix.vec2).create(); + const _vec3 = (0, _glMatrix.vec3).create(); + const _quat = (0, _glMatrix.quat).create(); + const minColor = options.minColor === undefined ? 0 : options.minColor; + const maxColor = options.maxColor === undefined ? 1 : options.maxColor; + const minOrder = options.minOrder === undefined ? 0 : options.minOrder; + const maxOrder = options.maxOrder === undefined ? 1 : options.maxOrder; + const orderReverse = options.orderReverse === undefined ? false : options.orderReverse; + const minStaggerOrder = options.minStaggerOrder === undefined ? 0 : options.minStaggerOrder; + const maxStaggerOrder = options.maxStaggerOrder === undefined ? 1 : options.maxStaggerOrder; + const staggerOrderReverse = options.staggerOrderReverse === undefined ? false : options.staggerOrderReverse; + const padding = options.padding === undefined ? 0 : options.padding; + const paddingZ = options.thickness === undefined ? padding : 0; + const thickness = options.thickness === undefined ? 1 : options.thickness; + const reverseX = options.reverseX === undefined ? false : options.reverseX; + const reverseY = options.reverseY === undefined ? false : options.reverseY; + const reverseZ = options.reverseZ === undefined ? false : options.reverseZ; + this._updateModelBounds(options); + (0, _glMatrix.quat).rotationTo(_quat, this._core.config.identityRotation, (0, _constantsJs.Constants).VECTOR3_UNITY); + const lookup = buffer.lookup; + const selection = options.selected && options.selected.size > 0; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = lookup[id]; + let positionX = this._positionsX[index]; + let positionY = this._positionsY[index]; + let positionZ = this._positionsZ[index]; + if (this._isFacetted) { + if (reverseX) positionX = this.minModelBoundsX + this.minModelBoundsX + this._facetSizeX * (1 + this._facetSpacingX) - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.minModelBoundsY + this._facetSizeY * (1 + this._facetSpacingY) - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.minModelBoundsZ + this._facetSizeZ * (1 + this._facetSpacingZ) - positionZ; + const facetX = options.facetCoordsX ? options.facetCoordsX[id] : 0; + const facetY = options.facetCoordsY ? options.facetCoordsY[id] : 0; + const facetZ = options.facetCoordsZ ? options.facetCoordsZ[id] : 0; + positionX += facetX * this._facetSizeX * (1 + this._facetSpacingX); + positionY += facetY * this._facetSizeY * (1 + this._facetSpacingY); + positionZ += facetZ * this._facetSizeZ * (1 + this._facetSpacingZ); + } else { + if (reverseX) positionX = this.minModelBoundsX + this.maxModelBoundsX - positionX; + if (reverseY) positionY = this.minModelBoundsY + this.maxModelBoundsY - positionY; + if (reverseZ) positionZ = this.minModelBoundsZ + this.maxModelBoundsZ - positionZ; } + _vec3[0] = (positionX - this.modelOriginX) * this._boundsScaling; + _vec3[1] = (positionY - this.modelOriginY) * this._boundsScaling; + _vec3[2] = (positionZ - this.modelOriginZ) * this._boundsScaling; + (0, _vertexJs.UnitVertex).setTranslation(dataView, index, _vec3); + _vec3[0] = Math.max((this._sizesX[index] - padding) * this._boundsScaling, 0); + _vec3[1] = Math.max((this._sizesY[index] - padding) * this._boundsScaling, 0); + _vec3[2] = Math.max((this._sizesZ[index] - paddingZ) * this._boundsScaling, 0) * thickness; + (0, _vertexJs.UnitVertex).setScale(dataView, index, _vec3); + (0, _vertexJs.UnitVertex).setRotation(dataView, index, _quat); + if (options.colors) { + const size = 1 / (maxColor - minColor + 1); + const color = (0, _mathJs.MathHelper).normalize(options.colors[id], minColor, maxColor, size / 2, 1 - size / 2); + (0, _glMatrix.vec2).set(_vec2, color, color); + (0, _vertexJs.UnitVertex).setColor(dataView, index, _vec2); + } else (0, _vertexJs.UnitVertex).setColor(dataView, index, (0, _constantsJs.Constants).VECTOR2_ONE); + (0, _vertexJs.UnitVertex).setIdHover(dataView, index, options.hover ? options.hover[id] : id); + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? options.selected.has(id) ? 1 : -1 : 0); + if (options.order !== undefined) { + const order = (0, _mathJs.MathHelper).normalize(options.order[id], minOrder, maxOrder, 0, 1); + _vec2[0] = orderReverse ? 1 - order : order; + } else _vec2[0] = count == 1 ? 0 : i / (count - 1); + if (options.staggerOrder !== undefined) _vec2[1] = options.staggerOrder; + else if (options.staggerOrders) { + const stagger = (0, _mathJs.MathHelper).normalize(options.staggerOrders[id], minStaggerOrder, maxStaggerOrder, 0, 1); + _vec2[1] = staggerOrderReverse ? 1 - stagger : stagger; + } else _vec2[1] = count == 1 ? 0 : i / (count - 1); + (0, _vertexJs.UnitVertex).setOrder(dataView, index, _vec2); + (0, _vertexJs.UnitVertex).setMaterial(dataView, index, options.material ? options.material : options.materials ? options.materials[id] : 0); + (0, _vertexJs.UnitVertex).setRounding(dataView, index, options.rounding ? options.rounding * this._boundsScaling : options.roundings ? options.roundings[id] * this._boundsScaling : 0); + (0, _vertexJs.UnitVertex).setSdfBuffer(dataView, index, options.sdfBuffer ? options.sdfBuffer : options.sdfBuffers ? options.sdfBuffers[id] : this._core.config.sdfBuffer); + (0, _vertexJs.UnitVertex).setSdfBorder(dataView, index, options.sdfBorder ? options.sdfBorder : options.sdfBorders ? options.sdfBorders[id] : this._core.config.sdfBorder); } - this._gl.disable(this._gl.CULL_FACE); - const size = axes.size; - const axisId2 = 0; - const axisId3 = 1; - const width1 = size[axisId2]; - const height1 = size[axisId3]; - gridShader.zero = axes.gridFaceZero; - gridShader.minorGridlines = axes.gridFaceMinorGridlines; - for(let face = 0; face < 2; face++){ - const faceId = face; - if (axes.getIsForwardFace(faceId)) this._renderGridFace(faceId, width1, height1); - } - this._gl.enable(this._gl.CULL_FACE); - } - _renderGridTicks(axisId, edgeId, width, height) { - const axes = this._axes; - const gridShader = this._main.gridShader; - const shaderResources = this._main.shaderResources; - gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); - gridShader.faceWidth = width; - gridShader.faceHeight = height; - gridShader.ApplyFace(); - gridShader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - gridShader.vMatrix = this.vMatrices[viewport]; - gridShader.pMatrix = this.pMatrices[viewport]; - gridShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); - } - if (this.isPickingEnabled && axes.isDivisionPickingEnabled[axisId]) { - gridShader.isPickShader = true; - gridShader.vMatrix = this.pickVMatrix; - gridShader.pMatrix = this.pickPMatrix; - gridShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, this._axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, this._axes.getGridTicksIndexOffset(axisId) * 2); - } - } - _renderGridFace(faceId, width, height) { - const axes = this._axes; - const gridShader = this._main.gridShader; - const shaderResources = this._main.shaderResources; - gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); - gridShader.faceWidth = width; - gridShader.faceHeight = height; - gridShader.ApplyFace(); - gridShader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - gridShader.vMatrix = this.vMatrices[viewport]; - gridShader.pMatrix = this.pMatrices[viewport]; - gridShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); - } - if (this.isPickingEnabled && axes.isGridPickingEnabled) { - gridShader.isPickShader = true; - gridShader.vMatrix = this.pickVMatrix; - gridShader.pMatrix = this.pickPMatrix; - gridShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); - } + buffer.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this.constructor.name.toLowerCase()} update ${ids.length} ${Math.round(window.performance.now() - start)}ms`); } } -},{"./axes.js":"h2UKw","../../../../main.js":"1Kju3","../../../../constants.js":"2Scl5","../../../../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"h2UKw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../constants.js":"lD0bG","../helpers/math.js":"f65d0","../vertex.js":"4J2YE","./treemap.js":"1HzJp","./layout.js":"kYBiT","gl-matrix":"5x28d","../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"flmwt":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Keyboard", ()=>(0, _keyboardJs.Keyboard)); +parcelHelpers.export(exports, "MouseWheel", ()=>(0, _mousewheelJs.MouseWheel)); +parcelHelpers.export(exports, "Pointers", ()=>(0, _pointersJs.Pointers)); +parcelHelpers.export(exports, "Manipulator", ()=>(0, _manipulatorJs.Manipulator)); +parcelHelpers.export(exports, "ManipulationProcessor", ()=>(0, _manipulationprocessorJs.ManipulationProcessor)); +parcelHelpers.export(exports, "Manager", ()=>(0, _managerJs.Manager)); +var _keyboardJs = require("./keyboard.js"); +var _mousewheelJs = require("./mousewheel.js"); +var _pointersJs = require("./pointers.js"); +var _manipulatorJs = require("./manipulator.js"); +var _manipulationprocessorJs = require("./manipulationprocessor.js"); +var _managerJs = require("./manager.js"); + +},{"./keyboard.js":"fXys0","./mousewheel.js":"dfHmP","./pointers.js":"7LFJO","./manipulator.js":"bYqKJ","./manipulationprocessor.js":"20HDq","./manager.js":"8nDg6","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hACG3":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LocalFile", ()=>(0, _fileJs.LocalFile)); +parcelHelpers.export(exports, "XmlHttp", ()=>(0, _xmlHttpJs.XmlHttp)); +var _fileJs = require("./file.js"); +var _xmlHttpJs = require("./xmlHttp.js"); + +},{"./file.js":"kwLAM","./xmlHttp.js":"49880","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kwLAM":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "AxesVisualBase", ()=>AxesVisualBase); -class AxesVisualBase { - get isInitialized() { - return this._isInitialized; - } - get axes() { - return this._axes; - } - constructor(core){ - this._core = core; - this.isVisible = true; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LocalFile", ()=>LocalFile); +class LocalFile { + constructor(core){} + loadText(file, completed, failed) { + const reader = new FileReader(); + reader.onload = (event)=>{ + const text = event.target.result; + completed(text); + }; + reader.onerror = (event)=>{ + const error = event.target.error; + failed(error.message); + }; + reader.readAsText(file); } - initializeContext(gl) { - this._gl = gl; + loadImage(file, completed, failed) { + const image = new Image(); + image.onload = ()=>completed(image); + image.onerror = (event)=>{ + const error = event.message; + failed(error); + }; + const reader = new FileReader(); + reader.onload = (event)=>{ + const text = event.target.result; + image.src = text; + }; + reader.onerror = (event)=>{ + const error = event.target.error; + failed(error.message); + }; + reader.readAsDataURL(file); } - update(elapsedTime) {} - render(elapsedTime, xrFrame) { - if (this.isInitialized) { - this._renderGrid(); - this._renderText(); - } + loadArrayBuffer(file, completed, failed) { + const reader = new FileReader(); + reader.onload = (event)=>{ + const arrayBuffer = event.target.result; + completed(arrayBuffer); + }; + reader.onerror = (event)=>{ + const error = event.target.error; + failed(error.message); + }; + reader.readAsArrayBuffer(file); } - _renderGrid() {} - _renderText() {} } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jewgl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cartesian3dVisual", ()=>Cartesian3dVisual); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"49880":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _axesJs = require("./axes.js"); -var _mainJs = require("../../../../main.js"); -var _constantsJs = require("../../../../constants.js"); -var _cubeJs = require("../../../../meshes/cube.js"); -class Cartesian3dVisual extends (0, _axesJs.AxesVisualBase) { - get isInitialized() { - return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; - } - constructor(core, main, cartesian3dAxes){ - super(core); - this._main = main; - this._axes = cartesian3dAxes; - this._axes.hasChangedCallback = ()=>{ - this._hasChanged = true; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "XmlHttp", ()=>XmlHttp); +class XmlHttp { + constructor(core){} + loadText(url, completed, failed) { + const request = new XMLHttpRequest(); + request.open("GET", url); + request.onreadystatechange = ()=>{ + if (request.readyState == XMLHttpRequest.DONE) switch(request.status){ + case 200: + completed(request.responseText); + break; + default: + failed(request.statusText); + break; + } }; + request.send(); } - initializeContext(gl) { - super.initializeContext(gl); - const axes = this._axes; - if (!axes.isInitialized) axes.initialize(); - if (axes.gridVertices) this._createGridBuffers(); - if (axes.textVertices) this._createTextBuffers(); - this._isInitialized = true; + loadImage(url, completed, failed) { + const image = new Image(); + image.onload = ()=>completed(image); + image.onerror = (event)=>{ + const error = event.message; + failed(error); + }; + image.src = url; } - _createGridBuffers() { - const axes = this._axes; - this._gridVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); - this._gridIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); - this._gridBufferSize = axes.gridVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers created`); + loadArrayBuffer(url, completed, failed) { + const request = new XMLHttpRequest(); + request.open("GET", url); + request.responseType = "arraybuffer"; + request.onreadystatechange = ()=>{ + if (request.readyState == XMLHttpRequest.DONE) switch(request.status){ + case 200: + completed(request.response); + break; + default: + failed(request.statusText); + break; + } + }; + request.send(); } - _createTextBuffers() { - const axes = this._axes; - this._textVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); - this._textIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); - this._textBufferSize = axes.textVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers created`); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6XXZT":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Quad", ()=>(0, _quadJs.Quad)); +parcelHelpers.export(exports, "Cube", ()=>(0, _cubeJs.Cube)); +parcelHelpers.export(exports, "Sphere", ()=>(0, _sphereJs.Sphere)); +var _quadJs = require("./quad.js"); +var _cubeJs = require("./cube.js"); +var _sphereJs = require("./sphere.js"); + +},{"./quad.js":"3PqJr","./cube.js":"79I5N","./sphere.js":"aj6T2","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1IHvF":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "RendererBase", ()=>(0, _rendererJs.RendererBase)); +parcelHelpers.export(exports, "Basic", ()=>_indexJs); +parcelHelpers.export(exports, "Advanced", ()=>_indexJs1); +parcelHelpers.export(exports, "RayTraceWebGPU", ()=>_indexJs2); +var _rendererJs = require("./renderer.js"); +var _indexJs = require("./basic/index.js"); +var _indexJs1 = require("./advanced/index.js"); +var _indexJs2 = require("./raytracewebgpu/index.js"); + +},{"./renderer.js":"8zmPQ","./basic/index.js":"fYCHg","./advanced/index.js":"gKCQy","./raytracewebgpu/index.js":"2SNte","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8zmPQ":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "RendererConfig", ()=>RendererConfig); +parcelHelpers.export(exports, "RendererBase", ()=>RendererBase); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../main.js"); +var _axesJs = require("../components/axes/axes.js"); +var _bufferJs = require("../buffer.js"); +var _vertexJs = require("../vertex.js"); +var _labelsJs = require("../components/labels.js"); +var _debugJs = require("../components/debug.js"); +var _controllerJs = require("../components/controller.js"); +var _imageJs = require("../components/image.js"); +var _fontJs = require("../font.js"); +var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); } - update(elapsedTime) { - if (this._hasChanged) { - this._hasChanged = false; - const axes = this._axes; - if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers updated`); + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); } - if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers updated`); + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); } - this._main.shaderResources.currentProgram = null; } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +class RendererConfig { + reset() {} +} +class RendererBase { + get isInitialized() { + return this._isInitialized; } - _renderText() { - const axes = this._axes; - const shader = this._main.sdfTextShader; - const shaderResources = this._main.shaderResources; - const fontVisual = this._main.fonts[axes.font.name]; - shader.vertexBuffer = this._textVertexBuffer; - shader.indexBuffer = this._textIndexBuffer; - shader.texture2D = fontVisual.texture; - shader.prepare(); - shader.buffer = fontVisual.font.edgeValue / 0xff; - shader.gamma = axes.gamma; - shader.borderWidth = axes.textBorderWidth; - shader.color = axes.textColor || this._core.config.axesTextColor; - shader.hoverColor = axes.textHoverColor || this._core.config.axesTextHoverColor; - shader.borderColor = axes.textBorderColor || this._core.config.textBorderColor; - shader.pickedIdColor = this.pickedIdColor; - shader.apply(); - let indexCount, indexOffset; - for(let axisId = 0; axisId < 3; axisId++){ - const orientation = axes.getLabelOrientation(axisId); - for(let edge = 0; edge < 4; edge++){ - const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; - if (axes.getIsOutsideEdge(edgeId)) { - if (axes.isEdgeVisible[edgeId]) { - if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { - indexCount = axes.getAxesLeftToRightIndexCount(axisId); - indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); - } else { - indexCount = axes.getAxesRightToLeftIndexCount(axisId); - indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); - } - if (indexCount > 0) { - shader.mMatrix = axes.getLabelMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - shader.vMatrix = this.vMatrices[viewport]; - shader.pMatrix = this.pMatrices[viewport]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - indexCount = axes.getTitleIndexCount(axisId); - if (indexCount > 0) { - indexOffset = axes.getTitleIndexOffset(axisId); - shader.mMatrix = axes.getTitleMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - for(let i1 = 0; i1 < this.viewportCount; i1++){ - const viewport1 = i1 + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport1]); - this._gl.viewport(this.viewports[viewport1].x, this.viewports[viewport1].y, this.viewports[viewport1].width, this.viewports[viewport1].height); - shader.vMatrix = this.vMatrices[viewport1]; - shader.pMatrix = this.pMatrices[viewport1]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - } - indexCount = axes.getHeadingIndexCount(axisId); - if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { - indexOffset = axes.getHeadingIndexOffset(axisId); - shader.mMatrix = axes.getHeadingMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - for(let i2 = 0; i2 < this.viewportCount; i2++){ - const viewport2 = i2 + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport2]); - this._gl.viewport(this.viewports[viewport2].x, this.viewports[viewport2].y, this.viewports[viewport2].width, this.viewports[viewport2].height); - shader.vMatrix = this.vMatrices[viewport2]; - shader.pMatrix = this.pMatrices[viewport2]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - } - } - } - } - _renderGrid() { - const axes = this._axes; - const gridShader = this._main.gridShader; - gridShader.vertexBuffer = this._gridVertexBuffer; - gridShader.indexBuffer = this._gridIndexBuffer; - gridShader.prepare(); - gridShader.majorThickness = axes.gridMajorThickness; - gridShader.minorThickness = axes.gridMinorThickness; - gridShader.zeroThickness = axes.gridZeroThickness; - gridShader.backgroundColor = axes.gridBackgroundColor || this._core.config.axesGridBackgroundColor; - gridShader.highlightColor = axes.gridHighlightColor || this._core.config.axesGridHighlightColor; - gridShader.majorColor = axes.gridMajorColor || this._core.config.axesGridMajorColor; - gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; - gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; - gridShader.pickedIdColor = this.pickedIdColor; - gridShader.directionToLight = (0, _constantsJs.Constants).VECTOR3_UNITZ; - gridShader.apply(); - for(let axisId = 0; axisId < 3; axisId++)if (axes.arePickDivisionsVisible[axisId]) { - const gridTicksScale = axes.getGridTicksScale(axisId); - const width = gridTicksScale[0]; - const height = gridTicksScale[1]; - gridShader.zero = axes.getGridTicksZero(axisId); - gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); - for(let edge = 0; edge < 4; edge++){ - const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; - if (axes.getIsOutsideEdge(edgeId) && axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); - } - } - this._gl.disable(this._gl.CULL_FACE); - const size = axes.size; - for(let axisId1 = 0; axisId1 < 3; axisId1++)if (axes.areFacesVisible[axisId1]) { - const axisId2 = axisId1 == 0 ? 1 : 0; - const axisId3 = axisId1 == 2 ? 1 : 2; - const width1 = size[axisId2]; - const height1 = size[axisId3]; - gridShader.zero = axes.getGridFaceZero(axisId1); - gridShader.minorGridlines = axes.getGridFaceMinorGridlines(axisId1); - for(let face = 0; face < 2; face++){ - const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId1][face]; - if (axes.getIsForwardFace(faceId) && axes.isFaceVisible[faceId]) this._renderGridFace(faceId, width1, height1); - } - } - this._gl.enable(this._gl.CULL_FACE); + get config() { + return this._config; } - _renderGridTicks(axisId, edgeId, width, height) { - const axes = this._axes; - const gridShader = this._main.gridShader; - const shaderResources = this._main.shaderResources; - gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); - gridShader.faceWidth = width; - gridShader.faceHeight = height; - gridShader.ApplyFace(); - gridShader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - gridShader.vMatrix = this.vMatrices[viewport]; - gridShader.pMatrix = this.pMatrices[viewport]; - gridShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); - } - if (this.isPickingEnabled && axes.isDivisionPickingEnabled[axisId]) { - gridShader.isPickShader = true; - gridShader.vMatrix = this.pickVMatrix; - gridShader.pMatrix = this.pickPMatrix; - gridShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); - } + get devicePixelRatio() { + return this._devicePixelRatio; } - _renderGridFace(faceId, width, height) { - const axes = this._axes; - const gridShader = this._main.gridShader; - const shaderResources = this._main.shaderResources; - gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); - gridShader.faceWidth = width; - gridShader.faceHeight = height; - gridShader.ApplyFace(); - gridShader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - gridShader.vMatrix = this.vMatrices[viewport]; - gridShader.pMatrix = this.pMatrices[viewport]; - gridShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); - } - if (this.isPickingEnabled && axes.isGridPickingEnabled) { - gridShader.isPickShader = true; - gridShader.vMatrix = this.pickVMatrix; - gridShader.pMatrix = this.pickPMatrix; - gridShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); - } + get width() { + return this._canvas.width; } -} - -},{"./axes.js":"h2UKw","../../../../main.js":"1Kju3","../../../../constants.js":"2Scl5","../../../../meshes/cube.js":"7rTMs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ciHaP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ControllerVisual", ()=>ControllerVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _textureJs = require("../../../helpers/texture.js"); -var _constantsJs = require("../../../constants.js"); -class ControllerVisual { - get isInitialized() { - return this._isInitialized && this._modelShader.isInitialized && this._colorShader.isInitialized; + set width(value) { + this._options.width = value; } - get controller() { - return this._controller; + get height() { + return this._canvas.height; } - constructor(core, main, controller){ - this._core = core; - this._main = main; - this._mMatrix = (0, _glMatrix.mat4).create(); - this._vec3 = (0, _glMatrix.vec3).create(); - this._controller = controller; - this._modelShader = main.modelShader; - this._colorShader = main.colorShader; - this.mMatrix = (0, _glMatrix.mat4).create(); - this.rayMMatrix = (0, _glMatrix.mat4).create(); - this.isVisible = true; + set height(value) { + this._options.height = value; } - initializeContext(gl) { - if (!this._controller.isInitialized) this._controller.initialize(); - this._initialize(gl); + get webXRReferenceSpace() { + return this._webXRReferenceSpace; } - _initialize(gl) { - this._gl = gl; - this.modelTexture = (0, _textureJs.TextureHelper).fromImage(gl, this._controller.texture, false, gl.LINEAR); - this._modelVertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._modelVertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._controller.vertices, gl.STATIC_DRAW); - this._modelIndexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._modelIndexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._controller.indices, gl.STATIC_DRAW); - this._rayVertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._rayVertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._controller.rayVertices, gl.STATIC_DRAW); - this._rayIndexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._rayIndexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._controller.rayIndices, gl.STATIC_DRAW); - this._isInitialized = true; + get pickedType() { + return this._pickedType; } - update(elapsedTime) {} - render(elapsedTime, xrFrame) { - if (this.isInitialized) { - this._modelShader.vertexBuffer = this._modelVertexBuffer; - this._modelShader.indexBuffer = this._modelIndexBuffer; - this._modelShader.texture2D = this.modelTexture; - this._modelShader.prepare(); - (0, _glMatrix.mat4).multiply(this._mMatrix, this._controller.useRayPose ? this.rayMMatrix : this.mMatrix, this._controller.mMatrix); - this._modelShader.mMatrix = this._mMatrix; - this._modelShader.specularPower = 10; - this._modelShader.specularIntensity = 0.01; - this._modelShader.apply(); - this._modelShader.applyModel(); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - this._main.shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - this._modelShader.directionToLight = (0, _constantsJs.Constants).VECTOR3_UNITZ; - this._modelShader.halfAngle = (0, _constantsJs.Constants).VECTOR3_UNITZ; - this._modelShader.vMatrix = this.vMatrices[viewport]; - this._modelShader.pMatrix = this.pMatrices[viewport]; - this._modelShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._controller.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - if (this.isRayVisible) { - this._colorShader.vertexBuffer = this._rayVertexBuffer; - this._colorShader.indexBuffer = this._rayIndexBuffer; - this._colorShader.prepare(); - (0, _glMatrix.mat4).multiply(this._mMatrix, this.rayMMatrix, this._controller.rayMMatrix); - this._colorShader.mMatrix = this._mMatrix; - this._colorShader.apply(); - this._colorShader.applyModel(); - for(let i1 = 0; i1 < this.viewportCount; i1++){ - const viewport1 = i1 + this.viewportOffset; - this._main.shaderResources.bindFramebuffer(this.framebuffers[viewport1]); - this._gl.viewport(this.viewports[viewport1].x, this.viewports[viewport1].y, this.viewports[viewport1].width, this.viewports[viewport1].height); - this._colorShader.vMatrix = this.vMatrices[viewport1]; - this._colorShader.pMatrix = this.pMatrices[viewport1]; - this._colorShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLE_STRIP, this._controller.rayIndexCount, this._gl.UNSIGNED_SHORT, 0); - } - } - } + get pickedId() { + return this._pickedId; } -} - -},{"gl-matrix":"9GjEQ","../../../helpers/texture.js":"bUBAh","../../../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fpCMV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _textureJs = require("../../../helpers/texture.js"); -class ImageVisual { - get isInitialized() { - return this._isInitialized && this._main.textureShader.isInitialized; + get isCapturingPickImage() { + return this._isCapturingPickImage; } - get image() { - return this._image; + capturePickImage() { + this._isCapturingPickImage = true; } - constructor(core, main, image){ - this._core = core; - this._main = main; - this._image = image; - this._image.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - this.mMatrix = (0, _glMatrix.mat4).create(); - this.isVisible = true; + get backgroundColor() { + return this._backgroundColor; } - initializeContext(gl) { - if (!this._image.isInitialized) this._image.initialize(); - this._gl = gl; - if (this._image.imageData) this.texture = (0, _textureJs.TextureHelper).fromImage(gl, this._image.imageData, false, gl.LINEAR); - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._image.vertices, gl.STATIC_DRAW); - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._image.indices, gl.STATIC_DRAW); - this._isInitialized = true; + set backgroundColor(value) { + if (!(0, _glMatrix.vec4).exactEquals(value, this._backgroundColor)) this._backgroundColor = value; } - update(elapsedTime) { - if (this._hasChanged) { - this._hasChanged = false; - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._image.vertices); - this._main.shaderResources.currentProgram = null; - } + get currentAxes() { + return this._isAxes1Current ? this._axes1 : this._axes2; } - render(elapsedTime, xrFrame) { - if (this.isInitialized) { - const textureShader = this._main.textureShader; - const shaderResources = this._main.shaderResources; - textureShader.vertexBuffer = this._vertexBuffer; - textureShader.indexBuffer = this._indexBuffer; - textureShader.texture2D = this.texture; - textureShader.prepare(); - textureShader.mMatrix = this.mMatrix; - textureShader.isPickShader = false; - textureShader.apply(); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - textureShader.vMatrix = this.vMatrices[viewport]; - textureShader.pMatrix = this.pMatrices[viewport]; - textureShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._image.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - if (this.isPickingEnabled) { - textureShader.isPickShader = true; - textureShader.vMatrix = this.pickVMatrix; - textureShader.pMatrix = this.pickPMatrix; - textureShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, this._image.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - } + set currentAxes(value) { + if (this._isAxes1Current) this._axes1 = value; + else this._axes2 = value; } -} - -},{"gl-matrix":"9GjEQ","../../../helpers/texture.js":"bUBAh","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kba4Q":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LabelVisual", ()=>LabelVisual); -parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class LabelVisualBase { - get isInitialized() { - return this._isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._label.font.name].isInitialized; + get previousAxes() { + return this._isAxes1Current ? this._axes2 : this._axes1; } - constructor(core, main, label){ - this._core = core; - this._main = main; - this._label = label; - this._label.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - this._mMatrix = (0, _glMatrix.mat4).create(); - this.mMatrix = (0, _glMatrix.mat4).create(); - this.isVisible = true; + set previousAxes(value) { + if (this._isAxes1Current) this._axes2 = value; + else this._axes1 = value; } - initializeContext(gl) { - if (!this._label.isInitialized) this._label.initialize(); - this._gl = gl; - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._label.vertices, gl.STATIC_DRAW); - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._label.indices, gl.STATIC_DRAW); - this._isInitialized = true; + swapAxes() { + this._isAxes1Current = !this._isAxes1Current; } - update(elapsedTime) { - if (this._hasChanged) { - this._hasChanged = false; - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._label.vertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, this._label.indices); - this._main.shaderResources.currentProgram = null; - } + createCartesian2dAxesVisual(axes) { + return new (0, _axesJs.AxesVisual)(axes); } - render(elapsedTime, xrFrame) { - if (this.isInitialized) { - const indexCount = this._label.indexCount; - if (indexCount > 0) { - const shader = this._main.sdfTextShader; - const fontVisual = this._main.fonts[this._label.font.name]; - shader.vertexBuffer = this._vertexBuffer; - shader.indexBuffer = this._indexBuffer; - shader.texture2D = fontVisual.texture; - shader.prepare(); - shader.gamma = this._label.gamma; - shader.buffer = fontVisual.font.edgeValue / 0xff; - shader.borderWidth = this._label.borderWidth; - shader.color = this._label.color || this._core.config.textColor; - shader.borderColor = this._label.borderColor || this._core.config.textBorderColor; - shader.hoverColor = this._label.hoverColor || this._core.config.textHoverColor; - shader.pickedIdColor = this.pickedIdColor; - shader.apply(); - (0, _glMatrix.mat4).multiply(this._mMatrix, this.mMatrix, this._label.mMatrix); - shader.mMatrix = this._mMatrix; - shader.applyModel(); - shader.isPickShader = false; - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - this._main.shaderResources.bindFramebuffer(this.framebuffers[viewport]); - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - shader.vMatrix = this.vMatrices[viewport]; - shader.pMatrix = this.pMatrices[viewport]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, 0); - } - if (this.isPickingEnabled) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - this._main.shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, 0); - } - } - } + createCartesian3dAxesVisual(axes) { + return new (0, _axesJs.AxesVisual)(axes); } -} -class LabelVisual extends LabelVisualBase { - get label() { - return this._label; + _createDebugAxesVisual(debugAxes) { + return null; } - set text(value) { - this._label.text = value; + createLabelSetVisual(labelSet) { + return new (0, _labelsJs.LabelSetVisual)(labelSet); } - get text() { - return this._label.text; + createControllerVisual(controller) { + return new (0, _controllerJs.ControllerVisual)(controller); } - constructor(core, main, label){ - super(core, main, label); + createTransitionBuffer(ids) { + return new (0, _bufferJs.TransitionBuffer)(this._core, ids); } -} -class LabelSetVisual extends LabelVisualBase { - get label() { - return this._label; + createImageVisual(image) { + return new (0, _imageJs.ImageVisual)(image); } - constructor(core, main, label){ - super(core, main, label); + createFontVisual(font) { + return new (0, _fontJs.FontVisual)(font); } -} - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5ax1N":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _textureJs = require("../../helpers/texture.js"); -var _mainJs = require("../../main.js"); -class FontVisual { - get isInitialized() { - return this._isInitialized; + constructor(options){ + this._options = options; + this.fonts = {}; } - get font() { - return this._font; + get isWebXRSupported() { + return false; } - constructor(core, font){ + initialize(core) { this._core = core; - this._font = font; - font.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - } - initializeContext(gl) { - this._gl = gl; - this._isInitialized = true; - if (this._font.count > 0) this._hasChanged = true; - } - update() { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - this.texture = (0, _textureJs.TextureHelper).fromImage(this._gl, this._font.atlas.imageData, false, this._gl.LINEAR); - this._core.log.write((0, _mainJs.LogLevel).info, `${this._font.name} texture updated`); + this._canvas = document.createElement("canvas"); + const contextmenu = this._options && this._options.contextmenu; + if (!contextmenu) this._canvas.addEventListener("contextmenu", (e)=>{ + e.preventDefault(); + }); + this._canvas.tabIndex = this._core.container.tabIndex; + this._canvas.style.display = "block"; + this._canvas.style.touchAction = "none"; + this._core.container.appendChild(this._canvas); + this._mvMatrices = [ + (0, _glMatrix.mat4).create(), + (0, _glMatrix.mat4).create() + ]; + this.pickPMatrix = (0, _glMatrix.mat4).create(); + this.axesVisibility = (0, _mainJs.AxesVisibility).current; + this._debugAxes = new (0, _debugJs.DebugAxes)(); + this._debugAxesVisual = this._createDebugAxesVisual(this._debugAxes); + this.transitionTime = 1; + this.transitionBuffers = []; + this.areLabelsVisible = true; + this.labelSets = []; + this.controllers = []; + this.areImagesVisible = true; + this.images = []; + this._viewports = [ + new DOMRect(), + new DOMRect() + ]; + this.isPickingEnabled = false; + this._pickedType = (0, _mainJs.PickType).none; + this._pickedId = 0; + this._lassoMMatrix = (0, _glMatrix.mat4).create(); + this._lassoThickness = (0, _glMatrix.vec2).create(); + this._resizeMinimumDelay = -1; + this._previousResizeWidth = -1; + this._previousResizeHeight = -1; + } + remove() { + this._core.container.removeChild(this._canvas); + } + finalize() { + this._isInitialized = false; + } + setSize(elapsedTime) { + if (this._options && this._options.width && this._options.height) { + this._devicePixelRatio = 1; + this._resizeWidth = this._options.width; + this._resizeHeight = this._options.height; + } else { + this._devicePixelRatio = window.devicePixelRatio || 1; + this._resizeWidth = this._core.container.clientWidth * devicePixelRatio; + this._resizeHeight = this._core.container.clientHeight * devicePixelRatio; + } + if (this._resizeWidth != this._previousResizeWidth || this._resizeHeight != this._previousResizeHeight) { + this._previousResizeWidth = this._resizeWidth; + this._previousResizeHeight = this._resizeHeight; + this._isResizing = true; + this._resizeElapsedTime = elapsedTime; + } + if (this._isResizing) { + if (this._resizeElapsedTime > this._resizeMinimumDelay && this._isInitialized) { + this._isResizing = false; + this._resizeMinimumDelay = this._core.config.resizeMinimumDelay; + this._resize(this._resizeWidth, this._resizeHeight); + } else this._resizeElapsedTime += elapsedTime; + } + } + _resize(width, height) { + this._canvas.style.width = `${Math.floor(width / this._devicePixelRatio)}px`; + this._canvas.style.height = `${Math.floor(height / this._devicePixelRatio)}px`; + width = Math.floor(width); + height = Math.floor(height); + this._canvas.width = width; + this._canvas.height = height; + } + update(elapsedTime) { + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible) { + const previous = transitionBuffer.previousPalette; + const current = transitionBuffer.currentPalette; + if (previous) previous.update(); + if (current) current.update(); + } + } + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible) { + const previous = transitionBuffer.previousAtlas; + const current = transitionBuffer.currentAtlas; + if (previous) previous.update(); + if (current) current.update(); + } + } + if (this._core.config.isDebugVisible) { + if (this._debugAxesVisual) { + this._debugAxesVisual.mMatrix = this.mMatrix; + this._debugAxesVisual.vMatrices = this.vMatrices; + this._debugAxesVisual.pMatrices = this.pMatrices; + this._debugAxesVisual.viewports = this._viewports; + this._debugAxesVisual.viewportOffset = this._viewportOffset; + this._debugAxesVisual.viewportCount = this._viewportCount; + } + } + if (this.areLabelsVisible) for(let i = 0; i < this.labelSets.length; i++){ + const labelSetVisual = this.labelSets[i]; + if (labelSetVisual.isVisible) { + this.labelSets[i].label.update(elapsedTime); + labelSetVisual.mMatrix = this.mMatrix; + labelSetVisual.vMatrices = this.vMatrices; + labelSetVisual.pMatrices = this.pMatrices; + labelSetVisual.isPickingEnabled = this.isPickingEnabled; + labelSetVisual.pickPMatrix = this.pickPMatrix; + labelSetVisual.pickVMatrix = this.pickVMatrix; + labelSetVisual.viewports = this._viewports; + labelSetVisual.viewportOffset = this._viewportOffset; + labelSetVisual.viewportCount = this._viewportCount; + labelSetVisual.update(elapsedTime); + } + } + if (this.areImagesVisible) for(let i = 0; i < this.images.length; i++){ + const imageVisual = this.images[i]; + if (imageVisual && imageVisual.isVisible) { + const image = this.images[i].image; + image.update(elapsedTime); + imageVisual.mMatrix = this.mMatrix; + imageVisual.vMatrices = this.vMatrices; + imageVisual.pMatrices = this.pMatrices; + imageVisual.isPickingEnabled = this.isPickingEnabled; + imageVisual.pickPMatrix = this.pickPMatrix; + imageVisual.pickVMatrix = this.pickVMatrix; + imageVisual.viewports = this._viewports; + imageVisual.viewportOffset = this._viewportOffset; + imageVisual.viewportCount = this._viewportCount; + imageVisual.update(elapsedTime); + } + } + for(let i = 0; i < this.controllers.length; i++){ + const controllerVisual = this.controllers[i]; + if (controllerVisual.isVisible) { + const controller = this.controllers[i].controller; + controller.update(elapsedTime); + controllerVisual.vMatrices = this.vMatrices; + controllerVisual.inverseVMatrices = this.vMatrices; + controllerVisual.pMatrices = this.pMatrices; + controllerVisual.viewports = this._viewports; + controllerVisual.viewportOffset = this._viewportOffset; + controllerVisual.viewportCount = this._viewportCount; + controllerVisual.update(elapsedTime); + } + } + const axesVisuals = this.axesVisibility == (0, _mainJs.AxesVisibility).current ? this.currentAxes : this.axesVisibility == (0, _mainJs.AxesVisibility).previous ? this.previousAxes : null; + if (axesVisuals) for(let i = 0; i < axesVisuals.length; i++){ + const axesVisual = axesVisuals[i]; + if (axesVisual.isVisible) { + const axes = axesVisual.axes; + axes.mMatrix = this.mMatrix; + axes.vMatrix = this.vMatrices[0]; + axes.update(elapsedTime); + axesVisual.vMatrices = this.vMatrices; + axesVisual.pMatrices = this.pMatrices; + axesVisual.isPickingEnabled = this.isPickingEnabled; + axesVisual.pickPMatrix = this.pickPMatrix; + axesVisual.pickVMatrix = this.pickVMatrix; + axesVisual.viewports = this._viewports; + axesVisual.viewportOffset = this._viewportOffset; + axesVisual.viewportCount = this._viewportCount; + axesVisual.update(elapsedTime); + } } + for(const key in this.fonts){ + const fontVisual = this.fonts[key]; + const font = fontVisual.font; + font.update(); + fontVisual.update(); + } + } + getVertexPosition(position, pickedId) { + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + const id = transitionBuffer.pickIdLookup[pickedId]; + if (id > -1) { + const index = transitionBuffer.currentBuffer.lookup[id]; + const dataView = transitionBuffer.currentBuffer.dataView; + (0, _vertexJs.UnitVertex).getTranslation(dataView, index, position); + break; + } + } + } + render(elapsedTime, xrFrame) { + return __awaiter(this, void 0, void 0, function*() {}); + } + prepare(xrFrame) {} + initializeWebXR(session) { + return null; } } -},{"../../helpers/texture.js":"bUBAh","../../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"46fmv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Lasso", ()=>Lasso); +},{"gl-matrix":"5x28d","../main.js":"f421K","../components/axes/axes.js":"8Tmim","../buffer.js":"itbJk","../vertex.js":"4J2YE","../components/labels.js":"PwNrz","../components/debug.js":"bBVbT","../components/controller.js":"f5tIG","../components/image.js":"kwtZG","../font.js":"ibkbS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"itbJk":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _constantsJs = require("../../../constants.js"); -var _quadJs = require("../../../meshes/quad.js"); -class Lasso { + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "BufferBase", ()=>BufferBase); +parcelHelpers.export(exports, "TransitionBufferBase", ()=>TransitionBufferBase); +parcelHelpers.export(exports, "Buffer", ()=>Buffer); +parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("./constants.js"); +var _paletteJs = require("./palette.js"); +var _vertexJs = require("./vertex.js"); +var _pickJs = require("./helpers/pick.js"); +var _mainJs = require("./main.js"); +var _atlasJs = require("./atlas.js"); +class BufferBase { get isInitialized() { return this._isInitialized; } - get vertexBuffer() { - return this._vertexBuffer; + get ids() { + return this._ids; } - get indexBuffer() { - return this._indexBuffer; + get dataView() { + return this._dataView; + } + get vertices() { + return this._vertices; + } + get lookup() { + return this._lookup; + } + get length() { + return this._length; + } + get selected() { + return this._selected; + } + constructor(core, ids){ + this._core = core; + this._ids = ids; + this._length = ids.length; + this._vertices = new ArrayBuffer(this._length * (0, _vertexJs.UnitVertex).SIZE_BYTES); + this._dataView = new DataView(this._vertices); + this._selected = new Set(); + this.from = 0; + this.to = 1; + this.unitType = (0, _mainJs.UnitType).block; + this._lookup = {}; + for(let i = 0; i < this._length; i++){ + const id = ids[i]; + this._lookup[id] = i; + (0, _vertexJs.UnitVertex).setRotation(this._dataView, i, (0, _constantsJs.Constants).QUAT_IDENTITY); + } + } + createShared() { + const buffer = Object.create(this); + buffer._vertices = new ArrayBuffer(buffer._vertices.byteLength); + buffer._dataView = new DataView(buffer._vertices); + return buffer; + } + copyFrom(buffer) { + const start = window.performance.now(); + const fromDataView = buffer.dataView; + const toDataView = this._dataView; + const lookup = buffer.lookup; + for(let i = 0; i < this._length; i++){ + const index = lookup[this._ids[i]]; + if (index != null) { + (0, _vertexJs.UnitVertex).copyIdHover(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyTranslation(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyScale(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyRotation(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyColor(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copySelected(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyMaterial(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyRounding(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyOrder(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyTexCoord(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyTexture(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copySdfBuffer(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copySdfBorder(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyParameter1(fromDataView, index, toDataView, i); + (0, _vertexJs.UnitVertex).copyParameter2(fromDataView, index, toDataView, i); + } else (0, _vertexJs.UnitVertex).setRotation(toDataView, i, (0, _constantsJs.Constants).QUAT_IDENTITY); + } + this.unitType = buffer.unitType; + this._selected = buffer.selected; + this._core.log.write((0, _mainJs.LogLevel).info, `buffer copied ${this._length} ${Math.round(window.performance.now() - start)}ms`); + } + update() {} + updateSelection(options) { + const start = window.performance.now(); + const ids = options && options.ids ? options.ids : this._ids; + const offset = options && options.offset !== undefined ? options.offset : 0; + const count = options && options.count !== undefined ? options.count : ids.length; + const selection = this._selected.size > 0; + const dataView = this._dataView; + for(let i = 0; i < count; i++){ + const id = ids[i + offset]; + const index = this._lookup[id]; + (0, _vertexJs.UnitVertex).setSelected(dataView, index, selection ? this._selected.has(id) ? 1 : -1 : 0); + } + this.update(); + this._core.log.write((0, _mainJs.LogLevel).info, `buffer update selection ${count} ${Math.round(window.performance.now() - start)}ms`); + } +} +class TransitionBufferBase { + get pickIdLookup() { + return this._pickIdLookup; + } + get currentBuffer() { + return this._isBuffer1Current ? this._buffer1 : this._buffer2; + } + get previousBuffer() { + return this._isBuffer1Current ? this._buffer2 : this._buffer1; + } + get currentPalette() { + return this._isBuffer1Current ? this._palette1 : this._palette2; + } + get previousPalette() { + return this._isBuffer1Current ? this._palette2 : this._palette1; + } + get currentAtlas() { + return this._isBuffer1Current ? this._atlas1 : this._atlas2; + } + get previousAtlas() { + return this._isBuffer1Current ? this._atlas2 : this._atlas1; + } + get isInitialized() { + return this._isInitialized; + } + get length() { + return this._length; + } + constructor(core, ids, bufferType, paletteType, atlasType){ + this.bufferType = bufferType; + this.paletteType = paletteType; + this.atlasType = atlasType; + this._core = core; + this._length = ids.length; + this.id = TransitionBufferBase._id++; + this.isVisible = true; + this.transitionTime = 1; + this.activeId = -1; + const start = window.performance.now(); + this._buffer1 = new bufferType(core, ids); + this._buffer2 = this._buffer1.createShared(); + this._palette1 = new paletteType(); + this._palette2 = new paletteType(); + this._atlas1 = new atlasType(); + this._atlas2 = new atlasType(); + this.isPickingEnabled = true; + this._pickIdLookup = {}; + const dataView1 = this._buffer1.dataView; + const dataView2 = this._buffer2.dataView; + const _vec4 = (0, _glMatrix.vec4).create(); + for(let i = 0; i < this._length; i++){ + const id = ids[i]; + const pickId = (0, _pickJs.PickHelper).nextPickId(); + this._pickIdLookup[pickId] = id; + (0, _pickJs.PickHelper).encodeNumber(pickId, (0, _mainJs.PickType).data, _vec4); + (0, _vertexJs.UnitVertex).setIdColor(dataView1, i, _vec4); + (0, _vertexJs.UnitVertex).setIdColor(dataView2, i, _vec4); + } + this._core.log.write((0, _mainJs.LogLevel).info, `transition buffer created ${this._length} ${Math.round(window.performance.now() - start)}ms`); + } + swap() { + this._isBuffer1Current = !this._isBuffer1Current; + } + copyFrom(transitionBuffer) { + const start = window.performance.now(); + this.key = transitionBuffer.key; + this.isVisible = transitionBuffer.isVisible; + this.transitionTime = transitionBuffer.transitionTime; + this.isPickingEnabled = transitionBuffer.isPickingEnabled; + this.unitType = transitionBuffer.unitType; + this.activeId = transitionBuffer.activeId; + this.currentBuffer.copyFrom(transitionBuffer.currentBuffer); + this.previousBuffer.copyFrom(transitionBuffer.previousBuffer); + this.currentBuffer.update(); + this.previousBuffer.update(); + this.currentPalette.copyFrom(transitionBuffer.currentPalette); + this.previousPalette.copyFrom(transitionBuffer.previousPalette); + this.currentAtlas.copyFrom(transitionBuffer.currentAtlas); + this.previousAtlas.copyFrom(transitionBuffer.previousAtlas); + this._core.log.write((0, _mainJs.LogLevel).info, `transition buffer copied ${this._length} ${Math.round(window.performance.now() - start)}ms`); + } +} +TransitionBufferBase._id = 1; +class Buffer extends BufferBase { + constructor(core, ids){ + super(core, ids); + } +} +class TransitionBuffer extends TransitionBufferBase { + constructor(core, ids){ + super(core, ids, Buffer, (0, _paletteJs.Palette), (0, _atlasJs.Atlas)); + } +} + +},{"gl-matrix":"5x28d","./constants.js":"lD0bG","./palette.js":"hZb65","./vertex.js":"4J2YE","./helpers/pick.js":"1t2sb","./main.js":"f421K","./atlas.js":"2peXi","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2peXi":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AtlasBase", ()=>AtlasBase); +parcelHelpers.export(exports, "Atlas", ()=>Atlas); +class AtlasBase { + get imageData() { + return this._imageData; + } + set imageData(value) { + if (this._imageData != value) { + this._imageData = value; + this._changed = true; + } + } + constructor(){ + this._imageData = null; + } + copyFrom(atlas) { + if (atlas.imageData) { + this._imageData = atlas.imageData; + this._changed = true; + } else this.imageData = null; + } + update() {} +} +class Atlas extends AtlasBase { +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bBVbT":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DebugAxes", ()=>DebugAxes); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _cubeJs = require("../meshes/cube.js"); +var _vertexJs = require("../vertex.js"); +class DebugAxes { + get vertices() { + return this._vertices; + } + get indices() { + return this._indices; } get indexCount() { return this._indexCount; } - initializeContext(gl) { - const vertices = (0, _quadJs.Quad).textured((0, _constantsJs.Constants).MAT4_IDENTITY); - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); - const indices = (0, _quadJs.Quad).INDICES; - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); - this._indexCount = indices.length; + get isInitialized() { + return this._isInitialized; + } + initialize() { + let vertexOffset = 0; + let indexOffset = 0; + const axisVertices = (0, _cubeJs.Cube).POSITIONS; + const axisIndices = (0, _cubeJs.Cube).INDICES; + this._vertices = new ArrayBuffer(3 * (0, _vertexJs.PositionColorVertex).SIZE_BYTES * axisVertices.length / (0, _vertexJs.PositionVertex).SIZE); + const verticesView = new DataView(this._vertices); + this._indices = new Uint16Array(3 * axisIndices.length + 4); + const vertexCount = axisVertices.length / (0, _vertexJs.PositionVertex).SIZE; + const indexCount = axisIndices.length; + const transform = (0, _glMatrix.mat4).create(); + const length = 1; + const width = 0.01; + transform[0] = length; + transform[5] = width; + transform[10] = width; + transform[12] = 0.5; + transform[13] = 0; + transform[14] = 0; + this._createAxis(axisVertices, axisIndices, verticesView, this._indices, (0, _constantsJs.Constants).VECTOR3_UNITX, transform, vertexOffset, indexOffset); + indexOffset += indexCount; + this._indices[indexOffset++] = axisIndices[indexCount - 1] + vertexOffset; + vertexOffset += vertexCount; + this._indices[indexOffset++] = axisIndices[0] + vertexOffset; + transform[0] = width; + transform[5] = length; + transform[10] = width; + transform[12] = 0; + transform[13] = 0.5; + transform[14] = 0; + this._createAxis(axisVertices, axisIndices, verticesView, this._indices, (0, _constantsJs.Constants).VECTOR3_UNITY, transform, vertexOffset, indexOffset); + indexOffset += indexCount; + this._indices[indexOffset++] = axisIndices[indexCount - 1] + vertexOffset; + vertexOffset += vertexCount; + this._indices[indexOffset++] = axisIndices[0] + vertexOffset; + transform[0] = width; + transform[5] = width; + transform[10] = length; + transform[12] = 0; + transform[13] = 0; + transform[14] = 0.5; + this._createAxis(axisVertices, axisIndices, verticesView, this._indices, (0, _constantsJs.Constants).VECTOR3_UNITZ, transform, vertexOffset, indexOffset); + this._indexCount = this._indices.length; this._isInitialized = true; } + update(elapsedTime) {} + _createAxis(axisVertices, axisIndices, verticesView, indices, color, transform, vertexOffset, indexOffset) { + const position = (0, _glMatrix.vec3).create(); + const vertexCount = axisVertices.length / (0, _vertexJs.PositionVertex).SIZE; + const indexCount = axisIndices.length; + for(let i = 0; i < vertexCount; i++){ + (0, _glMatrix.vec3).set(position, axisVertices[i * (0, _vertexJs.PositionVertex).SIZE], axisVertices[i * (0, _vertexJs.PositionVertex).SIZE + 1], axisVertices[i * (0, _vertexJs.PositionVertex).SIZE + 2]); + (0, _glMatrix.vec3).transformMat4(position, position, transform); + (0, _vertexJs.PositionColorVertex).setPosition(verticesView, vertexOffset + i, position); + (0, _vertexJs.PositionColorVertex).setColor(verticesView, vertexOffset + i, color); + } + for(let i = 0; i < indexCount; i++)indices[indexOffset + i] = axisIndices[i] + vertexOffset; + } } -},{"../../../constants.js":"2Scl5","../../../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fgt6s":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","../meshes/cube.js":"79I5N","../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fYCHg":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Main", ()=>(0, _mainJs.Main)); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Main", ()=>(0, _mainJs.Main)); var _mainJs = require("./main.js"); -},{"./main.js":"hZPBg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hZPBg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Main", ()=>Main); +},{"./main.js":"eZSaZ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eZSaZ":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Main", ()=>Main); +var _glMatrix = require("gl-matrix"); var _mainJs = require("../../main.js"); var _rendererJs = require("../renderer.js"); var _quadJs = require("./components/quad.js"); var _bufferJs = require("./buffer.js"); var _configJs = require("./config.js"); var _shaderJs = require("./shaders/shader.js"); +var _colorJs = require("./shaders/color.js"); var _textureJs = require("./shaders/texture.js"); var _lassoJs = require("./shaders/lasso.js"); +var _modelJs = require("./shaders/model.js"); var _sdftextJs = require("./shaders/sdftext.js"); var _pickgridJs = require("./shaders/pickgrid.js"); var _unitblockJs = require("./shaders/unitblock.js"); var _unitsphereJs = require("./shaders/unitsphere.js"); var _unitcylinderJs = require("./shaders/unitcylinder.js"); +var _unithexprismJs = require("./shaders/unithexprism.js"); var _unitsdfJs = require("./shaders/unitsdf.js"); -var _backgroundJs = require("./shaders/background.js"); -var _ssaoJs = require("./shaders/ssao.js"); -var _boxJs = require("./shaders/box.js"); -var _deferredJs = require("./shaders/deferred.js"); -var _combineJs = require("./shaders/combine.js"); -var _dofblurJs = require("./shaders/dofblur.js"); -var _downsampleJs = require("./shaders/downsample.js"); -var _gaussianJs = require("./shaders/gaussian.js"); -var _dofcombineJs = require("./shaders/dofcombine.js"); -var _fxaaJs = require("./shaders/fxaa.js"); -var _brightJs = require("./shaders/bright.js"); -var _angleJs = require("../../helpers/angle.js"); +var _anaglyphJs = require("./shaders/anaglyph.js"); +var _textureJs1 = require("../../helpers/texture.js"); var _pickJs = require("../../helpers/pick.js"); +var _debugJs = require("./components/debug.js"); var _cartesian2DJs = require("./components/axes/cartesian2d.js"); var _cartesian3DJs = require("./components/axes/cartesian3d.js"); -var _fontJs = require("./font.js"); -var _mathJs = require("./../../helpers/math.js"); -var _constantsJs = require("../../constants.js"); +var _controllerJs = require("./components/controller.js"); +var _imageJs = require("./components/image.js"); var _vertexJs = require("../../vertex.js"); -var _textureJs1 = require("../../helpers/texture.js"); var _labelsJs = require("./components/labels.js"); -var _imageJs = require("./components/image.js"); +var _fontJs = require("./font.js"); var _lassoJs1 = require("./components/lasso.js"); +var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; class Main extends (0, _rendererJs.RendererBase) { get shaderResources() { return this._shaderResources; } + get colorShader() { + return this._colorShader; + } get textureShader() { return this._textureShader; } get lassoShader() { return this._lassoShader; } + get modelShader() { + return this._modelShader; + } get sdfTextShader() { return this._sdfTextShader; } @@ -30263,9 +28058,15 @@ class Main extends (0, _rendererJs.RendererBase) { get cyclinderShader() { return this._cylinderShader; } + get hexPrismShader() { + return this._hexPrismShader; + } get sdfShader() { return this._sdfShader; } + get anaglyphShader() { + return this._anaglyphShader; + } get currentAxes() { return this._isAxes1Current ? this._axes1 : this._axes2; } @@ -30290,47 +28091,44 @@ class Main extends (0, _rendererJs.RendererBase) { this._lasso = new (0, _lassoJs1.Lasso)(); this._pickedPixels = new Uint8Array(4); this._pickedIdColor = (0, _glMatrix.vec4).create(); - this._position = (0, _glMatrix.vec3).create(); - this._direction = (0, _glMatrix.vec3).create(); - this._cameraRotation = (0, _glMatrix.mat3).create(); + this._mat3 = (0, _glMatrix.mat3).create(); + this._directionToCamera = (0, _glMatrix.vec3).create(); + this._directionToLight = (0, _glMatrix.vec3).create(); + this._halfAngle = (0, _glMatrix.vec3).create(); this._cameraPosition = (0, _glMatrix.vec3).create(); this._modelPosition = (0, _glMatrix.vec3).create(); - this._modelManipulationOrigin = (0, _glMatrix.vec3).create(); - this._shadowVMatrix = (0, _glMatrix.mat4).create(); - this._shadowPMatrix = (0, _glMatrix.mat4).create(); + this.depthEnabled = true; } get isSupported() { return this._createContext(document.createElement("canvas")) !== null; } + get isWebXRSupported() { + return true; + } initialize(core) { super.initialize(core); this._shaderResources = new (0, _shaderJs.Resources)(); - this._textureShader = new (0, _textureJs.Texture)(core, this); - this._lassoShader = new (0, _lassoJs.Lasso)(core, this); - this._sdfTextShader = new (0, _sdftextJs.SdfText)(core, this); - this._gridShader = new (0, _pickgridJs.PickGrid)(core, this); - this._blockShader = new (0, _unitblockJs.UnitBlock)(core, this); - this._sphereShader = new (0, _unitsphereJs.UnitSphere)(core, this); - this._cylinderShader = new (0, _unitcylinderJs.UnitCylinder)(core, this); - this._sdfShader = new (0, _unitsdfJs.UnitSdf)(core, this); - this._backgroundShader = new (0, _backgroundJs.Background)(core, this); - this._ssaoShader = new (0, _ssaoJs.Ssao)(core, this); - this._boxShader = new (0, _boxJs.Box)(core, this); - this._deferredShader = new (0, _deferredJs.Deferred)(core, this); - this._combineShader = new (0, _combineJs.Combine)(core, this); - this._dofBlurShader = new (0, _dofblurJs.DofBlur)(core, this); - this._downsampleShader = new (0, _downsampleJs.Downsample)(core, this); - this._gaussianShader = new (0, _gaussianJs.Gaussian)(core, this); - this._dofCombineShader = new (0, _dofcombineJs.DofCombine)(core, this); - this._fxaaShader = new (0, _fxaaJs.Fxaa)(core, this); - this._brightPassShader = new (0, _brightJs.Bright)(core, this); + this._colorShader = new (0, _colorJs.Color)(this._core, this); + this._textureShader = new (0, _textureJs.Texture)(this._core, this); + this._lassoShader = new (0, _lassoJs.Lasso)(this._core, this); + this._modelShader = new (0, _modelJs.Model)(this._core, this); + this._sdfTextShader = new (0, _sdftextJs.SdfText)(this._core, this); + this._gridShader = new (0, _pickgridJs.PickGrid)(this._core, this); + this._anaglyphShader = new (0, _anaglyphJs.Anaglyph)(this._core, this); + this._blockShader = new (0, _unitblockJs.UnitBlock)(this._core, this); + this._sphereShader = new (0, _unitsphereJs.UnitSphere)(this._core, this); + this._cylinderShader = new (0, _unitcylinderJs.UnitCylinder)(this._core, this); + this._hexPrismShader = new (0, _unithexprismJs.UnitHexPrism)(this._core, this); + this._sdfShader = new (0, _unitsdfJs.UnitSdf)(this._core, this); this._initializeContext(this._createContext(this._canvas)); this._canvas.addEventListener("webglcontextlost", (event)=>{ this._core.log.write((0, _mainJs.LogLevel).warn, "WebGL context lost"); + this._isInitialized = false; event.preventDefault(); }, false); this._canvas.addEventListener("webglcontextrestored", ()=>{ this._initializeContext(this._createContext(this._canvas)); + this._isInitialized = true; this._core.log.write((0, _mainJs.LogLevel).info, "WebGL context restored"); }, false); this._isInitialized = true; @@ -30341,64 +28139,22 @@ class Main extends (0, _rendererJs.RendererBase) { const fontVisual = this.fonts[key]; fontVisual.initializeContext(gl); } - this._ssaoSampleKernel = new Float32Array(this._config.ssaoKernelSize * 3); - const random = new (0, _mathJs.PseudoRandom)(0); - const _vec3 = (0, _glMatrix.vec3).create(); - for(let i = 0; i < this._config.ssaoKernelSize; i++){ - _vec3[0] = random.nextFloat() * 2 - 1; - _vec3[1] = random.nextFloat() * 2 - 1; - _vec3[2] = random.nextFloat(); - (0, _glMatrix.vec3).normalize(_vec3, _vec3); - (0, _glMatrix.vec3).scale(_vec3, _vec3, random.nextFloat()); - let scale = i / this._config.ssaoKernelSize; - scale = (0, _mathJs.MathHelper).lerp(0.1, 1, scale * scale); - (0, _glMatrix.vec3).scale(_vec3, _vec3, scale); - this._ssaoSampleKernel[i * 3] = _vec3[0]; - this._ssaoSampleKernel[i * 3 + 1] = _vec3[1]; - this._ssaoSampleKernel[i * 3 + 2] = _vec3[2]; - } - const noise = new Float32Array(this._config.ssaoNoiseSize * this._config.ssaoNoiseSize * 4); - _vec3[2] = 0; - for(let i1 = 0; i1 < this._config.ssaoNoiseSize * this._config.ssaoNoiseSize; i1++){ - _vec3[0] = random.nextFloat() * 2 - 1; - _vec3[1] = random.nextFloat() * 2 - 1; - (0, _glMatrix.vec3).normalize(_vec3, _vec3); - noise[i1 * 4] = _vec3[0]; - noise[i1 * 4 + 1] = _vec3[1]; - } - this._ssaoNoiseTexture = this._gl.createTexture(); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._ssaoNoiseTexture); - this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.REPEAT); - this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.REPEAT); - this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.NEAREST); - this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST); - this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA32F, this._config.ssaoNoiseSize, this._config.ssaoNoiseSize, 0, this._gl.RGBA, this._gl.FLOAT, noise); - this._ssaoWidth = -1; - this._ssaoHeight = -1; - this._shadowWidth = -1; - this._shadowHeight = -1; this._shaderResources.initializeContext(this._gl); + this._colorShader.initializeContext(this._gl); this._textureShader.initializeContext(this._gl); this._lassoShader.initializeContext(this._gl); + this._modelShader.initializeContext(this._gl); this._sdfTextShader.initializeContext(this._gl); this._gridShader.initializeContext(this._gl); + this._anaglyphShader.initializeContext(this._gl); this._blockShader.initializeContext(this._gl); this._sphereShader.initializeContext(this._gl); this._cylinderShader.initializeContext(this._gl); + this._hexPrismShader.initializeContext(this._gl); this._sdfShader.initializeContext(this._gl); - this._backgroundShader.initializeContext(this._gl); - this._ssaoShader.initializeContext(this._gl); - this._boxShader.initializeContext(this._gl); - this._deferredShader.initializeContext(this._gl); - this._combineShader.initializeContext(this._gl); - this._dofBlurShader.initializeContext(this._gl); - this._downsampleShader.initializeContext(this._gl); - this._gaussianShader.initializeContext(this._gl); - this._dofCombineShader.initializeContext(this._gl); - this._fxaaShader.initializeContext(this._gl); - this._brightPassShader.initializeContext(this._gl); this._quad.initializeContext(this._gl); this._lasso.initializeContext(this._gl); + this._debugAxesVisual.initializeContext(this._gl); this._framebuffers = [ null, null @@ -30406,146 +28162,157 @@ class Main extends (0, _rendererJs.RendererBase) { const texture = (0, _textureJs1.TextureHelper).create(this._gl, this._core.config.pickWidth, this._core.config.pickHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); const renderBuffer = this._gl.createRenderbuffer(); this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); - this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT24, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT16, this._core.config.pickWidth, this._core.config.pickHeight); const framebuffer = this._gl.createFramebuffer(); this._shaderResources.bindFramebuffer(framebuffer); this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, texture, 0); this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); this._pickFrameBuffer = framebuffer; - for(let i2 = 0; i2 < this.transitionBuffers.length; i2++)this.transitionBuffers[i2].initializeContext(this._gl); - if (this._axes1) for(let i3 = 0; i3 < this._axes1.length; i3++)this._axes1[i3].initializeContext(this._gl); - if (this._axes2) for(let i4 = 0; i4 < this._axes2.length; i4++)this._axes2[i4].initializeContext(this._gl); - for(let i5 = 0; i5 < this.labelSets.length; i5++)this.labelSets[i5].initializeContext(this._gl); - for(let i6 = 0; i6 < this.images.length; i6++)this.images[i6].initializeContext(this._gl); + this._anaglyphTextures = [ + null, + null + ]; + this.anaglyphFramebuffers = [ + null, + null + ]; + for(let i = 0; i < this.transitionBuffers.length; i++)this.transitionBuffers[i].initializeContext(this._gl); + if (this._axes1) for(let i = 0; i < this._axes1.length; i++)this._axes1[i].initializeContext(this._gl); + if (this._axes2) for(let i = 0; i < this._axes2.length; i++)this._axes2[i].initializeContext(this._gl); + for(let i = 0; i < this.labelSets.length; i++)this.labelSets[i].initializeContext(this._gl); + for(let i = 0; i < this.images.length; i++)this.images[i].initializeContext(this._gl); + for(let i = 0; i < this.controllers.length; i++)this.controllers[i].initializeContext(this._gl); } _resize(width, height) { super._resize(width, height); - this._positionTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.NEAREST, null, this._gl.RGBA32F); - this._colorTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._normalTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._geometryFrameBuffer = this._gl.createFramebuffer(); - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._positionTexture, 0); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT1, this._gl.TEXTURE_2D, this._colorTexture, 0); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT2, this._gl.TEXTURE_2D, this._normalTexture, 0); - const renderBuffer = this._gl.createRenderbuffer(); - this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); - this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT24, width, height); - this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); - this._gl.drawBuffers([ - this._gl.COLOR_ATTACHMENT0, - this._gl.COLOR_ATTACHMENT1, - this._gl.COLOR_ATTACHMENT2 - ]); - this._postProcessTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessDepthTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.DEPTH_COMPONENT, this._gl.UNSIGNED_INT, this._gl.NEAREST, null, this._gl.DEPTH_COMPONENT24); - this._postProcessFrameBuffer1 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessFrameBuffer1); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessTexture1, 0); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.TEXTURE_2D, this._postProcessDepthTexture, 0); - this._postProcessTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessFrameBuffer2 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessFrameBuffer2); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessTexture2, 0); - this._postProcessDofTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RED, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.R32F); - this._postProcessDofFrameBuffer = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessDofFrameBuffer); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessDofTexture, 0); - const widthHalf = Math.round(width / 2); - const heightHalf = Math.round(height / 2); - this._postProcessHalfTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthHalf, heightHalf, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessHalfFrameBuffer1 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer1); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessHalfTexture1, 0); - this._postProcessHalfTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthHalf, heightHalf, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessHalfFrameBuffer2 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer2); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessHalfTexture2, 0); - const widthQuarter = Math.round(widthHalf / 2); - const heightQuarter = Math.round(heightHalf / 2); - this._postProcessQuarterTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthQuarter, heightQuarter, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessQuarterFrameBuffer1 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer1); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessQuarterTexture1, 0); - this._postProcessQuarterTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthQuarter, heightQuarter, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessQuarterFrameBuffer2 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer2); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessQuarterTexture2, 0); - const widthEighth = Math.round(widthQuarter / 2); - const heightEighth = Math.round(heightQuarter / 2); - this._postProcessEighthTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthEighth, heightEighth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessEighthFrameBuffer1 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer1); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessEighthTexture1, 0); - this._postProcessEighthTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthEighth, heightEighth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessEighthFrameBuffer2 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer2); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessEighthTexture2, 0); - const widthSixteenth = Math.round(widthEighth / 2); - const hgeightSixteenth = Math.round(heightEighth / 2); - this._postProcessSixteenthTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthSixteenth, hgeightSixteenth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessSixteenthFrameBuffer1 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer1); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessSixteenthTexture1, 0); - this._postProcessSixteenthTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthSixteenth, hgeightSixteenth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); - this._postProcessSixteenthFrameBuffer2 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer2); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessSixteenthTexture2, 0); + for(let i = 0; i < 2; i++){ + const texture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); + const renderBuffer = this._gl.createRenderbuffer(); + this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); + this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT16, width, height); + const framebuffer = this._gl.createFramebuffer(); + this._shaderResources.bindFramebuffer(framebuffer); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, texture, 0); + this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); + this._anaglyphTextures[i] = texture; + this.anaglyphFramebuffers[i] = framebuffer; + } this._core.log.write((0, _mainJs.LogLevel).info, `buffers resized ${width},${height}`); } _createContext(canvas) { - let supported = false; - const options = { + const antialias = this._options ? this._options.antialias === undefined ? true : this._options.antialias : true; + const preserveDrawingBuffer = this._options ? this._options.preserveDrawingBuffer === undefined ? false : this._options.preserveDrawingBuffer : false; + return canvas.getContext("webgl", { stencil: true, - alpha: false, - antialias: false - }; - const gl = canvas.getContext("webgl2", options); - if (gl) { - const OES_texture_float_linear = gl.getExtension("OES_texture_float_linear"); - const EXT_color_buffer_float = gl.getExtension("EXT_color_buffer_float"); - if (OES_texture_float_linear && EXT_color_buffer_float && gl.MAX_DRAW_BUFFERS > 3) { - const texture = (0, _textureJs1.TextureHelper).create(gl, 1, 1, gl.RGBA, gl.FLOAT, gl.LINEAR, null, gl.RGBA32F); - const framebuffer = gl.createFramebuffer(); - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); - const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - if (status == gl.FRAMEBUFFER_COMPLETE) supported = true; - gl.bindTexture(gl.TEXTURE_2D, null); - } - } - return supported ? gl : null; + alpha: true, + antialias: antialias, + preserveDrawingBuffer: preserveDrawingBuffer + }); } - prepare() { - let viewport; - switch(this._core.config.stereoMode){ - case (0, _mainJs.StereoMode).none: - viewport = this._viewports[0]; - viewport.x = 0; - viewport.y = 0; - viewport.width = this._canvas.width; - viewport.height = this._canvas.height; - this._viewportOffset = 0; - this._viewportCount = 1; - break; - case (0, _mainJs.StereoMode).left: - viewport = this._viewports[0]; - viewport.x = 0; - viewport.y = 0; - viewport.width = this._canvas.width; - viewport.height = this._canvas.height; - this._viewportOffset = 0; - this._viewportCount = 1; - break; - case (0, _mainJs.StereoMode).right: - viewport = this._viewports[1]; - viewport.x = 0; - viewport.y = 0; - viewport.width = this._canvas.width; - viewport.height = this._canvas.height; - this._viewportOffset = 1; - this._viewportCount = 1; - break; + initializeWebXR(session) { + const promise = new Promise((resolve, reject)=>{ + this._gl.makeXRCompatible().then(()=>{ + session.updateRenderState({ + baseLayer: new XRWebGLLayer(session, this._gl), + depthNear: this._core.config.nearPlane, + depthFar: this._core.config.farPlane + }); + session.requestReferenceSpace('local').then((refSpace)=>{ + this._webXRReferenceSpace = refSpace; + resolve(); + }); + }); + }); + return promise; + } + prepare(xrFrame) { + if (xrFrame) { + const pose = xrFrame.getViewerPose(this._webXRReferenceSpace); + if (pose) { + const glLayer = xrFrame.session.renderState.baseLayer; + for(let i = 0; i < pose.views.length; i++){ + const view = pose.views[i]; + this.vMatrices[i] = view.transform.inverse.matrix; + this.inverseVMatrices[i] = view.transform.matrix; + (0, _glMatrix.mat4).multiply(this._mvMatrices[i], this.vMatrices[i], this.mMatrix); + this.mvMatrices[i] = this._mvMatrices[i]; + this.pMatrices[i] = view.projectionMatrix; + const viewport = glLayer.getViewport(view); + this._viewports[i].x = viewport.x; + this._viewports[i].y = viewport.y; + this._viewports[i].width = viewport.width; + this._viewports[i].height = viewport.height; + this._framebuffers[i] = glLayer.framebuffer; + } + } + this._viewportOffset = 0; + this._viewportCount = 2; + } else { + let viewport; + switch(this._core.config.stereoMode){ + case (0, _mainJs.StereoMode).none: + viewport = this._viewports[0]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 0; + this._viewportCount = 1; + this._framebuffers[0] = null; + break; + case (0, _mainJs.StereoMode).left: + viewport = this._viewports[0]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 0; + this._viewportCount = 1; + this._framebuffers[0] = null; + break; + case (0, _mainJs.StereoMode).right: + viewport = this._viewports[1]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 1; + this._viewportCount = 1; + this._framebuffers[1] = null; + break; + case (0, _mainJs.StereoMode).anaglyph: + viewport = this._viewports[0]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + viewport = this._viewports[1]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 0; + this._viewportCount = 2; + this._framebuffers[0] = this.anaglyphFramebuffers[0]; + this._framebuffers[1] = this.anaglyphFramebuffers[1]; + break; + case (0, _mainJs.StereoMode).split: + viewport = this._viewports[0]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width / 2; + viewport.height = this._canvas.height; + viewport = this._viewports[1]; + viewport.x = this._canvas.width / 2; + viewport.y = 0; + viewport.width = this._canvas.width / 2; + viewport.height = this._canvas.height; + this._viewportOffset = 0; + this._viewportCount = 2; + this._framebuffers[0] = null; + this._framebuffers[1] = null; + break; + } } } createTransitionBuffer(ids) { @@ -30553,6 +28320,11 @@ class Main extends (0, _rendererJs.RendererBase) { buffer.initializeContext(this._gl); return buffer; } + createControllerVisual(controller) { + const visual = new (0, _controllerJs.ControllerVisual)(this._core, this, controller); + visual.initializeContext(this._gl); + return visual; + } createCartesian2dAxesVisual(axes) { const visual = new (0, _cartesian2DJs.Cartesian2dVisual)(this._core, this, axes); visual.initializeContext(this._gl); @@ -30563,6 +28335,9 @@ class Main extends (0, _rendererJs.RendererBase) { visual.initializeContext(this._gl); return visual; } + _createDebugAxesVisual(debugAxes) { + return new (0, _debugJs.DebugAxesVisual)(this._core, this, debugAxes); + } _createLabelVisual(label) { return new (0, _labelsJs.LabelVisual)(this._core, this, label); } @@ -30584,152 +28359,148 @@ class Main extends (0, _rendererJs.RendererBase) { getDataUrl(mimeType) { return this._canvas.toDataURL(mimeType); } - update(elapsedTime) { - super.update(elapsedTime); - if (this._shadowWidth != this._config.shadowWidth || this._shadowHeight != this._config.shadowHeight) { - this._shadowWidth = this._config.shadowWidth; - this._shadowHeight = this._config.shadowHeight; - this._shadowColorTexture = (0, _textureJs1.TextureHelper).create(this._gl, this._config.shadowWidth, this._config.shadowHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); - this._shadowDepthTexture = (0, _textureJs1.TextureHelper).create(this._gl, this._config.shadowWidth, this._config.shadowHeight, this._gl.DEPTH_COMPONENT, this._gl.UNSIGNED_INT, this._gl.NEAREST, null, this._gl.DEPTH_COMPONENT24); - this._shadowFrameBuffer = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._shadowFrameBuffer); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._shadowColorTexture, 0); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.TEXTURE_2D, this._shadowDepthTexture, 0); - this._core.log.write((0, _mainJs.LogLevel).info, `shadow map resized ${this._shadowWidth},${this._shadowHeight}`); - } - if (this._ssaoWidth != this._config.ssaoWidth || this._ssaoHeight != this._config.ssaoHeight) { - this._ssaoWidth = this._config.ssaoWidth; - this._ssaoHeight = this._config.ssaoHeight; - this._ssaoTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, this._config.ssaoWidth, this._config.ssaoHeight, this._gl.RED, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null, this._gl.R8); - this._ssaoFrameBuffer1 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._ssaoFrameBuffer1); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._ssaoTexture1, 0); - this._ssaoTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, this._config.ssaoWidth, this._config.ssaoHeight, this._gl.RED, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null, this._gl.R8); - this._ssaoFrameBuffer2 = this._gl.createFramebuffer(); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._ssaoFrameBuffer2); - this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._ssaoTexture2, 0); - this._core.log.write((0, _mainJs.LogLevel).info, `ssao map resized ${this._ssaoWidth},${this._ssaoHeight}`); - } - if (this._config.isDofEnabled && this._config.dofAutoFocus) { - this._core.getModelManipulationOrigin(this._modelManipulationOrigin); - this._core.getModelPosition(this._modelPosition); - (0, _glMatrix.vec3).add(this._position, this._modelManipulationOrigin, this._modelPosition); - this._core.camera.getPosition(this._cameraPosition); - (0, _glMatrix.vec3).subtract(this._position, this._position, this._cameraPosition); - const distance = -this._position[2]; - const amount = Math.min(elapsedTime * this._core.config.focusSmoothing, 1); - this._config.dofFocusDistance = (0, _mathJs.MathHelper).lerp(this._config.dofFocusDistance, distance, amount); - } - } - render(elapsedTime) { - this._gl.enable(this._gl.DEPTH_TEST); - this._gl.enable(this._gl.CULL_FACE); - this._gl.cullFace(this._gl.BACK); - this._gl.disable(this._gl.BLEND); - if (this.isPickingEnabled) { - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.clearColor(0, 0, 0, 0); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); - } - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); - const backgroundColor = this._backgroundColor || this._core.config.backgroundColor; - this._gl.clearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], 1); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT | this._gl.STENCIL_BUFFER_BIT); - if (this.config.isShadowEnabled) { - this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); - this._gl.clear(this._gl.DEPTH_BUFFER_BIT); - (0, _glMatrix.mat4).perspective(this._shadowPMatrix, (0, _angleJs.AngleHelper).degreesToRadians(30), this._config.shadowWidth / this._config.shadowHeight, this._core.config.nearPlane, this._core.config.farPlane); - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.mat3).fromMat4(this._cameraRotation, this.inverseVMatrices[0]); - (0, _glMatrix.vec3).transformMat3(this._position, this._config.keyLightPosition, this._cameraRotation); - (0, _glMatrix.vec3).add(this._position, this._position, this._modelPosition); - (0, _glMatrix.mat4).lookAt(this._shadowVMatrix, this._position, this._modelPosition, (0, _constantsJs.Constants).VECTOR3_UNITY); - } - for(let i = 0; i < this.transitionBuffers.length; i++){ - const transitionBuffer = this.transitionBuffers[i]; - if (transitionBuffer.isVisible) this._renderTransitionBuffer(transitionBuffer); - } - const axesVisuals = this.axesVisibility == (0, _mainJs.AxesVisibility).current ? this.currentAxes : this.axesVisibility == (0, _mainJs.AxesVisibility).previous ? this.previousAxes : null; - if (axesVisuals) for(let i1 = 0; i1 < axesVisuals.length; i1++){ - const axesVisual = axesVisuals[i1]; - if (axesVisual.isVisible) { - axesVisual.pickedIdColor = this._pickedIdColor; - axesVisual.pickFramebuffer = this._pickFrameBuffer; - axesVisual.geometryFramebuffer = this._geometryFrameBuffer; - axesVisual.render(elapsedTime); + render(elapsedTime, xrFrame) { + return __awaiter(this, void 0, void 0, function*() { + if (this.depthEnabled) this._gl.enable(this._gl.DEPTH_TEST); + else this._gl.disable(this._gl.DEPTH_TEST); + this._gl.enable(this._gl.CULL_FACE); + this._gl.disable(this._gl.BLEND); + if (this.isPickingEnabled) { + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.clearColor(0, 0, 0, 0); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); } - } - if (this.areLabelsVisible) for(let i2 = 0; i2 < this.labelSets.length; i2++){ - const labelSetVisual = this.labelSets[i2]; - if (labelSetVisual.isVisible) { - labelSetVisual.pickedIdColor = this._pickedIdColor; - labelSetVisual.pickFramebuffer = this._pickFrameBuffer; - labelSetVisual.geometryFramebuffer = this._geometryFrameBuffer; - labelSetVisual.render(elapsedTime); + const backgroundColor = this._backgroundColor || this._core.config.backgroundColor; + this._gl.clearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], backgroundColor[3]); + if (xrFrame) { + const glLayer = xrFrame.session.renderState.baseLayer; + this._shaderResources.bindFramebuffer(glLayer.framebuffer); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); + } else if (this._core.config.stereoMode == (0, _mainJs.StereoMode).anaglyph) { + for(let i = 0; i < 2; i++){ + this._shaderResources.bindFramebuffer(this.anaglyphFramebuffers[i]); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); + } + this._shaderResources.bindFramebuffer(null); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); + } else { + this._shaderResources.bindFramebuffer(null); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); } - } - if (this.areImagesVisible) for(let i3 = 0; i3 < this.images.length; i3++){ - const imageVisual = this.images[i3]; - if (imageVisual.isVisible) { - imageVisual.geometryFramebuffer = this._geometryFrameBuffer; - imageVisual.render(elapsedTime); + if (this._core.config.isDebugVisible) { + this._debugAxesVisual.framebuffers = this._framebuffers; + this._debugAxesVisual.render(elapsedTime, xrFrame); + } + const axesVisuals = this.axesVisibility == (0, _mainJs.AxesVisibility).current ? this.currentAxes : this.axesVisibility == (0, _mainJs.AxesVisibility).previous ? this.previousAxes : null; + if (axesVisuals) for(let i = 0; i < axesVisuals.length; i++){ + const axesVisual = axesVisuals[i]; + if (axesVisual.isVisible) { + axesVisual.pickedIdColor = this._pickedIdColor; + axesVisual.pickFramebuffer = this._pickFrameBuffer; + axesVisual.framebuffers = this._framebuffers; + axesVisual.render(elapsedTime, xrFrame); + } } - } - if (this._backgroundShader.isInitialized) { - this._backgroundShader.prepare(); - this._backgroundShader.color = this._core.config.backgroundColor; - this._backgroundShader.apply(); - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); - for(let i4 = 0; i4 < this._viewportCount; i4++){ - const viewport = i4 + this._viewportOffset; - this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible) this._renderTransitionBuffer(xrFrame, transitionBuffer); + } + if (this.areLabelsVisible) for(let i = 0; i < this.labelSets.length; i++){ + const labelSetVisual = this.labelSets[i]; + if (labelSetVisual.isVisible) { + labelSetVisual.pickedIdColor = this._pickedIdColor; + labelSetVisual.pickFramebuffer = this._pickFrameBuffer; + labelSetVisual.framebuffers = this._framebuffers; + labelSetVisual.render(elapsedTime, xrFrame); + } } - this._gl.bindVertexArray(null); - } - if (this.isPickingEnabled) { - this._shaderResources.bindFramebuffer(this._pickFrameBuffer); - this._gl.readPixels(this._core.config.pickWidth / 2, this._core.config.pickHeight / 2, 1, 1, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._pickedPixels); - this._pickedType = (0, _pickJs.PickHelper).decodeType(this._pickedPixels); - (0, _glMatrix.vec4).set(this._pickedIdColor, this._pickedPixels[0] / 0xff, this._pickedPixels[1] / 0xff, this._pickedPixels[2] / 0xff, this._pickedPixels[3] / 0xff); - this._pickedId = (0, _pickJs.PickHelper).decodeNumber(this._pickedPixels); - } else { - (0, _glMatrix.vec4).set(this._pickedIdColor, 0, 0, 0, 0); - this._pickedId = 0; - } - if (this.transitionBuffers.length > 0 && this._quad.isInitialized) { - const viewport1 = this._viewportOffset; - this._postProcess(this.vMatrices[viewport1], this.inverseVMatrices[viewport1], this.pMatrices[viewport1], this._viewports[viewport1]); - } - if (this.isLassoPicking && this._lassoShader.isInitialized) { - this._lassoShader.vertexBuffer = this._lasso.vertexBuffer; - this._lassoShader.indexBuffer = this._lasso.indexBuffer; - const lassoWidth = this.lassoX1 - this.lassoX0; - const lassoHeight = this.lassoY1 - this.lassoY0; - this._lassoShader.prepare(); - this._lassoShader.color = this.lassoColor ? this.lassoColor : this._core.config.lassoColor; - this._lassoShader.dashWidth = this.lassoDashWidth ? this.lassoDashWidth : this._core.config.lassoDashWidth; - this._lassoShader.apply(); - const lassoThickness = this.lassoThickness ? this.lassoThickness : this._core.config.lassoThickness; - for(let i5 = 0; i5 < this._viewportCount; i5++){ - const viewportIndex = i5 + this._viewportOffset; - this._shaderResources.bindFramebuffer(this._framebuffers[viewportIndex]); - const viewport2 = this._viewports[viewportIndex]; - this._gl.viewport(viewport2.x, viewport2.y, viewport2.width, viewport2.height); - this._lassoMMatrix[0] = lassoWidth * 2 / viewport2.width; - this._lassoMMatrix[5] = lassoHeight * 2 / viewport2.height; - this._lassoMMatrix[10] = 1; - this._lassoMMatrix[12] = (this.lassoX0 + lassoWidth / 2) / viewport2.width * 2 - 1; - this._lassoMMatrix[13] = 1 - (this.lassoY0 + lassoHeight / 2) / viewport2.height * 2; - this._lassoShader.mMatrix = this._lassoMMatrix; - (0, _glMatrix.vec2).set(this._lassoThickness, lassoThickness / lassoWidth, lassoThickness / lassoHeight); - this._lassoShader.thickness = this._lassoThickness; - this._lassoShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._lasso.indexCount, this._gl.UNSIGNED_SHORT, 0); + if (this.areImagesVisible) for(let i = 0; i < this.images.length; i++){ + const imageVisual = this.images[i]; + if (imageVisual.isVisible) { + imageVisual.framebuffers = this._framebuffers; + imageVisual.pickFramebuffer = this._pickFrameBuffer; + imageVisual.isPickingEnabled = this.isPickingEnabled; + imageVisual.render(elapsedTime, xrFrame); + } } - } + for(let i = 0; i < this.controllers.length; i++){ + const controllerVisual = this.controllers[i]; + if (controllerVisual.isVisible) { + controllerVisual.isRayVisible = this.isPickingEnabled; + controllerVisual.framebuffers = this._framebuffers; + controllerVisual.render(elapsedTime, xrFrame); + } + } + if (this.isPickingEnabled) { + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.readPixels(this._core.config.pickWidth / 2, this._core.config.pickHeight / 2, 1, 1, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._pickedPixels); + this._pickedType = (0, _pickJs.PickHelper).decodeType(this._pickedPixels); + (0, _glMatrix.vec4).set(this._pickedIdColor, this._pickedPixels[0] / 0xff, this._pickedPixels[1] / 0xff, this._pickedPixels[2] / 0xff, this._pickedPixels[3] / 0xff); + this._pickedId = (0, _pickJs.PickHelper).decodeNumber(this._pickedPixels); + if (this._isCapturingPickImage && this.capturePickImageCallback) { + this._isCapturingPickImage = false; + const data = new Uint8ClampedArray(this._core.config.pickWidth * this._core.config.pickHeight * 4); + this._gl.readPixels(0, 0, this._core.config.pickWidth, this._core.config.pickHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data); + for(let i = 0; i < data.length / 4; i++)if (data[i * 4 + 3] == (0, _mainJs.PickType).data) data[i * 4 + 3] = 255; + else { + data[i * 4] = 0; + data[i * 4 + 1] = 0; + data[i * 4 + 2] = 0; + data[i * 4 + 3] = 0; + } + const length = this._core.config.pickWidth * this._core.config.pickHeight * 4; + const row = this._core.config.pickWidth * 4; + const end = (this._core.config.pickHeight - 1) * row; + const flipped = new Uint8ClampedArray(length); + for(let i = 0; i < length; i += row)flipped.set(data.subarray(i, i + row), end - i); + this.capturePickImageCallback(flipped, this._core.config.pickWidth, this._core.config.pickHeight); + } + } else { + (0, _glMatrix.vec4).set(this._pickedIdColor, 0, 0, 0, 0); + this._pickedId = 0; + } + if (this.isLassoPicking && this._lassoShader.isInitialized) { + this._lassoShader.vertexBuffer = this._lasso.vertexBuffer; + this._lassoShader.indexBuffer = this._lasso.indexBuffer; + const lassoWidth = this.lassoX1 - this.lassoX0; + const lassoHeight = this.lassoY1 - this.lassoY0; + this._lassoShader.prepare(); + this._lassoShader.color = this.lassoColor ? this.lassoColor : this._core.config.lassoColor; + this._lassoShader.dashWidth = this.lassoDashWidth ? this.lassoDashWidth : this._core.config.lassoDashWidth; + this._lassoShader.apply(); + const lassoThickness = this.lassoThickness ? this.lassoThickness : this._core.config.lassoThickness; + for(let i = 0; i < this._viewportCount; i++){ + const viewportIndex = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewportIndex]); + const viewport = this._viewports[viewportIndex]; + this._gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); + this._lassoMMatrix[0] = lassoWidth * 2 / viewport.width; + this._lassoMMatrix[5] = lassoHeight * 2 / viewport.height; + this._lassoMMatrix[10] = 1; + this._lassoMMatrix[12] = (this.lassoX0 + lassoWidth / 2) / viewport.width * 2 - 1; + this._lassoMMatrix[13] = 1 - (this.lassoY0 + lassoHeight / 2) / viewport.height * 2; + this._lassoShader.mMatrix = this._lassoMMatrix; + (0, _glMatrix.vec2).set(this._lassoThickness, lassoThickness / lassoWidth, lassoThickness / lassoHeight); + this._lassoShader.thickness = this._lassoThickness; + this._lassoShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._lasso.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + } + if (this._core.config.stereoMode == (0, _mainJs.StereoMode).anaglyph && this._anaglyphShader.isInitialized && this._quad.isInitialized) { + this._shaderResources.bindFramebuffer(null); + this._gl.viewport(this._viewports[0].x, this._viewports[0].y, this._viewports[0].width, this._viewports[0].height); + this._anaglyphShader.vertexBuffer = this._quad.vertexBuffer; + this._anaglyphShader.indexBuffer = this._quad.indexBuffer; + this._anaglyphShader.texture2D1 = this._anaglyphTextures[0]; + this._anaglyphShader.texture2D2 = this._anaglyphTextures[1]; + this._anaglyphShader.prepare(); + this._anaglyphShader.viewport = this._viewports[0]; + this._anaglyphShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + }); } - _renderTransitionBuffer(transitionBuffer) { + _renderTransitionBuffer(xrFrame, transitionBuffer) { const currentBuffer = transitionBuffer.currentBuffer; const previousBuffer = transitionBuffer.previousBuffer; const currentPalette = transitionBuffer.currentPalette; @@ -30740,7 +28511,7 @@ class Main extends (0, _rendererJs.RendererBase) { const id = currentBuffer.lookup[transitionBuffer.pickIdLookup[this._pickedId]]; const hoverId = id > -1 ? (0, _vertexJs.UnitVertex).getIdHover(currentBuffer.dataView, id) : -1; const activeId = transitionBuffer.activeId; - if (this._blockShader.isInitialized && (unitType == (0, _mainJs.UnitType).block || unitType == (0, _mainJs.UnitType).blockSdf)) { + if (this._blockShader.isInitialized && (unitType == (0, _mainJs.UnitType).block || unitType == (0, _mainJs.UnitType).blockSdf || unitType == (0, _mainJs.UnitType).ringSdf)) { this._blockShader.instanceBuffer = currentBuffer.vertexBuffer; this._blockShader.previousInstanceBuffer = previousBuffer.vertexBuffer; this._blockShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; @@ -30749,48 +28520,58 @@ class Main extends (0, _rendererJs.RendererBase) { this._blockShader.mMatrix = this.mMatrix; this._blockShader.time = this.transitionTime; this._blockShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._blockShader.rangeMin = currentBuffer.from; - this._blockShader.rangeMax = currentBuffer.to; + this._blockShader.rangeMin = 0; + this._blockShader.rangeMax = transitionBuffer.length - 1; this._blockShader.hover = hoverId; this._blockShader.active = activeId; + this._blockShader.selectedColor = this._core.config.selectionColor; + this._blockShader.hoverColor = this._core.config.hoverColor; + this._blockShader.activeColor = this._core.config.activeColor; + this._blockShader.highlightMode = this._core.config.highlightMode; this._blockShader.specularPower = this._config.specularPower; this._blockShader.specularIntensity = this._config.specularIntensity; + this._blockShader.ambient = this._config.ambient; this._blockShader.apply(); this._blockShader.isPickShader = false; - this._blockShader.isShadowMap = false; - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); for(let i = 0; i < this._viewportCount; i++){ const viewport = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewport]); this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); - this._blockShader.vMatrix = this.vMatrices[viewport]; + const vMatrix = this.vMatrices[viewport]; + if (xrFrame) { + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); + const inverseVMatrix = this.inverseVMatrices[viewport]; + (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix[12], inverseVMatrix[13], inverseVMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); + (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); + (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); + (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix); + (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); + (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); + this._blockShader.directionToLight = this._directionToLight; + this._blockShader.halfAngle = this._halfAngle; + } else { + this._blockShader.directionToLight = this._config.directionToLight; + this._blockShader.halfAngle = this._config.halfAngle; + } + this._blockShader.vMatrix = vMatrix; this._blockShader.pMatrix = this.pMatrices[viewport]; this._blockShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this._config.isShadowEnabled) { - this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); - this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); - this._gl.cullFace(this._gl.FRONT); - this._blockShader.isPickShader = false; - this._blockShader.isShadowMap = true; - this._blockShader.vMatrix = this._shadowVMatrix; - this._blockShader.pMatrix = this._shadowPMatrix; - this._blockShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - this._gl.colorMask(true, true, true, true); - this._gl.cullFace(this._gl.BACK); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - if (this.isPickingEnabled) { + if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { this._blockShader.isPickShader = true; - this._blockShader.isShadowMap = false; this._blockShader.pMatrix = this.pickPMatrix; this._blockShader.vMatrix = this.pickVMatrix; this._blockShader.applyView(); this._shaderResources.bindFramebuffer(this._pickFrameBuffer); this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - } else if (this._sphereShader.isInitialized && (unitType == (0, _mainJs.UnitType).sphere || unitType == (0, _mainJs.UnitType).sphereSdf)) { + } else if (this._sphereShader.isInitialized && (unitType == (0, _mainJs.UnitType).sphere || unitType == (0, _mainJs.UnitType).sphereSdf || unitType == (0, _mainJs.UnitType).disk)) { this._sphereShader.instanceBuffer = currentBuffer.vertexBuffer; this._sphereShader.previousInstanceBuffer = previousBuffer.vertexBuffer; this._sphereShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; @@ -30799,44 +28580,56 @@ class Main extends (0, _rendererJs.RendererBase) { this._sphereShader.mMatrix = this.mMatrix; this._sphereShader.time = this.transitionTime; this._sphereShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._sphereShader.rangeMin = currentBuffer.from; - this._sphereShader.rangeMax = currentBuffer.to; + this._sphereShader.rangeMin = 0; + this._sphereShader.rangeMax = transitionBuffer.length - 1; this._sphereShader.hover = hoverId; this._sphereShader.active = activeId; + this._sphereShader.selectedColor = this._core.config.selectionColor; + this._sphereShader.hoverColor = this._core.config.hoverColor; + this._sphereShader.activeColor = this._core.config.activeColor; + this._sphereShader.highlightMode = this._core.config.highlightMode; this._sphereShader.specularPower = this._config.specularPower; this._sphereShader.specularIntensity = this._config.specularIntensity; + this._sphereShader.ambient = this._config.ambient; this._sphereShader.apply(); this._sphereShader.isPickShader = false; - this._sphereShader.isShadowMap = false; - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); - for(let i1 = 0; i1 < this._viewportCount; i1++){ - const viewport1 = i1 + this._viewportOffset; - this._gl.viewport(this._viewports[viewport1].x, this._viewports[viewport1].y, this._viewports[viewport1].width, this._viewports[viewport1].height); - this._sphereShader.vMatrix = this.vMatrices[viewport1]; - this._sphereShader.pMatrix = this.pMatrices[viewport1]; - this._sphereShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this._config.isShadowEnabled) { - this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); - this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); - this._sphereShader.isPickShader = false; - this._sphereShader.isShadowMap = true; - this._sphereShader.vMatrix = this._shadowVMatrix; - this._sphereShader.pMatrix = this._shadowPMatrix; + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewport]); + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + const vMatrix = this.vMatrices[viewport]; + if (xrFrame) { + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); + const inverseVMatrix = this.inverseVMatrices[viewport]; + (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix[12], inverseVMatrix[13], inverseVMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); + (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); + (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); + (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix); + (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); + (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); + this._sphereShader.directionToLight = this._directionToLight; + this._sphereShader.halfAngle = this._halfAngle; + } else { + this._sphereShader.directionToLight = this._config.directionToLight; + this._sphereShader.halfAngle = this._config.halfAngle; + } + this._sphereShader.vMatrix = vMatrix; + this._sphereShader.pMatrix = this.pMatrices[viewport]; this._sphereShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - this._gl.colorMask(true, true, true, true); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - if (this.isPickingEnabled) { + if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { this._sphereShader.isPickShader = true; - this._sphereShader.isShadowMap = false; this._sphereShader.pMatrix = this.pickPMatrix; this._sphereShader.vMatrix = this.pickVMatrix; this._sphereShader.applyView(); this._shaderResources.bindFramebuffer(this._pickFrameBuffer); this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } } else if (this._cylinderShader.isInitialized && (unitType == (0, _mainJs.UnitType).cylinder || unitType == (0, _mainJs.UnitType).cylinderSdf)) { this._cylinderShader.instanceBuffer = currentBuffer.vertexBuffer; @@ -30847,44 +28640,116 @@ class Main extends (0, _rendererJs.RendererBase) { this._cylinderShader.mMatrix = this.mMatrix; this._cylinderShader.time = this.transitionTime; this._cylinderShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._cylinderShader.rangeMin = currentBuffer.from; - this._cylinderShader.rangeMax = currentBuffer.to; + this._cylinderShader.rangeMin = 0; + this._cylinderShader.rangeMax = transitionBuffer.length - 1; this._cylinderShader.hover = hoverId; this._cylinderShader.active = activeId; + this._cylinderShader.selectedColor = this._core.config.selectionColor; + this._cylinderShader.hoverColor = this._core.config.hoverColor; + this._cylinderShader.activeColor = this._core.config.activeColor; + this._cylinderShader.highlightMode = this._core.config.highlightMode; this._cylinderShader.specularPower = this._config.specularPower; this._cylinderShader.specularIntensity = this._config.specularIntensity; + this._cylinderShader.ambient = this._config.ambient; this._cylinderShader.apply(); this._cylinderShader.isPickShader = false; - this._cylinderShader.isShadowMap = false; - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); - for(let i2 = 0; i2 < this._viewportCount; i2++){ - const viewport2 = i2 + this._viewportOffset; - this._gl.viewport(this._viewports[viewport2].x, this._viewports[viewport2].y, this._viewports[viewport2].width, this._viewports[viewport2].height); - this._cylinderShader.vMatrix = this.vMatrices[viewport2]; - this._cylinderShader.pMatrix = this.pMatrices[viewport2]; - this._cylinderShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this._config.isShadowEnabled) { - this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); - this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); - this._cylinderShader.isPickShader = false; - this._cylinderShader.isShadowMap = true; - this._cylinderShader.vMatrix = this._shadowVMatrix; - this._cylinderShader.pMatrix = this._shadowPMatrix; + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewport]); + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + const vMatrix = this.vMatrices[viewport]; + if (xrFrame) { + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); + const inverseVMatrix = this.inverseVMatrices[viewport]; + (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix[12], inverseVMatrix[13], inverseVMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); + (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); + (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); + (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix); + (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); + (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); + this._cylinderShader.directionToLight = this._directionToLight; + this._cylinderShader.halfAngle = this._halfAngle; + } else { + this._cylinderShader.directionToLight = this._config.directionToLight; + this._cylinderShader.halfAngle = this._config.halfAngle; + } + this._cylinderShader.vMatrix = vMatrix; + this._cylinderShader.pMatrix = this.pMatrices[viewport]; this._cylinderShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - this._gl.colorMask(true, true, true, true); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - if (this.isPickingEnabled) { + if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { this._cylinderShader.isPickShader = true; - this._cylinderShader.isShadowMap = false; this._cylinderShader.pMatrix = this.pickPMatrix; this._cylinderShader.vMatrix = this.pickVMatrix; this._cylinderShader.applyView(); this._shaderResources.bindFramebuffer(this._pickFrameBuffer); this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + } else if (this._hexPrismShader.isInitialized && (unitType == (0, _mainJs.UnitType).hexPrism || unitType == (0, _mainJs.UnitType).hexPrismSdf)) { + this._hexPrismShader.instanceBuffer = currentBuffer.vertexBuffer; + this._hexPrismShader.previousInstanceBuffer = previousBuffer.vertexBuffer; + this._hexPrismShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; + this._hexPrismShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; + this._hexPrismShader.prepare(); + this._hexPrismShader.mMatrix = this.mMatrix; + this._hexPrismShader.time = this.transitionTime; + this._hexPrismShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); + this._hexPrismShader.rangeMin = 0; + this._hexPrismShader.rangeMax = transitionBuffer.length - 1; + this._hexPrismShader.hover = hoverId; + this._hexPrismShader.active = activeId; + this._hexPrismShader.selectedColor = this._core.config.selectionColor; + this._hexPrismShader.hoverColor = this._core.config.hoverColor; + this._hexPrismShader.activeColor = this._core.config.activeColor; + this._hexPrismShader.highlightMode = this._core.config.highlightMode; + this._hexPrismShader.specularPower = this._config.specularPower; + this._hexPrismShader.specularIntensity = this._config.specularIntensity; + this._hexPrismShader.ambient = this._config.ambient; + this._hexPrismShader.apply(); + this._hexPrismShader.isPickShader = false; + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewport]); + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + const vMatrix = this.vMatrices[viewport]; + if (xrFrame) { + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); + const inverseVMatrix = this.inverseVMatrices[viewport]; + (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix[12], inverseVMatrix[13], inverseVMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); + (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); + (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); + (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix); + (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); + (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); + this._hexPrismShader.directionToLight = this._directionToLight; + this._hexPrismShader.halfAngle = this._halfAngle; + } else { + this._hexPrismShader.directionToLight = this._config.directionToLight; + this._hexPrismShader.halfAngle = this._config.halfAngle; + } + this._hexPrismShader.vMatrix = vMatrix; + this._hexPrismShader.pMatrix = this.pMatrices[viewport]; + this._hexPrismShader.applyView(); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._hexPrismShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { + this._hexPrismShader.isPickShader = true; + this._hexPrismShader.pMatrix = this.pickPMatrix; + this._hexPrismShader.vMatrix = this.pickVMatrix; + this._hexPrismShader.applyView(); + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._hexPrismShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } } else if (this._sdfShader.isInitialized && unitType == (0, _mainJs.UnitType).sdf) { this._sdfShader.instanceBuffer = currentBuffer.vertexBuffer; @@ -30897,325 +28762,71 @@ class Main extends (0, _rendererJs.RendererBase) { this._sdfShader.mMatrix = this.mMatrix; this._sdfShader.time = this.transitionTime; this._sdfShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); - this._sdfShader.rangeMin = currentBuffer.from; - this._sdfShader.rangeMax = currentBuffer.to; + this._sdfShader.rangeMin = 0; + this._sdfShader.rangeMax = transitionBuffer.length - 1; this._sdfShader.hover = hoverId; this._sdfShader.active = activeId; + this._sdfShader.selectedColor = this._core.config.selectionColor; + this._sdfShader.hoverColor = this._core.config.hoverColor; + this._sdfShader.activeColor = this._core.config.activeColor; + this._sdfShader.highlightMode = this._core.config.highlightMode; + this._sdfShader.sdfBuffer = (this.sdfBuffer || this._core.config.sdfBuffer) / 0xff; + this._sdfShader.sdfBackgroundColor = this.sdfBackgroundColor || (0, _glMatrix.vec3).fromValues(this._core.config.backgroundColor[0], this._core.config.backgroundColor[1], this._core.config.backgroundColor[2]); this._sdfShader.specularPower = this._config.specularPower; this._sdfShader.specularIntensity = this._config.specularIntensity; + this._sdfShader.ambient = this._config.ambient; this._sdfShader.apply(); this._sdfShader.isPickShader = false; - this._sdfShader.isShadowMap = false; - this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); - for(let i3 = 0; i3 < this._viewportCount; i3++){ - const viewport3 = i3 + this._viewportOffset; - this._gl.viewport(this._viewports[viewport3].x, this._viewports[viewport3].y, this._viewports[viewport3].width, this._viewports[viewport3].height); - this._sdfShader.vMatrix = this.vMatrices[viewport3]; - this._sdfShader.pMatrix = this.pMatrices[viewport3]; - this._sdfShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - if (this._config.isShadowEnabled) { - this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); - this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); - this._gl.cullFace(this._gl.FRONT); - this._sdfShader.isPickShader = false; - this._sdfShader.isShadowMap = true; - this._sdfShader.vMatrix = this._shadowVMatrix; - this._sdfShader.pMatrix = this._shadowPMatrix; + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewport]); + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + const vMatrix = this.vMatrices[viewport]; + if (xrFrame) { + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToLight, this._config.lightPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToLight, this._directionToLight); + const inverseVMatrix = this.inverseVMatrices[viewport]; + (0, _glMatrix.vec3).set(this._cameraPosition, inverseVMatrix[12], inverseVMatrix[13], inverseVMatrix[14]); + (0, _glMatrix.vec3).subtract(this._directionToCamera, this._cameraPosition, this._modelPosition); + (0, _glMatrix.vec3).normalize(this._directionToCamera, this._directionToCamera); + (0, _glMatrix.vec3).add(this._halfAngle, this._directionToLight, this._directionToCamera); + (0, _glMatrix.vec3).normalize(this._halfAngle, this._halfAngle); + (0, _glMatrix.mat3).fromMat4(this._mat3, vMatrix); + (0, _glMatrix.vec3).transformMat3(this._directionToLight, this._directionToLight, this._mat3); + (0, _glMatrix.vec3).transformMat3(this._halfAngle, this._halfAngle, this._mat3); + this._sdfShader.directionToLight = this._directionToLight; + this._sdfShader.halfAngle = this._halfAngle; + } else { + this._sdfShader.directionToLight = this._config.directionToLight; + this._sdfShader.halfAngle = this._config.halfAngle; + } + this._sdfShader.vMatrix = vMatrix; + this._sdfShader.pMatrix = this.pMatrices[viewport]; this._sdfShader.applyView(); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - this._gl.colorMask(true, true, true, true); - this._gl.cullFace(this._gl.BACK); + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - if (this.isPickingEnabled) { + if (this.isPickingEnabled && transitionBuffer.isPickingEnabled) { this._sdfShader.isPickShader = true; - this._sdfShader.isShadowMap = false; this._sdfShader.pMatrix = this.pickPMatrix; this._sdfShader.vMatrix = this.pickVMatrix; this._sdfShader.applyView(); this._shaderResources.bindFramebuffer(this._pickFrameBuffer); this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); - } - } - } - _postProcess(vMatrix, inverseVMatrix, pMatrix, viewport) { - if (this._deferredShader.isInitialized) { - this._gl.disable(this._gl.DEPTH_TEST); - let ssaoTexture; - if (this._config.isSsaoEnabled && this._ssaoShader.isInitialized) { - this._gl.viewport(0, 0, this._config.ssaoWidth, this._config.ssaoHeight); - ssaoTexture = this._ssaoTexture1; - this._shaderResources.bindFramebuffer(this._ssaoFrameBuffer1); - this._ssaoShader.vertexBuffer = this._quad.vertexBuffer; - this._ssaoShader.indexBuffer = this._quad.indexBuffer; - this._ssaoShader.texture2D1 = this._positionTexture; - this._ssaoShader.texture2D2 = this._normalTexture; - this._ssaoShader.texture2D3 = this._ssaoNoiseTexture; - this._ssaoShader.prepare(); - this._ssaoShader.pMatrix = pMatrix; - this._ssaoShader.ssaoNoiseSize = this._config.ssaoNoiseSize; - this._ssaoShader.ssaoRadius = this._config.ssaoRadius; - this._ssaoShader.ssaoPower = this._config.ssaoPower; - this._ssaoShader.ssaoKernel = this._ssaoSampleKernel; - this._ssaoShader.left = 0; - this._ssaoShader.top = 0; - this._ssaoShader.width = this._config.ssaoWidth; - this._ssaoShader.height = this._config.ssaoHeight; - this._ssaoShader.apply(); - this._ssaoShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - if (this._config.ssaoBlurEnabled && this._boxShader.isInitialized) { - ssaoTexture = this._ssaoTexture2; - this._shaderResources.bindFramebuffer(this._ssaoFrameBuffer2); - this._boxShader.vertexBuffer = this._quad.vertexBuffer; - this._boxShader.indexBuffer = this._quad.indexBuffer; - this._boxShader.texture2D = this._ssaoTexture1; - this._boxShader.prepare(); - this._boxShader.left = 0; - this._boxShader.top = 0; - this._boxShader.width = this._config.ssaoWidth; - this._boxShader.height = this._config.ssaoHeight; - this._boxShader.apply(); - this._boxShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - } - this._gl.viewport(viewport.left, viewport.top, viewport.width, viewport.height); - let postProcessFrameBuffer = this._postProcessFrameBuffer1; - this._shaderResources.bindFramebuffer(postProcessFrameBuffer); - this._deferredShader.vertexBuffer = this._quad.vertexBuffer; - this._deferredShader.indexBuffer = this._quad.indexBuffer; - this._deferredShader.texture2D1 = this._positionTexture; - this._deferredShader.texture2D2 = this._colorTexture; - this._deferredShader.texture2D3 = this._normalTexture; - this._deferredShader.texture2D4 = this._config.isSsaoEnabled ? ssaoTexture : null; - this._deferredShader.texture2D5 = this._shadowDepthTexture; - this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE); - this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE); - this._deferredShader.prepare(); - this._deferredShader.isShadowEnabled = this._config.isShadowEnabled; - this._deferredShader.isSsaoEnabled = this._config.isSsaoEnabled; - this._deferredShader.inverseVMatrix = inverseVMatrix; - this._deferredShader.shadowVMatrix = this._shadowVMatrix; - this._deferredShader.shadowPMatrix = this._shadowPMatrix; - this._deferredShader.vMatrix = vMatrix; - this._deferredShader.keyLightIntensity = this._config.keyLightIntensity; - this._deferredShader.fillLight1Intensity = this._config.fillLight1Intensity; - this._deferredShader.fillLight2Intensity = this._config.fillLight2Intensity; - this._core.camera.getPosition(this._cameraPosition); - (0, _glMatrix.mat3).fromMat4(this._cameraRotation, vMatrix); - (0, _glMatrix.vec3).set(this._position, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - (0, _glMatrix.vec3).normalize(this._deferredShader.directionToKeyLight, this._config.keyLightPosition); - (0, _glMatrix.vec3).subtract(this._direction, this._cameraPosition, this._position); - (0, _glMatrix.vec3).normalize(this._direction, this._direction); - (0, _glMatrix.vec3).add(this._deferredShader.keyLightHalfAngle, this._direction, this._deferredShader.directionToKeyLight); - (0, _glMatrix.vec3).normalize(this._deferredShader.keyLightHalfAngle, this._deferredShader.keyLightHalfAngle); - (0, _glMatrix.vec3).copy(this._deferredShader.directionToFillLight1, this._config.fillLight1Position); - (0, _glMatrix.vec3).copy(this._deferredShader.directionToFillLight2, this._config.fillLight2Position); - this._deferredShader.left = viewport.left; - this._deferredShader.top = viewport.top; - this._deferredShader.width = viewport.width; - this._deferredShader.height = viewport.height; - this._deferredShader.shadowMapWidth = this._config.shadowWidth; - this._deferredShader.shadowMapHeight = this._config.shadowHeight; - this._deferredShader.ambientIntensity = this._config.ambientIntensity; - this._deferredShader.materialIntensity = this._config.materialIntensity; - this._deferredShader.specularPower = this._config.specularPower; - this._deferredShader.specularIntensity = this._config.specularIntensity; - this._deferredShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - const widthHalf = Math.round(viewport.width / 2); - const heightHalf = Math.round(viewport.height / 2); - const widthQuarter = Math.round(widthHalf / 2); - const heightQuarter = Math.round(heightHalf / 2); - const widthEighth = Math.round(widthQuarter / 2); - const heightEighth = Math.round(heightQuarter / 2); - const widthSixteenth = Math.round(widthEighth / 2); - const heightSixteenth = Math.round(heightEighth / 2); - if (this._config.isDofEnabled && this._dofBlurShader.isInitialized && this._dofCombineShader.isInitialized) { - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessDofFrameBuffer); - this._dofBlurShader.vertexBuffer = this._quad.vertexBuffer; - this._dofBlurShader.indexBuffer = this._quad.indexBuffer; - this._dofBlurShader.texture2D1 = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture2 : this._postProcessTexture1; - this._dofBlurShader.texture2D2 = this._positionTexture; - this._dofBlurShader.prepare(); - this._dofBlurShader.focusDepth = this._config.dofFocusDistance; - this._dofBlurShader.nearFocusDepth = this._config.dofFocusDistance - this._config.dofFocusRange / 2; - this._dofBlurShader.farFocusDepth = this._config.dofFocusDistance + this._config.dofFocusRange / 2; - this._dofBlurShader.maxBackgroundBlur = this._config.dofMaxBackgroundBlur; - this._dofBlurShader.left = viewport.left; - this._dofBlurShader.top = viewport.top; - this._dofBlurShader.width = viewport.width; - this._dofBlurShader.height = viewport.height; - this._dofBlurShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - postProcessFrameBuffer = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessFrameBuffer2 : this._postProcessFrameBuffer1; - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, postProcessFrameBuffer); - this._dofCombineShader.vertexBuffer = this._quad.vertexBuffer; - this._dofCombineShader.indexBuffer = this._quad.indexBuffer; - this._dofCombineShader.texture2D1 = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture2 : this._postProcessTexture1; - this._dofCombineShader.texture2D2 = this._postProcessDofTexture; - this._dofCombineShader.prepare(); - this._dofCombineShader.focusDepth = this._config.dofFocusDistance; - this._dofCombineShader.left = viewport.left; - this._dofCombineShader.top = viewport.top; - this._dofCombineShader.width = viewport.width; - this._dofCombineShader.height = viewport.height; - this._dofCombineShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - if (this._config.isBloomEnabled && this._brightPassShader.isInitialized && this._gaussianShader.isInitialized) { - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer1); - this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; - this._brightPassShader.indexBuffer = this._quad.indexBuffer; - this._brightPassShader.texture2D = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture1 : this._postProcessTexture2; - this._brightPassShader.prepare(); - this._brightPassShader.width = widthHalf; - this._brightPassShader.height = heightHalf; - this._brightPassShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer1); - this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; - this._brightPassShader.indexBuffer = this._quad.indexBuffer; - this._brightPassShader.texture2D = this._postProcessHalfTexture1; - this._brightPassShader.prepare(); - this._brightPassShader.width = widthQuarter; - this._brightPassShader.height = heightQuarter; - this._brightPassShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer1); - this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; - this._brightPassShader.indexBuffer = this._quad.indexBuffer; - this._brightPassShader.texture2D = this._postProcessQuarterTexture1; - this._brightPassShader.prepare(); - this._brightPassShader.width = widthEighth; - this._brightPassShader.height = heightEighth; - this._brightPassShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer1); - this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; - this._brightPassShader.indexBuffer = this._quad.indexBuffer; - this._brightPassShader.texture2D = this._postProcessEighthTexture1; - this._brightPassShader.prepare(); - this._brightPassShader.width = widthSixteenth; - this._brightPassShader.height = heightSixteenth; - this._brightPassShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer2); - this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; - this._gaussianShader.indexBuffer = this._quad.indexBuffer; - this._gaussianShader.texture2D = this._postProcessHalfTexture1; - this._gaussianShader.prepare(); - this._gaussianShader.width = widthHalf; - this._gaussianShader.height = heightHalf; - this._gaussianShader.horizontal = true; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer1); - this._gaussianShader.texture2D = this._postProcessHalfTexture2; - this._gaussianShader.prepare(); - this._gaussianShader.horizontal = false; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer2); - this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; - this._gaussianShader.indexBuffer = this._quad.indexBuffer; - this._gaussianShader.texture2D = this._postProcessQuarterTexture1; - this._gaussianShader.prepare(); - this._gaussianShader.width = widthQuarter; - this._gaussianShader.height = heightQuarter; - this._gaussianShader.horizontal = true; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer1); - this._gaussianShader.texture2D = this._postProcessQuarterTexture2; - this._gaussianShader.prepare(); - this._gaussianShader.horizontal = false; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer2); - this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; - this._gaussianShader.indexBuffer = this._quad.indexBuffer; - this._gaussianShader.texture2D = this._postProcessEighthTexture1; - this._gaussianShader.prepare(); - this._gaussianShader.width = widthEighth; - this._gaussianShader.height = heightEighth; - this._gaussianShader.horizontal = true; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer1); - this._gaussianShader.texture2D = this._postProcessEighthTexture2; - this._gaussianShader.prepare(); - this._gaussianShader.horizontal = false; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer2); - this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; - this._gaussianShader.indexBuffer = this._quad.indexBuffer; - this._gaussianShader.texture2D = this._postProcessSixteenthTexture1; - this._gaussianShader.prepare(); - this._gaussianShader.width = widthSixteenth; - this._gaussianShader.height = heightSixteenth; - this._gaussianShader.horizontal = true; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer1); - this._gaussianShader.texture2D = this._postProcessSixteenthTexture2; - this._gaussianShader.prepare(); - this._gaussianShader.horizontal = false; - this._gaussianShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - if (this._config.isFxaaEnabled && this._fxaaShader.isInitialized) { - postProcessFrameBuffer = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessFrameBuffer2 : this._postProcessFrameBuffer1; - this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, postProcessFrameBuffer); - this._fxaaShader.vertexBuffer = this._quad.vertexBuffer; - this._fxaaShader.indexBuffer = this._quad.indexBuffer; - this._fxaaShader.texture2D = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture2 : this._postProcessTexture1; - this._fxaaShader.prepare(); - this._fxaaShader.left = viewport.left; - this._fxaaShader.top = viewport.top; - this._fxaaShader.width = viewport.width; - this._fxaaShader.height = viewport.height; - this._fxaaShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); - } - this._shaderResources.bindFramebuffer(null); - this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); - this._gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); - this._combineShader.vertexBuffer = this._quad.vertexBuffer; - this._combineShader.indexBuffer = this._quad.indexBuffer; - this._combineShader.texture2D1 = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture1 : this._postProcessTexture2; - if (this._config.isBloomEnabled) { - this._combineShader.texture2D2 = this._postProcessHalfTexture1; - this._combineShader.texture2D3 = this._postProcessQuarterTexture1; - this._combineShader.texture2D4 = this._postProcessEighthTexture1; - this._combineShader.texture2D5 = this._postProcessSixteenthTexture1; - } else { - this._combineShader.texture2D2 = null; - this._combineShader.texture2D3 = null; - this._combineShader.texture2D4 = null; - this._combineShader.texture2D5 = null; + this._shaderResources.ANGLE_instanced_arrays.drawElementsInstancedANGLE(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); } - this._combineShader.prepare(); - this._combineShader.viewport = viewport; - this._combineShader.intensity = this._config.bloomIntensity; - this._combineShader.apply(); - this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); } } } -},{"gl-matrix":"9GjEQ","../../main.js":"1Kju3","../renderer.js":"gKWdZ","./components/quad.js":"4iGAx","./buffer.js":"jiHXz","./config.js":"584NM","./shaders/shader.js":"5yb62","./shaders/texture.js":"kHekF","./shaders/lasso.js":"kkqPx","./shaders/sdftext.js":"S8Cvl","./shaders/pickgrid.js":"kIMzi","./shaders/unitblock.js":"9SVao","./shaders/unitsphere.js":"eRyuE","./shaders/unitcylinder.js":"kCOh8","./shaders/unitsdf.js":"cSNWw","./shaders/background.js":"fZOIf","./shaders/ssao.js":"2cBXg","./shaders/box.js":"6dStE","./shaders/deferred.js":"1QDMF","./shaders/combine.js":"aeB23","./shaders/dofblur.js":"4Mg1v","./shaders/downsample.js":"bpIiM","./shaders/gaussian.js":"3qhJJ","./shaders/dofcombine.js":"dn6BO","./shaders/fxaa.js":"hFWxV","./shaders/bright.js":"cLRip","../../helpers/angle.js":"eKtPm","../../helpers/pick.js":"9zmDo","./components/axes/cartesian2d.js":"jVY6s","./components/axes/cartesian3d.js":"6nMmw","./font.js":"YHBp5","./../../helpers/math.js":"fOnPF","../../constants.js":"2Scl5","../../vertex.js":"ddAub","../../helpers/texture.js":"bUBAh","./components/labels.js":"fnVLv","./components/image.js":"27hDl","./components/lasso.js":"9nFbm","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4iGAx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Quad", ()=>Quad); +},{"gl-matrix":"5x28d","../../main.js":"f421K","../renderer.js":"8zmPQ","./components/quad.js":"j6pP2","./buffer.js":"l0kgV","./config.js":"lRVKC","./shaders/shader.js":"hWbX1","./shaders/color.js":"jXv4X","./shaders/texture.js":"c5hna","./shaders/lasso.js":"5QPQk","./shaders/model.js":"5cbW3","./shaders/sdftext.js":"8CJWE","./shaders/pickgrid.js":"9bPD8","./shaders/unitblock.js":"jKxeO","./shaders/unitsphere.js":"72WuL","./shaders/unitcylinder.js":"16WiR","./shaders/unithexprism.js":"3fOzC","./shaders/unitsdf.js":"9zSFc","./shaders/anaglyph.js":"8jbJ4","../../helpers/texture.js":"bUoBU","../../helpers/pick.js":"1t2sb","./components/debug.js":"bt0jr","./components/axes/cartesian2d.js":"ktXb3","./components/axes/cartesian3d.js":"6CCj9","./components/controller.js":"hdGVP","./components/image.js":"j2Sdg","../../vertex.js":"4J2YE","./components/labels.js":"5a9e1","./font.js":"4v679","./components/lasso.js":"bi5JS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"j6pP2":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Quad", ()=>Quad); +var _glMatrix = require("gl-matrix"); var _quadJs = require("../../../meshes/quad.js"); class Quad { get isInitialized() { @@ -31247,15 +28858,15 @@ class Quad { } } -},{"gl-matrix":"9GjEQ","../../../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jiHXz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Buffer", ()=>Buffer); -parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); +},{"gl-matrix":"5x28d","../../../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"l0kgV":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _bufferJs = require("../../buffer.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Buffer", ()=>Buffer); +parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); +var _bufferJs = require("../../buffer.js"); var _mainJs = require("../../main.js"); var _atlasJs = require("./atlas.js"); var _paletteJs = require("./palette.js"); @@ -31263,9 +28874,6 @@ class Buffer extends (0, _bufferJs.BufferBase) { get vertexBuffer() { return this._vertexBuffer; } - constructor(core, ids){ - super(core, ids); - } initializeContext(gl) { this._gl = gl; this._vertexBuffer = gl.createBuffer(); @@ -31297,14 +28905,14 @@ class TransitionBuffer extends (0, _bufferJs.TransitionBufferBase) { } } -},{"../../buffer.js":"k3bT1","../../main.js":"1Kju3","./atlas.js":"iK5kv","./palette.js":"eosCg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iK5kv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Atlas", ()=>Atlas); +},{"../../buffer.js":"itbJk","../../main.js":"f421K","./atlas.js":"4oA1j","./palette.js":"6O8ED","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4oA1j":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _textureJs = require("../../helpers/texture.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Atlas", ()=>Atlas); +var _textureJs = require("../../helpers/texture.js"); var _atlasJs = require("../../atlas.js"); class Atlas extends (0, _atlasJs.AtlasBase) { get texture() { @@ -31336,14 +28944,14 @@ class Atlas extends (0, _atlasJs.AtlasBase) { } } -},{"../../helpers/texture.js":"bUBAh","../../atlas.js":"duwwc","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eosCg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Palette", ()=>Palette); +},{"../../helpers/texture.js":"bUoBU","../../atlas.js":"2peXi","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6O8ED":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _textureJs = require("../../helpers/texture.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Palette", ()=>Palette); +var _textureJs = require("../../helpers/texture.js"); var _paletteJs = require("../../palette.js"); class Palette extends (0, _paletteJs.PaletteBase) { get texture() { @@ -31373,133 +28981,53 @@ class Palette extends (0, _paletteJs.PaletteBase) { } } -},{"../../helpers/texture.js":"bUBAh","../../palette.js":"8zxgm","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"584NM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Config", ()=>Config); +},{"../../helpers/texture.js":"bUoBU","../../palette.js":"hZb65","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lRVKC":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Config", ()=>Config); +var _glMatrix = require("gl-matrix"); var _constantsJs = require("../../constants.js"); var _angleJs = require("../../helpers/angle.js"); var _rendererJs = require("../renderer.js"); class Config extends (0, _rendererJs.RendererConfig) { - get keyLightAltitude() { - return this._keyLightAltitude; - } - set keyLightAltitude(value) { - this._keyLightAltitude = value; - this._updateLights(); - } - get keyLightAzimuth() { - return this._keyLightAzimuth; - } - set keyLightAzimuth(value) { - this._keyLightAzimuth = value; - this._updateLights(); - } - get keyLightDistance() { - return this._keyLightDistance; - } - set keyLightDistance(value) { - this._keyLightDistance = value; - this._updateLights(); - } - get fillLight1Altitude() { - return this._fillLight1Altitude; - } - set fillLight1Altitude(value) { - this._fillLight1Altitude = value; - this._updateLights(); - } - get fillLight1Azimuth() { - return this._fillLight1Azimuth; - } - set fillLight1Azimuth(value) { - this._fillLight1Azimuth = value; - this._updateLights(); - } - get fillLight2Altitude() { - return this._fillLight2Altitude; - } - set fillLight2Altitude(value) { - this._fillLight2Altitude = value; - this._updateLights(); - } - get fillLight2Azimuth() { - return this._fillLight2Azimuth; - } - set fillLight2Azimuth(value) { - this._fillLight2Azimuth = value; - this._updateLights(); - } constructor(){ super(); - this._rotation = (0, _glMatrix.quat).create(); - this.keyLightPosition = (0, _glMatrix.vec3).create(); - this.fillLight1Position = (0, _glMatrix.vec3).create(); - this.fillLight2Position = (0, _glMatrix.vec3).create(); this.reset(); } - _updateLights() { - this._updateLight(this._keyLightAltitude, this._keyLightAzimuth, this._keyLightDistance, this.keyLightPosition); - this._updateLight(this._fillLight1Altitude, this._fillLight1Azimuth, 1, this.fillLight1Position); - this._updateLight(this._fillLight2Altitude, this._fillLight2Azimuth, 1, this.fillLight2Position); - } - _updateLight(altitude, azimuth, distance, position) { - (0, _glMatrix.quat).rotateY(this._rotation, (0, _constantsJs.Constants).QUAT_IDENTITY, (0, _angleJs.AngleHelper).degreesToRadians(azimuth)); - (0, _glMatrix.quat).rotateX(this._rotation, this._rotation, (0, _angleJs.AngleHelper).degreesToRadians(-altitude)); - (0, _glMatrix.vec3).transformQuat(position, (0, _constantsJs.Constants).VECTOR3_UNITZ, this._rotation); - (0, _glMatrix.vec3).scale(position, position, distance); - } reset() { - this.isSsaoEnabled = true; - this.ssaoWidth = 1024; - this.ssaoHeight = 1024; - this.ssaoBlurEnabled = true; - this.ssaoKernelSize = 8; - this.ssaoNoiseSize = 4; - this.ssaoRadius = 0.02; - this.ssaoPower = 1; - this.isShadowEnabled = true; - this.shadowWidth = 1024; - this.shadowHeight = 1024; - this.isDofEnabled = false; - this.dofAutoFocus = true; - this.dofFocusDistance = 0.5; - this.dofFocusRange = 0.5; - this.dofMaxBackgroundBlur = 0.75; - this.isBloomEnabled = false; - this.bloomIntensity = 2; this.specularIntensity = 0.15; this.specularPower = 150; - this.ambientIntensity = 0.1; - this.materialIntensity = 0.5; - this.keyLightIntensity = 1.5; - this.fillLight1Intensity = 0.25; - this.fillLight2Intensity = 0.25; - this._keyLightAltitude = 30; - this._keyLightAzimuth = -45; - this._keyLightDistance = 1; - this._fillLight1Altitude = 30; - this._fillLight1Azimuth = 45; - this._fillLight2Altitude = 30; - this._fillLight2Azimuth = -135; - this._updateLights(); + this.lightPosition = (0, _glMatrix.vec3).fromValues(-0.5, 0.5, 0); + this.ambient = 0.01; + const _quat1 = (0, _glMatrix.quat).create(); + const _quat2 = (0, _glMatrix.quat).create(); + let angle = (0, _angleJs.AngleHelper).degreesToRadians(15); + (0, _glMatrix.quat).setAxisAngle(_quat1, (0, _constantsJs.Constants).VECTOR3_UNITX, angle); + (0, _glMatrix.quat).multiply(_quat2, _quat1, _quat2); + angle = (0, _angleJs.AngleHelper).degreesToRadians(-15); + (0, _glMatrix.quat).setAxisAngle(_quat1, (0, _constantsJs.Constants).VECTOR3_UNITY, angle); + (0, _glMatrix.quat).multiply(_quat2, _quat2, _quat1); + this.directionToLight = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).transformQuat(this.directionToLight, (0, _constantsJs.Constants).VECTOR3_UNITZ, _quat2); + this.halfAngle = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).add(this.halfAngle, (0, _constantsJs.Constants).VECTOR3_UNITZ, this.directionToLight); + (0, _glMatrix.vec3).normalize(this.halfAngle, this.halfAngle); this.isFxaaEnabled = false; } } -},{"gl-matrix":"9GjEQ","../../constants.js":"2Scl5","../../helpers/angle.js":"eKtPm","../renderer.js":"gKWdZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5yb62":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Resources", ()=>Resources); -parcelHelpers.export(exports, "ShaderBase", ()=>ShaderBase); +},{"gl-matrix":"5x28d","../../constants.js":"lD0bG","../../helpers/angle.js":"53hwW","../renderer.js":"8zmPQ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hWbX1":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _pathJs = require("../../../helpers/path.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Resources", ()=>Resources); +parcelHelpers.export(exports, "ShaderBase", ()=>ShaderBase); +var _pathJs = require("../../../helpers/path.js"); var _mainJs = require("../../../main.js"); class Resources { bindFramebuffer(framebuffer) { @@ -31511,42 +29039,39 @@ class Resources { initializeContext(gl) { this._gl = gl; this.framebuffer = this._gl.createFramebuffer(); - this.OES_texture_float = gl.getExtension("OES_texture_float"); - this.OES_texture_float_linear = gl.getExtension("OES_texture_float_linear"); + this.ANGLE_instanced_arrays = gl.getExtension("ANGLE_instanced_arrays"); + this.OES_standard_derivatives = gl.getExtension("OES_standard_derivatives"); + this.EXT_frag_depth = gl.getExtension("EXT_frag_depth"); + this.OES_element_index_uint = gl.getExtension("OES_element_index_uint"); this.WEBGL_lose_context = gl.getExtension("WEBGL_lose_context"); } } Resources.glsl = { - "background.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform vec3 uColor;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\ngl_FragDepth = 0.99999;\nmyPosition = vec4(0.0, 0.0, -FAR_PLANE, 0.0);\nmyColor = vec4(uColor, 1.0);\nmyNormal = vec4(0.0, 0.0, 1.0, 0.0);\n}\n', - "box.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform vec4 uViewport;\nuniform sampler2D uSampler;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec2 texelSize = vec2(1.0) / uViewport.zw;\nfloat result = 0.0;\nfor (int x = -2; x < 2; x++)\n{\nfor (int y = -2; y < 2; y++)\n{\nvec2 offset = vec2(float(x) + 0.5, float(y) + 0.5) * texelSize;\nresult += texture(uSampler, texCoords + offset).r;\n}\n}\nresult /= 16.0;\nmyOutputColor = vec4(vec3(result), 1.0);\n}\n", - "bright.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform vec2 uResolution;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uResolution;\nvec4 color = texture(uSampler, texCoords);\nmyOutputColor = vec4(color.rgb * color.a, 1.0);\n}\n", - "combine.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform sampler2D uSampler3;\nuniform sampler2D uSampler4;\nuniform sampler2D uSampler5;\nuniform vec4 uViewport;\nuniform float uIntensity;\nout vec4 myOutputColor;\nvoid main() {\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec3 bloom =\ntexture(uSampler2, texCoords).rgb +\ntexture(uSampler3, texCoords).rgb +\ntexture(uSampler4, texCoords).rgb +\ntexture(uSampler5, texCoords).rgb;\nbloom *= uIntensity;\nvec3 color = texture(uSampler1, texCoords).rgb;\ncolor += bloom;\nmyOutputColor = vec4(color, 1.0);\n}\n", - "deferred.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform mat4 uInverseVMatrix;\nuniform mat4 uShadowVMatrix;\nuniform mat4 uShadowPMatrix;\nuniform bool uShadow;\nuniform bool uSsao;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform sampler2D uSampler3;\nuniform sampler2D uSampler4;\nuniform sampler2D uSampler5;\nuniform vec4 uViewport;\nuniform vec3 uKeyLightHalfAngle;\nuniform vec3 uDirectionToKeyLight;\nuniform vec3 uDirectionToFillLight1;\nuniform vec3 uDirectionToFillLight2;\nuniform vec2 uShadowMapSize;\nuniform float uKeyLightIntensity;\nuniform float uFillLight1Intensity;\nuniform float uFillLight2Intensity;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbientIntensity;\nuniform float uMaterialIntensity;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec4 position = texture(uSampler1, texCoords);\nvec4 color = texture(uSampler2, texCoords);\nvec4 normal = texture(uSampler3, texCoords);\nfloat shadow;\nif (uShadow)\n{\nvec4 positionWorld = uInverseVMatrix * vec4(position.xyz, 1.0);\nvec4 positionShadowView = uShadowVMatrix * positionWorld;\nvec4 positionShadowViewProjection = uShadowPMatrix * positionShadowView;\nvec3 projCoords = positionShadowViewProjection.xyz / positionShadowViewProjection.w;\nprojCoords = projCoords * 0.5 + 0.5;\nfloat minProjCoords = min(projCoords.x, projCoords.y);\nfloat maxProjCoords = max(projCoords.x, projCoords.y);\nif (minProjCoords < 0.0 || maxProjCoords > 1.0)\n{\nshadow = 1.0;\n}\nelse\n{\nfloat currentDepth = projCoords.z;\nfloat bias = 0.0;\nvec2 texelSize = 1.0 / uShadowMapSize;\nfor(int x = -1; x <= 1; ++x)\n{\nfor(int y = -1; y <= 1; ++y)\n{\nfloat pcfDepth = texture(uSampler5, projCoords.xy + vec2(x, y) * texelSize).r;\nshadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0;\n}\n}\nshadow /= 9.0;\nshadow = clamp(1.0 - shadow, 0.0, 1.0);\n}\n}\nelse\n{\nshadow = 1.0;\n}\nfloat ssao = uSsao ? texture(uSampler4, texCoords).r : 1.0;\nfloat diffuseIntensity = clamp(dot(normal.rgb, uDirectionToKeyLight), 0.0, 1.0) * uKeyLightIntensity * shadow;\ndiffuseIntensity += clamp(dot(normal.rgb, uDirectionToFillLight1), 0.0, 1.0) * uFillLight1Intensity * ssao;\ndiffuseIntensity += clamp(dot(normal.rgb, uDirectionToFillLight2), 0.0, 1.0) * uFillLight2Intensity * ssao;\nvec3 diffuse = color.rgb * diffuseIntensity * uMaterialIntensity;\nvec3 ambient = uAmbientIntensity * color.rgb * ssao;\nvec3 emissive = color.w * color.rgb;\nfloat specular = normal.w * clamp(pow(clamp(dot(normal.rgb, uKeyLightHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity * uKeyLightIntensity * shadow, 0.0, 1.0);\nvec3 result = min(ambient + diffuse + specular + emissive, 1.0);\nresult = pow(result, GAMMA);\nmyOutputColor = vec4(result, position.w);\n}\n', - "dofblur.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform vec4 uViewport;\nuniform float uFocusDepth;\nuniform float uNearFocusDepth;\nuniform float uFarFocusDepth;\nuniform float uMaxBackgroundBlur;\nout vec4 myOutputColor;\nfloat circleOfConfusion(in float depth )\n{\nfloat f;\nif (depth < uFocusDepth)\n{\nf = (depth - uFocusDepth) / (uFocusDepth - uNearFocusDepth);\nf = clamp(f, -1.0, 0.0);\n}\nelse\n{\nf = (depth - uFocusDepth) / (uFarFocusDepth - uFocusDepth);\nf = clamp(f, 0.0, uMaxBackgroundBlur);\n}\nreturn f * 0.5 + 0.5;\n}\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uViewport.zw;\nvec4 color = texture(uSampler1, texCoords);\nfloat depth = -texture(uSampler2, texCoords).z;\nfloat coc = circleOfConfusion(depth);\nmyOutputColor = vec4(coc);\n}\n", - "dofcombine.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform vec4 uViewport;\nuniform float uFocusDepth;\nuniform float uAperture;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nout vec4 myOutputColor;\nconst float MAX_CIRCLE_OF_CONFUSION = 3.0;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec2 texelSize = vec2(1.0) / uViewport.zw;\nvec2 texelSizeLow = texelSize * 4.0;\nconst int NUM_TAPS = 13;\nvec2 samples[NUM_TAPS];\nsamples[0] = vec2(-0.326212,-0.405810);\nsamples[1] = vec2(-0.840144,-0.073580);\nsamples[2] = vec2(-0.695914, 0.457137);\nsamples[3] = vec2(-0.203345, 0.620716);\nsamples[4] = vec2( 0.962340,-0.194983);\nsamples[5] = vec2( 0.473434,-0.480026);\nsamples[6] = vec2( 0.519456, 0.767022);\nsamples[7] = vec2( 0.185461,-0.893124);\nsamples[8] = vec2( 0.507431, 0.064425);\nsamples[9] = vec2( 0.896420, 0.412458);\nsamples[10] = vec2(-0.321940,-0.932615);\nsamples[11] = vec2(-0.791559,-0.597710);\nsamples[12] = vec2( 0.000000, 0.000000);\nconst float maxCoC = 5.0;\nconst float radiusScale = 0.5;\nvec4 cOut = texture(uSampler1, texCoords);\nfloat coc = texture(uSampler2, texCoords).r;\nfloat centerDepth = coc;\nfloat discRadius = abs(coc * 2.0 - 1.0) * maxCoC;\nfloat discRadiusLow = discRadius * radiusScale;\ncOut = vec4(0.0);\nfloat acc = 0.0;\nfor (int t = 0; t < NUM_TAPS; t++)\n{\nvec2 coordLow = texCoords + (texelSizeLow * samples[t] * discRadiusLow);\nvec2 coordHigh = texCoords + (texelSize * samples[t] * discRadius);\nvec4 tapLow = texture(uSampler1, coordLow);\nvec4 tapHigh = texture(uSampler1, coordHigh);\nfloat cocLow = texture(uSampler2, coordLow).r;\nfloat cocHigh = texture(uSampler2, coordHigh).r;\nfloat tapBlur = abs(cocHigh * 2.0 - 1.0);\nvec4 tap = mix(tapHigh, tapLow, tapBlur);\nfloat cocBlur = mix(cocHigh, cocLow, tapBlur);\ncocBlur = (cocBlur >= centerDepth) ? 1.0 : abs(cocBlur * 2.0 - 1.0);\ncOut += tap * cocBlur;\nacc += cocBlur;\n}\nvec4 result = cOut / acc;\nmyOutputColor = result;\n}\n", - "downsample.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform vec4 uViewport;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uViewport.zw;\nmyOutputColor = texture(uSampler, texCoords);\n}\n", - "fxaa.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nconst float FXAA_SPAN_MAX = 8.0;\nconst float FXAA_REDUCE_MUL = 1.0 / 8.0;\nconst float FXAA_REDUCE_MIN = 1.0 / 128.0;\nuniform sampler2D uSampler;\nuniform vec4 uViewport;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec2 texelSize = vec2(1.0) / uViewport.zw;\nvec3 color = texture(uSampler, texCoords).rgb;\nvec3 colorNW = texture(uSampler, vec2(texCoords.x - texelSize.x, texCoords.y - texelSize.y)).rgb;\nvec3 colorNE = texture(uSampler, vec2(texCoords.x + texelSize.x, texCoords.y - texelSize.y)).rgb;\nvec3 colorSW = texture(uSampler, vec2(texCoords.x - texelSize.x, texCoords.y + texelSize.y)).rgb;\nvec3 colorSE = texture(uSampler, vec2(texCoords.x + texelSize.x, texCoords.y + texelSize.y)).rgb;\nfloat luminance = dot(color, LUMINANCE);\nfloat luminanceNW = dot(colorNW, LUMINANCE);\nfloat luminanceNE = dot(colorNE, LUMINANCE);\nfloat luminanceSW = dot(colorSW, LUMINANCE);\nfloat luminanceSE = dot(colorSE, LUMINANCE);\nfloat luminanceMin = min(luminance, min(min(luminanceNW, luminanceNE), min(luminanceSW, luminanceSE)));\nfloat luminanceMax = max(luminance, max(max(luminanceNW, luminanceNE), max(luminanceSW, luminanceSE)));\nvec2 dir = vec2(luminanceSW + luminanceSE - luminanceNW - luminanceNE, luminanceNW + luminanceSW - luminanceNE - luminanceSE);\nfloat dirReduce = max((luminanceNW + luminanceNE + luminanceSW + luminanceSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texelSize;\nvec3 colorA = 0.5 * (\ntexture(uSampler, texCoords.xy + dir * (1.0/3.0 - 0.5)).rgb +\ntexture(uSampler, texCoords.xy + dir * (2.0/3.0 - 0.5)).rgb);\nvec3 colorB = colorA * 0.5 + 0.25 * (\ntexture(uSampler, texCoords.xy - dir * 0.5).rgb +\ntexture(uSampler, texCoords.xy + dir * 0.5).rgb);\nluminance = dot(colorB, LUMINANCE);\nif (luminance < luminanceMin || luminance > luminanceMax)\n{\nmyOutputColor = vec4(colorA, 1.0);\n}\nelse\n{\nmyOutputColor = vec4(colorB, 1.0);\n}\n}\n', - "gaussian.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform vec2 uResolution;\nuniform bool uHorizontal;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uResolution;\nvec2 texelSize = vec2(1.0) / uResolution;\nconst int NUM_WEIGHTS = 3;\nfloat weights[NUM_WEIGHTS];\nweights[0] = 0.2270270270;\nweights[1] = 0.3162162162;\nweights[2] = 0.0702702703;\nfloat offsets[NUM_WEIGHTS];\noffsets[0] = 0.0;\noffsets[1] = 1.3846153846;\noffsets[2] = 3.2307692308;\nvec3 color = texture(uSampler, texCoords).rgb * weights[0];\nif (uHorizontal)\n{\nfor (int i = 1; i < NUM_WEIGHTS; i++) {\ncolor += texture(uSampler, texCoords + vec2(texelSize.x * offsets[i], 0.0)).rgb * weights[i];\ncolor += texture(uSampler, texCoords - vec2(texelSize.x * offsets[i], 0.0)).rgb * weights[i];\n}\n}\nelse\n{\nfor (int i = 1; i < NUM_WEIGHTS; i++) {\ncolor += texture(uSampler, texCoords + vec2(0.0, texelSize.y * offsets[i])).rgb * weights[i];\ncolor += texture(uSampler, texCoords - vec2(0.0, texelSize.y * offsets[i])).rgb * weights[i];\n}\n}\nmyOutputColor = vec4(color, 1.0);\n}\n", - "lasso.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform vec3 uColor;\nuniform vec2 uThickness;\nuniform float uDashWidth;\nin mediump vec2 vTexCoord;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 distance = min(vTexCoord, 1.0 - vTexCoord);\nif (distance.x > uThickness.x && distance.y > uThickness.y) {\ndiscard;\n}\nvec2 texCoord = vec2(vTexCoord.x, 1.0 - vTexCoord.y);\nvec2 thickness = uThickness * uDashWidth;\nvec2 b = mod(floor(texCoord / thickness), 2.0);\nif (b.x > 0.0 && texCoord.x < 1.0 - thickness.x) {\ndiscard;\n}\nif (b.y > 0.0 && texCoord.y < 1.0 - thickness.y) {\ndiscard;\n}\nmyOutputColor = vec4(pow(uColor, GAMMA), 1.0);\n}\n', - "lasso.vertex.fx": "#version 300 es\nin vec3 aPosition;\nin mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nout mediump vec2 vTexCoord;\nvoid main(void) {\ngl_Position = uMMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\n}\n", - "pickgrid.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform bool uPick;\nuniform vec2 uFaceSize;\nuniform vec3 uMajorColor;\nuniform vec3 uMinorColor;\nuniform vec3 uZeroColor;\nuniform float uMajorThickness;\nuniform float uMinorThickness;\nuniform float uZeroThickness;\nuniform vec2 uZero;\nuniform vec2 uMinorGridlines;\nin lowp vec4 vColor;\nin mediump vec2 vTexCoord;\nin mediump vec4 vBounds;\nin mediump vec3 vNormal;\nin vec3 vViewPosition;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void) {\nif (uPick)\n{\nmyPosition = vColor;\n}\nelse\n{\nmyPosition.xyz = vViewPosition;\nvec2 buffer = fwidth(vTexCoord);\nvec2 distance, thickness, step;\nvec4 color = vColor;\nvec2 width = vBounds.zw - vBounds.xy;\ndistance = (vTexCoord - vBounds.xy) / width;\ndistance = min(abs(distance - floor(uMinorGridlines * distance) / uMinorGridlines), abs(distance - ceil(uMinorGridlines * distance) / uMinorGridlines));\ndistance *= width;\nthickness = vec2(uMinorThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMinorColor, color.xyz, min(step.x, step.y));\nthickness = vec2(uMajorThickness) / uFaceSize;\ndistance = min(vTexCoord - vBounds.xy, vBounds.zw - vTexCoord);\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMajorColor, color.xyz, min(step.x, step.y));\ndistance = abs(vTexCoord - uZero);\nthickness = vec2(uZeroThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uZeroColor, color.xyz, min(step.x, step.y));\nmyColor.w = 0.0;\nmyNormal.xyz = vNormal;\nmyNormal.w = 0.0;\nmyColor.xyz = color.xyz;\n}\n}\n', - "pickgrid.vertex.fx": "#version 300 es\nin vec3 aPosition;\nin lowp vec4 aIdColor;\nin mediump vec2 aTexCoord;\nin mediump vec3 aNormal;\nin mediump vec4 aBounds;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform bool uPick;\nuniform vec4 uPickedIdColor;\nuniform vec3 uBackground;\nuniform vec3 uHighlight;\nout lowp vec4 vColor;\nout mediump vec2 vTexCoord;\nout mediump vec4 vBounds;\nout mediump vec3 vNormal;\nout vec3 vViewPosition;\nvoid main(void) {\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize(vec3(mvMatrix * vec4(aNormal, 0.0)));\nvTexCoord = aTexCoord;\nvBounds = aBounds;\nvec4 viewPosition = mvMatrix * vec4(aPosition, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nif (uPick)\n{\nvColor = aIdColor;\n}\nelse\n{\nvColor = uPickedIdColor == aIdColor ? vec4(uHighlight, 1.0) : vColor = vec4(uBackground, 1.0);\n}\n}\n", - "sdftext.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform bool uPick;\nuniform vec3 uColor;\nuniform vec3 uHoverColor;\nuniform float uGamma;\nuniform vec3 uBorderColor;\nuniform float uBuffer;\nuniform float uBorderWidth;\nin mediump vec2 vTexCoord;\nin vec3 vViewPosition;\nin vec3 vNormal;\nin lowp vec4 vIdColor;\nin lowp float vHover;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nif (uPick) {\nmyPosition = vIdColor;\n}\nelse\n{\nfloat distance = texture(uSampler, vTexCoord).r;\nif (distance < uBuffer - uBorderWidth)\n{\ndiscard;\n}\nfloat gamma = fwidth(distance);\nfloat value = smoothstep(uBuffer - gamma, uBuffer + gamma, distance);\nmyColor.xyz = mix(uBorderColor, mix(uColor, uHoverColor, vHover), value);\nmyPosition.xyz = vViewPosition;\nmyNormal.xyz = vNormal;\nmyColor.w = 1.0;\nmyPosition.w = 0.0;\nmyNormal.w = 0.0;\n}\n}\n", - "sdftext.vertex.fx": "#version 300 es\nin lowp vec4 aIdColor;\nin vec3 aPosition;\nin mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform vec4 uPickedIdColor;\nout vec3 vViewPosition;\nout vec3 vNormal;\nout mediump vec2 vTexCoord;\nout lowp vec4 vIdColor;\nout lowp float vHover;\nvoid main(void)\n{\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = vec3(mvMatrix * vec4(0.0, 0.0, 1.0, 0.0));\nvec4 viewPosition = mvMatrix* vec4(aPosition, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvTexCoord = aTexCoord;\nvIdColor = aIdColor;\nvHover = uPickedIdColor == aIdColor ? 1.0 : 0.0;\n}\n", - "simple.vertex.fx": "#version 300 es\nin vec3 aPosition;\nvoid main(void) {\ngl_Position = vec4(aPosition, 1.0);\n}\n", - "ssao.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nconst int SSAO_KERNEL_SIZE = 8;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform sampler2D uSampler3;\nuniform mat4 uPMatrix;\nuniform vec4 uViewport;\nuniform float uSsaoNoiseSize;\nuniform float uSsaoRadius;\nuniform float uSsaoPower;\nuniform vec3 uSsaoKernel[SSAO_KERNEL_SIZE];\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec3 position = texture(uSampler1, texCoords).rgb;\nvec3 normal = texture(uSampler2, texCoords).rgb;\nfloat occlusion = 0.0;\nvec2 noiseScale = uViewport.zw / uSsaoNoiseSize;\nvec3 randomVec = texture(uSampler3, texCoords * noiseScale).rgb;\nvec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));\nvec3 bitangent = cross(normal, tangent);\nmat3 tbn = mat3(tangent, bitangent, normal);\nfor(int i = 0; i < SSAO_KERNEL_SIZE; i++)\n{\nvec3 mySample = tbn * uSsaoKernel[i];\nmySample = position + mySample * uSsaoRadius;\nvec4 offset = vec4(mySample, 1.0);\noffset = uPMatrix * offset;\noffset.xy /= offset.w;\noffset.xy = offset.xy * 0.5 + 0.5;\nfloat sampleDepth = texture(uSampler1, offset.xy).z;\nfloat rangeCheck = abs(position.z - sampleDepth) > uSsaoRadius ? 0.0 : 1.0;\nocclusion += (sampleDepth < mySample.z ? 0.0 : 1.0) * rangeCheck;\n}\nocclusion /= float(SSAO_KERNEL_SIZE);\nocclusion = pow(1.0 - occlusion, uSsaoPower);\nmyOutputColor = vec4(occlusion, 0.0, 0.0, 1.0);\n}\n", - "texture.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\nuniform sampler2D uSampler;\nin mediump vec2 vTexCoord;\nin vec3 vViewPosition;\nin vec3 vNormal;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nmyPosition.xyz = vViewPosition;\nmyColor.xyz = pow(texture(uSampler, vTexCoord).xyz, INV_GAMMA);\nmyColor.w = 0.0;\nmyNormal.xyz = vNormal;\nmyNormal.w = 0.0;\n}\n', - "texture.vertex.fx": "#version 300 es\nin vec3 aPosition;\nin mediump vec3 aNormal;\nin mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nout vec3 vViewPosition;\nout mediump vec3 vNormal;\nout mediump vec2 vTexCoord;\nvoid main(void)\n{\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize((mvMatrix * vec4(aNormal, 0.0)).xyz);\nvec4 viewPosition = mvMatrix * vec4(aPosition, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvTexCoord = aTexCoord;\n}\n", - "unitblock.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\n#include "intersect.include.fx"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin mediump vec3 vModelPosition;\nin vec3 vViewPosition;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = vViewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nfloat distanceSquared = (0.75 - dot2(vModelPosition)) * 2.0;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\nmyNormal.xyz = normal;\nfloat specular = 1.0;\nmyNormal.w = specular;\nmyColor.xyz = color;\n}\n}\n', - "unitblock.vertex.fx": '#version 300 es\n#include "quat.include.fx"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin mediump vec4 aRotation;\nin mediump vec4 aPreviousRotation;\nin lowp vec2 aColor;\nin lowp vec2 aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin vec2 aOrder;\nin float aId;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout mediump vec3 vModelPosition;\nout vec3 vViewPosition;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvModelPosition = vec3(0.0);\ngl_Position = vec4(0.0);\nvViewPosition = vec3(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nvModelPosition = aPosition;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n', - "unitcylinder.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\n#include "intersect.include.fx"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin vec3 vViewPosition;\nin vec4 vCircle1;\nin vec4 vCircle2;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform bool uShadow;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 tnor = iCappedCone(ro, rd, vCircle1.xyz, vCircle2.xyz, vCircle1.w, vCircle2.w, uShadow ? -1.0 : 1.0);\nfloat t = tnor.x;\nif (t < 0.0)\n{\ndiscard;\n}\nvec3 viewPosition = rd * t;\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepth = ndcDepth * 0.5 + 0.5;\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = viewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = tnor.yzw;\nmyNormal.xyz = normal;\nfloat distanceSquared = dot(normal, rd);\ndistanceSquared *= distanceSquared;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nfloat specular = 1.0;\nmyNormal.w = specular;\nmyColor.xyz = color;\n}\n}\n', - "unitcylinder.vertex.fx": '#version 300 es\n#include "common.include.fx"\n#include "quat.include.fx"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin mediump vec4 aRotation;\nin mediump vec4 aPreviousRotation;\nin lowp vec2 aColor;\nin lowp vec2 aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin float aId;\nin vec2 aOrder;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nuniform vec3 uIdentityRotation;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout vec3 vViewPosition;\nout vec4 vCircle1;\nout vec4 vCircle2;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvCircle1 = vec4(0.0);\nvCircle2 = vec4(0.0);\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec3 viewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition;\nposition.xz *= max(scale.x, scale.z);\nposition.y *= scale.y;\nvec3 direction = IDENTITY_ROTATION;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\ndirection = rotate(direction, quat);\n}\nvec3 viewDirection = (mvMatrix * vec4(direction, 0.0)).xyz;\nvec3 h = viewDirection * scale.y * 0.5;\nfloat r1 = length(viewDirection) * 0.5;\nfloat r2 = r1 * scale.z;\nr1 *= scale.x;\nvCircle1 = vec4(viewCenter - h, r1);\nvCircle2 = vec4(viewCenter + h, r2);\nvec4 viewPosition = mvMatrix * vec4(position + translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n', - "unitsdf.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\n#include "intersect.include.fx"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin mediump vec2 vTexCoord;\nin mediump vec2 vPreviousTexCoord;\nin mediump vec3 vModelPosition;\nin vec3 vViewPosition;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform sampler2D uSampler1;\nuniform sampler2D uPreviousSampler1;\nuniform bool uPick;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nfloat uBorderWidth = 0.0 / 255.0;\nfloat uBuffer = 192.0 / 255.0;\nvec3 uBorderColor = vec3(1.0, 1.0, 1.0);\nfloat distance = mix(texture(uPreviousSampler1, vPreviousTexCoord).r, texture(uSampler1, vTexCoord).r, vAnimation);\nif (distance < uBuffer - uBorderWidth) {\ndiscard;\n}\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = vViewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nfloat distanceSquared = (0.75 - dot2(vModelPosition)) * 2.0;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\nmyNormal.xyz = normal;\nfloat specular = 1.0;\nmyNormal.w = specular;\nvec3 uBorderColor = vec3(1.0, 1.0, 1.0);\nfloat uGamma = 0.0;\nfloat gamma = fwidth(distance);\nfloat value = smoothstep(uBuffer - gamma, uBuffer + gamma, distance);\nmyColor.xyz = mix(uBorderColor, color, value);\n}\n}\n', - "unitsdf.vertex.fx": '#version 300 es\n#include "quat.include.fx"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin mediump vec4 aRotation;\nin mediump vec4 aPreviousRotation;\nin mediump vec4 aTexCoord;\nin mediump vec4 aPreviousTexCoord;\nin lowp vec2 aColor;\nin lowp vec2 aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin vec2 aOrder;\nin float aId;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout mediump vec3 vModelPosition;\nout mediump vec2 vTexCoord;\nout mediump vec2 vPreviousTexCoord;\nout vec3 vViewPosition;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvModelPosition = vec3(0.0);\ngl_Position = vec4(0.0);\nvViewPosition = vec3(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nvModelPosition = aPosition;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvPreviousTexCoord.x = aPosition.x < 0.0 ? aPreviousTexCoord.x : aPreviousTexCoord.z;\nvPreviousTexCoord.y = aPosition.y > 0.0 ? aPreviousTexCoord.y : aPreviousTexCoord.w;\nvTexCoord.x = aPosition.x < 0.0 ? aTexCoord.x : aTexCoord.z;\nvTexCoord.y = aPosition.y > 0.0 ? aTexCoord.y : aTexCoord.w;\n}\n}\n', - "unitsphere.fragment.fx": '#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include "common.include.fx"\n#include "intersect.include.fx"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin vec3 vViewPosition;\nin vec3 vViewCenter;\nin mediump float vRadius;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform bool uShadow;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 s = vec4(vViewCenter, vRadius);\nfloat t = sphIntersect(ro, rd, s, uShadow ? -1.0 : 1.0);\nif (t < 0.0)\n{\ndiscard;\n}\nvec3 viewPosition = rd * t;\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepth = ndcDepth * 0.5 + 0.5;\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = viewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = (viewPosition - vViewCenter) / s.w;\nmyNormal.xyz = normal;\nfloat distanceSquared = dot(normal, rd);\ndistanceSquared *= distanceSquared;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nfloat specular = 1.0;\nmyNormal.w = specular;\nmyColor.xyz = color;\n}\n}\n', - "unitsphere.vertex.fx": '#version 300 es\n#include "common.include.fx"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin lowp float aColor;\nin lowp float aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin float aId;\nin vec2 aOrder;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout mediump float vRadius;\nout vec3 vViewPosition;\nout vec3 vViewCenter;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvViewCenter = vec3(0.0);\nvRadius = 0.0;\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nfloat scale = mix(min(aPreviousScale.x, min(aPreviousScale.y, aPreviousScale.z)), min(aScale.x, min(aScale.y, aScale.z)), animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvViewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\ntranslation.xyz += aPosition * scale;\nvec4 viewPosition = mvMatrix * vec4(translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = vec2(aColor, aPreviousColor);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvRadius = distance(vViewPosition, vViewCenter) / ROOT_THREE;\n}\n}\n', - "common.include.fx": "const float NEAR_PLANE = 0.01;\nconst float FAR_PLANE = 100.0;\nconst float DEPTH_A = 1.0002000200020003;\nconst float DEPTH_B = 0.020002000200020003;\nconst vec3 GAMMA = vec3(0.45454545454545453);\nconst vec3 INV_GAMMA = vec3(2.2);\nconst vec3 LUMINANCE = vec3(0.2126, 0.7152, 0.0722);\nconst float PI = 3.1415926538;\nconst float ROOT_TWO = 1.4142135624;\nconst float ROOT_TWO_OVER_TWO = 0.7071067811865476;\nconst float ROOT_THREE = 1.7320508075688772;\nconst float ROOT_THREE_OVER_TWO = 0.8660254037844386;\nconst vec3 IDENTITY_ROTATION = vec3(0.0, 1.0, 0.0);\nfloat dot2(in vec2 v) { return dot(v, v); }\nfloat dot2(in vec3 v) { return dot(v, v); }\n", - "intersect.include.fx": "float sphIntersect( in vec3 ro, in vec3 rd, in vec4 sph, in float shadow)\n{\nvec3 oc = ro - sph.xyz;\nfloat b = dot( oc, rd );\nfloat c = dot( oc, oc ) - sph.w*sph.w;\nfloat h = b*b - c;\nif( h<0.0 ) return -1.0;\nreturn -b - shadow * sqrt( h );\n}\nfloat roundedboxIntersect( in vec3 ro, in vec3 rd, in vec3 size, in float rad )\n{\nvec3 m = 1.0/rd;\nvec3 n = m*ro;\nvec3 k = abs(m)*(size+rad);\nvec3 t1 = -n - k;\nvec3 t2 = -n + k;\nfloat tN = max( max( t1.x, t1.y ), t1.z );\nfloat tF = min( min( t2.x, t2.y ), t2.z );\nif( tN > tF || tF < 0.0) return -1.0;\nfloat t = tN;\nvec3 pos = ro+t*rd;\nvec3 s = sign(pos);\nro *= s;\nrd *= s;\npos *= s;\npos -= size;\npos = max( pos.xyz, pos.yzx );\nif( min(min(pos.x,pos.y),pos.z)<0.0 ) return t;\nvec3 oc = ro - size;\nvec3 dd = rd*rd;\nvec3 oo = oc*oc;\nvec3 od = oc*rd;\nfloat ra2 = rad*rad;\nt = 1e20;\n{\nfloat b = od.x + od.y + od.z;\nfloat c = oo.x + oo.y + oo.z - ra2;\nfloat h = b*b - c;\nif( h>0.0 ) t = -b-sqrt(h);\n}\n{\nfloat a = dd.y + dd.z;\nfloat b = od.y + od.z;\nfloat c = oo.y + oo.z - ra2;\nfloat h = b*b - a*c;\nif( h>0.0 )\n{\nh = (-b-sqrt(h))/a;\nif( h>0.0 && h<t && abs(ro.x+rd.x*h)<size.x ) t = h;\n}\n}\n{\nfloat a = dd.z + dd.x;\nfloat b = od.z + od.x;\nfloat c = oo.z + oo.x - ra2;\nfloat h = b*b - a*c;\nif( h>0.0 )\n{\nh = (-b-sqrt(h))/a;\nif( h>0.0 && h<t && abs(ro.y+rd.y*h)<size.y ) t = h;\n}\n}\n{\nfloat a = dd.x + dd.y;\nfloat b = od.x + od.y;\nfloat c = oo.x + oo.y - ra2;\nfloat h = b*b - a*c;\nif( h>0.0 )\n{\nh = (-b-sqrt(h))/a;\nif( h>0.0 && h<t && abs(ro.z+rd.z*h)<size.z ) t = h;\n}\n}\nif( t>1e19 ) t=-1.0;\nreturn t;\n}\nvec3 roundedboxNormal( in vec3 pos, in vec3 siz, in float rad )\n{\nreturn sign(pos)*normalize(max(abs(pos)-siz,0.0));\n}\nvec4 iCappedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb, in float shadow)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(oa, ba);\nfloat m2 = dot(ob, ba);\nfloat m3 = dot(rd, ba);\nif (m1 < 0.0) { if (dot2(oa * m3 - rd * m1) < (ra * ra * m3 * m3)) return vec4(-m1 / m3, -ba * inversesqrt(m0)); }\nelse if (m2 > 0.0) { if (dot2(ob * m3 - rd * m2) < (rb * rb * m3 * m3)) return vec4(-m2 / m3, ba * inversesqrt(m0)); }\nfloat m4 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat rr = ra - rb;\nfloat hy = m0 + rr * rr;\nfloat k2 = m0 * m0 - m3 * m3 * hy;\nfloat k1 = m0 * m0 * m4 - m1 * m3 * hy + m0 * ra * (rr * m3 * 1.0);\nfloat k0 = m0 * m0 * m5 - m1 * m1 * hy + m0 * ra * (rr * m1 * 2.0 - m0 * ra);\nfloat h = k1 * k1 - k2 * k0;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-k1 - shadow * sqrt(h)) / k2;\nfloat y = m1 + t * m3;\nif (y > 0.0 && y < m0)\n{\nreturn vec4(t, normalize(m0 * (m0 * (oa + t * rd) + rr * ba * ra) - ba * hy * y));\n}\nreturn vec4(-1.0);\n}\nvec4 iRoundedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb, in float shadow)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat rr = ra - rb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(ba, oa);\nfloat m2 = dot(ba, rd);\nfloat m3 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat m6 = dot(ob, rd);\nfloat m7 = dot(ob, ob);\nfloat d2 = m0 - rr * rr;\nfloat k2 = d2 - m2 * m2;\nfloat k1 = d2 * m3 - m1 * m2 + m2 * rr * ra;\nfloat k0 = d2 * m5 - m1 * m1 + m1 * rr * ra * 2.0 - m0 * ra * ra;\nfloat h = k1 * k1 - k0 * k2;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-shadow * sqrt(h) - k1) / k2;\nfloat y = m1 - ra * rr + t * m2;\nif (y > 0.0 && y < d2)\n{\nreturn vec4(t, normalize(d2 * (oa + t * rd) - ba * y));\n}\nfloat h1 = m3 * m3 - m5 + ra * ra;\nfloat h2 = m6 * m6 - m7 + rb * rb;\nif (max(h1, h2) < 0.0) return vec4(-1.0);\nvec4 r = vec4(1e20);\nif (h1 > 0.0)\n{\nt = -m3 - shadow * sqrt( h1 );\nr = vec4(t, (oa + t * rd) / ra);\n}\nif (h2 > 0.0)\n{\nt = -m6 - shadow * sqrt( h2 );\nif (t < r.x)\nr = vec4(t, (ob + t * rd) / rb);\n}\nreturn r;\n}\n", + "anaglyph.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform vec4 uViewport;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nconst vec3 LEFT_MASK = vec3(1.0, 0.0, 0.0);\nconst vec3 RIGHT_MASK = vec3(0.0, 1.0, 1.0);\nvoid main() {\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec3 color = LEFT_MASK * dot(texture2D(uSampler1, texCoords).rgb, LUMINANCE);\ncolor += RIGHT_MASK * dot(texture2D(uSampler2, texCoords).rgb, LUMINANCE);\ngl_FragColor = vec4(color, 1.0);\n}\n", + "color.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nvarying lowp vec3 vColor;\nvoid main(void)\n{\ngl_FragColor = vec4(pow(vColor, GAMMA), 1.0);\n}\n", + "color.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute lowp vec3 aColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nvarying lowp vec3 vColor;\nvoid main(void) {\ngl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aPosition, 1.0);\nvColor = aColor;\n}\n", + "lasso.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform vec3 uColor;\nuniform vec2 uThickness;\nuniform float uDashWidth;\nvarying mediump vec2 vTexCoord;\nvoid main(void)\n{\nvec2 distance = min(vTexCoord, 1.0 - vTexCoord);\nif (distance.x > uThickness.x && distance.y > uThickness.y) {\ndiscard;\n}\nvec2 texCoord = vec2(vTexCoord.x, 1.0 - vTexCoord.y);\nvec2 thickness = uThickness * uDashWidth;\nvec2 b = mod(floor(texCoord / thickness), 2.0);\nif (b.x > 0.0 && texCoord.x < 1.0 - thickness.x) {\ndiscard;\n}\nif (b.y > 0.0 && texCoord.y < 1.0 - thickness.y) {\ndiscard;\n}\ngl_FragColor = vec4(pow(uColor, GAMMA), 1.0);\n}\n", + "lasso.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nvarying mediump vec2 vTexCoord;\nvoid main(void) {\ngl_Position = uMMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\n}\n", + "model.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform sampler2D uSampler;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nvarying mediump vec3 vNormal;\nvarying mediump vec2 vTexCoord;\nvoid main(void)\n{\ngl_FragColor = vec4(pow(texture2D(uSampler, vTexCoord).xyz, GAMMA), 1.0);\nvec3 color = texture2D(uSampler, vTexCoord).xyz;\nfloat ambient = 0.01;\nvec3 normal = normalize(vNormal);\nfloat diffuse = 0.5 * max(dot(uDirectionToLight, normal), 0.0);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (ambient + diffuse);\ncolor += specular;\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n", + "model.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute mediump vec3 aNormal;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nvarying mediump vec3 vNormal;\nvarying mediump vec2 vTexCoord;\nvoid main(void) {\nvTexCoord = aTexCoord;\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = vec3(mvMatrix * vec4(aNormal, 0.0));\ngl_Position = uPMatrix * mvMatrix * vec4(aPosition, 1.0);\n}\n", + "pickgrid.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\n#define Derivatives\nuniform bool uPick;\nuniform vec2 uFaceSize;\nuniform vec3 uMajorColor;\nuniform vec3 uMinorColor;\nuniform vec3 uZeroColor;\nuniform float uMajorThickness;\nuniform float uMinorThickness;\nuniform float uZeroThickness;\nuniform vec2 uZero;\nuniform vec2 uMinorGridlines;\nuniform vec3 uDirectionToLight;\nvarying lowp vec4 vColor;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec4 vBounds;\nvarying mediump vec3 vNormal;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void) {\nif (uPick)\n{\ngl_FragColor = vColor;\n}\nelse\n{\nvec2 buffer;\n#ifdef Derivatives\nbuffer = fwidth(vTexCoord);\n#else\nbuffer = vec2(0.002);\n#endif\nvec2 distance, thickness, step;\nvec4 color = vColor;\nvec2 width = vBounds.zw - vBounds.xy;\ndistance = (vTexCoord - vBounds.xy) / width;\ndistance = min(abs(distance - floor(uMinorGridlines * distance) / uMinorGridlines), abs(distance - ceil(uMinorGridlines * distance) / uMinorGridlines));\ndistance *= width;\nthickness = vec2(uMinorThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMinorColor, color.xyz, min(step.x, step.y));\nthickness = vec2(uMajorThickness) / uFaceSize;\ndistance = min(vTexCoord - vBounds.xy, vBounds.zw - vTexCoord);\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMajorColor, color.xyz, min(step.x, step.y));\ndistance = abs(vTexCoord - uZero);\nthickness = vec2(uZeroThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uZeroColor, color.xyz, min(step.x, step.y));\nfloat diffuse = 0.2 * max(dot(uDirectionToLight, vNormal), 0.0);\nfloat ambient = 0.8;\ncolor.xyz *= (ambient + diffuse);\ncolor.xyz = pow(color.xyz, GAMMA);\ngl_FragColor = color;\n}\n}\n", + "pickgrid.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute lowp vec4 aIdColor;\nattribute mediump vec2 aTexCoord;\nattribute mediump vec3 aNormal;\nattribute mediump vec4 aBounds;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform bool uPick;\nuniform vec4 uPickedIdColor;\nuniform vec3 uBackground;\nuniform vec3 uHighlight;\nvarying lowp vec4 vColor;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec4 vBounds;\nvarying mediump vec3 vNormal;\nvoid main(void) {\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize(vec3(mvMatrix * vec4(aNormal, 0.0)));\nvTexCoord = aTexCoord;\nvBounds = aBounds;\ngl_Position = uPMatrix * mvMatrix * vec4(aPosition, 1.0);\nif (uPick)\n{\nvColor = aIdColor;\n}\nelse\n{\nvColor = uPickedIdColor == aIdColor ? vec4(uHighlight, 1.0) : vColor = vec4(uBackground, 1.0);\n}\n}\n", + "sdftext.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\n#define Derivatives\nuniform sampler2D uSampler;\nuniform bool uPick;\nuniform vec3 uColor;\nuniform vec3 uHoverColor;\nuniform float uGamma;\nuniform vec3 uBorderColor;\nuniform float uBuffer;\nuniform float uBorderWidth;\nvarying mediump vec2 vTexCoord;\nvarying lowp vec4 vIdColor;\nvarying lowp float vHover;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void) {\nif (uPick) {\ngl_FragColor = vIdColor;\n}\nelse {\nfloat distance = texture2D(uSampler, vTexCoord).r;\nif (distance < uBuffer - uBorderWidth) {\ndiscard;\n}\nfloat gamma;\n#ifdef Derivatives\ngamma = fwidth(distance);\n#else\ngamma = uGamma;\n#endif\nfloat value = smoothstep(uBuffer - gamma, uBuffer + gamma, distance);\ngl_FragColor = vec4(pow(mix(uBorderColor, mix(uColor, uHoverColor, vHover), value), GAMMA), 1.0);\n}\n}\n", + "sdftext.vertex.fx": "#version 100\nattribute lowp vec4 aIdColor;\nattribute vec3 aPosition;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform vec4 uPickedIdColor;\nvarying mediump vec2 vTexCoord;\nvarying lowp vec4 vIdColor;\nvarying lowp float vHover;\nvoid main(void) {\ngl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\nvIdColor = aIdColor;\nvHover = uPickedIdColor == aIdColor ? 1.0 : 0.0;\n}\n", + "simple.vertex.fx": "#version 100\nattribute vec3 aPosition;\nvoid main(void) {\ngl_Position = vec4(aPosition, 1.0);\n}\n", + "texture.fragment.fx": "#version 100\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform bool uPick;\nvarying mediump vec2 vTexCoord;\nvoid main(void)\n{\nif (uPick) {\ngl_FragColor = vec4(0.0);\n}\nelse {\ngl_FragColor = vec4(texture2D(uSampler, vTexCoord).xyz, 1.0);\n}\n}\n", + "texture.vertex.fx": "#version 100\nattribute vec3 aPosition;\nattribute mediump vec3 aNormal;\nattribute mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nvarying mediump vec3 vNormal;\nvarying mediump vec2 vTexCoord;\nvoid main(void) {\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize((mvMatrix * vec4(aNormal, 0.0)).xyz);\ngl_Position = uPMatrix * mvMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\n}\n", + "unitblock.fragment.fx": "#version 100\n#define Derivatives\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbient;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void)\n{\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nfloat diffuse, specular;\n#ifdef Derivatives\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\ndiffuse = clamp(dot(uDirectionToLight, normal), 0.0, 1.0);\nspecular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\n#else\ndiffuse = 1.0;\nspecular = 0.0;\n#endif\ncolor *= (uAmbient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n", + "unitblock.vertex.fx": "#version 100\n#include \"quat.include.fx\"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\ngl_Position = vec4(0.0);\n#ifdef Derivatives\nvViewPosition = vec3(0.0);\n#endif\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\n#ifdef Derivatives\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\n#else\ngl_Position = uPMatrix * mvMatrix * vec4(position, 1.0);\n#endif\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n", + "unitcylinder.fragment.fx": "#version 100\n#define FragDepth\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec4 vCircle1;\nvarying vec4 vCircle2;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbient;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\n#ifdef FragDepth\n#extension GL_EXT_frag_depth : enable\n#endif\nfloat dot2(in vec2 v) { return dot(v, v); }\nfloat dot2(in vec3 v) { return dot(v, v); }\nvec4 iCappedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(oa, ba);\nfloat m2 = dot(ob, ba);\nfloat m3 = dot(rd, ba);\nif (m1 < 0.0) { if (dot2(oa * m3 - rd * m1) < (ra * ra * m3 * m3)) return vec4(-m1 / m3, -ba * inversesqrt(m0)); }\nelse if (m2 > 0.0) { if (dot2(ob * m3 - rd * m2) < (rb * rb * m3 * m3)) return vec4(-m2 / m3, ba * inversesqrt(m0)); }\nfloat m4 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat rr = ra - rb;\nfloat hy = m0 + rr * rr;\nfloat k2 = m0 * m0 - m3 * m3 * hy;\nfloat k1 = m0 * m0 * m4 - m1 * m3 * hy + m0 * ra * (rr * m3 * 1.0);\nfloat k0 = m0 * m0 * m5 - m1 * m1 * hy + m0 * ra * (rr * m1 * 2.0 - m0 * ra);\nfloat h = k1 * k1 - k2 * k0;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-k1 - sqrt(h)) / k2;\nfloat y = m1 + t * m3;\nif (y > 0.0 && y < m0)\n{\nreturn vec4(t, normalize(m0 * (m0 * (oa + t * rd) + rr * ba * ra) - ba * hy * y));\n}\nreturn vec4(-1.0);\n}\nvec4 iRoundedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat rr = ra - rb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(ba, oa);\nfloat m2 = dot(ba, rd);\nfloat m3 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat m6 = dot(ob, rd);\nfloat m7 = dot(ob, ob);\nfloat d2 = m0 - rr * rr;\nfloat k2 = d2 - m2 * m2;\nfloat k1 = d2 * m3 - m1 * m2 + m2 * rr * ra;\nfloat k0 = d2 * m5 - m1 * m1 + m1 * rr * ra * 2.0 - m0 * ra * ra;\nfloat h = k1 * k1 - k0 * k2;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-sqrt(h) - k1) / k2;\nfloat y = m1 - ra * rr + t * m2;\nif (y > 0.0 && y < d2)\n{\nreturn vec4(t, normalize(d2 * (oa + t * rd) - ba * y));\n}\nfloat h1 = m3 * m3 - m5 + ra * ra;\nfloat h2 = m6 * m6 - m7 + rb * rb;\nif (max(h1, h2) < 0.0) return vec4(-1.0);\nvec4 r = vec4(1e20);\nif (h1 > 0.0)\n{\nt = -m3 - sqrt(h1);\nr = vec4(t, (oa + t * rd) / ra);\n}\nif (h2 > 0.0)\n{\nt = -m6 - sqrt(h2);\nif (t < r.x)\nr = vec4(t, (ob + t * rd) / rb);\n}\nreturn r;\n}\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 tnor = iCappedCone(ro, rd, vCircle1.xyz, vCircle2.xyz, vCircle1.w, vCircle2.w);\nfloat t = tnor.x;\nif (t < 0.0)\n{\ndiscard;\n}\nelse\n{\nvec3 viewPosition = rd * t;\n#ifdef FragDepth\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepthEXT = ndcDepth * 0.5 + 0.5;\n#endif\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = tnor.yzw;\nfloat diffuse = clamp(dot(uDirectionToLight, normal), 0.0, 1.0);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (uAmbient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n}\n", + "unitcylinder.vertex.fx": "#version 100\n#include \"common.include.fx\"\n#include \"quat.include.fx\"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nuniform vec3 uIdentityRotation;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec4 vCircle1;\nvarying vec4 vCircle2;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvCircle1 = vec4(0.0);\nvCircle2 = vec4(0.0);\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec3 viewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition;\nposition.xz *= max(scale.x, scale.z);\nposition.y *= scale.y;\nvec3 direction = IDENTITY_ROTATION;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\ndirection = rotate(direction, quat);\n}\nvec3 viewDirection = (mvMatrix * vec4(direction, 0.0)).xyz;\nvec3 h = viewDirection * scale.y * 0.5;\nfloat r1 = length(viewDirection) * 0.5;\nfloat r2 = r1 * scale.z;\nr1 *= scale.x;\nvCircle1 = vec4(viewCenter - h, r1);\nvCircle2 = vec4(viewCenter + h, r2);\nvec4 viewPosition = mvMatrix * vec4(position + translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n", + "unithexprism.fragment.fx": "#version 100\n#define FragDepth\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvarying float vRadius;\nvarying float vHeight;\nvarying float vScaling;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbient;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\nuniform mat4 uVMatrix;\n#ifdef FragDepth\n#extension GL_EXT_frag_depth : enable\n#endif\nvec4 iHexPrism( in vec3 ro, in vec3 rd, in float ra, in float he )\n{\nconst vec3 n1 = vec3( 1.0,0.0,0.0);\nconst vec3 n2 = vec3( 0.5,0.0,ROOT_THREE_OVER_TWO);\nconst vec3 n3 = vec3(-0.5,0.0,ROOT_THREE_OVER_TWO);\nconst vec3 n4 = vec3( 0.0,1.0,0.0);\nvec3 t1 = vec3((vec2(ra,-ra)-dot(ro,n1))/dot(rd,n1), 1.0);\nvec3 t2 = vec3((vec2(ra,-ra)-dot(ro,n2))/dot(rd,n2), 1.0);\nvec3 t3 = vec3((vec2(ra,-ra)-dot(ro,n3))/dot(rd,n3), 1.0);\nvec3 t4 = vec3((vec2(he,-he)-dot(ro,n4))/dot(rd,n4), 1.0);\nif( t1.y<t1.x ) t1=vec3(t1.yx,-1.0);\nif( t2.y<t2.x ) t2=vec3(t2.yx,-1.0);\nif( t3.y<t3.x ) t3=vec3(t3.yx,-1.0);\nif( t4.y<t4.x ) t4=vec3(t4.yx,-1.0);\nvec4 tN=vec4(t1.x,t1.z*n1);\nif( t2.x>tN.x ) tN=vec4(t2.x,t2.z*n2);\nif( t3.x>tN.x ) tN=vec4(t3.x,t3.z*n3);\nif( t4.x>tN.x ) tN=vec4(t4.x,t4.z*n4);\nfloat tF = min(min(t1.y,t2.y),min(t3.y,t4.y));\nif( tN.x>tF || tF<0.0) return vec4(-1.0);\nreturn tN;\n}\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = -vViewCenter;\nmat3 rot = mat3(uVMatrix);\nvec3 rdd = rd * rot;\nvec3 roo = ro * rot;\nvec4 tnor = iHexPrism(roo, rdd, vRadius * vScaling, vHeight * vScaling);\nfloat t = tnor.x;\nif (t < 0.0)\n{\ndiscard;\n}\nelse\n{\nvec3 viewPosition = rd * t;\n#ifdef FragDepth\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepthEXT = ndcDepth * 0.5 + 0.5;\n#endif\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = rot * tnor.yzw;\nfloat diffuse = clamp(dot(uDirectionToLight, normal), 0.0, 1.0);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (uAmbient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n}\n", + "unithexprism.vertex.fx": "#version 100\n#include \"common.include.fx\"\n#include \"quat.include.fx\"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nuniform vec3 uIdentityRotation;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvarying float vRadius;\nvarying float vHeight;\nvarying float vScaling;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvRadius = 0.0;\nvHeight = 0.0;\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvViewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvRadius = scale.x * ROOT_THREE_OVER_TWO;\nvHeight = scale.y;\nvec3 position = aPosition;\nposition.y *= scale.y;\nposition.z *= scale.x;\nposition.x *= scale.x * ROOT_THREE_OVER_TWO;\nvec3 direction = IDENTITY_ROTATION;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\ndirection = rotate(direction, quat);\n}\nvec3 viewDirection = (mvMatrix * vec4(direction, 0.0)).xyz;\nvec4 viewPosition = mvMatrix * vec4(position + translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvScaling = length(uMMatrix[0].xyz) / 2.0;\n}\n}\n", + "unitsdf.fragment.fx": "#version 100\n#define Derivatives\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec2 vPreviousTexCoord;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform sampler2D uSampler1;\nuniform sampler2D uPreviousSampler1;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbient;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\nuniform vec3 uBackgroundColor;\nuniform float uBuffer;\n#ifdef Derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\nvoid main(void) {\nfloat distance = mix(texture2D(uPreviousSampler1, vPreviousTexCoord).r, texture2D(uSampler1, vTexCoord).r, vAnimation);\nif (distance < uBuffer) {\ndiscard;\n}\nif (uPick) {\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nfloat diffuse, specular;\n#ifdef Derivatives\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\ndiffuse = clamp(dot(uDirectionToLight, normal), 0.0, 1.0);\nspecular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\n#else\ndiffuse = 1.0;\nspecular = 0.0;\n#endif\ncolor *= (uAmbient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\nfloat uGamma = 0.0;\nfloat gamma;\n#ifdef Derivatives\ngamma = fwidth(distance);\n#else\ngamma = uGamma;\n#endif\nfloat value = smoothstep(uBuffer + gamma, uBuffer, distance);\ngl_FragColor = vec4(mix(color, uBackgroundColor, value), 1.0);\n}\n}\n", + "unitsdf.vertex.fx": "#version 100\n#include \"quat.include.fx\"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute mediump vec4 aRotation;\nattribute mediump vec4 aPreviousRotation;\nattribute mediump vec4 aTexCoord;\nattribute mediump vec4 aPreviousTexCoord;\nattribute lowp vec2 aColor;\nattribute lowp vec2 aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\n#define Derivatives\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying mediump vec2 vTexCoord;\nvarying mediump vec2 vPreviousTexCoord;\n#ifdef Derivatives\nvarying vec3 vViewPosition;\n#endif\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\ngl_Position = vec4(0.0);\n#ifdef Derivatives\nvViewPosition = vec3(0.0);\n#endif\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\n#ifdef Derivatives\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\n#else\ngl_Position = uPMatrix * mvMatrix * vec4(position, 1.0);\n#endif\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvPreviousTexCoord.x = aPosition.x < 0.0 ? aPreviousTexCoord.x : aPreviousTexCoord.z;\nvPreviousTexCoord.y = aPosition.y > 0.0 ? aPreviousTexCoord.y : aPreviousTexCoord.w;\nvTexCoord.x = aPosition.x < 0.0 ? aTexCoord.x : aTexCoord.z;\nvTexCoord.y = aPosition.y > 0.0 ? aTexCoord.y : aTexCoord.w;\n}\n}\n", + "unitsphere.fragment.fx": "#version 100\n#define FragDepth\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvarying mediump float vRadius;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform vec3 uDirectionToLight;\nuniform vec3 uHalfAngle;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbient;\nuniform vec3 uHoverColor;\nuniform vec3 uActiveColor;\nuniform vec3 uSelectedColor;\nuniform float uHighlightMode;\n#ifdef FragDepth\n#extension GL_EXT_frag_depth : enable\n#endif\nfloat sphIntersect(in vec3 ro, in vec3 rd, in vec4 sph)\n{\nvec3 oc = ro - sph.xyz;\nfloat b = dot(oc, rd);\nfloat c = dot(oc, oc) - sph.w * sph.w;\nfloat h = b * b - c;\nif (h < 0.0) return -1.0;\nreturn -b - sqrt(h);\n}\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 s = vec4(vViewCenter, vRadius);\nfloat t = sphIntersect(ro, rd, s);\nif (t < 0.0)\n{\ndiscard;\n}\nelse\n{\nvec3 viewPosition = rd * t;\n#ifdef FragDepth\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepthEXT = ndcDepth * 0.5 + 0.5;\n#endif\nif (uPick)\n{\ngl_FragColor = vIdColor;\n}\nelse\n{\nfloat emissive = 0.0;\nvec3 previousColor = texture2D(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture2D(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\nif (uHighlightMode < 0.5) {\nemissive = vVertexSelected * 0.5;\nemissive += 1.5 * max(vHover, vActive);\nemissive /= 4.0;\n}\nelse {\npreviousColor = mix(previousColor, vec3(dot(LUMINANCE, previousColor)), max(-vVertexSelected, 0.0));\ncolor = mix(color, vec3(dot(LUMINANCE, color)), max(-vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uSelectedColor, max(vVertexSelected, 0.0));\ncolor = mix(color, uSelectedColor, max(vVertexSelected, 0.0));\npreviousColor = mix(previousColor, uActiveColor, vActive);\ncolor = mix(color, uActiveColor, vActive);\npreviousColor = mix(previousColor, uHoverColor, vHover);\ncolor = mix(color, uHoverColor, vHover);\n}\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = (viewPosition - vViewCenter) / s.w;\nfloat diffuse = clamp(dot(uDirectionToLight, normal), 0.0, 1.0);\nfloat specular = pow(clamp(dot(normal, uHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity;\ncolor *= (uAmbient + diffuse + emissive);\ncolor += specular;\ncolor = clamp(color, 0.0, 1.0);\ncolor = pow(color, GAMMA);\ngl_FragColor = vec4(color, 1.0);\n}\n}\n}\n", + "unitsphere.vertex.fx": "#version 100\n#include \"common.include.fx\"\nattribute mediump vec3 aPosition;\nattribute vec3 aTranslation;\nattribute vec3 aPreviousTranslation;\nattribute lowp float aColor;\nattribute lowp float aPreviousColor;\nattribute vec3 aScale;\nattribute vec3 aPreviousScale;\nattribute float aId;\nattribute vec2 aOrder;\nattribute lowp float aSelected;\nattribute lowp float aPreviousSelected;\nattribute lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nvarying lowp vec4 vIdColor;\nvarying lowp vec2 vVertexColor;\nvarying lowp float vVertexSelected;\nvarying highp float vAnimation;\nvarying lowp float vHover;\nvarying lowp float vActive;\nvarying mediump float vRadius;\nvarying vec3 vViewPosition;\nvarying vec3 vViewCenter;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvViewCenter = vec3(0.0);\nvRadius = 0.0;\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nfloat scale = mix(min(aPreviousScale.x, min(aPreviousScale.y, aPreviousScale.z)), min(aScale.x, min(aScale.y, aScale.z)), animation);\nvec4 translation = vec4(mix(aPreviousTranslation, aTranslation, animation), 1.0);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvViewCenter = (mvMatrix * translation).xyz;\ntranslation.xyz += aPosition * scale;\nvViewPosition = (mvMatrix * translation).xyz;\ngl_Position = uPMatrix * vec4(vViewPosition, 1.0);\nvVertexColor = vec2(aColor, aPreviousColor);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvRadius = distance(vViewPosition, vViewCenter) / ROOT_THREE;\n}\n}\n", + "common.include.fx": "const float NEAR_PLANE = 0.01;\nconst float FAR_PLANE = 100.0;\nconst float DEPTH_A = 1.0002000200020003;\nconst float DEPTH_B = 0.020002000200020003;\nconst vec3 GAMMA = vec3(0.45454545454545453);\nconst vec3 INV_GAMMA = vec3(2.2);\nconst vec3 LUMINANCE = vec3(0.2126, 0.7152, 0.0722);\nconst float PI = 3.1415926538;\nconst float ROOT_TWO = 1.4142135624;\nconst float ROOT_TWO_OVER_TWO = 0.7071067811865476;\nconst float ROOT_THREE = 1.7320508075688772;\nconst float ROOT_THREE_OVER_TWO = 0.8660254037844386;\nconst vec3 IDENTITY_ROTATION = vec3(0.0, 1.0, 0.0);\nmat3 transpose(in mat3 mat) {\nvec3 i0 = mat[0];\nvec3 i1 = mat[1];\nvec3 i2 = mat[2];\nreturn mat3\n(\nvec3(i0.x, i1.x, i2.x),\nvec3(i0.y, i1.y, i2.y),\nvec3(i0.z, i1.z, i2.z)\n);\n}\n", "quat.include.fx": "const float EPSILON = 0.000001;\nmat3 fromQuat(in vec4 q) {\nfloat x = q.x;\nfloat y = q.y;\nfloat z = q.z;\nfloat w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat yx = y * x2;\nfloat yy = y * y2;\nfloat zx = z * x2;\nfloat zy = z * y2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nmat3 m;\nm[0][0] = 1.0 - yy - zz;\nm[0][1] = yx - wz;\nm[0][2] = zx + wy;\nm[1][0] = yx + wz;\nm[1][1] = 1.0 - xx - zz;\nm[1][2] = zy - wx;\nm[2][0] = zx - wy;\nm[2][1] = zy + wx;\nm[2][2] = 1.0 - xx - yy;\nreturn m;\n}\nvec3 rotate(in vec3 p, in vec4 q) {\nreturn p + 2.0 * cross(q.xyz, cross(q.xyz, p) + q.w * p);\n}\nvec4 slerp(in vec4 a, in vec4 b, in float t) {\nfloat cosom = dot(a, b);\nif (cosom < 0.0) {\ncosom = -cosom;\nb = -b;\n}\nfloat scale0, scale1;\nif (1.0 - cosom > EPSILON) {\nfloat omega = acos(cosom);\nfloat sinom = sin(omega);\nscale0 = sin((1.0 - t) * omega) / sinom;\nscale1 = sin(t * omega) / sinom;\n}\nelse {\nscale0 = 1.0 - t;\nscale1 = t;\n}\nreturn vec4(scale0 * a + scale1 * b);\n}\n" }; class ShaderBase { @@ -31655,8 +29180,8 @@ class ShaderBase { do { index = source.indexOf("#include", index); if (index != -1) { - const start = source.indexOf('"', index); - const end = source.indexOf('"', start + 1); + const start = source.indexOf("\"", index); + const end = source.indexOf("\"", start + 1); const name = source.substring(start + 1, end); const inc = Resources.glsl[name]; source = source.substring(0, index) + inc + source.substring(end + 1); @@ -31667,8 +29192,8 @@ class ShaderBase { _includesFromUrl(source, index, callback) { index = source.indexOf("#include", index); if (index != -1) { - const start = source.indexOf('"', index); - const end = source.indexOf('"', start + 1); + const start = source.indexOf("\"", index); + const end = source.indexOf("\"", start + 1); const name = source.substring(start + 1, end); this._sourceFromUrl((0, _pathJs.PathHelper).combine("inc", name), (include)=>{ source = source.substring(0, index) + include + source.substring(end + 1); @@ -31678,14 +29203,63 @@ class ShaderBase { } } -},{"../../../helpers/path.js":"dofsD","../../../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kHekF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../../../helpers/path.js":"dvdia","../../../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jXv4X":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Texture", ()=>Texture); +parcelHelpers.export(exports, "Color", ()=>Color); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Color extends (0, _shaderJs.ShaderBase) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("color.vertex.fx", "color.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._colorAttribute = gl.getAttribLocation(this._program, "aColor"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._isInitialized = true; + } + apply() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + } + applyView() { + this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + } + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionColorVertex).SIZE_BYTES, (0, _vertexJs.PositionColorVertex).POSITION_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.vertexAttribPointer(this._colorAttribute, 3, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.PositionColorVertex).SIZE_BYTES, (0, _vertexJs.PositionColorVertex).COLOR_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._colorAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } +} + +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"c5hna":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Texture", ()=>Texture); +var _shaderJs = require("./shader.js"); var _vertexJs = require("../../../vertex.js"); class Texture extends (0, _shaderJs.ShaderBase) { get texture2D() { @@ -31715,6 +29289,7 @@ class Texture extends (0, _shaderJs.ShaderBase) { this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); this._normalAttribute = gl.getAttribLocation(this._program, "aNormal"); this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._pickUniform = gl.getUniformLocation(this._program, "uPick"); this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); @@ -31725,6 +29300,7 @@ class Texture extends (0, _shaderJs.ShaderBase) { this._gl.uniform1i(this._samplerUniform, 0); } applyView() { + this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); } @@ -31746,14 +29322,14 @@ class Texture extends (0, _shaderJs.ShaderBase) { } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kkqPx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Lasso", ()=>Lasso); +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5QPQk":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Lasso", ()=>Lasso); +var _shaderJs = require("./shader.js"); var _vertexJs = require("../../../vertex.js"); class Lasso extends (0, _shaderJs.ShaderBase) { initializeContext(gl) { @@ -31797,14 +29373,90 @@ class Lasso extends (0, _shaderJs.ShaderBase) { } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"S8Cvl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5cbW3":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SdfText", ()=>SdfText); +parcelHelpers.export(exports, "Model", ()=>Model); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Model extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; + } + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; + } + } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("model.vertex.fx", "model.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); + this._normalAttribute = gl.getAttribLocation(this._program, "aNormal"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._directionToLightUniform = gl.getUniformLocation(this._program, "uDirectionToLight"); + this._halfAngleUniform = gl.getUniformLocation(this._program, "uHalfAngle"); + this._specularPowerUniform = gl.getUniformLocation(this._program, "uSpecularPower"); + this._specularIntensityUniform = gl.getUniformLocation(this._program, "uSpecularIntensity"); + this._isInitialized = true; + } + apply() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + this._gl.uniform1i(this._samplerUniform, 0); + this._gl.uniform1f(this._specularPowerUniform, this.specularPower); + this._gl.uniform1f(this._specularIntensityUniform, this.specularIntensity); + } + applyView() { + this._gl.uniform3fv(this._directionToLightUniform, this.directionToLight); + this._gl.uniform3fv(this._halfAngleUniform, this.halfAngle); + this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + } + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).POSITION_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.vertexAttribPointer(this._normalAttribute, 3, this._gl.BYTE, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).NORMAL_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._normalAttribute); + this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).TEX_COORD_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._texCoordAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + } +} + +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8CJWE":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "SdfText", ()=>SdfText); +var _shaderJs = require("./shader.js"); var _vertexJs = require("../../../vertex.js"); class SdfText extends (0, _shaderJs.ShaderBase) { get texture2D() { @@ -31820,6 +29472,7 @@ class SdfText extends (0, _shaderJs.ShaderBase) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); else this._shaderFromFile("sdftext.vertex.fx", "sdftext.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.OES_standard_derivatives == null) fsSource = this._removeDirective(fsSource, "Derivatives"); this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -31883,20 +29536,21 @@ class SdfText extends (0, _shaderJs.ShaderBase) { } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kIMzi":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "PickGrid", ()=>PickGrid); +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9bPD8":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PickGrid", ()=>PickGrid); +var _shaderJs = require("./shader.js"); var _vertexJs = require("../../../vertex.js"); class PickGrid extends (0, _shaderJs.ShaderBase) { initializeContext(gl) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); else this._shaderFromFile("pickgrid.vertex.fx", "pickgrid.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.OES_standard_derivatives == null) fsSource = this._removeDirective(fsSource, "Derivatives"); this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -31928,6 +29582,7 @@ class PickGrid extends (0, _shaderJs.ShaderBase) { this._zeroThicknessUniform = gl.getUniformLocation(this._program, "uZeroThickness"); this._zeroUniform = gl.getUniformLocation(this._program, "uZero"); this._minorGridlinesUniform = gl.getUniformLocation(this._program, "uMinorGridlines"); + this._directionToLightUniform = gl.getUniformLocation(this._program, "uDirectionToLight"); this._isInitialized = true; } apply() { @@ -31939,6 +29594,7 @@ class PickGrid extends (0, _shaderJs.ShaderBase) { this._gl.uniform3fv(this._majorColorUniform, this.majorColor); this._gl.uniform3fv(this._minorColorUniform, this.minorColor); this._gl.uniform3fv(this._zeroColorUniform, this.zeroColor); + this._gl.uniform3fv(this._directionToLightUniform, this.directionToLight); this._gl.uniform4fv(this._pickedIdColorUniform, this.pickedIdColor); } applyView() { @@ -31969,20 +29625,24 @@ class PickGrid extends (0, _shaderJs.ShaderBase) { } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9SVao":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitBlock", ()=>UnitBlock); +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jKxeO":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitBlock", ()=>UnitBlock); +var _vertexJs = require("../../../vertex.js"); var _unitshaderJs = require("./unitshader.js"); class UnitBlock extends (0, _unitshaderJs.UnitShader) { initializeContext(gl) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); else this._shaderFromFile("unitblock.vertex.fx", "unitblock.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.OES_standard_derivatives == null) { + vsSource = this._removeDirective(vsSource, "Derivatives"); + fsSource = this._removeDirective(fsSource, "Derivatives"); + } this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -31997,39 +29657,43 @@ class UnitBlock extends (0, _unitshaderJs.UnitShader) { } _updateCurrentBuffer() { super._updateCurrentBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._rotationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); this._gl.enableVertexAttribArray(this._rotationAttribute); this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._colorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); this._gl.enableVertexAttribArray(this._colorAttribute); } _updatePreviousBuffer() { super._updatePreviousBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousRotationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); this._gl.enableVertexAttribArray(this._previousRotationAttribute); this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); this._gl.enableVertexAttribArray(this._previousColorAttribute); } disableProgram() { super.disableProgram(); - this._gl.vertexAttribDivisor(this._rotationAttribute, 0); - this._gl.vertexAttribDivisor(this._previousRotationAttribute, 0); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); } } -},{"../../../vertex.js":"ddAub","./unitshader.js":"QWSad","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"QWSad":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitShader", ()=>UnitShader); +},{"../../../vertex.js":"4J2YE","./unitshader.js":"ahgmR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ahgmR":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitShader", ()=>UnitShader); +var _shaderJs = require("./shader.js"); var _cubeJs = require("../../../meshes/cube.js"); var _vertexJs = require("../../../vertex.js"); +var _mainJs = require("../../../main.js"); class UnitShader extends (0, _shaderJs.ShaderBase) { get paletteTexture() { return this._paletteTexture; @@ -32110,7 +29774,15 @@ class UnitShader extends (0, _shaderJs.ShaderBase) { this._hoverUniform = gl.getUniformLocation(this._program, "uHover"); this._activeUniform = gl.getUniformLocation(this._program, "uActive"); this._pickUniform = gl.getUniformLocation(this._program, "uPick"); - this._shadowUniform = gl.getUniformLocation(this._program, "uShadow"); + this._directionToLightUniform = gl.getUniformLocation(this._program, "uDirectionToLight"); + this._halfAngleUniform = gl.getUniformLocation(this._program, "uHalfAngle"); + this._specularPowerUniform = gl.getUniformLocation(this._program, "uSpecularPower"); + this._specularIntensityUniform = gl.getUniformLocation(this._program, "uSpecularIntensity"); + this._hoverColorUniform = gl.getUniformLocation(this._program, "uHoverColor"); + this._ambientUniform = gl.getUniformLocation(this._program, "uAmbient"); + this._activeColorUniform = gl.getUniformLocation(this._program, "uActiveColor"); + this._selectedColorUniform = gl.getUniformLocation(this._program, "uSelectedColor"); + this._highlightModeUniform = gl.getUniformLocation(this._program, "uHighlightMode"); const vertices = (0, _cubeJs.Cube).POSITIONS; this._vertexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); @@ -32131,36 +29803,38 @@ class UnitShader extends (0, _shaderJs.ShaderBase) { this._updatePreviousBuffer(); } _updateCurrentBuffer() { + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._instanceBuffer); this._gl.vertexAttribPointer(this._idAttribute, 1, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ID_HOVER_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._idAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idAttribute, 1); this._gl.enableVertexAttribArray(this._idAttribute); this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ID_COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._idColorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idColorAttribute, 1); this._gl.enableVertexAttribArray(this._idColorAttribute); this._gl.vertexAttribPointer(this._translationAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TRANSLATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._translationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._translationAttribute, 1); this._gl.enableVertexAttribArray(this._translationAttribute); this._gl.vertexAttribPointer(this._scaleAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SCALE_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._scaleAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._scaleAttribute, 1); this._gl.enableVertexAttribArray(this._scaleAttribute); this._gl.vertexAttribPointer(this._selectedAttribute, 1, this._gl.BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SELECTED_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._selectedAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._selectedAttribute, 1); this._gl.enableVertexAttribArray(this._selectedAttribute); this._gl.vertexAttribPointer(this._orderAttribute, 2, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ORDER_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._orderAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._orderAttribute, 1); this._gl.enableVertexAttribArray(this._orderAttribute); } _updatePreviousBuffer() { + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; if (this._previousInstanceBuffer != this._instanceBuffer) this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._previousInstanceBuffer); this._gl.vertexAttribPointer(this._previousTranslationAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TRANSLATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousTranslationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTranslationAttribute, 1); this._gl.enableVertexAttribArray(this._previousTranslationAttribute); this._gl.vertexAttribPointer(this._previousScaleAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SCALE_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousScaleAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousScaleAttribute, 1); this._gl.enableVertexAttribArray(this._previousScaleAttribute); this._gl.vertexAttribPointer(this._previousSelectedAttribute, 1, this._gl.BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SELECTED_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousSelectedAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousSelectedAttribute, 1); this._gl.enableVertexAttribArray(this._previousSelectedAttribute); } apply() { @@ -32171,14 +29845,22 @@ class UnitShader extends (0, _shaderJs.ShaderBase) { this._gl.uniform1f(this._toOrderUniform, this.rangeMax); this._gl.uniform1i(this._previousSampler0Uniform, 0); this._gl.uniform1i(this._sampler0Uniform, 1); + this._gl.uniform1f(this._specularPowerUniform, this.specularPower); + this._gl.uniform1f(this._specularIntensityUniform, this.specularIntensity); + this._gl.uniform1f(this._ambientUniform, this.ambient); + this._gl.uniform3fv(this._hoverColorUniform, this.hoverColor); + this._gl.uniform3fv(this._activeColorUniform, this.activeColor); + this._gl.uniform3fv(this._selectedColorUniform, this.selectedColor); this._gl.uniform1f(this._hoverUniform, this.hover); this._gl.uniform1f(this._activeUniform, this.active); + this._gl.uniform1f(this._highlightModeUniform, this.highlightMode == (0, _mainJs.HighlightMode).luminance ? 0.0 : 1.0); } applyView() { this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + this._gl.uniform3fv(this._directionToLightUniform, this.directionToLight); + this._gl.uniform3fv(this._halfAngleUniform, this.halfAngle); this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); - this._gl.uniform1i(this._shadowUniform, this.isShadowMap ? 1 : 0); } updateTextures() { this._gl.activeTexture(this._gl.TEXTURE0); @@ -32188,34 +29870,36 @@ class UnitShader extends (0, _shaderJs.ShaderBase) { } disableProgram() { super.disableProgram(); - this._gl.vertexAttribDivisor(this._translationAttribute, 0); - this._gl.vertexAttribDivisor(this._previousTranslationAttribute, 0); - this._gl.vertexAttribDivisor(this._scaleAttribute, 0); - this._gl.vertexAttribDivisor(this._previousScaleAttribute, 0); - this._gl.vertexAttribDivisor(this._colorAttribute, 0); - this._gl.vertexAttribDivisor(this._previousColorAttribute, 0); - this._gl.vertexAttribDivisor(this._selectedAttribute, 0); - this._gl.vertexAttribDivisor(this._previousSelectedAttribute, 0); - this._gl.vertexAttribDivisor(this._orderAttribute, 0); - this._gl.vertexAttribDivisor(this._idAttribute, 0); - this._gl.vertexAttribDivisor(this._idColorAttribute, 0); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._translationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTranslationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._scaleAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousScaleAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._selectedAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousSelectedAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._orderAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._idColorAttribute, 0); } } -},{"./shader.js":"5yb62","../../../meshes/cube.js":"7rTMs","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eRyuE":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitSphere", ()=>UnitSphere); +},{"./shader.js":"hWbX1","../../../meshes/cube.js":"79I5N","../../../vertex.js":"4J2YE","../../../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"72WuL":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitSphere", ()=>UnitSphere); +var _vertexJs = require("../../../vertex.js"); var _unitshaderJs = require("./unitshader.js"); class UnitSphere extends (0, _unitshaderJs.UnitShader) { initializeContext(gl) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); else this._shaderFromFile("unitsphere.vertex.fx", "unitsphere.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.EXT_frag_depth == null) fsSource = this._removeDirective(fsSource, "FragDepth"); this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -32228,32 +29912,35 @@ class UnitSphere extends (0, _unitshaderJs.UnitShader) { } _updateCurrentBuffer() { super._updateCurrentBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._colorAttribute, 1, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._colorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); this._gl.enableVertexAttribArray(this._colorAttribute); } _updatePreviousBuffer() { super._updatePreviousBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._previousColorAttribute, 1, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); this._gl.enableVertexAttribArray(this._previousColorAttribute); } } -},{"../../../vertex.js":"ddAub","./unitshader.js":"QWSad","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kCOh8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitCylinder", ()=>UnitCylinder); +},{"../../../vertex.js":"4J2YE","./unitshader.js":"ahgmR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"16WiR":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitCylinder", ()=>UnitCylinder); +var _vertexJs = require("../../../vertex.js"); var _unitshaderJs = require("./unitshader.js"); class UnitCylinder extends (0, _unitshaderJs.UnitShader) { initializeContext(gl) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); else this._shaderFromFile("unitcylinder.vertex.fx", "unitcylinder.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.EXT_frag_depth == null) fsSource = this._removeDirective(fsSource, "FragDepth"); this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -32268,43 +29955,105 @@ class UnitCylinder extends (0, _unitshaderJs.UnitShader) { } _updateCurrentBuffer() { super._updateCurrentBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._rotationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); this._gl.enableVertexAttribArray(this._rotationAttribute); this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._colorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); this._gl.enableVertexAttribArray(this._colorAttribute); } _updatePreviousBuffer() { super._updatePreviousBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousRotationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); this._gl.enableVertexAttribArray(this._previousRotationAttribute); this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); this._gl.enableVertexAttribArray(this._previousColorAttribute); } disableProgram() { super.disableProgram(); - this._gl.vertexAttribDivisor(this._rotationAttribute, 0); - this._gl.vertexAttribDivisor(this._previousRotationAttribute, 0); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); } } -},{"../../../vertex.js":"ddAub","./unitshader.js":"QWSad","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cSNWw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../../../vertex.js":"4J2YE","./unitshader.js":"ahgmR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3fOzC":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "UnitSdf", ()=>UnitSdf); +parcelHelpers.export(exports, "UnitHexPrism", ()=>UnitHexPrism); +var _vertexJs = require("../../../vertex.js"); +var _unitshaderJs = require("./unitshader.js"); +class UnitHexPrism extends (0, _unitshaderJs.UnitShader) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("unithexprism.vertex.fx", "unithexprism.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.EXT_frag_depth == null) fsSource = this._removeDirective(fsSource, "FragDepth"); + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + super._initializeShader(gl, vsSource, fsSource); + this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); + this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); + this._isInitialized = true; + } + _updateCurrentBuffer() { + super._updateCurrentBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); + this._gl.enableVertexAttribArray(this._rotationAttribute); + this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); + this._gl.enableVertexAttribArray(this._colorAttribute); + } + _updatePreviousBuffer() { + super._updatePreviousBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); + this._gl.enableVertexAttribArray(this._previousRotationAttribute); + this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); + this._gl.enableVertexAttribArray(this._previousColorAttribute); + } + disableProgram() { + super.disableProgram(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); + } +} + +},{"../../../vertex.js":"4J2YE","./unitshader.js":"ahgmR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9zSFc":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _vertexJs = require("../../../vertex.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitSdf", ()=>UnitSdf); +var _vertexJs = require("../../../vertex.js"); var _unitshaderJs = require("./unitshader.js"); class UnitSdf extends (0, _unitshaderJs.UnitShader) { initializeContext(gl) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); else this._shaderFromFile("unitsdf.vertex.fx", "unitsdf.fragment.fx", (vsSource, fsSource)=>{ + if (this._main.shaderResources.OES_standard_derivatives == null) { + vsSource = this._removeDirective(vsSource, "Derivatives"); + fsSource = this._removeDirective(fsSource, "Derivatives"); + } this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -32319,36 +30068,42 @@ class UnitSdf extends (0, _unitshaderJs.UnitShader) { this._previousTexCoordAttribute = gl.getAttribLocation(this._program, "aPreviousTexCoord"); this._sampler1Uniform = gl.getUniformLocation(this._program, "uSampler1"); this._previousSampler1Uniform = gl.getUniformLocation(this._program, "uPreviousSampler1"); + this._sdfBufferUniform = gl.getUniformLocation(this._program, "uBuffer"); + this._sdfBackgroundColorUniform = gl.getUniformLocation(this._program, "uBackgroundColor"); this._isInitialized = true; } _updateCurrentBuffer() { super._updateCurrentBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._rotationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 1); this._gl.enableVertexAttribArray(this._rotationAttribute); this._gl.vertexAttribPointer(this._texCoordAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TEXCOORD_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._texCoordAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._texCoordAttribute, 1); this._gl.enableVertexAttribArray(this._texCoordAttribute); this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._colorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._colorAttribute, 1); this._gl.enableVertexAttribArray(this._colorAttribute); } _updatePreviousBuffer() { super._updatePreviousBuffer(); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousRotationAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 1); this._gl.enableVertexAttribArray(this._previousRotationAttribute); this._gl.vertexAttribPointer(this._previousTexCoordAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TEXCOORD_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousTexCoordAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTexCoordAttribute, 1); this._gl.enableVertexAttribArray(this._previousTexCoordAttribute); this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); - this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousColorAttribute, 1); this._gl.enableVertexAttribArray(this._previousColorAttribute); } apply() { super.apply(); this._gl.uniform1i(this._previousSampler1Uniform, 2); this._gl.uniform1i(this._sampler1Uniform, 3); + this._gl.uniform1f(this._sdfBufferUniform, this.sdfBuffer); + this._gl.uniform3fv(this._sdfBackgroundColorUniform, this.sdfBackgroundColor); } updateTextures() { super.updateTextures(); @@ -32359,73 +30114,24 @@ class UnitSdf extends (0, _unitshaderJs.UnitShader) { } disableProgram() { super.disableProgram(); - this._gl.vertexAttribDivisor(this._rotationAttribute, 0); - this._gl.vertexAttribDivisor(this._previousRotationAttribute, 0); - this._gl.vertexAttribDivisor(this._texCoordAttribute, 0); - this._gl.vertexAttribDivisor(this._previousTexCoordAttribute, 0); + const ANGLE_instanced_arrays = this._main.shaderResources.ANGLE_instanced_arrays; + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._rotationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousRotationAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._texCoordAttribute, 0); + ANGLE_instanced_arrays.vertexAttribDivisorANGLE(this._previousTexCoordAttribute, 0); } } -},{"../../../vertex.js":"ddAub","./unitshader.js":"QWSad","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fZOIf":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Background", ()=>Background); +},{"../../../vertex.js":"4J2YE","./unitshader.js":"ahgmR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8jbJ4":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -var _quadJs = require("../components/quad.js"); -class Background extends (0, _shaderJs.ShaderBase) { - constructor(core, main){ - super(core, main); - this._quad = new (0, _quadJs.Quad)(); - } - initializeContext(gl) { - super.initializeContext(gl); - this._quad.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "background.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._colorUniform = gl.getUniformLocation(this._program, "uColor"); - this._isInitialized = true; - this._vao = gl.createVertexArray(); - gl.bindVertexArray(this._vao); - gl.bindBuffer(gl.ARRAY_BUFFER, this._quad.vertexBuffer); - gl.vertexAttribPointer(this._positionAttribute, 3, gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - gl.enableVertexAttribArray(this._positionAttribute); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._quad.indexBuffer); - gl.bindVertexArray(null); - } - apply() { - this._gl.uniform3fv(this._colorUniform, this.color); - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindVertexArray(this._vao); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","../components/quad.js":"4iGAx","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2cBXg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Ssao", ()=>Ssao); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); +parcelHelpers.export(exports, "Anaglyph", ()=>Anaglyph); +var _shaderJs = require("./shader.js"); var _vertexJs = require("../../../vertex.js"); -class Ssao extends (0, _shaderJs.ShaderBase) { +class Anaglyph extends (0, _shaderJs.ShaderBase) { get texture2D1() { return this._texture2D1; } @@ -32444,19 +30150,10 @@ class Ssao extends (0, _shaderJs.ShaderBase) { this._haveTexturesChanged = true; } } - get texture2D3() { - return this._texture2D3; - } - set texture2D3(value) { - if (this._texture2D3 != value) { - this._texture2D3 = value; - this._haveTexturesChanged = true; - } - } initializeContext(gl) { super.initializeContext(gl); if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "ssao.fragment.fx", (vsSource, fsSource)=>{ + else this._shaderFromFile("simple.vertex.fx", "anaglyph.fragment.fx", (vsSource, fsSource)=>{ this._vsSource = vsSource; this._fsSource = fsSource; this._isLoaded = true; @@ -32468,29 +30165,15 @@ class Ssao extends (0, _shaderJs.ShaderBase) { const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); this._program = this._createProgram(vs, fs); this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); - this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); - this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._ssaoNoiseSizeUniform = gl.getUniformLocation(this._program, "uSsaoNoiseSize"); - this._ssaoRadiusUniform = gl.getUniformLocation(this._program, "uSsaoRadius"); - this._ssaoPowerUniform = gl.getUniformLocation(this._program, "uSsaoPower"); - this._ssaoKernelUniform = gl.getUniformLocation(this._program, "uSsaoKernel"); this._isInitialized = true; } apply() { + this._gl.uniform4f(this._viewportUniform, this.viewport.x, this.viewport.y, this.viewport.width, this.viewport.height); this._gl.uniform1i(this._samplerUniform1, 0); this._gl.uniform1i(this._samplerUniform2, 1); - this._gl.uniform1i(this._samplerUniform3, 2); - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - this._gl.uniform1f(this._ssaoNoiseSizeUniform, this.ssaoNoiseSize); - this._gl.uniform1f(this._ssaoRadiusUniform, this.ssaoRadius); - this._gl.uniform1f(this._ssaoPowerUniform, this.ssaoPower); - this._gl.uniform3fv(this._ssaoKernelUniform, this.ssaoKernel); - } - applyView() { - this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); } updateBuffers() { super.updateBuffers(); @@ -32506,800 +30189,454 @@ class Ssao extends (0, _shaderJs.ShaderBase) { this._gl.activeTexture(this._gl.TEXTURE1); this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); this._gl.activeTexture(this._gl.TEXTURE2); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6dStE":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Box", ()=>Box); +},{"./shader.js":"hWbX1","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bt0jr":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Box extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DebugAxesVisual", ()=>DebugAxesVisual); +class DebugAxesVisual { + get isInitialized() { + return this._isInitialized && this._main.colorShader.isInitialized; } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; - } + constructor(core, main, debugAxes){ + this._main = main; + this._debugAxes = debugAxes; + this.isVisible = true; } initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "box.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + if (!this._debugAxes.isInitialized) this._debugAxes.initialize(); + this._gl = gl; + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._debugAxes.vertices, gl.STATIC_DRAW); + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._debugAxes.indices, gl.STATIC_DRAW); this._isInitialized = true; } - apply() { - this._gl.uniform1i(this._samplerUniform, 0); - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + update(elapsedTime) {} + render(elapsedTime, xrFrame) { + if (this.isInitialized) { + const colorShader = this._main.colorShader; + const shaderResources = this._main.shaderResources; + colorShader.vertexBuffer = this._vertexBuffer; + colorShader.indexBuffer = this._indexBuffer; + colorShader.prepare(); + colorShader.mMatrix = this.mMatrix; + colorShader.apply(); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + colorShader.vMatrix = this.vMatrices[viewport]; + colorShader.pMatrix = this.pMatrices[viewport]; + colorShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLE_STRIP, this._debugAxes.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + } } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1QDMF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Deferred", ()=>Deferred); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ktXb3":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -var _glMatrix = require("gl-matrix"); -class Deferred extends (0, _shaderJs.ShaderBase) { - get texture2D1() { - return this._texture2D1; - } - set texture2D1(value) { - if (this._texture2D1 != value) { - this._texture2D1 = value; - this._haveTexturesChanged = true; - } - } - get texture2D2() { - return this._texture2D2; - } - set texture2D2(value) { - if (this._texture2D2 != value) { - this._texture2D2 = value; - this._haveTexturesChanged = true; - } - } - get texture2D3() { - return this._texture2D3; - } - set texture2D3(value) { - if (this._texture2D3 != value) { - this._texture2D3 = value; - this._haveTexturesChanged = true; - } - } - get texture2D4() { - return this._texture2D4; - } - set texture2D4(value) { - if (this._texture2D4 != value) { - this._texture2D4 = value; - this._haveTexturesChanged = true; - } - } - get texture2D5() { - return this._texture2D5; - } - set texture2D5(value) { - if (this._texture2D5 != value) { - this._texture2D5 = value; - this._haveTexturesChanged = true; - } + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cartesian2dVisual", ()=>Cartesian2dVisual); +var _axesJs = require("./axes.js"); +var _mainJs = require("../../../../main.js"); +var _constantsJs = require("../../../../constants.js"); +var _quadJs = require("../../../../meshes/quad.js"); +class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { + get isInitialized() { + return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; } - constructor(core, main){ - super(core, main); - this.directionToKeyLight = (0, _glMatrix.vec3).create(); - this.directionToFillLight1 = (0, _glMatrix.vec3).create(); - this.directionToFillLight2 = (0, _glMatrix.vec3).create(); - this.keyLightHalfAngle = (0, _glMatrix.vec3).create(); + constructor(core, main, cartesian2dAxes){ + super(core); + this._main = main; + this._axes = cartesian2dAxes; + this._axes.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; } initializeContext(gl) { super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "deferred.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._shadowUniform = gl.getUniformLocation(this._program, "uShadow"); - this._ssaoUniform = gl.getUniformLocation(this._program, "uSsao"); - this._inverseVMatrixUniform = gl.getUniformLocation(this._program, "uInverseVMatrix"); - this._shadowVMatrixUniform = gl.getUniformLocation(this._program, "uShadowVMatrix"); - this._shadowPMatrixUniform = gl.getUniformLocation(this._program, "uShadowPMatrix"); - this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); - this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); - this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); - this._samplerUniform4 = gl.getUniformLocation(this._program, "uSampler4"); - this._samplerUniform5 = gl.getUniformLocation(this._program, "uSampler5"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._shadowMapSizeUniform = gl.getUniformLocation(this._program, "uShadowMapSize"); - this._keyLightHalfAngleUniform = gl.getUniformLocation(this._program, "uKeyLightHalfAngle"); - this._directionToKeyLightUniform = gl.getUniformLocation(this._program, "uDirectionToKeyLight"); - this._directionToFillLight1Uniform = gl.getUniformLocation(this._program, "uDirectionToFillLight1"); - this._directionToFillLight2Uniform = gl.getUniformLocation(this._program, "uDirectionToFillLight2"); - this._keyLightIntensityUniform = gl.getUniformLocation(this._program, "uKeyLightIntensity"); - this._fillLight1IntensityUniform = gl.getUniformLocation(this._program, "uFillLight1Intensity"); - this._fillLight2IntensityUniform = gl.getUniformLocation(this._program, "uFillLight2Intensity"); - this._ambientIntensityUniform = gl.getUniformLocation(this._program, "uAmbientIntensity"); - this._materialIntensityUniform = gl.getUniformLocation(this._program, "uMaterialIntensity"); - this._specularPowerUniform = gl.getUniformLocation(this._program, "uSpecularPower"); - this._specularIntensityUniform = gl.getUniformLocation(this._program, "uSpecularIntensity"); + const axes = this._axes; + if (!axes.isInitialized) axes.initialize(); + if (axes.gridVertices) this._createGridBuffers(); + if (axes.textVertices) this._createTextBuffers(); this._isInitialized = true; } - apply() { - this._gl.uniform1i(this._shadowUniform, this.isShadowEnabled ? 1 : 0); - this._gl.uniform1i(this._ssaoUniform, this.isSsaoEnabled ? 1 : 0); - this._gl.uniformMatrix4fv(this._inverseVMatrixUniform, false, this.inverseVMatrix); - this._gl.uniformMatrix4fv(this._shadowVMatrixUniform, false, this.shadowVMatrix); - this._gl.uniformMatrix4fv(this._shadowPMatrixUniform, false, this.shadowPMatrix); - this._gl.uniform1i(this._samplerUniform1, 0); - this._gl.uniform1i(this._samplerUniform2, 1); - this._gl.uniform1i(this._samplerUniform3, 2); - this._gl.uniform1i(this._samplerUniform4, 3); - this._gl.uniform1i(this._samplerUniform5, 4); - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - this._gl.uniform2f(this._shadowMapSizeUniform, this.shadowMapWidth, this.shadowMapHeight); - this._gl.uniform1f(this._keyLightIntensityUniform, this.keyLightIntensity); - this._gl.uniform1f(this._fillLight1IntensityUniform, this.fillLight1Intensity); - this._gl.uniform1f(this._fillLight2IntensityUniform, this.fillLight2Intensity); - this._gl.uniform1f(this._ambientIntensityUniform, this.ambientIntensity); - this._gl.uniform1f(this._materialIntensityUniform, this.materialIntensity); - this._gl.uniform1f(this._specularPowerUniform, this.specularPower); - this._gl.uniform1f(this._specularIntensityUniform, this.specularIntensity); - this._gl.uniform3fv(this._directionToKeyLightUniform, this.directionToKeyLight); - this._gl.uniform3fv(this._directionToFillLight1Uniform, this.directionToFillLight1); - this._gl.uniform3fv(this._directionToFillLight2Uniform, this.directionToFillLight2); - this._gl.uniform3fv(this._keyLightHalfAngleUniform, this.keyLightHalfAngle); + _createGridBuffers() { + const axes = this._axes; + this._gridVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); + this._gridIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); + this._gridBufferSize = axes.gridVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers created`); } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + _createTextBuffers() { + const axes = this._axes; + this._textVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); + this._textIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); + this._textBufferSize = axes.textVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers created`); } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); - this._gl.activeTexture(this._gl.TEXTURE1); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); - this._gl.activeTexture(this._gl.TEXTURE2); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); - this._gl.activeTexture(this._gl.TEXTURE3); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D4); - this._gl.activeTexture(this._gl.TEXTURE4); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D5); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aeB23":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Combine", ()=>Combine); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Combine extends (0, _shaderJs.ShaderBase) { - get texture2D1() { - return this._texture2D1; - } - set texture2D1(value) { - if (this._texture2D1 != value) { - this._texture2D1 = value; - this._haveTexturesChanged = true; + update(elapsedTime) { + if (this._hasChanged) { + this._hasChanged = false; + const axes = this._axes; + if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers updated`); + } + if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers updated`); + } + this._main.shaderResources.currentProgram = null; } } - get texture2D2() { - return this._texture2D2; - } - set texture2D2(value) { - if (this._texture2D2 != value) { - this._texture2D2 = value; - this._haveTexturesChanged = true; + _renderText() { + const axes = this._axes; + const shader = this._main.sdfTextShader; + const shaderResources = this._main.shaderResources; + const fontVisual = this._main.fonts[axes.font.name]; + shader.vertexBuffer = this._textVertexBuffer; + shader.indexBuffer = this._textIndexBuffer; + shader.texture2D = fontVisual.texture; + shader.prepare(); + shader.buffer = fontVisual.font.edgeValue / 0xff; + shader.gamma = axes.gamma; + shader.borderWidth = axes.textBorderWidth; + shader.color = axes.textColor || this._core.config.axesTextColor; + shader.hoverColor = axes.textHoverColor || this._core.config.axesTextHoverColor; + shader.borderColor = axes.textBorderColor || this._core.config.textBorderColor; + shader.pickedIdColor = this.pickedIdColor; + shader.apply(); + let indexCount, indexOffset; + for(let axisId = 0; axisId < 2; axisId++){ + const orientation = axes.getLabelOrientation(axisId); + for(let edge = 0; edge < 2; edge++){ + const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; + if (axes.isEdgeVisible[edgeId]) { + if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { + indexCount = axes.getAxesLeftToRightIndexCount(axisId); + indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); + } else { + indexCount = axes.getAxesRightToLeftIndexCount(axisId); + indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); + } + if (indexCount > 0) { + shader.mMatrix = axes.getLabelMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + indexCount = axes.getTitleIndexCount(axisId); + if (indexCount > 0) { + indexOffset = axes.getTitleIndexOffset(axisId); + shader.mMatrix = axes.getTitleMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + } + indexCount = axes.getHeadingIndexCount(axisId); + if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { + indexOffset = axes.getHeadingIndexOffset(axisId); + shader.mMatrix = axes.getHeadingMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + } } } - get texture2D3() { - return this._texture2D3; - } - set texture2D3(value) { - if (this._texture2D3 != value) { - this._texture2D3 = value; - this._haveTexturesChanged = true; + _renderGrid() { + const axes = this._axes; + const gridShader = this._main.gridShader; + gridShader.vertexBuffer = this._gridVertexBuffer; + gridShader.indexBuffer = this._gridIndexBuffer; + gridShader.prepare(); + gridShader.majorThickness = axes.gridMajorThickness; + gridShader.minorThickness = axes.gridMinorThickness; + gridShader.zeroThickness = axes.gridZeroThickness; + gridShader.backgroundColor = axes.gridBackgroundColor || this._core.config.axesGridBackgroundColor; + gridShader.highlightColor = axes.gridHighlightColor || this._core.config.axesGridHighlightColor; + gridShader.majorColor = axes.gridMajorColor || this._core.config.axesGridMajorColor; + gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; + gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; + gridShader.pickedIdColor = this.pickedIdColor; + gridShader.directionToLight = (0, _constantsJs.Constants).VECTOR3_UNITZ; + gridShader.apply(); + for(let axisId = 0; axisId < 2; axisId++)if (axes.arePickDivisionsVisible[axisId]) { + const gridTicksScale = axes.getGridTicksScale(axisId); + const width = gridTicksScale[0]; + const height = gridTicksScale[1]; + gridShader.zero = axes.getGridTicksZero(axisId); + gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); + for(let edge = 0; edge < 2; edge++){ + const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; + if (axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); + } } - } - get texture2D4() { - return this._texture2D4; - } - set texture2D4(value) { - if (this._texture2D4 != value) { - this._texture2D4 = value; - this._haveTexturesChanged = true; + this._gl.disable(this._gl.CULL_FACE); + const size = axes.size; + const axisId2 = 0; + const axisId3 = 1; + const width = size[axisId2]; + const height = size[axisId3]; + gridShader.zero = axes.gridFaceZero; + gridShader.minorGridlines = axes.gridFaceMinorGridlines; + for(let face = 0; face < 2; face++){ + const faceId = face; + if (axes.getIsForwardFace(faceId)) this._renderGridFace(faceId, width, height); } + this._gl.enable(this._gl.CULL_FACE); } - get texture2D5() { - return this._texture2D5; - } - set texture2D5(value) { - if (this._texture2D5 != value) { - this._texture2D5 = value; - this._haveTexturesChanged = true; + _renderGridTicks(axisId, edgeId, width, height) { + const axes = this._axes; + const gridShader = this._main.gridShader; + const shaderResources = this._main.shaderResources; + gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); + gridShader.faceWidth = width; + gridShader.faceHeight = height; + gridShader.ApplyFace(); + gridShader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + gridShader.vMatrix = this.vMatrices[viewport]; + gridShader.pMatrix = this.pMatrices[viewport]; + gridShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); + } + if (this.isPickingEnabled && axes.isDivisionPickingEnabled[axisId]) { + gridShader.isPickShader = true; + gridShader.vMatrix = this.pickVMatrix; + gridShader.pMatrix = this.pickPMatrix; + gridShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, this._axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, this._axes.getGridTicksIndexOffset(axisId) * 2); } } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "combine.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._intensityUniform = gl.getUniformLocation(this._program, "uIntensity"); - this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); - this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); - this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); - this._samplerUniform4 = gl.getUniformLocation(this._program, "uSampler4"); - this._samplerUniform5 = gl.getUniformLocation(this._program, "uSampler5"); - this._isInitialized = true; - } - apply() { - this._gl.uniform4f(this._viewportUniform, this.viewport.x, this.viewport.y, this.viewport.width, this.viewport.height); - this._gl.uniform1f(this._intensityUniform, this.intensity); - this._gl.uniform1i(this._samplerUniform1, 0); - this._gl.uniform1i(this._samplerUniform2, 1); - this._gl.uniform1i(this._samplerUniform3, 2); - this._gl.uniform1i(this._samplerUniform4, 3); - this._gl.uniform1i(this._samplerUniform5, 4); - } - updateBuffers() { - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); - this._gl.activeTexture(this._gl.TEXTURE1); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); - this._gl.activeTexture(this._gl.TEXTURE2); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); - this._gl.activeTexture(this._gl.TEXTURE3); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D4); - this._gl.activeTexture(this._gl.TEXTURE4); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D5); + _renderGridFace(faceId, width, height) { + const axes = this._axes; + const gridShader = this._main.gridShader; + const shaderResources = this._main.shaderResources; + gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); + gridShader.faceWidth = width; + gridShader.faceHeight = height; + gridShader.ApplyFace(); + gridShader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + gridShader.vMatrix = this.vMatrices[viewport]; + gridShader.pMatrix = this.pMatrices[viewport]; + gridShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); + } + if (this.isPickingEnabled && axes.isGridPickingEnabled) { + gridShader.isPickShader = true; + gridShader.vMatrix = this.pickVMatrix; + gridShader.pMatrix = this.pickPMatrix; + gridShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); + } } } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4Mg1v":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DofBlur", ()=>DofBlur); +},{"./axes.js":"e0jpG","../../../../main.js":"f421K","../../../../constants.js":"lD0bG","../../../../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e0jpG":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class DofBlur extends (0, _shaderJs.ShaderBase) { - get texture2D1() { - return this._texture2D1; - } - set texture2D1(value) { - if (this._texture2D1 != value) { - this._texture2D1 = value; - this._haveTexturesChanged = true; - } + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AxesVisualBase", ()=>AxesVisualBase); +class AxesVisualBase { + get isInitialized() { + return this._isInitialized; } - get texture2D2() { - return this._texture2D2; + get axes() { + return this._axes; } - set texture2D2(value) { - if (this._texture2D2 != value) { - this._texture2D2 = value; - this._haveTexturesChanged = true; - } + constructor(core){ + this._core = core; + this.isVisible = true; } initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "dofblur.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._focusDepthUniform = gl.getUniformLocation(this._program, "uFocusDepth"); - this._nearFocusDepthUniform = gl.getUniformLocation(this._program, "uNearFocusDepth"); - this._farFocusDepthUniform = gl.getUniformLocation(this._program, "uFarFocusDepth"); - this._maxBackgroundBlurUniform = gl.getUniformLocation(this._program, "uMaxBackgroundBlur"); - this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); - this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); - this._isInitialized = true; - } - apply() { - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - this._gl.uniform1f(this._focusDepthUniform, this.focusDepth); - this._gl.uniform1f(this._nearFocusDepthUniform, this.nearFocusDepth); - this._gl.uniform1f(this._farFocusDepthUniform, this.farFocusDepth); - this._gl.uniform1f(this._maxBackgroundBlurUniform, this.maxBackgroundBlur); - this._gl.uniform1i(this._samplerUniform1, 0); - this._gl.uniform1i(this._samplerUniform2, 1); - } - updateBuffers() { - super.updateBuffers(); - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + this._gl = gl; } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); - this._gl.activeTexture(this._gl.TEXTURE1); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); + update(elapsedTime) {} + render(elapsedTime, xrFrame) { + if (this.isInitialized) { + this._renderGrid(); + this._renderText(); + } } + _renderGrid() {} + _renderText() {} } -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bpIiM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Downsample", ()=>Downsample); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6CCj9":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Downsample extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cartesian3dVisual", ()=>Cartesian3dVisual); +var _axesJs = require("./axes.js"); +var _mainJs = require("../../../../main.js"); +var _constantsJs = require("../../../../constants.js"); +var _cubeJs = require("../../../../meshes/cube.js"); +class Cartesian3dVisual extends (0, _axesJs.AxesVisualBase) { + get isInitialized() { + return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; - } + constructor(core, main, cartesian3dAxes){ + super(core); + this._main = main; + this._axes = cartesian3dAxes; + this._axes.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; } initializeContext(gl) { super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "downsample.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + const axes = this._axes; + if (!axes.isInitialized) axes.initialize(); + if (axes.gridVertices) this._createGridBuffers(); + if (axes.textVertices) this._createTextBuffers(); this._isInitialized = true; } - apply() { - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - this._gl.uniform1i(this._samplerUniform, 0); + _createGridBuffers() { + const axes = this._axes; + this._gridVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); + this._gridIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); + this._gridBufferSize = axes.gridVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers created`); } - updateBuffers() { - super.updateBuffers(); - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + _createTextBuffers() { + const axes = this._axes; + this._textVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); + this._textIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); + this._textBufferSize = axes.textVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers created`); } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3qhJJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Gaussian", ()=>Gaussian); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Gaussian extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; - } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; - } - } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "gaussian.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._resolutionUniform = gl.getUniformLocation(this._program, "uResolution"); - this._horizontalUniform = gl.getUniformLocation(this._program, "uHorizontal"); - this._isInitialized = true; - } - apply() { - this._gl.uniform1i(this._samplerUniform, 0); - this._gl.uniform2f(this._resolutionUniform, this.width, this.height); - this._gl.uniform1i(this._horizontalUniform, this.horizontal ? 1 : 0); - } - updateBuffers() { - super.updateBuffers(); - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dn6BO":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DofCombine", ()=>DofCombine); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class DofCombine extends (0, _shaderJs.ShaderBase) { - get texture2D1() { - return this._texture2D1; - } - set texture2D1(value) { - if (this._texture2D1 != value) { - this._texture2D1 = value; - this._haveTexturesChanged = true; - } - } - get texture2D2() { - return this._texture2D2; - } - set texture2D2(value) { - if (this._texture2D2 != value) { - this._texture2D2 = value; - this._haveTexturesChanged = true; - } - } - get texture2D3() { - return this._texture2D3; - } - set texture2D3(value) { - if (this._texture2D3 != value) { - this._texture2D3 = value; - this._haveTexturesChanged = true; - } - } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "dofcombine.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._focusDepthUniform = gl.getUniformLocation(this._program, "uFocusDepth"); - this._apertureUniform = gl.getUniformLocation(this._program, "uAperture"); - this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); - this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); - this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); - this._isInitialized = true; - } - apply() { - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - this._gl.uniform1f(this._focusDepthUniform, this.focusDepth); - this._gl.uniform1f(this._apertureUniform, this.aperture); - this._gl.uniform1i(this._samplerUniform1, 0); - this._gl.uniform1i(this._samplerUniform2, 1); - this._gl.uniform1i(this._samplerUniform3, 2); - } - updateBuffers() { - super.updateBuffers(); - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); - this._gl.activeTexture(this._gl.TEXTURE1); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); - this._gl.activeTexture(this._gl.TEXTURE2); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hFWxV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Fxaa", ()=>Fxaa); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Fxaa extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; - } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; - } - } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "fxaa.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._isInitialized = true; - } - apply() { - this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); - this._gl.uniform1i(this._samplerUniform, 0); - } - updateBuffers() { - super.updateBuffers(); - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cLRip":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Bright", ()=>Bright); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _shaderJs = require("./shader.js"); -var _vertexJs = require("../../../vertex.js"); -class Bright extends (0, _shaderJs.ShaderBase) { - get texture2D() { - return this._texture2D; - } - set texture2D(value) { - if (this._texture2D != value) { - this._texture2D = value; - this._haveTexturesChanged = true; - } - } - initializeContext(gl) { - super.initializeContext(gl); - if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); - else this._shaderFromFile("simple.vertex.fx", "bright.fragment.fx", (vsSource, fsSource)=>{ - this._vsSource = vsSource; - this._fsSource = fsSource; - this._isLoaded = true; - this._initializeShader(gl, vsSource, fsSource); - }); - } - _initializeShader(gl, vsSource, fsSource) { - const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); - const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); - this._program = this._createProgram(vs, fs); - this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); - this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); - this._resolutionUniform = gl.getUniformLocation(this._program, "uResolution"); - this._isInitialized = true; - } - apply() { - this._gl.uniform1i(this._samplerUniform, 0); - this._gl.uniform2f(this._resolutionUniform, this.width, this.height); - } - updateBuffers() { - super.updateBuffers(); - super.updateBuffers(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); - this._gl.enableVertexAttribArray(this._positionAttribute); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - } - updateTextures() { - super.updateTextures(); - this._gl.activeTexture(this._gl.TEXTURE0); - this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); - } -} - -},{"./shader.js":"5yb62","../../../vertex.js":"ddAub","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jVY6s":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cartesian2dVisual", ()=>Cartesian2dVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _axesJs = require("./axes.js"); -var _mainJs = require("../../../../main.js"); -var _quadJs = require("../../../../meshes/quad.js"); -class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { - get isInitialized() { - return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; - } - constructor(core, main, cartesian2dAxes){ - super(core); - this._main = main; - this._axes = cartesian2dAxes; - this._axes.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - } - initializeContext(gl) { - super.initializeContext(gl); - const axes = this._axes; - if (!axes.isInitialized) axes.initialize(); - if (axes.gridVertices) this._createGridBuffers(); - if (axes.textVertices) this._createTextBuffers(); - this._isInitialized = true; - } - _createGridBuffers() { - const axes = this._axes; - this._gridVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); - this._gridIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); - this._gridBufferSize = axes.gridVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers created`); - } - _createTextBuffers() { - const axes = this._axes; - this._textVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); - this._textIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); - this._textBufferSize = axes.textVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers created`); - } - update(elapsedTime) { - if (this._hasChanged) { - this._hasChanged = false; - const axes = this._axes; - if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers updated`); - } - if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers updated`); - } - this._main.shaderResources.currentProgram = null; - } + update(elapsedTime) { + if (this._hasChanged) { + this._hasChanged = false; + const axes = this._axes; + if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers updated`); + } + if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers updated`); + } + this._main.shaderResources.currentProgram = null; + } } _renderText() { + const axes = this._axes; const shader = this._main.sdfTextShader; const shaderResources = this._main.shaderResources; - const axes = this._axes; const fontVisual = this._main.fonts[axes.font.name]; shader.vertexBuffer = this._textVertexBuffer; shader.indexBuffer = this._textIndexBuffer; @@ -33314,57 +30651,84 @@ class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { shader.pickedIdColor = this.pickedIdColor; shader.apply(); let indexCount, indexOffset; - for(let axisId = 0; axisId < 2; axisId++){ + for(let axisId = 0; axisId < 3; axisId++){ const orientation = axes.getLabelOrientation(axisId); - for(let edge = 0; edge < 2; edge++){ - const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; - if (axes.isEdgeVisible[edgeId]) { - if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { - indexCount = axes.getAxesLeftToRightIndexCount(axisId); - indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); - } else { - indexCount = axes.getAxesRightToLeftIndexCount(axisId); - indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); + for(let edge = 0; edge < 4; edge++){ + const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; + if (axes.getIsOutsideEdge(edgeId)) { + if (axes.isEdgeVisible[edgeId]) { + if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { + indexCount = axes.getAxesLeftToRightIndexCount(axisId); + indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); + } else { + indexCount = axes.getAxesRightToLeftIndexCount(axisId); + indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); + } + if (indexCount > 0) { + shader.mMatrix = axes.getLabelMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + indexCount = axes.getTitleIndexCount(axisId); + if (indexCount > 0) { + indexOffset = axes.getTitleIndexOffset(axisId); + shader.mMatrix = axes.getTitleMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } } - if (indexCount > 0) { - shader.mMatrix = axes.getLabelMMatrix(edgeId); + indexCount = axes.getHeadingIndexCount(axisId); + if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { + indexOffset = axes.getHeadingIndexOffset(axisId); + shader.mMatrix = axes.getHeadingMMatrix(edgeId); shader.applyModel(); shader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); for(let i = 0; i < this.viewportCount; i++){ const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); shader.vMatrix = this.vMatrices[viewport]; shader.pMatrix = this.pMatrices[viewport]; shader.applyView(); this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); } - if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - indexCount = axes.getTitleIndexCount(axisId); - if (indexCount > 0) { - indexOffset = axes.getTitleIndexOffset(axisId); - shader.mMatrix = axes.getTitleMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i1 = 0; i1 < this.viewportCount; i1++){ - const viewport1 = i1 + this.viewportOffset; - this._gl.viewport(this.viewports[viewport1].x, this.viewports[viewport1].y, this.viewports[viewport1].width, this.viewports[viewport1].height); - shader.vMatrix = this.vMatrices[viewport1]; - shader.pMatrix = this.pMatrices[viewport1]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { + if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { shader.isPickShader = true; shader.pMatrix = this.pickPMatrix; shader.vMatrix = this.pickVMatrix; @@ -33375,37 +30739,12 @@ class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { } } } - indexCount = axes.getHeadingIndexCount(axisId); - if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { - indexOffset = axes.getHeadingIndexOffset(axisId); - shader.mMatrix = axes.getHeadingMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i2 = 0; i2 < this.viewportCount; i2++){ - const viewport2 = i2 + this.viewportOffset; - this._gl.viewport(this.viewports[viewport2].x, this.viewports[viewport2].y, this.viewports[viewport2].width, this.viewports[viewport2].height); - shader.vMatrix = this.vMatrices[viewport2]; - shader.pMatrix = this.pMatrices[viewport2]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } } } } _renderGrid() { - const gridShader = this._main.gridShader; const axes = this._axes; + const gridShader = this._main.gridShader; gridShader.vertexBuffer = this._gridVertexBuffer; gridShader.indexBuffer = this._gridIndexBuffer; gridShader.prepare(); @@ -33418,44 +30757,47 @@ class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; gridShader.pickedIdColor = this.pickedIdColor; + gridShader.directionToLight = (0, _constantsJs.Constants).VECTOR3_UNITZ; gridShader.apply(); - for(let axisId = 0; axisId < 2; axisId++)if (axes.arePickDivisionsVisible[axisId]) { + for(let axisId = 0; axisId < 3; axisId++)if (axes.arePickDivisionsVisible[axisId]) { const gridTicksScale = axes.getGridTicksScale(axisId); const width = gridTicksScale[0]; const height = gridTicksScale[1]; gridShader.zero = axes.getGridTicksZero(axisId); gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); - for(let edge = 0; edge < 2; edge++){ - const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; - if (axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); + for(let edge = 0; edge < 4; edge++){ + const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; + if (axes.getIsOutsideEdge(edgeId) && axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); } } this._gl.disable(this._gl.CULL_FACE); const size = axes.size; - const axisId2 = 0; - const axisId3 = 1; - const width1 = size[axisId2]; - const height1 = size[axisId3]; - gridShader.zero = axes.gridFaceZero; - gridShader.minorGridlines = axes.gridFaceMinorGridlines; - for(let face = 0; face < 2; face++){ - const faceId = face; - if (axes.getIsForwardFace(faceId)) this._renderGridFace(faceId, width1, height1); + for(let axisId = 0; axisId < 3; axisId++)if (axes.areFacesVisible[axisId]) { + const axisId2 = axisId == 0 ? 1 : 0; + const axisId3 = axisId == 2 ? 1 : 2; + const width = size[axisId2]; + const height = size[axisId3]; + gridShader.zero = axes.getGridFaceZero(axisId); + gridShader.minorGridlines = axes.getGridFaceMinorGridlines(axisId); + for(let face = 0; face < 2; face++){ + const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId][face]; + if (axes.getIsForwardFace(faceId) && axes.isFaceVisible[faceId]) this._renderGridFace(faceId, width, height); + } } this._gl.enable(this._gl.CULL_FACE); } _renderGridTicks(axisId, edgeId, width, height) { + const axes = this._axes; const gridShader = this._main.gridShader; const shaderResources = this._main.shaderResources; - const axes = this._axes; gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); gridShader.faceWidth = width; gridShader.faceHeight = height; gridShader.ApplyFace(); gridShader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); for(let i = 0; i < this.viewportCount; i++){ const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); gridShader.vMatrix = this.vMatrices[viewport]; gridShader.pMatrix = this.pMatrices[viewport]; @@ -33473,17 +30815,17 @@ class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { } } _renderGridFace(faceId, width, height) { + const axes = this._axes; const gridShader = this._main.gridShader; const shaderResources = this._main.shaderResources; - const axes = this._axes; gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); gridShader.faceWidth = width; gridShader.faceHeight = height; gridShader.ApplyFace(); gridShader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); for(let i = 0; i < this.viewportCount; i++){ const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); gridShader.vMatrix = this.vMatrices[viewport]; gridShader.pMatrix = this.pMatrices[viewport]; @@ -33502,369 +30844,190 @@ class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { } } -},{"./axes.js":"6Qfc5","../../../../main.js":"1Kju3","../../../../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6Qfc5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"./axes.js":"e0jpG","../../../../main.js":"f421K","../../../../constants.js":"lD0bG","../../../../meshes/cube.js":"79I5N","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hdGVP":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "AxesVisualBase", ()=>AxesVisualBase); -class AxesVisualBase { + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ControllerVisual", ()=>ControllerVisual); +var _glMatrix = require("gl-matrix"); +var _textureJs = require("../../../helpers/texture.js"); +var _constantsJs = require("../../../constants.js"); +class ControllerVisual { get isInitialized() { - return this._isInitialized; + return this._isInitialized && this._modelShader.isInitialized && this._colorShader.isInitialized; } - get axes() { - return this._axes; + get controller() { + return this._controller; } - constructor(core){ + constructor(core, main, controller){ this._core = core; + this._main = main; + this._mMatrix = (0, _glMatrix.mat4).create(); + this._vec3 = (0, _glMatrix.vec3).create(); + this._controller = controller; + this._modelShader = main.modelShader; + this._colorShader = main.colorShader; + this.mMatrix = (0, _glMatrix.mat4).create(); + this.rayMMatrix = (0, _glMatrix.mat4).create(); this.isVisible = true; } initializeContext(gl) { + if (!this._controller.isInitialized) this._controller.initialize(); + this._initialize(gl); + } + _initialize(gl) { this._gl = gl; + this.modelTexture = (0, _textureJs.TextureHelper).fromImage(gl, this._controller.texture, false, gl.LINEAR); + this._modelVertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._modelVertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._controller.vertices, gl.STATIC_DRAW); + this._modelIndexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._modelIndexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._controller.indices, gl.STATIC_DRAW); + this._rayVertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._rayVertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._controller.rayVertices, gl.STATIC_DRAW); + this._rayIndexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._rayIndexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._controller.rayIndices, gl.STATIC_DRAW); + this._isInitialized = true; } update(elapsedTime) {} render(elapsedTime, xrFrame) { if (this.isInitialized) { - this._renderGrid(); - this._renderText(); + this._modelShader.vertexBuffer = this._modelVertexBuffer; + this._modelShader.indexBuffer = this._modelIndexBuffer; + this._modelShader.texture2D = this.modelTexture; + this._modelShader.prepare(); + (0, _glMatrix.mat4).multiply(this._mMatrix, this._controller.useRayPose ? this.rayMMatrix : this.mMatrix, this._controller.mMatrix); + this._modelShader.mMatrix = this._mMatrix; + this._modelShader.specularPower = 10; + this._modelShader.specularIntensity = 0.01; + this._modelShader.apply(); + this._modelShader.applyModel(); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._main.shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + this._modelShader.directionToLight = (0, _constantsJs.Constants).VECTOR3_UNITZ; + this._modelShader.halfAngle = (0, _constantsJs.Constants).VECTOR3_UNITZ; + this._modelShader.vMatrix = this.vMatrices[viewport]; + this._modelShader.pMatrix = this.pMatrices[viewport]; + this._modelShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._controller.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + if (this.isRayVisible) { + this._colorShader.vertexBuffer = this._rayVertexBuffer; + this._colorShader.indexBuffer = this._rayIndexBuffer; + this._colorShader.prepare(); + (0, _glMatrix.mat4).multiply(this._mMatrix, this.rayMMatrix, this._controller.rayMMatrix); + this._colorShader.mMatrix = this._mMatrix; + this._colorShader.apply(); + this._colorShader.applyModel(); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._main.shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + this._colorShader.vMatrix = this.vMatrices[viewport]; + this._colorShader.pMatrix = this.pMatrices[viewport]; + this._colorShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLE_STRIP, this._controller.rayIndexCount, this._gl.UNSIGNED_SHORT, 0); + } + } } } - _renderGrid() {} - _renderText() {} } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6nMmw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Cartesian3dVisual", ()=>Cartesian3dVisual); +},{"gl-matrix":"5x28d","../../../helpers/texture.js":"bUoBU","../../../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"j2Sdg":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _axesJs = require("./axes.js"); -var _mainJs = require("../../../../main.js"); -var _cubeJs = require("../../../../meshes/cube.js"); -class Cartesian3dVisual extends (0, _axesJs.AxesVisualBase) { + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); +var _glMatrix = require("gl-matrix"); +var _textureJs = require("../../../helpers/texture.js"); +class ImageVisual { get isInitialized() { - return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; + return this._isInitialized && this._main.textureShader.isInitialized; } - constructor(core, main, cartesian3dAxes){ - super(core); + get image() { + return this._image; + } + constructor(core, main, image){ + this._core = core; this._main = main; - this._axes = cartesian3dAxes; - this._axes.hasChangedCallback = ()=>{ + this._image = image; + this._image.hasChangedCallback = ()=>{ this._hasChanged = true; }; + this.mMatrix = (0, _glMatrix.mat4).create(); + this.isVisible = true; } initializeContext(gl) { - super.initializeContext(gl); - const axes = this._axes; - if (!axes.isInitialized) axes.initialize(); - if (axes.gridVertices) this._createGridBuffers(); - if (axes.textVertices) this._createTextBuffers(); + if (!this._image.isInitialized) this._image.initialize(); + this._gl = gl; + if (this._image.imageData) this.texture = (0, _textureJs.TextureHelper).fromImage(gl, this._image.imageData, false, gl.LINEAR); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._image.vertices, gl.STATIC_DRAW); + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._image.indices, gl.STATIC_DRAW); this._isInitialized = true; } - _createGridBuffers() { - const axes = this._axes; - this._gridVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); - this._gridIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); - this._gridBufferSize = axes.gridVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers created`); - } - _createTextBuffers() { - const axes = this._axes; - this._textVertexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); - this._textIndexBuffer = this._gl.createBuffer(); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); - this._textBufferSize = axes.textVertices.byteLength; - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers created`); - } update(elapsedTime) { if (this._hasChanged) { this._hasChanged = false; - const axes = this._axes; - if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers updated`); - } - if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); - else { - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); - this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); - this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); - this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers updated`); - } + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._image.vertices); this._main.shaderResources.currentProgram = null; } } - _renderText() { - const axes = this._axes; - const shader = this._main.sdfTextShader; - const shaderResources = this._main.shaderResources; - const fontVisual = this._main.fonts[axes.font.name]; - shader.vertexBuffer = this._textVertexBuffer; - shader.indexBuffer = this._textIndexBuffer; - shader.texture2D = fontVisual.texture; - shader.prepare(); - shader.buffer = fontVisual.font.edgeValue / 0xff; - shader.gamma = axes.gamma; - shader.borderWidth = axes.textBorderWidth; - shader.color = axes.textColor || this._core.config.axesTextColor; - shader.hoverColor = axes.textHoverColor || this._core.config.axesTextHoverColor; - shader.borderColor = axes.textBorderColor || this._core.config.textBorderColor; - shader.pickedIdColor = this.pickedIdColor; - shader.apply(); - let indexCount, indexOffset; - for(let axisId = 0; axisId < 3; axisId++){ - const orientation = axes.getLabelOrientation(axisId); - for(let edge = 0; edge < 4; edge++){ - const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; - if (axes.getIsOutsideEdge(edgeId)) { - if (axes.isEdgeVisible[edgeId]) { - if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { - indexCount = axes.getAxesLeftToRightIndexCount(axisId); - indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); - } else { - indexCount = axes.getAxesRightToLeftIndexCount(axisId); - indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); - } - if (indexCount > 0) { - shader.mMatrix = axes.getLabelMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - shader.vMatrix = this.vMatrices[viewport]; - shader.pMatrix = this.pMatrices[viewport]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - indexCount = axes.getTitleIndexCount(axisId); - if (indexCount > 0) { - indexOffset = axes.getTitleIndexOffset(axisId); - shader.mMatrix = axes.getTitleMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i1 = 0; i1 < this.viewportCount; i1++){ - const viewport1 = i1 + this.viewportOffset; - this._gl.viewport(this.viewports[viewport1].x, this.viewports[viewport1].y, this.viewports[viewport1].width, this.viewports[viewport1].height); - shader.vMatrix = this.vMatrices[viewport1]; - shader.pMatrix = this.pMatrices[viewport1]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - } - indexCount = axes.getHeadingIndexCount(axisId); - if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { - indexOffset = axes.getHeadingIndexOffset(axisId); - shader.mMatrix = axes.getHeadingMMatrix(edgeId); - shader.applyModel(); - shader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i2 = 0; i2 < this.viewportCount; i2++){ - const viewport2 = i2 + this.viewportOffset; - this._gl.viewport(this.viewports[viewport2].x, this.viewports[viewport2].y, this.viewports[viewport2].width, this.viewports[viewport2].height); - shader.vMatrix = this.vMatrices[viewport2]; - shader.pMatrix = this.pMatrices[viewport2]; - shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { - shader.isPickShader = true; - shader.pMatrix = this.pickPMatrix; - shader.vMatrix = this.pickVMatrix; - shader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); - } - } - } - } - } - } - _renderGrid() { - const axes = this._axes; - const gridShader = this._main.gridShader; - gridShader.vertexBuffer = this._gridVertexBuffer; - gridShader.indexBuffer = this._gridIndexBuffer; - gridShader.prepare(); - gridShader.majorThickness = axes.gridMajorThickness; - gridShader.minorThickness = axes.gridMinorThickness; - gridShader.zeroThickness = axes.gridZeroThickness; - gridShader.backgroundColor = axes.gridBackgroundColor || this._core.config.axesGridBackgroundColor; - gridShader.highlightColor = axes.gridHighlightColor || this._core.config.axesGridHighlightColor; - gridShader.majorColor = axes.gridMajorColor || this._core.config.axesGridMajorColor; - gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; - gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; - gridShader.pickedIdColor = this.pickedIdColor; - gridShader.apply(); - for(let axisId = 0; axisId < 3; axisId++)if (axes.arePickDivisionsVisible[axisId]) { - const gridTicksScale = axes.getGridTicksScale(axisId); - const width = gridTicksScale[0]; - const height = gridTicksScale[1]; - gridShader.zero = axes.getGridTicksZero(axisId); - gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); - for(let edge = 0; edge < 4; edge++){ - const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; - if (axes.getIsOutsideEdge(edgeId) && axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); + render(elapsedTime, xrFrame) { + if (this.isInitialized) { + const textureShader = this._main.textureShader; + const shaderResources = this._main.shaderResources; + textureShader.vertexBuffer = this._vertexBuffer; + textureShader.indexBuffer = this._indexBuffer; + textureShader.texture2D = this.texture; + textureShader.prepare(); + textureShader.mMatrix = this.mMatrix; + textureShader.isPickShader = false; + textureShader.apply(); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + shaderResources.bindFramebuffer(this.framebuffers[viewport]); + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + textureShader.vMatrix = this.vMatrices[viewport]; + textureShader.pMatrix = this.pMatrices[viewport]; + textureShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._image.indexCount, this._gl.UNSIGNED_SHORT, 0); } - } - this._gl.disable(this._gl.CULL_FACE); - const size = axes.size; - for(let axisId1 = 0; axisId1 < 3; axisId1++)if (axes.areFacesVisible[axisId1]) { - const axisId2 = axisId1 == 0 ? 1 : 0; - const axisId3 = axisId1 == 2 ? 1 : 2; - const width1 = size[axisId2]; - const height1 = size[axisId3]; - gridShader.zero = axes.getGridFaceZero(axisId1); - gridShader.minorGridlines = axes.getGridFaceMinorGridlines(axisId1); - for(let face = 0; face < 2; face++){ - const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId1][face]; - if (axes.getIsForwardFace(faceId) && axes.isFaceVisible[faceId]) this._renderGridFace(faceId, width1, height1); + if (this.isPickingEnabled) { + textureShader.isPickShader = true; + textureShader.vMatrix = this.pickVMatrix; + textureShader.pMatrix = this.pickPMatrix; + textureShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, this._image.indexCount, this._gl.UNSIGNED_SHORT, 0); } } - this._gl.enable(this._gl.CULL_FACE); - } - _renderGridTicks(axisId, edgeId, width, height) { - const axes = this._axes; - const gridShader = this._main.gridShader; - const shaderResources = this._main.shaderResources; - gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); - gridShader.faceWidth = width; - gridShader.faceHeight = height; - gridShader.ApplyFace(); - gridShader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - gridShader.vMatrix = this.vMatrices[viewport]; - gridShader.pMatrix = this.pMatrices[viewport]; - gridShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); - } - if (this.isPickingEnabled && axes.isDivisionPickingEnabled[axisId]) { - gridShader.isPickShader = true; - gridShader.vMatrix = this.pickVMatrix; - gridShader.pMatrix = this.pickPMatrix; - gridShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); - } - } - _renderGridFace(faceId, width, height) { - const axes = this._axes; - const gridShader = this._main.gridShader; - const shaderResources = this._main.shaderResources; - gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); - gridShader.faceWidth = width; - gridShader.faceHeight = height; - gridShader.ApplyFace(); - gridShader.isPickShader = false; - shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - gridShader.vMatrix = this.vMatrices[viewport]; - gridShader.pMatrix = this.pMatrices[viewport]; - gridShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); - } - if (this.isPickingEnabled && axes.isGridPickingEnabled) { - gridShader.isPickShader = true; - gridShader.vMatrix = this.pickVMatrix; - gridShader.pMatrix = this.pickPMatrix; - gridShader.applyView(); - shaderResources.bindFramebuffer(this.pickFramebuffer); - this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); - } } } -},{"./axes.js":"6Qfc5","../../../../main.js":"1Kju3","../../../../meshes/cube.js":"7rTMs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"YHBp5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); +},{"gl-matrix":"5x28d","../../../helpers/texture.js":"bUoBU","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5a9e1":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _textureJs = require("../../helpers/texture.js"); -var _mainJs = require("../../main.js"); -class FontVisual { - get isInitialized() { - return this._isInitialized; - } - get font() { - return this._font; - } - constructor(core, font){ - this._core = core; - this._font = font; - font.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - } - initializeContext(gl) { - this._gl = gl; - this._isInitialized = true; - if (this._font.count > 0) this._hasChanged = true; - } - update() { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - this.texture = (0, _textureJs.TextureHelper).fromImage(this._gl, this._font.atlas.imageData, false, this._gl.LINEAR); - this._core.log.write((0, _mainJs.LogLevel).info, `${this._font.name} texture updated`); - } - } -} - -},{"../../helpers/texture.js":"bUBAh","../../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fnVLv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "LabelVisual", ()=>LabelVisual); parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); +var _glMatrix = require("gl-matrix"); class LabelVisualBase { get isInitialized() { return this._isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._label.font.name].isInitialized; @@ -33898,6 +31061,7 @@ class LabelVisualBase { this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._label.vertices); this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, this._label.indices); + this._main.shaderResources.currentProgram = null; } } render(elapsedTime, xrFrame) { @@ -33922,14 +31086,14 @@ class LabelVisualBase { shader.mMatrix = this._mMatrix; shader.applyModel(); shader.isPickShader = false; - this._main.shaderResources.bindFramebuffer(this.geometryFramebuffer); for(let i = 0; i < this.viewportCount; i++){ const viewport = i + this.viewportOffset; + this._main.shaderResources.bindFramebuffer(this.framebuffers[viewport]); this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); shader.vMatrix = this.vMatrices[viewport]; shader.pMatrix = this.pMatrices[viewport]; shader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_INT, 0); } if (this.isPickingEnabled) { shader.isPickShader = true; @@ -33938,7 +31102,7 @@ class LabelVisualBase { shader.applyView(); this._main.shaderResources.bindFramebuffer(this.pickFramebuffer); this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); - this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_INT, 0); } } } @@ -33967,82 +31131,51 @@ class LabelSetVisual extends LabelVisualBase { } } -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"27hDl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4v679":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _textureJs = require("../../../helpers/texture.js"); -class ImageVisual { + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); +var _textureJs = require("../../helpers/texture.js"); +var _mainJs = require("../../main.js"); +class FontVisual { get isInitialized() { - return this._isInitialized && this._main.textureShader.isInitialized; + return this._isInitialized; } - get image() { - return this._image; + get font() { + return this._font; } - constructor(core, main, image){ + constructor(core, font){ this._core = core; - this._main = main; - this._image = image; - this._image.hasChangedCallback = ()=>{ + this._font = font; + font.hasChangedCallback = ()=>{ this._hasChanged = true; }; - this.mMatrix = (0, _glMatrix.mat4).create(); - this.isVisible = true; } initializeContext(gl) { - if (!this._image.isInitialized) this._image.initialize(); this._gl = gl; - if (this._image.imageData) this.texture = (0, _textureJs.TextureHelper).fromImage(gl, this._image.imageData, false, gl.LINEAR); - this._vertexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this._image.vertices, gl.STATIC_DRAW); - this._indexBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._image.indices, gl.STATIC_DRAW); this._isInitialized = true; + if (this._font.count > 0) this._hasChanged = true; } - update(elapsedTime) { - if (this._hasChanged) { + update() { + if (this._hasChanged && this._isInitialized) { this._hasChanged = false; - this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); - this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._image.vertices); - this._main.shaderResources.currentProgram = null; - } - } - render(elapsedTime, xrFrame) { - if (this.isInitialized) { - const textureShader = this._main.textureShader; - textureShader.vertexBuffer = this._vertexBuffer; - textureShader.indexBuffer = this._indexBuffer; - textureShader.texture2D = this.texture; - textureShader.prepare(); - textureShader.mMatrix = this.mMatrix; - textureShader.apply(); - this._main.shaderResources.bindFramebuffer(this.geometryFramebuffer); - for(let i = 0; i < this.viewportCount; i++){ - const viewport = i + this.viewportOffset; - this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); - textureShader.vMatrix = this.vMatrices[viewport]; - textureShader.pMatrix = this.pMatrices[viewport]; - textureShader.applyView(); - this._gl.drawElements(this._gl.TRIANGLES, this._image.indexCount, this._gl.UNSIGNED_SHORT, 0); - } + this.texture = (0, _textureJs.TextureHelper).fromImage(this._gl, this._font.atlas.imageData, false, this._gl.LINEAR); + this._core.log.write((0, _mainJs.LogLevel).info, `${this._font.name} texture updated`); } } } -},{"gl-matrix":"9GjEQ","../../../helpers/texture.js":"bUBAh","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9nFbm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Lasso", ()=>Lasso); +},{"../../helpers/texture.js":"bUoBU","../../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bi5JS":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _constantsJs = require("../../../constants.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Lasso", ()=>Lasso); +var _constantsJs = require("../../../constants.js"); var _quadJs = require("../../../meshes/quad.js"); class Lasso { get isInitialized() { @@ -34071,62 +31204,61 @@ class Lasso { } } -},{"../../../constants.js":"2Scl5","../../../meshes/quad.js":"jyd4s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jCrZa":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"../../../constants.js":"lD0bG","../../../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gKCQy":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Main", ()=>(0, _mainJs.Main)); -parcelHelpers.export(exports, "Material", ()=>(0, _materialJs.Material)); -parcelHelpers.export(exports, "MetalMaterial", ()=>(0, _materialJs.MetalMaterial)); -parcelHelpers.export(exports, "GlossyMaterial", ()=>(0, _materialJs.GlossyMaterial)); -parcelHelpers.export(exports, "VarnishMaterial", ()=>(0, _materialJs.VarnishMaterial)); -parcelHelpers.export(exports, "LambertianMaterial", ()=>(0, _materialJs.LambertianMaterial)); -parcelHelpers.export(exports, "DielectricMaterial", ()=>(0, _materialJs.DielectricMaterial)); -parcelHelpers.export(exports, "DiffuseLightMaterial", ()=>(0, _materialJs.DiffuseLightMaterial)); -parcelHelpers.export(exports, "IsotropicMaterial", ()=>(0, _materialJs.IsotropicMaterial)); -parcelHelpers.export(exports, "Texture", ()=>(0, _textureJs.Texture)); -parcelHelpers.export(exports, "SolidColorTexture", ()=>(0, _textureJs.SolidColorTexture)); -parcelHelpers.export(exports, "ImageTexture", ()=>(0, _textureJs.ImageTexture)); -parcelHelpers.export(exports, "CheckerTexture", ()=>(0, _textureJs.CheckerTexture)); -parcelHelpers.export(exports, "GridTexture", ()=>(0, _textureJs.GridTexture)); -parcelHelpers.export(exports, "Light", ()=>(0, _lightJs.Light)); -parcelHelpers.export(exports, "Ground", ()=>(0, _groundJs.Ground)); -parcelHelpers.export(exports, "Constants", ()=>(0, _constantsJs.Constants)); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Main", ()=>(0, _mainJs.Main)); var _mainJs = require("./main.js"); -var _materialJs = require("./material.js"); -var _textureJs = require("./texture.js"); -var _lightJs = require("./light.js"); -var _groundJs = require("./ground.js"); -var _constantsJs = require("./constants.js"); -},{"./main.js":"gcdZ1","./material.js":"5mttU","./texture.js":"3ZvZF","./light.js":"8rYr6","./ground.js":"68giq","./constants.js":"3ibK7","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gcdZ1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./main.js":"gU7zw","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gU7zw":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); parcelHelpers.export(exports, "Main", ()=>Main); var _glMatrix = require("gl-matrix"); -var _rendererJs = require("../renderer.js"); var _mainJs = require("../../main.js"); +var _rendererJs = require("../renderer.js"); +var _quadJs = require("./components/quad.js"); +var _bufferJs = require("./buffer.js"); var _configJs = require("./config.js"); -var _hittableJs = require("./hittable.js"); -var _materialJs = require("./material.js"); -var _raytraceJs = require("./shaders/raytrace.js"); -var _fullscreenquadJs = require("./shaders/fullscreenquad.js"); -var _bvhJs = require("./bvh.js"); -var _textureJs = require("./texture.js"); -var _lightJs = require("./light.js"); -var _constantsJs = require("../../constants.js"); +var _shaderJs = require("./shaders/shader.js"); +var _textureJs = require("./shaders/texture.js"); +var _lassoJs = require("./shaders/lasso.js"); +var _sdftextJs = require("./shaders/sdftext.js"); +var _pickgridJs = require("./shaders/pickgrid.js"); +var _unitblockJs = require("./shaders/unitblock.js"); +var _unitsphereJs = require("./shaders/unitsphere.js"); +var _unitcylinderJs = require("./shaders/unitcylinder.js"); +var _unitsdfJs = require("./shaders/unitsdf.js"); +var _backgroundJs = require("./shaders/background.js"); +var _ssaoJs = require("./shaders/ssao.js"); +var _boxJs = require("./shaders/box.js"); +var _deferredJs = require("./shaders/deferred.js"); +var _combineJs = require("./shaders/combine.js"); +var _dofblurJs = require("./shaders/dofblur.js"); +var _downsampleJs = require("./shaders/downsample.js"); +var _gaussianJs = require("./shaders/gaussian.js"); +var _dofcombineJs = require("./shaders/dofcombine.js"); +var _fxaaJs = require("./shaders/fxaa.js"); +var _brightJs = require("./shaders/bright.js"); var _angleJs = require("../../helpers/angle.js"); +var _pickJs = require("../../helpers/pick.js"); +var _cartesian2DJs = require("./components/axes/cartesian2d.js"); +var _cartesian3DJs = require("./components/axes/cartesian3d.js"); var _fontJs = require("./font.js"); -var _imageJs = require("./image.js"); -var _labelsJs = require("./labels.js"); -var _bufferJs = require("./buffer.js"); -var _constantsJs1 = require("./constants.js"); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { +var _mathJs = require("./../../helpers/math.js"); +var _constantsJs = require("../../constants.js"); +var _vertexJs = require("../../vertex.js"); +var _textureJs1 = require("../../helpers/texture.js"); +var _labelsJs = require("./components/labels.js"); +var _imageJs = require("./components/image.js"); +var _lassoJs1 = require("./components/lasso.js"); +var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -34154,81724 +31286,82355 @@ var _constantsJs1 = require("./constants.js"); }); }; class Main extends (0, _rendererJs.RendererBase) { - get frameCount() { - return this._frameCount; + get shaderResources() { + return this._shaderResources; } - get duration() { - return this._duration; + get textureShader() { + return this._textureShader; + } + get lassoShader() { + return this._lassoShader; + } + get sdfTextShader() { + return this._sdfTextShader; + } + get gridShader() { + return this._gridShader; + } + get blockShader() { + return this._blockShader; + } + get sphereShader() { + return this._sphereShader; + } + get cyclinderShader() { + return this._cylinderShader; + } + get sdfShader() { + return this._sdfShader; + } + get currentAxes() { + return this._isAxes1Current ? this._axes1 : this._axes2; + } + set currentAxes(value) { + if (this._isAxes1Current) this._axes1 = value; + else this._axes2 = value; + } + get previousAxes() { + return this._isAxes1Current ? this._axes2 : this._axes1; + } + set previousAxes(value) { + if (this._isAxes1Current) this._axes2 = value; + else this._axes1 = value; } get config() { return this._config; } constructor(options){ super(options); - (0, _glMatrix.glMatrix).setMatrixArrayType(Float32Array); this._config = new (0, _configJs.Config)(); - this._frameCount = 0; - this._duration = 0; + this._quad = new (0, _quadJs.Quad)(); + this._lasso = new (0, _lassoJs1.Lasso)(); + this._pickedPixels = new Uint8Array(4); + this._pickedIdColor = (0, _glMatrix.vec4).create(); this._position = (0, _glMatrix.vec3).create(); - this._right = (0, _glMatrix.vec3).create(); - this._up = (0, _glMatrix.vec3).create(); - this._forward = (0, _glMatrix.vec3).create(); + this._direction = (0, _glMatrix.vec3).create(); + this._cameraRotation = (0, _glMatrix.mat3).create(); + this._cameraPosition = (0, _glMatrix.vec3).create(); this._modelPosition = (0, _glMatrix.vec3).create(); - this._manipulationOrigin = (0, _glMatrix.vec3).create(); - this._backgroundColor = (0, _glMatrix.vec3).create(); + this._modelManipulationOrigin = (0, _glMatrix.vec3).create(); + this._shadowVMatrix = (0, _glMatrix.mat4).create(); + this._shadowPMatrix = (0, _glMatrix.mat4).create(); + } + get isSupported() { + return this._createContext(document.createElement("canvas")) !== null; } initialize(core) { super.initialize(core); - this._hittables = []; - this._lightBuffer = null; - this._initializeAPI().then(()=>{ - this._initializeResources(); - this._createWorld(); - if (this._hittables.length > 0) { - this._createLights(); - this._resizeBackings(); - } - this._hasChanged = false; - }); - } - _initializeAPI() { - return __awaiter(this, void 0, void 0, function*() { - try { - const start = window.performance.now(); - const gpu = navigator.gpu; - this._presentationFormat = gpu.getPreferredCanvasFormat(); - this._adapter = yield gpu.requestAdapter(); - this._device = yield this._adapter.requestDevice(); - this._queue = this._device.queue; - this._context = this._canvas.getContext("webgpu"); - this._core.log.write((0, _mainJs.LogLevel).info, `WebGPU API initialized ${Math.round(window.performance.now() - start)}ms`); - } catch (e) { - this._core.log.write((0, _mainJs.LogLevel).error, e); - return false; - } - return true; - }); + this._shaderResources = new (0, _shaderJs.Resources)(); + this._textureShader = new (0, _textureJs.Texture)(core, this); + this._lassoShader = new (0, _lassoJs.Lasso)(core, this); + this._sdfTextShader = new (0, _sdftextJs.SdfText)(core, this); + this._gridShader = new (0, _pickgridJs.PickGrid)(core, this); + this._blockShader = new (0, _unitblockJs.UnitBlock)(core, this); + this._sphereShader = new (0, _unitsphereJs.UnitSphere)(core, this); + this._cylinderShader = new (0, _unitcylinderJs.UnitCylinder)(core, this); + this._sdfShader = new (0, _unitsdfJs.UnitSdf)(core, this); + this._backgroundShader = new (0, _backgroundJs.Background)(core, this); + this._ssaoShader = new (0, _ssaoJs.Ssao)(core, this); + this._boxShader = new (0, _boxJs.Box)(core, this); + this._deferredShader = new (0, _deferredJs.Deferred)(core, this); + this._combineShader = new (0, _combineJs.Combine)(core, this); + this._dofBlurShader = new (0, _dofblurJs.DofBlur)(core, this); + this._downsampleShader = new (0, _downsampleJs.Downsample)(core, this); + this._gaussianShader = new (0, _gaussianJs.Gaussian)(core, this); + this._dofCombineShader = new (0, _dofcombineJs.DofCombine)(core, this); + this._fxaaShader = new (0, _fxaaJs.Fxaa)(core, this); + this._brightPassShader = new (0, _brightJs.Bright)(core, this); + this._initializeContext(this._createContext(this._canvas)); + this._canvas.addEventListener("webglcontextlost", (event)=>{ + this._core.log.write((0, _mainJs.LogLevel).warn, "WebGL context lost"); + event.preventDefault(); + }, false); + this._canvas.addEventListener("webglcontextrestored", ()=>{ + this._initializeContext(this._createContext(this._canvas)); + this._core.log.write((0, _mainJs.LogLevel).info, "WebGL context restored"); + }, false); + this._isInitialized = true; } - _initializeResources() { - const start = window.performance.now(); - const canvasConfig = { - device: this._device, - format: this._presentationFormat, - alphaMode: "opaque" - }; - this._context.configure(canvasConfig); - const computeUniformBufferDescriptor = { - label: "Compute uniform buffer", - size: (0, _raytraceJs.ComputeUniformBufferData).SIZE * 4, - usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST - }; - this._computeUniformBuffer = this._device.createBuffer(computeUniformBufferDescriptor); - this._computeUniformBufferData = new (0, _raytraceJs.ComputeUniformBufferData)(); - const fullscreenQuadUniformBufferDescriptor = { - label: "Full screen quad uniform buffer", - size: (0, _fullscreenquadJs.FullscreenQuadUniformBufferData).SIZE * 4, - usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST - }; - this._fullscreenQuadUniformBuffer = this._device.createBuffer(fullscreenQuadUniformBufferDescriptor); - this._fullscreenQuadUniformBufferData = new (0, _fullscreenquadJs.FullscreenQuadUniformBufferData)(); - this._sampler = this._device.createSampler({ - label: "Sampler", - magFilter: "linear", - minFilter: "linear" - }); + _initializeContext(gl) { + this._gl = gl; for(const key in this.fonts){ const fontVisual = this.fonts[key]; - fontVisual.initializeContext(this._device); - fontVisual.update(); + fontVisual.initializeContext(gl); } - for(let i = 0; i < this.images.length; i++){ - const image = this.images[i]; - image.initializeContext(this._device); - image.update(); + this._ssaoSampleKernel = new Float32Array(this._config.ssaoKernelSize * 3); + const random = new (0, _mathJs.PseudoRandom)(0); + const _vec3 = (0, _glMatrix.vec3).create(); + for(let i = 0; i < this._config.ssaoKernelSize; i++){ + _vec3[0] = random.nextFloat() * 2 - 1; + _vec3[1] = random.nextFloat() * 2 - 1; + _vec3[2] = random.nextFloat(); + (0, _glMatrix.vec3).normalize(_vec3, _vec3); + (0, _glMatrix.vec3).scale(_vec3, _vec3, random.nextFloat()); + let scale = i / this._config.ssaoKernelSize; + scale = (0, _mathJs.MathHelper).lerp(0.1, 1, scale * scale); + (0, _glMatrix.vec3).scale(_vec3, _vec3, scale); + this._ssaoSampleKernel[i * 3] = _vec3[0]; + this._ssaoSampleKernel[i * 3 + 1] = _vec3[1]; + this._ssaoSampleKernel[i * 3 + 2] = _vec3[2]; } - const textureSize = { - width: 1, - height: 1 - }; - const textureDescriptor = { - label: "Placeholder texture", - size: textureSize, - format: this._presentationFormat, - usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT - }; - this._texture = this._device.createTexture(textureDescriptor); - this._core.log.write((0, _mainJs.LogLevel).info, `WebGPU resources initialized ${Math.round(window.performance.now() - start)}ms`); - this._isInitialized = true; + const noise = new Float32Array(this._config.ssaoNoiseSize * this._config.ssaoNoiseSize * 4); + _vec3[2] = 0; + for(let i = 0; i < this._config.ssaoNoiseSize * this._config.ssaoNoiseSize; i++){ + _vec3[0] = random.nextFloat() * 2 - 1; + _vec3[1] = random.nextFloat() * 2 - 1; + (0, _glMatrix.vec3).normalize(_vec3, _vec3); + noise[i * 4] = _vec3[0]; + noise[i * 4 + 1] = _vec3[1]; + } + this._ssaoNoiseTexture = this._gl.createTexture(); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._ssaoNoiseTexture); + this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.REPEAT); + this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.REPEAT); + this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.NEAREST); + this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.NEAREST); + this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA32F, this._config.ssaoNoiseSize, this._config.ssaoNoiseSize, 0, this._gl.RGBA, this._gl.FLOAT, noise); + this._ssaoWidth = -1; + this._ssaoHeight = -1; + this._shadowWidth = -1; + this._shadowHeight = -1; + this._shaderResources.initializeContext(this._gl); + this._textureShader.initializeContext(this._gl); + this._lassoShader.initializeContext(this._gl); + this._sdfTextShader.initializeContext(this._gl); + this._gridShader.initializeContext(this._gl); + this._blockShader.initializeContext(this._gl); + this._sphereShader.initializeContext(this._gl); + this._cylinderShader.initializeContext(this._gl); + this._sdfShader.initializeContext(this._gl); + this._backgroundShader.initializeContext(this._gl); + this._ssaoShader.initializeContext(this._gl); + this._boxShader.initializeContext(this._gl); + this._deferredShader.initializeContext(this._gl); + this._combineShader.initializeContext(this._gl); + this._dofBlurShader.initializeContext(this._gl); + this._downsampleShader.initializeContext(this._gl); + this._gaussianShader.initializeContext(this._gl); + this._dofCombineShader.initializeContext(this._gl); + this._fxaaShader.initializeContext(this._gl); + this._brightPassShader.initializeContext(this._gl); + this._quad.initializeContext(this._gl); + this._lasso.initializeContext(this._gl); + this._framebuffers = [ + null, + null + ]; + const texture = (0, _textureJs1.TextureHelper).create(this._gl, this._core.config.pickWidth, this._core.config.pickHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); + const renderBuffer = this._gl.createRenderbuffer(); + this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); + this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT24, this._core.config.pickWidth, this._core.config.pickHeight); + const framebuffer = this._gl.createFramebuffer(); + this._shaderResources.bindFramebuffer(framebuffer); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, texture, 0); + this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); + this._pickFrameBuffer = framebuffer; + for(let i = 0; i < this.transitionBuffers.length; i++)this.transitionBuffers[i].initializeContext(this._gl); + if (this._axes1) for(let i = 0; i < this._axes1.length; i++)this._axes1[i].initializeContext(this._gl); + if (this._axes2) for(let i = 0; i < this._axes2.length; i++)this._axes2[i].initializeContext(this._gl); + for(let i = 0; i < this.labelSets.length; i++)this.labelSets[i].initializeContext(this._gl); + for(let i = 0; i < this.images.length; i++)this.images[i].initializeContext(this._gl); } - get isSupported() { - return navigator.gpu !== undefined; + _resize(width, height) { + super._resize(width, height); + this._positionTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.NEAREST, null, this._gl.RGBA32F); + this._colorTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._normalTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._geometryFrameBuffer = this._gl.createFramebuffer(); + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._positionTexture, 0); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT1, this._gl.TEXTURE_2D, this._colorTexture, 0); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT2, this._gl.TEXTURE_2D, this._normalTexture, 0); + const renderBuffer = this._gl.createRenderbuffer(); + this._gl.bindRenderbuffer(this._gl.RENDERBUFFER, renderBuffer); + this._gl.renderbufferStorage(this._gl.RENDERBUFFER, this._gl.DEPTH_COMPONENT24, width, height); + this._gl.framebufferRenderbuffer(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.RENDERBUFFER, renderBuffer); + this._gl.drawBuffers([ + this._gl.COLOR_ATTACHMENT0, + this._gl.COLOR_ATTACHMENT1, + this._gl.COLOR_ATTACHMENT2 + ]); + this._postProcessTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessDepthTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.DEPTH_COMPONENT, this._gl.UNSIGNED_INT, this._gl.NEAREST, null, this._gl.DEPTH_COMPONENT24); + this._postProcessFrameBuffer1 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessFrameBuffer1); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessTexture1, 0); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.TEXTURE_2D, this._postProcessDepthTexture, 0); + this._postProcessTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessFrameBuffer2 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessFrameBuffer2); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessTexture2, 0); + this._postProcessDofTexture = (0, _textureJs1.TextureHelper).create(this._gl, width, height, this._gl.RED, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.R32F); + this._postProcessDofFrameBuffer = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessDofFrameBuffer); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessDofTexture, 0); + const widthHalf = Math.round(width / 2); + const heightHalf = Math.round(height / 2); + this._postProcessHalfTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthHalf, heightHalf, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessHalfFrameBuffer1 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer1); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessHalfTexture1, 0); + this._postProcessHalfTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthHalf, heightHalf, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessHalfFrameBuffer2 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer2); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessHalfTexture2, 0); + const widthQuarter = Math.round(widthHalf / 2); + const heightQuarter = Math.round(heightHalf / 2); + this._postProcessQuarterTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthQuarter, heightQuarter, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessQuarterFrameBuffer1 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer1); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessQuarterTexture1, 0); + this._postProcessQuarterTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthQuarter, heightQuarter, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessQuarterFrameBuffer2 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer2); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessQuarterTexture2, 0); + const widthEighth = Math.round(widthQuarter / 2); + const heightEighth = Math.round(heightQuarter / 2); + this._postProcessEighthTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthEighth, heightEighth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessEighthFrameBuffer1 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer1); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessEighthTexture1, 0); + this._postProcessEighthTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthEighth, heightEighth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessEighthFrameBuffer2 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer2); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessEighthTexture2, 0); + const widthSixteenth = Math.round(widthEighth / 2); + const hgeightSixteenth = Math.round(heightEighth / 2); + this._postProcessSixteenthTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, widthSixteenth, hgeightSixteenth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessSixteenthFrameBuffer1 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer1); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessSixteenthTexture1, 0); + this._postProcessSixteenthTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, widthSixteenth, hgeightSixteenth, this._gl.RGBA, this._gl.FLOAT, this._gl.LINEAR, null, this._gl.RGBA32F); + this._postProcessSixteenthFrameBuffer2 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer2); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._postProcessSixteenthTexture2, 0); + this._core.log.write((0, _mainJs.LogLevel).info, `buffers resized ${width},${height}`); } - _createWorld() { - const start = performance.now(); - this._hittables = this._getHittables(); - if (this._hittables.length == 0) return; - const bvhAccel = new (0, _bvhJs.BVHAccel)(this._core, this._hittables, this._config.maxPrimsInNode, (0, _bvhJs.SplitMethod).sah); - const hittables = bvhAccel.orderedPrimitives; - for(let i = 0; i < this.transitionBuffers.length; i++){ - const transitionBuffer = this.transitionBuffers[i]; - if (transitionBuffer.isVisible) { - const atlas = transitionBuffer.currentAtlas; - if (atlas.imageData) { - const imageData = atlas.imageData; - const textureSize = { - width: imageData.width, - height: imageData.height - }; - createImageBitmap(imageData).then((imageBitmap)=>{ - const textureDescriptor = { - label: "Atlas texture", - size: textureSize, - format: this._presentationFormat, - usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT - }; - this._atlasTexture = this._device.createTexture(textureDescriptor); - const imageCopyExternalImage = { - source: imageBitmap - }; - const imageCopyTextureTagged = { - texture: this._atlasTexture - }; - const copySize = { - width: imageData.width, - height: imageData.height - }; - this._device.queue.copyExternalImageToTexture(imageCopyExternalImage, imageCopyTextureTagged, copySize); - }); - } - break; + _createContext(canvas) { + let supported = false; + const preserveDrawingBuffer = this._options ? this._options.preserveDrawingBuffer === undefined ? false : this._options.preserveDrawingBuffer : false; + const options = { + stencil: true, + alpha: false, + antialias: false, + preserveDrawingBuffer: preserveDrawingBuffer + }; + const gl = canvas.getContext("webgl2", options); + if (gl) { + const OES_texture_float_linear = gl.getExtension("OES_texture_float_linear"); + const EXT_color_buffer_float = gl.getExtension("EXT_color_buffer_float"); + if (OES_texture_float_linear && EXT_color_buffer_float && gl.MAX_DRAW_BUFFERS > 3) { + const texture = (0, _textureJs1.TextureHelper).create(gl, 1, 1, gl.RGBA, gl.FLOAT, gl.LINEAR, null, gl.RGBA32F); + const framebuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); + const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + if (status == gl.FRAMEBUFFER_COMPLETE) supported = true; + gl.bindTexture(gl.TEXTURE_2D, null); } } - const materials = []; - const materialIds = []; - for(let i1 = 0; i1 < hittables.length; i1++){ - const hittable = hittables[i1]; - const material = hittable.material; - let materialId; - let found; - for(let j = 0; j < materials.length; j++)if (materials[j] === material) { - found = true; - materialId = j; - break; - } - if (!found) { - materialId = materials.length; - materials.push(material); - } - materialIds.push(materialId); - } - const textures = []; - const textureIds = []; - for(let i2 = 0; i2 < materials.length; i2++){ - const material1 = materials[i2]; - const texture = material1.texture; - if (texture) { - let textureId; - let found1; - for(let j1 = 0; j1 < textures.length; j1++)if (textures[j1] === texture) { - found1 = true; - textureId = j1; - break; - } - if (!found1) { - textureId = textures.length; - textures.push(texture); - } - textureIds.push(textureId); - } else textureIds.push(0); - } - const textureBufferSizeBytes = textures.length * (0, _textureJs.TextureBufferData).SIZE * 4; - const textureBufferDescriptor = { - label: "Texture buffer", - size: textureBufferSizeBytes, - usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST - }; - this._textureBuffer = this._device.createBuffer(textureBufferDescriptor); - this._textureBufferData = new (0, _textureJs.TextureBufferData)(textures.length); - for(let i3 = 0; i3 < textures.length; i3++)textures[i3].toBuffer(this._textureBufferData, i3); - const materialBufferSizeBytes = materials.length * (0, _materialJs.MaterialBufferData).SIZE * 4; - const materialBufferDescriptor = { - label: "Material buffer", - size: materialBufferSizeBytes, - usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST - }; - this._materialBuffer = this._device.createBuffer(materialBufferDescriptor); - this._materialBufferData = new (0, _materialJs.MaterialBufferData)(materials.length); - for(let i4 = 0; i4 < materials.length; i4++)materials[i4].toBuffer(this._materialBufferData, i4, textureIds[i4]); - const hittableBufferSizeBytes = hittables.length * (0, _hittableJs.HittableBufferData).SIZE * 4; - const hittableBufferDescriptor = { - label: "Hittable buffer", - size: hittableBufferSizeBytes, - usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST - }; - this._hittableBuffer = this._device.createBuffer(hittableBufferDescriptor); - this._hittableBufferData = new (0, _hittableJs.HittableBufferData)(hittables.length); - for(let i5 = 0; i5 < hittables.length; i5++){ - const hittable1 = hittables[i5]; - hittable1.toBuffer(this._hittableBufferData, i5, materialIds[i5]); - } - const linearBVHNodes = bvhAccel.nodes; - const linearBVHNodeBufferSizeBytes = linearBVHNodes.length * (0, _bvhJs.LinearBVHNodeBufferData).SIZE * 4; - const linearBVHNodeBufferDescriptor = { - label: "Linear BVH node buffer", - size: linearBVHNodeBufferSizeBytes, - usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST - }; - this._linearBVHNodeBuffer = this._device.createBuffer(linearBVHNodeBufferDescriptor); - this._linearBVHNodeBufferData = new (0, _bvhJs.LinearBVHNodeBufferData)(linearBVHNodes.length); - for(let i6 = 0; i6 < linearBVHNodes.length; i6++)linearBVHNodes[i6].toBuffer(this._linearBVHNodeBufferData, i6); - this._device.queue.writeBuffer(this._hittableBuffer, 0, this._hittableBufferData.buffer, this._hittableBufferData.byteOffset, this._hittableBufferData.byteLength); - this._device.queue.writeBuffer(this._materialBuffer, 0, this._materialBufferData.buffer, this._materialBufferData.byteOffset, this._materialBufferData.byteLength); - this._device.queue.writeBuffer(this._textureBuffer, 0, this._textureBufferData.buffer, this._textureBufferData.byteOffset, this._textureBufferData.byteLength); - this._device.queue.writeBuffer(this._linearBVHNodeBuffer, 0, this._linearBVHNodeBufferData.buffer, this._linearBVHNodeBufferData.byteOffset, this._linearBVHNodeBufferData.byteLength); - this._core.log.write((0, _mainJs.LogLevel).info, `create world ${Math.round(window.performance.now() - start)}ms`); + return supported ? gl : null; } - _createLights() { - const modelScale = this._core.getModelScale(); - (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - const lightsCopy = []; - if (this.lights) for(let i = 0; i < this.lights.length; i++){ - const light = this.lights[i]; - let lightCopy; - if (light instanceof (0, _lightJs.RectLight)) lightCopy = new (0, _lightJs.RectLight)({ - center: (0, _glMatrix.vec3).clone(light.center), - color: (0, _glMatrix.vec3).clone(light.color), - rotation: (0, _glMatrix.quat).clone(light.rotation), - size: (0, _glMatrix.vec2).fromValues(light.size[0] * modelScale, light.size[1] * modelScale) - }); - else if (light instanceof (0, _lightJs.SphereLight)) lightCopy = new (0, _lightJs.SphereLight)({ - center: (0, _glMatrix.vec3).clone(light.center), - color: (0, _glMatrix.vec3).clone(light.color), - radius: light.radius * modelScale - }); - (0, _glMatrix.vec3).scale(lightCopy.center, lightCopy.center, modelScale); - (0, _glMatrix.vec3).add(lightCopy.center, lightCopy.center, this._modelPosition); - lightsCopy.push(lightCopy); - } - else lightsCopy.push(new (0, _lightJs.SphereLight)({ - center: (0, _constantsJs.Constants).VECTOR3_ZERO, - color: (0, _constantsJs.Constants).VECTOR3_ZERO, - radius: 0 - })); - if (!this._lightBuffer) { - const lightBufferSizeBytes = lightsCopy.length * (0, _lightJs.LightBufferData).SIZE * 4; - const lightBufferDescriptor = { - label: "Light buffer", - size: lightBufferSizeBytes, - usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST - }; - this._lightBuffer = this._device.createBuffer(lightBufferDescriptor); - this._lightBufferData = new (0, _lightJs.LightBufferData)(lightsCopy.length); + prepare() { + let viewport; + switch(this._core.config.stereoMode){ + case (0, _mainJs.StereoMode).none: + viewport = this._viewports[0]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 0; + this._viewportCount = 1; + break; + case (0, _mainJs.StereoMode).left: + viewport = this._viewports[0]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 0; + this._viewportCount = 1; + break; + case (0, _mainJs.StereoMode).right: + viewport = this._viewports[1]; + viewport.x = 0; + viewport.y = 0; + viewport.width = this._canvas.width; + viewport.height = this._canvas.height; + this._viewportOffset = 1; + this._viewportCount = 1; + break; } - for(let i1 = 0; i1 < lightsCopy.length; i1++)lightsCopy[i1].toBuffer(this._lightBufferData, i1); - this._device.queue.writeBuffer(this._lightBuffer, 0, this._lightBufferData.buffer, this._lightBufferData.byteOffset, this._lightBufferData.byteLength); } - standardLighting(options) { - options || (options = this._config.standardLightingOptions); - const azimuthOffset = options.azimuthOffset || 0; - const lightOptionsArray = [ - options.key, - options.fill, - options.back, - ]; - const lights = []; - for(let i = 0; i < lightOptionsArray.length; i++){ - const lightOptions = lightOptionsArray[i]; - const center = (0, _glMatrix.vec3).create(); - const rotation = (0, _glMatrix.quat).create(); - const azimuth = (0, _angleJs.AngleHelper).degreesToRadians(azimuthOffset + lightOptions.azimuth); - const altitude = (0, _angleJs.AngleHelper).degreesToRadians(-lightOptions.altitude); - (0, _glMatrix.quat).rotateY(rotation, (0, _constantsJs.Constants).QUAT_IDENTITY, azimuth); - (0, _glMatrix.quat).rotateX(rotation, rotation, altitude); - (0, _glMatrix.vec3).transformQuat(center, (0, _constantsJs.Constants).VECTOR3_UNITZ, rotation); - (0, _glMatrix.vec3).scale(center, center, lightOptions.distance); - const yaw = (0, _angleJs.AngleHelper).degreesToRadians(azimuthOffset + lightOptions.yaw); - const pitch = (0, _angleJs.AngleHelper).degreesToRadians(-lightOptions.pitch); - (0, _glMatrix.quat).rotateY(rotation, (0, _constantsJs.Constants).QUAT_IDENTITY, yaw); - (0, _glMatrix.quat).rotateX(rotation, rotation, pitch); - lights.push(new (0, _lightJs.RectLight)({ - center: center, - color: (0, _glMatrix.vec3).fromValues(lightOptions.brightness * lightOptions.color[0], lightOptions.brightness * lightOptions.color[1], lightOptions.brightness * lightOptions.color[2]), - size: (0, _glMatrix.vec2).fromValues(lightOptions.size[0], lightOptions.size[1]), - rotation: rotation - })); - } - return lights; + createTransitionBuffer(ids) { + const buffer = new (0, _bufferJs.TransitionBuffer)(this._core, ids); + buffer.initializeContext(this._gl); + return buffer; } - _getHittables() { - const hittables = []; - let minY = Number.MAX_VALUE; - for(let i = 0; i < this.transitionBuffers.length; i++){ - const transitionBuffer = this.transitionBuffers[i]; - if (transitionBuffer.isVisible && transitionBuffer.hittables && transitionBuffer.hittables.length > 0) { - minY = Math.min(minY, transitionBuffer.minY); - for(let j = 0; j < transitionBuffer.hittables.length; j++)hittables.push(transitionBuffer.hittables[j]); - } - } - if (this.labelSets && this.labelSets.length > 0) for(let i1 = 0; i1 < this.labelSets.length; i1++){ - const labelSet = this.labelSets[i1]; - if (labelSet.hittables) for(let j1 = 0; j1 < labelSet.hittables.length; j1++)hittables.push(labelSet.hittables[j1]); - } - if (this.images && this.images.length > 0) { - for(let i2 = 0; i2 < this.images.length; i2++)if (this.images[i2].hittable) { - const hittable = this.images[i2].hittable; - hittables.push(hittable); - minY = Math.min(hittable.bounds.min[1], minY); - } - } - if (this.ground) { - const modelPosition = (0, _glMatrix.vec3).create(); - const modelScale = this._core.getModelScale(); - const modelRotation = (0, _glMatrix.quat).create(); - this._core.getModelRotation(modelRotation); - (0, _glMatrix.vec3).set(modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); - const groundSize = (0, _glMatrix.vec2).create(); - const groundPosition = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec2).scale(groundSize, this.ground.size || this._config.groundSize, modelScale); - if (this.ground.position) (0, _glMatrix.vec3).scale(groundPosition, this.ground.position, modelScale); - else (0, _glMatrix.vec3).set(groundPosition, 0, minY - (0, _constantsJs1.Constants).SHADOW_OFFSET, 0); - const options = { - size: groundSize, - center0: groundPosition, - center1: groundPosition, - time0: 1, - time1: 1, - texCoord0: (0, _glMatrix.vec2).fromValues(0, 0), - texCoord1: (0, _glMatrix.vec2).fromValues(1, 1), - material: this.ground.material || this.config.defaultMaterial - }; - (0, _glMatrix.vec3).add(options.center0, options.center0, modelPosition); - hittables.push(new (0, _hittableJs.HittableXzRect)(options)); - } - return hittables; + createCartesian2dAxesVisual(axes) { + const visual = new (0, _cartesian2DJs.Cartesian2dVisual)(this._core, this, axes); + visual.initializeContext(this._gl); + return visual; } - createFontVisual(font) { - const visual = new (0, _fontJs.FontVisual)(this._core, font); - if (this._isInitialized) visual.initializeContext(this._device); - visual.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; + createCartesian3dAxesVisual(axes) { + const visual = new (0, _cartesian3DJs.Cartesian3dVisual)(this._core, this, axes); + visual.initializeContext(this._gl); + return visual; + } + _createLabelVisual(label) { + return new (0, _labelsJs.LabelVisual)(this._core, this, label); + } + createLabelSetVisual(labelSet) { + const visual = new (0, _labelsJs.LabelSetVisual)(this._core, this, labelSet); + visual.initializeContext(this._gl); return visual; } createImageVisual(image) { const visual = new (0, _imageJs.ImageVisual)(this._core, this, image); - if (this._isInitialized) visual.initializeContext(this._device); - visual.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; + visual.initializeContext(this._gl); return visual; } - createLabelSetVisual(labelSet) { - const visual = new (0, _labelsJs.LabelSetVisual)(this._core, this, labelSet); - visual.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; + createFontVisual(font) { + const visual = new (0, _fontJs.FontVisual)(this._core, font); + visual.initializeContext(this._gl); return visual; } - createTransitionBuffer(ids) { - const transitionBuffer = new (0, _bufferJs.TransitionBuffer)(this._core, this, ids); - transitionBuffer.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - return transitionBuffer; - } - _resizeBackings() { - const width = this.width; - const height = this.height; - const colorChannels = 3; - const outputColorBufferSizeBytes = Uint32Array.BYTES_PER_ELEMENT * width * height * colorChannels; - const outputColorBufferDescriptor = { - label: "Output color buffer", - size: outputColorBufferSizeBytes, - usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC - }; - const outputColorBuffer = this._device.createBuffer(outputColorBufferDescriptor); - const computeShaderModuleDescriptor = { - code: (0, _raytraceJs.ComputeShaderWgsl) - }; - const computeModule = this._device.createShaderModule(computeShaderModuleDescriptor); - const computeBindGroupLayoutDescriptor = { - entries: [ - { - binding: 0, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "storage" - } - }, - { - binding: 1, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "uniform" - } - }, - { - binding: 2, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "read-only-storage" - } - }, - { - binding: 3, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "read-only-storage" - } - }, - { - binding: 4, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "read-only-storage" - } - }, - { - binding: 5, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "read-only-storage" - } - }, - { - binding: 6, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "read-only-storage" - } - }, - { - binding: 7, - visibility: GPUShaderStage.COMPUTE, - sampler: { - type: "filtering" - } - }, - { - binding: 8, - visibility: GPUShaderStage.COMPUTE, - texture: { - multisampled: false, - sampleType: "float", - viewDimension: "2d" - } - }, - { - binding: 9, - visibility: GPUShaderStage.COMPUTE, - texture: { - multisampled: false, - sampleType: "float", - viewDimension: "2d" - } - }, - { - binding: 10, - visibility: GPUShaderStage.COMPUTE, - texture: { - multisampled: false, - sampleType: "float", - viewDimension: "2d" - } - } - ] - }; - const computeBindGroupLayout = this._device.createBindGroupLayout(computeBindGroupLayoutDescriptor); - const computeBindGroupDescriptor = { - label: "Compute bind group descriptor", - layout: computeBindGroupLayout, - entries: [ - { - binding: 0, - resource: { - buffer: outputColorBuffer - } - }, - { - binding: 1, - resource: { - buffer: this._computeUniformBuffer - } - }, - { - binding: 2, - resource: { - buffer: this._hittableBuffer - } - }, - { - binding: 3, - resource: { - buffer: this._materialBuffer - } - }, - { - binding: 4, - resource: { - buffer: this._textureBuffer - } - }, - { - binding: 5, - resource: { - buffer: this._lightBuffer - } - }, - { - binding: 6, - resource: { - buffer: this._linearBVHNodeBuffer - } - }, - { - binding: 7, - resource: this._sampler - }, - { - binding: 8, - resource: (this.fonts[this._core.font.name].texture || this._texture).createView() - }, - { - binding: 9, - resource: (this.images && this.images.length > 0 && this.images[0].texture || this._texture).createView() - }, - { - binding: 10, - resource: (this._atlasTexture || this._texture).createView() - } - ] - }; - this._computeBindGroup = this._device.createBindGroup(computeBindGroupDescriptor); - const computePipelineLayoutDescriptor = { - label: "Compute pipeline layout descriptor", - bindGroupLayouts: [ - computeBindGroupLayout - ] - }; - const computePipelineLayout = this._device.createPipelineLayout(computePipelineLayoutDescriptor); - const compute = { - module: computeModule, - entryPoint: "main" - }; - const computePipelineDescriptor = { - label: "Compute pipeline descriptor", - layout: computePipelineLayout, - compute: compute - }; - this._computePipeline = this._device.createComputePipeline(computePipelineDescriptor); - const clearBindGroupLayoutDescriptor = { - label: "Clear bind group layout descriptor", - entries: [ - { - binding: 0, - visibility: GPUShaderStage.COMPUTE, - buffer: { - type: "storage" - } - } - ] - }; - const clearBindGroupLayout = this._device.createBindGroupLayout(clearBindGroupLayoutDescriptor); - const clearBindGroupDescriptor = { - label: "Clear bind group descriptor", - layout: clearBindGroupLayout, - entries: [ - { - binding: 0, - resource: { - buffer: outputColorBuffer - } - } - ] - }; - this._clearBindGroup = this._device.createBindGroup(clearBindGroupDescriptor); - const clearPipelineLayoutDescriptor = { - label: "Clear pipeline layout descriptor", - bindGroupLayouts: [ - clearBindGroupLayout - ] - }; - const clearPipelineLayout = this._device.createPipelineLayout(clearPipelineLayoutDescriptor); - const clear = { - module: computeModule, - entryPoint: "clear" - }; - const clearPipelineDescriptor = { - label: "Clear pipeline descriptor", - layout: clearPipelineLayout, - compute: clear - }; - this._clearPipeline = this._device.createComputePipeline(clearPipelineDescriptor); - const fullscreenQuadShaderDescriptor = { - label: "Fullscreen quad shader descriptor", - code: (0, _fullscreenquadJs.FullscreenQuadWgsl) - }; - const fullscreenQuadModule = this._device.createShaderModule(fullscreenQuadShaderDescriptor); - const fullscreenQuadBindGroupLayoutDescriptor = { - label: "Fullscreen quad bind group layout descriptor", - entries: [ - { - binding: 0, - visibility: GPUShaderStage.FRAGMENT, - buffer: { - type: "uniform" - } - }, - { - binding: 1, - visibility: GPUShaderStage.FRAGMENT, - buffer: { - type: "read-only-storage" - } - } - ] - }; - const fullscreenQuadBindGroupLayout = this._device.createBindGroupLayout(fullscreenQuadBindGroupLayoutDescriptor); - const fullscreenQuadPipelineLayoutDescriptor = { - label: "Fullscreen quad pipeline layout descriptor", - bindGroupLayouts: [ - fullscreenQuadBindGroupLayout - ] - }; - const fullscreenQuadPipelineLayout = this._device.createPipelineLayout(fullscreenQuadPipelineLayoutDescriptor); - const vertex = { - module: fullscreenQuadModule, - entryPoint: "vert_main" - }; - const colorState = { - format: this._presentationFormat - }; - const fragment = { - module: fullscreenQuadModule, - entryPoint: "frag_main", - targets: [ - colorState - ] - }; - const primitive = { - topology: "triangle-list" - }; - const fullscreenQuadPiplelineDescriptor = { - label: "Fullscreen quad pipeline descriptor", - layout: fullscreenQuadPipelineLayout, - vertex: vertex, - fragment: fragment, - primitive: primitive - }; - this._fullscreenQuadPipeline = this._device.createRenderPipeline(fullscreenQuadPiplelineDescriptor); - const fullscreenQuadBindGroupDescriptor = { - label: "Fullscreen quad bind group descriptor", - layout: fullscreenQuadBindGroupLayout, - entries: [ - { - binding: 0, - resource: { - buffer: this._fullscreenQuadUniformBuffer - } - }, - { - binding: 1, - resource: { - buffer: outputColorBuffer - } - } - ] - }; - this._fullscreenQuadBindGroup = this._device.createBindGroup(fullscreenQuadBindGroupDescriptor); - this._computeUniformBufferData.setWidth(width); - this._computeUniformBufferData.setHeight(height); - this._fullscreenQuadUniformBufferData.setWidth(width); - this._fullscreenQuadUniformBufferData.setHeight(height); - this._computeUniformBufferData.setTime0(0); - this._computeUniformBufferData.setTime1(1); - this._computeDispatchCount = Math.min(Math.ceil(width * height / 256), this._device.limits.maxComputeWorkgroupsPerDimension); - this._frameCount = 0; + getDataUrl(mimeType) { + return this._canvas.toDataURL(mimeType); } update(elapsedTime) { super.update(elapsedTime); - for(let i = 0; i < this.transitionBuffers.length; i++){ - const transitionBuffer = this.transitionBuffers[i]; - if (transitionBuffer.isVisible) { - const time0 = this._core.renderer.transitionTime; - const time1 = Math.min(time0 + this._config.shutterSpeed, 1); - transitionBuffer.time0 = time0; - transitionBuffer.time1 = time1; - transitionBuffer.duration = this._core.config.transitionDuration; - transitionBuffer.stagger = this._core.config.transitionStaggering; - transitionBuffer.update(); - } - } - if (this._hasChanged) { - this._hasChanged = false; - this._createWorld(); - if (this._hittables.length > 0) { - this._createLights(); - this._resizeBackings(); - } + if (this._shadowWidth != this._config.shadowWidth || this._shadowHeight != this._config.shadowHeight) { + this._shadowWidth = this._config.shadowWidth; + this._shadowHeight = this._config.shadowHeight; + this._shadowColorTexture = (0, _textureJs1.TextureHelper).create(this._gl, this._config.shadowWidth, this._config.shadowHeight, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null); + this._shadowDepthTexture = (0, _textureJs1.TextureHelper).create(this._gl, this._config.shadowWidth, this._config.shadowHeight, this._gl.DEPTH_COMPONENT, this._gl.UNSIGNED_INT, this._gl.NEAREST, null, this._gl.DEPTH_COMPONENT24); + this._shadowFrameBuffer = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._shadowFrameBuffer); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._shadowColorTexture, 0); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.DEPTH_ATTACHMENT, this._gl.TEXTURE_2D, this._shadowDepthTexture, 0); + this._core.log.write((0, _mainJs.LogLevel).info, `shadow map resized ${this._shadowWidth},${this._shadowHeight}`); } - if (this._core.config.isDebugVisible) this._core.debugText.addLine(`frm tot ${this._frameCount}`); - } - render(elapsedTime) { - if (this._hittables.length == 0) return; - const epsilon = 0.000001; - if (Math.abs(this._computeUniformBufferData.getFieldOfView() - this._core.config.fov) > epsilon) { - this._frameCount = 0; - this._computeUniformBufferData.setFieldOfView(this._core.config.fov); + if (this._ssaoWidth != this._config.ssaoWidth || this._ssaoHeight != this._config.ssaoHeight) { + this._ssaoWidth = this._config.ssaoWidth; + this._ssaoHeight = this._config.ssaoHeight; + this._ssaoTexture1 = (0, _textureJs1.TextureHelper).create(this._gl, this._config.ssaoWidth, this._config.ssaoHeight, this._gl.RED, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null, this._gl.R8); + this._ssaoFrameBuffer1 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._ssaoFrameBuffer1); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._ssaoTexture1, 0); + this._ssaoTexture2 = (0, _textureJs1.TextureHelper).create(this._gl, this._config.ssaoWidth, this._config.ssaoHeight, this._gl.RED, this._gl.UNSIGNED_BYTE, this._gl.LINEAR, null, this._gl.R8); + this._ssaoFrameBuffer2 = this._gl.createFramebuffer(); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._ssaoFrameBuffer2); + this._gl.framebufferTexture2D(this._gl.FRAMEBUFFER, this._gl.COLOR_ATTACHMENT0, this._gl.TEXTURE_2D, this._ssaoTexture2, 0); + this._core.log.write((0, _mainJs.LogLevel).info, `ssao map resized ${this._ssaoWidth},${this._ssaoHeight}`); } - if (Math.abs(this._computeUniformBufferData.getAperture() - this._config.aperture) > epsilon) { - this._frameCount = 0; - this._computeUniformBufferData.setAperture(this._config.aperture); - } - const m = this.inverseVMatrices[0]; - this._computeUniformBufferData.getPosition(this._position); - this._computeUniformBufferData.getRight(this._right); - this._computeUniformBufferData.getUp(this._up); - this._computeUniformBufferData.getForward(this._forward); - if (Math.abs(this._position[0] - m[12]) > epsilon || Math.abs(this._position[1] - m[13]) > epsilon || Math.abs(this._position[2] - m[14]) > epsilon || Math.abs(this._right[0] - m[0]) > epsilon || Math.abs(this._right[1] - m[1]) > epsilon || Math.abs(this._right[2] - m[2]) > epsilon || Math.abs(this._up[0] - m[4]) > epsilon || Math.abs(this._up[1] - m[5]) > epsilon || Math.abs(this._up[2] - m[6]) > epsilon || Math.abs(this._forward[0] - m[8]) > epsilon || Math.abs(this._forward[1] - m[9]) > epsilon || Math.abs(this._forward[2] - m[10]) > epsilon) { - this._frameCount = 0; - (0, _glMatrix.vec3).set(this._position, m[12], m[13], m[14]); - (0, _glMatrix.vec3).set(this._right, m[0], m[1], m[2]); - (0, _glMatrix.vec3).set(this._up, m[4], m[5], m[6]); - (0, _glMatrix.vec3).set(this._forward, m[8], m[9], m[10]); - this._computeUniformBufferData.setPosition(this._position); - this._computeUniformBufferData.setRight(this._right); - this._computeUniformBufferData.setUp(this._up); - this._computeUniformBufferData.setForward(this._forward); + if (this._config.isDofEnabled && this._config.dofAutoFocus) { + this._core.getModelManipulationOrigin(this._modelManipulationOrigin); this._core.getModelPosition(this._modelPosition); - this._core.getModelManipulationOrigin(this._manipulationOrigin); - (0, _glMatrix.vec3).add(this._modelPosition, this._modelPosition, this._manipulationOrigin); - this._computeUniformBufferData.setLookAt(this._modelPosition); - } - this._computeUniformBufferData.getBackgroundColor(this._backgroundColor); - if (!(0, _glMatrix.vec3).equals(this._backgroundColor, this._config.backgroundColor)) { - this._frameCount = 0; - this._computeUniformBufferData.setBackgroundColor(this._config.backgroundColor); - } - if (this.lights) { - this._lightBufferData.getCenter(0, this._position); - if (Math.abs(this._position[0] - this.lights[0].center[0] * this._core.getModelScale()) > epsilon) { - this._frameCount = 0; - this._createLights(); - } - } - const clear = this._frameCount == 0; - if (clear) { - this._duration = 0; - this._startTime = performance.now(); - } - if (this._frameCount >= this._config.maxSamplesPerPixel) { - this._core.stop(); - return; - } - const raysPerFrame = 1; - this._computeUniformBufferData.setSeed(this._core.totalFrames * raysPerFrame); - this._device.queue.writeBuffer(this._computeUniformBuffer, 0, this._computeUniformBufferData.buffer, this._computeUniformBufferData.byteOffset, this._computeUniformBufferData.byteLength); - this._frameCount += raysPerFrame; - this._fullscreenQuadUniformBufferData.setSamplesPerPixel(this._frameCount); - this._fullscreenQuadUniformBufferData.setExposure(this._config.exposure); - this._device.queue.writeBuffer(this._fullscreenQuadUniformBuffer, 0, this._fullscreenQuadUniformBufferData.buffer, this._fullscreenQuadUniformBufferData.byteOffset, this._fullscreenQuadUniformBufferData.byteLength); - this._encodeCommands(clear); - this._duration = performance.now() - this._startTime; - } - clear() { - this._frameCount = 0; - } - _encodeCommands(clear) { - const commandEncoder = this._device.createCommandEncoder(); - const computePassEncoder = commandEncoder.beginComputePass(); - if (clear) { - computePassEncoder.setPipeline(this._clearPipeline); - computePassEncoder.setBindGroup(0, this._clearBindGroup); - computePassEncoder.dispatchWorkgroups(this._computeDispatchCount, 1, 1); - } - computePassEncoder.setPipeline(this._computePipeline); - computePassEncoder.setBindGroup(0, this._computeBindGroup); - computePassEncoder.dispatchWorkgroups(this._computeDispatchCount, 1, 1); - computePassEncoder.end(); - const colorAttachment = { - view: this._context.getCurrentTexture().createView(), - clearValue: { - r: 0.0, - g: 0.0, - b: 0.0, - a: 1.0 - }, - loadOp: "clear", - storeOp: "store" - }; - const fullscreenQuadRenderPassDescriptor = { - colorAttachments: [ - colorAttachment - ] - }; - const renderPassEncoder = commandEncoder.beginRenderPass(fullscreenQuadRenderPassDescriptor); - renderPassEncoder.setPipeline(this._fullscreenQuadPipeline); - renderPassEncoder.setBindGroup(0, this._fullscreenQuadBindGroup); - renderPassEncoder.draw(6, 1, 0, 0); - renderPassEncoder.end(); - this._queue.submit([ - commandEncoder.finish() - ]); - } - _resize(width, height) { - super._resize(width, height); - if (this._isInitialized && this._hittables.length > 0) { - this._resizeBackings(); - this._core.log.write((0, _mainJs.LogLevel).info, `buffers resized ${width},${height}`); + (0, _glMatrix.vec3).add(this._position, this._modelManipulationOrigin, this._modelPosition); + this._core.camera.getPosition(this._cameraPosition); + (0, _glMatrix.vec3).subtract(this._position, this._position, this._cameraPosition); + const distance = -this._position[2]; + const amount = Math.min(elapsedTime * this._core.config.focusSmoothing, 1); + this._config.dofFocusDistance = (0, _mathJs.MathHelper).lerp(this._config.dofFocusDistance, distance, amount); } } -} - -},{"gl-matrix":"9GjEQ","../renderer.js":"gKWdZ","../../main.js":"1Kju3","./config.js":"kzWKJ","./hittable.js":"5bOsK","./material.js":"5mttU","./shaders/raytrace.js":"iJHMh","./shaders/fullscreenquad.js":"3e1eA","./bvh.js":"rJ9Fm","./texture.js":"3ZvZF","./light.js":"8rYr6","../../constants.js":"2Scl5","../../helpers/angle.js":"eKtPm","./font.js":"iQd3h","./image.js":"8XGYp","./labels.js":"jWtqv","./buffer.js":"fTufe","./constants.js":"3ibK7","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kzWKJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Config", ()=>Config); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _rendererJs = require("../renderer.js"); -var _materialJs = require("./material.js"); -var _textureJs = require("./texture.js"); -class Config extends (0, _rendererJs.RendererConfig) { - constructor(){ - super(); - this.reset(); - } - reset() { - this.aperture = 0; - this.exposure = 1; - this.maxSamplesPerPixel = 10000; - this.shutterSpeed = 0; - this.maxPrimsInNode = 1; - this.defaultMaterial = new (0, _materialJs.LambertianMaterial)({ - texture: new (0, _textureJs.SolidColorTexture)({ - color: (0, _glMatrix.vec3).fromValues(0.5, 0.5, 0.5) - }) - }); - this.defaultTextMaterial = new (0, _materialJs.LambertianMaterial)({ - texture: new (0, _textureJs.SolidColorTexture)({ - color: (0, _glMatrix.vec3).fromValues(1, 1, 1) - }) - }); - this.groundSize = (0, _glMatrix.vec2).fromValues(10, 10); - this.backgroundColor = (0, _glMatrix.vec3).fromValues(0, 0, 0); - this.standardLightingOptions = { - azimuthOffset: 0, - key: { - brightness: 10, - azimuth: -45, - altitude: 30, - distance: 1.5, - size: (0, _glMatrix.vec2).fromValues(0.5, 0.5), - yaw: -45, - pitch: 30, - color: (0, _glMatrix.vec3).fromValues(1, 1, 1) - }, - fill: { - brightness: 1, - azimuth: 45, - altitude: 30, - distance: 1.5, - size: (0, _glMatrix.vec2).fromValues(0.5, 0.5), - yaw: 45, - pitch: 30, - color: (0, _glMatrix.vec3).fromValues(1, 1, 1) - }, - back: { - brightness: 1, - azimuth: -135, - altitude: 30, - distance: 1.5, - size: (0, _glMatrix.vec2).fromValues(0.5, 0.5), - yaw: -135, - pitch: 30, - color: (0, _glMatrix.vec3).fromValues(1, 1, 1) + render(elapsedTime) { + return __awaiter(this, void 0, void 0, function*() { + this._gl.enable(this._gl.DEPTH_TEST); + this._gl.enable(this._gl.CULL_FACE); + this._gl.cullFace(this._gl.BACK); + this._gl.disable(this._gl.BLEND); + if (this.isPickingEnabled) { + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.clearColor(0, 0, 0, 0); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); } - }; - } -} - -},{"gl-matrix":"9GjEQ","../renderer.js":"gKWdZ","./material.js":"5mttU","./texture.js":"3ZvZF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5mttU":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "MaterialType", ()=>MaterialType); -parcelHelpers.export(exports, "MaterialBufferData", ()=>MaterialBufferData); -parcelHelpers.export(exports, "Material", ()=>Material); -parcelHelpers.export(exports, "LambertianMaterial", ()=>LambertianMaterial); -parcelHelpers.export(exports, "MetalMaterial", ()=>MetalMaterial); -parcelHelpers.export(exports, "DielectricMaterial", ()=>DielectricMaterial); -parcelHelpers.export(exports, "DiffuseLightMaterial", ()=>DiffuseLightMaterial); -parcelHelpers.export(exports, "GlossyMaterial", ()=>GlossyMaterial); -parcelHelpers.export(exports, "IsotropicMaterial", ()=>IsotropicMaterial); -parcelHelpers.export(exports, "VarnishMaterial", ()=>VarnishMaterial); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -const MaterialType = { - lambertian: 0, - metal: 1, - dielectric: 2, - glossy: 3, - diffuseLight: 4, - isotropic: 5, - varnish: 6 -}; -class MaterialBufferData extends Float32Array { - constructor(count){ - super(count * MaterialBufferData.SIZE); - this.TYPE_OFFSET = 0; - this.FUZZ_OFFSET = 1; - this.REFRACTIVE_INDEX_OFFSET = 2; - this.TEXTURE_ID_OFFSET = 3; - this.COLOR_OFFSET = 4; - this.GLOSSINESS_OFFSET = 7; - this.DENSITY_OFFSET = 8; - } - getType(index) { - return this[MaterialBufferData.SIZE * index + this.TYPE_OFFSET]; - } - setType(index, value) { - this[MaterialBufferData.SIZE * index + this.TYPE_OFFSET] = value; - } - getFuzz(index) { - return this[MaterialBufferData.SIZE * index + this.FUZZ_OFFSET]; - } - setFuzz(index, value) { - this[MaterialBufferData.SIZE * index + this.FUZZ_OFFSET] = value; - } - getRefractiveIndex(index) { - return this[MaterialBufferData.SIZE * index + this.REFRACTIVE_INDEX_OFFSET]; - } - setRefractiveIndex(index, value) { - this[MaterialBufferData.SIZE * index + this.REFRACTIVE_INDEX_OFFSET] = value; - } - getTextureId(index) { - return this[MaterialBufferData.SIZE * index + this.TEXTURE_ID_OFFSET]; - } - setTextureId(index, value) { - this[MaterialBufferData.SIZE * index + this.TEXTURE_ID_OFFSET] = value; - } - getColor(index, value) { - const offset = MaterialBufferData.SIZE * index + this.COLOR_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + const backgroundColor = this._backgroundColor || this._core.config.backgroundColor; + this._gl.clearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], 1); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT | this._gl.STENCIL_BUFFER_BIT); + if (this.config.isShadowEnabled) { + this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); + this._gl.clear(this._gl.DEPTH_BUFFER_BIT); + (0, _glMatrix.mat4).perspective(this._shadowPMatrix, (0, _angleJs.AngleHelper).degreesToRadians(30), this._config.shadowWidth / this._config.shadowHeight, this._core.config.nearPlane, this._core.config.farPlane); + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.mat3).fromMat4(this._cameraRotation, this.inverseVMatrices[0]); + (0, _glMatrix.vec3).transformMat3(this._position, this._config.keyLightPosition, this._cameraRotation); + (0, _glMatrix.vec3).add(this._position, this._position, this._modelPosition); + (0, _glMatrix.mat4).lookAt(this._shadowVMatrix, this._position, this._modelPosition, (0, _constantsJs.Constants).VECTOR3_UNITY); + } + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible) this._renderTransitionBuffer(transitionBuffer); + } + const axesVisuals = this.axesVisibility == (0, _mainJs.AxesVisibility).current ? this.currentAxes : this.axesVisibility == (0, _mainJs.AxesVisibility).previous ? this.previousAxes : null; + if (axesVisuals) for(let i = 0; i < axesVisuals.length; i++){ + const axesVisual = axesVisuals[i]; + if (axesVisual.isVisible) { + axesVisual.pickedIdColor = this._pickedIdColor; + axesVisual.pickFramebuffer = this._pickFrameBuffer; + axesVisual.geometryFramebuffer = this._geometryFrameBuffer; + axesVisual.render(elapsedTime); + } + } + if (this.areLabelsVisible) for(let i = 0; i < this.labelSets.length; i++){ + const labelSetVisual = this.labelSets[i]; + if (labelSetVisual.isVisible) { + labelSetVisual.pickedIdColor = this._pickedIdColor; + labelSetVisual.pickFramebuffer = this._pickFrameBuffer; + labelSetVisual.geometryFramebuffer = this._geometryFrameBuffer; + labelSetVisual.render(elapsedTime); + } + } + if (this.areImagesVisible) for(let i = 0; i < this.images.length; i++){ + const imageVisual = this.images[i]; + if (imageVisual.isVisible) { + imageVisual.geometryFramebuffer = this._geometryFrameBuffer; + imageVisual.render(elapsedTime); + } + } + if (this._backgroundShader.isInitialized) { + this._backgroundShader.prepare(); + this._backgroundShader.color = (0, _glMatrix.vec3).fromValues(this._core.config.backgroundColor[0], this._core.config.backgroundColor[1], this._core.config.backgroundColor[2]); + this._backgroundShader.apply(); + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + this._gl.bindVertexArray(null); + } + if (this.isPickingEnabled) { + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.readPixels(this._core.config.pickWidth / 2, this._core.config.pickHeight / 2, 1, 1, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._pickedPixels); + this._pickedType = (0, _pickJs.PickHelper).decodeType(this._pickedPixels); + (0, _glMatrix.vec4).set(this._pickedIdColor, this._pickedPixels[0] / 0xff, this._pickedPixels[1] / 0xff, this._pickedPixels[2] / 0xff, this._pickedPixels[3] / 0xff); + this._pickedId = (0, _pickJs.PickHelper).decodeNumber(this._pickedPixels); + } else { + (0, _glMatrix.vec4).set(this._pickedIdColor, 0, 0, 0, 0); + this._pickedId = 0; + } + if (this.transitionBuffers.length > 0 && this._quad.isInitialized) { + const viewport = this._viewportOffset; + this._postProcess(this.vMatrices[viewport], this.inverseVMatrices[viewport], this.pMatrices[viewport], this._viewports[viewport]); + } + if (this.isLassoPicking && this._lassoShader.isInitialized) { + this._lassoShader.vertexBuffer = this._lasso.vertexBuffer; + this._lassoShader.indexBuffer = this._lasso.indexBuffer; + const lassoWidth = this.lassoX1 - this.lassoX0; + const lassoHeight = this.lassoY1 - this.lassoY0; + this._lassoShader.prepare(); + this._lassoShader.color = this.lassoColor ? this.lassoColor : this._core.config.lassoColor; + this._lassoShader.dashWidth = this.lassoDashWidth ? this.lassoDashWidth : this._core.config.lassoDashWidth; + this._lassoShader.apply(); + const lassoThickness = this.lassoThickness ? this.lassoThickness : this._core.config.lassoThickness; + for(let i = 0; i < this._viewportCount; i++){ + const viewportIndex = i + this._viewportOffset; + this._shaderResources.bindFramebuffer(this._framebuffers[viewportIndex]); + const viewport = this._viewports[viewportIndex]; + this._gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); + this._lassoMMatrix[0] = lassoWidth * 2 / viewport.width; + this._lassoMMatrix[5] = lassoHeight * 2 / viewport.height; + this._lassoMMatrix[10] = 1; + this._lassoMMatrix[12] = (this.lassoX0 + lassoWidth / 2) / viewport.width * 2 - 1; + this._lassoMMatrix[13] = 1 - (this.lassoY0 + lassoHeight / 2) / viewport.height * 2; + this._lassoShader.mMatrix = this._lassoMMatrix; + (0, _glMatrix.vec2).set(this._lassoThickness, lassoThickness / lassoWidth, lassoThickness / lassoHeight); + this._lassoShader.thickness = this._lassoThickness; + this._lassoShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._lasso.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + } + }); } - setColor(index, value) { - const offset = MaterialBufferData.SIZE * index + this.COLOR_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getGlossiness(index) { - return this[MaterialBufferData.SIZE * index + this.GLOSSINESS_OFFSET]; - } - setGlossiness(index, value) { - this[MaterialBufferData.SIZE * index + this.GLOSSINESS_OFFSET] = value; - } - getDensity(index) { - return this[MaterialBufferData.SIZE * index + this.DENSITY_OFFSET]; + _renderTransitionBuffer(transitionBuffer) { + const currentBuffer = transitionBuffer.currentBuffer; + const previousBuffer = transitionBuffer.previousBuffer; + const currentPalette = transitionBuffer.currentPalette; + const previousPalette = transitionBuffer.previousPalette; + const currentAtlas = transitionBuffer.currentAtlas; + const previousAtlas = transitionBuffer.previousAtlas; + const unitType = transitionBuffer.unitType === undefined ? currentBuffer.unitType : transitionBuffer.unitType; + const id = currentBuffer.lookup[transitionBuffer.pickIdLookup[this._pickedId]]; + const hoverId = id > -1 ? (0, _vertexJs.UnitVertex).getIdHover(currentBuffer.dataView, id) : -1; + const activeId = transitionBuffer.activeId; + if (this._blockShader.isInitialized && (unitType == (0, _mainJs.UnitType).block || unitType == (0, _mainJs.UnitType).blockSdf)) { + this._blockShader.instanceBuffer = currentBuffer.vertexBuffer; + this._blockShader.previousInstanceBuffer = previousBuffer.vertexBuffer; + this._blockShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; + this._blockShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; + this._blockShader.prepare(); + this._blockShader.mMatrix = this.mMatrix; + this._blockShader.time = this.transitionTime; + this._blockShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); + this._blockShader.rangeMin = currentBuffer.from; + this._blockShader.rangeMax = currentBuffer.to; + this._blockShader.hover = hoverId; + this._blockShader.active = activeId; + this._blockShader.specularPower = this._config.specularPower; + this._blockShader.specularIntensity = this._config.specularIntensity; + this._blockShader.apply(); + this._blockShader.isPickShader = false; + this._blockShader.isShadowMap = false; + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + this._blockShader.vMatrix = this.vMatrices[viewport]; + this._blockShader.pMatrix = this.pMatrices[viewport]; + this._blockShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + if (this._config.isShadowEnabled) { + this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); + this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); + this._gl.cullFace(this._gl.FRONT); + this._blockShader.isPickShader = false; + this._blockShader.isShadowMap = true; + this._blockShader.vMatrix = this._shadowVMatrix; + this._blockShader.pMatrix = this._shadowPMatrix; + this._blockShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._gl.colorMask(true, true, true, true); + this._gl.cullFace(this._gl.BACK); + } + if (this.isPickingEnabled) { + this._blockShader.isPickShader = true; + this._blockShader.isShadowMap = false; + this._blockShader.pMatrix = this.pickPMatrix; + this._blockShader.vMatrix = this.pickVMatrix; + this._blockShader.applyView(); + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._blockShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + } else if (this._sphereShader.isInitialized && (unitType == (0, _mainJs.UnitType).sphere || unitType == (0, _mainJs.UnitType).sphereSdf)) { + this._sphereShader.instanceBuffer = currentBuffer.vertexBuffer; + this._sphereShader.previousInstanceBuffer = previousBuffer.vertexBuffer; + this._sphereShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; + this._sphereShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; + this._sphereShader.prepare(); + this._sphereShader.mMatrix = this.mMatrix; + this._sphereShader.time = this.transitionTime; + this._sphereShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); + this._sphereShader.rangeMin = currentBuffer.from; + this._sphereShader.rangeMax = currentBuffer.to; + this._sphereShader.hover = hoverId; + this._sphereShader.active = activeId; + this._sphereShader.specularPower = this._config.specularPower; + this._sphereShader.specularIntensity = this._config.specularIntensity; + this._sphereShader.apply(); + this._sphereShader.isPickShader = false; + this._sphereShader.isShadowMap = false; + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + this._sphereShader.vMatrix = this.vMatrices[viewport]; + this._sphereShader.pMatrix = this.pMatrices[viewport]; + this._sphereShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + if (this._config.isShadowEnabled) { + this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); + this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); + this._sphereShader.isPickShader = false; + this._sphereShader.isShadowMap = true; + this._sphereShader.vMatrix = this._shadowVMatrix; + this._sphereShader.pMatrix = this._shadowPMatrix; + this._sphereShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._gl.colorMask(true, true, true, true); + } + if (this.isPickingEnabled) { + this._sphereShader.isPickShader = true; + this._sphereShader.isShadowMap = false; + this._sphereShader.pMatrix = this.pickPMatrix; + this._sphereShader.vMatrix = this.pickVMatrix; + this._sphereShader.applyView(); + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sphereShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + } else if (this._cylinderShader.isInitialized && (unitType == (0, _mainJs.UnitType).cylinder || unitType == (0, _mainJs.UnitType).cylinderSdf)) { + this._cylinderShader.instanceBuffer = currentBuffer.vertexBuffer; + this._cylinderShader.previousInstanceBuffer = previousBuffer.vertexBuffer; + this._cylinderShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; + this._cylinderShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; + this._cylinderShader.prepare(); + this._cylinderShader.mMatrix = this.mMatrix; + this._cylinderShader.time = this.transitionTime; + this._cylinderShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); + this._cylinderShader.rangeMin = currentBuffer.from; + this._cylinderShader.rangeMax = currentBuffer.to; + this._cylinderShader.hover = hoverId; + this._cylinderShader.active = activeId; + this._cylinderShader.specularPower = this._config.specularPower; + this._cylinderShader.specularIntensity = this._config.specularIntensity; + this._cylinderShader.apply(); + this._cylinderShader.isPickShader = false; + this._cylinderShader.isShadowMap = false; + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + this._cylinderShader.vMatrix = this.vMatrices[viewport]; + this._cylinderShader.pMatrix = this.pMatrices[viewport]; + this._cylinderShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + if (this._config.isShadowEnabled) { + this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); + this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); + this._cylinderShader.isPickShader = false; + this._cylinderShader.isShadowMap = true; + this._cylinderShader.vMatrix = this._shadowVMatrix; + this._cylinderShader.pMatrix = this._shadowPMatrix; + this._cylinderShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._gl.colorMask(true, true, true, true); + } + if (this.isPickingEnabled) { + this._cylinderShader.isPickShader = true; + this._cylinderShader.isShadowMap = false; + this._cylinderShader.pMatrix = this.pickPMatrix; + this._cylinderShader.vMatrix = this.pickVMatrix; + this._cylinderShader.applyView(); + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._cylinderShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + } else if (this._sdfShader.isInitialized && unitType == (0, _mainJs.UnitType).sdf) { + this._sdfShader.instanceBuffer = currentBuffer.vertexBuffer; + this._sdfShader.previousInstanceBuffer = previousBuffer.vertexBuffer; + this._sdfShader.paletteTexture = currentPalette.texture || currentPalette.defaultTexture; + this._sdfShader.previousPaletteTexture = previousPalette.texture || previousPalette.defaultTexture; + this._sdfShader.sdfTexture = currentAtlas.texture || currentAtlas.defaultTexture; + this._sdfShader.previousSdfTexture = previousAtlas.texture || previousAtlas.defaultTexture; + this._sdfShader.prepare(); + this._sdfShader.mMatrix = this.mMatrix; + this._sdfShader.time = this.transitionTime; + this._sdfShader.duration = this._core.config.transitionDuration / (this._core.config.transitionDuration + this._core.config.transitionStaggering); + this._sdfShader.rangeMin = currentBuffer.from; + this._sdfShader.rangeMax = currentBuffer.to; + this._sdfShader.hover = hoverId; + this._sdfShader.active = activeId; + this._sdfShader.specularPower = this._config.specularPower; + this._sdfShader.specularIntensity = this._config.specularIntensity; + this._sdfShader.apply(); + this._sdfShader.isPickShader = false; + this._sdfShader.isShadowMap = false; + this._shaderResources.bindFramebuffer(this._geometryFrameBuffer); + for(let i = 0; i < this._viewportCount; i++){ + const viewport = i + this._viewportOffset; + this._gl.viewport(this._viewports[viewport].x, this._viewports[viewport].y, this._viewports[viewport].width, this._viewports[viewport].height); + this._sdfShader.vMatrix = this.vMatrices[viewport]; + this._sdfShader.pMatrix = this.pMatrices[viewport]; + this._sdfShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + if (this._config.isShadowEnabled) { + this._shaderResources.bindFramebuffer(this._shadowFrameBuffer); + this._gl.viewport(0, 0, this._config.shadowWidth, this._config.shadowHeight); + this._gl.cullFace(this._gl.FRONT); + this._sdfShader.isPickShader = false; + this._sdfShader.isShadowMap = true; + this._sdfShader.vMatrix = this._shadowVMatrix; + this._sdfShader.pMatrix = this._shadowPMatrix; + this._sdfShader.applyView(); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + this._gl.colorMask(true, true, true, true); + this._gl.cullFace(this._gl.BACK); + } + if (this.isPickingEnabled) { + this._sdfShader.isPickShader = true; + this._sdfShader.isShadowMap = false; + this._sdfShader.pMatrix = this.pickPMatrix; + this._sdfShader.vMatrix = this.pickVMatrix; + this._sdfShader.applyView(); + this._shaderResources.bindFramebuffer(this._pickFrameBuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElementsInstanced(this._gl.TRIANGLE_STRIP, this._sdfShader.indexCount, this._gl.UNSIGNED_SHORT, 0, transitionBuffer.length); + } + } } - setDensity(index, value) { - this[MaterialBufferData.SIZE * index + this.DENSITY_OFFSET] = value; + _postProcess(vMatrix, inverseVMatrix, pMatrix, viewport) { + if (this._deferredShader.isInitialized) { + this._gl.disable(this._gl.DEPTH_TEST); + let ssaoTexture; + if (this._config.isSsaoEnabled && this._ssaoShader.isInitialized) { + this._gl.viewport(0, 0, this._config.ssaoWidth, this._config.ssaoHeight); + ssaoTexture = this._ssaoTexture1; + this._shaderResources.bindFramebuffer(this._ssaoFrameBuffer1); + this._ssaoShader.vertexBuffer = this._quad.vertexBuffer; + this._ssaoShader.indexBuffer = this._quad.indexBuffer; + this._ssaoShader.texture2D1 = this._positionTexture; + this._ssaoShader.texture2D2 = this._normalTexture; + this._ssaoShader.texture2D3 = this._ssaoNoiseTexture; + this._ssaoShader.prepare(); + this._ssaoShader.pMatrix = pMatrix; + this._ssaoShader.ssaoNoiseSize = this._config.ssaoNoiseSize; + this._ssaoShader.ssaoRadius = this._config.ssaoRadius; + this._ssaoShader.ssaoPower = this._config.ssaoPower; + this._ssaoShader.ssaoKernel = this._ssaoSampleKernel; + this._ssaoShader.left = 0; + this._ssaoShader.top = 0; + this._ssaoShader.width = this._config.ssaoWidth; + this._ssaoShader.height = this._config.ssaoHeight; + this._ssaoShader.apply(); + this._ssaoShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + if (this._config.ssaoBlurEnabled && this._boxShader.isInitialized) { + ssaoTexture = this._ssaoTexture2; + this._shaderResources.bindFramebuffer(this._ssaoFrameBuffer2); + this._boxShader.vertexBuffer = this._quad.vertexBuffer; + this._boxShader.indexBuffer = this._quad.indexBuffer; + this._boxShader.texture2D = this._ssaoTexture1; + this._boxShader.prepare(); + this._boxShader.left = 0; + this._boxShader.top = 0; + this._boxShader.width = this._config.ssaoWidth; + this._boxShader.height = this._config.ssaoHeight; + this._boxShader.apply(); + this._boxShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + } + this._gl.viewport(viewport.left, viewport.top, viewport.width, viewport.height); + let postProcessFrameBuffer = this._postProcessFrameBuffer1; + this._shaderResources.bindFramebuffer(postProcessFrameBuffer); + this._deferredShader.vertexBuffer = this._quad.vertexBuffer; + this._deferredShader.indexBuffer = this._quad.indexBuffer; + this._deferredShader.texture2D1 = this._positionTexture; + this._deferredShader.texture2D2 = this._colorTexture; + this._deferredShader.texture2D3 = this._normalTexture; + this._deferredShader.texture2D4 = this._config.isSsaoEnabled ? ssaoTexture : null; + this._deferredShader.texture2D5 = this._shadowDepthTexture; + this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE); + this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE); + this._deferredShader.prepare(); + this._deferredShader.isShadowEnabled = this._config.isShadowEnabled; + this._deferredShader.isSsaoEnabled = this._config.isSsaoEnabled; + this._deferredShader.inverseVMatrix = inverseVMatrix; + this._deferredShader.shadowVMatrix = this._shadowVMatrix; + this._deferredShader.shadowPMatrix = this._shadowPMatrix; + this._deferredShader.vMatrix = vMatrix; + this._deferredShader.keyLightIntensity = this._config.keyLightIntensity; + this._deferredShader.fillLight1Intensity = this._config.fillLight1Intensity; + this._deferredShader.fillLight2Intensity = this._config.fillLight2Intensity; + this._core.camera.getPosition(this._cameraPosition); + (0, _glMatrix.mat3).fromMat4(this._cameraRotation, vMatrix); + (0, _glMatrix.vec3).set(this._position, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + (0, _glMatrix.vec3).normalize(this._deferredShader.directionToKeyLight, this._config.keyLightPosition); + (0, _glMatrix.vec3).subtract(this._direction, this._cameraPosition, this._position); + (0, _glMatrix.vec3).normalize(this._direction, this._direction); + (0, _glMatrix.vec3).add(this._deferredShader.keyLightHalfAngle, this._direction, this._deferredShader.directionToKeyLight); + (0, _glMatrix.vec3).normalize(this._deferredShader.keyLightHalfAngle, this._deferredShader.keyLightHalfAngle); + (0, _glMatrix.vec3).copy(this._deferredShader.directionToFillLight1, this._config.fillLight1Position); + (0, _glMatrix.vec3).copy(this._deferredShader.directionToFillLight2, this._config.fillLight2Position); + this._deferredShader.left = viewport.left; + this._deferredShader.top = viewport.top; + this._deferredShader.width = viewport.width; + this._deferredShader.height = viewport.height; + this._deferredShader.shadowMapWidth = this._config.shadowWidth; + this._deferredShader.shadowMapHeight = this._config.shadowHeight; + this._deferredShader.ambientIntensity = this._config.ambientIntensity; + this._deferredShader.materialIntensity = this._config.materialIntensity; + this._deferredShader.specularPower = this._config.specularPower; + this._deferredShader.specularIntensity = this._config.specularIntensity; + this._deferredShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + const widthHalf = Math.round(viewport.width / 2); + const heightHalf = Math.round(viewport.height / 2); + const widthQuarter = Math.round(widthHalf / 2); + const heightQuarter = Math.round(heightHalf / 2); + const widthEighth = Math.round(widthQuarter / 2); + const heightEighth = Math.round(heightQuarter / 2); + const widthSixteenth = Math.round(widthEighth / 2); + const heightSixteenth = Math.round(heightEighth / 2); + if (this._config.isDofEnabled && this._dofBlurShader.isInitialized && this._dofCombineShader.isInitialized) { + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessDofFrameBuffer); + this._dofBlurShader.vertexBuffer = this._quad.vertexBuffer; + this._dofBlurShader.indexBuffer = this._quad.indexBuffer; + this._dofBlurShader.texture2D1 = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture2 : this._postProcessTexture1; + this._dofBlurShader.texture2D2 = this._positionTexture; + this._dofBlurShader.prepare(); + this._dofBlurShader.focusDepth = this._config.dofFocusDistance; + this._dofBlurShader.nearFocusDepth = this._config.dofFocusDistance - this._config.dofFocusRange / 2; + this._dofBlurShader.farFocusDepth = this._config.dofFocusDistance + this._config.dofFocusRange / 2; + this._dofBlurShader.maxBackgroundBlur = this._config.dofMaxBackgroundBlur; + this._dofBlurShader.left = viewport.left; + this._dofBlurShader.top = viewport.top; + this._dofBlurShader.width = viewport.width; + this._dofBlurShader.height = viewport.height; + this._dofBlurShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + postProcessFrameBuffer = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessFrameBuffer2 : this._postProcessFrameBuffer1; + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, postProcessFrameBuffer); + this._dofCombineShader.vertexBuffer = this._quad.vertexBuffer; + this._dofCombineShader.indexBuffer = this._quad.indexBuffer; + this._dofCombineShader.texture2D1 = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture2 : this._postProcessTexture1; + this._dofCombineShader.texture2D2 = this._postProcessDofTexture; + this._dofCombineShader.prepare(); + this._dofCombineShader.focusDepth = this._config.dofFocusDistance; + this._dofCombineShader.left = viewport.left; + this._dofCombineShader.top = viewport.top; + this._dofCombineShader.width = viewport.width; + this._dofCombineShader.height = viewport.height; + this._dofCombineShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + if (this._config.isBloomEnabled && this._brightPassShader.isInitialized && this._gaussianShader.isInitialized) { + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer1); + this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; + this._brightPassShader.indexBuffer = this._quad.indexBuffer; + this._brightPassShader.texture2D = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture1 : this._postProcessTexture2; + this._brightPassShader.prepare(); + this._brightPassShader.width = widthHalf; + this._brightPassShader.height = heightHalf; + this._brightPassShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer1); + this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; + this._brightPassShader.indexBuffer = this._quad.indexBuffer; + this._brightPassShader.texture2D = this._postProcessHalfTexture1; + this._brightPassShader.prepare(); + this._brightPassShader.width = widthQuarter; + this._brightPassShader.height = heightQuarter; + this._brightPassShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer1); + this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; + this._brightPassShader.indexBuffer = this._quad.indexBuffer; + this._brightPassShader.texture2D = this._postProcessQuarterTexture1; + this._brightPassShader.prepare(); + this._brightPassShader.width = widthEighth; + this._brightPassShader.height = heightEighth; + this._brightPassShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer1); + this._brightPassShader.vertexBuffer = this._quad.vertexBuffer; + this._brightPassShader.indexBuffer = this._quad.indexBuffer; + this._brightPassShader.texture2D = this._postProcessEighthTexture1; + this._brightPassShader.prepare(); + this._brightPassShader.width = widthSixteenth; + this._brightPassShader.height = heightSixteenth; + this._brightPassShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer2); + this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; + this._gaussianShader.indexBuffer = this._quad.indexBuffer; + this._gaussianShader.texture2D = this._postProcessHalfTexture1; + this._gaussianShader.prepare(); + this._gaussianShader.width = widthHalf; + this._gaussianShader.height = heightHalf; + this._gaussianShader.horizontal = true; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessHalfFrameBuffer1); + this._gaussianShader.texture2D = this._postProcessHalfTexture2; + this._gaussianShader.prepare(); + this._gaussianShader.horizontal = false; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer2); + this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; + this._gaussianShader.indexBuffer = this._quad.indexBuffer; + this._gaussianShader.texture2D = this._postProcessQuarterTexture1; + this._gaussianShader.prepare(); + this._gaussianShader.width = widthQuarter; + this._gaussianShader.height = heightQuarter; + this._gaussianShader.horizontal = true; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessQuarterFrameBuffer1); + this._gaussianShader.texture2D = this._postProcessQuarterTexture2; + this._gaussianShader.prepare(); + this._gaussianShader.horizontal = false; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer2); + this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; + this._gaussianShader.indexBuffer = this._quad.indexBuffer; + this._gaussianShader.texture2D = this._postProcessEighthTexture1; + this._gaussianShader.prepare(); + this._gaussianShader.width = widthEighth; + this._gaussianShader.height = heightEighth; + this._gaussianShader.horizontal = true; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessEighthFrameBuffer1); + this._gaussianShader.texture2D = this._postProcessEighthTexture2; + this._gaussianShader.prepare(); + this._gaussianShader.horizontal = false; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer2); + this._gaussianShader.vertexBuffer = this._quad.vertexBuffer; + this._gaussianShader.indexBuffer = this._quad.indexBuffer; + this._gaussianShader.texture2D = this._postProcessSixteenthTexture1; + this._gaussianShader.prepare(); + this._gaussianShader.width = widthSixteenth; + this._gaussianShader.height = heightSixteenth; + this._gaussianShader.horizontal = true; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, this._postProcessSixteenthFrameBuffer1); + this._gaussianShader.texture2D = this._postProcessSixteenthTexture2; + this._gaussianShader.prepare(); + this._gaussianShader.horizontal = false; + this._gaussianShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + if (this._config.isFxaaEnabled && this._fxaaShader.isInitialized) { + postProcessFrameBuffer = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessFrameBuffer2 : this._postProcessFrameBuffer1; + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, postProcessFrameBuffer); + this._fxaaShader.vertexBuffer = this._quad.vertexBuffer; + this._fxaaShader.indexBuffer = this._quad.indexBuffer; + this._fxaaShader.texture2D = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture2 : this._postProcessTexture1; + this._fxaaShader.prepare(); + this._fxaaShader.left = viewport.left; + this._fxaaShader.top = viewport.top; + this._fxaaShader.width = viewport.width; + this._fxaaShader.height = viewport.height; + this._fxaaShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } + this._shaderResources.bindFramebuffer(null); + this._gl.clear(this._gl.COLOR_BUFFER_BIT | this._gl.DEPTH_BUFFER_BIT); + this._gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height); + this._combineShader.vertexBuffer = this._quad.vertexBuffer; + this._combineShader.indexBuffer = this._quad.indexBuffer; + this._combineShader.texture2D1 = postProcessFrameBuffer == this._postProcessFrameBuffer1 ? this._postProcessTexture1 : this._postProcessTexture2; + if (this._config.isBloomEnabled) { + this._combineShader.texture2D2 = this._postProcessHalfTexture1; + this._combineShader.texture2D3 = this._postProcessQuarterTexture1; + this._combineShader.texture2D4 = this._postProcessEighthTexture1; + this._combineShader.texture2D5 = this._postProcessSixteenthTexture1; + } else { + this._combineShader.texture2D2 = null; + this._combineShader.texture2D3 = null; + this._combineShader.texture2D4 = null; + this._combineShader.texture2D5 = null; + } + this._combineShader.prepare(); + this._combineShader.viewport = viewport; + this._combineShader.intensity = this._config.bloomIntensity; + this._combineShader.apply(); + this._gl.drawElements(this._gl.TRIANGLES, this._quad.indexCount, this._gl.UNSIGNED_SHORT, 0); + } } } -MaterialBufferData.SIZE = 12; -class Material { - get texture() { - return this._texture; + +},{"gl-matrix":"5x28d","../../main.js":"f421K","../renderer.js":"8zmPQ","./components/quad.js":"dAFCJ","./buffer.js":"i3lUV","./config.js":"btHxw","./shaders/shader.js":"f1nVl","./shaders/texture.js":"kb7uV","./shaders/lasso.js":"3XY2K","./shaders/sdftext.js":"9eKN6","./shaders/pickgrid.js":"dPLtS","./shaders/unitblock.js":"arj7Q","./shaders/unitsphere.js":"idlJV","./shaders/unitcylinder.js":"kG3Ma","./shaders/unitsdf.js":"eIwH3","./shaders/background.js":"j1a66","./shaders/ssao.js":"8V9Nh","./shaders/box.js":"6rVqd","./shaders/deferred.js":"jNY1W","./shaders/combine.js":"7jcRQ","./shaders/dofblur.js":"aFGoZ","./shaders/downsample.js":"emlyC","./shaders/gaussian.js":"5Fqo6","./shaders/dofcombine.js":"kBlwc","./shaders/fxaa.js":"9Vj9y","./shaders/bright.js":"3saQu","../../helpers/angle.js":"53hwW","../../helpers/pick.js":"1t2sb","./components/axes/cartesian2d.js":"ewMaB","./components/axes/cartesian3d.js":"h51do","./font.js":"8IUfH","./../../helpers/math.js":"f65d0","../../constants.js":"lD0bG","../../vertex.js":"4J2YE","../../helpers/texture.js":"bUoBU","./components/labels.js":"lrIn9","./components/image.js":"492tj","./components/lasso.js":"7Nt0P","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dAFCJ":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Quad", ()=>Quad); +var _glMatrix = require("gl-matrix"); +var _quadJs = require("../../../meshes/quad.js"); +class Quad { + get isInitialized() { + return this._isInitialized; } - constructor(options){} - toBuffer(buffer, index, textureId) {} -} -class LambertianMaterial extends Material { - constructor(options){ - super(options); - this._texture = options.texture; + get vertexBuffer() { + return this._vertexBuffer; } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.lambertian); - buffer.setTextureId(index, textureId); + get indexBuffer() { + return this._indexBuffer; } -} -class MetalMaterial extends Material { - constructor(options){ - super(options); - this.fuzz = options.fuzz !== undefined ? options.fuzz : 0; - this._texture = options.texture; + get indexCount() { + return this._indexCount; } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.metal); - buffer.setFuzz(index, this.fuzz); - buffer.setTextureId(index, textureId); + initializeContext(gl) { + const _vec3 = (0, _glMatrix.vec3).fromValues(2, 2, 2); + const _mat4 = (0, _glMatrix.mat4).create(); + (0, _glMatrix.mat4).fromScaling(_mat4, _vec3); + const vertices = (0, _quadJs.Quad).positions(_mat4); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); + const indices = (0, _quadJs.Quad).INDICES; + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); + this._indexCount = indices.length; + this._isInitialized = true; } } -class DielectricMaterial extends Material { - constructor(options){ - super(options); - this.fuzz = options && options.fuzz !== undefined ? options.fuzz : 0; - this.refractiveIndex = options && options.refractiveIndex !== undefined ? options.refractiveIndex : 1.5; - this.glossiness = options && options.glossiness !== undefined ? options.glossiness : 1; - this.color = options && options.color || (0, _glMatrix.vec3).fromValues(1, 1, 1); + +},{"gl-matrix":"5x28d","../../../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"i3lUV":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Buffer", ()=>Buffer); +parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); +var _bufferJs = require("../../buffer.js"); +var _mainJs = require("../../main.js"); +var _atlasJs = require("./atlas.js"); +var _paletteJs = require("./palette.js"); +class Buffer extends (0, _bufferJs.BufferBase) { + get vertexBuffer() { + return this._vertexBuffer; } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.dielectric); - buffer.setRefractiveIndex(index, this.refractiveIndex); - buffer.setFuzz(index, this.fuzz); - buffer.setGlossiness(index, this.glossiness); - buffer.setColor(index, this.color); + constructor(core, ids){ + super(core, ids); } -} -class DiffuseLightMaterial extends Material { - constructor(options){ - super(options); - this.color = options && options.color || (0, _glMatrix.vec3).fromValues(1, 1, 1); + initializeContext(gl) { + this._gl = gl; + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._vertices, gl.STATIC_DRAW); + this._isInitialized = true; } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.diffuseLight); - buffer.setColor(index, this.color); + update() { + if (this._isInitialized) { + const start = window.performance.now(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._vertices); + this._core.log.write((0, _mainJs.LogLevel).info, `buffer updated ${this._length} ${Math.round(window.performance.now() - start)}ms`); + } } } -class GlossyMaterial extends Material { - constructor(options){ - super(options); - this._texture = options.texture; - this.fuzz = options.fuzz !== undefined ? options.fuzz : 0; - this.refractiveIndex = options.refractiveIndex !== undefined ? options.refractiveIndex : 1.5; - this.glossiness = options.glossiness !== undefined ? options.glossiness : 1; +class TransitionBuffer extends (0, _bufferJs.TransitionBufferBase) { + constructor(core, ids){ + super(core, ids, Buffer, (0, _paletteJs.Palette), (0, _atlasJs.Atlas)); } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.glossy); - buffer.setFuzz(index, this.fuzz); - buffer.setGlossiness(index, this.glossiness); - buffer.setRefractiveIndex(index, this.refractiveIndex); - buffer.setTextureId(index, textureId); + initializeContext(gl) { + this._buffer1.initializeContext(gl); + this._buffer2.initializeContext(gl); + this._palette1.initializeContext(this._core, gl); + this._palette2.initializeContext(this._core, gl); + this._atlas1.initializeContext(this._core, gl); + this._atlas2.initializeContext(this._core, gl); + this._isInitialized = true; } } -class IsotropicMaterial extends Material { - constructor(options){ - super(options); - this.density = options.density; - this.color = options.color; + +},{"../../buffer.js":"itbJk","../../main.js":"f421K","./atlas.js":"3SMAz","./palette.js":"cjVUn","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3SMAz":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Atlas", ()=>Atlas); +var _textureJs = require("../../helpers/texture.js"); +var _atlasJs = require("../../atlas.js"); +class Atlas extends (0, _atlasJs.AtlasBase) { + get texture() { + return this._texture; } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.isotropic); - buffer.setDensity(index, this.density); - buffer.setColor(index, this.color); + get defaultTexture() { + return this._defaultTexture; } -} -class VarnishMaterial extends Material { - constructor(options){ - super(options); - this.fuzz = options && options.fuzz !== undefined ? options.fuzz : 0; - this.refractiveIndex = options && options.refractiveIndex !== undefined ? options.refractiveIndex : 1.5; - this.glossiness = options && options.glossiness !== undefined ? options.glossiness : 1; + initializeContext(core, gl) { + this._gl = gl; + this._defaultTexture = (0, _textureJs.TextureHelper).create(gl, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, gl.NEAREST, new Uint8Array([ + 0xff, + 0xff, + 0xff, + 0xff + ])); + this._updateTexture(); } - toBuffer(buffer, index, textureId) { - buffer.setType(index, MaterialType.varnish); - buffer.setFuzz(index, this.fuzz); - buffer.setGlossiness(index, this.glossiness); - buffer.setRefractiveIndex(index, this.refractiveIndex); + update() { + super.update(); + if (this._changed) { + this._changed = false; + this._updateTexture(); + } + } + _updateTexture() { + if (this._imageData) this._texture = (0, _textureJs.TextureHelper).fromImage(this._gl, this._imageData, false, this._gl.LINEAR); + else this._texture = null; } } -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3ZvZF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "TextureType", ()=>TextureType); -parcelHelpers.export(exports, "TextureBufferData", ()=>TextureBufferData); -parcelHelpers.export(exports, "Texture", ()=>Texture); -parcelHelpers.export(exports, "SolidColorTexture", ()=>SolidColorTexture); -parcelHelpers.export(exports, "ImageTexture", ()=>ImageTexture); -parcelHelpers.export(exports, "CheckerTexture", ()=>CheckerTexture); -parcelHelpers.export(exports, "GridTexture", ()=>GridTexture); +},{"../../helpers/texture.js":"bUoBU","../../atlas.js":"2peXi","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cjVUn":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../../constants.js"); -const TextureType = { - none: 0, - solidColor: 1, - image: 2, - sdfText: 3, - checker: 4, - grid: 5 -}; -class TextureBufferData extends Float32Array { - constructor(count){ - super(count * TextureBufferData.SIZE); - this.COLOR0_OFFSET = 0; - this.TYPE_OFFSET = 3; - this.COLOR1_OFFSET = 4; - this.SIZE0_OFFSET = 8; - this.SIZE1_OFFSET = 12; - this.CLIP_OFFSET = 16; - this.OFFSET_OFFSET = 20; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Palette", ()=>Palette); +var _textureJs = require("../../helpers/texture.js"); +var _paletteJs = require("../../palette.js"); +class Palette extends (0, _paletteJs.PaletteBase) { + get texture() { + return this._texture; } - getType(index) { - return this[TextureBufferData.SIZE * index + this.TYPE_OFFSET]; + get defaultTexture() { + return this._defaultTexture; } - setType(index, value) { - this[TextureBufferData.SIZE * index + this.TYPE_OFFSET] = value; + initializeContext(core, gl) { + this._gl = gl; + this._defaultTexture = (0, _textureJs.TextureHelper).create(gl, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, gl.NEAREST, core.config.paletteColor); + this._updateTexture(); } - getColor0(index, value) { - const offset = TextureBufferData.SIZE * index + this.COLOR0_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + update() { + super.update(); + if (this._changed) { + this._changed = false; + this._updateTexture(); + } } - setColor0(index, value) { - const offset = TextureBufferData.SIZE * index + this.COLOR0_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; + _updateTexture() { + if (this._colors) { + const colors = new Uint8Array(this._colors); + for(let i = 0; i < colors.length; i++)colors[i] = Math.pow(colors[i] / 0xff, 2.2) * 0xff; + this._texture = (0, _textureJs.TextureHelper).create(this._gl, this._colors.length / 4, 1, this._gl.RGBA, this._gl.UNSIGNED_BYTE, this._gl.NEAREST, colors); + } else this._texture = null; } - getColor1(index, value) { - const offset = TextureBufferData.SIZE * index + this.COLOR1_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); +} + +},{"../../helpers/texture.js":"bUoBU","../../palette.js":"hZb65","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"btHxw":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Config", ()=>Config); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../../constants.js"); +var _angleJs = require("../../helpers/angle.js"); +var _rendererJs = require("../renderer.js"); +class Config extends (0, _rendererJs.RendererConfig) { + get keyLightAltitude() { + return this._keyLightAltitude; } - setColor1(index, value) { - const offset = TextureBufferData.SIZE * index + this.COLOR1_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; + set keyLightAltitude(value) { + this._keyLightAltitude = value; + this._updateLights(); } - getSize0(index, value) { - const offset = TextureBufferData.SIZE * index + this.SIZE0_OFFSET; - (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + get keyLightAzimuth() { + return this._keyLightAzimuth; } - setSize0(index, value) { - const offset = TextureBufferData.SIZE * index + this.SIZE0_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - this[offset + 3] = value[3]; + set keyLightAzimuth(value) { + this._keyLightAzimuth = value; + this._updateLights(); } - getSize1(index, value) { - const offset = TextureBufferData.SIZE * index + this.SIZE1_OFFSET; - (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + get keyLightDistance() { + return this._keyLightDistance; } - setSize1(index, value) { - const offset = TextureBufferData.SIZE * index + this.SIZE1_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - this[offset + 3] = value[3]; + set keyLightDistance(value) { + this._keyLightDistance = value; + this._updateLights(); } - getClip(index, value) { - const offset = TextureBufferData.SIZE * index + this.CLIP_OFFSET; - (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + get fillLight1Altitude() { + return this._fillLight1Altitude; } - setClip(index, value) { - const offset = TextureBufferData.SIZE * index + this.CLIP_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - this[offset + 3] = value[3]; + set fillLight1Altitude(value) { + this._fillLight1Altitude = value; + this._updateLights(); } - getOffset(index, value) { - const offset = TextureBufferData.SIZE * index + this.OFFSET_OFFSET; - (0, _glMatrix.vec2).set(value, this[offset], this[offset + 1]); + get fillLight1Azimuth() { + return this._fillLight1Azimuth; } - setOffset(index, value) { - const offset = TextureBufferData.SIZE * index + this.OFFSET_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; + set fillLight1Azimuth(value) { + this._fillLight1Azimuth = value; + this._updateLights(); } -} -TextureBufferData.SIZE = 24; -class Texture { -} -class SolidColorTexture extends Texture { - constructor(options){ - super(); - this.color = options.color; - this._color = (0, _glMatrix.vec3).fromValues(Math.pow(this.color[0], 2.2), Math.pow(this.color[1], 2.2), Math.pow(this.color[2], 2.2)); + get fillLight2Altitude() { + return this._fillLight2Altitude; } - toBuffer(buffer, index) { - buffer.setType(index, TextureType.solidColor); - buffer.setColor0(index, this._color); + set fillLight2Altitude(value) { + this._fillLight2Altitude = value; + this._updateLights(); } -} -class ImageTexture extends Texture { - constructor(options){ - super(); - this.image = options.image; + get fillLight2Azimuth() { + return this._fillLight2Azimuth; } - toBuffer(buffer, index) { - buffer.setType(index, TextureType.image); + set fillLight2Azimuth(value) { + this._fillLight2Azimuth = value; + this._updateLights(); } -} -class CheckerTexture extends Texture { - constructor(options){ + constructor(){ super(); - this.color0 = options.color0; - this.color1 = options.color1; - this.size = options.size; - this.offset = options.offset || (0, _constantsJs.Constants).VECTOR2_ZERO; - this._color0 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color0[0], 2.2), Math.pow(this.color0[1], 2.2), Math.pow(this.color0[2], 2.2)); - this._color1 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color1[0], 2.2), Math.pow(this.color1[1], 2.2), Math.pow(this.color1[2], 2.2)); + this._rotation = (0, _glMatrix.quat).create(); + this.keyLightPosition = (0, _glMatrix.vec3).create(); + this.fillLight1Position = (0, _glMatrix.vec3).create(); + this.fillLight2Position = (0, _glMatrix.vec3).create(); + this.reset(); } - toBuffer(buffer, index) { - buffer.setType(index, TextureType.checker); - buffer.setColor0(index, this._color0); - buffer.setColor1(index, this._color1); - buffer.setSize0(index, (0, _glMatrix.vec4).fromValues(this.size[0], this.size[1], 0, 0)); - buffer.setOffset(index, this.offset); + _updateLights() { + this._updateLight(this._keyLightAltitude, this._keyLightAzimuth, this._keyLightDistance, this.keyLightPosition); + this._updateLight(this._fillLight1Altitude, this._fillLight1Azimuth, 1, this.fillLight1Position); + this._updateLight(this._fillLight2Altitude, this._fillLight2Azimuth, 1, this.fillLight2Position); } -} -class GridTexture extends Texture { - constructor(options){ - super(); - this.color0 = options.color0; - this.color1 = options.color1; - this.size = options.size; - this.minorSize = options.minorSize; - this.thickness = options.thickness; - this.minorThickness = options.minorThickness; - this.offset = options.offset || (0, _constantsJs.Constants).VECTOR2_ZERO; - this.clip = options.clip || (0, _glMatrix.vec4).fromValues(0, 0, 1, 1); - this._color0 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color0[0], 2.2), Math.pow(this.color0[1], 2.2), Math.pow(this.color0[2], 2.2)); - this._color1 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color1[0], 2.2), Math.pow(this.color1[1], 2.2), Math.pow(this.color1[2], 2.2)); + _updateLight(altitude, azimuth, distance, position) { + (0, _glMatrix.quat).rotateY(this._rotation, (0, _constantsJs.Constants).QUAT_IDENTITY, (0, _angleJs.AngleHelper).degreesToRadians(azimuth)); + (0, _glMatrix.quat).rotateX(this._rotation, this._rotation, (0, _angleJs.AngleHelper).degreesToRadians(-altitude)); + (0, _glMatrix.vec3).transformQuat(position, (0, _constantsJs.Constants).VECTOR3_UNITZ, this._rotation); + (0, _glMatrix.vec3).scale(position, position, distance); } - toBuffer(buffer, index) { - buffer.setType(index, TextureType.grid); - buffer.setColor0(index, this._color0); - buffer.setColor1(index, this._color1); - buffer.setSize0(index, (0, _glMatrix.vec4).fromValues(this.size[0], this.size[1], this.minorSize[0], this.minorSize[1])); - buffer.setSize1(index, (0, _glMatrix.vec4).fromValues(this.thickness[0], this.thickness[1], this.minorThickness[0], this.minorThickness[1])); - buffer.setOffset(index, this.offset); - buffer.setClip(index, this.clip); + reset() { + this.isSsaoEnabled = true; + this.ssaoWidth = 1024; + this.ssaoHeight = 1024; + this.ssaoBlurEnabled = true; + this.ssaoKernelSize = 8; + this.ssaoNoiseSize = 4; + this.ssaoRadius = 0.02; + this.ssaoPower = 1; + this.isShadowEnabled = true; + this.shadowWidth = 1024; + this.shadowHeight = 1024; + this.isDofEnabled = false; + this.dofAutoFocus = true; + this.dofFocusDistance = 0.5; + this.dofFocusRange = 0.5; + this.dofMaxBackgroundBlur = 0.75; + this.isBloomEnabled = false; + this.bloomIntensity = 2; + this.specularIntensity = 0.15; + this.specularPower = 150; + this.ambientIntensity = 0.1; + this.materialIntensity = 0.5; + this.keyLightIntensity = 1.5; + this.fillLight1Intensity = 0.25; + this.fillLight2Intensity = 0.25; + this._keyLightAltitude = 30; + this._keyLightAzimuth = -45; + this._keyLightDistance = 1; + this._fillLight1Altitude = 30; + this._fillLight1Azimuth = 45; + this._fillLight2Altitude = 30; + this._fillLight2Azimuth = -135; + this._updateLights(); + this.isFxaaEnabled = false; } } -},{"gl-matrix":"9GjEQ","../../constants.js":"2Scl5","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5bOsK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "HittableType", ()=>HittableType); -parcelHelpers.export(exports, "HittableBufferData", ()=>HittableBufferData); -parcelHelpers.export(exports, "Hittable", ()=>Hittable); -parcelHelpers.export(exports, "HittableSphere", ()=>HittableSphere); -parcelHelpers.export(exports, "HittableBox", ()=>HittableBox); -parcelHelpers.export(exports, "HittableBoxSdf", ()=>HittableBoxSdf); -parcelHelpers.export(exports, "HittableRotatedBox", ()=>HittableRotatedBox); -parcelHelpers.export(exports, "HittableCylinder", ()=>HittableCylinder); -parcelHelpers.export(exports, "HittableCylinderSdf", ()=>HittableCylinderSdf); -parcelHelpers.export(exports, "HittableHexPrism", ()=>HittableHexPrism); -parcelHelpers.export(exports, "HittableHexPrismSdf", ()=>HittableHexPrismSdf); -parcelHelpers.export(exports, "HittableRect", ()=>HittableRect); -parcelHelpers.export(exports, "HittableXyRect", ()=>HittableXyRect); -parcelHelpers.export(exports, "HittableXzRect", ()=>HittableXzRect); -parcelHelpers.export(exports, "HittableYzRect", ()=>HittableYzRect); -parcelHelpers.export(exports, "HittableFontXyRect", ()=>HittableFontXyRect); -parcelHelpers.export(exports, "HittableSdfXyRect", ()=>HittableSdfXyRect); -parcelHelpers.export(exports, "HittableRotatedXyRect", ()=>HittableRotatedXyRect); -parcelHelpers.export(exports, "HittableRotatedFontXyRect", ()=>HittableRotatedFontXyRect); -parcelHelpers.export(exports, "HittableRotatedSdfXyRect", ()=>HittableRotatedSdfXyRect); -parcelHelpers.export(exports, "HittableConstantMedium", ()=>HittableConstantMedium); +},{"gl-matrix":"5x28d","../../constants.js":"lD0bG","../../helpers/angle.js":"53hwW","../renderer.js":"8zmPQ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"f1nVl":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../../constants.js"); -var _boundsJs = require("../../helpers/bounds.js"); -var _aabbJs = require("./aabb.js"); -const HittableType = { - sphere: 0, - box: 1, - cylinder: 2, - hexPrism: 3, - rotatedBox: 4, - xyRect: 5, - xzRect: 6, - yzRect: 7, - rotatedXyRect: 8, - fontXyRect: 9, - rotatedFontXyRect: 10, - boxSdf: 11, - cylinderSdf: 12, - hexPrismSdf: 13, - constantMedium: 14, - sdfXyRect: 15, - rotatedSdfXyRect: 16 -}; -class HittableBufferData extends Float32Array { - constructor(count){ - super(count * HittableBufferData.SIZE); - this.CENTER0_OFFSET = 0; - this.TYPE_OFFSET = 3; - this.SIZE_OFFSET = 4; - this.MATERIAL_ID_OFFSET = 7; - this.ROTATION_OFFSET = 8; - this.TEXCOORD0_OFFSET = 12; - this.TEXCOORD1_OFFSET = 14; - this.CENTER1_OFFSET = 16; - this.ROUNDING_OFFSET = 19; - this.BOUNDARY_TYPE_OFFSET = 20; - this.TIME0_OFFSET = 21; - this.TIME1_OFFSET = 22; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Resources", ()=>Resources); +parcelHelpers.export(exports, "ShaderBase", ()=>ShaderBase); +var _pathJs = require("../../../helpers/path.js"); +var _mainJs = require("../../../main.js"); +class Resources { + bindFramebuffer(framebuffer) { + if (this.framebuffer != framebuffer) { + this.framebuffer = framebuffer; + this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer); + } } - getType(index) { - return this[HittableBufferData.SIZE * index + this.TYPE_OFFSET]; + initializeContext(gl) { + this._gl = gl; + this.framebuffer = this._gl.createFramebuffer(); + this.OES_texture_float = gl.getExtension("OES_texture_float"); + this.OES_texture_float_linear = gl.getExtension("OES_texture_float_linear"); + this.WEBGL_lose_context = gl.getExtension("WEBGL_lose_context"); } - setType(index, value) { - this[HittableBufferData.SIZE * index + this.TYPE_OFFSET] = value; +} +Resources.glsl = { + "background.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform vec3 uColor;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\ngl_FragDepth = 0.99999;\nmyPosition = vec4(0.0, 0.0, -FAR_PLANE, 0.0);\nmyColor = vec4(uColor, 1.0);\nmyNormal = vec4(0.0, 0.0, 1.0, 0.0);\n}\n", + "box.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform vec4 uViewport;\nuniform sampler2D uSampler;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec2 texelSize = vec2(1.0) / uViewport.zw;\nfloat result = 0.0;\nfor (int x = -2; x < 2; x++)\n{\nfor (int y = -2; y < 2; y++)\n{\nvec2 offset = vec2(float(x) + 0.5, float(y) + 0.5) * texelSize;\nresult += texture(uSampler, texCoords + offset).r;\n}\n}\nresult /= 16.0;\nmyOutputColor = vec4(vec3(result), 1.0);\n}\n", + "bright.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform vec2 uResolution;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uResolution;\nvec4 color = texture(uSampler, texCoords);\nmyOutputColor = vec4(color.rgb * color.a, 1.0);\n}\n", + "combine.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform sampler2D uSampler3;\nuniform sampler2D uSampler4;\nuniform sampler2D uSampler5;\nuniform vec4 uViewport;\nuniform float uIntensity;\nout vec4 myOutputColor;\nvoid main() {\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec3 bloom =\ntexture(uSampler2, texCoords).rgb +\ntexture(uSampler3, texCoords).rgb +\ntexture(uSampler4, texCoords).rgb +\ntexture(uSampler5, texCoords).rgb;\nbloom *= uIntensity;\nvec3 color = texture(uSampler1, texCoords).rgb;\ncolor += bloom;\nmyOutputColor = vec4(color, 1.0);\n}\n", + "deferred.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform mat4 uInverseVMatrix;\nuniform mat4 uShadowVMatrix;\nuniform mat4 uShadowPMatrix;\nuniform bool uShadow;\nuniform bool uSsao;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform sampler2D uSampler3;\nuniform sampler2D uSampler4;\nuniform sampler2D uSampler5;\nuniform vec4 uViewport;\nuniform vec3 uKeyLightHalfAngle;\nuniform vec3 uDirectionToKeyLight;\nuniform vec3 uDirectionToFillLight1;\nuniform vec3 uDirectionToFillLight2;\nuniform vec2 uShadowMapSize;\nuniform float uKeyLightIntensity;\nuniform float uFillLight1Intensity;\nuniform float uFillLight2Intensity;\nuniform float uSpecularPower;\nuniform float uSpecularIntensity;\nuniform float uAmbientIntensity;\nuniform float uMaterialIntensity;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec4 position = texture(uSampler1, texCoords);\nvec4 color = texture(uSampler2, texCoords);\nvec4 normal = texture(uSampler3, texCoords);\nfloat shadow;\nif (uShadow)\n{\nvec4 positionWorld = uInverseVMatrix * vec4(position.xyz, 1.0);\nvec4 positionShadowView = uShadowVMatrix * positionWorld;\nvec4 positionShadowViewProjection = uShadowPMatrix * positionShadowView;\nvec3 projCoords = positionShadowViewProjection.xyz / positionShadowViewProjection.w;\nprojCoords = projCoords * 0.5 + 0.5;\nfloat minProjCoords = min(projCoords.x, projCoords.y);\nfloat maxProjCoords = max(projCoords.x, projCoords.y);\nif (minProjCoords < 0.0 || maxProjCoords > 1.0)\n{\nshadow = 1.0;\n}\nelse\n{\nfloat currentDepth = projCoords.z;\nfloat bias = 0.0;\nvec2 texelSize = 1.0 / uShadowMapSize;\nfor(int x = -1; x <= 1; ++x)\n{\nfor(int y = -1; y <= 1; ++y)\n{\nfloat pcfDepth = texture(uSampler5, projCoords.xy + vec2(x, y) * texelSize).r;\nshadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0;\n}\n}\nshadow /= 9.0;\nshadow = clamp(1.0 - shadow, 0.0, 1.0);\n}\n}\nelse\n{\nshadow = 1.0;\n}\nfloat ssao = uSsao ? texture(uSampler4, texCoords).r : 1.0;\nfloat diffuseIntensity = clamp(dot(normal.rgb, uDirectionToKeyLight), 0.0, 1.0) * uKeyLightIntensity * shadow;\ndiffuseIntensity += clamp(dot(normal.rgb, uDirectionToFillLight1), 0.0, 1.0) * uFillLight1Intensity * ssao;\ndiffuseIntensity += clamp(dot(normal.rgb, uDirectionToFillLight2), 0.0, 1.0) * uFillLight2Intensity * ssao;\nvec3 diffuse = color.rgb * diffuseIntensity * uMaterialIntensity;\nvec3 ambient = uAmbientIntensity * color.rgb * ssao;\nvec3 emissive = color.w * color.rgb;\nfloat specular = normal.w * clamp(pow(clamp(dot(normal.rgb, uKeyLightHalfAngle), 0.0, 1.0), uSpecularPower) * uSpecularIntensity * uKeyLightIntensity * shadow, 0.0, 1.0);\nvec3 result = min(ambient + diffuse + specular + emissive, 1.0);\nresult = pow(result, GAMMA);\nmyOutputColor = vec4(result, position.w);\n}\n", + "dofblur.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform vec4 uViewport;\nuniform float uFocusDepth;\nuniform float uNearFocusDepth;\nuniform float uFarFocusDepth;\nuniform float uMaxBackgroundBlur;\nout vec4 myOutputColor;\nfloat circleOfConfusion(in float depth )\n{\nfloat f;\nif (depth < uFocusDepth)\n{\nf = (depth - uFocusDepth) / (uFocusDepth - uNearFocusDepth);\nf = clamp(f, -1.0, 0.0);\n}\nelse\n{\nf = (depth - uFocusDepth) / (uFarFocusDepth - uFocusDepth);\nf = clamp(f, 0.0, uMaxBackgroundBlur);\n}\nreturn f * 0.5 + 0.5;\n}\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uViewport.zw;\nvec4 color = texture(uSampler1, texCoords);\nfloat depth = -texture(uSampler2, texCoords).z;\nfloat coc = circleOfConfusion(depth);\nmyOutputColor = vec4(coc);\n}\n", + "dofcombine.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform vec4 uViewport;\nuniform float uFocusDepth;\nuniform float uAperture;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nout vec4 myOutputColor;\nconst float MAX_CIRCLE_OF_CONFUSION = 3.0;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec2 texelSize = vec2(1.0) / uViewport.zw;\nvec2 texelSizeLow = texelSize * 4.0;\nconst int NUM_TAPS = 13;\nvec2 samples[NUM_TAPS];\nsamples[0] = vec2(-0.326212,-0.405810);\nsamples[1] = vec2(-0.840144,-0.073580);\nsamples[2] = vec2(-0.695914, 0.457137);\nsamples[3] = vec2(-0.203345, 0.620716);\nsamples[4] = vec2( 0.962340,-0.194983);\nsamples[5] = vec2( 0.473434,-0.480026);\nsamples[6] = vec2( 0.519456, 0.767022);\nsamples[7] = vec2( 0.185461,-0.893124);\nsamples[8] = vec2( 0.507431, 0.064425);\nsamples[9] = vec2( 0.896420, 0.412458);\nsamples[10] = vec2(-0.321940,-0.932615);\nsamples[11] = vec2(-0.791559,-0.597710);\nsamples[12] = vec2( 0.000000, 0.000000);\nconst float maxCoC = 5.0;\nconst float radiusScale = 0.5;\nvec4 cOut = texture(uSampler1, texCoords);\nfloat coc = texture(uSampler2, texCoords).r;\nfloat centerDepth = coc;\nfloat discRadius = abs(coc * 2.0 - 1.0) * maxCoC;\nfloat discRadiusLow = discRadius * radiusScale;\ncOut = vec4(0.0);\nfloat acc = 0.0;\nfor (int t = 0; t < NUM_TAPS; t++)\n{\nvec2 coordLow = texCoords + (texelSizeLow * samples[t] * discRadiusLow);\nvec2 coordHigh = texCoords + (texelSize * samples[t] * discRadius);\nvec4 tapLow = texture(uSampler1, coordLow);\nvec4 tapHigh = texture(uSampler1, coordHigh);\nfloat cocLow = texture(uSampler2, coordLow).r;\nfloat cocHigh = texture(uSampler2, coordHigh).r;\nfloat tapBlur = abs(cocHigh * 2.0 - 1.0);\nvec4 tap = mix(tapHigh, tapLow, tapBlur);\nfloat cocBlur = mix(cocHigh, cocLow, tapBlur);\ncocBlur = (cocBlur >= centerDepth) ? 1.0 : abs(cocBlur * 2.0 - 1.0);\ncOut += tap * cocBlur;\nacc += cocBlur;\n}\nvec4 result = cOut / acc;\nmyOutputColor = result;\n}\n", + "downsample.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform vec4 uViewport;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uViewport.zw;\nmyOutputColor = texture(uSampler, texCoords);\n}\n", + "fxaa.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nconst float FXAA_SPAN_MAX = 8.0;\nconst float FXAA_REDUCE_MUL = 1.0 / 8.0;\nconst float FXAA_REDUCE_MIN = 1.0 / 128.0;\nuniform sampler2D uSampler;\nuniform vec4 uViewport;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec2 texelSize = vec2(1.0) / uViewport.zw;\nvec3 color = texture(uSampler, texCoords).rgb;\nvec3 colorNW = texture(uSampler, vec2(texCoords.x - texelSize.x, texCoords.y - texelSize.y)).rgb;\nvec3 colorNE = texture(uSampler, vec2(texCoords.x + texelSize.x, texCoords.y - texelSize.y)).rgb;\nvec3 colorSW = texture(uSampler, vec2(texCoords.x - texelSize.x, texCoords.y + texelSize.y)).rgb;\nvec3 colorSE = texture(uSampler, vec2(texCoords.x + texelSize.x, texCoords.y + texelSize.y)).rgb;\nfloat luminance = dot(color, LUMINANCE);\nfloat luminanceNW = dot(colorNW, LUMINANCE);\nfloat luminanceNE = dot(colorNE, LUMINANCE);\nfloat luminanceSW = dot(colorSW, LUMINANCE);\nfloat luminanceSE = dot(colorSE, LUMINANCE);\nfloat luminanceMin = min(luminance, min(min(luminanceNW, luminanceNE), min(luminanceSW, luminanceSE)));\nfloat luminanceMax = max(luminance, max(max(luminanceNW, luminanceNE), max(luminanceSW, luminanceSE)));\nvec2 dir = vec2(luminanceSW + luminanceSE - luminanceNW - luminanceNE, luminanceNW + luminanceSW - luminanceNE - luminanceSE);\nfloat dirReduce = max((luminanceNW + luminanceNE + luminanceSW + luminanceSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texelSize;\nvec3 colorA = 0.5 * (\ntexture(uSampler, texCoords.xy + dir * (1.0/3.0 - 0.5)).rgb +\ntexture(uSampler, texCoords.xy + dir * (2.0/3.0 - 0.5)).rgb);\nvec3 colorB = colorA * 0.5 + 0.25 * (\ntexture(uSampler, texCoords.xy - dir * 0.5).rgb +\ntexture(uSampler, texCoords.xy + dir * 0.5).rgb);\nluminance = dot(colorB, LUMINANCE);\nif (luminance < luminanceMin || luminance > luminanceMax)\n{\nmyOutputColor = vec4(colorA, 1.0);\n}\nelse\n{\nmyOutputColor = vec4(colorB, 1.0);\n}\n}\n", + "gaussian.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform vec2 uResolution;\nuniform bool uHorizontal;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = gl_FragCoord.xy / uResolution;\nvec2 texelSize = vec2(1.0) / uResolution;\nconst int NUM_WEIGHTS = 3;\nfloat weights[NUM_WEIGHTS];\nweights[0] = 0.2270270270;\nweights[1] = 0.3162162162;\nweights[2] = 0.0702702703;\nfloat offsets[NUM_WEIGHTS];\noffsets[0] = 0.0;\noffsets[1] = 1.3846153846;\noffsets[2] = 3.2307692308;\nvec3 color = texture(uSampler, texCoords).rgb * weights[0];\nif (uHorizontal)\n{\nfor (int i = 1; i < NUM_WEIGHTS; i++) {\ncolor += texture(uSampler, texCoords + vec2(texelSize.x * offsets[i], 0.0)).rgb * weights[i];\ncolor += texture(uSampler, texCoords - vec2(texelSize.x * offsets[i], 0.0)).rgb * weights[i];\n}\n}\nelse\n{\nfor (int i = 1; i < NUM_WEIGHTS; i++) {\ncolor += texture(uSampler, texCoords + vec2(0.0, texelSize.y * offsets[i])).rgb * weights[i];\ncolor += texture(uSampler, texCoords - vec2(0.0, texelSize.y * offsets[i])).rgb * weights[i];\n}\n}\nmyOutputColor = vec4(color, 1.0);\n}\n", + "lasso.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform vec3 uColor;\nuniform vec2 uThickness;\nuniform float uDashWidth;\nin mediump vec2 vTexCoord;\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 distance = min(vTexCoord, 1.0 - vTexCoord);\nif (distance.x > uThickness.x && distance.y > uThickness.y) {\ndiscard;\n}\nvec2 texCoord = vec2(vTexCoord.x, 1.0 - vTexCoord.y);\nvec2 thickness = uThickness * uDashWidth;\nvec2 b = mod(floor(texCoord / thickness), 2.0);\nif (b.x > 0.0 && texCoord.x < 1.0 - thickness.x) {\ndiscard;\n}\nif (b.y > 0.0 && texCoord.y < 1.0 - thickness.y) {\ndiscard;\n}\nmyOutputColor = vec4(pow(uColor, GAMMA), 1.0);\n}\n", + "lasso.vertex.fx": "#version 300 es\nin vec3 aPosition;\nin mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nout mediump vec2 vTexCoord;\nvoid main(void) {\ngl_Position = uMMatrix * vec4(aPosition, 1.0);\nvTexCoord = aTexCoord;\n}\n", + "pickgrid.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform bool uPick;\nuniform vec2 uFaceSize;\nuniform vec3 uMajorColor;\nuniform vec3 uMinorColor;\nuniform vec3 uZeroColor;\nuniform float uMajorThickness;\nuniform float uMinorThickness;\nuniform float uZeroThickness;\nuniform vec2 uZero;\nuniform vec2 uMinorGridlines;\nin lowp vec4 vColor;\nin mediump vec2 vTexCoord;\nin mediump vec4 vBounds;\nin mediump vec3 vNormal;\nin vec3 vViewPosition;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void) {\nif (uPick)\n{\nmyPosition = vColor;\n}\nelse\n{\nmyPosition.xyz = vViewPosition;\nvec2 buffer = fwidth(vTexCoord);\nvec2 distance, thickness, step;\nvec4 color = vColor;\nvec2 width = vBounds.zw - vBounds.xy;\ndistance = (vTexCoord - vBounds.xy) / width;\ndistance = min(abs(distance - floor(uMinorGridlines * distance) / uMinorGridlines), abs(distance - ceil(uMinorGridlines * distance) / uMinorGridlines));\ndistance *= width;\nthickness = vec2(uMinorThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMinorColor, color.xyz, min(step.x, step.y));\nthickness = vec2(uMajorThickness) / uFaceSize;\ndistance = min(vTexCoord - vBounds.xy, vBounds.zw - vTexCoord);\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uMajorColor, color.xyz, min(step.x, step.y));\ndistance = abs(vTexCoord - uZero);\nthickness = vec2(uZeroThickness) / uFaceSize;\nstep = smoothstep(thickness, thickness + buffer, distance);\ncolor.xyz = mix(uZeroColor, color.xyz, min(step.x, step.y));\nmyColor.w = 0.0;\nmyNormal.xyz = vNormal;\nmyNormal.w = 0.0;\nmyColor.xyz = color.xyz;\n}\n}\n", + "pickgrid.vertex.fx": "#version 300 es\nin vec3 aPosition;\nin lowp vec4 aIdColor;\nin mediump vec2 aTexCoord;\nin mediump vec3 aNormal;\nin mediump vec4 aBounds;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform bool uPick;\nuniform vec4 uPickedIdColor;\nuniform vec3 uBackground;\nuniform vec3 uHighlight;\nout lowp vec4 vColor;\nout mediump vec2 vTexCoord;\nout mediump vec4 vBounds;\nout mediump vec3 vNormal;\nout vec3 vViewPosition;\nvoid main(void) {\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize(vec3(mvMatrix * vec4(aNormal, 0.0)));\nvTexCoord = aTexCoord;\nvBounds = aBounds;\nvec4 viewPosition = mvMatrix * vec4(aPosition, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nif (uPick)\n{\nvColor = aIdColor;\n}\nelse\n{\nvColor = uPickedIdColor == aIdColor ? vec4(uHighlight, 1.0) : vColor = vec4(uBackground, 1.0);\n}\n}\n", + "sdftext.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uSampler;\nuniform bool uPick;\nuniform vec3 uColor;\nuniform vec3 uHoverColor;\nuniform float uGamma;\nuniform vec3 uBorderColor;\nuniform float uBuffer;\nuniform float uBorderWidth;\nin mediump vec2 vTexCoord;\nin vec3 vViewPosition;\nin vec3 vNormal;\nin lowp vec4 vIdColor;\nin lowp float vHover;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nif (uPick) {\nmyPosition = vIdColor;\n}\nelse\n{\nfloat distance = texture(uSampler, vTexCoord).r;\nif (distance < uBuffer - uBorderWidth)\n{\ndiscard;\n}\nfloat gamma = fwidth(distance);\nfloat value = smoothstep(uBuffer - gamma, uBuffer + gamma, distance);\nmyColor.xyz = mix(uBorderColor, mix(uColor, uHoverColor, vHover), value);\nmyPosition.xyz = vViewPosition;\nmyNormal.xyz = vNormal;\nmyColor.w = 1.0;\nmyPosition.w = 0.0;\nmyNormal.w = 0.0;\n}\n}\n", + "sdftext.vertex.fx": "#version 300 es\nin lowp vec4 aIdColor;\nin vec3 aPosition;\nin mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform vec4 uPickedIdColor;\nout vec3 vViewPosition;\nout vec3 vNormal;\nout mediump vec2 vTexCoord;\nout lowp vec4 vIdColor;\nout lowp float vHover;\nvoid main(void)\n{\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = vec3(mvMatrix * vec4(0.0, 0.0, 1.0, 0.0));\nvec4 viewPosition = mvMatrix* vec4(aPosition, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvTexCoord = aTexCoord;\nvIdColor = aIdColor;\nvHover = uPickedIdColor == aIdColor ? 1.0 : 0.0;\n}\n", + "simple.vertex.fx": "#version 300 es\nin vec3 aPosition;\nvoid main(void) {\ngl_Position = vec4(aPosition, 1.0);\n}\n", + "ssao.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nconst int SSAO_KERNEL_SIZE = 8;\nuniform sampler2D uSampler1;\nuniform sampler2D uSampler2;\nuniform sampler2D uSampler3;\nuniform mat4 uPMatrix;\nuniform vec4 uViewport;\nuniform float uSsaoNoiseSize;\nuniform float uSsaoRadius;\nuniform float uSsaoPower;\nuniform vec3 uSsaoKernel[SSAO_KERNEL_SIZE];\nout vec4 myOutputColor;\nvoid main(void)\n{\nvec2 texCoords = (gl_FragCoord.xy - uViewport.xy) / uViewport.zw;\nvec3 position = texture(uSampler1, texCoords).rgb;\nvec3 normal = texture(uSampler2, texCoords).rgb;\nfloat occlusion = 0.0;\nvec2 noiseScale = uViewport.zw / uSsaoNoiseSize;\nvec3 randomVec = texture(uSampler3, texCoords * noiseScale).rgb;\nvec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));\nvec3 bitangent = cross(normal, tangent);\nmat3 tbn = mat3(tangent, bitangent, normal);\nfor(int i = 0; i < SSAO_KERNEL_SIZE; i++)\n{\nvec3 mySample = tbn * uSsaoKernel[i];\nmySample = position + mySample * uSsaoRadius;\nvec4 offset = vec4(mySample, 1.0);\noffset = uPMatrix * offset;\noffset.xy /= offset.w;\noffset.xy = offset.xy * 0.5 + 0.5;\nfloat sampleDepth = texture(uSampler1, offset.xy).z;\nfloat rangeCheck = abs(position.z - sampleDepth) > uSsaoRadius ? 0.0 : 1.0;\nocclusion += (sampleDepth < mySample.z ? 0.0 : 1.0) * rangeCheck;\n}\nocclusion /= float(SSAO_KERNEL_SIZE);\nocclusion = pow(1.0 - occlusion, uSsaoPower);\nmyOutputColor = vec4(occlusion, 0.0, 0.0, 1.0);\n}\n", + "texture.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\nuniform sampler2D uSampler;\nin mediump vec2 vTexCoord;\nin vec3 vViewPosition;\nin vec3 vNormal;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nmyPosition.xyz = vViewPosition;\nmyColor.xyz = pow(texture(uSampler, vTexCoord).xyz, INV_GAMMA);\nmyColor.w = 0.0;\nmyNormal.xyz = vNormal;\nmyNormal.w = 0.0;\n}\n", + "texture.vertex.fx": "#version 300 es\nin vec3 aPosition;\nin mediump vec3 aNormal;\nin mediump vec2 aTexCoord;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nout vec3 vViewPosition;\nout mediump vec3 vNormal;\nout mediump vec2 vTexCoord;\nvoid main(void)\n{\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvNormal = normalize((mvMatrix * vec4(aNormal, 0.0)).xyz);\nvec4 viewPosition = mvMatrix * vec4(aPosition, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvTexCoord = aTexCoord;\n}\n", + "unitblock.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\n#include \"intersect.include.fx\"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin mediump vec3 vModelPosition;\nin vec3 vViewPosition;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = vViewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nfloat distanceSquared = (0.75 - dot2(vModelPosition)) * 2.0;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\nmyNormal.xyz = normal;\nfloat specular = 1.0;\nmyNormal.w = specular;\nmyColor.xyz = color;\n}\n}\n", + "unitblock.vertex.fx": "#version 300 es\n#include \"quat.include.fx\"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin mediump vec4 aRotation;\nin mediump vec4 aPreviousRotation;\nin lowp vec2 aColor;\nin lowp vec2 aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin vec2 aOrder;\nin float aId;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout mediump vec3 vModelPosition;\nout vec3 vViewPosition;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvModelPosition = vec3(0.0);\ngl_Position = vec4(0.0);\nvViewPosition = vec3(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nvModelPosition = aPosition;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n", + "unitcylinder.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\n#include \"intersect.include.fx\"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin vec3 vViewPosition;\nin vec4 vCircle1;\nin vec4 vCircle2;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform bool uShadow;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 tnor = iCappedCone(ro, rd, vCircle1.xyz, vCircle2.xyz, vCircle1.w, vCircle2.w, uShadow ? -1.0 : 1.0);\nfloat t = tnor.x;\nif (t < 0.0)\n{\ndiscard;\n}\nvec3 viewPosition = rd * t;\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepth = ndcDepth * 0.5 + 0.5;\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = viewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = tnor.yzw;\nmyNormal.xyz = normal;\nfloat distanceSquared = dot(normal, rd);\ndistanceSquared *= distanceSquared;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nfloat specular = 1.0;\nmyNormal.w = specular;\nmyColor.xyz = color;\n}\n}\n", + "unitcylinder.vertex.fx": "#version 300 es\n#include \"common.include.fx\"\n#include \"quat.include.fx\"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin mediump vec4 aRotation;\nin mediump vec4 aPreviousRotation;\nin lowp vec2 aColor;\nin lowp vec2 aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin float aId;\nin vec2 aOrder;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nuniform vec3 uIdentityRotation;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout vec3 vViewPosition;\nout vec4 vCircle1;\nout vec4 vCircle2;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvCircle1 = vec4(0.0);\nvCircle2 = vec4(0.0);\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec3 viewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition;\nposition.xz *= max(scale.x, scale.z);\nposition.y *= scale.y;\nvec3 direction = IDENTITY_ROTATION;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\ndirection = rotate(direction, quat);\n}\nvec3 viewDirection = (mvMatrix * vec4(direction, 0.0)).xyz;\nvec3 h = viewDirection * scale.y * 0.5;\nfloat r1 = length(viewDirection) * 0.5;\nfloat r2 = r1 * scale.z;\nr1 *= scale.x;\nvCircle1 = vec4(viewCenter - h, r1);\nvCircle2 = vec4(viewCenter + h, r2);\nvec4 viewPosition = mvMatrix * vec4(position + translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\n}\n}\n", + "unitsdf.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\n#include \"intersect.include.fx\"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin mediump vec2 vTexCoord;\nin mediump vec2 vPreviousTexCoord;\nin mediump vec3 vModelPosition;\nin vec3 vViewPosition;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform sampler2D uSampler1;\nuniform sampler2D uPreviousSampler1;\nuniform bool uPick;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nfloat uBorderWidth = 0.0 / 255.0;\nfloat uBuffer = 192.0 / 255.0;\nvec3 uBorderColor = vec3(1.0, 1.0, 1.0);\nfloat distance = mix(texture(uPreviousSampler1, vPreviousTexCoord).r, texture(uSampler1, vTexCoord).r, vAnimation);\nif (distance < uBuffer - uBorderWidth) {\ndiscard;\n}\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = vViewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nfloat distanceSquared = (0.75 - dot2(vModelPosition)) * 2.0;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nvec3 normal = normalize(cross(dFdx(vViewPosition), dFdy(vViewPosition)));\nmyNormal.xyz = normal;\nfloat specular = 1.0;\nmyNormal.w = specular;\nvec3 uBorderColor = vec3(1.0, 1.0, 1.0);\nfloat uGamma = 0.0;\nfloat gamma = fwidth(distance);\nfloat value = smoothstep(uBuffer - gamma, uBuffer + gamma, distance);\nmyColor.xyz = mix(uBorderColor, color, value);\n}\n}\n", + "unitsdf.vertex.fx": "#version 300 es\n#include \"quat.include.fx\"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin mediump vec4 aRotation;\nin mediump vec4 aPreviousRotation;\nin mediump vec4 aTexCoord;\nin mediump vec4 aPreviousTexCoord;\nin lowp vec2 aColor;\nin lowp vec2 aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin vec2 aOrder;\nin float aId;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout mediump vec3 vModelPosition;\nout mediump vec2 vTexCoord;\nout mediump vec2 vPreviousTexCoord;\nout vec3 vViewPosition;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvModelPosition = vec3(0.0);\ngl_Position = vec4(0.0);\nvViewPosition = vec3(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nvModelPosition = aPosition;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nvec3 scale = mix(aPreviousScale, aScale, animation);\nvec3 position = aPosition * scale;\nif (aRotation.w * aPreviousRotation.w != 1.0)\n{\nvec4 quat = slerp(aPreviousRotation, aRotation, animation);\nposition = rotate(position, quat);\n}\nposition += mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvec4 viewPosition = mvMatrix * vec4(position, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = aPosition.y < 0.0 ? vec2(aColor.x, aPreviousColor.x) : vec2(aColor.y, aPreviousColor.y);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvPreviousTexCoord.x = aPosition.x < 0.0 ? aPreviousTexCoord.x : aPreviousTexCoord.z;\nvPreviousTexCoord.y = aPosition.y > 0.0 ? aPreviousTexCoord.y : aPreviousTexCoord.w;\nvTexCoord.x = aPosition.x < 0.0 ? aTexCoord.x : aTexCoord.z;\nvTexCoord.y = aPosition.y > 0.0 ? aTexCoord.y : aTexCoord.w;\n}\n}\n", + "unitsphere.fragment.fx": "#version 300 es\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include \"common.include.fx\"\n#include \"intersect.include.fx\"\nin lowp vec4 vIdColor;\nin lowp vec2 vVertexColor;\nin lowp float vVertexSelected;\nin float vAnimation;\nin lowp float vHover;\nin lowp float vActive;\nin vec3 vViewPosition;\nin vec3 vViewCenter;\nin mediump float vRadius;\nuniform sampler2D uSampler;\nuniform sampler2D uPreviousSampler;\nuniform bool uPick;\nuniform bool uShadow;\nlayout(location = 0) out vec4 myPosition;\nlayout(location = 1) out vec4 myColor;\nlayout(location = 2) out vec4 myNormal;\nvoid main(void)\n{\nvec3 rd = normalize(vViewPosition);\nvec3 ro = vec3(0.0);\nvec4 s = vec4(vViewCenter, vRadius);\nfloat t = sphIntersect(ro, rd, s, uShadow ? -1.0 : 1.0);\nif (t < 0.0)\n{\ndiscard;\n}\nvec3 viewPosition = rd * t;\nfloat ndcDepth = DEPTH_A + DEPTH_B / viewPosition.z;\ngl_FragDepth = ndcDepth * 0.5 + 0.5;\nif (uPick)\n{\nmyPosition = vIdColor;\n}\nelse\n{\nmyPosition.xyz = viewPosition;\nvec3 previousColor = texture(uPreviousSampler, vec2(vVertexColor.y, 0.0)).xyz;\nvec3 color = texture(uSampler, vec2(vVertexColor.x, 0.0)).xyz;\ncolor = mix(previousColor, color, vAnimation);\nvec3 normal = (viewPosition - vViewCenter) / s.w;\nmyNormal.xyz = normal;\nfloat distanceSquared = dot(normal, rd);\ndistanceSquared *= distanceSquared;\nfloat emissive = max(vVertexSelected, 0.0);\nemissive += max(vHover, vActive);\nemissive *= distanceSquared;\nmyColor.w = emissive;\nmyPosition.w = emissive;\nfloat specular = 1.0;\nmyNormal.w = specular;\nmyColor.xyz = color;\n}\n}\n", + "unitsphere.vertex.fx": "#version 300 es\n#include \"common.include.fx\"\nin mediump vec3 aPosition;\nin vec3 aTranslation;\nin vec3 aPreviousTranslation;\nin lowp float aColor;\nin lowp float aPreviousColor;\nin vec3 aScale;\nin vec3 aPreviousScale;\nin float aId;\nin vec2 aOrder;\nin lowp float aSelected;\nin lowp float aPreviousSelected;\nin lowp vec4 aIdColor;\nuniform mat4 uMMatrix;\nuniform mat4 uVMatrix;\nuniform mat4 uPMatrix;\nuniform float uTime;\nuniform float uDuration;\nuniform float uOrderFrom;\nuniform float uOrderTo;\nuniform float uHover;\nuniform float uActive;\nout lowp vec4 vIdColor;\nout lowp vec2 vVertexColor;\nout lowp float vVertexSelected;\nout highp float vAnimation;\nout lowp float vHover;\nout lowp float vActive;\nout mediump float vRadius;\nout vec3 vViewPosition;\nout vec3 vViewCenter;\nvoid main(void)\n{\nif (aOrder.x < uOrderFrom || aOrder.x > uOrderTo)\n{\nvIdColor = vec4(0.0);\nvVertexColor = vec2(0.0);\nvVertexSelected = 0.0;\nvAnimation = 0.0;\nvHover = 0.0;\nvActive = 0.0;\nvViewPosition = vec3(0.0);\nvViewCenter = vec3(0.0);\nvRadius = 0.0;\ngl_Position = vec4(0.0);\n}\nelse\n{\nvIdColor = aIdColor;\nfloat staggerOrder = aOrder.y;\nfloat startTime = staggerOrder * (1.0 - uDuration);\nfloat animation = clamp((uTime - startTime) / uDuration, 0.0, 1.0);\nanimation = smoothstep(0.0, 1.0, animation);\nfloat scale = mix(min(aPreviousScale.x, min(aPreviousScale.y, aPreviousScale.z)), min(aScale.x, min(aScale.y, aScale.z)), animation);\nvec3 translation = mix(aPreviousTranslation, aTranslation, animation);\nmat4 mvMatrix = uVMatrix * uMMatrix;\nvViewCenter = (mvMatrix * vec4(translation, 1.0)).xyz;\ntranslation.xyz += aPosition * scale;\nvec4 viewPosition = mvMatrix * vec4(translation, 1.0);\nvViewPosition = viewPosition.xyz;\ngl_Position = uPMatrix * viewPosition;\nvVertexColor = vec2(aColor, aPreviousColor);\nvVertexSelected = mix(aPreviousSelected, aSelected, animation);\nvAnimation = animation;\nvHover = uHover == aId ? 1.0 : 0.0;\nvActive = uActive == aId ? 1.0 : 0.0;\nvRadius = distance(vViewPosition, vViewCenter) / ROOT_THREE;\n}\n}\n", + "common.include.fx": "const float NEAR_PLANE = 0.01;\nconst float FAR_PLANE = 100.0;\nconst float DEPTH_A = 1.0002000200020003;\nconst float DEPTH_B = 0.020002000200020003;\nconst vec3 GAMMA = vec3(0.45454545454545453);\nconst vec3 INV_GAMMA = vec3(2.2);\nconst vec3 LUMINANCE = vec3(0.2126, 0.7152, 0.0722);\nconst float PI = 3.1415926538;\nconst float ROOT_TWO = 1.4142135624;\nconst float ROOT_TWO_OVER_TWO = 0.7071067811865476;\nconst float ROOT_THREE = 1.7320508075688772;\nconst float ROOT_THREE_OVER_TWO = 0.8660254037844386;\nconst vec3 IDENTITY_ROTATION = vec3(0.0, 1.0, 0.0);\nfloat dot2(in vec2 v) { return dot(v, v); }\nfloat dot2(in vec3 v) { return dot(v, v); }\n", + "intersect.include.fx": "float sphIntersect( in vec3 ro, in vec3 rd, in vec4 sph, in float shadow)\n{\nvec3 oc = ro - sph.xyz;\nfloat b = dot( oc, rd );\nfloat c = dot( oc, oc ) - sph.w*sph.w;\nfloat h = b*b - c;\nif( h<0.0 ) return -1.0;\nreturn -b - shadow * sqrt( h );\n}\nfloat roundedboxIntersect( in vec3 ro, in vec3 rd, in vec3 size, in float rad )\n{\nvec3 m = 1.0/rd;\nvec3 n = m*ro;\nvec3 k = abs(m)*(size+rad);\nvec3 t1 = -n - k;\nvec3 t2 = -n + k;\nfloat tN = max( max( t1.x, t1.y ), t1.z );\nfloat tF = min( min( t2.x, t2.y ), t2.z );\nif( tN > tF || tF < 0.0) return -1.0;\nfloat t = tN;\nvec3 pos = ro+t*rd;\nvec3 s = sign(pos);\nro *= s;\nrd *= s;\npos *= s;\npos -= size;\npos = max( pos.xyz, pos.yzx );\nif( min(min(pos.x,pos.y),pos.z)<0.0 ) return t;\nvec3 oc = ro - size;\nvec3 dd = rd*rd;\nvec3 oo = oc*oc;\nvec3 od = oc*rd;\nfloat ra2 = rad*rad;\nt = 1e20;\n{\nfloat b = od.x + od.y + od.z;\nfloat c = oo.x + oo.y + oo.z - ra2;\nfloat h = b*b - c;\nif( h>0.0 ) t = -b-sqrt(h);\n}\n{\nfloat a = dd.y + dd.z;\nfloat b = od.y + od.z;\nfloat c = oo.y + oo.z - ra2;\nfloat h = b*b - a*c;\nif( h>0.0 )\n{\nh = (-b-sqrt(h))/a;\nif( h>0.0 && h<t && abs(ro.x+rd.x*h)<size.x ) t = h;\n}\n}\n{\nfloat a = dd.z + dd.x;\nfloat b = od.z + od.x;\nfloat c = oo.z + oo.x - ra2;\nfloat h = b*b - a*c;\nif( h>0.0 )\n{\nh = (-b-sqrt(h))/a;\nif( h>0.0 && h<t && abs(ro.y+rd.y*h)<size.y ) t = h;\n}\n}\n{\nfloat a = dd.x + dd.y;\nfloat b = od.x + od.y;\nfloat c = oo.x + oo.y - ra2;\nfloat h = b*b - a*c;\nif( h>0.0 )\n{\nh = (-b-sqrt(h))/a;\nif( h>0.0 && h<t && abs(ro.z+rd.z*h)<size.z ) t = h;\n}\n}\nif( t>1e19 ) t=-1.0;\nreturn t;\n}\nvec3 roundedboxNormal( in vec3 pos, in vec3 siz, in float rad )\n{\nreturn sign(pos)*normalize(max(abs(pos)-siz,0.0));\n}\nvec4 iCappedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb, in float shadow)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(oa, ba);\nfloat m2 = dot(ob, ba);\nfloat m3 = dot(rd, ba);\nif (m1 < 0.0) { if (dot2(oa * m3 - rd * m1) < (ra * ra * m3 * m3)) return vec4(-m1 / m3, -ba * inversesqrt(m0)); }\nelse if (m2 > 0.0) { if (dot2(ob * m3 - rd * m2) < (rb * rb * m3 * m3)) return vec4(-m2 / m3, ba * inversesqrt(m0)); }\nfloat m4 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat rr = ra - rb;\nfloat hy = m0 + rr * rr;\nfloat k2 = m0 * m0 - m3 * m3 * hy;\nfloat k1 = m0 * m0 * m4 - m1 * m3 * hy + m0 * ra * (rr * m3 * 1.0);\nfloat k0 = m0 * m0 * m5 - m1 * m1 * hy + m0 * ra * (rr * m1 * 2.0 - m0 * ra);\nfloat h = k1 * k1 - k2 * k0;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-k1 - shadow * sqrt(h)) / k2;\nfloat y = m1 + t * m3;\nif (y > 0.0 && y < m0)\n{\nreturn vec4(t, normalize(m0 * (m0 * (oa + t * rd) + rr * ba * ra) - ba * hy * y));\n}\nreturn vec4(-1.0);\n}\nvec4 iRoundedCone(in vec3 ro, in vec3 rd,\nin vec3 pa, in vec3 pb,\nin float ra, in float rb, in float shadow)\n{\nvec3 ba = pb - pa;\nvec3 oa = ro - pa;\nvec3 ob = ro - pb;\nfloat rr = ra - rb;\nfloat m0 = dot(ba, ba);\nfloat m1 = dot(ba, oa);\nfloat m2 = dot(ba, rd);\nfloat m3 = dot(rd, oa);\nfloat m5 = dot(oa, oa);\nfloat m6 = dot(ob, rd);\nfloat m7 = dot(ob, ob);\nfloat d2 = m0 - rr * rr;\nfloat k2 = d2 - m2 * m2;\nfloat k1 = d2 * m3 - m1 * m2 + m2 * rr * ra;\nfloat k0 = d2 * m5 - m1 * m1 + m1 * rr * ra * 2.0 - m0 * ra * ra;\nfloat h = k1 * k1 - k0 * k2;\nif (h < 0.0) return vec4(-1.0);\nfloat t = (-shadow * sqrt(h) - k1) / k2;\nfloat y = m1 - ra * rr + t * m2;\nif (y > 0.0 && y < d2)\n{\nreturn vec4(t, normalize(d2 * (oa + t * rd) - ba * y));\n}\nfloat h1 = m3 * m3 - m5 + ra * ra;\nfloat h2 = m6 * m6 - m7 + rb * rb;\nif (max(h1, h2) < 0.0) return vec4(-1.0);\nvec4 r = vec4(1e20);\nif (h1 > 0.0)\n{\nt = -m3 - shadow * sqrt( h1 );\nr = vec4(t, (oa + t * rd) / ra);\n}\nif (h2 > 0.0)\n{\nt = -m6 - shadow * sqrt( h2 );\nif (t < r.x)\nr = vec4(t, (ob + t * rd) / rb);\n}\nreturn r;\n}\n", + "quat.include.fx": "const float EPSILON = 0.000001;\nmat3 fromQuat(in vec4 q) {\nfloat x = q.x;\nfloat y = q.y;\nfloat z = q.z;\nfloat w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat yx = y * x2;\nfloat yy = y * y2;\nfloat zx = z * x2;\nfloat zy = z * y2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nmat3 m;\nm[0][0] = 1.0 - yy - zz;\nm[0][1] = yx - wz;\nm[0][2] = zx + wy;\nm[1][0] = yx + wz;\nm[1][1] = 1.0 - xx - zz;\nm[1][2] = zy - wx;\nm[2][0] = zx - wy;\nm[2][1] = zy + wx;\nm[2][2] = 1.0 - xx - yy;\nreturn m;\n}\nvec3 rotate(in vec3 p, in vec4 q) {\nreturn p + 2.0 * cross(q.xyz, cross(q.xyz, p) + q.w * p);\n}\nvec4 slerp(in vec4 a, in vec4 b, in float t) {\nfloat cosom = dot(a, b);\nif (cosom < 0.0) {\ncosom = -cosom;\nb = -b;\n}\nfloat scale0, scale1;\nif (1.0 - cosom > EPSILON) {\nfloat omega = acos(cosom);\nfloat sinom = sin(omega);\nscale0 = sin((1.0 - t) * omega) / sinom;\nscale1 = sin(t * omega) / sinom;\n}\nelse {\nscale0 = 1.0 - t;\nscale1 = t;\n}\nreturn vec4(scale0 * a + scale1 * b);\n}\n" +}; +class ShaderBase { + get isInitialized() { + return this._isInitialized; } - getCenter0(index, value) { - const offset = HittableBufferData.SIZE * index + this.CENTER0_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + get vertexBuffer() { + return this._vertexBuffer; } - setCenter0(index, value) { - const offset = HittableBufferData.SIZE * index + this.CENTER0_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getCenter1(index, value) { - const offset = HittableBufferData.SIZE * index + this.CENTER1_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); - } - setCenter1(index, value) { - const offset = HittableBufferData.SIZE * index + this.CENTER1_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getTime0(index) { - return this[HittableBufferData.SIZE * index + this.TIME0_OFFSET]; + set vertexBuffer(value) { + if (this._vertexBuffer != value) { + this._vertexBuffer = value; + this._haveBuffersChanged = true; + } } - setTime0(index, value) { - this[HittableBufferData.SIZE * index + this.TIME0_OFFSET] = value; + get indexBuffer() { + return this._indexBuffer; } - getTime1(index) { - return this[HittableBufferData.SIZE * index + this.TIME1_OFFSET]; + set indexBuffer(value) { + if (this._indexBuffer != value) { + this._indexBuffer = value; + this._haveBuffersChanged = true; + } } - setTime1(index, value) { - this[HittableBufferData.SIZE * index + this.TIME1_OFFSET] = value; + constructor(core, main){ + this._core = core; + this._main = main; } - getSize(index, value) { - const offset = HittableBufferData.SIZE * index + this.SIZE_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + initializeContext(gl) { + this._gl = gl; } - setSize(index, value) { - const offset = HittableBufferData.SIZE * index + this.SIZE_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; + _createProgram(vs, fs) { + const program = this._gl.createProgram(); + this._gl.attachShader(program, vs); + this._gl.attachShader(program, fs); + this._gl.linkProgram(program); + if (!this._gl.getProgramParameter(program, this._gl.LINK_STATUS)) this._core.log.write((0, _mainJs.LogLevel).error, this._gl.getProgramInfoLog(program)); + return program; } - getMaterialId(index) { - return this[HittableBufferData.SIZE * index + this.MATERIAL_ID_OFFSET]; + _compileShader(source, type) { + const shader = this._gl.createShader(type); + this._gl.shaderSource(shader, source); + this._gl.compileShader(shader); + if (!this._gl.getShaderParameter(shader, this._gl.COMPILE_STATUS)) this._core.log.write((0, _mainJs.LogLevel).error, this._gl.getShaderInfoLog(shader)); + return shader; } - setMaterialId(index, value) { - this[HittableBufferData.SIZE * index + this.MATERIAL_ID_OFFSET] = value; + _removeDirective(shaderSource, directive) { + const remove = `#define ${directive}`; + const index = shaderSource.indexOf(remove); + shaderSource = index == -1 ? shaderSource : shaderSource.substring(0, index) + shaderSource.substring(index + remove.length); + return shaderSource; } - getRotation(index, value) { - const offset = HittableBufferData.SIZE * index + this.ROTATION_OFFSET; - (0, _glMatrix.quat).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + prepare() { + if (this._program != this._main.shaderResources.currentProgram) { + if (this._main.shaderResources.currentShader) this._main.shaderResources.currentShader.disableProgram(); + this.enableProgram(this._program); + this.updateBuffers(); + this.updateTextures(); + } else { + if (this._haveBuffersChanged) this.updateBuffers(); + if (this._haveTexturesChanged) this.updateTextures(); + } } - setRotation(index, value) { - const offset = HittableBufferData.SIZE * index + this.ROTATION_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - this[offset + 3] = value[3]; + apply() {} + applyModel() {} + applyView() {} + enableProgram(program) { + this._gl.useProgram(program); + this._main.shaderResources.currentProgram = program; + this._main.shaderResources.currentShader = this; } - getTexCoord0(index, value) { - const offset = HittableBufferData.SIZE * index + this.TEXCOORD0_OFFSET; - (0, _glMatrix.vec2).set(value, this[offset], this[offset + 1]); + updateBuffers() { + this._haveBuffersChanged = false; } - setTexCoord0(index, value) { - const offset = HittableBufferData.SIZE * index + this.TEXCOORD0_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; + updateTextures() { + this._haveTexturesChanged = false; } - getTexCoord1(index, value) { - const offset = HittableBufferData.SIZE * index + this.TEXCOORD1_OFFSET; - (0, _glMatrix.vec2).set(value, this[offset], this[offset + 1]); + disableProgram() { + this._main.shaderResources.currentShader = null; + this._main.shaderResources.currentProgram = null; } - setTexCoord1(index, value) { - const offset = HittableBufferData.SIZE * index + this.TEXCOORD1_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; + _shaderFromFile(vsName, fsName, callback) { + callback(this._includesFromFile(Resources.glsl[vsName]), this._includesFromFile(Resources.glsl[fsName])); } - getRounding(index) { - return this[HittableBufferData.SIZE * index + this.ROUNDING_OFFSET]; + _shaderFromUrl(vsName, fsName, callback) { + this._sourceFromUrl(vsName, (vsSource)=>{ + this._includesFromUrl(vsSource, 0, (vsIncSource)=>{ + this._sourceFromUrl(fsName, (fsSource)=>{ + this._includesFromUrl(fsSource, 0, (fsIncSource)=>{ + callback(vsIncSource, fsIncSource); + }); + }); + }); + }); } - setRounding(index, value) { - this[HittableBufferData.SIZE * index + this.ROUNDING_OFFSET] = value; + _sourceFromUrl(url, callback) { + const request = new XMLHttpRequest(); + request.open("GET", (0, _pathJs.PathHelper).combine(this._core.config.shaderPath, url)); + request.onreadystatechange = ()=>{ + if (request.readyState == XMLHttpRequest.DONE && request.status == 200) callback(request.responseText); + }; + request.send(); } - getBoundaryType(index) { - return this[HittableBufferData.SIZE * index + this.BOUNDARY_TYPE_OFFSET]; + _includesFromFile(source) { + let index = 0; + do { + index = source.indexOf("#include", index); + if (index != -1) { + const start = source.indexOf("\"", index); + const end = source.indexOf("\"", start + 1); + const name = source.substring(start + 1, end); + const inc = Resources.glsl[name]; + source = source.substring(0, index) + inc + source.substring(end + 1); + } + }while (index != -1); + return source; } - setBoundaryType(index, value) { - this[HittableBufferData.SIZE * index + this.BOUNDARY_TYPE_OFFSET] = value; + _includesFromUrl(source, index, callback) { + index = source.indexOf("#include", index); + if (index != -1) { + const start = source.indexOf("\"", index); + const end = source.indexOf("\"", start + 1); + const name = source.substring(start + 1, end); + this._sourceFromUrl((0, _pathJs.PathHelper).combine("inc", name), (include)=>{ + source = source.substring(0, index) + include + source.substring(end + 1); + this._includesFromUrl(source, index, callback); + }); + } else callback(source); } } -HittableBufferData.SIZE = 24; -class Hittable { - get center0() { - return this._center0; - } - get center1() { - return this._center1; + +},{"../../../helpers/path.js":"dvdia","../../../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kb7uV":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Texture", ()=>Texture); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Texture extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; } - get time0() { - return this._time0; + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; + } } - get time1() { - return this._time1; + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("texture.vertex.fx", "texture.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - get material() { - return this._material; + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); + this._normalAttribute = gl.getAttribLocation(this._program, "aNormal"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._isInitialized = true; } - set material(material) { - this._material = material; + apply() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + this._gl.uniform1i(this._samplerUniform, 0); } - get bounds() { - return this._bounds; + applyView() { + this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); } - constructor(options){ - this._center0 = options.center0; - this._center1 = options.center1; - this._time0 = options.time0; - this._time1 = options.time1; - this._material = options.material; - this._bounds = new (0, _aabbJs.AABB)(); + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).POSITION_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.vertexAttribPointer(this._normalAttribute, 3, this._gl.BYTE, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).NORMAL_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._normalAttribute); + this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionNormalTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionNormalTextureVertex).TEX_COORD_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._texCoordAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); } - toBuffer(buffer, index, materialId) { - buffer.setCenter0(index, this._center0); - buffer.setCenter1(index, this._center1); - buffer.setTime0(index, this._time0); - buffer.setTime1(index, this._time1); - buffer.setMaterialId(index, materialId); + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); } } -class HittableSphere extends Hittable { - get radius() { - return this._radius; + +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3XY2K":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Lasso", ()=>Lasso); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Lasso extends (0, _shaderJs.ShaderBase) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("lasso.vertex.fx", "lasso.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - constructor(options){ - super(options); - this._radius = options.radius; - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = Math.min(this._center0[0] - this._radius, this._center1[0] - this._radius); - max[0] = Math.max(this._center0[0] + this._radius, this._center1[0] + this._radius); - min[1] = Math.min(this._center0[1] - this._radius, this._center1[1] - this._radius); - max[1] = Math.max(this._center0[1] + this._radius, this._center1[1] + this._radius); - min[2] = Math.min(this._center0[2] - this._radius, this._center1[2] - this._radius); - max[2] = Math.max(this._center0[2] + this._radius, this._center1[2] + this._radius); + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._colorUniform = gl.getUniformLocation(this._program, "uColor"); + this._thicknessUniform = gl.getUniformLocation(this._program, "uThickness"); + this._dashWidthUniform = gl.getUniformLocation(this._program, "uDashWidth"); + this._isInitialized = true; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.sphere); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this._radius, this._radius, this._radius)); + apply() { + this._gl.uniform3fv(this._colorUniform, this.color); + this._gl.uniform1f(this._dashWidthUniform, this.dashWidth); } -} -class HittableBox extends Hittable { - constructor(options){ - super(options); - this._size = options.size; - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = Math.min(this._center0[0] - this._size[0], this._center1[0] - this._size[0]); - max[0] = Math.max(this._center0[0] + this._size[0], this._center1[0] + this._size[0]); - min[1] = Math.min(this._center0[1] - this._size[1], this._center1[1] - this._size[1]); - max[1] = Math.max(this._center0[1] + this._size[1], this._center1[1] + this._size[1]); - min[2] = Math.min(this._center0[2] - this._size[2], this._center1[2] - this._size[2]); - max[2] = Math.max(this._center0[2] + this._size[2], this._center1[2] + this._size[2]); + applyView() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + this._gl.uniform2fv(this._thicknessUniform, this.thickness); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.box); - buffer.setSize(index, this._size); + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionTextureVertex).POSITION_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionTextureVertex).SIZE_BYTES, (0, _vertexJs.PositionTextureVertex).TEX_COORD_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._texCoordAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); } } -class HittableBoxSdf extends HittableBox { - constructor(options){ - super(options); - this._rounding = options.rounding; + +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9eKN6":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "SdfText", ()=>SdfText); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class SdfText extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.boxSdf); - buffer.setRounding(index, this._rounding); + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; + } } -} -class HittableRotatedBox extends HittableBox { - constructor(options){ - super(options); - this._rotation = options.rotation; - const rotatedBounds = new (0, _aabbJs.AABB)(); - (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation, rotatedBounds.min, rotatedBounds.max); - this._bounds = rotatedBounds; + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("sdftext.vertex.fx", "sdftext.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.rotatedBox); - buffer.setRotation(index, this._rotation); + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._idColorAttribute = gl.getAttribLocation(this._program, "aIdColor"); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._colorUniform = gl.getUniformLocation(this._program, "uColor"); + this._hoverColorUniform = gl.getUniformLocation(this._program, "uHoverColor"); + this._pickUniform = gl.getUniformLocation(this._program, "uPick"); + this._pickedIdColorUniform = gl.getUniformLocation(this._program, "uPickedIdColor"); + this._borderColorUniform = gl.getUniformLocation(this._program, "uBorderColor"); + this._bufferUniform = gl.getUniformLocation(this._program, "uBuffer"); + this._borderWidthUniform = gl.getUniformLocation(this._program, "uBorderWidth"); + this._gammaUniform = gl.getUniformLocation(this._program, "uGamma"); + this._isInitialized = true; } -} -class HittableCylinder extends Hittable { - get radius() { - return this._radius; + apply() { + this._gl.uniform1i(this._samplerUniform, 0); + this._gl.uniform3fv(this._colorUniform, this.color); + this._gl.uniform3fv(this._hoverColorUniform, this.hoverColor); + this._gl.uniform3fv(this._borderColorUniform, this.borderColor); + this._gl.uniform1f(this._gammaUniform, this.gamma); + this._gl.uniform1f(this._bufferUniform, this.buffer); + this._gl.uniform1f(this._borderWidthUniform, this.borderWidth); + this._gl.uniform4fv(this._pickedIdColorUniform, this.pickedIdColor); } - get height() { - return this._height; + applyModel() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); } - constructor(options){ - super(options); - this._radius = options.radius; - this._height = options.height; - this._rotation = options.rotation || (0, _constantsJs.Constants).QUAT_IDENTITY; - if (this._rotation[3] == 1) { - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = Math.min(this._center0[0] - this._radius, this._center1[0] - this._radius); - max[0] = Math.max(this._center0[0] + this._radius, this._center1[0] + this._radius); - min[1] = Math.min(this._center0[1] - this._height, this._center1[1] - this._height); - max[1] = Math.max(this._center0[1] + this._height, this._center1[1] + this._height); - min[2] = Math.min(this._center0[2] - this._radius, this._center1[2] - this._radius); - max[2] = Math.max(this._center0[2] + this._radius, this._center1[2] + this._radius); - } else { - const ca = (0, _glMatrix.vec3).create(); - const pa = (0, _glMatrix.vec3).create(); - const pb = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).transformQuat(ca, (0, _constantsJs.Constants).VECTOR3_UNITY, this._rotation); - (0, _glMatrix.vec3).scaleAndAdd(pa, this._center0, ca, -this._height); - (0, _glMatrix.vec3).scaleAndAdd(pb, this._center0, ca, this._height); - this._bounds.fromCylinder(pa, pb, this._radius); - (0, _glMatrix.vec3).scaleAndAdd(pa, this._center1, ca, -this._height); - (0, _glMatrix.vec3).scaleAndAdd(pb, this._center1, ca, this._height); - const bounds = new (0, _aabbJs.AABB)(); - bounds.fromCylinder(pa, pb, this._radius); - const min0 = this._bounds.min; - const max0 = this._bounds.max; - const min1 = bounds.min; - const max1 = bounds.max; - min0[0] = Math.min(min0[0], min1[0]); - max0[0] = Math.max(max0[0], max1[0]); - min0[1] = Math.min(min0[1], min1[1]); - max0[1] = Math.max(max0[1], max1[1]); - min0[2] = Math.min(min0[2], min1[2]); - max0[2] = Math.max(max0[2], max1[2]); - } + applyView() { + this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); + this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.cylinder); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this._radius, this._height, this._radius)); - buffer.setRotation(index, this._rotation); + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES, (0, _vertexJs.PositionTexturePickVertex).ID_COLOR_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._idColorAttribute); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES, (0, _vertexJs.PositionTexturePickVertex).POSITION_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PositionTexturePickVertex).SIZE_BYTES, (0, _vertexJs.PositionTexturePickVertex).TEX_COORD_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._texCoordAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); } } -class HittableCylinderSdf extends HittableCylinder { - constructor(options){ - super(options); - this._rounding = options.rounding; + +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dPLtS":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PickGrid", ()=>PickGrid); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class PickGrid extends (0, _shaderJs.ShaderBase) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("pickgrid.vertex.fx", "pickgrid.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.cylinderSdf); - buffer.setRounding(index, this._rounding); + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = this._gl.getAttribLocation(this._program, "aPosition"); + this._idColorAttribute = this._gl.getAttribLocation(this._program, "aIdColor"); + this._texCoordAttribute = this._gl.getAttribLocation(this._program, "aTexCoord"); + this._normalAttribute = this._gl.getAttribLocation(this._program, "aNormal"); + this._boundsAttribute = this._gl.getAttribLocation(this._program, "aBounds"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); + this._pickUniform = gl.getUniformLocation(this._program, "uPick"); + this._majorColorUniform = gl.getUniformLocation(this._program, "uMajorColor"); + this._minorColorUniform = gl.getUniformLocation(this._program, "uMinorColor"); + this._zeroColorUniform = gl.getUniformLocation(this._program, "uZeroColor"); + this._backgroundUniform = gl.getUniformLocation(this._program, "uBackground"); + this._highlightUniform = gl.getUniformLocation(this._program, "uHighlight"); + this._pickedIdColorUniform = gl.getUniformLocation(this._program, "uPickedIdColor"); + this._faceSizeUniform = gl.getUniformLocation(this._program, "uFaceSize"); + this._majorThicknessUniform = gl.getUniformLocation(this._program, "uMajorThickness"); + this._minorThicknessUniform = gl.getUniformLocation(this._program, "uMinorThickness"); + this._zeroThicknessUniform = gl.getUniformLocation(this._program, "uZeroThickness"); + this._zeroUniform = gl.getUniformLocation(this._program, "uZero"); + this._minorGridlinesUniform = gl.getUniformLocation(this._program, "uMinorGridlines"); + this._isInitialized = true; } -} -class HittableHexPrism extends Hittable { - get radius() { - return this._radius; + apply() { + this._gl.uniform1f(this._majorThicknessUniform, this.majorThickness); + this._gl.uniform1f(this._minorThicknessUniform, this.minorThickness); + this._gl.uniform1f(this._zeroThicknessUniform, this.zeroThickness); + this._gl.uniform3fv(this._backgroundUniform, this.backgroundColor); + this._gl.uniform3fv(this._highlightUniform, this.highlightColor); + this._gl.uniform3fv(this._majorColorUniform, this.majorColor); + this._gl.uniform3fv(this._minorColorUniform, this.minorColor); + this._gl.uniform3fv(this._zeroColorUniform, this.zeroColor); + this._gl.uniform4fv(this._pickedIdColorUniform, this.pickedIdColor); } - get height() { - return this._height; + applyView() { + this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); + this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); } - constructor(options){ - super(options); - this._radius = options.radius; - this._height = options.height; - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = this._center0[0] - this._radius * (0, _constantsJs.Constants).ROOT_THREE_OVER_TWO; - max[0] = this._center0[0] + this._radius * (0, _constantsJs.Constants).ROOT_THREE_OVER_TWO; - min[1] = this._center0[1] - this._height; - max[1] = this._center0[1] + this._height; - min[2] = this._center0[2] - this._radius; - max[2] = this._center0[2] + this._radius; + ApplyFace() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + this._gl.uniform2f(this._faceSizeUniform, this.faceWidth, this.faceHeight); + this._gl.uniform2fv(this._zeroUniform, this.zero); + this._gl.uniform2fv(this._minorGridlinesUniform, this.minorGridlines); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.hexPrism); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this._radius * (0, _constantsJs.Constants).ROOT_THREE_OVER_TWO, this._height, this._radius)); + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).TRANSLATION_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.vertexAttribPointer(this._normalAttribute, 3, this._gl.BYTE, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).NORMAL_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._normalAttribute); + this._gl.vertexAttribPointer(this._texCoordAttribute, 2, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).TEX_COORD_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._texCoordAttribute); + this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).ID_COLOR_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._idColorAttribute); + this._gl.vertexAttribPointer(this._boundsAttribute, 4, this._gl.UNSIGNED_SHORT, true, (0, _vertexJs.PickGridVertex).SIZE_BYTES, (0, _vertexJs.PickGridVertex).BOUNDS_OFFSET_BYTES); + this._gl.enableVertexAttribArray(this._boundsAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); } } -class HittableHexPrismSdf extends HittableHexPrism { - constructor(options){ - super(options); - this._rounding = options.rounding; - } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.hexPrismSdf); - buffer.setRounding(index, this._rounding); + +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"arj7Q":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitBlock", ()=>UnitBlock); +var _vertexJs = require("../../../vertex.js"); +var _unitshaderJs = require("./unitshader.js"); +class UnitBlock extends (0, _unitshaderJs.UnitShader) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("unitblock.vertex.fx", "unitblock.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } -} -class HittableRect extends Hittable { - get texCoord0() { - return this._texCoord0; + _initializeShader(gl, vsSource, fsSource) { + super._initializeShader(gl, vsSource, fsSource); + this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); + this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); + this._isInitialized = true; } - get texCoord1() { - return this._texCoord1; + _updateCurrentBuffer() { + super._updateCurrentBuffer(); + this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._rotationAttribute, 1); + this._gl.enableVertexAttribArray(this._rotationAttribute); + this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._colorAttribute, 1); + this._gl.enableVertexAttribArray(this._colorAttribute); } - constructor(options){ - super(options); - this._thickness = 0.00001; - this._size = options.size; - this._texCoord0 = options.texCoord0; - this._texCoord1 = options.texCoord1; - this._setBounds(); + _updatePreviousBuffer() { + super._updatePreviousBuffer(); + this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousRotationAttribute, 1); + this._gl.enableVertexAttribArray(this._previousRotationAttribute); + this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + this._gl.enableVertexAttribArray(this._previousColorAttribute); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setTexCoord0(index, this._texCoord0); - buffer.setTexCoord1(index, this._texCoord1); + disableProgram() { + super.disableProgram(); + this._gl.vertexAttribDivisor(this._rotationAttribute, 0); + this._gl.vertexAttribDivisor(this._previousRotationAttribute, 0); } } -class HittableXyRect extends HittableRect { - _setBounds() { - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = this._center0[0] - this._size[0]; - max[0] = this._center0[0] + this._size[0]; - min[1] = this._center0[1] - this._size[1]; - max[1] = this._center0[1] + this._size[1]; - min[2] = this._center0[2] - this._thickness; - max[2] = this._center0[2] + this._thickness; + +},{"../../../vertex.js":"4J2YE","./unitshader.js":"dMP7E","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dMP7E":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitShader", ()=>UnitShader); +var _shaderJs = require("./shader.js"); +var _cubeJs = require("../../../meshes/cube.js"); +var _vertexJs = require("../../../vertex.js"); +class UnitShader extends (0, _shaderJs.ShaderBase) { + get paletteTexture() { + return this._paletteTexture; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.xyRect); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this._size[0], this._size[1], this._thickness)); + set paletteTexture(value) { + if (this._paletteTexture != value) { + this._paletteTexture = value; + this._haveTexturesChanged = true; + } } -} -class HittableXzRect extends HittableRect { - _setBounds() { - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = this._center0[0] - this._size[0]; - max[0] = this._center0[0] + this._size[0]; - min[1] = this._center0[1] - this._thickness; - max[1] = this._center0[1] + this._thickness; - min[2] = this._center0[2] - this._size[1]; - max[2] = this._center0[2] + this._size[1]; + get previousPaletteTexture() { + return this._previousPaletteTexture; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.xzRect); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this._size[0], this._thickness, this._size[1])); + set previousPaletteTexture(value) { + if (this._previousPaletteTexture != value) { + this._previousPaletteTexture = value; + this._haveTexturesChanged = true; + } } -} -class HittableYzRect extends HittableRect { - _setBounds() { - const min = this._bounds.min; - const max = this._bounds.max; - min[0] = this._center0[0] - this._thickness; - max[0] = this._center0[0] + this._thickness; - min[1] = this._center0[1] - this._size[0]; - max[1] = this._center0[1] + this._size[0]; - min[2] = this._center0[2] - this._size[1]; - max[2] = this._center0[2] + this._size[1]; + get sdfTexture() { + return this._sdfTexture; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.yzRect); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this._thickness, this._size[0], this._size[1])); + set sdfTexture(value) { + if (this._sdfTexture != value) { + this._sdfTexture = value; + this._haveTexturesChanged = true; + } } -} -class HittableFontXyRect extends HittableXyRect { - constructor(options){ - super(options); + get previousSdfTexture() { + return this._previousSdfTexture; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.fontXyRect); + set previousSdfTexture(value) { + if (this._previousSdfTexture != value) { + this._previousSdfTexture = value; + this._haveTexturesChanged = true; + } } -} -class HittableSdfXyRect extends HittableXyRect { - constructor(options){ - super(options); + set instanceBuffer(value) { + if (this._instanceBuffer != value) { + this._instanceBuffer = value; + this._haveBuffersChanged = true; + } } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.sdfXyRect); + set previousInstanceBuffer(value) { + if (this._previousInstanceBuffer != value) { + this._previousInstanceBuffer = value; + this._haveBuffersChanged = true; + } } -} -class HittableRotatedXyRect extends HittableXyRect { - constructor(options){ - super(options); - this._rotation = options.rotation; - const rotatedBounds = new (0, _aabbJs.AABB)(); - (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation, rotatedBounds.min, rotatedBounds.max); - this._bounds = rotatedBounds; + initializeData() { + this._areBuffersInitialized = false; } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.rotatedXyRect); - buffer.setRotation(index, this._rotation); + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._translationAttribute = gl.getAttribLocation(this._program, "aTranslation"); + this._previousTranslationAttribute = gl.getAttribLocation(this._program, "aPreviousTranslation"); + this._scaleAttribute = gl.getAttribLocation(this._program, "aScale"); + this._previousScaleAttribute = gl.getAttribLocation(this._program, "aPreviousScale"); + this._colorAttribute = gl.getAttribLocation(this._program, "aColor"); + this._previousColorAttribute = gl.getAttribLocation(this._program, "aPreviousColor"); + this._selectedAttribute = gl.getAttribLocation(this._program, "aSelected"); + this._previousSelectedAttribute = gl.getAttribLocation(this._program, "aPreviousSelected"); + this._orderAttribute = gl.getAttribLocation(this._program, "aOrder"); + this._idAttribute = gl.getAttribLocation(this._program, "aId"); + this._idColorAttribute = gl.getAttribLocation(this._program, "aIdColor"); + this._sampler0Uniform = gl.getUniformLocation(this._program, "uSampler"); + this._previousSampler0Uniform = gl.getUniformLocation(this._program, "uPreviousSampler"); + this._mMatrixUniform = gl.getUniformLocation(this._program, "uMMatrix"); + this._vMatrixUniform = gl.getUniformLocation(this._program, "uVMatrix"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._timeUniform = gl.getUniformLocation(this._program, "uTime"); + this._durationUniform = gl.getUniformLocation(this._program, "uDuration"); + this._fromOrderUniform = gl.getUniformLocation(this._program, "uOrderFrom"); + this._toOrderUniform = gl.getUniformLocation(this._program, "uOrderTo"); + this._hoverUniform = gl.getUniformLocation(this._program, "uHover"); + this._activeUniform = gl.getUniformLocation(this._program, "uActive"); + this._pickUniform = gl.getUniformLocation(this._program, "uPick"); + this._shadowUniform = gl.getUniformLocation(this._program, "uShadow"); + const vertices = (0, _cubeJs.Cube).POSITIONS; + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); + const indices = (0, _cubeJs.Cube).INDICES; + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); + this.indexCount = indices.length; } -} -class HittableRotatedFontXyRect extends HittableRotatedXyRect { - constructor(options){ - super(options); + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, 12, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._updateCurrentBuffer(); + this._updatePreviousBuffer(); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.rotatedFontXyRect); + _updateCurrentBuffer() { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._instanceBuffer); + this._gl.vertexAttribPointer(this._idAttribute, 1, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ID_HOVER_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._idAttribute, 1); + this._gl.enableVertexAttribArray(this._idAttribute); + this._gl.vertexAttribPointer(this._idColorAttribute, 4, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ID_COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._idColorAttribute, 1); + this._gl.enableVertexAttribArray(this._idColorAttribute); + this._gl.vertexAttribPointer(this._translationAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TRANSLATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._translationAttribute, 1); + this._gl.enableVertexAttribArray(this._translationAttribute); + this._gl.vertexAttribPointer(this._scaleAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SCALE_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._scaleAttribute, 1); + this._gl.enableVertexAttribArray(this._scaleAttribute); + this._gl.vertexAttribPointer(this._selectedAttribute, 1, this._gl.BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SELECTED_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._selectedAttribute, 1); + this._gl.enableVertexAttribArray(this._selectedAttribute); + this._gl.vertexAttribPointer(this._orderAttribute, 2, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ORDER_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._orderAttribute, 1); + this._gl.enableVertexAttribArray(this._orderAttribute); } -} -class HittableRotatedSdfXyRect extends HittableRotatedXyRect { - constructor(options){ - super(options); + _updatePreviousBuffer() { + if (this._previousInstanceBuffer != this._instanceBuffer) this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._previousInstanceBuffer); + this._gl.vertexAttribPointer(this._previousTranslationAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TRANSLATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousTranslationAttribute, 1); + this._gl.enableVertexAttribArray(this._previousTranslationAttribute); + this._gl.vertexAttribPointer(this._previousScaleAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SCALE_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousScaleAttribute, 1); + this._gl.enableVertexAttribArray(this._previousScaleAttribute); + this._gl.vertexAttribPointer(this._previousSelectedAttribute, 1, this._gl.BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).SELECTED_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousSelectedAttribute, 1); + this._gl.enableVertexAttribArray(this._previousSelectedAttribute); } - toBuffer(buffer, index, materialId) { - super.toBuffer(buffer, index, materialId); - buffer.setType(index, HittableType.rotatedSdfXyRect); + apply() { + this._gl.uniformMatrix4fv(this._mMatrixUniform, false, this.mMatrix); + this._gl.uniform1f(this._timeUniform, this.time); + this._gl.uniform1f(this._durationUniform, this.duration); + this._gl.uniform1f(this._fromOrderUniform, this.rangeMin); + this._gl.uniform1f(this._toOrderUniform, this.rangeMax); + this._gl.uniform1i(this._previousSampler0Uniform, 0); + this._gl.uniform1i(this._sampler0Uniform, 1); + this._gl.uniform1f(this._hoverUniform, this.hover); + this._gl.uniform1f(this._activeUniform, this.active); } -} -class HittableConstantMedium extends Hittable { - get boundary() { - return this._boundary; + applyView() { + this._gl.uniformMatrix4fv(this._vMatrixUniform, false, this.vMatrix); + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + this._gl.uniform1i(this._pickUniform, this.isPickShader ? 1 : 0); + this._gl.uniform1i(this._shadowUniform, this.isShadowMap ? 1 : 0); } - constructor(options){ - super(options); - this._boundary = options.boundary; - this._bounds = this._boundary.bounds; + updateTextures() { + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._previousPaletteTexture); + this._gl.activeTexture(this._gl.TEXTURE1); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._paletteTexture); } - toBuffer(buffer, index, materialId) { - this._boundary.toBuffer(buffer, index, materialId); - buffer.setBoundaryType(index, buffer.getType(index)); - buffer.setType(index, HittableType.constantMedium); + disableProgram() { + super.disableProgram(); + this._gl.vertexAttribDivisor(this._translationAttribute, 0); + this._gl.vertexAttribDivisor(this._previousTranslationAttribute, 0); + this._gl.vertexAttribDivisor(this._scaleAttribute, 0); + this._gl.vertexAttribDivisor(this._previousScaleAttribute, 0); + this._gl.vertexAttribDivisor(this._colorAttribute, 0); + this._gl.vertexAttribDivisor(this._previousColorAttribute, 0); + this._gl.vertexAttribDivisor(this._selectedAttribute, 0); + this._gl.vertexAttribDivisor(this._previousSelectedAttribute, 0); + this._gl.vertexAttribDivisor(this._orderAttribute, 0); + this._gl.vertexAttribDivisor(this._idAttribute, 0); + this._gl.vertexAttribDivisor(this._idColorAttribute, 0); } } -},{"gl-matrix":"9GjEQ","../../constants.js":"2Scl5","../../helpers/bounds.js":"coSRO","./aabb.js":"9AXPV","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9AXPV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AABB", ()=>AABB); +},{"./shader.js":"f1nVl","../../../meshes/cube.js":"79I5N","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"idlJV":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _cubeJs = require("../../meshes/cube.js"); -class AABB { - get min() { - return this._min; - } - get max() { - return this._max; - } - constructor(){ - this._min = (0, _glMatrix.vec3).fromValues(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); - this._max = (0, _glMatrix.vec3).fromValues(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - } - centroid(centroid) { - centroid[0] = (this._min[0] + this._max[0]) / 2; - centroid[1] = (this._min[1] + this._max[1]) / 2; - centroid[2] = (this._min[2] + this._max[2]) / 2; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitSphere", ()=>UnitSphere); +var _vertexJs = require("../../../vertex.js"); +var _unitshaderJs = require("./unitshader.js"); +class UnitSphere extends (0, _unitshaderJs.UnitShader) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("unitsphere.vertex.fx", "unitsphere.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - size(size) { - size[0] = this._max[0] - this._min[0]; - size[1] = this._max[1] - this._min[1]; - size[2] = this._max[2] - this._min[2]; + _initializeShader(gl, vsSource, fsSource) { + super._initializeShader(gl, vsSource, fsSource); + this._isInitialized = true; } - offset(point, normalized) { - normalized[0] = (point[0] - this._min[0]) / (this._max[0] - this._min[0]); - normalized[1] = (point[1] - this._min[1]) / (this._max[1] - this._min[1]); - normalized[2] = (point[2] - this._min[2]) / (this._max[2] - this._min[2]); + _updateCurrentBuffer() { + super._updateCurrentBuffer(); + this._gl.vertexAttribPointer(this._colorAttribute, 1, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._colorAttribute, 1); + this._gl.enableVertexAttribArray(this._colorAttribute); } - unionBounds(bounds) { - (0, _glMatrix.vec3).min(this._min, this._min, bounds.min); - (0, _glMatrix.vec3).max(this._max, this._max, bounds.max); + _updatePreviousBuffer() { + super._updatePreviousBuffer(); + this._gl.vertexAttribPointer(this._previousColorAttribute, 1, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + this._gl.enableVertexAttribArray(this._previousColorAttribute); } - unionPoint(point) { - (0, _glMatrix.vec3).min(this._min, this._min, point); - (0, _glMatrix.vec3).max(this._max, this._max, point); +} + +},{"../../../vertex.js":"4J2YE","./unitshader.js":"dMP7E","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kG3Ma":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitCylinder", ()=>UnitCylinder); +var _vertexJs = require("../../../vertex.js"); +var _unitshaderJs = require("./unitshader.js"); +class UnitCylinder extends (0, _unitshaderJs.UnitShader) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("unitcylinder.vertex.fx", "unitcylinder.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - maximumExtent() { - const dx = this._max[0] - this._min[0]; - const dy = this._max[1] - this._min[1]; - const dz = this._max[2] - this._min[2]; - if (dx > dy && dx > dz) return 0; - else if (dy > dz) return 1; - return 2; + _initializeShader(gl, vsSource, fsSource) { + super._initializeShader(gl, vsSource, fsSource); + this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); + this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); + this._isInitialized = true; } - surfaceArea() { - const dx = this._max[0] - this._min[0]; - const dy = this._max[1] - this._min[1]; - const dz = this._max[2] - this._min[2]; - return 2 * (dx * dy + dx * dz + dy * dz); + _updateCurrentBuffer() { + super._updateCurrentBuffer(); + this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._rotationAttribute, 1); + this._gl.enableVertexAttribArray(this._rotationAttribute); + this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._colorAttribute, 1); + this._gl.enableVertexAttribArray(this._colorAttribute); } - rotate(rotation) { - const sizeX = this._max[0] - this._min[0]; - const sizeY = this._max[1] - this._min[1]; - const sizeZ = this._max[2] - this._min[2]; - const min = (0, _glMatrix.vec3).fromValues(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); - const max = (0, _glMatrix.vec3).fromValues(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - const position = (0, _glMatrix.vec3).create(); - const vertices = (0, _cubeJs.Cube).POSITIONS; - for(let i = 0; i < 8; i++){ - (0, _glMatrix.vec3).set(position, vertices[i * 3] * sizeX, vertices[i * 3 + 1] * sizeY, vertices[i * 3 + 2] * sizeZ); - (0, _glMatrix.vec3).transformQuat(position, position, rotation); - (0, _glMatrix.vec3).min(min, min, position); - (0, _glMatrix.vec3).max(max, max, position); - } - (0, _glMatrix.vec3).copy(this._min, min); - (0, _glMatrix.vec3).copy(this._max, max); + _updatePreviousBuffer() { + super._updatePreviousBuffer(); + this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousRotationAttribute, 1); + this._gl.enableVertexAttribArray(this._previousRotationAttribute); + this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + this._gl.enableVertexAttribArray(this._previousColorAttribute); } - fromCylinder(pa, pb, radius) { - const a = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).subtract(a, pb, pa); - const aa = (0, _glMatrix.vec3).dot(a, a); - const ex = radius * Math.sqrt(1 - a[0] * a[0] / aa); - const ey = radius * Math.sqrt(1 - a[1] * a[1] / aa); - const ez = radius * Math.sqrt(1 - a[2] * a[2] / aa); - this._min[0] = Math.min(pa[0] - ex, pb[0] - ex); - this._min[1] = Math.min(pa[1] - ey, pb[1] - ey); - this._min[2] = Math.min(pa[2] - ez, pb[2] - ez); - this._max[0] = Math.max(pa[0] + ex, pb[0] + ex); - this._max[1] = Math.max(pa[1] + ey, pb[1] + ey); - this._max[2] = Math.max(pa[2] + ez, pb[2] + ez); + disableProgram() { + super.disableProgram(); + this._gl.vertexAttribDivisor(this._rotationAttribute, 0); + this._gl.vertexAttribDivisor(this._previousRotationAttribute, 0); } } -},{"gl-matrix":"9GjEQ","../../meshes/cube.js":"7rTMs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iJHMh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ComputeShaderWgsl", ()=>ComputeShaderWgsl); -parcelHelpers.export(exports, "ComputeUniformBufferData", ()=>ComputeUniformBufferData); +},{"../../../vertex.js":"4J2YE","./unitshader.js":"dMP7E","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eIwH3":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -const ComputeShaderWgsl = ` -const PI = 3.1415926535897932385f; -const TWO_PI = 6.2831853071795864769f; -const ROOT_THREE_OVER_TWO = 0.86602540378443864676f; - -struct ColorBuffer { - values: array<f32>, -} - -struct Ray { - origin: vec3<f32>, - direction: vec3<f32>, - time: f32, -} - -struct HitRecord { - normal: vec3<f32>, - t: f32, - frontFace: bool, - materialId: u32, - uv: vec2<f32>, - id: u32, - previousId: u32, - position: vec3<f32>, - previousPosition: vec3<f32>, - isAbsorbing: bool, - previousIsAbsorbing: bool, - absorption: vec3<f32>, - previousAbsorption: vec3<f32>, -} - -struct Camera { - origin: vec3<f32>, - lowerLeftCorner: vec3<f32>, - horizontal: vec3<f32>, - vertical: vec3<f32>, - lookAt: vec3<f32>, - u: vec3<f32>, - v: vec3<f32>, - w: vec3<f32>, - aspectRatio: f32, - focusDistance: f32, - viewportWidth: f32, - viewportHeight: f32, - fov: f32, - aperture: f32, - time0: f32, - time1: f32, -} - - // offest align size -struct Uniforms { // ------------------------------ - position: vec3<f32>, // 0 16 12 - width: f32, // 12 4 4 - right: vec3<f32>, // 16 16 12 - height: f32, // 28 4 4 - up: vec3<f32>, // 32 16 12 - seed: f32, // 44 4 4 - forward: vec3<f32>, // 48 16 12 - fov: f32, // 60 4 4 - lookAt: vec3<f32>, // 64 16 12 - aperture: f32, // 76 4 4 - backgroundColor: vec3<f32>, // 80 16 12 - time0: f32, // 92 4 4 - time1: f32, // 96 4 4 - // padding 100 4 12 - // ------------------------------ - // 16 112 -} - -// id type -// ---------------- -// 0 none -// 1 solidColor -// 2 image -// 3 sdfText -// 4 checker -// 5 grid - // offest align size stride -struct Texture { // --------------------------------------- - color0: vec3<f32>, // 0 16 12 - typeId: f32, // 12 4 4 - color1: vec3<f32>, // 16 12 12 - // padding 28 12 12 - size0: vec4<f32>, // 32 16 16 - size1: vec4<f32>, // 48 16 16 - clip: vec4<f32>, // 64 16 16 - offset: vec2<f32>, // 80 8 8 -} // --------------------------------------- - // 16 88 96 - -// id type -// --------------- -// 0 lambertian -// 1 metal -// 2 dielectric -// 3 diffuse light -// 4 glossy -// 5 isotropic -// 6 varnitsh - // offest align size stride -struct Material { // --------------------------------------- - typeId: f32, // 0 4 4 - fuzz: f32, // 4 4 4 - refractiveIndex: f32, // 8 4 4 - textureId: f32, // 12 4 4 - color: vec3<f32>, // 16 16 12 - glossiness: f32, // 28 4 4 - density: f32, // 32 4 4 - // --------------------------------------- -} // 16 36 48 - -// id type -// ---------------- -// 0 distant -// 1 sphere -// 2 rect -// 3 disc -// 4 cylinder -// 5 dome - // offest align size stride -struct Light { // --------------------------------------- - rotation: vec4<f32>, // 0 16 16 - center: vec3<f32>, // 16 16 12 - typeId: f32, // 28 4 4 - size: vec3<f32>, // 32 16 12 - // padding 44 4 4 - color: vec3<f32>, // 48 16 12 -} // --------------------------------------- - // 16 60 64 - -// id type -// ---------------- -// 0 sphere -// 1 box -// 2 cylinder -// 3 hexPrism -// 4 rotatedBox -// 5 xyRect -// 6 xzRect -// 7 yzRect -// 8 rotatedXyRect -// 9 fontXyRect -// 10 rotatedFontXyRect -// 11 boxSdf -// 12 cylinderSdf -// 13 hexPrismSdf -// 14 constantMedium -// 15 sdfXyRect -// 16 rotatedSdfXyRect - - // offest align size stride -struct Hittable { // --------------------------------------- - center0: vec3<f32>, // 0 16 12 - typeId: f32, // 12 4 4 - size: vec3<f32>, // 16 16 12 - materialId: f32, // 28 4 4 - rotation: vec4<f32>, // 32 16 16 - texCoord0: vec2<f32>, // 48 8 8 - texCoord1: vec2<f32>, // 56 8 8 - center1: vec3<f32>, // 64 16 12 - rounding: f32, // 76 4 4 - boundaryTypeId: f32, // 80 4 4 - time0: f32, // 84 4 4 - time1: f32, // 88 4 4 - // padding 92 4 4 -} // --------------------------------------- - // 16 96 96 - - // offest align size stride -struct LinearBVHNode { // --------------------------------------- - center: vec3<f32>, // 0 16 12 - primitivesOffset: f32, // 12 4 4 - size: vec3<f32>, // 16 16 12 - secondChildOffset: f32, // 28 4 4 - nPrimitives: f32, // 32 4 4 - axis: f32, // 36 4 4 -} // --------------------------------------- - // 16 40 48 - -struct HittableBuffer { - hittables: array<Hittable>, -} - -struct MaterialBuffer { - materials: array<Material>, -} - -struct TextureBuffer { - textures: array<Texture>, -} - -struct LightBuffer { - lights: array<Light>, -} - -struct LinearBVHNodeBuffer { - nodes: array<LinearBVHNode>, -} - -// Schlick's approximation for reflectance -fn reflectance(cos: f32, refractiveIndex: f32) -> f32 { - var r = (1f - refractiveIndex) / (1f + refractiveIndex); - r = r * r; - return r + (1f - r) * pow(1f - cos, 5f); -} - -fn refraction(uv: vec3<f32>, n: vec3<f32>, etaiOverEtat: f32) -> vec3<f32> { - let cosTheta = min(dot(-uv, n), 1f); - let rOutPerp = etaiOverEtat * (uv + cosTheta * n); - let rOutParallel = -sqrt(abs(1f - dot(rOutPerp, rOutPerp))) * n; - return rOutPerp + rOutParallel; -} - -fn getCameraRay(camera: Camera, seed: ptr<function, u32>, texCoord: vec2<f32>) -> Ray { - // Depth of field - let rd = camera.aperture * randomInUnitDisk(seed); - let offset = camera.u * rd.x + camera.v * rd.y; - var ray: Ray; - ray.origin = camera.origin + offset; - ray.direction = normalize(camera.lowerLeftCorner + texCoord.x * camera.horizontal - texCoord.y * camera.vertical - camera.origin - offset); - ray.time = camera.time0 + random(seed) * (camera.time1 - camera.time0); - return ray; -} - -fn degreesToRadians(degrees: f32) -> f32 { - return degrees * PI / 180f; -} - -// See https://www.reedbeta.com/blog/hash-functions-for-gpu-rendering/ -fn random(seed: ptr<function, u32>) -> f32 { - var random = ((*seed >> ((*seed >> 28u) + 4u)) ^ *seed) * 277803737u; - random = (random >> 22u) ^ random; - *seed = *seed * 747796405u + 2891336453u; - return f32(random) / 4294967295f; // [0,1] -} - -fn randomInUnitDisk(seed: ptr<function, u32>) -> vec2<f32> { - var p: vec2<f32>; - loop { - p = 2f * vec2<f32>(random(seed), random(seed)) - vec2<f32>(1f, 1f); - if (dot(p, p) <= 1f) { break; } + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "UnitSdf", ()=>UnitSdf); +var _vertexJs = require("../../../vertex.js"); +var _unitshaderJs = require("./unitshader.js"); +class UnitSdf extends (0, _unitshaderJs.UnitShader) { + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("unitsdf.vertex.fx", "unitsdf.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - return p; -} - -// fn randomInUnitDisk(seed: ptr<function, u32>) -> vec2<f32> { -// let t = TWO_PI * random(seed); -// let r = sqrt(random(seed)); -// return r * vec2<f32>(cos(t), sin(t)); -// } - -fn randomInUnitSphere(seed: ptr<function, u32>) -> vec3<f32> { - var p: vec3<f32>; - loop { - p = 2f * vec3<f32>(random(seed), random(seed), random(seed)) - vec3<f32>(1f, 1f, 1f); - if (dot(p, p) <= 1f) { break; } + _initializeShader(gl, vsSource, fsSource) { + super._initializeShader(gl, vsSource, fsSource); + this._rotationAttribute = gl.getAttribLocation(this._program, "aRotation"); + this._previousRotationAttribute = gl.getAttribLocation(this._program, "aPreviousRotation"); + this._texCoordAttribute = gl.getAttribLocation(this._program, "aTexCoord"); + this._previousTexCoordAttribute = gl.getAttribLocation(this._program, "aPreviousTexCoord"); + this._sampler1Uniform = gl.getUniformLocation(this._program, "uSampler1"); + this._previousSampler1Uniform = gl.getUniformLocation(this._program, "uPreviousSampler1"); + this._isInitialized = true; + } + _updateCurrentBuffer() { + super._updateCurrentBuffer(); + this._gl.vertexAttribPointer(this._rotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._rotationAttribute, 1); + this._gl.enableVertexAttribArray(this._rotationAttribute); + this._gl.vertexAttribPointer(this._texCoordAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TEXCOORD_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._texCoordAttribute, 1); + this._gl.enableVertexAttribArray(this._texCoordAttribute); + this._gl.vertexAttribPointer(this._colorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._colorAttribute, 1); + this._gl.enableVertexAttribArray(this._colorAttribute); + } + _updatePreviousBuffer() { + super._updatePreviousBuffer(); + this._gl.vertexAttribPointer(this._previousRotationAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).ROTATION_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousRotationAttribute, 1); + this._gl.enableVertexAttribArray(this._previousRotationAttribute); + this._gl.vertexAttribPointer(this._previousTexCoordAttribute, 4, this._gl.FLOAT, false, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).TEXCOORD_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousTexCoordAttribute, 1); + this._gl.enableVertexAttribArray(this._previousTexCoordAttribute); + this._gl.vertexAttribPointer(this._previousColorAttribute, 2, this._gl.UNSIGNED_BYTE, true, (0, _vertexJs.UnitVertex).SIZE_BYTES, (0, _vertexJs.UnitVertex).COLOR_OFFSET_BYTES); + this._gl.vertexAttribDivisor(this._previousColorAttribute, 1); + this._gl.enableVertexAttribArray(this._previousColorAttribute); + } + apply() { + super.apply(); + this._gl.uniform1i(this._previousSampler1Uniform, 2); + this._gl.uniform1i(this._sampler1Uniform, 3); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE2); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._previousSdfTexture); + this._gl.activeTexture(this._gl.TEXTURE3); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._sdfTexture); + } + disableProgram() { + super.disableProgram(); + this._gl.vertexAttribDivisor(this._rotationAttribute, 0); + this._gl.vertexAttribDivisor(this._previousRotationAttribute, 0); + this._gl.vertexAttribDivisor(this._texCoordAttribute, 0); + this._gl.vertexAttribDivisor(this._previousTexCoordAttribute, 0); } - return p; -} - -fn randomUnitVector(seed: ptr<function, u32>) -> vec3<f32> { - return normalize(randomInUnitSphere(seed)); -} - -// fn randomUnitVector(seed: ptr<function, u32>) -> vec3<f32> { -// let theta = TWO_PI * random(seed); // [0,2Pi] -// let phi = acos(2f * random(seed) - 1f); // [-1,1] -// return vec3<f32>(sin(phi) * cos(theta), sin(phi) * sin(theta), cos(phi)); -// } - -fn rayAt(ray: Ray, t: f32) -> vec3<f32> { - return ray.origin + ray.direction * t; } -fn setFaceNormal(ray: Ray, outwardNormal: vec3<f32>, hitRecord: ptr<function, HitRecord>) { - (*hitRecord).frontFace = dot(ray.direction, outwardNormal) < 0f; - (*hitRecord).normal = select(-outwardNormal, outwardNormal, (*hitRecord).frontFace); +},{"../../../vertex.js":"4J2YE","./unitshader.js":"dMP7E","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"j1a66":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Background", ()=>Background); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +var _quadJs = require("../components/quad.js"); +class Background extends (0, _shaderJs.ShaderBase) { + constructor(core, main){ + super(core, main); + this._quad = new (0, _quadJs.Quad)(); + } + initializeContext(gl) { + super.initializeContext(gl); + this._quad.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "background.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._colorUniform = gl.getUniformLocation(this._program, "uColor"); + this._isInitialized = true; + this._vao = gl.createVertexArray(); + gl.bindVertexArray(this._vao); + gl.bindBuffer(gl.ARRAY_BUFFER, this._quad.vertexBuffer); + gl.vertexAttribPointer(this._positionAttribute, 3, gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + gl.enableVertexAttribArray(this._positionAttribute); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._quad.indexBuffer); + gl.bindVertexArray(null); + } + apply() { + this._gl.uniform3fv(this._colorUniform, this.color); + } + updateBuffers() { + super.updateBuffers(); + this._gl.bindVertexArray(this._vao); + } } -// fn hitWorld(ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { -// var hitAnything = false; -// var closestSoFar = tMax; -// let invDir = vec3<f32>(1f, 1f, 1f) / ray.direction; -// var tempHitRecord: HitRecord; -// for (var i: u32 = 0u; i < arrayLength(&hittableBuffer.hittables); i = i + 1u) { -// if (hit(i, ray, invDir, tMin, closestSoFar, &tempHitRecord, seed)) { -// hitAnything = true; -// closestSoFar = tempHitRecord.t; -// tempHitRecord.materialId = u32(hittableBuffer.hittables[i].materialId); -// *hitRecord = tempHitRecord; -// } -// } -// return hitAnything; -// } - -fn hitBVH(ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { - var hitAnything = false; - var closestSoFar = tMax; - let invDir = vec3<f32>(1f, 1f, 1f) / ray.direction; - var tempHitRecord: HitRecord; - var toVisitOffset = 0u; - var currentNodeIndex = 0u; - var nodesToVisit: array<u32, 64>; - loop { - let node = &linearBVHNodeBuffer.nodes[currentNodeIndex]; - // Check ray against BVH node - if (intersectBox((*node).center, (*node).size, ray, invDir, tMin, closestSoFar)) { - let nPrimitives = u32((*node).nPrimitives); - if (nPrimitives > 0u) { - let primitiveOffset = u32((*node).primitivesOffset); - for (var i: u32 = 0u; i < nPrimitives; i = i + 1u) { - let id = primitiveOffset + i; - if (hit(id, ray, invDir, tMin, closestSoFar, &tempHitRecord, seed)) { - hitAnything = true; - closestSoFar = tempHitRecord.t; - tempHitRecord.materialId = u32(hittableBuffer.hittables[id].materialId); - tempHitRecord.id = id; - } - } - if (toVisitOffset == 0u) { break; } - toVisitOffset = toVisitOffset - 1u; - currentNodeIndex = nodesToVisit[toVisitOffset]; - } - else { - // Put far BVH node on nodesToVisit stack, advance to near node - if (ray.direction[u32((*node).axis)] < 0f) { - nodesToVisit[toVisitOffset] = currentNodeIndex + 1u; - currentNodeIndex = u32((*node).secondChildOffset); - } else { - nodesToVisit[toVisitOffset] = u32((*node).secondChildOffset); - currentNodeIndex = currentNodeIndex + 1u; - } - toVisitOffset = toVisitOffset + 1u; - } +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","../components/quad.js":"dAFCJ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8V9Nh":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Ssao", ()=>Ssao); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Ssao extends (0, _shaderJs.ShaderBase) { + get texture2D1() { + return this._texture2D1; + } + set texture2D1(value) { + if (this._texture2D1 != value) { + this._texture2D1 = value; + this._haveTexturesChanged = true; } - else { - if (toVisitOffset == 0u) { break; } - toVisitOffset = toVisitOffset - 1u; - currentNodeIndex = nodesToVisit[toVisitOffset]; + } + get texture2D2() { + return this._texture2D2; + } + set texture2D2(value) { + if (this._texture2D2 != value) { + this._texture2D2 = value; + this._haveTexturesChanged = true; } } - if (hitAnything) { - tempHitRecord.previousId = (*hitRecord).id; - tempHitRecord.previousPosition = (*hitRecord).position; - tempHitRecord.previousIsAbsorbing = (*hitRecord).isAbsorbing; - tempHitRecord.previousAbsorption = (*hitRecord).absorption; - *hitRecord = tempHitRecord; - return true; - }; - return false; + get texture2D3() { + return this._texture2D3; + } + set texture2D3(value) { + if (this._texture2D3 != value) { + this._texture2D3 = value; + this._haveTexturesChanged = true; + } + } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "ssao.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); + this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); + this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); + this._pMatrixUniform = gl.getUniformLocation(this._program, "uPMatrix"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._ssaoNoiseSizeUniform = gl.getUniformLocation(this._program, "uSsaoNoiseSize"); + this._ssaoRadiusUniform = gl.getUniformLocation(this._program, "uSsaoRadius"); + this._ssaoPowerUniform = gl.getUniformLocation(this._program, "uSsaoPower"); + this._ssaoKernelUniform = gl.getUniformLocation(this._program, "uSsaoKernel"); + this._isInitialized = true; + } + apply() { + this._gl.uniform1i(this._samplerUniform1, 0); + this._gl.uniform1i(this._samplerUniform2, 1); + this._gl.uniform1i(this._samplerUniform3, 2); + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + this._gl.uniform1f(this._ssaoNoiseSizeUniform, this.ssaoNoiseSize); + this._gl.uniform1f(this._ssaoRadiusUniform, this.ssaoRadius); + this._gl.uniform1f(this._ssaoPowerUniform, this.ssaoPower); + this._gl.uniform3fv(this._ssaoKernelUniform, this.ssaoKernel); + } + applyView() { + this._gl.uniformMatrix4fv(this._pMatrixUniform, false, this.pMatrix); + } + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); + this._gl.activeTexture(this._gl.TEXTURE1); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); + this._gl.activeTexture(this._gl.TEXTURE2); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); + } } -fn hit(id: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { - switch u32(hittableBuffer.hittables[id].typeId) { - default: { - return false; - } - case 0u: { - return hitSphere(id, ray, tMin, tMax, hitRecord); - } - case 1u: { - return hitBox(id, ray, invDir, tMin, tMax, hitRecord); - } - case 2u: { - return hitCylinder(id, ray, tMin, tMax, hitRecord); +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6rVqd":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Box", ()=>Box); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Box extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; + } + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; } - case 3u: { - return hitHexPrism(id, ray, tMin, tMax, hitRecord); - } - case 4u: { - return hitRotatedBox(id, ray, tMin, tMax, hitRecord); - } - case 5u: { - return hitXyRect(id, ray, tMin, tMax, hitRecord); - } - case 6u: { - return hitXzRect(id, ray, tMin, tMax, hitRecord); - } - // case 7u: { - // return hitYzRect(hittable, ray, tMin, tMax, hitRecord); - // } - case 8u: { - return hitRotatedXyRect(id, ray, tMin, tMax, hitRecord); - } - case 9u: { - return hitFontXyRect(id, ray, tMin, tMax, hitRecord); - } - case 10u: { - return hitRotatedFontXyRect(id, ray, tMin, tMax, hitRecord); - } - case 11u: { - return hitBoxSdf(id, ray, tMin, tMax, hitRecord); + } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "box.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._isInitialized = true; + } + apply() { + this._gl.uniform1i(this._samplerUniform, 0); + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + } + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + } +} + +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jNY1W":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Deferred", ()=>Deferred); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +var _glMatrix = require("gl-matrix"); +class Deferred extends (0, _shaderJs.ShaderBase) { + get texture2D1() { + return this._texture2D1; + } + set texture2D1(value) { + if (this._texture2D1 != value) { + this._texture2D1 = value; + this._haveTexturesChanged = true; } - case 12u: { - return hitCylinderSdf(id, ray, tMin, tMax, hitRecord); + } + get texture2D2() { + return this._texture2D2; + } + set texture2D2(value) { + if (this._texture2D2 != value) { + this._texture2D2 = value; + this._haveTexturesChanged = true; } - case 13u: { - return hitHexPrismSdf(id, ray, tMin, tMax, hitRecord); + } + get texture2D3() { + return this._texture2D3; + } + set texture2D3(value) { + if (this._texture2D3 != value) { + this._texture2D3 = value; + this._haveTexturesChanged = true; } - case 14u: { - return hitConstantMedium(id, ray, invDir, tMin, tMax, hitRecord, seed); + } + get texture2D4() { + return this._texture2D4; + } + set texture2D4(value) { + if (this._texture2D4 != value) { + this._texture2D4 = value; + this._haveTexturesChanged = true; } - case 15u: { - return hitSdfXyRect(id, ray, tMin, tMax, hitRecord, seed); + } + get texture2D5() { + return this._texture2D5; + } + set texture2D5(value) { + if (this._texture2D5 != value) { + this._texture2D5 = value; + this._haveTexturesChanged = true; } - case 16u: { - return hitRotatedSdfXyRect(id, ray, tMin, tMax, hitRecord, seed); - } } -} - -fn intersectBox(center: vec3<f32>, size: vec3<f32>, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32) -> bool { - let oc = ray.origin - center; - let n = invDir * oc; - let k = abs(invDir) * size; // Box size is from center to edge - let t0 = -n - k; - let t1 = -n + k; - let tNear = max(max(t0.x, t0.y), t0.z); - let tFar = min(min(t1.x, t1.y), t1.z); - if (tNear > tFar) { return false; } - return tNear < tMax && tFar > 0f; // Must return true when inside box, even if closestSoFar is closer than far box intersection -} - -// https://www.pbr-book.org/3ed-2018/Shapes/Basic_Shape_Interface#Bounds3::IntersectP -// fn intersectBox2(center: vec3<f32>, size: vec3<f32>, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32) -> bool { -// var t0:f32 = tMin; -// var t1:f32 = tMax; -// for (var i: u32 = 0u; i < 3; i = i + 1u) { -// // Update interval for ith bounding box slab -// let tNear = (pMin[i] - ray.o[i]) * invDir[i]; -// let tFar = (pMax[i] - ray.o[i]) * invDir[i]; -// // Update parametric interval from slab intersection values -// if (tNear > tFar) { -// std::swap(tNear, tFar); -// } -// // Update tFar to ensure robust ray–bounds intersection -// tFar *= 1 + 2 * gamma(3); - -// t0 = tNear > t0 ? tNear : t0; -// t1 = tFar < t1 ? tFar : t1; -// if (t0 > t1) { return false; } -// } -// if (hitt0) { *hitt0 = t0; } -// if (hitt1) { *hitt1 = t1; } -// return true; -// } - -fn hitConstantMedium(id: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { - let constantMedium = &hittableBuffer.hittables[id]; - let boundaryTypeId = u32((*constantMedium).boundaryTypeId); - var tempHitRecord1: HitRecord; - if (!hitConstantMediumBoundary(id, boundaryTypeId, ray, invDir, -100f, 100f, &tempHitRecord1)) { return false; } - var tempHitRecord2: HitRecord; - // When raymarching narrow grazing angles, adding SHADOW_OFFSET is < epsilon from surface, so hit function returns tN not tF, hence distanceInsideBoundary is incorrect - // HACK: Add larger distance to t - if (!hitConstantMediumBoundary(id, boundaryTypeId, ray, invDir, tempHitRecord1.t + 0.001f, 100f, &tempHitRecord2)) { return false; } - if (tempHitRecord1.t < tMin) { tempHitRecord1.t = tMin; } - if (tempHitRecord2.t > tMax) { tempHitRecord2.t = tMax; } - if (tempHitRecord1.t >= tempHitRecord2.t) { - return false; + constructor(core, main){ + super(core, main); + this.directionToKeyLight = (0, _glMatrix.vec3).create(); + this.directionToFillLight1 = (0, _glMatrix.vec3).create(); + this.directionToFillLight2 = (0, _glMatrix.vec3).create(); + this.keyLightHalfAngle = (0, _glMatrix.vec3).create(); + } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "deferred.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._shadowUniform = gl.getUniformLocation(this._program, "uShadow"); + this._ssaoUniform = gl.getUniformLocation(this._program, "uSsao"); + this._inverseVMatrixUniform = gl.getUniformLocation(this._program, "uInverseVMatrix"); + this._shadowVMatrixUniform = gl.getUniformLocation(this._program, "uShadowVMatrix"); + this._shadowPMatrixUniform = gl.getUniformLocation(this._program, "uShadowPMatrix"); + this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); + this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); + this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); + this._samplerUniform4 = gl.getUniformLocation(this._program, "uSampler4"); + this._samplerUniform5 = gl.getUniformLocation(this._program, "uSampler5"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._shadowMapSizeUniform = gl.getUniformLocation(this._program, "uShadowMapSize"); + this._keyLightHalfAngleUniform = gl.getUniformLocation(this._program, "uKeyLightHalfAngle"); + this._directionToKeyLightUniform = gl.getUniformLocation(this._program, "uDirectionToKeyLight"); + this._directionToFillLight1Uniform = gl.getUniformLocation(this._program, "uDirectionToFillLight1"); + this._directionToFillLight2Uniform = gl.getUniformLocation(this._program, "uDirectionToFillLight2"); + this._keyLightIntensityUniform = gl.getUniformLocation(this._program, "uKeyLightIntensity"); + this._fillLight1IntensityUniform = gl.getUniformLocation(this._program, "uFillLight1Intensity"); + this._fillLight2IntensityUniform = gl.getUniformLocation(this._program, "uFillLight2Intensity"); + this._ambientIntensityUniform = gl.getUniformLocation(this._program, "uAmbientIntensity"); + this._materialIntensityUniform = gl.getUniformLocation(this._program, "uMaterialIntensity"); + this._specularPowerUniform = gl.getUniformLocation(this._program, "uSpecularPower"); + this._specularIntensityUniform = gl.getUniformLocation(this._program, "uSpecularIntensity"); + this._isInitialized = true; + } + apply() { + this._gl.uniform1i(this._shadowUniform, this.isShadowEnabled ? 1 : 0); + this._gl.uniform1i(this._ssaoUniform, this.isSsaoEnabled ? 1 : 0); + this._gl.uniformMatrix4fv(this._inverseVMatrixUniform, false, this.inverseVMatrix); + this._gl.uniformMatrix4fv(this._shadowVMatrixUniform, false, this.shadowVMatrix); + this._gl.uniformMatrix4fv(this._shadowPMatrixUniform, false, this.shadowPMatrix); + this._gl.uniform1i(this._samplerUniform1, 0); + this._gl.uniform1i(this._samplerUniform2, 1); + this._gl.uniform1i(this._samplerUniform3, 2); + this._gl.uniform1i(this._samplerUniform4, 3); + this._gl.uniform1i(this._samplerUniform5, 4); + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + this._gl.uniform2f(this._shadowMapSizeUniform, this.shadowMapWidth, this.shadowMapHeight); + this._gl.uniform1f(this._keyLightIntensityUniform, this.keyLightIntensity); + this._gl.uniform1f(this._fillLight1IntensityUniform, this.fillLight1Intensity); + this._gl.uniform1f(this._fillLight2IntensityUniform, this.fillLight2Intensity); + this._gl.uniform1f(this._ambientIntensityUniform, this.ambientIntensity); + this._gl.uniform1f(this._materialIntensityUniform, this.materialIntensity); + this._gl.uniform1f(this._specularPowerUniform, this.specularPower); + this._gl.uniform1f(this._specularIntensityUniform, this.specularIntensity); + this._gl.uniform3fv(this._directionToKeyLightUniform, this.directionToKeyLight); + this._gl.uniform3fv(this._directionToFillLight1Uniform, this.directionToFillLight1); + this._gl.uniform3fv(this._directionToFillLight2Uniform, this.directionToFillLight2); + this._gl.uniform3fv(this._keyLightHalfAngleUniform, this.keyLightHalfAngle); + } + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); + this._gl.activeTexture(this._gl.TEXTURE1); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); + this._gl.activeTexture(this._gl.TEXTURE2); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); + this._gl.activeTexture(this._gl.TEXTURE3); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D4); + this._gl.activeTexture(this._gl.TEXTURE4); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D5); } - tempHitRecord1.t = max(tempHitRecord1.t, 0f); - let distanceInsideBoundary = tempHitRecord2.t - tempHitRecord1.t; - let negativeInverseDensity = -1f / materialBuffer.materials[u32((*constantMedium).materialId)].density; - let hitDistance = negativeInverseDensity * log(random(seed)); - if (hitDistance > distanceInsideBoundary) { return false; } - let t = tempHitRecord1.t + hitDistance; - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - return true; } -fn hitConstantMediumBoundary(id: u32, boundaryTypeId: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - switch boundaryTypeId { - default: { - return false; - } - case 0u: { - return hitSphere(id, ray, tMin, tMax, hitRecord); - } - case 1u: { - return hitBox(id, ray, invDir, tMin, tMax, hitRecord); - } - case 2u: { - return hitCylinder(id, ray, tMin, tMax, hitRecord); - } - case 3u: { - return hitHexPrism(id, ray, tMin, tMax, hitRecord); +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7jcRQ":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Combine", ()=>Combine); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Combine extends (0, _shaderJs.ShaderBase) { + get texture2D1() { + return this._texture2D1; + } + set texture2D1(value) { + if (this._texture2D1 != value) { + this._texture2D1 = value; + this._haveTexturesChanged = true; } - case 4u: { - return hitRotatedBox(id, ray, tMin, tMax, hitRecord); + } + get texture2D2() { + return this._texture2D2; + } + set texture2D2(value) { + if (this._texture2D2 != value) { + this._texture2D2 = value; + this._haveTexturesChanged = true; } - case 11u: { - return hitBoxSdf(id, ray, tMin, tMax, hitRecord); + } + get texture2D3() { + return this._texture2D3; + } + set texture2D3(value) { + if (this._texture2D3 != value) { + this._texture2D3 = value; + this._haveTexturesChanged = true; } - case 12u: { - return hitCylinderSdf(id, ray, tMin, tMax, hitRecord); + } + get texture2D4() { + return this._texture2D4; + } + set texture2D4(value) { + if (this._texture2D4 != value) { + this._texture2D4 = value; + this._haveTexturesChanged = true; } - case 13u: { - return hitHexPrismSdf(id, ray, tMin, tMax, hitRecord); + } + get texture2D5() { + return this._texture2D5; + } + set texture2D5(value) { + if (this._texture2D5 != value) { + this._texture2D5 = value; + this._haveTexturesChanged = true; } } -} - -fn hitSphere(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let sphere = &hittableBuffer.hittables[id]; - let radius = (*sphere).size.x; - let time = min(max((ray.time - (*sphere).time0) / ((*sphere).time1 - (*sphere).time0), 0), 1); // Normalize time to [0,1] - let center = (*sphere).center0 + time * ((*sphere).center1 - (*sphere).center0); - let oc = ray.origin - center; - let b = dot(oc, ray.direction); - let c = dot(oc, oc) - radius * radius; - var h = b * b - c; - if (h < 0f) { return false; } - h = sqrt(h); - - // Find the nearest root in range - var root = -b - h; - if (root < tMin || root > tMax) { - root = -b + h; - if (root < tMin || root > tMax) { return false; } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "combine.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - - // (*hitRecord).t = root; - // (*hitRecord).position = rayAt(ray, root); - // let outwardNormal = ((*hitRecord).position - center) / radius; - // setFaceNormal(ray, outwardNormal, hitRecord); - - // Reduce precision error in t by ensuring hit position is on sphere surface - // This is actually faster (fewer rays?) - let outwardNormal = normalize(ray.origin + ray.direction * root - center); - setFaceNormal(ray, outwardNormal, hitRecord); - (*hitRecord).position = center + outwardNormal * radius; // Use outward normal with internal reflection - (*hitRecord).t = root; // I should also re-calculate t, but this would involve another normalization. t is only used to check closest hit, so only important with overlapping geometry - - // TODO: Could move to hittable.sphereUV if expensive - // UV - let phi = atan2(outwardNormal.x, outwardNormal.z); // [-pi,pi] - let theta = asin(outwardNormal.y); // [-pi/2, pi/2] - (*hitRecord).uv = vec2<f32>(phi / TWO_PI + 0.5f, theta / PI + 0.5f); // [0,1] - return true; -} - -fn hitBox(id: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let box = &hittableBuffer.hittables[id]; - let time = min(max((ray.time - (*box).time0) / ((*box).time1 - (*box).time0), 0), 1); // Normalize time to [0,1] - let center = (*box).center0 + time * ((*box).center1 - (*box).center0); - let oc = ray.origin - center; - let n = invDir * oc; - let k = abs(invDir) * (*box).size; // Box size is from center to edge - let t1 = -n - k; - let t2 = -n + k; - let tNear = max(max(t1.x, t1.y), t1.z); - let tFar = min(min(t2.x, t2.y), t2.z); - // if (tFar <= tNear) { return false; } - if (tNear > tFar || tFar < 0f) { return false; } - - // Find nearest root in range - var outwardNormal: vec3<f32>; - var root = tNear; - if (root < tMin || root > tMax) { - root = tFar; - if (root < tMin || root > tMax) { return false; } - outwardNormal = sign(ray.direction) * step(t2.xyz, t2.yzx) * step(t2.xyz, t2.zxy); + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._intensityUniform = gl.getUniformLocation(this._program, "uIntensity"); + this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); + this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); + this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); + this._samplerUniform4 = gl.getUniformLocation(this._program, "uSampler4"); + this._samplerUniform5 = gl.getUniformLocation(this._program, "uSampler5"); + this._isInitialized = true; } - else { - outwardNormal = -sign(ray.direction) * step(t1.yzx, t1.xyz) * step(t1.zxy, t1.xyz); + apply() { + this._gl.uniform4f(this._viewportUniform, this.viewport.x, this.viewport.y, this.viewport.width, this.viewport.height); + this._gl.uniform1f(this._intensityUniform, this.intensity); + this._gl.uniform1i(this._samplerUniform1, 0); + this._gl.uniform1i(this._samplerUniform2, 1); + this._gl.uniform1i(this._samplerUniform3, 2); + this._gl.uniform1i(this._samplerUniform4, 3); + this._gl.uniform1i(this._samplerUniform5, 4); } - - (*hitRecord).t = root; - (*hitRecord).position = rayAt(ray, root); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; -} - -fn hitRotatedBox(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let rotatedBox = &hittableBuffer.hittables[id]; - let time = min(max((ray.time - (*rotatedBox).time0) / ((*rotatedBox).time1 - (*rotatedBox).time0), 0), 1); // Normalize time to [0,1] - let center = (*rotatedBox).center0 + time * ((*rotatedBox).center1 - (*rotatedBox).center0); - let rotation = (*rotatedBox).rotation; - let invRotation = conjugate(rotation); - var rotatedRay: Ray; - rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; - rotatedRay.direction = rotateQuat(ray.direction, invRotation); - let rotatedInvDir = vec3<f32>(1f, 1f, 1f) / rotatedRay.direction; - let hit = hitBox(id, rotatedRay, rotatedInvDir, tMin, tMax, hitRecord); - if (hit) { - (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; - (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); - return true; + updateBuffers() { + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); } - return false; -} - -fn hitXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let xyRect = &hittableBuffer.hittables[id]; - let oc = ray.origin - (*xyRect).center0; - - // Distance to plane, t - let t = -oc.z / ray.direction.z; - - // If direction == 0, t = +/- infinity, which always returns false - if (t < tMin || t > tMax) { return false; } - - // Intersection point in model space - let p = oc + t * ray.direction; - - // Bounds - let size = (*xyRect).size; - if (abs(p.x) > size.x || abs(p.y) > size.y) { return false; } - - // Texture coords - var uv = vec2<f32>(0.5 * p.xy / size.xy + vec2<f32>(0.5f, 0.5f)); - let texCoord0 = (*xyRect).texCoord0; - let texCoord1 = (*xyRect).texCoord1; - uv = texCoord0 + uv * (texCoord1 - texCoord0); - - (*hitRecord).uv = uv; - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - let outwardNormal = vec3<f32>(0f, 0f, 1f); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; -} - -fn hitRotatedXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let rotatedXyRect = &hittableBuffer.hittables[id]; - let center = (*rotatedXyRect).center0; - let rotation = (*rotatedXyRect).rotation; - let invRotation = conjugate(rotation); - var rotatedRay: Ray; - rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; - rotatedRay.direction = rotateQuat(ray.direction, invRotation); - let hit = hitXyRect(id, rotatedRay, tMin, tMax, hitRecord); - if (hit) { - (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; - (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); - return true; + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); + this._gl.activeTexture(this._gl.TEXTURE1); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); + this._gl.activeTexture(this._gl.TEXTURE2); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); + this._gl.activeTexture(this._gl.TEXTURE3); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D4); + this._gl.activeTexture(this._gl.TEXTURE4); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D5); } - return false; } -fn hitXzRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let xzRect = &hittableBuffer.hittables[id]; - let oc = ray.origin - (*xzRect).center0; - - // Distance to plane, t - let t = -oc.y / ray.direction.y; - - // If direction == 0, t = +/- infinity, which always returns false - if (t < tMin || t > tMax) { return false; } - - // Intersection point in model space - let p = oc + t * ray.direction; - - // Bounds - let size = (*xzRect).size; - if (abs(p.x) > size.x || abs(p.z) > size.z) { return false; } - - // Texture coords - var uv = vec2<f32>(0.5 * p.xz / size.xz + vec2<f32>(0.5f, 0.5f)); - let texCoord0 = (*xzRect).texCoord0; - let texCoord1 = (*xzRect).texCoord1; - uv = texCoord0 + uv * (texCoord1 - texCoord0); - - (*hitRecord).uv = uv; - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - let outwardNormal = vec3<f32>(0f, 1f, 0f); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; -} - -// fn hitYzRect(yzRect: Hittable, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { -// let oc = ray.origin - yzRect.center0; - -// // Distance to plane, t -// let t = -oc.x / ray.direction.x; - -// // If direction == 0, t = +/- infinity, which always returns false -// if (t < tMin || t > tMax) { return false; } - -// // Intersection point in model space -// let p = oc + t * ray.direction; - -// // Bounds -// if (abs(p.y) > yzRect.size.y || abs(p.z) > yzRect.size.z) { return false; } - -// // Texture coords -// var uv = vec2<f32>(0.5 * p.yz / yzRect.size.yz + vec2<f32>(0.5f, 0.5f)); -// uv = yzRect.texCoord0 + uv * (yzRect.texCoord1 - yzRect.texCoord0); - -// (*hitRecord).uv = uv; -// (*hitRecord).t = t; -// (*hitRecord).position = rayAt(ray, t); -// let outwardNormal = vec3<f32>(1f, 0f, 0f); -// setFaceNormal(ray, outwardNormal, hitRecord); -// return true; -// } - -// TODO: Share hit function with XyRect -fn hitFontXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let xyRect = &hittableBuffer.hittables[id]; - let oc = ray.origin - (*xyRect).center0; - - // Distance to plane, t - let t = -oc.z / ray.direction.z; - - // If direction == 0, t = +/- infinity, which always returns false - if (t < tMin || t > tMax) { return false; } - - // Intersection point in model space - let p = oc + t * ray.direction; - - // Bounds - let size = (*xyRect).size; - // if (abs(p.x) > size.x || abs(p.y) > size.y) { return false; } - - // Texture coords - var uv = vec2<f32>(0.5 * p.xy / size.xy + vec2<f32>(0.5f, 0.5f)); - let texCoord0 = (*xyRect).texCoord0; - let texCoord1 = (*xyRect).texCoord1; - uv = texCoord0 + uv * (texCoord1 - texCoord0); - - // Sample sdf - let buffer = 0xc0.f / 0xff.f; // TODO: Move to constant - let r = textureSampleLevel(fontTexture, linearSampler, uv, 0f).r; - if (r < buffer) { return false; } - - (*hitRecord).uv = uv; - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - let outwardNormal = vec3<f32>(0f, 0f, 1f); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; -} - -fn hitRotatedFontXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let rotatedXyRect = &hittableBuffer.hittables[id]; - let center = (*rotatedXyRect).center0; - let rotation = (*rotatedXyRect).rotation; - let invRotation = conjugate(rotation); - var rotatedRay: Ray; - rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; - rotatedRay.direction = rotateQuat(ray.direction, invRotation); - let hit = hitFontXyRect(id, rotatedRay, tMin, tMax, hitRecord); - if (hit) { - (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; - (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); - return true; +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aFGoZ":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DofBlur", ()=>DofBlur); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class DofBlur extends (0, _shaderJs.ShaderBase) { + get texture2D1() { + return this._texture2D1; } - return false; -} - -// TODO: Share hit function with FontXyRect, specifying texture -fn hitSdfXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { - let xyRect = &hittableBuffer.hittables[id]; - let oc = ray.origin - (*xyRect).center0; - - // Distance to plane, t - let t = -oc.z / ray.direction.z; - - // If direction == 0, t = +/- infinity, which always returns false - if (t < tMin || t > tMax) { return false; } - - // Intersection point in model space - let p = oc + t * ray.direction; - - // Bounds - let size = (*xyRect).size; - // if (abs(p.x) > (*xyRect).size.x || abs(p.y) > (*xyRect).size.y) { return false; } - - // Zero-thickness transparency - // TODO: Pre-multiplied alpha - // if (random(seed) > 0.5f) { return false; } - - // Texture coords - var uv = vec2<f32>(0.5 * p.xy / size.xy + vec2<f32>(0.5f, 0.5f)); - let texCoord0 = (*xyRect).texCoord0; - let texCoord1 = (*xyRect).texCoord1; - uv = texCoord0 + uv * (texCoord1 - texCoord0); - - // Sample sdf - // let buffer = 0xc0.f / 0xff.f; // TODO: Move to constant - let buffer = 0xc0.f / 0xff.f + 2.0 / 255.0; // TODO: Move to constant - let r = textureSampleLevel(atlasTexture, linearSampler, uv, 0f).r; - if (r < buffer) { return false; } - - (*hitRecord).uv = uv; - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - let outwardNormal = vec3<f32>(0f, 0f, 1f); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; -} - -fn hitRotatedSdfXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { - let rotatedXyRect = &hittableBuffer.hittables[id]; - let center = (*rotatedXyRect).center0; - let rotation = (*rotatedXyRect).rotation; - let invRotation = conjugate(rotation); - var rotatedRay: Ray; - rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; - rotatedRay.direction = rotateQuat(ray.direction, invRotation); - let hit = hitSdfXyRect(id, rotatedRay, tMin, tMax, hitRecord, seed); - if (hit) { - (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; - (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); - return true; + set texture2D1(value) { + if (this._texture2D1 != value) { + this._texture2D1 = value; + this._haveTexturesChanged = true; + } } - return false; -} - -fn rotateQuat(v: vec3<f32>, q: vec4<f32>) -> vec3<f32> { - return v + 2f * cross(q.xyz, cross(q.xyz, v) + q.w * v); -} - -fn conjugate(q: vec4<f32>) -> vec4<f32> { - return vec4<f32>(-q.x, -q.y, -q.z, q.w); -} - -fn hitCylinder(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let cylinder = &hittableBuffer.hittables[id]; - let time = min(max((ray.time - (*cylinder).time0) / ((*cylinder).time1 - (*cylinder).time0), 0), 1); // Normalize time to [0,1] - let center = (*cylinder).center0 + time * ((*cylinder).center1 - (*cylinder).center0); - let size = (*cylinder).size; - let ra = size.x; // Radius - let ca = rotateQuat(vec3<f32>(0f, 1f, 0f), (*cylinder).rotation); - let oc = ray.origin - center; - let card = dot(ca, ray.direction); - let caoc = dot(ca, oc); - let a = 1f - card * card; - let b = dot(oc, ray.direction) - caoc * card; - let c = dot(oc, oc) - caoc * caoc - ra * ra; - var h = b * b - a * c; - if (h < 0f) { return false; } - h = sqrt(h); - let br0 = (-b - h) / a; - let br1 = (-b + h) / a; - - // Body - let ch = size.y; // Half-height - let y0 = caoc + br0 * card; - let y1 = caoc + br1 * card; - let bt0 = select(10000000f, br0, abs(y0) < ch); - let bt1 = select(-10000000f, br1, abs(y1) < ch); - - // Caps - let sy0 = sign(y0); - let sy1 = sign(y1); - let cr0 = (sy0 * ch - caoc) / card; - let cr1 = (sy1 * ch - caoc) / card; - let ct0 = select(10000000f, cr0, abs(b + a * cr0) < h); - let ct1 = select(-10000000f, cr1, abs(b + a * cr1) < h); - - // Find the nearest root in range - let tN = min(bt0, ct0); - let tF = max(bt1, ct1); - var root = tN; - if (root < tMin || root > tMax) { - root = tF; - if (root < tMin || root > tMax) { return false; } + get texture2D2() { + return this._texture2D2; } - - // Normal - var outwardNormal: vec3<f32>; - if (root == bt0 || root == bt1) { - let y = select(y1, y0, root == bt0); - // outwardNormal = (oc + root * ray.direction - ca * y) / ra; - - // Reduce precision error in t by ensuring hit position is on cylinder surface - outwardNormal = normalize(oc + root * ray.direction - ca * y); - setFaceNormal(ray, outwardNormal, hitRecord); - (*hitRecord).position = center + ca * y + outwardNormal * ra; // Use outward normal with internal reflection - (*hitRecord).t = root; + set texture2D2(value) { + if (this._texture2D2 != value) { + this._texture2D2 = value; + this._haveTexturesChanged = true; + } } - else { - let sy = select(sy1, sy0, root == ct0); - outwardNormal = ca * sy; - - // TODO: Reduce precision error - setFaceNormal(ray, outwardNormal, hitRecord); - (*hitRecord).position = rayAt(ray, root); - (*hitRecord).t = root; + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "dofblur.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - - // setFaceNormal(ray, outwardNormal, hitRecord); - // (*hitRecord).position = rayAt(ray, root); - // (*hitRecord).t = root; - return true; -} - -fn hitHexPrism(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let hexPrism = &hittableBuffer.hittables[id]; - let time = min(max((ray.time - (*hexPrism).time0) / ((*hexPrism).time1 - (*hexPrism).time0), 0), 1); // Normalize time to [0,1] - let center = (*hexPrism).center0 + time * ((*hexPrism).center1 - (*hexPrism).center0); - let oc = ray.origin - center; - let size = (*hexPrism).size; - let ra = size.x; // Distance from center to edge - let he = size.y; // Half-height - let rd = ray.direction; - - // Normals - let n1 = vec3<f32>(1f, 0f, 0f); - let n2 = vec3<f32>(0.5f, 0f, ROOT_THREE_OVER_TWO); - let n3 = vec3<f32>(-0.5f, 0f, ROOT_THREE_OVER_TWO); - let n4 = vec3<f32>(0f, 1f, 0f); - - // Slabs intersections - var t1 = vec3<f32>((vec2<f32>(ra, -ra) - dot(oc, n1)) / dot(rd, n1), 1f); - var t2 = vec3<f32>((vec2<f32>(ra, -ra) - dot(oc, n2)) / dot(rd, n2), 1f); - var t3 = vec3<f32>((vec2<f32>(ra, -ra) - dot(oc, n3)) / dot(rd, n3), 1f); - var t4 = vec3<f32>((vec2<f32>(he, -he) - dot(oc, n4)) / dot(rd, n4), 1f); - - // Inetsection selection - if (t1.y < t1.x) { t1 = vec3<f32>(t1.yx, -1f); } - if (t2.y < t2.x) { t2 = vec3<f32>(t2.yx, -1f); } - if (t3.y < t3.x) { t3 = vec3<f32>(t3.yx, -1f); } - if (t4.y < t4.x) { t4 = vec3<f32>(t4.yx, -1f); } - - var tN = vec4<f32>(t1.x, t1.z * n1); - if (t2.x > tN.x) { tN = vec4<f32>(t2.x, t2.z * n2); } - if (t3.x > tN.x) { tN = vec4<f32>(t3.x, t3.z * n3); } - if (t4.x > tN.x) { tN = vec4<f32>(t4.x, t4.z * n4); } - - let tF = min(min(t1.y,t2.y),min(t3.y,t4.y)); - - if (tN.x > tF || tF < 0f) { return false; } - - // Find the nearest root in range - var outwardNormal: vec3<f32>; - var root = tN.x; - if (root < tMin || root > tMax) { - root = tF; - if (root < tMin || root > tMax) { return false; } - - // Normal - if (root == t1.y) { outwardNormal = -t1.z * n1; } - else if (root == t2.y) { outwardNormal = -t2.z * n2; } - else if (root == t3.y) { outwardNormal = -t3.z * n3; } - else if (root == t4.y) { outwardNormal = -t4.z * n4; } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._focusDepthUniform = gl.getUniformLocation(this._program, "uFocusDepth"); + this._nearFocusDepthUniform = gl.getUniformLocation(this._program, "uNearFocusDepth"); + this._farFocusDepthUniform = gl.getUniformLocation(this._program, "uFarFocusDepth"); + this._maxBackgroundBlurUniform = gl.getUniformLocation(this._program, "uMaxBackgroundBlur"); + this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); + this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); + this._isInitialized = true; } - else { - outwardNormal = tN.yzw; + apply() { + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + this._gl.uniform1f(this._focusDepthUniform, this.focusDepth); + this._gl.uniform1f(this._nearFocusDepthUniform, this.nearFocusDepth); + this._gl.uniform1f(this._farFocusDepthUniform, this.farFocusDepth); + this._gl.uniform1f(this._maxBackgroundBlurUniform, this.maxBackgroundBlur); + this._gl.uniform1i(this._samplerUniform1, 0); + this._gl.uniform1i(this._samplerUniform2, 1); } - - (*hitRecord).t = root; - (*hitRecord).position = rayAt(ray, root); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; -} - -fn mapBoxSdf(p: vec3<f32>, b: vec3<f32>, r: f32) -> f32 { - let q = abs(p) - b; - return length(max(q, vec3<f32>(0f, 0f, 0f))) + min(max(q.x, max(q.y, q.z)), 0f) - r; -} - -// Box frame -// fn mapBoxSdf(p: vec3<f32>, b: vec3<f32>, r: f32) -> f32 { -// let s = abs(p) - b; -// let e = b.y / 3f; -// let q = abs(s + e) - e; -// return min(min( -// length(max(vec3<f32>(s.x, q.y, q.z), vec3<f32>(0f, 0f, 0f))) + min(max(s.x, max(q.y,q.z)), 0f), -// length(max(vec3<f32>(q.x, s.y, q.z), vec3<f32>(0f, 0f, 0f))) + min(max(q.x, max(s.y,q.z)), 0f)), -// length(max(vec3<f32>(q.x, q.y, s.z), vec3<f32>(0f, 0f, 0f))) + min(max(q.x, max(q.y,s.z)), 0f)); -// } - -fn hitBoxSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let boxSdf = &hittableBuffer.hittables[id]; - var t = tMin; - let r = (*boxSdf).rounding; - let size = (*boxSdf).size - r; - let time = min(max((ray.time - (*boxSdf).time0) / ((*boxSdf).time1 - (*boxSdf).time0), 0), 1); // Normalize time to [0,1] - let center = (*boxSdf).center0 + time * ((*boxSdf).center1 - (*boxSdf).center0); - for (var i: u32 = 0u; i < 256u; i = i + 1u) { - let position = rayAt(ray, t); - let oc = position - center; - let distance = abs(mapBoxSdf(oc, size, r)); - t = t + distance; - if (t > tMax) { return false; } - if (distance < 0.000001f) { - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - - // Normal - let h = 0.000001f; // replace by an appropriate value - let k = vec2<f32>(1f, -1f); - let outwardNormal = normalize( - k.xyy * mapBoxSdf(oc + k.xyy * h, size, r) + - k.yyx * mapBoxSdf(oc + k.yyx * h, size, r) + - k.yxy * mapBoxSdf(oc + k.yxy * h, size, r) + - k.xxx * mapBoxSdf(oc + k.xxx * h, size, r)); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; - } + updateBuffers() { + super.updateBuffers(); + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); } - return false; -} - -fn mapCylinderSdf(p: vec3<f32>, a: vec3<f32>, b: vec3<f32>, r0: f32, r1: f32) -> f32 { - let ba: vec3<f32> = b - a; - let pa: vec3<f32> = p - a; - let baba: f32 = dot(ba, ba); - let paba: f32 = dot(pa, ba); - let x: f32 = length(pa * baba - ba * paba) - r0 * baba; - let y: f32 = abs(paba - baba * 0.5f) - baba * 0.5f; - let x2: f32 = x * x; - let y2: f32 = y * y * baba; - // let d: f32 = (max(x, y) < 0f) ? -min(x2, y2) : (((x > 0f) ? x2 : 0f) + ((y > 0f) ? y2 : 0f)); - let d: f32 = select(select(0f, x2, x > 0f) + select(0f, y2, y > 0f), -min(x2, y2), max(x, y) < 0f); - return sign(d) * sqrt(abs(d)) / baba - r1; -} - -fn hitCylinderSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let cylinderSdf = &hittableBuffer.hittables[id]; - var t = tMin; - let r1 = (*cylinderSdf).rounding; - let size = (*cylinderSdf).size; - let r0 = size.x - r1; - let h0 = size.y - r1; - let ca = rotateQuat(vec3<f32>(0f, 1f, 0f), (*cylinderSdf).rotation); - let pa = ca * h0; - let pb = -pa; - let time = min(max((ray.time - (*cylinderSdf).time0) / ((*cylinderSdf).time1 - (*cylinderSdf).time0), 0), 1); // Normalize time to [0,1] - let center = (*cylinderSdf).center0 + time * ((*cylinderSdf).center1 - (*cylinderSdf).center0); - for (var i: u32 = 0u; i < 256u; i = i + 1u) { - let position = rayAt(ray, t); - let oc = position - center; - let distance = abs(mapCylinderSdf(oc, pa, pb, r0, r1)); - t = t + distance; - if (t > tMax) { return false; } - if (distance < 0.000001f) { - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - - // Normal - let h = 0.000001f; // replace by an appropriate value - let k = vec2<f32>(1f, -1f); - let outwardNormal = normalize( - k.xyy * mapCylinderSdf(oc + k.xyy * h, pa, pb, r0, r1) + - k.yyx * mapCylinderSdf(oc + k.yyx * h, pa, pb, r0, r1) + - k.yxy * mapCylinderSdf(oc + k.yxy * h, pa, pb, r0, r1) + - k.xxx * mapCylinderSdf(oc + k.xxx * h, pa, pb, r0, r1)); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; - } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); + this._gl.activeTexture(this._gl.TEXTURE1); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); } - return false; -} - -fn mapHexPrismSdf(p: vec3<f32>, hx: f32, hy: f32, r: f32) -> f32 { - let k = vec3<f32>(-0.8660254, 0.5, 0.57735); // (-sqrt(3)/2 or sin(60), 0.5, sqrt(3)/3 or tan(30)) - var p0 = abs(p.zxy); - let p1 = p0.xy - 2f * min(dot(k.xy, p0.xy), 0f) * k.xy; - let d = vec2<f32>(length(p1.xy - vec2(clamp(p1.x, -k.z * hx, k.z * hx), hx)) * sign(p1.y - hx), p0.z - hy); - return min(max(d.x, d.y), 0f) + length(max(d, vec2<f32>(0f, 0f))) - r; } -fn hitHexPrismSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { - let hexPrismSdf = &hittableBuffer.hittables[id]; - var t = tMin; - let r = (*hexPrismSdf).rounding; - let size = (*hexPrismSdf).size; - let time = min(max((ray.time - (*hexPrismSdf).time0) / ((*hexPrismSdf).time1 - (*hexPrismSdf).time0), 0), 1); // Normalize time to [0,1] - let center = (*hexPrismSdf).center0 + time * ((*hexPrismSdf).center1 - (*hexPrismSdf).center0); - let hx = size.x - r; - let hy = size.y - r; - for (var i: u32 = 0u; i < 256u; i = i + 1u) { - let position = rayAt(ray, t); - let oc = position - center; - let distance = abs(mapHexPrismSdf(oc, hx, hy, r)); - t = t + distance; - if (t > tMax) { return false; } - if (distance < 0.000001f) { - (*hitRecord).t = t; - (*hitRecord).position = rayAt(ray, t); - - // Normal - let h = 0.000001f; // replace by an appropriate value - let k = vec2<f32>(1f, -1f); - let outwardNormal = normalize( - k.xyy * mapHexPrismSdf(oc + k.xyy * h, hx, hy, r) + - k.yyx * mapHexPrismSdf(oc + k.yyx * h, hx, hy, r) + - k.yxy * mapHexPrismSdf(oc + k.yxy * h, hx, hy, r) + - k.xxx * mapHexPrismSdf(oc + k.xxx * h, hx, hy, r)); - setFaceNormal(ray, outwardNormal, hitRecord); - return true; +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"emlyC":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Downsample", ()=>Downsample); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Downsample extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; + } + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; } } - return false; + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "downsample.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._isInitialized = true; + } + apply() { + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + this._gl.uniform1i(this._samplerUniform, 0); + } + updateBuffers() { + super.updateBuffers(); + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + } } -fn hitLights(ray: Ray) -> vec3<f32> { - var hit: bool; - for (var i: u32 = 0u; i < arrayLength(&lightBuffer.lights); i = i + 1u) { - // let light = lightBuffer.lights[i]; - switch u32(lightBuffer.lights[i].typeId) { - default: { - hit = hitSphereLight(i, ray); - } - case 2u: { - hit = hitRectLight(i, ray); - } - } - if (hit) { - return lightBuffer.lights[i].color; +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5Fqo6":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Gaussian", ()=>Gaussian); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Gaussian extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; + } + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; } } - - // Background color - // return vec3<f32>(0f, 0f, 0f); - // return vec3<f32>(1f, 1f, 1f); - return uniforms.backgroundColor; - - // TODO: Dome light - // let t = 0.5f * (ray.direction.y + 1f); - // let background = (1f - t) * vec3<f32>(1f, 1f, 1f) + t * vec3<f32>(0.5f, 0.7f, 1.0f); - // return background; -} - -fn hitSphereLight(id: u32, ray: Ray) -> bool { - let sphere = &lightBuffer.lights[id]; - let radius = (*sphere).size.x; - let oc = ray.origin - (*sphere).center; - let b = dot(oc, ray.direction); - let c = dot(oc, oc) - radius * radius; - var h = b * b - c; - if (h < 0f) { return false; } - return b < 0f; // Ensure ray towards light -} - -fn hitRectLight(id: u32, ray: Ray) -> bool { - let rotatedXyRect = &lightBuffer.lights[id]; - let center = (*rotatedXyRect).center; - let rotation = (*rotatedXyRect).rotation; - let invRotation = conjugate(rotation); - var rotatedRay: Ray; - rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; - rotatedRay.direction = rotateQuat(ray.direction, invRotation); - if (dot(rotatedRay.direction, vec3<f32>(0f, 0f, 1f)) < 0f) { return false; } // Directional light - let oc = rotatedRay.origin - center; - let t = -oc.z / rotatedRay.direction.z; - if (t < 0f) { return false; } - let p = oc + t * rotatedRay.direction; - if (abs(p.x) > (*rotatedXyRect).size.x || abs(p.y) > (*rotatedXyRect).size.y) { return false; } - return true; -} - -fn nearZero(v: vec3<f32>) -> bool { - return max(max(abs(v.x), abs(v.y)), abs(v.z)) < 0.00000001f; // 1e-8 -} - -fn scatterLambertian(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { - let scatterDirection = hitRecord.normal + randomUnitVector(seed); - - // Catch degenerate scatter direction - (*ray).direction = select(normalize(scatterDirection), hitRecord.normal, nearZero(scatterDirection)); - - (*ray).origin = hitRecord.position; - (*attenuation) = textureValue(hitRecord); - return true; -} - -fn scatterMetal(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { - (*ray).direction = normalize(reflect((*ray).direction, hitRecord.normal) + materialBuffer.materials[hitRecord.materialId].fuzz * randomInUnitSphere(seed)); - (*ray).origin = hitRecord.position; - (*attenuation) = textureValue(hitRecord); - - // Absorb any rays which fuzz scatters below the surface - return dot((*ray).direction, hitRecord.normal) > 0f; -} - -fn scatterGlossy(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { - // Specular - let material = &materialBuffer.materials[hitRecord.materialId]; - let refractiveIndex = (*material).refractiveIndex; - let refractionRatio = select(refractiveIndex, 1f / refractiveIndex, hitRecord.frontFace); - let cosTheta = min(dot(-(*ray).direction, hitRecord.normal), 1f); - if (reflectance(cosTheta, refractionRatio) * (*material).glossiness > random(seed)) { - (*ray).direction = normalize(reflect((*ray).direction, hitRecord.normal) + (*material).fuzz * randomInUnitSphere(seed)); - (*ray).origin = hitRecord.position; - (*attenuation) = vec3<f32>(1f, 1f, 1f); - - // Absorb any rays which fuzz scatters below the surface - return dot((*ray).direction, hitRecord.normal) > 0f; + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "gaussian.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); } - else { - // Lambertian - return scatterLambertian(ray, hitRecord, attenuation, seed); + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._resolutionUniform = gl.getUniformLocation(this._program, "uResolution"); + this._horizontalUniform = gl.getUniformLocation(this._program, "uHorizontal"); + this._isInitialized = true; + } + apply() { + this._gl.uniform1i(this._samplerUniform, 0); + this._gl.uniform2f(this._resolutionUniform, this.width, this.height); + this._gl.uniform1i(this._horizontalUniform, this.horizontal ? 1 : 0); + } + updateBuffers() { + super.updateBuffers(); + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); } } -fn scatterDielectric(ray: ptr<function, Ray>, hitRecord: ptr<function, HitRecord>, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { - let material = &materialBuffer.materials[(*hitRecord).materialId]; - let refractiveIndex = (*material).refractiveIndex; - // TODO: If still inside another material, use it's refractive index - let refractionRatio = select(refractiveIndex, 1f / refractiveIndex, (*hitRecord).frontFace); - let cosTheta = min(dot(-(*ray).direction, (*hitRecord).normal), 1f); - let sinTheta = sqrt(1f - cosTheta * cosTheta); - let cannotRefract = refractionRatio * sinTheta > 1f; - // if (cannotRefract || reflectance(cosTheta, refractionRatio) > random(seed)) { - if (cannotRefract || reflectance(cosTheta, refractionRatio) * (*material).glossiness > random(seed)) { - (*ray).direction = reflect((*ray).direction, (*hitRecord).normal); +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kBlwc":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DofCombine", ()=>DofCombine); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class DofCombine extends (0, _shaderJs.ShaderBase) { + get texture2D1() { + return this._texture2D1; } - else { - (*ray).direction = refraction((*ray).direction, (*hitRecord).normal, refractionRatio); + set texture2D1(value) { + if (this._texture2D1 != value) { + this._texture2D1 = value; + this._haveTexturesChanged = true; + } } - (*ray).origin = (*hitRecord).position; - // (*attenuation) = vec3<f32>(1f, 1f, 1f); - - (*ray).direction = normalize((*ray).direction + (*material).fuzz * randomInUnitSphere(seed)); - - // TODO: Or use another material, but share scatterDielectric with a boolean flag for attenuation - // if (!all((*material).color == vec3<f32>(1f, 1f, 1f)) && (*hitRecord).id == (*hitRecord).previousId) { - // // Inside reflection or refraction - // // Beer's law - // let d = distance((*hitRecord).previousPosition, (*hitRecord).position); - // (*attenuation) = exp(-d * (*material).color); - // } - // else { - // // Outside reflection or unit color - // (*attenuation) = vec3<f32>(1f, 1f, 1f); - // } - - // Did the ray enter/stay inside? - (*attenuation) = vec3<f32>(1f, 1f, 1f); - // if (dot((*ray).direction, (*hitRecord).normal) < 0f) { - if (dot((*ray).direction, select(-(*hitRecord).normal, (*hitRecord).normal, (*hitRecord).frontFace)) < 0f) { - (*hitRecord).isAbsorbing = true; - (*hitRecord).absorption = (*material).color; - - // If already inside another absorbing dielectric, add to absorption - if ((*hitRecord).previousIsAbsorbing && (*hitRecord).id != (*hitRecord).previousId) { - (*hitRecord).absorption = (*hitRecord).absorption + (*hitRecord).previousAbsorption; + get texture2D2() { + return this._texture2D2; + } + set texture2D2(value) { + if (this._texture2D2 != value) { + this._texture2D2 = value; + this._haveTexturesChanged = true; } } - return true; -} - -fn scatterIsotropic(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { - // TODO: Add a fuzz which defaults to 1 - (*ray).direction = randomUnitVector(seed); - // (*ray).direction = normalize((*ray).direction + materialBuffer.materials[hitRecord.materialId].fuzz * randomInUnitSphere(seed)); - (*ray).origin = hitRecord.position; - (*attenuation) = materialBuffer.materials[hitRecord.materialId].color; - return true; + get texture2D3() { + return this._texture2D3; + } + set texture2D3(value) { + if (this._texture2D3 != value) { + this._texture2D3 = value; + this._haveTexturesChanged = true; + } + } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "dofcombine.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._focusDepthUniform = gl.getUniformLocation(this._program, "uFocusDepth"); + this._apertureUniform = gl.getUniformLocation(this._program, "uAperture"); + this._samplerUniform1 = gl.getUniformLocation(this._program, "uSampler1"); + this._samplerUniform2 = gl.getUniformLocation(this._program, "uSampler2"); + this._samplerUniform3 = gl.getUniformLocation(this._program, "uSampler3"); + this._isInitialized = true; + } + apply() { + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + this._gl.uniform1f(this._focusDepthUniform, this.focusDepth); + this._gl.uniform1f(this._apertureUniform, this.aperture); + this._gl.uniform1i(this._samplerUniform1, 0); + this._gl.uniform1i(this._samplerUniform2, 1); + this._gl.uniform1i(this._samplerUniform3, 2); + } + updateBuffers() { + super.updateBuffers(); + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D1); + this._gl.activeTexture(this._gl.TEXTURE1); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D2); + this._gl.activeTexture(this._gl.TEXTURE2); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D3); + } } -fn scatterVarnish(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { - // Front-face only (no internal reflection or refraction) - let material = &materialBuffer.materials[hitRecord.materialId]; - if (hitRecord.frontFace && (*material).glossiness > random(seed)) { - let refractiveIndex = (*material).refractiveIndex; - let refractionRatio = select(refractiveIndex, 1f / refractiveIndex, hitRecord.frontFace); - let cosTheta = min(dot(-(*ray).direction, hitRecord.normal), 1f); - let sinTheta = sqrt(1f - cosTheta * cosTheta); - let cannotRefract = refractionRatio * sinTheta > 1f; - if (cannotRefract || reflectance(cosTheta, refractionRatio) > random(seed)) { - (*ray).direction = reflect((*ray).direction, hitRecord.normal); - } - else { - // Refraction improves definition at edges and deepens color on faces - (*ray).direction = refraction((*ray).direction, hitRecord.normal, refractionRatio); +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9Vj9y":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Fxaa", ()=>Fxaa); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Fxaa extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; + } + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; } - (*ray).direction = normalize((*ray).direction + (*material).fuzz * randomInUnitSphere(seed)); } - // Pass-through - (*ray).origin = hitRecord.position; - (*attenuation) = vec3<f32>(1f, 1f, 1f); - return true; + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "fxaa.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._viewportUniform = gl.getUniformLocation(this._program, "uViewport"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._isInitialized = true; + } + apply() { + this._gl.uniform4f(this._viewportUniform, this.left, this.top, this.width, this.height); + this._gl.uniform1i(this._samplerUniform, 0); + } + updateBuffers() { + super.updateBuffers(); + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + } } -fn textureValue(hitRecord: HitRecord) -> vec3<f32> { - let textureId = materialBuffer.materials[hitRecord.materialId].textureId; - let texture = &textureBuffer.textures[u32(textureId)]; - switch u32((*texture).typeId) { - // No texture - default: { - return vec3<f32>(); +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3saQu":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Bright", ()=>Bright); +var _shaderJs = require("./shader.js"); +var _vertexJs = require("../../../vertex.js"); +class Bright extends (0, _shaderJs.ShaderBase) { + get texture2D() { + return this._texture2D; + } + set texture2D(value) { + if (this._texture2D != value) { + this._texture2D = value; + this._haveTexturesChanged = true; } - // Solid color - case 1u: { - return (*texture).color0; + } + initializeContext(gl) { + super.initializeContext(gl); + if (this._isLoaded) this._initializeShader(gl, this._vsSource, this._fsSource); + else this._shaderFromFile("simple.vertex.fx", "bright.fragment.fx", (vsSource, fsSource)=>{ + this._vsSource = vsSource; + this._fsSource = fsSource; + this._isLoaded = true; + this._initializeShader(gl, vsSource, fsSource); + }); + } + _initializeShader(gl, vsSource, fsSource) { + const vs = this._compileShader(vsSource, gl.VERTEX_SHADER); + const fs = this._compileShader(fsSource, gl.FRAGMENT_SHADER); + this._program = this._createProgram(vs, fs); + this._positionAttribute = gl.getAttribLocation(this._program, "aPosition"); + this._samplerUniform = gl.getUniformLocation(this._program, "uSampler"); + this._resolutionUniform = gl.getUniformLocation(this._program, "uResolution"); + this._isInitialized = true; + } + apply() { + this._gl.uniform1i(this._samplerUniform, 0); + this._gl.uniform2f(this._resolutionUniform, this.width, this.height); + } + updateBuffers() { + super.updateBuffers(); + super.updateBuffers(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.vertexAttribPointer(this._positionAttribute, 3, this._gl.FLOAT, false, (0, _vertexJs.PositionVertex).SIZE_BYTES, 0); + this._gl.enableVertexAttribArray(this._positionAttribute); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + } + updateTextures() { + super.updateTextures(); + this._gl.activeTexture(this._gl.TEXTURE0); + this._gl.bindTexture(this._gl.TEXTURE_2D, this._texture2D); + } +} - // Debug uv - // return vec3<f32>(hitRecord.uv, 0f); - } - // Image - case 2u: { - // Sample in linear space - return textureSampleLevel(backgroundTexture, linearSampler, hitRecord.uv, 0f).rgb; - } - // Checker - case 4u: { - let q = trunc((hitRecord.uv + (*texture).offset) / (*texture).size0.xy); - return select((*texture).color0, (*texture).color1, (q.x + q.y) % 2f > 0f); - } - // Grid - case 5u: { - let size0 = (*texture).size0; - let size1 = (*texture).size1; - let clip = (*texture).clip; - // TODO: Optimize - if (hitRecord.uv.x < clip.x || hitRecord.uv.y < clip.y || hitRecord.uv.x > clip.z || hitRecord.uv.y > clip.w) { - return (*texture).color1; - } - let uv = hitRecord.uv + (*texture).offset; - var d = uv / size0.xy; - // TODO: Use mod - d = abs(d - round(d)) * size0.xy; - if (d.x < size1.x || d.y < size1.y) { - return (*texture).color0; +},{"./shader.js":"f1nVl","../../../vertex.js":"4J2YE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ewMaB":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cartesian2dVisual", ()=>Cartesian2dVisual); +var _axesJs = require("./axes.js"); +var _mainJs = require("../../../../main.js"); +var _quadJs = require("../../../../meshes/quad.js"); +class Cartesian2dVisual extends (0, _axesJs.AxesVisualBase) { + get isInitialized() { + return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; + } + constructor(core, main, cartesian2dAxes){ + super(core); + this._main = main; + this._axes = cartesian2dAxes; + this._axes.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; + } + initializeContext(gl) { + super.initializeContext(gl); + const axes = this._axes; + if (!axes.isInitialized) axes.initialize(); + if (axes.gridVertices) this._createGridBuffers(); + if (axes.textVertices) this._createTextBuffers(); + this._isInitialized = true; + } + _createGridBuffers() { + const axes = this._axes; + this._gridVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); + this._gridIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); + this._gridBufferSize = axes.gridVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers created`); + } + _createTextBuffers() { + const axes = this._axes; + this._textVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); + this._textIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); + this._textBufferSize = axes.textVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers created`); + } + update(elapsedTime) { + if (this._hasChanged) { + this._hasChanged = false; + const axes = this._axes; + if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual grid buffers updated`); } + if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); else { - d = uv / size0.zw; - // TODO: Use mod - d = abs(d - round(d)) * size0.zw; - if (d.x < size1.z || d.y < size1.w) { - return (*texture).color0; - } - return (*texture).color1; + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian2d visual text buffers updated`); } + this._main.shaderResources.currentProgram = null; } } -} - -fn rayColor(ray: ptr<function, Ray>, seed: ptr<function, u32>) -> vec3<f32> { - let maxDepth = 16u; // TODO: Pass as uniform - var depth = 0u; - var color = vec3<f32>(1f, 1f, 1f); - var attenuation = vec3<f32>(1f, 1f, 1f); - var emitted = vec3<f32>(0f, 0f, 0f); - var hitRecord: HitRecord; - hitRecord.id = 4294967295; // -1 as u32 - var scatter: bool; - loop { - // if (hitWorld(*ray, 0.00001f, 100f, &hitRecord, seed)) { - if (hitBVH(*ray, 0.00001f, 100f, &hitRecord, seed)) { - // Debug normal - // color = hitRecord.normal * 0.5f + vec3<f32>(0.5f, 0.5f, 0.5f); - // return color; - - // Depth - depth = depth + 1u; - if (depth == maxDepth) { - // Exceeded bounce limit, no more light is gathered - return vec3<f32>(0f, 0f, 0f); - } - - // Bounce - // TODO: If last hit was travelling INTO a dielectric, use last hit position to calculate distance - // and apply Beer's law to attenuate the light. Modify the dielectric scattering function to - // recrord travelling INTO a dielectric based on hitRecord normal and ray direction. - // Reset this flag each time here. - if (hitRecord.previousIsAbsorbing) { - // Beer's law - let d = distance(hitRecord.previousPosition, hitRecord.position); - color = color * exp(-d * hitRecord.previousAbsorption); - } - // Reset absorption - hitRecord.isAbsorbing = false; - hitRecord.absorption = vec3<f32>(0f, 0f, 0f); - switch u32(materialBuffer.materials[hitRecord.materialId].typeId) { - default: { - scatter = false; - } - case 0u: { - scatter = scatterLambertian(ray, hitRecord, &attenuation, seed); - } - case 1u: { - scatter = scatterMetal(ray, hitRecord, &attenuation, seed); - } - case 2u: { - scatter = scatterDielectric(ray, &hitRecord, &attenuation, seed); - } - case 3u: { - scatter = scatterGlossy(ray, hitRecord, &attenuation, seed); - } - case 4u: { - // Diffuse light - scatter = false; - emitted = materialBuffer.materials[hitRecord.materialId].color; - } - case 5u: { - scatter = scatterIsotropic(ray, hitRecord, &attenuation, seed); + _renderText() { + const shader = this._main.sdfTextShader; + const shaderResources = this._main.shaderResources; + const axes = this._axes; + const fontVisual = this._main.fonts[axes.font.name]; + shader.vertexBuffer = this._textVertexBuffer; + shader.indexBuffer = this._textIndexBuffer; + shader.texture2D = fontVisual.texture; + shader.prepare(); + shader.buffer = fontVisual.font.edgeValue / 0xff; + shader.gamma = axes.gamma; + shader.borderWidth = axes.textBorderWidth; + shader.color = axes.textColor || this._core.config.axesTextColor; + shader.hoverColor = axes.textHoverColor || this._core.config.axesTextHoverColor; + shader.borderColor = axes.textBorderColor || this._core.config.textBorderColor; + shader.pickedIdColor = this.pickedIdColor; + shader.apply(); + let indexCount, indexOffset; + for(let axisId = 0; axisId < 2; axisId++){ + const orientation = axes.getLabelOrientation(axisId); + for(let edge = 0; edge < 2; edge++){ + const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; + if (axes.isEdgeVisible[edgeId]) { + if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { + indexCount = axes.getAxesLeftToRightIndexCount(axisId); + indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); + } else { + indexCount = axes.getAxesRightToLeftIndexCount(axisId); + indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); + } + if (indexCount > 0) { + shader.mMatrix = axes.getLabelMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + indexCount = axes.getTitleIndexCount(axisId); + if (indexCount > 0) { + indexOffset = axes.getTitleIndexOffset(axisId); + shader.mMatrix = axes.getTitleMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } } - case 6u: { - scatter = scatterVarnish(ray, hitRecord, &attenuation, seed); + indexCount = axes.getHeadingIndexCount(axisId); + if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { + indexOffset = axes.getHeadingIndexOffset(axisId); + shader.mMatrix = axes.getHeadingMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } } } - - if (scatter) { - // Attenuate - color = color * attenuation; - } - else { - // Emit - return color * emitted; - } } - else { - // return color; - - // No hits - if (depth > 0u) { // Hide lights, background - return hitLights(*ray) * color; - } - else { - // TODO: Background color - return vec3<f32>(0f, 0f, 0f); + } + _renderGrid() { + const gridShader = this._main.gridShader; + const axes = this._axes; + gridShader.vertexBuffer = this._gridVertexBuffer; + gridShader.indexBuffer = this._gridIndexBuffer; + gridShader.prepare(); + gridShader.majorThickness = axes.gridMajorThickness; + gridShader.minorThickness = axes.gridMinorThickness; + gridShader.zeroThickness = axes.gridZeroThickness; + gridShader.backgroundColor = axes.gridBackgroundColor || this._core.config.axesGridBackgroundColor; + gridShader.highlightColor = axes.gridHighlightColor || this._core.config.axesGridHighlightColor; + gridShader.majorColor = axes.gridMajorColor || this._core.config.axesGridMajorColor; + gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; + gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; + gridShader.pickedIdColor = this.pickedIdColor; + gridShader.apply(); + for(let axisId = 0; axisId < 2; axisId++)if (axes.arePickDivisionsVisible[axisId]) { + const gridTicksScale = axes.getGridTicksScale(axisId); + const width = gridTicksScale[0]; + const height = gridTicksScale[1]; + gridShader.zero = axes.getGridTicksZero(axisId); + gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); + for(let edge = 0; edge < 2; edge++){ + const edgeId = (0, _quadJs.Quad).AXIS_EDGES[axisId][edge]; + if (axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); } - - // Background - // let t = 0.5f * ((*ray).direction.y + 1f); - // let background = (1f - t) * vec3<f32>(1f, 1f, 1f) + t * vec3<f32>(0.5f, 0.7f, 1.0f); - // return color * background; } + this._gl.disable(this._gl.CULL_FACE); + const size = axes.size; + const axisId2 = 0; + const axisId3 = 1; + const width = size[axisId2]; + const height = size[axisId3]; + gridShader.zero = axes.gridFaceZero; + gridShader.minorGridlines = axes.gridFaceMinorGridlines; + for(let face = 0; face < 2; face++){ + const faceId = face; + if (axes.getIsForwardFace(faceId)) this._renderGridFace(faceId, width, height); + } + this._gl.enable(this._gl.CULL_FACE); } -} - -// TODO: Try writing color directly using var outputTexture : texture_storage_2d<rgb32f,read_write>; -// textureStore(outputTexture, uv, vec3<f32>(1f, 1f, 1f)); -@group(0) @binding(0) var<storage, read_write> outputColorBuffer: ColorBuffer; -@group(0) @binding(1) var<uniform> uniforms: Uniforms; -@group(0) @binding(2) var<storage, read> hittableBuffer: HittableBuffer; -@group(0) @binding(3) var<storage, read> materialBuffer: MaterialBuffer; -@group(0) @binding(4) var<storage, read> textureBuffer: TextureBuffer; -@group(0) @binding(5) var<storage, read> lightBuffer: LightBuffer; -@group(0) @binding(6) var<storage, read> linearBVHNodeBuffer: LinearBVHNodeBuffer; -@group(0) @binding(7) var linearSampler: sampler; -@group(0) @binding(8) var fontTexture: texture_2d<f32>; -@group(0) @binding(9) var backgroundTexture: texture_2d<f32>; -@group(0) @binding(10) var atlasTexture: texture_2d<f32>; - -@compute @workgroup_size(256, 1, 1) -fn clear(@builtin(global_invocation_id) globalId : vec3<u32>) { - let index = globalId.x * 3u; - outputColorBuffer.values[index] = 0f; - outputColorBuffer.values[index + 1u] = 0f; - outputColorBuffer.values[index + 2u] = 0f; -} - -// @builtin(local_invocation_id) localId : vec3<u32>, -// @builtin(num_workgroups) numWorkgroups : vec3<u32>, -// @builtin(workgroup_id) workgroupId : vec3<u32> -// TODO: Use workgroup dimensions xy to get position directly froem globalId -// Then store using textureStore -// Check within bounds due to overdispatching - -@compute @workgroup_size(256, 1, 1) -fn main(@builtin(global_invocation_id) globalId : vec3<u32>) { - let imageSize = vec2<f32>(uniforms.width, uniforms.height); - - // Tex coords [0,1] - // let id = f32(globalId.x); - // // TODO: Divide by (imageSize.x - 1) - // let v = floor(id / imageSize.x); - // let u = (id - v * imageSize.x); - // let uv = vec2<f32>(u, v); - // let texCoord = uv / imageSize; - - // Pixel coords ([0,width-1], [0,height-1]) - let id = f32(globalId.x); - let pixelY = floor(id / imageSize.x); - let pixelX = id - pixelY * imageSize.x; - - // Tex coords ([0,1], [0,1]) - let texCoord = vec2<f32>(pixelX / (imageSize.x - 1f), pixelY / (imageSize.y - 1f)); - - // Camera - var camera: Camera; - camera.aperture = uniforms.aperture; - camera.aspectRatio = uniforms.width / uniforms.height; - camera.fov = uniforms.fov; - camera.viewportHeight = 2f * tan(camera.fov / 2f); - camera.viewportWidth = camera.aspectRatio * camera.viewportHeight; - camera.origin = uniforms.position; - camera.lookAt = uniforms.lookAt; - camera.u = uniforms.right; - camera.v = uniforms.up; - camera.w = uniforms.forward; - let focusDistance = dot(camera.w, camera.origin - camera.lookAt); - camera.horizontal = camera.u * camera.viewportWidth * focusDistance; - camera.vertical = camera.v * camera.viewportHeight * focusDistance; - camera.lowerLeftCorner = camera.origin - camera.horizontal / 2f + camera.vertical / 2f - camera.w * focusDistance; - camera.time0 = uniforms.time0; - camera.time1 = uniforms.time1; - - // Frame seed - var frameSeed = u32(uniforms.seed); - let raysPerFrame = 1u; - var color = vec3<f32>(0f, 0f, 0f); - var seed: u32; - - for (var i = 0u; i < raysPerFrame; i = i + 1u) { - // Random number generator - seed = u32(pixelY * imageSize.x + pixelX) + frameSeed * u32(imageSize.x * imageSize.y); - - // Sample position (sub-pixel sampling has same seed, but only sampled once per frame) - let samplePos = vec2<f32>(texCoord) + vec2<f32>(random(&seed), random(&seed)) / imageSize; - - // Ray - var ray = getCameraRay(camera, &seed, samplePos); - - // Color [0,1] - // let color = rayColor(&ray, &seed); - // let color = clamp(rayColor(&ray, &seed), vec3<f32>(0f, 0f, 0f), vec3<f32>(1f, 1f, 1f)); - // let color = clamp(rayColor(&ray, &seed), vec3<f32>(0f, 0f, 0f), vec3<f32>(10f, 10f, 10f)); // Max light - color += clamp(rayColor(&ray, &seed), vec3<f32>(0f, 0f, 0f), vec3<f32>(10f, 10f, 10f)); // Max light - - // Next frame - frameSeed = frameSeed + 1u; - } - let index = globalId.x * 3u; - outputColorBuffer.values[index + 0u] = outputColorBuffer.values[index + 0u] + color.x; - outputColorBuffer.values[index + 1u] = outputColorBuffer.values[index + 1u] + color.y; - outputColorBuffer.values[index + 2u] = outputColorBuffer.values[index + 2u] + color.z; -}`; -class ComputeUniformBufferData extends Float32Array { - constructor(){ - super(ComputeUniformBufferData.SIZE); - this.POSITION_OFFSET = 0; - this.WIDTH_OFFSET = 3; - this.RIGHT_OFFSET = 4; - this.HEIGHT_OFFSET = 7; - this.UP_OFFSET = 8; - this.SEED_OFFSET = 11; - this.FORWARD_OFFSET = 12; - this.FOV_OFFSET = 15; - this.LOOKAT_OFFSET = 16; - this.APERTURE_OFFSET = 19; - this.BACKGROUND_COLOR_OFFSET = 20; - this.TIME0_OFFSET = 23; - this.TIME1_OFFSET = 24; - } - getWidth() { - return this[this.WIDTH_OFFSET]; - } - setWidth(value) { - this[this.WIDTH_OFFSET] = value; - } - getHeight() { - return this[this.HEIGHT_OFFSET]; - } - setHeight(value) { - this[this.HEIGHT_OFFSET] = value; - } - getSeed() { - return this[this.SEED_OFFSET]; - } - setSeed(value) { - this[this.SEED_OFFSET] = value; - } - getFieldOfView() { - return this[this.FOV_OFFSET]; - } - setFieldOfView(value) { - this[this.FOV_OFFSET] = value; - } - getAperture() { - return this[this.APERTURE_OFFSET]; - } - setAperture(value) { - this[this.APERTURE_OFFSET] = value; - } - getPosition(value) { - (0, _glMatrix.vec3).set(value, this[this.POSITION_OFFSET], this[this.POSITION_OFFSET + 1], this[this.POSITION_OFFSET + 2]); - } - setPosition(value) { - this[this.POSITION_OFFSET] = value[0]; - this[this.POSITION_OFFSET + 1] = value[1]; - this[this.POSITION_OFFSET + 2] = value[2]; + _renderGridTicks(axisId, edgeId, width, height) { + const gridShader = this._main.gridShader; + const shaderResources = this._main.shaderResources; + const axes = this._axes; + gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); + gridShader.faceWidth = width; + gridShader.faceHeight = height; + gridShader.ApplyFace(); + gridShader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + gridShader.vMatrix = this.vMatrices[viewport]; + gridShader.pMatrix = this.pMatrices[viewport]; + gridShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); + } + if (this.isPickingEnabled && axes.isDivisionPickingEnabled[axisId]) { + gridShader.isPickShader = true; + gridShader.vMatrix = this.pickVMatrix; + gridShader.pMatrix = this.pickPMatrix; + gridShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); + } } - getRight(value) { - (0, _glMatrix.vec3).set(value, this[this.RIGHT_OFFSET], this[this.RIGHT_OFFSET + 1], this[this.RIGHT_OFFSET + 2]); + _renderGridFace(faceId, width, height) { + const gridShader = this._main.gridShader; + const shaderResources = this._main.shaderResources; + const axes = this._axes; + gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); + gridShader.faceWidth = width; + gridShader.faceHeight = height; + gridShader.ApplyFace(); + gridShader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + gridShader.vMatrix = this.vMatrices[viewport]; + gridShader.pMatrix = this.pMatrices[viewport]; + gridShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); + } + if (this.isPickingEnabled && axes.isGridPickingEnabled) { + gridShader.isPickShader = true; + gridShader.vMatrix = this.pickVMatrix; + gridShader.pMatrix = this.pickPMatrix; + gridShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); + } } - setRight(value) { - this[this.RIGHT_OFFSET] = value[0]; - this[this.RIGHT_OFFSET + 1] = value[1]; - this[this.RIGHT_OFFSET + 2] = value[2]; +} + +},{"./axes.js":"fFTxg","../../../../main.js":"f421K","../../../../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fFTxg":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AxesVisualBase", ()=>AxesVisualBase); +class AxesVisualBase { + get isInitialized() { + return this._isInitialized; } - getUp(value) { - (0, _glMatrix.vec3).set(value, this[this.UP_OFFSET], this[this.UP_OFFSET + 1], this[this.UP_OFFSET + 2]); + get axes() { + return this._axes; } - setUp(value) { - this[this.UP_OFFSET] = value[0]; - this[this.UP_OFFSET + 1] = value[1]; - this[this.UP_OFFSET + 2] = value[2]; + constructor(core){ + this._core = core; + this.isVisible = true; } - getForward(value) { - (0, _glMatrix.vec3).set(value, this[this.FORWARD_OFFSET], this[this.FORWARD_OFFSET + 1], this[this.FORWARD_OFFSET + 2]); + initializeContext(gl) { + this._gl = gl; } - setForward(value) { - this[this.FORWARD_OFFSET] = value[0]; - this[this.FORWARD_OFFSET + 1] = value[1]; - this[this.FORWARD_OFFSET + 2] = value[2]; + update(elapsedTime) {} + render(elapsedTime, xrFrame) { + if (this.isInitialized) { + this._renderGrid(); + this._renderText(); + } } - getLookAt(value) { - (0, _glMatrix.vec3).set(value, this[this.LOOKAT_OFFSET], this[this.LOOKAT_OFFSET + 1], this[this.LOOKAT_OFFSET + 2]); + _renderGrid() {} + _renderText() {} +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h51do":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Cartesian3dVisual", ()=>Cartesian3dVisual); +var _axesJs = require("./axes.js"); +var _mainJs = require("../../../../main.js"); +var _cubeJs = require("../../../../meshes/cube.js"); +class Cartesian3dVisual extends (0, _axesJs.AxesVisualBase) { + get isInitialized() { + return this._isInitialized && this._main.gridShader.isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._axes.font.name].isInitialized; } - setLookAt(value) { - this[this.LOOKAT_OFFSET] = value[0]; - this[this.LOOKAT_OFFSET + 1] = value[1]; - this[this.LOOKAT_OFFSET + 2] = value[2]; + constructor(core, main, cartesian3dAxes){ + super(core); + this._main = main; + this._axes = cartesian3dAxes; + this._axes.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; } - getBackgroundColor(value) { - (0, _glMatrix.vec3).set(value, this[this.BACKGROUND_COLOR_OFFSET], this[this.BACKGROUND_COLOR_OFFSET + 1], this[this.BACKGROUND_COLOR_OFFSET + 2]); + initializeContext(gl) { + super.initializeContext(gl); + const axes = this._axes; + if (!axes.isInitialized) axes.initialize(); + if (axes.gridVertices) this._createGridBuffers(); + if (axes.textVertices) this._createTextBuffers(); + this._isInitialized = true; } - setBackgroundColor(value) { - this[this.BACKGROUND_COLOR_OFFSET] = value[0]; - this[this.BACKGROUND_COLOR_OFFSET + 1] = value[1]; - this[this.BACKGROUND_COLOR_OFFSET + 2] = value[2]; + _createGridBuffers() { + const axes = this._axes; + this._gridVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.gridVertices, this._gl.STATIC_DRAW); + this._gridIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.gridIndices, this._gl.STATIC_DRAW); + this._gridBufferSize = axes.gridVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers created`); } - getTime0() { - return this[this.TIME0_OFFSET]; + _createTextBuffers() { + const axes = this._axes; + this._textVertexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferData(this._gl.ARRAY_BUFFER, axes.textVertices, this._gl.STATIC_DRAW); + this._textIndexBuffer = this._gl.createBuffer(); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, axes.textIndices, this._gl.STATIC_DRAW); + this._textBufferSize = axes.textVertices.byteLength; + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers created`); } - setTime0(value) { - this[this.TIME0_OFFSET] = value; + update(elapsedTime) { + if (this._hasChanged) { + this._hasChanged = false; + const axes = this._axes; + if (!this._gridVertexBuffer || axes.gridVertices.byteLength > this._gridBufferSize) this._createGridBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._gridVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.gridVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._gridIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.gridIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual grid buffers updated`); + } + if (!this._textVertexBuffer || axes.textVertices.byteLength > this._textBufferSize) this._createTextBuffers(); + else { + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._textVertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, axes.textVertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._textIndexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, axes.textIndices); + this._core.log.write((0, _mainJs.LogLevel).info, `cartesian3d visual text buffers updated`); + } + this._main.shaderResources.currentProgram = null; + } } - getTime1() { - return this[this.TIME1_OFFSET]; - } - setTime1(value) { - this[this.TIME1_OFFSET] = value; - } -} -ComputeUniformBufferData.SIZE = 28; - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3e1eA":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FullscreenQuadWgsl", ()=>FullscreenQuadWgsl); -parcelHelpers.export(exports, "FullscreenQuadUniformBufferData", ()=>FullscreenQuadUniformBufferData); -const FullscreenQuadWgsl = ` -const GAMMA = vec3<f32>(0.45454545f); // 1 / 2.2 - -struct ColorData { - data : array<f32>, -} - - // offest align size -struct Uniforms { // ------------------------------ - width: f32, // 0 4 4 - height: f32, // 4 4 4 - samplesPerPixel: f32, // 8 4 4 - exposure: f32, // 12 4 4 -} // ------------------------------ - // 4 16 - -@group(0) @binding(0) var<uniform> uniforms : Uniforms; -@group(0) @binding(1) var<storage, read> colorBuffer : ColorData; - -struct VertexOutput { - @builtin(position) Position : vec4<f32>, -}; - -@vertex -fn vert_main(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput { - var pos = array<vec2<f32>, 6>( - vec2<f32>( 1f, 1f), - vec2<f32>( 1f, -1f), - vec2<f32>(-1f, -1f), - vec2<f32>( 1f, 1f), - vec2<f32>(-1f, -1f), - vec2<f32>(-1f, 1f)); - var output : VertexOutput; - output.Position = vec4<f32>(pos[vertexIndex], 0f, 1f); - return output; -} - -@fragment -fn frag_main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { - let x = floor(coord.x); - let y = floor(coord.y); - let index = u32(x + y * uniforms.width) * 3u; - // [0,1] - var color = vec3<f32>(colorBuffer.data[index + 0u], colorBuffer.data[index + 1u], colorBuffer.data[index + 2u]) / uniforms.samplesPerPixel; - - // Simple tone-mapping from HDR to LDR - // color = color * uniforms.exposure; - // color = color / (color + vec3<f32>(1f, 1f, 1f)); - - // Gamma-correct - return vec4<f32>(pow(color, GAMMA), 1f); -}`; -class FullscreenQuadUniformBufferData extends Float32Array { - constructor(){ - super(FullscreenQuadUniformBufferData.SIZE); - this.WIDTH_OFFSET = 0; - this.HEIGHT_OFFSET = 1; - this.SPP_OFFSET = 2; - this.EXPOSURE_OFFSET = 3; - } - getWidth() { - return this[this.WIDTH_OFFSET]; - } - setWidth(value) { - this[this.WIDTH_OFFSET] = value; - } - getHeight() { - return this[this.HEIGHT_OFFSET]; - } - setHeight(value) { - this[this.HEIGHT_OFFSET] = value; - } - getSamplesPerPixel() { - return this[this.SPP_OFFSET]; + _renderText() { + const axes = this._axes; + const shader = this._main.sdfTextShader; + const shaderResources = this._main.shaderResources; + const fontVisual = this._main.fonts[axes.font.name]; + shader.vertexBuffer = this._textVertexBuffer; + shader.indexBuffer = this._textIndexBuffer; + shader.texture2D = fontVisual.texture; + shader.prepare(); + shader.buffer = fontVisual.font.edgeValue / 0xff; + shader.gamma = axes.gamma; + shader.borderWidth = axes.textBorderWidth; + shader.color = axes.textColor || this._core.config.axesTextColor; + shader.hoverColor = axes.textHoverColor || this._core.config.axesTextHoverColor; + shader.borderColor = axes.textBorderColor || this._core.config.textBorderColor; + shader.pickedIdColor = this.pickedIdColor; + shader.apply(); + let indexCount, indexOffset; + for(let axisId = 0; axisId < 3; axisId++){ + const orientation = axes.getLabelOrientation(axisId); + for(let edge = 0; edge < 4; edge++){ + const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; + if (axes.getIsOutsideEdge(edgeId)) { + if (axes.isEdgeVisible[edgeId]) { + if (orientation == (0, _mainJs.AxesTextOrientation).parallel && axes.getIsLeftToRightHorizontal(edgeId) || orientation == (0, _mainJs.AxesTextOrientation).perpendicular && axes.getIsLeftToRightVertical(edgeId)) { + indexCount = axes.getAxesLeftToRightIndexCount(axisId); + indexOffset = axes.getAxesLeftToRightIndexOffset(axisId); + } else { + indexCount = axes.getAxesRightToLeftIndexCount(axisId); + indexOffset = axes.getAxesRightToLeftIndexOffset(axisId); + } + if (indexCount > 0) { + shader.mMatrix = axes.getLabelMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isLabelPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + indexCount = axes.getTitleIndexCount(axisId); + if (indexCount > 0) { + indexOffset = axes.getTitleIndexOffset(axisId); + shader.mMatrix = axes.getTitleMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isTitlePickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + } + indexCount = axes.getHeadingIndexCount(axisId); + if (indexCount > 0 && axes.isHeadingVisible[edgeId]) { + indexOffset = axes.getHeadingIndexOffset(axisId); + shader.mMatrix = axes.getHeadingMMatrix(edgeId); + shader.applyModel(); + shader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + if (this.isPickingEnabled && axes.isHeadingPickingEnabled[axisId]) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, indexOffset * 2); + } + } + } + } + } } - setSamplesPerPixel(value) { - this[this.SPP_OFFSET] = value; + _renderGrid() { + const axes = this._axes; + const gridShader = this._main.gridShader; + gridShader.vertexBuffer = this._gridVertexBuffer; + gridShader.indexBuffer = this._gridIndexBuffer; + gridShader.prepare(); + gridShader.majorThickness = axes.gridMajorThickness; + gridShader.minorThickness = axes.gridMinorThickness; + gridShader.zeroThickness = axes.gridZeroThickness; + gridShader.backgroundColor = axes.gridBackgroundColor || this._core.config.axesGridBackgroundColor; + gridShader.highlightColor = axes.gridHighlightColor || this._core.config.axesGridHighlightColor; + gridShader.majorColor = axes.gridMajorColor || this._core.config.axesGridMajorColor; + gridShader.minorColor = axes.gridMinorColor || this._core.config.axesGridMinorColor; + gridShader.zeroColor = axes.gridZeroColor || this._core.config.axesGridZeroColor; + gridShader.pickedIdColor = this.pickedIdColor; + gridShader.apply(); + for(let axisId = 0; axisId < 3; axisId++)if (axes.arePickDivisionsVisible[axisId]) { + const gridTicksScale = axes.getGridTicksScale(axisId); + const width = gridTicksScale[0]; + const height = gridTicksScale[1]; + gridShader.zero = axes.getGridTicksZero(axisId); + gridShader.minorGridlines = axes.getGridTicksMinorGridlines(axisId); + for(let edge = 0; edge < 4; edge++){ + const edgeId = (0, _cubeJs.Cube).AXIS_EDGES[axisId][edge]; + if (axes.getIsOutsideEdge(edgeId) && axes.isEdgeVisible[edgeId]) this._renderGridTicks(axisId, edgeId, width, height); + } + } + this._gl.disable(this._gl.CULL_FACE); + const size = axes.size; + for(let axisId = 0; axisId < 3; axisId++)if (axes.areFacesVisible[axisId]) { + const axisId2 = axisId == 0 ? 1 : 0; + const axisId3 = axisId == 2 ? 1 : 2; + const width = size[axisId2]; + const height = size[axisId3]; + gridShader.zero = axes.getGridFaceZero(axisId); + gridShader.minorGridlines = axes.getGridFaceMinorGridlines(axisId); + for(let face = 0; face < 2; face++){ + const faceId = (0, _cubeJs.Cube).AXIS_FACES[axisId][face]; + if (axes.getIsForwardFace(faceId) && axes.isFaceVisible[faceId]) this._renderGridFace(faceId, width, height); + } + } + this._gl.enable(this._gl.CULL_FACE); } - getExposure() { - return this[this.EXPOSURE_OFFSET]; + _renderGridTicks(axisId, edgeId, width, height) { + const axes = this._axes; + const gridShader = this._main.gridShader; + const shaderResources = this._main.shaderResources; + gridShader.mMatrix = axes.getGridTicksMMatrix(edgeId); + gridShader.faceWidth = width; + gridShader.faceHeight = height; + gridShader.ApplyFace(); + gridShader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + gridShader.vMatrix = this.vMatrices[viewport]; + gridShader.pMatrix = this.pMatrices[viewport]; + gridShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); + } + if (this.isPickingEnabled && axes.isDivisionPickingEnabled[axisId]) { + gridShader.isPickShader = true; + gridShader.vMatrix = this.pickVMatrix; + gridShader.pMatrix = this.pickPMatrix; + gridShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridTicksIndexCount(axisId), this._gl.UNSIGNED_SHORT, axes.getGridTicksIndexOffset(axisId) * 2); + } } - setExposure(value) { - this[this.EXPOSURE_OFFSET] = value; + _renderGridFace(faceId, width, height) { + const axes = this._axes; + const gridShader = this._main.gridShader; + const shaderResources = this._main.shaderResources; + gridShader.mMatrix = axes.getGridFaceMMatrix(faceId); + gridShader.faceWidth = width; + gridShader.faceHeight = height; + gridShader.ApplyFace(); + gridShader.isPickShader = false; + shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + gridShader.vMatrix = this.vMatrices[viewport]; + gridShader.pMatrix = this.pMatrices[viewport]; + gridShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); + } + if (this.isPickingEnabled && axes.isGridPickingEnabled) { + gridShader.isPickShader = true; + gridShader.vMatrix = this.pickVMatrix; + gridShader.pMatrix = this.pickPMatrix; + gridShader.applyView(); + shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, axes.getGridFaceIndexCount(faceId), this._gl.UNSIGNED_SHORT, axes.getGridFaceIndexOffset(faceId) * 2); + } } } -FullscreenQuadUniformBufferData.SIZE = 4; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"rJ9Fm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SplitMethod", ()=>SplitMethod); -parcelHelpers.export(exports, "LinearBVHNode", ()=>LinearBVHNode); -parcelHelpers.export(exports, "BVHAccel", ()=>BVHAccel); -parcelHelpers.export(exports, "LinearBVHNodeBufferData", ()=>LinearBVHNodeBufferData); +},{"./axes.js":"fFTxg","../../../../main.js":"f421K","../../../../meshes/cube.js":"79I5N","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8IUfH":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); +var _textureJs = require("../../helpers/texture.js"); var _mainJs = require("../../main.js"); -var _aabbJs = require("./aabb.js"); -const SplitMethod = { - middle: "middle", - equalCounts: "equalCounts", - sah: "sah" -}; -class BVHPrimitiveInfo { - get primitiveNumber() { - return this._primitiveNumber; - } - get bounds() { - return this._bounds; +class FontVisual { + get isInitialized() { + return this._isInitialized; } - get centroid() { - return this._centroid; + get font() { + return this._font; } - constructor(primitiveNumber, bounds){ - this._primitiveNumber = primitiveNumber; - this._bounds = bounds; - this._centroid = (0, _glMatrix.vec3).create(); - bounds.centroid(this._centroid); + constructor(core, font){ + this._core = core; + this._font = font; + font.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; } -} -class BVHBuildNode { - get bounds() { - return this._bounds; + initializeContext(gl) { + this._gl = gl; + this._isInitialized = true; + if (this._font.count > 0) this._hasChanged = true; } - get left() { - return this._left; + update() { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + this.texture = (0, _textureJs.TextureHelper).fromImage(this._gl, this._font.atlas.imageData, false, this._gl.LINEAR); + this._core.log.write((0, _mainJs.LogLevel).info, `${this._font.name} texture updated`); + } } - get right() { - return this._right; +} + +},{"../../helpers/texture.js":"bUoBU","../../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lrIn9":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LabelVisual", ()=>LabelVisual); +parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); +var _glMatrix = require("gl-matrix"); +class LabelVisualBase { + get isInitialized() { + return this._isInitialized && this._main.sdfTextShader.isInitialized && this._main.fonts[this._label.font.name].isInitialized; } - get splitAxis() { - return this._splitAxis; + constructor(core, main, label){ + this._core = core; + this._main = main; + this._label = label; + this._label.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; + this._mMatrix = (0, _glMatrix.mat4).create(); + this.mMatrix = (0, _glMatrix.mat4).create(); + this.isVisible = true; } - get firstPrimOffset() { - return this._firstPrimOffset; + initializeContext(gl) { + if (!this._label.isInitialized) this._label.initialize(); + this._gl = gl; + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._label.vertices, gl.STATIC_DRAW); + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._label.indices, gl.STATIC_DRAW); + this._isInitialized = true; } - get nPrimitives() { - return this._nPrimitives; + update(elapsedTime) { + if (this._hasChanged) { + this._hasChanged = false; + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._label.vertices); + this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + this._gl.bufferSubData(this._gl.ELEMENT_ARRAY_BUFFER, 0, this._label.indices); + } } - get start() { - return this._start; + render(elapsedTime, xrFrame) { + if (this.isInitialized) { + const indexCount = this._label.indexCount; + if (indexCount > 0) { + const shader = this._main.sdfTextShader; + const fontVisual = this._main.fonts[this._label.font.name]; + shader.vertexBuffer = this._vertexBuffer; + shader.indexBuffer = this._indexBuffer; + shader.texture2D = fontVisual.texture; + shader.prepare(); + shader.gamma = this._label.gamma; + shader.buffer = fontVisual.font.edgeValue / 0xff; + shader.borderWidth = this._label.borderWidth; + shader.color = this._label.color || this._core.config.textColor; + shader.borderColor = this._label.borderColor || this._core.config.textBorderColor; + shader.hoverColor = this._label.hoverColor || this._core.config.textHoverColor; + shader.pickedIdColor = this.pickedIdColor; + shader.apply(); + (0, _glMatrix.mat4).multiply(this._mMatrix, this.mMatrix, this._label.mMatrix); + shader.mMatrix = this._mMatrix; + shader.applyModel(); + shader.isPickShader = false; + this._main.shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + shader.vMatrix = this.vMatrices[viewport]; + shader.pMatrix = this.pMatrices[viewport]; + shader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, 0); + } + if (this.isPickingEnabled) { + shader.isPickShader = true; + shader.pMatrix = this.pickPMatrix; + shader.vMatrix = this.pickVMatrix; + shader.applyView(); + this._main.shaderResources.bindFramebuffer(this.pickFramebuffer); + this._gl.viewport(0, 0, this._core.config.pickWidth, this._core.config.pickHeight); + this._gl.drawElements(this._gl.TRIANGLES, indexCount, this._gl.UNSIGNED_SHORT, 0); + } + } + } } - get end() { - return this._end; +} +class LabelVisual extends LabelVisualBase { + get label() { + return this._label; } - constructor(start, end){ - this._start = start; - this._end = end; + set text(value) { + this._label.text = value; } - initLeaf(first, n, bounds) { - this._firstPrimOffset = first; - this._nPrimitives = n; - this._bounds = bounds; - this._left = null; - this._right = null; + get text() { + return this._label.text; } - initInterior(axis, left, right) { - this._left = left; - this._right = right; - this._bounds = new (0, _aabbJs.AABB)(); - this._bounds.unionBounds(this._left.bounds); - this._bounds.unionBounds(this._right.bounds); - this._splitAxis = axis; - this._nPrimitives = 0; + constructor(core, main, label){ + super(core, main, label); } } -class LinearBVHNode { - constructor(){ - this.bounds = new (0, _aabbJs.AABB)(); - this.primitivesOffset = 0; - this.secondChildOffset = 0; - this.nPrimitives = 0; - this.axis = 0; - this._centroid = (0, _glMatrix.vec3).create(); - this._size = (0, _glMatrix.vec3).create(); +class LabelSetVisual extends LabelVisualBase { + get label() { + return this._label; } - toBuffer(buffer, index) { - this.bounds.centroid(this._centroid); - buffer.setCenter(index, this._centroid); - this.bounds.size(this._size); - (0, _glMatrix.vec3).scale(this._size, this._size, 0.5); - buffer.setSize(index, this._size); - buffer.setPrimitivesOffset(index, this.primitivesOffset); - buffer.setSecondChildOffset(index, this.secondChildOffset); - buffer.setNPrimitives(index, this.nPrimitives); - buffer.setAxis(index, this.axis); + constructor(core, main, label){ + super(core, main, label); } } -class BVHAccel { - get orderedPrimitives() { - return this._orderedPrimitives; + +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"492tj":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); +var _glMatrix = require("gl-matrix"); +var _textureJs = require("../../../helpers/texture.js"); +class ImageVisual { + get isInitialized() { + return this._isInitialized && this._main.textureShader.isInitialized; } - get nodes() { - return this._nodes; + get image() { + return this._image; } - constructor(core, primitives, maxPrimsInNode, splitMethod){ + constructor(core, main, image){ this._core = core; - if (!primitives || primitives.length == 0) return; - let start = performance.now(); - this._maxPrimsInNode = maxPrimsInNode; - this._splitMethod = splitMethod; - this._primitives = primitives; - this._normalized = (0, _glMatrix.vec3).create(); - this._primitiveInfo = []; - for(let i = 0; i < primitives.length; i++)this._primitiveInfo.push(new BVHPrimitiveInfo(i, primitives[i].bounds)); - this._totalNodes = 0; - this._orderedPrimitives = []; - const root = this._recursiveBuild(0, primitives.length); - this._core.log.write((0, _mainJs.LogLevel).info, `bvh ${this._totalNodes} nodes split ${this._splitMethod} ${Math.round(window.performance.now() - start)}ms`); - start = performance.now(); - this._nodes = []; - for(let i1 = 0; i1 < this._totalNodes; i1++)this._nodes.push(new LinearBVHNode()); - this._offset = 0; - this._flattenBVHTree(root); - this._core.log.write((0, _mainJs.LogLevel).info, `bvh flattened ${Math.round(window.performance.now() - start)}ms`); + this._main = main; + this._image = image; + this._image.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; + this.mMatrix = (0, _glMatrix.mat4).create(); + this.isVisible = true; } - _recursiveBuild(start, end) { - const node = new BVHBuildNode(start, end - 1); - this._totalNodes++; - const bounds = new (0, _aabbJs.AABB)(); - for(let i = start; i < end; i++)bounds.unionBounds(this._primitiveInfo[i].bounds); - const nPrimitives = end - start; - if (nPrimitives == 1) { - const firstPrimOffset = this._orderedPrimitives.length; - for(let i1 = start; i1 < end; i1++){ - const primNum = this._primitiveInfo[i1].primitiveNumber; - this._orderedPrimitives.push(this._primitives[primNum]); - } - node.initLeaf(firstPrimOffset, nPrimitives, bounds); - return node; - } else { - const centroidBounds = new (0, _aabbJs.AABB)(); - for(let i2 = start; i2 < end; i2++)centroidBounds.unionPoint(this._primitiveInfo[i2].centroid); - const dim = centroidBounds.maximumExtent(); - let mid = Math.floor((start + end) / 2); - if (centroidBounds.max[dim] == centroidBounds.min[dim]) { - const firstPrimOffset1 = this._orderedPrimitives.length; - for(let i3 = start; i3 < end; i3++){ - const primNum1 = this._primitiveInfo[i3].primitiveNumber; - this._orderedPrimitives.push(this._primitives[primNum1]); - } - node.initLeaf(firstPrimOffset1, nPrimitives, bounds); - return node; - } else { - switch(this._splitMethod){ - case SplitMethod.middle: - break; - case SplitMethod.equalCounts: - mid = Math.floor((start + end) / 2); - const primtiveInfo = this._primitiveInfo.slice(start, end); - primtiveInfo.sort(function(a, b) { - return a.centroid[dim] - b.centroid[dim]; - }); - for(let i4 = start; i4 < end; i4++)this._primitiveInfo[i4] = primtiveInfo[i4 - start]; - break; - case SplitMethod.sah: - default: - if (nPrimitives <= 4) { - mid = Math.floor((start + end) / 2); - const primtiveInfo1 = this._primitiveInfo.slice(start, end); - primtiveInfo1.sort(function(a, b) { - return a.centroid[dim] - b.centroid[dim]; - }); - for(let i5 = start; i5 < end; i5++)this._primitiveInfo[i5] = primtiveInfo1[i5 - start]; - } else { - const nBuckets = 12; - const buckets = []; - for(let i6 = 0; i6 < nBuckets; i6++)buckets.push({ - count: 0, - bounds: new (0, _aabbJs.AABB)() - }); - for(let i7 = start; i7 < end; i7++){ - centroidBounds.offset(this._primitiveInfo[i7].centroid, this._normalized); - const b = Math.min(Math.round(nBuckets * this._normalized[dim]), nBuckets - 1); - buckets[b].count++; - buckets[b].bounds.unionBounds(this._primitiveInfo[i7].bounds); - } - const cost = []; - for(let i8 = 0; i8 < nBuckets - 1; i8++){ - const b0 = new (0, _aabbJs.AABB)(); - const b1 = new (0, _aabbJs.AABB)(); - let count0 = 0; - let count1 = 0; - for(let j = 0; j <= i8; j++){ - b0.unionBounds(buckets[j].bounds); - count0 += buckets[j].count; - } - for(let j1 = i8 + 1; j1 < nBuckets; j1++){ - b1.unionBounds(buckets[j1].bounds); - count1 += buckets[j1].count; - } - cost.push(0.125 + (count0 * b0.surfaceArea() + count1 * b1.surfaceArea()) / bounds.surfaceArea()); - } - let minCost = cost[0]; - let minCostSplitBucket = 0; - for(let i9 = 1; i9 < nBuckets - 1; i9++)if (cost[i9] < minCost) { - minCost = cost[i9]; - minCostSplitBucket = i9; - } - const leafCost = nPrimitives; - if (nPrimitives > this._maxPrimsInNode || minCost < leafCost) { - const primtiveInfo2 = this._primitiveInfo.slice(start, end); - primtiveInfo2.sort(function(a, b) { - return a.centroid[dim] - b.centroid[dim]; - }); - for(let i10 = start; i10 < end; i10++)this._primitiveInfo[i10] = primtiveInfo2[i10 - start]; - for(let i11 = start; i11 < end; i11++){ - centroidBounds.offset(this._primitiveInfo[i11].centroid, this._normalized); - const b2 = Math.min(Math.round(nBuckets * this._normalized[dim]), nBuckets - 1); - if (b2 > minCostSplitBucket) { - mid = i11; - break; - } - } - } else { - const firstPrimOffset2 = this._orderedPrimitives.length; - for(let i12 = start; i12 < end; i12++){ - const primNum2 = this._primitiveInfo[i12].primitiveNumber; - this._orderedPrimitives.push(this._primitives[primNum2]); - } - node.initLeaf(firstPrimOffset2, nPrimitives, bounds); - return node; - } - } - break; - } - node.initInterior(dim, this._recursiveBuild(start, mid), this._recursiveBuild(mid, end)); - } + initializeContext(gl) { + if (!this._image.isInitialized) this._image.initialize(); + this._gl = gl; + if (this._image.imageData) this.texture = (0, _textureJs.TextureHelper).fromImage(gl, this._image.imageData, false, gl.LINEAR); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this._image.vertices, gl.STATIC_DRAW); + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this._image.indices, gl.STATIC_DRAW); + this._isInitialized = true; + } + update(elapsedTime) { + if (this._hasChanged) { + this._hasChanged = false; + this._gl.bindBuffer(this._gl.ARRAY_BUFFER, this._vertexBuffer); + this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, this._image.vertices); + this._main.shaderResources.currentProgram = null; } - return node; } - _flattenBVHTree(node) { - const linearNode = this._nodes[this._offset]; - linearNode.bounds = node.bounds; - const myOffset = this._offset++; - if (node.nPrimitives > 0) { - linearNode.primitivesOffset = node.firstPrimOffset; - linearNode.nPrimitives = node.nPrimitives; - } else { - linearNode.axis = node.splitAxis; - linearNode.nPrimitives = 0; - this._flattenBVHTree(node.left); - linearNode.secondChildOffset = this._flattenBVHTree(node.right); + render(elapsedTime, xrFrame) { + if (this.isInitialized) { + const textureShader = this._main.textureShader; + textureShader.vertexBuffer = this._vertexBuffer; + textureShader.indexBuffer = this._indexBuffer; + textureShader.texture2D = this.texture; + textureShader.prepare(); + textureShader.mMatrix = this.mMatrix; + textureShader.apply(); + this._main.shaderResources.bindFramebuffer(this.geometryFramebuffer); + for(let i = 0; i < this.viewportCount; i++){ + const viewport = i + this.viewportOffset; + this._gl.viewport(this.viewports[viewport].x, this.viewports[viewport].y, this.viewports[viewport].width, this.viewports[viewport].height); + textureShader.vMatrix = this.vMatrices[viewport]; + textureShader.pMatrix = this.pMatrices[viewport]; + textureShader.applyView(); + this._gl.drawElements(this._gl.TRIANGLES, this._image.indexCount, this._gl.UNSIGNED_SHORT, 0); + } } - return myOffset; } } -class LinearBVHNodeBufferData extends Float32Array { - constructor(count){ - super(count * LinearBVHNodeBufferData.SIZE); - this.CENTER_OFFSET = 0; - this.SIZE_OFFSET = 4; - this.PRIMITIVES_OFFSET_OFFSET = 3; - this.SECOND_CHILD_OFFSET_OFFSET = 7; - this.N_PRIMITIVES_OFFSET = 8; - this.AXIS_OFFSET = 9; - } - getCenter(index, value) { - const offset = LinearBVHNodeBufferData.SIZE * index + this.CENTER_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); - } - setCenter(index, value) { - const offset = LinearBVHNodeBufferData.SIZE * index + this.CENTER_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getSize(index, value) { - const offset = LinearBVHNodeBufferData.SIZE * index + this.SIZE_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); - } - setSize(index, value) { - const offset = LinearBVHNodeBufferData.SIZE * index + this.SIZE_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getPrimitivesOffset(index) { - return this[LinearBVHNodeBufferData.SIZE * index + this.PRIMITIVES_OFFSET_OFFSET]; - } - setPrimitivesOffset(index, value) { - this[LinearBVHNodeBufferData.SIZE * index + this.PRIMITIVES_OFFSET_OFFSET] = value; - } - getSecondChildOffset(index) { - return this[LinearBVHNodeBufferData.SIZE * index + this.SECOND_CHILD_OFFSET_OFFSET]; - } - setSecondChildOffset(index, value) { - this[LinearBVHNodeBufferData.SIZE * index + this.SECOND_CHILD_OFFSET_OFFSET] = value; + +},{"gl-matrix":"5x28d","../../../helpers/texture.js":"bUoBU","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7Nt0P":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Lasso", ()=>Lasso); +var _constantsJs = require("../../../constants.js"); +var _quadJs = require("../../../meshes/quad.js"); +class Lasso { + get isInitialized() { + return this._isInitialized; } - getNPrimitives(index) { - return this[LinearBVHNodeBufferData.SIZE * index + this.N_PRIMITIVES_OFFSET]; + get vertexBuffer() { + return this._vertexBuffer; } - setNPrimitives(index, value) { - this[LinearBVHNodeBufferData.SIZE * index + this.N_PRIMITIVES_OFFSET] = value; + get indexBuffer() { + return this._indexBuffer; } - getAxis(index) { - return this[LinearBVHNodeBufferData.SIZE * index + this.AXIS_OFFSET]; + get indexCount() { + return this._indexCount; } - setAxis(index, value) { - this[LinearBVHNodeBufferData.SIZE * index + this.AXIS_OFFSET] = value; + initializeContext(gl) { + const vertices = (0, _quadJs.Quad).textured((0, _constantsJs.Constants).MAT4_IDENTITY); + this._vertexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); + gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); + const indices = (0, _quadJs.Quad).INDICES; + this._indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); + this._indexCount = indices.length; + this._isInitialized = true; } } -LinearBVHNodeBufferData.SIZE = 12; -},{"gl-matrix":"9GjEQ","../../main.js":"1Kju3","./aabb.js":"9AXPV","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8rYr6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../../../constants.js":"lD0bG","../../../meshes/quad.js":"3PqJr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2SNte":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LightType", ()=>LightType); -parcelHelpers.export(exports, "LightBufferData", ()=>LightBufferData); -parcelHelpers.export(exports, "Light", ()=>Light); -parcelHelpers.export(exports, "SphereLight", ()=>SphereLight); -parcelHelpers.export(exports, "RectLight", ()=>RectLight); +parcelHelpers.export(exports, "Main", ()=>(0, _mainJs.Main)); +parcelHelpers.export(exports, "Material", ()=>(0, _materialJs.Material)); +parcelHelpers.export(exports, "MetalMaterial", ()=>(0, _materialJs.MetalMaterial)); +parcelHelpers.export(exports, "GlossyMaterial", ()=>(0, _materialJs.GlossyMaterial)); +parcelHelpers.export(exports, "VarnishMaterial", ()=>(0, _materialJs.VarnishMaterial)); +parcelHelpers.export(exports, "LambertianMaterial", ()=>(0, _materialJs.LambertianMaterial)); +parcelHelpers.export(exports, "DielectricMaterial", ()=>(0, _materialJs.DielectricMaterial)); +parcelHelpers.export(exports, "DiffuseLightMaterial", ()=>(0, _materialJs.DiffuseLightMaterial)); +parcelHelpers.export(exports, "IsotropicMaterial", ()=>(0, _materialJs.IsotropicMaterial)); +parcelHelpers.export(exports, "Texture", ()=>(0, _textureJs.Texture)); +parcelHelpers.export(exports, "SolidColorTexture", ()=>(0, _textureJs.SolidColorTexture)); +parcelHelpers.export(exports, "ImageTexture", ()=>(0, _textureJs.ImageTexture)); +parcelHelpers.export(exports, "CheckerTexture", ()=>(0, _textureJs.CheckerTexture)); +parcelHelpers.export(exports, "GridTexture", ()=>(0, _textureJs.GridTexture)); +parcelHelpers.export(exports, "Light", ()=>(0, _lightJs.Light)); +parcelHelpers.export(exports, "SphereLight", ()=>(0, _lightJs.SphereLight)); +parcelHelpers.export(exports, "RectLight", ()=>(0, _lightJs.RectLight)); +parcelHelpers.export(exports, "Ground", ()=>(0, _groundJs.Ground)); +parcelHelpers.export(exports, "Constants", ()=>(0, _constantsJs.Constants)); +var _mainJs = require("./main.js"); +var _materialJs = require("./material.js"); +var _textureJs = require("./texture.js"); +var _lightJs = require("./light.js"); +var _groundJs = require("./ground.js"); +var _constantsJs = require("./constants.js"); + +},{"./main.js":"dfh4e","./material.js":"jQJhi","./texture.js":"5NgmA","./light.js":"2sMdC","./ground.js":"54e1Z","./constants.js":"6DWH0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dfh4e":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -const LightType = { - distant: 0, - sphere: 1, - rect: 2, - disc: 3, - cylinder: 4, - dome: 5 -}; -class LightBufferData extends Float32Array { - constructor(count){ - super(count * LightBufferData.SIZE); - this.ROTATION_OFFSET = 0; - this.CENTER_OFFSET = 4; - this.TYPE_OFFSET = 7; - this.SIZE_OFFSET = 8; - this.COLOR_OFFSET = 12; - } - getType(index) { - return this[LightBufferData.SIZE * index + this.TYPE_OFFSET]; - } - setType(index, value) { - this[LightBufferData.SIZE * index + this.TYPE_OFFSET] = value; - } - getCenter(index, value) { - const offset = LightBufferData.SIZE * index + this.CENTER_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); - } - setCenter(index, value) { - const offset = LightBufferData.SIZE * index + this.CENTER_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getSize(index, value) { - const offset = LightBufferData.SIZE * index + this.SIZE_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); - } - setSize(index, value) { - const offset = LightBufferData.SIZE * index + this.SIZE_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - } - getColor(index, value) { - const offset = LightBufferData.SIZE * index + this.COLOR_OFFSET; - (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); - } - setColor(index, value) { - const offset = LightBufferData.SIZE * index + this.COLOR_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Main", ()=>Main); +var _glMatrix = require("gl-matrix"); +var _rendererJs = require("../renderer.js"); +var _mainJs = require("../../main.js"); +var _configJs = require("./config.js"); +var _hittableJs = require("./hittable.js"); +var _materialJs = require("./material.js"); +var _raytraceJs = require("./shaders/raytrace.js"); +var _fullscreenquadJs = require("./shaders/fullscreenquad.js"); +var _bvhJs = require("./bvh.js"); +var _textureJs = require("./texture.js"); +var _lightJs = require("./light.js"); +var _constantsJs = require("../../constants.js"); +var _angleJs = require("../../helpers/angle.js"); +var _fontJs = require("./font.js"); +var _imageJs = require("./image.js"); +var _labelsJs = require("./labels.js"); +var _bufferJs = require("./buffer.js"); +var _constantsJs1 = require("./constants.js"); +var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); } - getRotation(index, value) { - const offset = LightBufferData.SIZE * index + this.ROTATION_OFFSET; - (0, _glMatrix.quat).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +class Main extends (0, _rendererJs.RendererBase) { + get frameCount() { + return this._frameCount; } - setRotation(index, value) { - const offset = LightBufferData.SIZE * index + this.ROTATION_OFFSET; - this[offset] = value[0]; - this[offset + 1] = value[1]; - this[offset + 2] = value[2]; - this[offset + 3] = value[3]; + get duration() { + return this._duration; } -} -LightBufferData.SIZE = 16; -class Light { - constructor(options){ - this.color = options.color; - this.center = options.center; + get config() { + return this._config; } - toBuffer(buffer, index) { - buffer.setCenter(index, this.center); - buffer.setColor(index, this.color); + set lights(value) { + if (value != this._lights) { + this._lights = value; + this._haveLightsChanged = true; + this._frameCount = 0; + } } -} -class SphereLight extends Light { - constructor(options){ - super(options); - this.radius = options.radius / 2; + get lights() { + return this._lights; } - toBuffer(buffer, index) { - super.toBuffer(buffer, index); - buffer.setType(index, LightType.sphere); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this.radius, this.radius, this.radius)); + restart() { + this._frameCount = 0; + this._core.start(); } -} -class RectLight extends Light { constructor(options){ super(options); - this._thickness = 0.00001; - this.size = options.size; - this.rotation = options.rotation; - } - toBuffer(buffer, index) { - super.toBuffer(buffer, index); - buffer.setType(index, LightType.rect); - buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this.size[0], this.size[1], this._thickness)); - buffer.setRotation(index, this.rotation); + (0, _glMatrix.glMatrix).setMatrixArrayType(Float32Array); + this._config = new (0, _configJs.Config)(); + this._frameCount = 0; + this._duration = 0; + this._position = (0, _glMatrix.vec3).create(); + this._right = (0, _glMatrix.vec3).create(); + this._up = (0, _glMatrix.vec3).create(); + this._forward = (0, _glMatrix.vec3).create(); + this._modelPosition = (0, _glMatrix.vec3).create(); + this._manipulationOrigin = (0, _glMatrix.vec3).create(); + this._backgroundColor = (0, _glMatrix.vec4).fromValues(0, 0, 0, 1); } -} - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iQd3h":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mainJs = require("../../main.js"); -class FontVisual { - get isInitialized() { - return this._isInitialized; + initialize(core) { + super.initialize(core); + this._hittables = []; + this._lightBuffer = null; + this._worldCreated = false; + this._initializeAPI().then(()=>{ + this._initializeResources(); + }); } - get font() { - return this._font; + _initializeAPI() { + return __awaiter(this, void 0, void 0, function*() { + try { + const start = window.performance.now(); + const gpu = navigator.gpu; + this._presentationFormat = gpu.getPreferredCanvasFormat(); + this._adapter = yield gpu.requestAdapter(); + const gpuDeviceDescriptor = { + requiredLimits: { + maxStorageBufferBindingSize: 134217728, + maxComputeWorkgroupsPerDimension: 256 + } + }; + this._device = yield this._adapter.requestDevice(gpuDeviceDescriptor); + this._queue = this._device.queue; + this._context = this._canvas.getContext("webgpu"); + this._core.log.write((0, _mainJs.LogLevel).info, `WebGPU API initialized ${Math.round(window.performance.now() - start)}ms`); + } catch (e) { + this._core.log.write((0, _mainJs.LogLevel).error, e); + return false; + } + return true; + }); } - constructor(core, font){ - this._core = core; - this._font = font; - font.hasChangedCallback = ()=>{ - this._hasChanged = true; + _initializeResources() { + const start = window.performance.now(); + const canvasConfig = { + device: this._device, + format: this._presentationFormat, + alphaMode: "premultiplied" }; - } - initializeContext(device) { - this._device = device; - this._hasChanged = true; + this._context.configure(canvasConfig); + const computeUniformBufferDescriptor = { + label: "Compute uniform buffer", + size: (0, _raytraceJs.ComputeUniformBufferData).SIZE * 4, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST + }; + this._computeUniformBuffer = this._device.createBuffer(computeUniformBufferDescriptor); + this._computeUniformBufferData = new (0, _raytraceJs.ComputeUniformBufferData)(); + const depthMinMaxBufferDescriptor = { + label: "Depth min max buffer", + size: 8, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC + }; + this._depthMinMaxBuffer = this._device.createBuffer(depthMinMaxBufferDescriptor); + const depthMinMaxBufferResultDescriptor = { + label: "Depth min max result buffer", + size: 8, + usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ + }; + this._depthMinMaxResultBuffer = this._device.createBuffer(depthMinMaxBufferResultDescriptor); + const fullscreenQuadUniformBufferDescriptor = { + label: "Full screen quad uniform buffer", + size: (0, _fullscreenquadJs.FullscreenQuadUniformBufferData).SIZE * 4, + usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST + }; + this._fullscreenQuadUniformBuffer = this._device.createBuffer(fullscreenQuadUniformBufferDescriptor); + this._fullscreenQuadUniformBufferData = new (0, _fullscreenquadJs.FullscreenQuadUniformBufferData)(); + this._sampler = this._device.createSampler({ + label: "Sampler", + magFilter: "linear", + minFilter: "linear" + }); + for(const key in this.fonts){ + const fontVisual = this.fonts[key]; + fontVisual.initializeContext(this._device); + fontVisual.update(); + } + for(let i = 0; i < this.images.length; i++){ + const image = this.images[i]; + image.initializeContext(this._device); + image.update(); + } + const textureSize = { + width: 1, + height: 1 + }; + const textureDescriptor = { + label: "Placeholder texture", + size: textureSize, + format: this._presentationFormat, + usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT + }; + this._texture = this._device.createTexture(textureDescriptor); + this._core.log.write((0, _mainJs.LogLevel).info, `WebGPU resources initialized ${Math.round(window.performance.now() - start)}ms`); this._isInitialized = true; } - update() { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - const start = window.performance.now(); - const imageData = this._font.atlas.imageData; - const textureSize = { - width: imageData.width, - height: imageData.height - }; - createImageBitmap(imageData).then((imageBitmap)=>{ - const textureDescriptor = { - size: textureSize, - format: "rgba8unorm", - usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT - }; - this.texture = this._device.createTexture(textureDescriptor); - const imageCopyExternalImage = { - source: imageBitmap - }; - const imageCopyTextureTagged = { - texture: this.texture - }; - const copySize = { - width: imageData.width, - height: imageData.height - }; - this._device.queue.copyExternalImageToTexture(imageCopyExternalImage, imageCopyTextureTagged, copySize); - if (this.hasChangedCallback) this.hasChangedCallback(); - this._core.log.write((0, _mainJs.LogLevel).info, `${this._font.name} texture updated ${Math.round(window.performance.now() - start)}ms`); - }); - } - } -} - -},{"../../main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8XGYp":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _imageJs = require("../../components/image.js"); -var _mainJs = require("../../main.js"); -var _hittableJs = require("./hittable.js"); -class ImageVisual { - get isInitialized() { - return this._isInitialized; + get isSupported() { + return navigator.gpu !== undefined; } - get image() { - return this._image; + _createWorld() { + return __awaiter(this, void 0, void 0, function*() { + const start = performance.now(); + this._hittables = this._getHittables(); + if (this._hittables.length == 0) return; + const bvhAccel = new (0, _bvhJs.BVHAccel)(this._core, this._hittables, this._config.maxPrimsInNode, (0, _bvhJs.SplitMethod).sah); + const hittables = bvhAccel.orderedPrimitives; + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible) { + const atlas = transitionBuffer.currentAtlas; + if (atlas.imageData) { + const imageData = atlas.imageData; + const textureSize = { + width: imageData.width, + height: imageData.height + }; + yield createImageBitmap(imageData).then((imageBitmap)=>{ + const textureDescriptor = { + label: "Atlas texture", + size: textureSize, + format: this._presentationFormat, + usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT + }; + this._atlasTexture = this._device.createTexture(textureDescriptor); + const imageCopyExternalImage = { + source: imageBitmap + }; + const imageCopyTextureTagged = { + texture: this._atlasTexture + }; + const copySize = { + width: imageData.width, + height: imageData.height + }; + this._device.queue.copyExternalImageToTexture(imageCopyExternalImage, imageCopyTextureTagged, copySize); + this._core.log.write((0, _mainJs.LogLevel).info, `atlas texture updated ${Math.round(window.performance.now() - start)}ms`); + }); + break; + } + } + } + const materials = []; + const materialIds = []; + for(let i = 0; i < hittables.length; i++){ + const hittable = hittables[i]; + const material = hittable.material; + let materialId; + let found; + for(let j = 0; j < materials.length; j++)if (materials[j] === material) { + found = true; + materialId = j; + break; + } + if (!found) { + materialId = materials.length; + materials.push(material); + } + materialIds.push(materialId); + } + const textures = []; + const textureIds = []; + for(let i = 0; i < materials.length; i++){ + const material = materials[i]; + const texture = material.texture; + if (texture) { + let textureId; + let found; + for(let j = 0; j < textures.length; j++)if (textures[j] === texture) { + found = true; + textureId = j; + break; + } + if (!found) { + textureId = textures.length; + textures.push(texture); + if (texture instanceof (0, _textureJs.ImageTexture)) { + const imageData = texture.image; + if (imageData) { + let start = performance.now(); + const imageDataLinear = new ImageData(imageData.width, imageData.height); + for(let i = 0; i < imageData.data.length; i++)imageDataLinear.data[i] = Math.pow(imageData.data[i] / 0xff, 2.2) * 0xff; + this._core.log.write((0, _mainJs.LogLevel).info, `image inverse gamma ${Math.round(window.performance.now() - start)}ms`); + start = window.performance.now(); + const textureSize = { + width: imageData.width, + height: imageData.height + }; + createImageBitmap(imageDataLinear).then((imageBitmap)=>{ + const textureDescriptor = { + size: textureSize, + format: 'rgba8unorm', + usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT + }; + this._backgroundTexture = this._device.createTexture(textureDescriptor); + const imageCopyExternalImage = { + source: imageBitmap, + flipY: true + }; + const imageCopyTextureTagged = { + texture: this._backgroundTexture + }; + const copySize = { + width: imageData.width, + height: imageData.height + }; + this._device.queue.copyExternalImageToTexture(imageCopyExternalImage, imageCopyTextureTagged, copySize); + this._core.log.write((0, _mainJs.LogLevel).info, `background image updated ${Math.round(window.performance.now() - start)}ms`); + }); + } + } + } + textureIds.push(textureId); + } else textureIds.push(0); + } + const textureBufferSizeBytes = textures.length * (0, _textureJs.TextureBufferData).SIZE * 4; + const textureBufferDescriptor = { + label: "Texture buffer", + size: textureBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST + }; + this._textureBuffer = this._device.createBuffer(textureBufferDescriptor); + this._textureBufferData = new (0, _textureJs.TextureBufferData)(textures.length); + for(let i = 0; i < textures.length; i++)textures[i].toBuffer(this._textureBufferData, i); + const materialBufferSizeBytes = materials.length * (0, _materialJs.MaterialBufferData).SIZE * 4; + const materialBufferDescriptor = { + label: "Material buffer", + size: materialBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST + }; + this._materialBuffer = this._device.createBuffer(materialBufferDescriptor); + this._materialBufferData = new (0, _materialJs.MaterialBufferData)(materials.length); + for(let i = 0; i < materials.length; i++)materials[i].toBuffer(this._materialBufferData, i, textureIds[i]); + const hittableBufferSizeBytes = hittables.length * (0, _hittableJs.HittableBufferData).SIZE * 4; + const hittableBufferDescriptor = { + label: "Hittable buffer", + size: hittableBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST + }; + this._hittableBuffer = this._device.createBuffer(hittableBufferDescriptor); + this._hittableBufferData = new (0, _hittableJs.HittableBufferData)(hittables.length); + for(let i = 0; i < hittables.length; i++){ + const hittable = hittables[i]; + hittable.toBuffer(this._hittableBufferData, i, materialIds[i]); + } + const linearBVHNodes = bvhAccel.nodes; + const linearBVHNodeBufferSizeBytes = linearBVHNodes.length * (0, _bvhJs.LinearBVHNodeBufferData).SIZE * 4; + const linearBVHNodeBufferDescriptor = { + label: "Linear BVH node buffer", + size: linearBVHNodeBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST + }; + this._linearBVHNodeBuffer = this._device.createBuffer(linearBVHNodeBufferDescriptor); + this._linearBVHNodeBufferData = new (0, _bvhJs.LinearBVHNodeBufferData)(linearBVHNodes.length); + for(let i = 0; i < linearBVHNodes.length; i++)linearBVHNodes[i].toBuffer(this._linearBVHNodeBufferData, i); + this._device.queue.writeBuffer(this._hittableBuffer, 0, this._hittableBufferData.buffer, this._hittableBufferData.byteOffset, this._hittableBufferData.byteLength); + this._device.queue.writeBuffer(this._materialBuffer, 0, this._materialBufferData.buffer, this._materialBufferData.byteOffset, this._materialBufferData.byteLength); + this._device.queue.writeBuffer(this._textureBuffer, 0, this._textureBufferData.buffer, this._textureBufferData.byteOffset, this._textureBufferData.byteLength); + this._device.queue.writeBuffer(this._linearBVHNodeBuffer, 0, this._linearBVHNodeBufferData.buffer, this._linearBVHNodeBufferData.byteOffset, this._linearBVHNodeBufferData.byteLength); + this._core.log.write((0, _mainJs.LogLevel).info, `create world ${Math.round(window.performance.now() - start)}ms`); + }); } - render(elapsedTime) {} - constructor(core, main, image){ - this._core = core; - this._main = main; - this._image = image; - this.isVisible = true; - image.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; + _createLights() { + if (!this._lights || this._lights.length == 0) return; + const modelScale = this._core.getModelScale(); + (0, _glMatrix.vec3).set(this._modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + if (!this._lightBuffer) { + const lightBufferSizeBytes = this._lights.length * (0, _lightJs.LightBufferData).SIZE * 4; + const lightBufferDescriptor = { + label: "Light buffer", + size: lightBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST + }; + this._lightBuffer = this._device.createBuffer(lightBufferDescriptor); + this._lightBufferData = new (0, _lightJs.LightBufferData)(this._lights.length); + } + for(let i = 0; i < this._lights.length; i++){ + const light = this._lights[i]; + let lightCopy; + if (light instanceof (0, _lightJs.RectLight)) lightCopy = new (0, _lightJs.RectLight)({ + center: (0, _glMatrix.vec3).clone(light.center), + color: (0, _glMatrix.vec3).clone(light.color), + rotation: (0, _glMatrix.quat).clone(light.rotation), + size: (0, _glMatrix.vec2).fromValues(light.size[0] * modelScale, light.size[1] * modelScale) + }); + else if (light instanceof (0, _lightJs.SphereLight)) lightCopy = new (0, _lightJs.SphereLight)({ + center: (0, _glMatrix.vec3).clone(light.center), + color: (0, _glMatrix.vec3).clone(light.color), + radius: light.radius * modelScale + }); + (0, _glMatrix.vec3).scale(lightCopy.center, lightCopy.center, modelScale); + (0, _glMatrix.vec3).add(lightCopy.center, lightCopy.center, this._modelPosition); + lightCopy.toBuffer(this._lightBufferData, i); + } + this._device.queue.writeBuffer(this._lightBuffer, 0, this._lightBufferData.buffer, this._lightBufferData.byteOffset, this._lightBufferData.byteLength); + this._areLightsInitialized = true; } - initializeContext(device) { - this._device = device; - if (!this._image.isInitialized) this._image.initialize(); - this._hasChanged = true; - this._isInitialized = true; + standardLighting(lights) { + lights || (lights = this._config.standardLightingOptions()); + const rectLights = []; + for(let i = 0; i < lights.length; i++){ + const light = lights[i]; + const center = (0, _glMatrix.vec3).create(); + const rotation = (0, _glMatrix.quat).create(); + const azimuth = (0, _angleJs.AngleHelper).degreesToRadians(light.azimuth); + const altitude = (0, _angleJs.AngleHelper).degreesToRadians(-light.altitude); + (0, _glMatrix.quat).rotateY(rotation, (0, _constantsJs.Constants).QUAT_IDENTITY, azimuth); + (0, _glMatrix.quat).rotateX(rotation, rotation, altitude); + (0, _glMatrix.vec3).transformQuat(center, (0, _constantsJs.Constants).VECTOR3_UNITZ, rotation); + (0, _glMatrix.vec3).scale(center, center, light.distance); + const yaw = (0, _angleJs.AngleHelper).degreesToRadians(light.yaw); + const pitch = (0, _angleJs.AngleHelper).degreesToRadians(-light.altitude); + (0, _glMatrix.quat).rotateY(rotation, (0, _constantsJs.Constants).QUAT_IDENTITY, yaw); + (0, _glMatrix.quat).rotateX(rotation, rotation, pitch); + rectLights.push(new (0, _lightJs.RectLight)({ + center: center, + rotation: rotation, + size: light.size, + color: light.color + })); + } + return rectLights; } - update() { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - const material = this._image.material == -1 ? this._main.config.defaultMaterial : this._main.materials[this._image.material]; - const modelPosition = (0, _glMatrix.vec3).create(); - const modelScale = this._core.getModelScale(); - const modelRotation = (0, _glMatrix.quat).create(); - this._core.getModelRotation(modelRotation); - const modelSizeX = this._image.maxBoundsX - this._image.minBoundsX; - const modelSizeY = this._image.maxBoundsY - this._image.minBoundsY; - const modelSizeZ = this._image.maxBoundsZ - this._image.minBoundsZ; - const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); - const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; - (0, _glMatrix.vec3).set(modelPosition, this._main.mMatrix[12], this._main.mMatrix[13], this._main.mMatrix[14]); - if (this._image instanceof (0, _imageJs.ImageQuad)) { - const imageQuad = this._image; - const position = (0, _glMatrix.vec3).fromValues((imageQuad.minBoundsX + imageQuad.maxBoundsX) / 2, (imageQuad.minBoundsY + imageQuad.maxBoundsY) / 2, (imageQuad.minBoundsZ + imageQuad.maxBoundsZ) / 2); - (0, _glMatrix.vec3).subtract(position, imageQuad.position, position); - (0, _glMatrix.vec3).scale(position, position, boundsScaling); - (0, _glMatrix.vec3).scale(position, position, modelScale); - (0, _glMatrix.vec3).transformQuat(position, position, modelRotation); - (0, _glMatrix.vec3).add(position, position, modelPosition); - const hittableRotatedXyRectOptions = { - center0: position, - center1: position, - time0: 1, - time1: 1, - size: (0, _glMatrix.vec2).fromValues(imageQuad.width * boundsScaling * modelScale / 2, imageQuad.height * boundsScaling * modelScale / 2), - material: material, - texCoord0: imageQuad.texCoord0, - texCoord1: imageQuad.texCoord1, - rotation: imageQuad.rotation - }; - this.hittable = new (0, _hittableJs.HittableRotatedXyRect)(hittableRotatedXyRectOptions); - } else if (this._image instanceof (0, _imageJs.ImageSphere)) { - const imageSphere = this._image; - const position1 = imageSphere.position; - (0, _glMatrix.vec3).subtract(position1, imageSphere.position, position1); - (0, _glMatrix.vec3).scale(position1, position1, boundsScaling); - (0, _glMatrix.vec3).scale(position1, position1, modelScale); - (0, _glMatrix.vec3).transformQuat(position1, position1, modelRotation); - (0, _glMatrix.vec3).add(position1, position1, modelPosition); - const hittableSphereOptions = { - center0: position1, - center1: position1, - time0: 1, - time1: 1, - radius: imageSphere.radius * boundsScaling, - material: material - }; - this.hittable = new (0, _hittableJs.HittableSphere)(hittableSphereOptions); + _getHittables() { + const hittables = []; + let minY = Number.MAX_VALUE; + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible && transitionBuffer.hittables && transitionBuffer.hittables.length > 0) { + minY = Math.min(minY, transitionBuffer.minY); + for(let j = 0; j < transitionBuffer.hittables.length; j++)hittables.push(transitionBuffer.hittables[j]); } - const imageData = this._image.imageData; - if (imageData) { - let start = performance.now(); - const imageDataLinear = new ImageData(imageData.width, imageData.height); - for(let i = 0; i < imageData.data.length; i++)imageDataLinear.data[i] = Math.pow(imageData.data[i] / 0xff, 2.2) * 0xff; - this._core.log.write((0, _mainJs.LogLevel).info, `image inverse gamma ${Math.round(window.performance.now() - start)}ms`); - start = window.performance.now(); - const textureSize = { - width: imageData.width, - height: imageData.height - }; - createImageBitmap(imageDataLinear).then((imageBitmap)=>{ - const textureDescriptor = { - size: textureSize, - format: "rgba8unorm", - usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT - }; - this.texture = this._device.createTexture(textureDescriptor); - const imageCopyExternalImage = { - source: imageBitmap, - flipY: true - }; - const imageCopyTextureTagged = { - texture: this.texture - }; - const copySize = { - width: imageData.width, - height: imageData.height - }; - this._device.queue.copyExternalImageToTexture(imageCopyExternalImage, imageCopyTextureTagged, copySize); - if (this.hasChangedCallback) this.hasChangedCallback(); - this._core.log.write((0, _mainJs.LogLevel).info, `background image updated ${Math.round(window.performance.now() - start)}ms`); - }); + } + if (this.labelSets && this.labelSets.length > 0) for(let i = 0; i < this.labelSets.length; i++){ + const labelSet = this.labelSets[i]; + if (labelSet.hittables) for(let j = 0; j < labelSet.hittables.length; j++)hittables.push(labelSet.hittables[j]); + } + if (this.images && this.images.length > 0) { + for(let i = 0; i < this.images.length; i++)if (this.images[i].hittable) { + const hittable = this.images[i].hittable; + hittables.push(hittable); + minY = Math.min(hittable.bounds.min[1], minY); } } - } -} - -},{"gl-matrix":"9GjEQ","../../components/image.js":"llF9m","../../main.js":"1Kju3","./hittable.js":"5bOsK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jWtqv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _vertexJs = require("../../vertex.js"); -var _hittableJs = require("./hittable.js"); -class LabelSetVisual { - get isInitialized() { - return this._isInitialized; - } - get label() { - return this._labelSet; - } - render(elapsedTime) {} - constructor(core, main, labelSet){ - this._core = core; - this._main = main; - this._labelSet = labelSet; - this.isVisible = true; - labelSet.hasChangedCallback = ()=>{ - this._hasChanged = true; - }; - if (!this._labelSet.isInitialized) this._labelSet.initialize(); - if (this._labelSet.text && this._labelSet.text.length > 0) this._hasChanged = true; - this._isInitialized = true; - } - update() { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - this.hittables = []; + if (this.ground) { const modelPosition = (0, _glMatrix.vec3).create(); const modelScale = this._core.getModelScale(); const modelRotation = (0, _glMatrix.quat).create(); this._core.getModelRotation(modelRotation); - (0, _glMatrix.vec3).set(modelPosition, this._main.mMatrix[12], this._main.mMatrix[13], this._main.mMatrix[14]); - const glpyhRotation = (0, _glMatrix.quat).create(); - const glyphInvRotation = (0, _glMatrix.quat).create(); - const position0 = (0, _glMatrix.vec3).create(); - const position1 = (0, _glMatrix.vec3).create(); - const dataView = this._labelSet.verticesView; - const labelCount = this._labelSet.text.length; - let glyphIndex = 0; - for(let i = 0; i < labelCount; i++){ - const material = this._labelSet.material !== undefined ? this._main.materials[this._labelSet.material] : this._labelSet.materials ? this._main.materials[this._labelSet.materials[i]] : this._main.config.defaultTextMaterial; - const glyphCount = this._labelSet.text[i].length; - for(let j = 0; j < glyphCount; j++){ - (0, _vertexJs.PositionTexturePickVertex).getPosition(dataView, glyphIndex * 4 + 2, position0); - (0, _vertexJs.PositionTexturePickVertex).getPosition(dataView, glyphIndex * 4 + 1, position1); - (0, _glMatrix.vec3).scale(position0, position0, modelScale); - (0, _glMatrix.vec3).scale(position1, position1, modelScale); - (0, _glMatrix.vec3).transformQuat(position0, position0, modelRotation); - (0, _glMatrix.vec3).transformQuat(position1, position1, modelRotation); - (0, _glMatrix.vec3).add(position0, position0, modelPosition); - (0, _glMatrix.vec3).add(position1, position1, modelPosition); - const centroid = (0, _glMatrix.vec3).create(); - (0, _glMatrix.vec3).add(centroid, position0, position1); - (0, _glMatrix.vec3).scale(centroid, centroid, 0.5); - if (this._labelSet.rotation) (0, _glMatrix.quat).set(glpyhRotation, this._labelSet.rotation[0], this._labelSet.rotation[1], this._labelSet.rotation[2], this._labelSet.rotation[3]); - else if (this._labelSet.rotations) (0, _glMatrix.quat).set(glpyhRotation, this._labelSet.rotations[i * 4], this._labelSet.rotations[i * 4 + 1], this._labelSet.rotations[i * 4 + 2], this._labelSet.rotations[i * 4 + 3]); - else (0, _glMatrix.quat).identity(glpyhRotation); - const rotation = (0, _glMatrix.quat).clone(glpyhRotation); - (0, _glMatrix.quat).multiply(rotation, modelRotation, rotation); - (0, _glMatrix.quat).conjugate(glyphInvRotation, rotation); - (0, _glMatrix.vec3).subtract(position0, position0, centroid); - (0, _glMatrix.vec3).subtract(position1, position1, centroid); - (0, _glMatrix.vec3).transformQuat(position0, position0, glyphInvRotation); - (0, _glMatrix.vec3).transformQuat(position1, position1, glyphInvRotation); - (0, _glMatrix.vec3).add(position0, position0, centroid); - (0, _glMatrix.vec3).add(position1, position1, centroid); - const texCoord0 = (0, _glMatrix.vec2).create(); - const texCoord1 = (0, _glMatrix.vec2).create(); - (0, _vertexJs.PositionTexturePickVertex).getTexCoord(dataView, glyphIndex * 4 + 2, texCoord0); - (0, _vertexJs.PositionTexturePickVertex).getTexCoord(dataView, glyphIndex * 4 + 1, texCoord1); - const hittableFontOptions = { - center0: centroid, - center1: centroid, - time0: 1, - time1: 1, - size: (0, _glMatrix.vec2).fromValues((position1[0] - position0[0]) / 2, (position1[1] - position0[1]) / 2), - material: material, - texCoord0: texCoord0, - texCoord1: texCoord1, - rotation: rotation - }; - const hittable = new (0, _hittableJs.HittableRotatedFontXyRect)(hittableFontOptions); - this.hittables.push(hittable); - glyphIndex++; - } - } - if (this.hasChangedCallback) this.hasChangedCallback(); - } - } -} - -},{"gl-matrix":"9GjEQ","../../vertex.js":"ddAub","./hittable.js":"5bOsK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fTufe":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Buffer", ()=>Buffer); -parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _atlasJs = require("../../atlas.js"); -var _bufferJs = require("../../buffer.js"); -var _indexJs = require("../../index.js"); -var _mainJs = require("../../main.js"); -var _paletteJs = require("../../palette.js"); -var _vertexJs = require("../../vertex.js"); -var _hittableJs = require("./hittable.js"); -var _materialJs = require("./material.js"); -var _mathJs = require("../../helpers/math.js"); -class Buffer extends (0, _bufferJs.BufferBase) { - constructor(core, ids){ - super(core, ids); - this._isInitialized = true; - } - update() { - if (this._isInitialized) { - if (this.hasChangedCallback) this.hasChangedCallback(); - } - } -} -class TransitionBuffer extends (0, _bufferJs.TransitionBufferBase) { - get time0() { - return this._time0; - } - set time0(value) { - if (this._time0 != value) { - this._time0 = value; - this._hasChanged = true; - } - } - get time1() { - return this._time1; - } - set time1(value) { - if (this._time1 != value) { - this._time1 = value; - this._hasChanged = true; + (0, _glMatrix.vec3).set(modelPosition, this.mMatrix[12], this.mMatrix[13], this.mMatrix[14]); + const groundSize = (0, _glMatrix.vec2).create(); + const groundPosition = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec2).scale(groundSize, this.ground.size || this._config.groundSize, modelScale); + if (this.ground.position) (0, _glMatrix.vec3).scale(groundPosition, this.ground.position, modelScale); + else (0, _glMatrix.vec3).set(groundPosition, 0, minY - (0, _constantsJs1.Constants).SHADOW_OFFSET, 0); + const options = { + size0: groundSize, + size1: groundSize, + center0: groundPosition, + center1: groundPosition, + time0: 1, + time1: 1, + texCoord0: (0, _glMatrix.vec2).fromValues(0, 0), + texCoord1: (0, _glMatrix.vec2).fromValues(1, 1), + material: this.ground.material || this.config.defaultMaterial + }; + (0, _glMatrix.vec3).add(options.center0, options.center0, modelPosition); + hittables.push(new (0, _hittableJs.HittableXzRect)(options)); } + return hittables; } - get duration() { - return this._duration; + createFontVisual(font) { + const visual = new (0, _fontJs.FontVisual)(this._core, font); + if (this._isInitialized) visual.initializeContext(this._device); + visual.hasChangedCallback = ()=>{ + this._hasWorldChanged = true; + }; + return visual; } - set duration(value) { - if (this._duration != value) { - this._duration = value; - this._hasChanged = true; - } + createImageVisual(image) { + const visual = new (0, _imageJs.ImageVisual)(this._core, this, image); + if (this._isInitialized) visual.initializeContext(this._device); + visual.hasChangedCallback = ()=>{ + this._hasWorldChanged = true; + }; + return visual; } - get stagger() { - return this.stagger; + createLabelSetVisual(labelSet) { + const visual = new (0, _labelsJs.LabelSetVisual)(this._core, this, labelSet); + visual.hasChangedCallback = ()=>{ + this._hasWorldChanged = true; + }; + return visual; } - set stagger(value) { - if (this._stagger != value) { - this._stagger = value; - this._hasChanged = true; - } + createTransitionBuffer(ids) { + const transitionBuffer = new (0, _bufferJs.TransitionBuffer)(this._core, this, ids); + transitionBuffer.hasChangedCallback = ()=>{ + this._hasWorldChanged = true; + }; + return transitionBuffer; } - constructor(core, main, ids){ - super(core, ids, Buffer, (0, _paletteJs.Palette), (0, _atlasJs.Atlas)); - this._main = main; - this._time0 = 0; - this._time1 = 1; - this._buffer1.hasChangedCallback = ()=>{ - this._hasChanged = true; + _resizeBackings() { + const width = this.width; + const height = this.height; + const colorChannels = 3; + const outputColorBufferSizeBytes = Uint32Array.BYTES_PER_ELEMENT * width * height * colorChannels; + const outputColorBufferDescriptor = { + label: "Output color buffer", + size: outputColorBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC }; - this._buffer2.hasChangedCallback = ()=>{ - this._hasChanged = true; + const outputColorBuffer = this._device.createBuffer(outputColorBufferDescriptor); + const outputNormalDepthBufferSizeBytes = Uint32Array.BYTES_PER_ELEMENT * width * height * 4; + const outputDepthBufferDescriptor = { + label: "Output normal depth buffer", + size: outputNormalDepthBufferSizeBytes, + usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC }; - this._isInitialized = true; - } - update() { - if (this._hasChanged && this._isInitialized) { - this._hasChanged = false; - const start = window.performance.now(); - this.hittables = []; - const modelPosition = (0, _glMatrix.vec3).create(); - const modelScale = this._core.getModelScale(); - const modelRotation = (0, _glMatrix.quat).create(); - this._core.getModelRotation(modelRotation); - this.minY = Number.MAX_VALUE; - (0, _glMatrix.vec3).set(modelPosition, this._main.mMatrix[12], this._main.mMatrix[13], this._main.mMatrix[14]); - const previousBuffer = this.previousBuffer; - const currentBuffer = this.currentBuffer; - const currentUnitTranslation = (0, _glMatrix.vec3).create(); - const previousUnitTranslation = (0, _glMatrix.vec3).create(); - const unitOrder = (0, _glMatrix.vec2).create(); - const transitionDuration = this._duration / (this._duration + this._stagger); - for(let j = 0; j < currentBuffer.ids.length; j++){ - (0, _vertexJs.UnitVertex).getOrder(currentBuffer.dataView, j, unitOrder); - const startTime = unitOrder[1] * (1 - transitionDuration); - const animation0 = (0, _mathJs.MathHelper).clamp((this._time0 - startTime) / transitionDuration, 0, 1); - const animation1 = (0, _mathJs.MathHelper).clamp((this._time1 - startTime) / transitionDuration, 0, 1); - const unitScale = (0, _glMatrix.vec3).create(); - (0, _vertexJs.UnitVertex).getScale(currentBuffer.dataView, j, unitScale); - const unitTranslation0 = (0, _glMatrix.vec3).create(); - const unitTranslation1 = (0, _glMatrix.vec3).create(); - (0, _vertexJs.UnitVertex).getTranslation(currentBuffer.dataView, j, currentUnitTranslation); - (0, _vertexJs.UnitVertex).getTranslation(previousBuffer.dataView, j, previousUnitTranslation); - (0, _glMatrix.vec3).lerp(unitTranslation0, previousUnitTranslation, currentUnitTranslation, animation0); - (0, _glMatrix.vec3).lerp(unitTranslation1, previousUnitTranslation, currentUnitTranslation, animation1); - const unitRotation = (0, _glMatrix.quat).create(); - (0, _vertexJs.UnitVertex).getRotation(currentBuffer.dataView, j, unitRotation); - (0, _glMatrix.quat).multiply(unitRotation, modelRotation, unitRotation); - (0, _glMatrix.vec3).scale(unitTranslation0, unitTranslation0, modelScale); - (0, _glMatrix.vec3).scale(unitTranslation1, unitTranslation1, modelScale); - (0, _glMatrix.vec3).transformQuat(unitTranslation0, unitTranslation0, modelRotation); - (0, _glMatrix.vec3).transformQuat(unitTranslation1, unitTranslation1, modelRotation); - (0, _glMatrix.vec3).add(unitTranslation0, unitTranslation0, modelPosition); - (0, _glMatrix.vec3).add(unitTranslation1, unitTranslation1, modelPosition); - (0, _glMatrix.vec3).scale(unitScale, unitScale, modelScale / 2); - unitScale[0] = Math.max(unitScale[0], 0.00001); - unitScale[1] = Math.max(unitScale[1], 0.00001); - unitScale[2] = Math.max(unitScale[2], 0.00001); - const endTime = startTime + transitionDuration; - const time0 = Math.min(Math.max((startTime - this._time0) / (this._time1 - this.time0), 0), 1); - const time1 = Math.min(Math.max((endTime - this._time0) / (this._time1 - this.time0), 0), 1); - const materialId = (0, _vertexJs.UnitVertex).getMaterial(currentBuffer.dataView, j); - const material = this._main.materials && this._main.materials.length > materialId ? this._main.materials[materialId] : this._main.config.defaultMaterial; - let hittable; - switch(currentBuffer.unitType){ - case (0, _indexJs.UnitType).sphere: - case (0, _indexJs.UnitType).sphereSdf: - hittable = new (0, _hittableJs.HittableSphere)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - radius: unitScale[0], - material: material - }); - break; - case (0, _indexJs.UnitType).block: - if (unitRotation[3] == 1) hittable = new (0, _hittableJs.HittableBox)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - size: unitScale, - material: material - }); - else hittable = new (0, _hittableJs.HittableRotatedBox)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - size: unitScale, - rotation: unitRotation, - material: material - }); - break; - case (0, _indexJs.UnitType).sdf: - const unitTexCoord = (0, _glMatrix.vec4).create(); - (0, _vertexJs.UnitVertex).getTexCoord(currentBuffer.dataView, j, unitTexCoord); - const options = { - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - size: (0, _glMatrix.vec2).fromValues(unitScale[0], unitScale[1]), - texCoord0: (0, _glMatrix.vec2).fromValues(unitTexCoord[0], unitTexCoord[3]), - texCoord1: (0, _glMatrix.vec2).fromValues(unitTexCoord[2], unitTexCoord[1]), - rotation: unitRotation, - material: material - }; - hittable = unitRotation[3] == 1 ? new (0, _hittableJs.HittableSdfXyRect)(options) : new (0, _hittableJs.HittableRotatedSdfXyRect)(options); - break; - case (0, _indexJs.UnitType).blockSdf: - hittable = new (0, _hittableJs.HittableBoxSdf)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - size: unitScale, - rounding: Math.min(Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale[0]), unitScale[1]), unitScale[2]), - material: material - }); - break; - case (0, _indexJs.UnitType).cylinder: - hittable = new (0, _hittableJs.HittableCylinder)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - radius: unitScale[0], - height: unitScale[1], - rotation: unitRotation, - material: material - }); - break; - case (0, _indexJs.UnitType).cylinderSdf: - hittable = new (0, _hittableJs.HittableCylinderSdf)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - radius: unitScale[0], - height: unitScale[1], - rounding: Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale[0]), unitScale[1]), - material: material, - rotation: unitRotation - }); - break; - case (0, _indexJs.UnitType).hexPrism: - hittable = new (0, _hittableJs.HittableHexPrism)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - radius: unitScale[0], - height: unitScale[1], - material: material - }); - break; - case (0, _indexJs.UnitType).hexPrismSdf: - hittable = new (0, _hittableJs.HittableHexPrismSdf)({ - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - radius: unitScale[0], - height: unitScale[1], - rounding: Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale[0]), unitScale[1]), - material: material - }); - break; + const outputNormalDepthBuffer = this._device.createBuffer(outputDepthBufferDescriptor); + const computeShaderModuleDescriptor = { + code: (0, _raytraceJs.ComputeShaderWgsl) + }; + const computeModule = this._device.createShaderModule(computeShaderModuleDescriptor); + const computeBindGroupLayoutDescriptor = { + entries: [ + { + binding: 0, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "storage" + } + }, + { + binding: 1, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "uniform" + } + }, + { + binding: 2, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "read-only-storage" + } + }, + { + binding: 3, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "read-only-storage" + } + }, + { + binding: 4, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "read-only-storage" + } + }, + { + binding: 5, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "read-only-storage" + } + }, + { + binding: 6, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "read-only-storage" + } + }, + { + binding: 7, + visibility: GPUShaderStage.COMPUTE, + sampler: { + type: "filtering" + } + }, + { + binding: 8, + visibility: GPUShaderStage.COMPUTE, + texture: { + multisampled: false, + sampleType: "float", + viewDimension: "2d" + } + }, + { + binding: 9, + visibility: GPUShaderStage.COMPUTE, + texture: { + multisampled: false, + sampleType: "float", + viewDimension: "2d" + } + }, + { + binding: 10, + visibility: GPUShaderStage.COMPUTE, + texture: { + multisampled: false, + sampleType: "float", + viewDimension: "2d" + } + }, + { + binding: 11, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "storage" + } + }, + { + binding: 12, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "storage" + } } - if (hittable.material instanceof (0, _materialJs.IsotropicMaterial)) this.hittables.push(new (0, _hittableJs.HittableConstantMedium)({ - boundary: hittable, - center0: unitTranslation0, - center1: unitTranslation1, - time0: time0, - time1: time1, - material: hittable.material - })); - else this.hittables.push(hittable); - this.minY = Math.min(hittable.bounds.min[1], this.minY); + ] + }; + const computeBindGroupLayout = this._device.createBindGroupLayout(computeBindGroupLayoutDescriptor); + const computeBindGroupDescriptor = { + label: "Compute bind group descriptor", + layout: computeBindGroupLayout, + entries: [ + { + binding: 0, + resource: { + buffer: outputColorBuffer + } + }, + { + binding: 1, + resource: { + buffer: this._computeUniformBuffer + } + }, + { + binding: 2, + resource: { + buffer: this._hittableBuffer + } + }, + { + binding: 3, + resource: { + buffer: this._materialBuffer + } + }, + { + binding: 4, + resource: { + buffer: this._textureBuffer + } + }, + { + binding: 5, + resource: { + buffer: this._lightBuffer + } + }, + { + binding: 6, + resource: { + buffer: this._linearBVHNodeBuffer + } + }, + { + binding: 7, + resource: this._sampler + }, + { + binding: 8, + resource: (this.fonts[this._core.font.name].texture || this._texture).createView() + }, + { + binding: 9, + resource: (this._backgroundTexture || this._texture).createView() + }, + { + binding: 10, + resource: (this._atlasTexture || this._texture).createView() + }, + { + binding: 11, + resource: { + buffer: outputNormalDepthBuffer + } + }, + { + binding: 12, + resource: { + buffer: this._depthMinMaxBuffer + } + } + ] + }; + this._computeBindGroup = this._device.createBindGroup(computeBindGroupDescriptor); + const computePipelineLayoutDescriptor = { + label: "Compute pipeline layout descriptor", + bindGroupLayouts: [ + computeBindGroupLayout + ] + }; + const computePipelineLayout = this._device.createPipelineLayout(computePipelineLayoutDescriptor); + const compute = { + module: computeModule, + entryPoint: "main" + }; + const computePipelineDescriptor = { + label: "Compute pipeline descriptor", + layout: computePipelineLayout, + compute: compute + }; + this._computePipeline = this._device.createComputePipeline(computePipelineDescriptor); + const computeDepthNormal = { + module: computeModule, + entryPoint: "depthNormal" + }; + const computeDepthNormalPipelineDescriptor = { + label: "Depth normal pipeline descriptor", + layout: computePipelineLayout, + compute: computeDepthNormal + }; + this._computeDepthNormalPipeline = this._device.createComputePipeline(computeDepthNormalPipelineDescriptor); + const computeSegment = { + module: computeModule, + entryPoint: "segment" + }; + const computeSegmentPipelineDescriptor = { + label: "Segment pipeline descriptor", + layout: computePipelineLayout, + compute: computeSegment + }; + this._computeSegmentPipeline = this._device.createComputePipeline(computeSegmentPipelineDescriptor); + const clearBindGroupLayoutDescriptor = { + label: "Clear bind group layout descriptor", + entries: [ + { + binding: 0, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "storage" + } + }, + { + binding: 11, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "storage" + } + }, + { + binding: 12, + visibility: GPUShaderStage.COMPUTE, + buffer: { + type: "storage" + } + } + ] + }; + const clearBindGroupLayout = this._device.createBindGroupLayout(clearBindGroupLayoutDescriptor); + const clearBindGroupDescriptor = { + label: "Clear bind group descriptor", + layout: clearBindGroupLayout, + entries: [ + { + binding: 0, + resource: { + buffer: outputColorBuffer + } + }, + { + binding: 11, + resource: { + buffer: outputNormalDepthBuffer + } + }, + { + binding: 12, + resource: { + buffer: this._depthMinMaxBuffer + } + } + ] + }; + this._clearBindGroup = this._device.createBindGroup(clearBindGroupDescriptor); + const clearPipelineLayoutDescriptor = { + label: "Clear pipeline layout descriptor", + bindGroupLayouts: [ + clearBindGroupLayout + ] + }; + const clearPipelineLayout = this._device.createPipelineLayout(clearPipelineLayoutDescriptor); + const clear = { + module: computeModule, + entryPoint: "clear" + }; + const clearPipelineDescriptor = { + label: "Clear pipeline descriptor", + layout: clearPipelineLayout, + compute: clear + }; + this._clearPipeline = this._device.createComputePipeline(clearPipelineDescriptor); + const fullscreenQuadShaderDescriptor = { + label: "Fullscreen quad shader descriptor", + code: (0, _fullscreenquadJs.FullscreenQuadWgsl) + }; + const fullscreenQuadModule = this._device.createShaderModule(fullscreenQuadShaderDescriptor); + const fullscreenQuadBindGroupLayoutDescriptor = { + label: "Fullscreen quad bind group layout descriptor", + entries: [ + { + binding: 0, + visibility: GPUShaderStage.FRAGMENT, + buffer: { + type: "uniform" + } + }, + { + binding: 1, + visibility: GPUShaderStage.FRAGMENT, + buffer: { + type: "read-only-storage" + } + }, + { + binding: 2, + visibility: GPUShaderStage.FRAGMENT, + buffer: { + type: "read-only-storage" + } + } + ] + }; + const fullscreenQuadBindGroupLayout = this._device.createBindGroupLayout(fullscreenQuadBindGroupLayoutDescriptor); + const fullscreenQuadPipelineLayoutDescriptor = { + label: "Fullscreen quad pipeline layout descriptor", + bindGroupLayouts: [ + fullscreenQuadBindGroupLayout + ] + }; + const fullscreenQuadPipelineLayout = this._device.createPipelineLayout(fullscreenQuadPipelineLayoutDescriptor); + const vertex = { + module: fullscreenQuadModule, + entryPoint: "vert_main" + }; + const primitive = { + topology: "triangle-list" + }; + const colorState = { + format: this._presentationFormat + }; + const fragment = { + module: fullscreenQuadModule, + entryPoint: "frag_main", + targets: [ + colorState + ] + }; + const fullscreenQuadPiplelineDescriptor = { + label: "Fullscreen quad pipeline descriptor", + layout: fullscreenQuadPipelineLayout, + vertex: vertex, + fragment: fragment, + primitive: primitive + }; + this._fullscreenQuadPipeline = this._device.createRenderPipeline(fullscreenQuadPiplelineDescriptor); + const fullscreenQuadBindGroupDescriptor = { + label: "Fullscreen quad bind group descriptor", + layout: fullscreenQuadBindGroupLayout, + entries: [ + { + binding: 0, + resource: { + buffer: this._fullscreenQuadUniformBuffer + } + }, + { + binding: 1, + resource: { + buffer: outputColorBuffer + } + }, + { + binding: 2, + resource: { + buffer: outputNormalDepthBuffer + } + } + ] + }; + this._fullscreenQuadBindGroup = this._device.createBindGroup(fullscreenQuadBindGroupDescriptor); + const fragmentHdr = { + module: fullscreenQuadModule, + entryPoint: "frag_main_hdr", + targets: [ + colorState + ] + }; + const fullscreenQuadHdrPiplelineDescriptor = { + label: "Fullscreen quad HDR pipeline descriptor", + layout: fullscreenQuadPipelineLayout, + vertex: vertex, + fragment: fragmentHdr, + primitive: primitive + }; + this._fullscreenQuadHdrPipeline = this._device.createRenderPipeline(fullscreenQuadHdrPiplelineDescriptor); + const fragmentDepth = { + module: fullscreenQuadModule, + entryPoint: "frag_depth", + targets: [ + colorState + ] + }; + const fullscreenQuadDepthPiplelineDescriptor = { + label: "Fullscreen quad depth pipeline descriptor", + layout: fullscreenQuadPipelineLayout, + vertex: vertex, + fragment: fragmentDepth, + primitive: primitive + }; + this._fullscreenQuadDepthPipeline = this._device.createRenderPipeline(fullscreenQuadDepthPiplelineDescriptor); + const fragmentNormal = { + module: fullscreenQuadModule, + entryPoint: "frag_normal", + targets: [ + colorState + ] + }; + const fullscreenQuadNormalPiplelineDescriptor = { + label: "Fullscreen quad normal pipeline descriptor", + layout: fullscreenQuadPipelineLayout, + vertex: vertex, + fragment: fragmentNormal, + primitive: primitive + }; + this._fullscreenQuadNormalPipeline = this._device.createRenderPipeline(fullscreenQuadNormalPiplelineDescriptor); + const fragmentEdge = { + module: fullscreenQuadModule, + entryPoint: "frag_edge", + targets: [ + colorState + ] + }; + const fullscreenQuadEdgePiplelineDescriptor = { + label: "Fullscreen quad edge pipeline descriptor", + layout: fullscreenQuadPipelineLayout, + vertex: vertex, + fragment: fragmentEdge, + primitive: primitive + }; + this._fullscreenQuadEdgePipeline = this._device.createRenderPipeline(fullscreenQuadEdgePiplelineDescriptor); + const fragmentSegment = { + module: fullscreenQuadModule, + entryPoint: "frag_segment", + targets: [ + colorState + ] + }; + const fullscreenQuadSegmentPiplelineDescriptor = { + label: "Fullscreen quad segment pipeline descriptor", + layout: fullscreenQuadPipelineLayout, + vertex: vertex, + fragment: fragmentSegment, + primitive: primitive + }; + this._fullscreenQuadSegmentPipeline = this._device.createRenderPipeline(fullscreenQuadSegmentPiplelineDescriptor); + this._computeUniformBufferData.setWidth(width); + this._computeUniformBufferData.setHeight(height); + this._fullscreenQuadUniformBufferData.setWidth(width); + this._fullscreenQuadUniformBufferData.setHeight(height); + this._computeUniformBufferData.setTime0(0); + this._computeUniformBufferData.setTime1(1); + this._computeDispatchCount = Math.min(Math.ceil(width * height / 256), this._device.limits.maxComputeWorkgroupsPerDimension); + this._frameCount = 0; + this._core.log.write((0, _mainJs.LogLevel).info, "backings resized"); + } + update(elapsedTime) { + super.update(elapsedTime); + for(let i = 0; i < this.transitionBuffers.length; i++){ + const transitionBuffer = this.transitionBuffers[i]; + if (transitionBuffer.isVisible) { + const time0 = this._core.renderer.transitionTime; + const time1 = Math.min(time0 + this._config.shutterSpeed, 1); + transitionBuffer.time0 = time0; + transitionBuffer.time1 = time1; + transitionBuffer.duration = this._core.config.transitionDuration; + transitionBuffer.stagger = this._core.config.transitionStaggering; + transitionBuffer.update(); } - if (this.hasChangedCallback) this.hasChangedCallback(); - this._core.log.write((0, _mainJs.LogLevel).info, `buffer updated ${this._length} ${Math.round(window.performance.now() - start)}ms`); } + if (this._haveLightsChanged || !this._lightBuffer) { + this._haveLightsChanged = false; + this._createLights(); + } + if (this._hasWorldChanged) { + this._hasWorldChanged = false; + this._createWorld().then(()=>{ + if (this._hittables.length > 0) { + this._resizeBackings(); + this._worldCreated = true; + } + }); + } + if (this._core.config.isDebugVisible) this._core.debugText.addLine(`frm tot ${this._frameCount}`); } -} - -},{"gl-matrix":"9GjEQ","../../atlas.js":"duwwc","../../buffer.js":"k3bT1","../../index.js":"eKLJv","../../main.js":"1Kju3","../../palette.js":"8zxgm","../../vertex.js":"ddAub","./hittable.js":"5bOsK","./material.js":"5mttU","../../helpers/math.js":"fOnPF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3ibK7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Constants", ()=>Constants); -class Constants { -} -Constants.SHADOW_OFFSET = 0.001; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"68giq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Ground", ()=>Ground); -class Ground { - constructor(options){ - if (options) { - this.position = options.position; - this.size = options.size; - this.material = options.material; + render(elapsedTime) { + return __awaiter(this, void 0, void 0, function*() { + if (!this._worldCreated || !this._areLightsInitialized || this._hittables.length == 0) return; + const epsilon = 0.000001; + if (Math.abs(this._computeUniformBufferData.getFieldOfView() - this._core.config.fov) > epsilon) { + this._frameCount = 0; + this._computeUniformBufferData.setFieldOfView(this._core.config.fov); + } + if (Math.abs(this._computeUniformBufferData.getAperture() - this._config.aperture) > epsilon) { + this._frameCount = 0; + this._computeUniformBufferData.setAperture(this._config.aperture); + } + const m = this.inverseVMatrices[0]; + this._computeUniformBufferData.getPosition(this._position); + this._computeUniformBufferData.getRight(this._right); + this._computeUniformBufferData.getUp(this._up); + this._computeUniformBufferData.getForward(this._forward); + if (Math.abs(this._position[0] - m[12]) > epsilon || Math.abs(this._position[1] - m[13]) > epsilon || Math.abs(this._position[2] - m[14]) > epsilon || Math.abs(this._right[0] - m[0]) > epsilon || Math.abs(this._right[1] - m[1]) > epsilon || Math.abs(this._right[2] - m[2]) > epsilon || Math.abs(this._up[0] - m[4]) > epsilon || Math.abs(this._up[1] - m[5]) > epsilon || Math.abs(this._up[2] - m[6]) > epsilon || Math.abs(this._forward[0] - m[8]) > epsilon || Math.abs(this._forward[1] - m[9]) > epsilon || Math.abs(this._forward[2] - m[10]) > epsilon) { + this._frameCount = 0; + (0, _glMatrix.vec3).set(this._position, m[12], m[13], m[14]); + (0, _glMatrix.vec3).set(this._right, m[0], m[1], m[2]); + (0, _glMatrix.vec3).set(this._up, m[4], m[5], m[6]); + (0, _glMatrix.vec3).set(this._forward, m[8], m[9], m[10]); + this._computeUniformBufferData.setPosition(this._position); + this._computeUniformBufferData.setRight(this._right); + this._computeUniformBufferData.setUp(this._up); + this._computeUniformBufferData.setForward(this._forward); + this._core.getModelPosition(this._modelPosition); + this._core.getModelManipulationOrigin(this._manipulationOrigin); + (0, _glMatrix.vec3).add(this._modelPosition, this._modelPosition, this._manipulationOrigin); + this._computeUniformBufferData.setLookAt(this._modelPosition); + } + this._computeUniformBufferData.getBackgroundColor(this._backgroundColor); + if (!(0, _glMatrix.vec4).equals(this._backgroundColor, this._config.backgroundColor)) { + this._frameCount = 0; + this._computeUniformBufferData.setBackgroundColor(this._config.backgroundColor); + } + this._tilesX = this._computeUniformBufferData.getTilesX(); + this._tilesY = this._computeUniformBufferData.getTilesY(); + this._tileOffsetX = this._computeUniformBufferData.getTileOffsetX(); + this._tileOffsetY = this._computeUniformBufferData.getTileOffsetY(); + if (this._tilesX != this._core.config.tilesX || this._tilesY != this._core.config.tilesY || this._tileOffsetX != this._core.config.tileOffsetX || this._tileOffsetY != this._core.config.tileOffsetY) { + this._frameCount = 0; + this._computeUniformBufferData.setTilesX(this._core.config.tilesX); + this._computeUniformBufferData.setTilesY(this._core.config.tilesY); + this._computeUniformBufferData.setTileOffsetX(this._core.config.tileOffsetX); + this._computeUniformBufferData.setTileOffsetY(this._core.config.tileOffsetY); + } + const clear = this._frameCount == 0; + if (clear) { + this._duration = 0; + this._startTime = performance.now(); + } + if (this._frameCount >= this._config.maxSamplesPerPixel) { + this._core.stop(); + return; + } + const raysPerFrame = this._config.raysPerFrame; + this._computeUniformBufferData.setRaysPerFrame(raysPerFrame); + this._computeUniformBufferData.setSeed(this._core.totalFrames * raysPerFrame); + this._device.queue.writeBuffer(this._computeUniformBuffer, 0, this._computeUniformBufferData.buffer, this._computeUniformBufferData.byteOffset, this._computeUniformBufferData.byteLength); + this._frameCount += raysPerFrame; + this._fullscreenQuadUniformBufferData.setSamplesPerPixel(this._frameCount); + this._fullscreenQuadUniformBufferData.setExposure(this._config.exposure); + this._fullscreenQuadUniformBufferData.setMinDepth(this._config.minDepth); + this._fullscreenQuadUniformBufferData.setMaxDepth(this._config.maxDepth); + this._fullscreenQuadUniformBufferData.setEdgeDepth(this._config.edgeDepth); + this._fullscreenQuadUniformBufferData.setEdgeNormal(this._config.edgeNormal); + this._device.queue.writeBuffer(this._fullscreenQuadUniformBuffer, 0, this._fullscreenQuadUniformBufferData.buffer, this._fullscreenQuadUniformBufferData.byteOffset, this._fullscreenQuadUniformBufferData.byteLength); + yield this._encodeCommands(clear); + this._duration = performance.now() - this._startTime; + }); + } + clear() { + this._frameCount = 0; + } + _encodeCommands(clear) { + return __awaiter(this, void 0, void 0, function*() { + const commandEncoder = this._device.createCommandEncoder(); + const computePassEncoder = commandEncoder.beginComputePass(); + if (clear) { + computePassEncoder.setPipeline(this._clearPipeline); + computePassEncoder.setBindGroup(0, this._clearBindGroup); + computePassEncoder.dispatchWorkgroups(this._computeDispatchCount, 1, 1); + } + switch(this._core.config.renderMode){ + case (0, _mainJs.RenderMode).color: + case (0, _mainJs.RenderMode).hdr: + computePassEncoder.setPipeline(this._computePipeline); + computePassEncoder.setBindGroup(0, this._computeBindGroup); + computePassEncoder.dispatchWorkgroups(this._computeDispatchCount, 1, 1); + computePassEncoder.end(); + break; + case (0, _mainJs.RenderMode).depth: + case (0, _mainJs.RenderMode).normal: + computePassEncoder.setPipeline(this._computeDepthNormalPipeline); + computePassEncoder.setBindGroup(0, this._computeBindGroup); + computePassEncoder.dispatchWorkgroups(this._computeDispatchCount, 1, 1); + computePassEncoder.end(); + commandEncoder.copyBufferToBuffer(this._depthMinMaxBuffer, 0, this._depthMinMaxResultBuffer, 0, this._depthMinMaxResultBuffer.size); + if (this._config.autoDepth) { + yield this._depthMinMaxResultBuffer.mapAsync(GPUMapMode.READ); + const depthMinMax = new Uint32Array(this._depthMinMaxResultBuffer.getMappedRange()); + const depthMin = depthMinMax[0] / 1000; + const depthMax = depthMinMax[1] / 1000; + if (this._config.minDepth != depthMin || this._config.maxDepth != depthMax) console.log('depthMinMax', depthMin, depthMax); + this._config.minDepth = depthMin; + this._config.maxDepth = depthMax; + this._depthMinMaxResultBuffer.unmap(); + } + break; + case (0, _mainJs.RenderMode).edge: + case (0, _mainJs.RenderMode).segment: + computePassEncoder.setPipeline(this._computeSegmentPipeline); + computePassEncoder.setBindGroup(0, this._computeBindGroup); + computePassEncoder.dispatchWorkgroups(this._computeDispatchCount, 1, 1); + computePassEncoder.end(); + break; + } + const colorAttachment = { + view: this._context.getCurrentTexture().createView(), + clearValue: { + r: 0.0, + g: 0.0, + b: 0.0, + a: 0.0 + }, + loadOp: "clear", + storeOp: "store" + }; + const fullscreenQuadRenderPassDescriptor = { + colorAttachments: [ + colorAttachment + ] + }; + const renderPassEncoder = commandEncoder.beginRenderPass(fullscreenQuadRenderPassDescriptor); + switch(this._core.config.renderMode){ + case (0, _mainJs.RenderMode).color: + renderPassEncoder.setPipeline(this._fullscreenQuadPipeline); + break; + case (0, _mainJs.RenderMode).hdr: + renderPassEncoder.setPipeline(this._fullscreenQuadHdrPipeline); + break; + case (0, _mainJs.RenderMode).depth: + renderPassEncoder.setPipeline(this._fullscreenQuadDepthPipeline); + break; + case (0, _mainJs.RenderMode).normal: + renderPassEncoder.setPipeline(this._fullscreenQuadNormalPipeline); + break; + case (0, _mainJs.RenderMode).edge: + renderPassEncoder.setPipeline(this._fullscreenQuadEdgePipeline); + break; + case (0, _mainJs.RenderMode).segment: + renderPassEncoder.setPipeline(this._fullscreenQuadSegmentPipeline); + break; + } + renderPassEncoder.setBindGroup(0, this._fullscreenQuadBindGroup); + renderPassEncoder.draw(6, 1, 0, 0); + renderPassEncoder.end(); + this._queue.submit([ + commandEncoder.finish() + ]); + }); + } + _resize(width, height) { + super._resize(width, height); + if (this._isInitialized && this._hittables.length > 0) { + this._resizeBackings(); + this._core.log.write((0, _mainJs.LogLevel).info, `buffers resized ${width},${height}`); } } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6ceod":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"gl-matrix":"5x28d","../renderer.js":"8zmPQ","../../main.js":"f421K","./config.js":"2dRLO","./hittable.js":"5cw7N","./material.js":"jQJhi","./shaders/raytrace.js":"cAHlu","./shaders/fullscreenquad.js":"1gtMg","./bvh.js":"8lb3C","./texture.js":"5NgmA","./light.js":"2sMdC","../../constants.js":"lD0bG","../../helpers/angle.js":"53hwW","./font.js":"3rF26","./image.js":"enHlm","./labels.js":"72uDI","./buffer.js":"dRm64","./constants.js":"6DWH0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2dRLO":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ parcelHelpers.export(exports, "Table", ()=>(0, _tableJs.Table)); -parcelHelpers.export(exports, "ColumnType", ()=>(0, _tableJs.ColumnType)); -parcelHelpers.export(exports, "Filter", ()=>(0, _filterJs.Filter)); -var _tableJs = require("./table.js"); -var _filterJs = require("./filter.js"); - -},{"./table.js":"gsKwH","./filter.js":"gwwV8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dDVZM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ parcelHelpers.export(exports, "CameraBase", ()=>(0, _cameraJs.CameraBase)); -parcelHelpers.export(exports, "CameraView", ()=>(0, _cameraJs.CameraView)); -parcelHelpers.export(exports, "AltAzimuthCamera", ()=>(0, _altazimuthJs.AltAzimuthCamera)); -parcelHelpers.export(exports, "AltAzimuthCameraView", ()=>(0, _altazimuthJs.AltAzimuthCameraView)); -parcelHelpers.export(exports, "OrbitCamera", ()=>(0, _orbitJs.OrbitCamera)); -var _cameraJs = require("./camera.js"); -var _altazimuthJs = require("./altazimuth.js"); -var _orbitJs = require("./orbit.js"); - -},{"./camera.js":"5VwCW","./altazimuth.js":"6C63a","./orbit.js":"8xYw7","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8xYw7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "OrbitCamera", ()=>OrbitCamera); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -var _constantsJs = require("../constants.js"); -var _cameraJs = require("./camera.js"); -class OrbitCamera extends (0, _cameraJs.CameraBase) { - getTwist(value) { - (0, _glMatrix.quat).copy(value, this._cameraRotation); - } - setTwist(value, isSmooth) { - (0, _glMatrix.quat).copy(this._cameraRotation, value); - if (!isSmooth) (0, _glMatrix.quat).copy(this._smoothedCameraRotation, value); - } - twist(angle, x, y) { - this.unproject(this._vec3, x, y, 1); - (0, _glMatrix.vec3).normalize(this._vec3, this._vec3); - (0, _glMatrix.vec3).transformQuat(this._vec3, this._vec3, this._orbitRotation); - this._twist(this._vec3, angle); +parcelHelpers.export(exports, "Config", ()=>Config); +var _glMatrix = require("gl-matrix"); +var _rendererJs = require("../renderer.js"); +var _materialJs = require("./material.js"); +var _textureJs = require("./texture.js"); +class Config extends (0, _rendererJs.RendererConfig) { + constructor(){ + super(); + this.reset(); } - _twist(axis, angle) { - (0, _glMatrix.quat).setAxisAngle(this._quat, axis, angle); - (0, _glMatrix.quat).multiply(this._cameraRotation, this._quat, this._cameraRotation); + standardLightingOptions(options) { + const azimuthOffset = options && options.azimuthOffset ? options.azimuthOffset : this.lightingAzimuthOffset; + const altitude = options && options.altitude ? options.altitude : this.lightingAltitude; + const size = options && options.size ? options.size : this.lightingSize; + const distance = options && options.distance ? options.distance : this.lightingDistance; + return [ + { + azimuth: -45 + azimuthOffset, + altitude: altitude, + distance: distance, + size: (0, _glMatrix.vec2).fromValues(size, size), + yaw: -45 + azimuthOffset, + pitch: altitude, + color: (0, _glMatrix.vec3).fromValues(10, 10, 10) + }, + { + azimuth: 45 + azimuthOffset, + altitude: altitude, + distance: distance, + size: (0, _glMatrix.vec2).fromValues(size, size), + yaw: 45 + azimuthOffset, + pitch: altitude, + color: (0, _glMatrix.vec3).fromValues(1, 1, 1) + }, + { + azimuth: -135 + azimuthOffset, + altitude: altitude, + distance: distance, + size: (0, _glMatrix.vec2).fromValues(size, size), + yaw: -135 + azimuthOffset, + pitch: altitude, + color: (0, _glMatrix.vec3).fromValues(1, 1, 1) + } + ]; } - rotate(translationDelta) { - (0, _glMatrix.vec3).set(this._vec3, translationDelta[1], translationDelta[0], 0); - const length = (0, _glMatrix.vec3).length(this._vec3); - const angle = length * (0, _constantsJs.Constants).PI / Math.min(this.width, this.height); - (0, _glMatrix.vec3).scale(this._vec3, this._vec3, 1 / length); - (0, _glMatrix.quat).setAxisAngle(this._quat, this._vec3, angle); - (0, _glMatrix.quat).multiply(this._orbitRotation, this._quat, this._orbitRotation); + reset() { + this.aperture = 0; + this.exposure = 1; + this.maxSamplesPerPixel = 10000; + this.shutterSpeed = 0; + this.raysPerFrame = 1; + this.maxPrimsInNode = 1; + this.defaultMaterial = new (0, _materialJs.LambertianMaterial)({ + texture: new (0, _textureJs.SolidColorTexture)({ + color: (0, _glMatrix.vec3).fromValues(0.5, 0.5, 0.5) + }) + }); + this.defaultTextMaterial = new (0, _materialJs.LambertianMaterial)({ + texture: new (0, _textureJs.SolidColorTexture)({ + color: (0, _glMatrix.vec3).fromValues(1, 1, 1) + }) + }); + this.groundSize = (0, _glMatrix.vec2).fromValues(10, 10); + this.backgroundColor = (0, _glMatrix.vec4).fromValues(0, 0, 0, 1); + this.lightingAzimuthOffset = 0; + this.lightingAltitude = 30; + this.lightingSize = 0.5; + this.lightingDistance = 1.5; + this.autoDepth = true; + this.minDepth = 1; + this.maxDepth = 10; + this.edgeDepth = 0.01; + this.edgeNormal = 0.025; } } -},{"gl-matrix":"9GjEQ","../constants.js":"2Scl5","./camera.js":"5VwCW","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lwUwQ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Colors", ()=>Colors); +},{"gl-matrix":"5x28d","../renderer.js":"8zmPQ","./material.js":"jQJhi","./texture.js":"5NgmA","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jQJhi":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _glMatrix = require("gl-matrix"); -class Colors { -} -Colors.MediumVioletRed = (0, _glMatrix.vec3).fromValues(0xc7, 0x15, 0x85); -Colors.DeepPink = (0, _glMatrix.vec3).fromValues(0xff, 0x14, 0x93); -Colors.PaleVioletRed = (0, _glMatrix.vec3).fromValues(0xdb, 0x70, 0x93); -Colors.HotPink = (0, _glMatrix.vec3).fromValues(0xff, 0x69, 0xb4); -Colors.LightPink = (0, _glMatrix.vec3).fromValues(0xff, 0xb6, 0xc1); -Colors.Pink = (0, _glMatrix.vec3).fromValues(0xff, 0xc0, 0xcb); -Colors.DarkRed = (0, _glMatrix.vec3).fromValues(0x8b, 0x00, 0x00); -Colors.Red = (0, _glMatrix.vec3).fromValues(0xff, 0x00, 0x00); -Colors.Firebrick = (0, _glMatrix.vec3).fromValues(0xb2, 0x22, 0x22); -Colors.Crimson = (0, _glMatrix.vec3).fromValues(0xdc, 0x14, 0x3c); -Colors.IndianRed = (0, _glMatrix.vec3).fromValues(0xcd, 0x5c, 0x5c); -Colors.LightCoral = (0, _glMatrix.vec3).fromValues(0xf0, 0x80, 0x80); -Colors.Salmon = (0, _glMatrix.vec3).fromValues(0xfa, 0x80, 0x72); -Colors.DarkSalmon = (0, _glMatrix.vec3).fromValues(0xe9, 0x96, 0x7a); -Colors.LightSalmon = (0, _glMatrix.vec3).fromValues(0xff, 0xa0, 0x7a); -Colors.OrangeRed = (0, _glMatrix.vec3).fromValues(0xff, 0x45, 0x00); -Colors.Tomato = (0, _glMatrix.vec3).fromValues(0xff, 0x63, 0x47); -Colors.DarkOrange = (0, _glMatrix.vec3).fromValues(0xff, 0x8c, 0x00); -Colors.Coral = (0, _glMatrix.vec3).fromValues(0xff, 0x7f, 0x50); -Colors.Orange = (0, _glMatrix.vec3).fromValues(0xff, 0xa5, 0x00); -Colors.DarkKhaki = (0, _glMatrix.vec3).fromValues(0xbd, 0xb7, 0x6b); -Colors.Gold = (0, _glMatrix.vec3).fromValues(0xff, 0xd7, 0x00); -Colors.Khaki = (0, _glMatrix.vec3).fromValues(0xf0, 0xe6, 0x8c); -Colors.PeachPuff = (0, _glMatrix.vec3).fromValues(0xff, 0xda, 0xb9); -Colors.Yellow = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0x00); -Colors.PaleGoldenrod = (0, _glMatrix.vec3).fromValues(0xee, 0xe8, 0xaa); -Colors.Moccasin = (0, _glMatrix.vec3).fromValues(0xff, 0xe4, 0xb5); -Colors.PapayaWhip = (0, _glMatrix.vec3).fromValues(0xff, 0xef, 0xd5); -Colors.LightGoldenrodYellow = (0, _glMatrix.vec3).fromValues(0xfa, 0xfa, 0xd2); -Colors.LemonChiffon = (0, _glMatrix.vec3).fromValues(0xff, 0xfa, 0xcd); -Colors.LightYellow = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0xe0); -Colors.Maroon = (0, _glMatrix.vec3).fromValues(0x80, 0x00, 0x00); -Colors.Brown = (0, _glMatrix.vec3).fromValues(0xa5, 0x2a, 0x2a); -Colors.SaddleBrown = (0, _glMatrix.vec3).fromValues(0x8b, 0x45, 0x13); -Colors.Sienna = (0, _glMatrix.vec3).fromValues(0xa0, 0x52, 0x2d); -Colors.Chocolate = (0, _glMatrix.vec3).fromValues(0xd2, 0x69, 0x1e); -Colors.DarkGoldenrod = (0, _glMatrix.vec3).fromValues(0xb8, 0x86, 0x0b); -Colors.Peru = (0, _glMatrix.vec3).fromValues(0xcd, 0x85, 0x3f); -Colors.RosyBrown = (0, _glMatrix.vec3).fromValues(0xbc, 0x8f, 0x8f); -Colors.Goldenrod = (0, _glMatrix.vec3).fromValues(0xda, 0xa5, 0x20); -Colors.SandyBrown = (0, _glMatrix.vec3).fromValues(0xf4, 0xa4, 0x60); -Colors.Tan = (0, _glMatrix.vec3).fromValues(0xd2, 0xb4, 0x8c); -Colors.Burlywood = (0, _glMatrix.vec3).fromValues(0xde, 0xb8, 0x87); -Colors.Wheat = (0, _glMatrix.vec3).fromValues(0xf5, 0xde, 0xb3); -Colors.NavajoWhite = (0, _glMatrix.vec3).fromValues(0xff, 0xde, 0xad); -Colors.Bisque = (0, _glMatrix.vec3).fromValues(0xff, 0xe4, 0xc4); -Colors.BlanchedAlmond = (0, _glMatrix.vec3).fromValues(0xff, 0xeb, 0xcd); -Colors.Cornsilk = (0, _glMatrix.vec3).fromValues(0xff, 0xf8, 0xdc); -Colors.DarkGreen = (0, _glMatrix.vec3).fromValues(0x00, 0x64, 0x00); -Colors.Green = (0, _glMatrix.vec3).fromValues(0x00, 0x80, 0x00); -Colors.DarkOliveGreen = (0, _glMatrix.vec3).fromValues(0x55, 0x6b, 0x2f); -Colors.ForestGreen = (0, _glMatrix.vec3).fromValues(0x22, 0x8b, 0x22); -Colors.SeaGreen = (0, _glMatrix.vec3).fromValues(0x2e, 0x8b, 0x57); -Colors.Olive = (0, _glMatrix.vec3).fromValues(0x80, 0x80, 0x00); -Colors.OliveDrab = (0, _glMatrix.vec3).fromValues(0x6b, 0x8e, 0x23); -Colors.MediumSeaGreen = (0, _glMatrix.vec3).fromValues(0x3c, 0xb3, 0x71); -Colors.LimeGreen = (0, _glMatrix.vec3).fromValues(0x32, 0xcd, 0x32); -Colors.Lime = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0x00); -Colors.SpringGreen = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0x7f); -Colors.MediumSpringGreen = (0, _glMatrix.vec3).fromValues(0x00, 0xfa, 0x9a); -Colors.DarkSeaGreen = (0, _glMatrix.vec3).fromValues(0x8f, 0xbc, 0x8f); -Colors.MediumAquamarine = (0, _glMatrix.vec3).fromValues(0x66, 0xcd, 0xaa); -Colors.YellowGreen = (0, _glMatrix.vec3).fromValues(0x9a, 0xcd, 0x32); -Colors.LawnGreen = (0, _glMatrix.vec3).fromValues(0x7c, 0xfc, 0x00); -Colors.Chartreuse = (0, _glMatrix.vec3).fromValues(0x7f, 0xff, 0x00); -Colors.LightGreen = (0, _glMatrix.vec3).fromValues(0x90, 0xee, 0x90); -Colors.GreenYellow = (0, _glMatrix.vec3).fromValues(0xad, 0xff, 0x2f); -Colors.PaleGreen = (0, _glMatrix.vec3).fromValues(0x98, 0xfb, 0x98); -Colors.Teal = (0, _glMatrix.vec3).fromValues(0x00, 0x80, 0x80); -Colors.DarkCyan = (0, _glMatrix.vec3).fromValues(0x00, 0x8b, 0x8b); -Colors.LightSeaGreen = (0, _glMatrix.vec3).fromValues(0x20, 0xb2, 0xaa); -Colors.CadetBlue = (0, _glMatrix.vec3).fromValues(0x5f, 0x9e, 0xa0); -Colors.DarkTurquoise = (0, _glMatrix.vec3).fromValues(0x00, 0xce, 0xd1); -Colors.MediumTurquoise = (0, _glMatrix.vec3).fromValues(0x48, 0xd1, 0xcc); -Colors.Turquoise = (0, _glMatrix.vec3).fromValues(0x40, 0xe0, 0xd0); -Colors.Aqua = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0xff); -Colors.Cyan = (0, _glMatrix.vec3).fromValues(0x00, 0xff, 0xff); -Colors.Aquamarine = (0, _glMatrix.vec3).fromValues(0x7f, 0xff, 0xd4); -Colors.PaleTurquoise = (0, _glMatrix.vec3).fromValues(0xaf, 0xee, 0xee); -Colors.LightCyan = (0, _glMatrix.vec3).fromValues(0xe0, 0xff, 0xff); -Colors.Navy = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0x80); -Colors.DarkBlue = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0x8b); -Colors.MediumBlue = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0xcd); -Colors.Blue = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0xff); -Colors.MidnightBlue = (0, _glMatrix.vec3).fromValues(0x19, 0x19, 0x70); -Colors.RoyalBlue = (0, _glMatrix.vec3).fromValues(0x41, 0x69, 0xe1); -Colors.SteelBlue = (0, _glMatrix.vec3).fromValues(0x46, 0x82, 0xb4); -Colors.DodgerBlue = (0, _glMatrix.vec3).fromValues(0x1e, 0x90, 0xff); -Colors.DeepSkyBlue = (0, _glMatrix.vec3).fromValues(0x00, 0xbf, 0xff); -Colors.CornflowerBlue = (0, _glMatrix.vec3).fromValues(0x64, 0x95, 0xed); -Colors.SkyBlue = (0, _glMatrix.vec3).fromValues(0x87, 0xce, 0xeb); -Colors.LightSkyBlue = (0, _glMatrix.vec3).fromValues(0x87, 0xce, 0xfa); -Colors.LightSteelBlue = (0, _glMatrix.vec3).fromValues(0xb0, 0xc4, 0xde); -Colors.LightBlue = (0, _glMatrix.vec3).fromValues(0xad, 0xd8, 0xe6); -Colors.PowderBlue = (0, _glMatrix.vec3).fromValues(0xb0, 0xe0, 0xe6); -Colors.Indigo = (0, _glMatrix.vec3).fromValues(0x4b, 0x00, 0x82); -Colors.Purple = (0, _glMatrix.vec3).fromValues(0x80, 0x00, 0x80); -Colors.DarkMagenta = (0, _glMatrix.vec3).fromValues(0x8b, 0x00, 0x8b); -Colors.DarkViolet = (0, _glMatrix.vec3).fromValues(0x94, 0x00, 0xd3); -Colors.DarkSlateBlue = (0, _glMatrix.vec3).fromValues(0x48, 0x3d, 0x8b); -Colors.BlueViolet = (0, _glMatrix.vec3).fromValues(0x8a, 0x2b, 0xe2); -Colors.DarkOrchid = (0, _glMatrix.vec3).fromValues(0x99, 0x32, 0xcc); -Colors.Fuchsia = (0, _glMatrix.vec3).fromValues(0xff, 0x00, 0xff); -Colors.Magenta = (0, _glMatrix.vec3).fromValues(0xff, 0x00, 0xff); -Colors.SlateBlue = (0, _glMatrix.vec3).fromValues(0x6a, 0x5a, 0xcd); -Colors.MediumSlateBlue = (0, _glMatrix.vec3).fromValues(0x7b, 0x68, 0xee); -Colors.MediumOrchid = (0, _glMatrix.vec3).fromValues(0xba, 0x55, 0xd3); -Colors.MediumPurple = (0, _glMatrix.vec3).fromValues(0x93, 0x70, 0xdb); -Colors.Orchid = (0, _glMatrix.vec3).fromValues(0xda, 0x70, 0xd6); -Colors.Violet = (0, _glMatrix.vec3).fromValues(0xee, 0x82, 0xee); -Colors.Plum = (0, _glMatrix.vec3).fromValues(0xdd, 0xa0, 0xdd); -Colors.Thistle = (0, _glMatrix.vec3).fromValues(0xd8, 0xbf, 0xd8); -Colors.Lavender = (0, _glMatrix.vec3).fromValues(0xe6, 0xe6, 0xfa); -Colors.MistyRose = (0, _glMatrix.vec3).fromValues(0xff, 0xe4, 0xe1); -Colors.AntiqueWhite = (0, _glMatrix.vec3).fromValues(0xfa, 0xeb, 0xd7); -Colors.Linen = (0, _glMatrix.vec3).fromValues(0xfa, 0xf0, 0xe6); -Colors.Beige = (0, _glMatrix.vec3).fromValues(0xf5, 0xf5, 0xdc); -Colors.WhiteSmoke = (0, _glMatrix.vec3).fromValues(0xf5, 0xf5, 0xf5); -Colors.LavenderBlush = (0, _glMatrix.vec3).fromValues(0xff, 0xf0, 0xf5); -Colors.OldLace = (0, _glMatrix.vec3).fromValues(0xfd, 0xf5, 0xe6); -Colors.AliceBlue = (0, _glMatrix.vec3).fromValues(0xf0, 0xf8, 0xff); -Colors.Seashell = (0, _glMatrix.vec3).fromValues(0xff, 0xf5, 0xee); -Colors.GhostWhite = (0, _glMatrix.vec3).fromValues(0xf8, 0xf8, 0xff); -Colors.Honeydew = (0, _glMatrix.vec3).fromValues(0xf0, 0xff, 0xf0); -Colors.FloralWhite = (0, _glMatrix.vec3).fromValues(0xff, 0xfa, 0xf0); -Colors.Azure = (0, _glMatrix.vec3).fromValues(0xf0, 0xff, 0xff); -Colors.MintCream = (0, _glMatrix.vec3).fromValues(0xf5, 0xff, 0xfa); -Colors.Snow = (0, _glMatrix.vec3).fromValues(0xff, 0xfa, 0xfa); -Colors.Ivory = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0xf0); -Colors.White = (0, _glMatrix.vec3).fromValues(0xff, 0xff, 0xff); -Colors.Black = (0, _glMatrix.vec3).fromValues(0x00, 0x00, 0x00); -Colors.DarkSlateGray = (0, _glMatrix.vec3).fromValues(0x2f, 0x4f, 0x4f); -Colors.DimGray = (0, _glMatrix.vec3).fromValues(0x69, 0x69, 0x69); -Colors.SlateGray = (0, _glMatrix.vec3).fromValues(0x70, 0x80, 0x90); -Colors.Gray = (0, _glMatrix.vec3).fromValues(0x80, 0x80, 0x80); -Colors.LightSlateGray = (0, _glMatrix.vec3).fromValues(0x77, 0x88, 0x99); -Colors.DarkGray = (0, _glMatrix.vec3).fromValues(0xa9, 0xa9, 0xa9); -Colors.Silver = (0, _glMatrix.vec3).fromValues(0xc0, 0xc0, 0xc0); -Colors.LightGray = (0, _glMatrix.vec3).fromValues(0xd3, 0xd3, 0xd3); -Colors.Gainsboro = (0, _glMatrix.vec3).fromValues(0xdc, 0xdc, 0xdc); -Colors.Copper = (0, _glMatrix.vec3).fromValues(0xb8, 0x73, 0x33); -Colors.Bronze = (0, _glMatrix.vec3).fromValues(0xcd, 0x7f, 0x32); -Colors.Steel = (0, _glMatrix.vec3).fromValues(0xce, 0xd2, 0xd7); -Colors.Platinum = (0, _glMatrix.vec3).fromValues(0xe5, 0xe4, 0xe2); -Colors.Gunmetal = (0, _glMatrix.vec3).fromValues(0x5c, 0x5d, 0x5b); -Colors.Titanium = (0, _glMatrix.vec3).fromValues(0x87, 0x86, 0x81); -Colors.RoseGold = (0, _glMatrix.vec3).fromValues(0xcb, 0xa3, 0xb2); -Colors.AquaGlass = (0, _glMatrix.vec3).fromValues(0xd2, 0xe8, 0xdf); -Colors.BlueGlass = (0, _glMatrix.vec3).fromValues(0xc7, 0xe3, 0xe1); - -},{"gl-matrix":"9GjEQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eFmnR":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "MapItem", ()=>MapItem); -parcelHelpers.export(exports, "MapVisual", ()=>MapVisual); -parcelHelpers.export(exports, "Map", ()=>Map); -parcelHelpers.export(exports, "MapAtlas", ()=>MapAtlas); -parcelHelpers.export(exports, "MapRasterizer", ()=>MapRasterizer); -parcelHelpers.export(exports, "GeoJSONRasterizer", ()=>GeoJSONRasterizer); -/*! - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ var _mapJs = require("./helpers/map.js"); -var _mainJs = require("./main.js"); -class MapItem { - toJSON() { - return { - key: this.key, - minLat: this.minLat, - maxLat: this.maxLat, - minLon: this.minLon, - maxLon: this.maxLon, - u0: this.u0, - v0: this.v0, - u1: this.u1, - v1: this.v1 - }; +parcelHelpers.export(exports, "MaterialType", ()=>MaterialType); +parcelHelpers.export(exports, "MaterialBufferData", ()=>MaterialBufferData); +parcelHelpers.export(exports, "Material", ()=>Material); +parcelHelpers.export(exports, "LambertianMaterial", ()=>LambertianMaterial); +parcelHelpers.export(exports, "MetalMaterial", ()=>MetalMaterial); +parcelHelpers.export(exports, "DielectricMaterial", ()=>DielectricMaterial); +parcelHelpers.export(exports, "DiffuseLightMaterial", ()=>DiffuseLightMaterial); +parcelHelpers.export(exports, "GlossyMaterial", ()=>GlossyMaterial); +parcelHelpers.export(exports, "IsotropicMaterial", ()=>IsotropicMaterial); +parcelHelpers.export(exports, "VarnishMaterial", ()=>VarnishMaterial); +var _glMatrix = require("gl-matrix"); +const MaterialType = { + lambertian: 0, + metal: 1, + dielectric: 2, + glossy: 3, + diffuseLight: 4, + isotropic: 5, + varnish: 6 +}; +class MaterialBufferData extends Float32Array { + constructor(count){ + super(count * MaterialBufferData.SIZE); + this.TYPE_OFFSET = 0; + this.FUZZ_OFFSET = 1; + this.REFRACTIVE_INDEX_OFFSET = 2; + this.TEXTURE_ID_OFFSET = 3; + this.COLOR_OFFSET = 4; + this.GLOSSINESS_OFFSET = 7; + this.ID_COLOR_OFFSET = 8; + this.DENSITY_OFFSET = 12; } -} -class MapVisual { - update() {} - constructor(map){ - this.map = map; + getType(index) { + return this[MaterialBufferData.SIZE * index + this.TYPE_OFFSET]; } -} -class Map { - get atlas() { - return this._rasterizer.atlas; + setType(index, value) { + this[MaterialBufferData.SIZE * index + this.TYPE_OFFSET] = value; } - get count() { - return this._keys.size; + getFuzz(index) { + return this[MaterialBufferData.SIZE * index + this.FUZZ_OFFSET]; } - constructor(core, rasterizer){ - this._core = core; - this._rasterizer = rasterizer; - this._keys = new Set(); - this._previousSize = 0; - this.items = {}; + setFuzz(index, value) { + this[MaterialBufferData.SIZE * index + this.FUZZ_OFFSET] = value; } - add(key) { - if (!this._keys.has(key)) { - this._keys.add(key); - this._rasterizer.draw(key); - this._hasChanged = true; - } + getRefractiveIndex(index) { + return this[MaterialBufferData.SIZE * index + this.REFRACTIVE_INDEX_OFFSET]; } - update() { - if (this._hasChanged) { - this._hasChanged = false; - this._core.log.write((0, _mainJs.LogLevel).info, `${this.key} added ${this._keys.size - this._previousSize} new items`); - this._previousSize = this._keys.size; - if (this.hasChangedCallback) this.hasChangedCallback(); - } + setRefractiveIndex(index, value) { + this[MaterialBufferData.SIZE * index + this.REFRACTIVE_INDEX_OFFSET] = value; } - toJSON() { - const items = []; - for(let key in this.items){ - const item = this.items[key]; - items.push(item.toJSON()); - } - return { - key: this.key, - items: items - }; + getTextureId(index) { + return this[MaterialBufferData.SIZE * index + this.TEXTURE_ID_OFFSET]; } -} -class MapAtlas { - constructor(width, height){ - const canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - const context = canvas.getContext("2d"); - context.clearRect(0, 0, width, height); - this.imageData = context.getImageData(0, 0, width, height); - this.x = 0; - this.top = new Uint16Array(width); + setTextureId(index, value) { + this[MaterialBufferData.SIZE * index + this.TEXTURE_ID_OFFSET] = value; + } + getColor(index, value) { + const offset = MaterialBufferData.SIZE * index + this.COLOR_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setColor(index, value) { + const offset = MaterialBufferData.SIZE * index + this.COLOR_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getGlossiness(index) { + return this[MaterialBufferData.SIZE * index + this.GLOSSINESS_OFFSET]; + } + setGlossiness(index, value) { + this[MaterialBufferData.SIZE * index + this.GLOSSINESS_OFFSET] = value; + } + getDensity(index) { + return this[MaterialBufferData.SIZE * index + this.DENSITY_OFFSET]; + } + setDensity(index, value) { + this[MaterialBufferData.SIZE * index + this.DENSITY_OFFSET] = value; + } + getIdColor(index, value) { + const offset = MaterialBufferData.SIZE * index + this.ID_COLOR_OFFSET; + (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + } + setIdColor(index, value) { + const offset = MaterialBufferData.SIZE * index + this.ID_COLOR_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; } } -class geoJSON { -} -class geoJSONFeature { +MaterialBufferData.SIZE = 16; +class Material { + get texture() { + return this._texture; + } + get idColor() { + return this._idColor; + } + constructor(options){ + this._idColor = options.idColor || (0, _glMatrix.vec4).fromValues(0, 0, 0, 0); + } + toBuffer(buffer, index, textureId) {} } -class geoJSONGeometry { +class LambertianMaterial extends Material { + constructor(options){ + super(options); + this._texture = options.texture; + } + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.lambertian); + buffer.setIdColor(index, this.idColor); + buffer.setTextureId(index, textureId); + } } -class geoJSONPolygon extends geoJSONGeometry { +class MetalMaterial extends Material { + constructor(options){ + super(options); + this.fuzz = options.fuzz !== undefined ? options.fuzz : 0; + this._texture = options.texture; + } + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.metal); + buffer.setIdColor(index, this.idColor); + buffer.setFuzz(index, this.fuzz); + buffer.setTextureId(index, textureId); + } } -class geoJSONMultiPolygon extends geoJSONGeometry { +class DielectricMaterial extends Material { + constructor(options){ + super(options); + this.fuzz = options && options.fuzz !== undefined ? options.fuzz : 0; + this.refractiveIndex = options && options.refractiveIndex !== undefined ? options.refractiveIndex : 1.5; + this.glossiness = options && options.glossiness !== undefined ? options.glossiness : 1; + this.color = options && options.color || (0, _glMatrix.vec3).fromValues(1, 1, 1); + this.density = options && options.density !== undefined ? options.density : 1; + } + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.dielectric); + buffer.setIdColor(index, this.idColor); + buffer.setRefractiveIndex(index, this.refractiveIndex); + buffer.setFuzz(index, this.fuzz); + buffer.setGlossiness(index, this.glossiness); + buffer.setColor(index, (0, _glMatrix.vec3).fromValues(-Math.log(this.color[0]) * this.density, -Math.log(this.color[1]) * this.density, -Math.log(this.color[2]) * this.density)); + } } -class MapRasterizer { - get map() { - return this._map; +class DiffuseLightMaterial extends Material { + constructor(options){ + super(options); + this.color = options && options.color || (0, _glMatrix.vec3).fromValues(1, 1, 1); } - get atlas() { - return this._atlas; + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.diffuseLight); + buffer.setIdColor(index, this.idColor); + buffer.setColor(index, this.color); } - constructor(core, options){ - let start = performance.now(); - this._core = core; - this._atlas = options.atlas; - this._geoJSON = options.geoJSON; - this._scale = options.scale; - this._property = options.property; - this._border = options.border; - this._maxDistance = options.maxDistance; - this._edgeValue = options.edgeValue; - this._key = options.key; - this._useMercator = options.useMercator; - this._map = new Map(core, this); - this._map.key = this._key; - const geoJSONRasterizerOptions = { - border: this._border, - edgeValue: this._edgeValue, - maxDistance: this._maxDistance, - geoJSON: this._geoJSON, - scale: this._scale, - property: this._property, - useMercator: this._useMercator - }; - this._geoJSONRasterizer = new GeoJSONRasterizer(core, geoJSONRasterizerOptions); - this._core.log.write((0, _mainJs.LogLevel).info, `map rasterizer ${Math.round(window.performance.now() - start)}ms`); +} +class GlossyMaterial extends Material { + constructor(options){ + super(options); + this._texture = options.texture; + this.fuzz = options.fuzz !== undefined ? options.fuzz : 0; + this.refractiveIndex = options.refractiveIndex !== undefined ? options.refractiveIndex : 1.5; + this.glossiness = options.glossiness !== undefined ? options.glossiness : 1; } - draw(key) { - const item = this._geoJSONRasterizer.draw(key); - if (item) { - const texWidth = item.width + 2 * this._border; - const texHeight = item.height + 2 * this._border; - const width = this._atlas.imageData.width; - const height = this.atlas.imageData.height; - if (this._atlas.x + texWidth > width - 1) this._atlas.x = 0; - let y = 0; - for(let x = this._atlas.x; x < this._atlas.x + texWidth; x++)y = Math.max(y, this._atlas.top[x]); - if (y + texHeight > height - 1) this._core.log.write((0, _mainJs.LogLevel).warn, `${this._map.key} height overflow`); - for(let x1 = this._atlas.x; x1 < this._atlas.x + texWidth; x1++)this._atlas.top[x1] = y + texHeight; - const halfTexelOffsetX = 0.5 / width; - const halfTexelOffsetY = 0.5 / height; - item.u0 = this._atlas.x / width + halfTexelOffsetX; - item.v0 = y / height + halfTexelOffsetY; - item.u1 = (this._atlas.x + texWidth) / width - halfTexelOffsetX; - item.v1 = (y + texHeight) / height - halfTexelOffsetY; - this._map.items[key] = item; - for(let i = 0; i < item.distances.length; i++){ - const distance = item.distances[i]; - const dataX = i % texWidth; - const dataY = Math.floor(i / texWidth); - const offset = (this._atlas.x + dataX + (y + dataY) * width) * 4; - this._atlas.imageData.data[offset + 0] = distance; - this._atlas.imageData.data[offset + 1] = distance; - this._atlas.imageData.data[offset + 2] = distance; - this._atlas.imageData.data[offset + 3] = 0xff; - } - this._atlas.x += texWidth; - } + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.glossy); + buffer.setIdColor(index, this.idColor); + buffer.setFuzz(index, this.fuzz); + buffer.setGlossiness(index, this.glossiness); + buffer.setRefractiveIndex(index, this.refractiveIndex); + buffer.setTextureId(index, textureId); } } -class GeoJSONRasterizer { - constructor(core, options){ - let start = performance.now(); - this._core = core; - this._geoJSON = options.geoJSON; - this._scale = options.scale; - this._property = options.property; - this._border = options.border; - this._maxDistance = options.maxDistance; - this._edgeValue = options.edgeValue; - this._useMercator = options.useMercator; - this._mercator = [ - 0, - 0 - ]; - this._core.log.write((0, _mainJs.LogLevel).info, `geoJSON rasterizer ${Math.round(window.performance.now() - start)}ms`); +class IsotropicMaterial extends Material { + constructor(options){ + super(options); + this.density = options.density; + this.color = options.color; } - draw(key) { - let feature; - for(let i = 0; i < this._geoJSON.features.length; i++){ - feature = this._geoJSON.features[i]; - if (feature.properties[this._property] == key) { - let minX = Number.MAX_VALUE; - let maxX = -Number.MAX_VALUE; - let minY = Number.MAX_VALUE; - let maxY = -Number.MAX_VALUE; - let sizeX = 0; - let sizeY = 0; - switch(feature.geometry.type){ - case "Polygon": - const polygon = feature.geometry; - const outer = polygon.coordinates[0]; - for(let k = 0; k < outer.length; k++){ - const position = outer[k]; - if (position[0] > 0) position[0] -= 360; - if (this._useMercator) { - (0, _mapJs.AlbersHelper).project(position[0], position[1], this._mercator); - position[0] = this._mercator[0]; - position[1] = this._mercator[1]; - } - minX = Math.min(minX, position[0]); - maxX = Math.max(maxX, position[0]); - minY = Math.min(minY, position[1]); - maxY = Math.max(maxY, position[1]); - } - sizeX = maxX - minX; - sizeY = maxY - minY; - break; - case "MultiPolygon": - const multiPolygon = feature.geometry; - for(let j = 0; j < multiPolygon.coordinates.length; j++){ - const polygon1 = multiPolygon.coordinates[j]; - const outer1 = polygon1[0]; - for(let k1 = 0; k1 < outer1.length; k1++){ - const position1 = outer1[k1]; - if (position1[0] > 0) position1[0] -= 360; - if (this._useMercator) { - (0, _mapJs.AlbersHelper).project(position1[0], position1[1], this._mercator); - position1[0] = this._mercator[0]; - position1[1] = this._mercator[1]; - } - minX = Math.min(minX, position1[0]); - maxX = Math.max(maxX, position1[0]); - minY = Math.min(minY, position1[1]); - maxY = Math.max(maxY, position1[1]); - } - } - sizeX = maxX - minX; - sizeY = maxY - minY; - break; - } - if (sizeX > 0 && sizeY > 0) { - sizeX = Math.ceil(sizeX * this._scale); - sizeY = Math.ceil(sizeY * this._scale); - const canvas = document.createElement("canvas"); - const width = sizeX + 2 * this._border; - const height = sizeY + 2 * this._border; - canvas.width = width; - canvas.height = height; - const ctx = canvas.getContext("2d", { - willReadFrequently: true - }); - let length = width * height; - this._gridOuter = new Float64Array(length); - this._gridInner = new Float64Array(length); - length = Math.max(width, height); - this._f = new Float64Array(length); - this._z = new Float64Array(length + 1); - this._v = new Uint16Array(length); - length = width * height; - const distances = new Uint8ClampedArray(length); - const gradientsX = new Uint8ClampedArray(length); - const gradientsY = new Uint8ClampedArray(length); - const pixels = new Uint8ClampedArray(length); - const item = new MapItem(); - item.key = key; - item.distances = distances; - item.gradientsX = gradientsX; - item.gradientsY = gradientsY; - item.pixels = pixels; - item.width = sizeX; - item.height = sizeY; - item.minLon = minX; - item.maxLon = maxX; - item.minLat = minY; - item.maxLat = maxY; - ctx.clearRect(this._border, this._border, sizeX, sizeY); - switch(feature.geometry.type){ - case "Polygon": - const polygon2 = feature.geometry; - const outer2 = polygon2.coordinates[0]; - ctx.fillStyle = "black"; - ctx.beginPath(); - const position2 = outer2[0]; - const x = (position2[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y = height / 2 - (position2[1] - minY) * this._scale + sizeY / 2; - ctx.moveTo(x, y); - for(let k2 = 1; k2 < outer2.length; k2++){ - const position3 = outer2[k2]; - const x1 = (position3[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y1 = height / 2 - (position3[1] - minY) * this._scale + sizeY / 2; - ctx.lineTo(x1, y1); - } - ctx.fill(); - for(let k3 = 1; k3 < polygon2.coordinates.length; k3++){ - const inner = polygon2.coordinates[k3]; - ctx.fillStyle = "transparent"; - ctx.beginPath(); - const position4 = inner[0]; - if (position4[0] > 0) position4[0] -= 360; - if (this._useMercator) { - (0, _mapJs.AlbersHelper).project(position4[0], position4[1], this._mercator); - position4[0] = this._mercator[0]; - position4[1] = this._mercator[1]; - } - const x2 = (position4[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y2 = height / 2 - (position4[1] - minY) * this._scale + sizeY / 2; - ctx.moveTo(x2, y2); - for(let l = 1; l < inner.length; l++){ - const position5 = inner[l]; - if (position5[0] > 0) position5[0] -= 360; - if (this._useMercator) { - (0, _mapJs.AlbersHelper).project(position5[0], position5[1], this._mercator); - position5[0] = this._mercator[0]; - position5[1] = this._mercator[1]; - } - const x3 = (position5[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y3 = height / 2 - (position5[1] - minY) * this._scale + sizeY / 2; - ctx.lineTo(x3, y3); - } - ctx.fill(); - } - break; - case "MultiPolygon": - const multiPolygon1 = feature.geometry; - for(let j1 = 0; j1 < multiPolygon1.coordinates.length; j1++){ - const polygon3 = multiPolygon1.coordinates[j1]; - const outer3 = polygon3[0]; - ctx.fillStyle = "black"; - ctx.beginPath(); - const position6 = outer3[0]; - const x4 = (position6[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y4 = height / 2 - (position6[1] - minY) * this._scale + sizeY / 2; - ctx.moveTo(x4, y4); - for(let k4 = 1; k4 < outer3.length; k4++){ - const position7 = outer3[k4]; - const x5 = (position7[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y5 = height / 2 - (position7[1] - minY) * this._scale + sizeY / 2; - ctx.lineTo(x5, y5); - } - ctx.fill(); - for(let k5 = 1; k5 < polygon3.length; k5++){ - const inner1 = polygon3[k5]; - ctx.fillStyle = "transparent"; - ctx.beginPath(); - const position8 = inner1[0]; - if (position8[0] > 0) position8[0] -= 360; - if (this._useMercator) { - (0, _mapJs.AlbersHelper).project(position8[0], position8[1], this._mercator); - position8[0] = this._mercator[0]; - position8[1] = this._mercator[1]; - } - const x6 = (position8[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y6 = height / 2 - (position8[1] - minY) * this._scale + sizeY / 2; - ctx.moveTo(x6, y6); - for(let l1 = 1; l1 < inner1.length; l1++){ - const position9 = inner1[l1]; - if (position9[0] > 0) position9[0] -= 360; - if (this._useMercator) { - (0, _mapJs.AlbersHelper).project(position9[0], position9[1], this._mercator); - position9[0] = this._mercator[0]; - position9[1] = this._mercator[1]; - } - const x7 = (position9[0] - minX) * this._scale - sizeX / 2 + width / 2; - const y7 = height / 2 - (position9[1] - minY) * this._scale + sizeY / 2; - ctx.lineTo(x7, y7); - } - ctx.fill(); - } - } - break; - } - const imgData = ctx.getImageData(this._border, this._border, sizeX, sizeY); - for(let i1 = 0; i1 < length; i1++){ - this._gridOuter[i1] = Number.MAX_VALUE; - this._gridInner[i1] = 0; - } - for(let y8 = 0; y8 < sizeY; y8++)for(let x8 = 0; x8 < sizeX; x8++){ - const a = imgData.data[4 * (y8 * sizeX + x8) + 3] / 0xff; - if (a > 0) { - const j2 = (y8 + this._border) * width + x8 + this._border; - if (a == 1) { - this._gridOuter[j2] = 0; - this._gridInner[j2] = Number.MAX_VALUE; - pixels[j2] = 0xff; - } else { - const d = 0.5 - a; - this._gridOuter[j2] = d > 0 ? d * d : 0; - this._gridInner[j2] = d < 0 ? d * d : 0; - } - } - } - this._edt(this._gridOuter, 0, 0, width, height, width, this._f, this._v, this._z); - this._edt(this._gridInner, this._border, this._border, sizeX, sizeY, width, this._f, this._v, this._z); - const distances2 = new Float32Array(length); - for(let i2 = 0; i2 < length; i2++){ - const distance = Math.sqrt(this._gridOuter[i2]) - Math.sqrt(this._gridInner[i2]); - distances[i2] = Math.round(this._edgeValue - distance * 0xff / this._maxDistance); - distances2[i2] = distance; - } - for(let i3 = 0; i3 < length; i3++){ - const x9 = i3 % width; - const y9 = Math.floor(i3 / width); - const d1 = distances2[i3]; - const sign = d1 < 0 ? -1 : 1; - const x0 = x9 > 0 ? distances2[i3 - 1] : Number.MAX_VALUE; - const x11 = x9 < width - 1 ? distances2[i3 + 1] : Number.MAX_VALUE; - const y0 = y9 > 0 ? distances2[i3 - width] : Number.MAX_VALUE; - const y11 = y9 < height - 1 ? distances2[i3 + width] : Number.MAX_VALUE; - let gradientX = sign * x0 < sign * x11 ? d1 - x0 : x11 - d1; - let gradientY = sign * y0 < sign * y11 ? y0 - d1 : d1 - y11; - gradientsX[i3] = Math.round((gradientX * 0.5 + 0.5) * 0xff); - gradientsY[i3] = Math.round((gradientY * 0.5 + 0.5) * 0xff); - } - return item; - } - } - } - this._core.log.write((0, _mainJs.LogLevel).warn, `geoJSON rasterizer ${key} not found`); - return null; + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.isotropic); + buffer.setIdColor(index, this.idColor); + buffer.setDensity(index, this.density); + buffer.setColor(index, this.color); } - _edt(data, x0, y0, width, height, gridSize, f, v, z) { - for(let x = x0; x < x0 + width; x++)this._edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); - for(let y = y0; y < y0 + height; y++)this._edt1d(data, y * gridSize + x0, 1, width, f, v, z); +} +class VarnishMaterial extends Material { + constructor(options){ + super(options); + this.fuzz = options && options.fuzz !== undefined ? options.fuzz : 0; + this.refractiveIndex = options && options.refractiveIndex !== undefined ? options.refractiveIndex : 1.5; + this.glossiness = options && options.glossiness !== undefined ? options.glossiness : 1; } - _edt1d(grid, offset, stride, n, f, v, z) { - v[0] = 0; - z[0] = -Number.MAX_VALUE; - z[1] = Number.MAX_VALUE; - f[0] = grid[offset]; - for(let q = 1, k = 0, s = 0; q < n; q++){ - f[q] = grid[offset + q * stride]; - const q2 = q * q; - do { - const r = v[k]; - s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; - }while (s <= z[k] && --k > -1); - k++; - v[k] = q; - z[k] = s; - z[k + 1] = Number.MAX_VALUE; - } - for(let q1 = 0, k1 = 0; q1 < n; q1++){ - while(z[k1 + 1] < q1)k1++; - const r1 = v[k1]; - const qr = q1 - r1; - grid[offset + q1 * stride] = f[r1] + qr * qr; - } + toBuffer(buffer, index, textureId) { + buffer.setType(index, MaterialType.varnish); + buffer.setIdColor(index, this.idColor); + buffer.setFuzz(index, this.fuzz); + buffer.setGlossiness(index, this.glossiness); + buffer.setRefractiveIndex(index, this.refractiveIndex); } } -},{"./helpers/map.js":"haUyw","./main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hMOrK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Icon", ()=>Icon); -parcelHelpers.export(exports, "IconsVisual", ()=>IconsVisual); -parcelHelpers.export(exports, "Icons", ()=>Icons); -parcelHelpers.export(exports, "IconsAtlas", ()=>IconsAtlas); -parcelHelpers.export(exports, "IconsRasterizer", ()=>IconsRasterizer); -parcelHelpers.export(exports, "IconRasterizer", ()=>IconRasterizer); +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5NgmA":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. - */ var _mainJs = require("./main.js"); -class Icon { - toJSON() { - return { - key: this.key, - u0: this.u0, - v0: this.v0, - u1: this.u1, - v1: this.v1 - }; + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "TextureType", ()=>TextureType); +parcelHelpers.export(exports, "TextureBufferData", ()=>TextureBufferData); +parcelHelpers.export(exports, "Texture", ()=>Texture); +parcelHelpers.export(exports, "SolidColorTexture", ()=>SolidColorTexture); +parcelHelpers.export(exports, "ImageTexture", ()=>ImageTexture); +parcelHelpers.export(exports, "CheckerTexture", ()=>CheckerTexture); +parcelHelpers.export(exports, "GridTexture", ()=>GridTexture); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../../constants.js"); +const TextureType = { + none: 0, + solidColor: 1, + image: 2, + sdfText: 3, + checker: 4, + grid: 5 +}; +class TextureBufferData extends Float32Array { + constructor(count){ + super(count * TextureBufferData.SIZE); + this.COLOR0_OFFSET = 0; + this.TYPE_OFFSET = 3; + this.COLOR1_OFFSET = 4; + this.SIZE0_OFFSET = 8; + this.SIZE1_OFFSET = 12; + this.CLIP_OFFSET = 16; + this.OFFSET_OFFSET = 20; } -} -class IconsVisual { - update() {} - constructor(icons){ - this.icons = icons; + getType(index) { + return this[TextureBufferData.SIZE * index + this.TYPE_OFFSET]; } -} -class Icons { - get atlas() { - return this._rasterizer.atlas; + setType(index, value) { + this[TextureBufferData.SIZE * index + this.TYPE_OFFSET] = value; } - get count() { - return this._keys.size; + getColor0(index, value) { + const offset = TextureBufferData.SIZE * index + this.COLOR0_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); } - constructor(core, rasterizer){ - this._core = core; - this._rasterizer = rasterizer; - this._keys = new Set(); - this._previousSize = 0; - this.items = {}; + setColor0(index, value) { + const offset = TextureBufferData.SIZE * index + this.COLOR0_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; } - add(key, imgData) { - if (!this._keys.has(key)) { - this._keys.add(key); - this._rasterizer.draw(key, imgData); - } + getColor1(index, value) { + const offset = TextureBufferData.SIZE * index + this.COLOR1_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); } - update() { - if (this._hasChanged) { - this._hasChanged = false; - this._core.log.write((0, _mainJs.LogLevel).info, `${this.key} added ${this._keys.size - this._previousSize} new items`); - this._previousSize = this._keys.size; - if (this.hasChangedCallback) this.hasChangedCallback(); - } + setColor1(index, value) { + const offset = TextureBufferData.SIZE * index + this.COLOR1_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; } - toJSON() { - const items = []; - for(let key in this.items){ - const item = this.items[key]; - items.push(item.toJSON()); - } - return { - key: this.key, - items: items - }; + getSize0(index, value) { + const offset = TextureBufferData.SIZE * index + this.SIZE0_OFFSET; + (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); } -} -class IconsAtlas { - constructor(width, height){ - const canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - const context = canvas.getContext("2d"); - context.clearRect(0, 0, width, height); - this.imageData = context.getImageData(0, 0, width, height); - this.x = 0; - this.top = new Uint16Array(width); + setSize0(index, value) { + const offset = TextureBufferData.SIZE * index + this.SIZE0_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; + } + getSize1(index, value) { + const offset = TextureBufferData.SIZE * index + this.SIZE1_OFFSET; + (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + } + setSize1(index, value) { + const offset = TextureBufferData.SIZE * index + this.SIZE1_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; + } + getClip(index, value) { + const offset = TextureBufferData.SIZE * index + this.CLIP_OFFSET; + (0, _glMatrix.vec4).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + } + setClip(index, value) { + const offset = TextureBufferData.SIZE * index + this.CLIP_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; + } + getOffset(index, value) { + const offset = TextureBufferData.SIZE * index + this.OFFSET_OFFSET; + (0, _glMatrix.vec2).set(value, this[offset], this[offset + 1]); + } + setOffset(index, value) { + const offset = TextureBufferData.SIZE * index + this.OFFSET_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; } } -class IconsRasterizer { - get icons() { - return this._icons; +TextureBufferData.SIZE = 24; +class Texture { +} +class SolidColorTexture extends Texture { + constructor(options){ + super(); + this.color = options.color; + this.borderColor = options.borderColor || (0, _constantsJs.Constants).VECTOR3_ONE; + this._color = (0, _glMatrix.vec3).fromValues(Math.pow(this.color[0], 2.2), Math.pow(this.color[1], 2.2), Math.pow(this.color[2], 2.2)); + this._borderColor = (0, _glMatrix.vec3).fromValues(Math.pow(this.borderColor[0], 2.2), Math.pow(this.borderColor[1], 2.2), Math.pow(this.borderColor[2], 2.2)); } - get atlas() { - return this._atlas; + toBuffer(buffer, index) { + buffer.setType(index, TextureType.solidColor); + buffer.setColor0(index, this._color); + buffer.setColor1(index, this._borderColor); } - constructor(core, options){ - let start = performance.now(); - this._core = core; - this._atlas = options.atlas; - this._border = options.border; - this._maxDistance = options.maxDistance; - this._edgeValue = options.edgeValue; - this._key = options.key; - this._icons = new Icons(core, this); - this._icons.key = this._key; - const iconRasterizerOptions = { - border: this._border, - edgeValue: this._edgeValue, - maxDistance: this._maxDistance - }; - this._iconRasterizer = new IconRasterizer(core, iconRasterizerOptions); - this._core.log.write((0, _mainJs.LogLevel).info, `icons rasterizer ${Math.round(window.performance.now() - start)}ms`); +} +class ImageTexture extends Texture { + constructor(options){ + super(); + this.image = options.image; } - draw(key, imgData) { - const item = this._iconRasterizer.draw(key, imgData); - if (item) { - const texWidth = item.width + 2 * this._border; - const texHeight = item.height + 2 * this._border; - const width = this._atlas.imageData.width; - const height = this.atlas.imageData.height; - if (this._atlas.x + texWidth > width - 1) this._atlas.x = 0; - let y = 0; - for(let x = this._atlas.x; x < this._atlas.x + texWidth; x++)y = Math.max(y, this._atlas.top[x]); - if (y + texHeight > height - 1) this._core.log.write((0, _mainJs.LogLevel).warn, `${this._icons.key} height overflow`); - for(let x1 = this._atlas.x; x1 < this._atlas.x + texWidth; x1++)this._atlas.top[x1] = y + texHeight; - const halfTexelOffsetX = 0.5 / width; - const halfTexelOffsetY = 0.5 / height; - item.u0 = this._atlas.x / width + halfTexelOffsetX; - item.v0 = y / height + halfTexelOffsetY; - item.u1 = (this._atlas.x + texWidth) / width - halfTexelOffsetX; - item.v1 = (y + texHeight) / height - halfTexelOffsetY; - this._icons.items[key] = item; - for(let i = 0; i < item.distances.length; i++){ - const distance = item.distances[i]; - const dataX = i % texWidth; - const dataY = Math.floor(i / texWidth); - const offset = (this._atlas.x + dataX + (y + dataY) * width) * 4; - this._atlas.imageData.data[offset + 0] = distance; - this._atlas.imageData.data[offset + 1] = distance; - this._atlas.imageData.data[offset + 2] = distance; - this._atlas.imageData.data[offset + 3] = 0xff; - } - this._atlas.x += texWidth; - } + toBuffer(buffer, index) { + buffer.setType(index, TextureType.image); } } -class IconRasterizer { - constructor(core, options){ - let start = performance.now(); - this._core = core; - this._border = options.border; - this._maxDistance = options.maxDistance; - this._edgeValue = options.edgeValue; - this._core.log.write((0, _mainJs.LogLevel).info, `icon rasterizer ${Math.round(window.performance.now() - start)}ms`); +class CheckerTexture extends Texture { + constructor(options){ + super(); + this.color0 = options.color0; + this.color1 = options.color1; + this.size = options.size; + this.offset = options.offset || (0, _constantsJs.Constants).VECTOR2_ZERO; + this._color0 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color0[0], 2.2), Math.pow(this.color0[1], 2.2), Math.pow(this.color0[2], 2.2)); + this._color1 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color1[0], 2.2), Math.pow(this.color1[1], 2.2), Math.pow(this.color1[2], 2.2)); } - draw(key, imgData0) { - const sizeX = imgData0.width; - const sizeY = imgData0.height; - const canvas = document.createElement("canvas"); - const width = sizeX + 2 * this._border; - const height = sizeY + 2 * this._border; - canvas.width = width; - canvas.height = height; - let length = width * height; - this._gridOuter = new Float64Array(length); - this._gridInner = new Float64Array(length); - length = Math.max(width, height); - this._f = new Float64Array(length); - this._z = new Float64Array(length + 1); - this._v = new Uint16Array(length); - length = width * height; - const distances = new Uint8ClampedArray(length); - const gradientsX = new Uint8ClampedArray(length); - const gradientsY = new Uint8ClampedArray(length); - const pixels = new Uint8ClampedArray(length); - const item = new Icon(); - item.key = key; - item.distances = distances; - item.gradientsX = gradientsX; - item.gradientsY = gradientsY; - item.pixels = pixels; - item.width = sizeX; - item.height = sizeY; - const ctx = canvas.getContext("2d", { - willReadFrequently: true - }); - ctx.clearRect(this._border, this._border, sizeX, sizeY); - ctx.putImageData(imgData0, this._border, this._border); - const imgData1 = ctx.getImageData(this._border, this._border, sizeX, sizeY); - for(let i = 0; i < length; i++){ - this._gridOuter[i] = Number.MAX_VALUE; - this._gridInner[i] = 0; - } - for(let y = 0; y < sizeY; y++)for(let x = 0; x < sizeX; x++){ - const a = imgData1.data[4 * (y * sizeX + x) + 3] / 0xff; - if (a > 0) { - const j = (y + this._border) * width + x + this._border; - if (a == 1) { - this._gridOuter[j] = 0; - this._gridInner[j] = Number.MAX_VALUE; - pixels[j] = 0xff; - } else { - const d = 0.5 - a; - this._gridOuter[j] = d > 0 ? d * d : 0; - this._gridInner[j] = d < 0 ? d * d : 0; - } - } - } - this._edt(this._gridOuter, 0, 0, width, height, width, this._f, this._v, this._z); - this._edt(this._gridInner, this._border, this._border, sizeX, sizeY, width, this._f, this._v, this._z); - const distances2 = new Float32Array(length); - for(let i1 = 0; i1 < length; i1++){ - const distance = Math.sqrt(this._gridOuter[i1]) - Math.sqrt(this._gridInner[i1]); - distances[i1] = Math.round(this._edgeValue - distance * 0xff / this._maxDistance); - distances2[i1] = distance; - } - for(let i2 = 0; i2 < length; i2++){ - const x1 = i2 % width; - const y1 = Math.floor(i2 / width); - const d1 = distances2[i2]; - const sign = d1 < 0 ? -1 : 1; - const x0 = x1 > 0 ? distances2[i2 - 1] : Number.MAX_VALUE; - const x11 = x1 < width - 1 ? distances2[i2 + 1] : Number.MAX_VALUE; - const y0 = y1 > 0 ? distances2[i2 - width] : Number.MAX_VALUE; - const y11 = y1 < height - 1 ? distances2[i2 + width] : Number.MAX_VALUE; - let gradientX = sign * x0 < sign * x11 ? d1 - x0 : x11 - d1; - let gradientY = sign * y0 < sign * y11 ? y0 - d1 : d1 - y11; - gradientsX[i2] = Math.round((gradientX * 0.5 + 0.5) * 0xff); - gradientsY[i2] = Math.round((gradientY * 0.5 + 0.5) * 0xff); - } - return item; + toBuffer(buffer, index) { + buffer.setType(index, TextureType.checker); + buffer.setColor0(index, this._color0); + buffer.setColor1(index, this._color1); + buffer.setSize0(index, (0, _glMatrix.vec4).fromValues(this.size[0], this.size[1], 0, 0)); + buffer.setOffset(index, this.offset); } - _edt(data, x0, y0, width, height, gridSize, f, v, z) { - for(let x = x0; x < x0 + width; x++)this._edt1d(data, y0 * gridSize + x, gridSize, height, f, v, z); - for(let y = y0; y < y0 + height; y++)this._edt1d(data, y * gridSize + x0, 1, width, f, v, z); +} +class GridTexture extends Texture { + constructor(options){ + super(); + this.color0 = options.color0; + this.color1 = options.color1; + this.size = options.size; + this.minorSize = options.minorSize; + this.thickness = options.thickness; + this.minorThickness = options.minorThickness; + this.offset = options.offset || (0, _constantsJs.Constants).VECTOR2_ZERO; + this.clip = options.clip || (0, _glMatrix.vec4).fromValues(0, 0, 1, 1); + this._color0 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color0[0], 2.2), Math.pow(this.color0[1], 2.2), Math.pow(this.color0[2], 2.2)); + this._color1 = (0, _glMatrix.vec3).fromValues(Math.pow(this.color1[0], 2.2), Math.pow(this.color1[1], 2.2), Math.pow(this.color1[2], 2.2)); } - _edt1d(grid, offset, stride, n, f, v, z) { - v[0] = 0; - z[0] = -Number.MAX_VALUE; - z[1] = Number.MAX_VALUE; - f[0] = grid[offset]; - for(let q = 1, k = 0, s = 0; q < n; q++){ - f[q] = grid[offset + q * stride]; - const q2 = q * q; - do { - const r = v[k]; - s = (f[q] - f[r] + q2 - r * r) / (q - r) / 2; - }while (s <= z[k] && --k > -1); - k++; - v[k] = q; - z[k] = s; - z[k + 1] = Number.MAX_VALUE; - } - for(let q1 = 0, k1 = 0; q1 < n; q1++){ - while(z[k1 + 1] < q1)k1++; - const r1 = v[k1]; - const qr = q1 - r1; - grid[offset + q1 * stride] = f[r1] + qr * qr; - } + toBuffer(buffer, index) { + buffer.setType(index, TextureType.grid); + buffer.setColor0(index, this._color0); + buffer.setColor1(index, this._color1); + buffer.setSize0(index, (0, _glMatrix.vec4).fromValues(this.size[0], this.size[1], this.minorSize[0], this.minorSize[1])); + buffer.setSize1(index, (0, _glMatrix.vec4).fromValues(this.thickness[0], this.thickness[1], this.minorThickness[0], this.minorThickness[1])); + buffer.setOffset(index, this.offset); + buffer.setClip(index, this.clip); } } -},{"./main.js":"1Kju3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5jv9L":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -//alphabetize for documentation -parcelHelpers.export(exports, "addDiv", ()=>(0, _htmlHelpers.addDiv)); -parcelHelpers.export(exports, "addEl", ()=>(0, _htmlHelpers.addEl)); -parcelHelpers.export(exports, "allTruthy", ()=>(0, _array.allTruthy)); -parcelHelpers.export(exports, "clone", ()=>(0, _clone.clone)); -parcelHelpers.export(exports, "colorFromString", ()=>(0, _color.colorFromString)); -parcelHelpers.export(exports, "colorIsEqual", ()=>(0, _color.colorIsEqual)); -parcelHelpers.export(exports, "colorToString", ()=>(0, _color.colorToString)); -parcelHelpers.export(exports, "concat", ()=>(0, _array.concat)); -parcelHelpers.export(exports, "createElement", ()=>(0, _tsxCreateElement.createElement)); -parcelHelpers.export(exports, "deepMerge", ()=>(0, _clone.deepMerge)); -parcelHelpers.export(exports, "desaturate", ()=>(0, _color.desaturate)); -parcelHelpers.export(exports, "getActiveElementInfo", ()=>(0, _tsxCreateElement.getActiveElementInfo)); -parcelHelpers.export(exports, "mount", ()=>(0, _tsxCreateElement.mount)); -parcelHelpers.export(exports, "outerSize", ()=>(0, _htmlHelpers.outerSize)); -parcelHelpers.export(exports, "push", ()=>(0, _array.push)); -parcelHelpers.export(exports, "setActiveElement", ()=>(0, _tsxCreateElement.setActiveElement)); +},{"gl-matrix":"5x28d","../../constants.js":"lD0bG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5cw7N":[function(require,module,exports,__globalThis) { /*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ /** - * This file is for external facing export only, do not use this for internal references, - * as it may cause circular dependencies in Rollup. - */ var _array = require("../array"); -var _htmlHelpers = require("../htmlHelpers"); -var _clone = require("../clone"); -var _color = require("../color"); -var _tsxCreateElement = require("tsx-create-element"); - -},{"../array":"5cIjm","../htmlHelpers":"e21ro","../clone":"kri2h","../color":"aVVvT","tsx-create-element":"c7YxA","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5cIjm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ parcelHelpers.export(exports, "concat", ()=>concat); -/** - * Returns array with items which are truthy. - * @param args array or arrays to concat into a single array. - */ parcelHelpers.export(exports, "allTruthy", ()=>allTruthy); -/** - * Add an array to an existing array in place. - * @param arr Array to append to. - * @param items Arrof of items to append. - */ parcelHelpers.export(exports, "push", ()=>push); -function concat(...args) { - return args.reduce((p, c)=>c ? p.concat(c) : p, []); -} -function allTruthy(...args) { - return args.reduce((p, c)=>c ? p.concat(c) : p, []).filter(Boolean); +parcelHelpers.export(exports, "HittableType", ()=>HittableType); +parcelHelpers.export(exports, "HittableBufferData", ()=>HittableBufferData); +parcelHelpers.export(exports, "Hittable", ()=>Hittable); +parcelHelpers.export(exports, "HittableSphere", ()=>HittableSphere); +parcelHelpers.export(exports, "HittableXyDisk", ()=>HittableXyDisk); +parcelHelpers.export(exports, "HittableRotatedXyDisk", ()=>HittableRotatedXyDisk); +parcelHelpers.export(exports, "HittableRingSdf", ()=>HittableRingSdf); +parcelHelpers.export(exports, "HittableRotatedRingSdf", ()=>HittableRotatedRingSdf); +parcelHelpers.export(exports, "HittableBox", ()=>HittableBox); +parcelHelpers.export(exports, "HittableBoxSdf", ()=>HittableBoxSdf); +parcelHelpers.export(exports, "HittableRotatedBoxSdf", ()=>HittableRotatedBoxSdf); +parcelHelpers.export(exports, "HittableRotatedBox", ()=>HittableRotatedBox); +parcelHelpers.export(exports, "HittableCylinder", ()=>HittableCylinder); +parcelHelpers.export(exports, "HittableCylinderSdf", ()=>HittableCylinderSdf); +parcelHelpers.export(exports, "HittableHexPrism", ()=>HittableHexPrism); +parcelHelpers.export(exports, "HittableHexPrismSdf", ()=>HittableHexPrismSdf); +parcelHelpers.export(exports, "HittableRect", ()=>HittableRect); +parcelHelpers.export(exports, "HittableXyRect", ()=>HittableXyRect); +parcelHelpers.export(exports, "HittableXzRect", ()=>HittableXzRect); +parcelHelpers.export(exports, "HittableYzRect", ()=>HittableYzRect); +parcelHelpers.export(exports, "HittableFontXyRect", ()=>HittableFontXyRect); +parcelHelpers.export(exports, "HittableSdfXyRect", ()=>HittableSdfXyRect); +parcelHelpers.export(exports, "HittableRotatedXyRect", ()=>HittableRotatedXyRect); +parcelHelpers.export(exports, "HittableRotatedFontXyRect", ()=>HittableRotatedFontXyRect); +parcelHelpers.export(exports, "HittableRotatedSdfXyRect", ()=>HittableRotatedSdfXyRect); +parcelHelpers.export(exports, "HittableConstantMedium", ()=>HittableConstantMedium); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../../constants.js"); +var _boundsJs = require("../../helpers/bounds.js"); +var _aabbJs = require("./aabb.js"); +const HittableType = { + sphere: 0, + box: 1, + cylinder: 2, + hexPrism: 3, + rotatedBox: 4, + xyRect: 5, + xzRect: 6, + yzRect: 7, + rotatedXyRect: 8, + fontXyRect: 9, + rotatedFontXyRect: 10, + boxSdf: 11, + cylinderSdf: 12, + hexPrismSdf: 13, + constantMedium: 14, + sdfXyRect: 15, + rotatedSdfXyRect: 16, + rotatedBoxSdf: 17, + xYDisk: 18, + rotatedXyDisk: 19, + ringSdf: 20, + rotatedRingSdf: 21 +}; +class HittableBufferData extends Float32Array { + constructor(count){ + super(count * HittableBufferData.SIZE); + this.CENTER0_OFFSET = 0; + this.TYPE_OFFSET = 3; + this.SIZE0_OFFSET = 4; + this.MATERIAL_ID_OFFSET = 7; + this.ROTATION0_OFFSET = 8; + this.ROTATION1_OFFSET = 12; + this.TEXCOORD0_OFFSET = 16; + this.TEXCOORD1_OFFSET = 18; + this.CENTER1_OFFSET = 20; + this.ROUNDING_OFFSET = 23; + this.SIZE1_OFFSET = 24; + this.BOUNDARY_TYPE_OFFSET = 27; + this.TIME0_OFFSET = 28; + this.TIME1_OFFSET = 29; + this.TEX_ID_OFFSET = 30; + this.SDF_BUFFER_OFFSET = 31; + this.SDF_BORDER_OFFSET = 32; + this.PARAMETER_1_OFFSET = 33; + this.PARAMETER_2_OFFSET = 34; + } + getType(index) { + return this[HittableBufferData.SIZE * index + this.TYPE_OFFSET]; + } + setType(index, value) { + this[HittableBufferData.SIZE * index + this.TYPE_OFFSET] = value; + } + getCenter0(index, value) { + const offset = HittableBufferData.SIZE * index + this.CENTER0_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setCenter0(index, value) { + const offset = HittableBufferData.SIZE * index + this.CENTER0_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getCenter1(index, value) { + const offset = HittableBufferData.SIZE * index + this.CENTER1_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setCenter1(index, value) { + const offset = HittableBufferData.SIZE * index + this.CENTER1_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getTime0(index) { + return this[HittableBufferData.SIZE * index + this.TIME0_OFFSET]; + } + setTime0(index, value) { + this[HittableBufferData.SIZE * index + this.TIME0_OFFSET] = value; + } + getTime1(index) { + return this[HittableBufferData.SIZE * index + this.TIME1_OFFSET]; + } + setTime1(index, value) { + this[HittableBufferData.SIZE * index + this.TIME1_OFFSET] = value; + } + getSize0(index, value) { + const offset = HittableBufferData.SIZE * index + this.SIZE0_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setSize0(index, value) { + const offset = HittableBufferData.SIZE * index + this.SIZE0_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getSize1(index, value) { + const offset = HittableBufferData.SIZE * index + this.SIZE1_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setSize1(index, value) { + const offset = HittableBufferData.SIZE * index + this.SIZE1_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getMaterialId(index) { + return this[HittableBufferData.SIZE * index + this.MATERIAL_ID_OFFSET]; + } + setMaterialId(index, value) { + this[HittableBufferData.SIZE * index + this.MATERIAL_ID_OFFSET] = value; + } + getRotation0(index, value) { + const offset = HittableBufferData.SIZE * index + this.ROTATION0_OFFSET; + (0, _glMatrix.quat).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + } + setRotation0(index, value) { + const offset = HittableBufferData.SIZE * index + this.ROTATION0_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; + } + getRotation1(index, value) { + const offset = HittableBufferData.SIZE * index + this.ROTATION1_OFFSET; + (0, _glMatrix.quat).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + } + setRotation1(index, value) { + const offset = HittableBufferData.SIZE * index + this.ROTATION1_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; + } + getTexCoord0(index, value) { + const offset = HittableBufferData.SIZE * index + this.TEXCOORD0_OFFSET; + (0, _glMatrix.vec2).set(value, this[offset], this[offset + 1]); + } + setTexCoord0(index, value) { + const offset = HittableBufferData.SIZE * index + this.TEXCOORD0_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + } + getTexCoord1(index, value) { + const offset = HittableBufferData.SIZE * index + this.TEXCOORD1_OFFSET; + (0, _glMatrix.vec2).set(value, this[offset], this[offset + 1]); + } + setTexCoord1(index, value) { + const offset = HittableBufferData.SIZE * index + this.TEXCOORD1_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + } + getRounding(index) { + return this[HittableBufferData.SIZE * index + this.ROUNDING_OFFSET]; + } + setRounding(index, value) { + this[HittableBufferData.SIZE * index + this.ROUNDING_OFFSET] = value; + } + getParameter1(index) { + return this[HittableBufferData.SIZE * index + this.PARAMETER_1_OFFSET]; + } + setParameter1(index, value) { + this[HittableBufferData.SIZE * index + this.PARAMETER_1_OFFSET] = value; + } + getParameter2(index) { + return this[HittableBufferData.SIZE * index + this.PARAMETER_2_OFFSET]; + } + setParameter2(index, value) { + this[HittableBufferData.SIZE * index + this.PARAMETER_2_OFFSET] = value; + } + getBoundaryType(index) { + return this[HittableBufferData.SIZE * index + this.BOUNDARY_TYPE_OFFSET]; + } + setBoundaryType(index, value) { + this[HittableBufferData.SIZE * index + this.BOUNDARY_TYPE_OFFSET] = value; + } + getTexId(index) { + return this[HittableBufferData.SIZE * index + this.TEX_ID_OFFSET]; + } + setTexId(index, value) { + this[HittableBufferData.SIZE * index + this.TEX_ID_OFFSET] = value; + } + getSdfBuffer(index) { + return this[HittableBufferData.SIZE * index + this.SDF_BUFFER_OFFSET]; + } + setSdfBuffer(index, value) { + this[HittableBufferData.SIZE * index + this.SDF_BUFFER_OFFSET] = value; + } + getSdfBorder(index) { + return this[HittableBufferData.SIZE * index + this.SDF_BORDER_OFFSET]; + } + setSdfBorder(index, value) { + this[HittableBufferData.SIZE * index + this.SDF_BORDER_OFFSET] = value; + } } -function push(arr, items) { - arr.push.apply(arr, items); +HittableBufferData.SIZE = 36; +class Hittable { + get center0() { + return this._center0; + } + get center1() { + return this._center1; + } + get time0() { + return this._time0; + } + get time1() { + return this._time1; + } + get material() { + return this._material; + } + set material(material) { + this._material = material; + } + get bounds() { + return this._bounds; + } + get offset0() { + return this._offset0; + } + get offset1() { + return this._offset1; + } + constructor(options){ + this._center0 = options.center0; + this._center1 = options.center1; + this._time0 = options.time0; + this._time1 = options.time1; + this._material = options.material; + this._bounds = new (0, _aabbJs.AABB)(); + this._offset0 = (0, _glMatrix.vec3).create(); + this._offset1 = (0, _glMatrix.vec3).create(); + } + toBuffer(buffer, index, materialId) { + buffer.setCenter0(index, this._center0); + buffer.setCenter1(index, this._center1); + buffer.setTime0(index, this._time0); + buffer.setTime1(index, this._time1); + buffer.setMaterialId(index, materialId); + } } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"e21ro":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ /** - * Create a new element as a child of another element. - * @param tagName Tag name of the new tag to create. - * @param parentElement Reference of the element to append to. - * @returns new HTMLElement. - */ parcelHelpers.export(exports, "addEl", ()=>addEl); -/** - * Create a new div HTMLElement as a child of another element. - * @param parentElement Reference of the element to append to. - * @param className Optional css class name to apply to the div. - */ parcelHelpers.export(exports, "addDiv", ()=>addDiv); -/** - * Measure the outer height and width of an HTMLElement, including margin, padding and border. - * @param el HTML Element to measure. - */ parcelHelpers.export(exports, "outerSize", ()=>outerSize); -function addEl(tagName, parentElement) { - const el = document.createElement(tagName); - parentElement.appendChild(el); - return el; +class HittableSphere extends Hittable { + get radius() { + return this._radius; + } + constructor(options){ + super(options); + this._radius = options.radius; + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._radius, this._center1[0] - this._radius); + max[0] = Math.max(this._center0[0] + this._radius, this._center1[0] + this._radius); + min[1] = Math.min(this._center0[1] - this._radius, this._center1[1] - this._radius); + max[1] = Math.max(this._center0[1] + this._radius, this._center1[1] + this._radius); + min[2] = Math.min(this._center0[2] - this._radius, this._center1[2] - this._radius); + max[2] = Math.max(this._center0[2] + this._radius, this._center1[2] + this._radius); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.sphere); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._radius, this._radius, this._radius)); + } } -function addDiv(parentElement, className) { - const div = addEl("div", parentElement); - if (className) div.className = className; - return div; +class HittableXyDisk extends Hittable { + get texCoord0() { + return this._texCoord0; + } + get texCoord1() { + return this._texCoord1; + } + constructor(options){ + super(options); + this._thickness = 0.00001; + this._radius0 = options.radius0; + this._radius1 = options.radius1; + this._texCoord0 = options.texCoord0; + this._texCoord1 = options.texCoord1; + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._radius0, this._center1[0] - this._radius1); + max[0] = Math.max(this._center0[0] + this._radius0, this._center1[0] + this._radius1); + min[1] = Math.min(this._center0[1] - this._radius0, this._center1[1] - this._radius1); + max[1] = Math.max(this._center0[1] + this._radius0, this._center1[1] + this._radius1); + min[2] = Math.min(this._center0[2] - this._thickness, this._center1[2] - this._thickness); + max[2] = Math.max(this._center0[2] + this._thickness, this._center1[2] + this._thickness); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.xYDisk); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._radius0, this._radius0, this._thickness)); + buffer.setSize1(index, (0, _glMatrix.vec3).fromValues(this._radius1, this._radius1, this._thickness)); + buffer.setTexCoord0(index, this._texCoord0); + buffer.setTexCoord1(index, this._texCoord1); + } } -function outerSize(el) { - const cs = getComputedStyle(el); - const height = parseFloat(cs.marginTop) + parseFloat(cs.paddingTop) + parseFloat(cs.borderTopWidth) + el.offsetHeight + parseFloat(cs.borderBottomWidth) + parseFloat(cs.paddingBottom) + parseFloat(cs.marginBottom); - const width = parseFloat(cs.marginLeft) + parseFloat(cs.paddingLeft) + parseFloat(cs.borderLeftWidth) + el.offsetWidth + parseFloat(cs.borderRightWidth) + parseFloat(cs.paddingRight) + parseFloat(cs.marginRight); - return { - height, - width - }; +class HittableRotatedXyDisk extends HittableXyDisk { + constructor(options){ + super(options); + this._rotation0 = options.rotation0; + this._rotation1 = options.rotation1; + const rotatedBounds0 = new (0, _aabbJs.AABB)(); + const rotatedBounds1 = new (0, _aabbJs.AABB)(); + const min0 = rotatedBounds0.min; + const max0 = rotatedBounds0.max; + const min1 = rotatedBounds1.min; + const max1 = rotatedBounds1.max; + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation0, min0, max0, this._offset0); + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation1, min1, max1, this._offset1); + min0[0] = Math.min(min0[0], min1[0]); + max0[0] = Math.max(max0[0], max1[0]); + min0[1] = Math.min(min0[1], min1[1]); + max0[1] = Math.max(max0[1], max1[1]); + min0[2] = Math.min(min0[2], min1[2]); + max0[2] = Math.max(max0[2], max1[2]); + this._bounds = rotatedBounds0; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.rotatedXyDisk); + buffer.setRotation0(index, this._rotation0); + buffer.setRotation1(index, this._rotation1); + } } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kri2h":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "clone", ()=>clone); -parcelHelpers.export(exports, "deepMerge", ()=>deepMerge); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _deepmerge = require("deepmerge"); -var _isPlainObject = require("is-plain-object"); -const deepmerge = _deepmerge.default || _deepmerge; -function clone(objectToClone) { - if (!objectToClone) return objectToClone; - return deepmerge.all([ - objectToClone - ]); +class HittableRingSdf extends Hittable { + constructor(options){ + super(options); + this._size0 = options.size0; + this._size1 = options.size1; + this._angle = options.angle0; + this._innerRadius = options.innerRadius0; + this._rounding = options.rounding; + const outerRadius = this._size0[0]; + const innerRadius = this._size0[1]; + const extrudedThicknesses = this._size0[2]; + const min = this._bounds.min; + const max = this._bounds.max; + max[1] = this._center0[1] + outerRadius; + const sinAngle = Math.sin(this._angle); + const cosAngle = Math.cos(this._angle); + if (this._angle < (0, _constantsJs.Constants).PI_OVER_TWO) { + min[0] = this.center0[0] - sinAngle * outerRadius; + max[0] = this.center0[0] + sinAngle * outerRadius; + min[1] = this.center0[1] + cosAngle * innerRadius; + } else { + min[0] = this._center0[0] - outerRadius; + max[0] = this._center0[0] + outerRadius; + min[1] = this._center0[1] + cosAngle * outerRadius; + } + min[2] = this._center0[2] - extrudedThicknesses; + max[2] = this._center0[2] + extrudedThicknesses; + this.offset0[0] = (min[0] + max[0]) / 2 - this._center0[0]; + this.offset0[1] = (min[1] + max[1]) / 2 - this._center0[1]; + this.offset0[2] = (min[2] + max[2]) / 2 - this._center0[2]; + this.offset1[0] = (min[0] + max[0]) / 2 - this._center1[0]; + this.offset1[1] = (min[1] + max[1]) / 2 - this._center1[1]; + this.offset1[2] = (min[2] + max[2]) / 2 - this._center1[2]; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.ringSdf); + buffer.setSize0(index, this._size0); + buffer.setSize1(index, this._size1); + buffer.setParameter1(index, this._angle); + buffer.setParameter2(index, this._innerRadius); + buffer.setRounding(index, this._rounding); + } } -const dontMerge = (destination, source)=>source; -function deepMerge(...objectsToMerge) { - const objects = objectsToMerge.filter(Boolean); - return deepmerge.all(objects, { - arrayMerge: dontMerge, - isMergeableObject: (0, _isPlainObject.isPlainObject) - }); +class HittableRotatedRingSdf extends HittableRingSdf { + constructor(options){ + super(options); + this._rotation0 = options.rotation0; + this._rotation1 = options.rotation1; + const rotatedBounds0 = new (0, _aabbJs.AABB)(); + const rotatedBounds1 = new (0, _aabbJs.AABB)(); + const min0 = rotatedBounds0.min; + const max0 = rotatedBounds0.max; + const min1 = rotatedBounds1.min; + const max1 = rotatedBounds1.max; + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation0, min0, max0, this._offset0); + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation1, min1, max1, this._offset1); + min0[0] = Math.min(min0[0], min1[0]); + max0[0] = Math.max(max0[0], max1[0]); + min0[1] = Math.min(min0[1], min1[1]); + max0[1] = Math.max(max0[1], max1[1]); + min0[2] = Math.min(min0[2], min1[2]); + max0[2] = Math.max(max0[2], max1[2]); + this._bounds = rotatedBounds0; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.rotatedRingSdf); + buffer.setRotation0(index, this._rotation0); + buffer.setRotation1(index, this._rotation1); + } } - -},{"deepmerge":"8eicl","is-plain-object":"cXzXP","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8eicl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var isMergeableObject = function isMergeableObject(value) { - return isNonNullObject(value) && !isSpecial(value); -}; -function isNonNullObject(value) { - return !!value && typeof value === "object"; +class HittableBox extends Hittable { + constructor(options){ + super(options); + this._size0 = options.size0; + this._size1 = options.size1; + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._size0[0], this._center1[0] - this._size1[0]); + max[0] = Math.max(this._center0[0] + this._size0[0], this._center1[0] + this._size1[0]); + min[1] = Math.min(this._center0[1] - this._size0[1], this._center1[1] - this._size1[1]); + max[1] = Math.max(this._center0[1] + this._size0[1], this._center1[1] + this._size1[1]); + min[2] = Math.min(this._center0[2] - this._size0[2], this._center1[2] - this._size1[2]); + max[2] = Math.max(this._center0[2] + this._size0[2], this._center1[2] + this._size1[2]); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.box); + buffer.setSize0(index, this._size0); + buffer.setSize1(index, this._size1); + } } -function isSpecial(value) { - var stringValue = Object.prototype.toString.call(value); - return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); +class HittableBoxSdf extends HittableBox { + constructor(options){ + super(options); + this._rounding = options.rounding; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.boxSdf); + buffer.setRounding(index, this._rounding); + } } -// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 -var canUseSymbol = typeof Symbol === "function" && Symbol.for; -var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 0xeac7; -function isReactElement(value) { - return value.$$typeof === REACT_ELEMENT_TYPE; +class HittableRotatedBoxSdf extends HittableBoxSdf { + constructor(options){ + super(options); + this._rotation0 = options.rotation0; + this._rotation1 = options.rotation1; + const rotatedBounds0 = new (0, _aabbJs.AABB)(); + const rotatedBounds1 = new (0, _aabbJs.AABB)(); + const min0 = rotatedBounds0.min; + const max0 = rotatedBounds0.max; + const min1 = rotatedBounds1.min; + const max1 = rotatedBounds1.max; + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation0, min0, max0, this._offset0); + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation1, min1, max1, this._offset1); + min0[0] = Math.min(min0[0], min1[0]); + max0[0] = Math.max(max0[0], max1[0]); + min0[1] = Math.min(min0[1], min1[1]); + max0[1] = Math.max(max0[1], max1[1]); + min0[2] = Math.min(min0[2], min1[2]); + max0[2] = Math.max(max0[2], max1[2]); + this._bounds = rotatedBounds0; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.rotatedBoxSdf); + buffer.setRotation0(index, this._rotation0); + buffer.setRotation1(index, this._rotation1); + } } -function emptyTarget(val) { - return Array.isArray(val) ? [] : {}; +class HittableRotatedBox extends HittableBox { + constructor(options){ + super(options); + this._rotation0 = options.rotation0; + this._rotation1 = options.rotation1; + const rotatedBounds0 = new (0, _aabbJs.AABB)(); + const rotatedBounds1 = new (0, _aabbJs.AABB)(); + const min0 = rotatedBounds0.min; + const max0 = rotatedBounds0.max; + const min1 = rotatedBounds1.min; + const max1 = rotatedBounds1.max; + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation0, min0, max0, this._offset0); + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation1, min1, max1, this._offset1); + min0[0] = Math.min(min0[0], min1[0]); + max0[0] = Math.max(max0[0], max1[0]); + min0[1] = Math.min(min0[1], min1[1]); + max0[1] = Math.max(max0[1], max1[1]); + min0[2] = Math.min(min0[2], min1[2]); + max0[2] = Math.max(max0[2], max1[2]); + this._bounds = rotatedBounds0; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.rotatedBox); + buffer.setRotation0(index, this._rotation0); + buffer.setRotation1(index, this._rotation1); + } } -function cloneUnlessOtherwiseSpecified(value, options) { - return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value; +class HittableCylinder extends Hittable { + get radius() { + return this._radius; + } + get height() { + return this._height; + } + constructor(options){ + super(options); + this._radius = options.radius; + this._height = options.height; + this._rotation0 = options.rotation0 || (0, _constantsJs.Constants).QUAT_IDENTITY; + this._rotation1 = options.rotation1 || (0, _constantsJs.Constants).QUAT_IDENTITY; + if (this._rotation0[3] * this._rotation1[3] == 1) { + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._radius, this._center1[0] - this._radius); + max[0] = Math.max(this._center0[0] + this._radius, this._center1[0] + this._radius); + min[1] = Math.min(this._center0[1] - this._height, this._center1[1] - this._height); + max[1] = Math.max(this._center0[1] + this._height, this._center1[1] + this._height); + min[2] = Math.min(this._center0[2] - this._radius, this._center1[2] - this._radius); + max[2] = Math.max(this._center0[2] + this._radius, this._center1[2] + this._radius); + } else { + const ca0 = (0, _glMatrix.vec3).create(); + const pa0 = (0, _glMatrix.vec3).create(); + const pb0 = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).transformQuat(ca0, (0, _constantsJs.Constants).VECTOR3_UNITY, this._rotation0); + (0, _glMatrix.vec3).scaleAndAdd(pa0, this._center0, ca0, -this._height); + (0, _glMatrix.vec3).scaleAndAdd(pb0, this._center0, ca0, this._height); + const ca1 = (0, _glMatrix.vec3).create(); + const pa1 = (0, _glMatrix.vec3).create(); + const pb1 = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).transformQuat(ca1, (0, _constantsJs.Constants).VECTOR3_UNITY, this._rotation1); + (0, _glMatrix.vec3).scaleAndAdd(pa1, this._center1, ca1, -this._height); + (0, _glMatrix.vec3).scaleAndAdd(pb1, this._center1, ca1, this._height); + this._bounds.fromCylinder(pa0, pb0, this._radius); + const bounds = new (0, _aabbJs.AABB)(); + bounds.fromCylinder(pa1, pb1, this._radius); + const min0 = this._bounds.min; + const max0 = this._bounds.max; + const min1 = bounds.min; + const max1 = bounds.max; + min0[0] = Math.min(min0[0], min1[0]); + max0[0] = Math.max(max0[0], max1[0]); + min0[1] = Math.min(min0[1], min1[1]); + max0[1] = Math.max(max0[1], max1[1]); + min0[2] = Math.min(min0[2], min1[2]); + max0[2] = Math.max(max0[2], max1[2]); + } + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.cylinder); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._radius, this._height, this._radius)); + buffer.setSize1(index, (0, _glMatrix.vec3).fromValues(this._radius, this._height, this._radius)); + buffer.setRotation0(index, this._rotation0); + buffer.setRotation1(index, this._rotation1); + } } -function defaultArrayMerge(target, source, options) { - return target.concat(source).map(function(element) { - return cloneUnlessOtherwiseSpecified(element, options); - }); +class HittableCylinderSdf extends HittableCylinder { + constructor(options){ + super(options); + this._rounding = options.rounding; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.cylinderSdf); + buffer.setRounding(index, this._rounding); + } } -function mergeObject(target, source, options) { - var destination = {}; - if (options.isMergeableObject(target)) Object.keys(target).forEach(function(key) { - destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); - }); - Object.keys(source).forEach(function(key) { - if (!options.isMergeableObject(source[key]) || !target[key]) destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); - else destination[key] = deepmerge(target[key], source[key], options); - }); - return destination; +class HittableHexPrism extends Hittable { + get radius() { + return this._radius; + } + get height() { + return this._height; + } + constructor(options){ + super(options); + this._radius = options.radius; + this._height = options.height; + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = this._center0[0] - this._radius * (0, _constantsJs.Constants).ROOT_THREE_OVER_TWO; + max[0] = this._center0[0] + this._radius * (0, _constantsJs.Constants).ROOT_THREE_OVER_TWO; + min[1] = this._center0[1] - this._height; + max[1] = this._center0[1] + this._height; + min[2] = this._center0[2] - this._radius; + max[2] = this._center0[2] + this._radius; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.hexPrism); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._radius * (0, _constantsJs.Constants).ROOT_THREE_OVER_TWO, this._height, this._radius)); + } } -function deepmerge(target, source, options) { - options = options || {}; - options.arrayMerge = options.arrayMerge || defaultArrayMerge; - options.isMergeableObject = options.isMergeableObject || isMergeableObject; - var sourceIsArray = Array.isArray(source); - var targetIsArray = Array.isArray(target); - var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; - if (!sourceAndTargetTypesMatch) return cloneUnlessOtherwiseSpecified(source, options); - else if (sourceIsArray) return options.arrayMerge(target, source, options); - else return mergeObject(target, source, options); +class HittableHexPrismSdf extends HittableHexPrism { + constructor(options){ + super(options); + this._rounding = options.rounding; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.hexPrismSdf); + buffer.setRounding(index, this._rounding); + } } -deepmerge.all = function deepmergeAll(array, options) { - if (!Array.isArray(array)) throw new Error("first argument should be an array"); - return array.reduce(function(prev, next) { - return deepmerge(prev, next, options); - }, {}); -}; -var deepmerge_1 = deepmerge; -exports.default = deepmerge_1; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cXzXP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "isPlainObject", ()=>isPlainObject); -/*! - * is-plain-object <https://github.com/jonschlinkert/is-plain-object> - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ function isObject(o) { - return Object.prototype.toString.call(o) === "[object Object]"; +class HittableRect extends Hittable { + get texCoord0() { + return this._texCoord0; + } + get texCoord1() { + return this._texCoord1; + } + constructor(options){ + super(options); + this._thickness = 0.00001; + this._size0 = options.size0; + this._size1 = options.size1; + this._texCoord0 = options.texCoord0; + this._texCoord1 = options.texCoord1; + this._setBounds(); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setTexCoord0(index, this._texCoord0); + buffer.setTexCoord1(index, this._texCoord1); + } } -function isPlainObject(o) { - var ctor, prot; - if (isObject(o) === false) return false; - // If has modified constructor - ctor = o.constructor; - if (ctor === undefined) return true; - // If has modified prototype - prot = ctor.prototype; - if (isObject(prot) === false) return false; - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty("isPrototypeOf") === false) return false; - // Most likely a plain Object - return true; +class HittableXyRect extends HittableRect { + _setBounds() { + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._size0[0], this._center1[0] - this._size1[0]); + max[0] = Math.max(this._center0[0] + this._size0[0], this._center1[0] + this._size1[0]); + min[1] = Math.min(this._center0[1] - this._size0[1], this._center1[1] - this._size1[1]); + max[1] = Math.max(this._center0[1] + this._size0[1], this._center1[1] + this._size1[1]); + min[2] = Math.min(this._center0[2] - this._thickness, this._center1[2] - this._thickness); + max[2] = Math.max(this._center0[2] + this._thickness, this._center1[2] + this._thickness); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.xyRect); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._size0[0], this._size0[1], this._thickness)); + buffer.setSize1(index, (0, _glMatrix.vec3).fromValues(this._size1[0], this._size1[1], this._thickness)); + } } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aVVvT":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Compares 2 colors to see if they are equal. - * @param a RGBAColor to compare - * @param b RGBAColor to compare - * @returns True if colors are equal. - */ parcelHelpers.export(exports, "colorIsEqual", ()=>colorIsEqual); -/** - * Convert a CSS color string to a Deck.gl RGBAColor array - (The rgba color of each object, in r, g, b, [a]. Each component is in the 0-255 range.). - * @param cssColorSpecifier A CSS Color Module Level 3 specifier string. - */ parcelHelpers.export(exports, "colorFromString", ()=>colorFromString); -/** - * Convert a Deck.gl color to a CSS rgba() string. - * @param color A Deck.gl RGBAColor array - (The rgba color of each object, in r, g, b, [a]. Each component is in the 0-255 range.) - */ parcelHelpers.export(exports, "colorToString", ()=>colorToString); -parcelHelpers.export(exports, "desaturate", ()=>desaturate); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _d3Color = require("d3-color"); -function rgbToDeckglColor(c) { - return [ - c.r, - c.g, - c.b, - c.opacity * 255 - ]; +class HittableXzRect extends HittableRect { + _setBounds() { + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._size0[0], this._center1[0] - this._size1[0]); + max[0] = Math.max(this._center0[0] + this._size0[0], this._center1[0] + this._size1[0]); + min[1] = Math.min(this._center0[1] - this._thickness, this._center1[1] - this._thickness); + max[1] = Math.max(this._center0[1] + this._thickness, this._center1[1] + this._thickness); + min[2] = Math.min(this._center0[2] - this._size0[1], this._center1[2] - this._size1[1]); + max[2] = Math.max(this._center0[2] + this._size0[1], this._center1[2] + this._size1[1]); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.xzRect); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._size0[0], this._thickness, this._size0[1])); + buffer.setSize1(index, (0, _glMatrix.vec3).fromValues(this._size1[0], this._thickness, this._size1[1])); + } } -function colorIsEqual(a, b) { - if (a.length !== b.length) return false; - for(let i = 0; i < a.length; i++){ - if (a[i] !== b[i]) return false; +class HittableYzRect extends HittableRect { + _setBounds() { + const min = this._bounds.min; + const max = this._bounds.max; + min[0] = Math.min(this._center0[0] - this._thickness, this._center1[0] - this._thickness); + max[0] = Math.max(this._center0[0] + this._thickness, this._center1[0] + this._thickness); + min[1] = Math.min(this._center0[1] - this._size0[0], this._center1[1] - this._size1[0]); + max[1] = Math.max(this._center0[1] + this._size0[0], this._center1[1] + this._size1[0]); + min[2] = Math.min(this._center0[2] - this._size0[1], this._center1[2] - this._size1[1]); + max[2] = Math.max(this._center0[2] + this._size0[1], this._center1[2] + this._size1[1]); + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.yzRect); + buffer.setSize0(index, (0, _glMatrix.vec3).fromValues(this._thickness, this._size0[0], this._size0[1])); + buffer.setSize1(index, (0, _glMatrix.vec3).fromValues(this._thickness, this._size1[0], this._size1[1])); } - return true; } -function colorFromString(cssColorSpecifier) { - if (cssColorSpecifier) { - const dc = (0, _d3Color.color)(cssColorSpecifier); - if (dc) { - const c = dc.rgb(); - return rgbToDeckglColor(c); - } +class HittableFontXyRect extends HittableXyRect { + constructor(options){ + super(options); + this._sdfBuffer = options.sdfBuffer; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setSdfBuffer(index, this._sdfBuffer); + buffer.setType(index, HittableType.fontXyRect); } } -function colorToString(color) { - const c = [ - ...color - ]; - if (c.length > 3) c[3] /= 255; - return `rgba(${c.join(",")})`; +class HittableSdfXyRect extends HittableXyRect { + constructor(options){ + super(options); + this._texId = options.texId; + this._sdfBuffer = options.sdfBuffer; + this._sdfBorder = options.sdfBorder; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setTexId(index, this._texId); + buffer.setSdfBuffer(index, this._sdfBuffer); + buffer.setSdfBorder(index, this._sdfBorder); + buffer.setType(index, HittableType.sdfXyRect); + } } -function desaturate(color, value) { - const rgb = (0, _d3Color.rgb)(color[0], color[1], color[2], color[3] / 255); - const hslColor = (0, _d3Color.hsl)(rgb); - hslColor.s = value; - const c = hslColor.rgb(); - return rgbToDeckglColor(c); +class HittableRotatedXyRect extends HittableXyRect { + constructor(options){ + super(options); + this._rotation0 = options.rotation0; + this._rotation1 = options.rotation1; + const rotatedBounds0 = new (0, _aabbJs.AABB)(); + const rotatedBounds1 = new (0, _aabbJs.AABB)(); + const min0 = rotatedBounds0.min; + const max0 = rotatedBounds0.max; + const min1 = rotatedBounds1.min; + const max1 = rotatedBounds1.max; + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation0, min0, max0, this._offset0); + (0, _boundsJs.BoundsHelper).rotateBounds(this._bounds.min, this._bounds.max, this._rotation1, min1, max1, this._offset1); + min0[0] = Math.min(min0[0], min1[0]); + max0[0] = Math.max(max0[0], max1[0]); + min0[1] = Math.min(min0[1], min1[1]); + max0[1] = Math.max(max0[1], max1[1]); + min0[2] = Math.min(min0[2], min1[2]); + max0[2] = Math.max(max0[2], max1[2]); + this._bounds = rotatedBounds0; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setType(index, HittableType.rotatedXyRect); + buffer.setRotation0(index, this._rotation0); + buffer.setRotation1(index, this._rotation1); + } +} +class HittableRotatedFontXyRect extends HittableRotatedXyRect { + constructor(options){ + super(options); + this._sdfBuffer = options.sdfBuffer; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setSdfBuffer(index, this._sdfBuffer); + buffer.setType(index, HittableType.rotatedFontXyRect); + } +} +class HittableRotatedSdfXyRect extends HittableRotatedXyRect { + constructor(options){ + super(options); + this._texId = options.texId; + this._sdfBuffer = options.sdfBuffer; + this._sdfBorder = options.sdfBorder; + } + toBuffer(buffer, index, materialId) { + super.toBuffer(buffer, index, materialId); + buffer.setTexId(index, this._texId); + buffer.setSdfBuffer(index, this._sdfBuffer); + buffer.setSdfBorder(index, this._sdfBorder); + buffer.setType(index, HittableType.rotatedSdfXyRect); + } +} +class HittableConstantMedium extends Hittable { + get boundary() { + return this._boundary; + } + constructor(options){ + super(options); + this._boundary = options.boundary; + this._bounds = this._boundary.bounds; + } + toBuffer(buffer, index, materialId) { + this._boundary.toBuffer(buffer, index, materialId); + buffer.setBoundaryType(index, buffer.getType(index)); + buffer.setType(index, HittableType.constantMedium); + } } -},{"d3-color":"i92wS","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i92wS":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"gl-matrix":"5x28d","../../constants.js":"lD0bG","../../helpers/bounds.js":"beD2A","./aabb.js":"7wAtJ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7wAtJ":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "color", ()=>(0, _colorJsDefault.default)); -parcelHelpers.export(exports, "rgb", ()=>(0, _colorJs.rgb)); -parcelHelpers.export(exports, "hsl", ()=>(0, _colorJs.hsl)); -parcelHelpers.export(exports, "lab", ()=>(0, _labJsDefault.default)); -parcelHelpers.export(exports, "hcl", ()=>(0, _labJs.hcl)); -parcelHelpers.export(exports, "lch", ()=>(0, _labJs.lch)); -parcelHelpers.export(exports, "gray", ()=>(0, _labJs.gray)); -parcelHelpers.export(exports, "cubehelix", ()=>(0, _cubehelixJsDefault.default)); -var _colorJs = require("./color.js"); -var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); -var _labJs = require("./lab.js"); -var _labJsDefault = parcelHelpers.interopDefault(_labJs); -var _cubehelixJs = require("./cubehelix.js"); -var _cubehelixJsDefault = parcelHelpers.interopDefault(_cubehelixJs); +parcelHelpers.export(exports, "AABB", ()=>AABB); +var _glMatrix = require("gl-matrix"); +var _cubeJs = require("../../meshes/cube.js"); +class AABB { + get min() { + return this._min; + } + get max() { + return this._max; + } + constructor(){ + this._min = (0, _glMatrix.vec3).fromValues(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + this._max = (0, _glMatrix.vec3).fromValues(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); + } + centroid(centroid) { + centroid[0] = (this._min[0] + this._max[0]) / 2; + centroid[1] = (this._min[1] + this._max[1]) / 2; + centroid[2] = (this._min[2] + this._max[2]) / 2; + } + size(size) { + size[0] = this._max[0] - this._min[0]; + size[1] = this._max[1] - this._min[1]; + size[2] = this._max[2] - this._min[2]; + } + offset(point, normalized) { + normalized[0] = (point[0] - this._min[0]) / (this._max[0] - this._min[0]); + normalized[1] = (point[1] - this._min[1]) / (this._max[1] - this._min[1]); + normalized[2] = (point[2] - this._min[2]) / (this._max[2] - this._min[2]); + } + unionBounds(bounds) { + (0, _glMatrix.vec3).min(this._min, this._min, bounds.min); + (0, _glMatrix.vec3).max(this._max, this._max, bounds.max); + } + unionPoint(point) { + (0, _glMatrix.vec3).min(this._min, this._min, point); + (0, _glMatrix.vec3).max(this._max, this._max, point); + } + maximumExtent() { + const dx = this._max[0] - this._min[0]; + const dy = this._max[1] - this._min[1]; + const dz = this._max[2] - this._min[2]; + if (dx > dy && dx > dz) return 0; + else if (dy > dz) return 1; + return 2; + } + surfaceArea() { + const dx = this._max[0] - this._min[0]; + const dy = this._max[1] - this._min[1]; + const dz = this._max[2] - this._min[2]; + return 2 * (dx * dy + dx * dz + dy * dz); + } + rotate(rotation) { + const sizeX = this._max[0] - this._min[0]; + const sizeY = this._max[1] - this._min[1]; + const sizeZ = this._max[2] - this._min[2]; + const min = (0, _glMatrix.vec3).fromValues(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + const max = (0, _glMatrix.vec3).fromValues(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); + const position = (0, _glMatrix.vec3).create(); + const vertices = (0, _cubeJs.Cube).POSITIONS; + for(let i = 0; i < 8; i++){ + (0, _glMatrix.vec3).set(position, vertices[i * 3] * sizeX, vertices[i * 3 + 1] * sizeY, vertices[i * 3 + 2] * sizeZ); + (0, _glMatrix.vec3).transformQuat(position, position, rotation); + (0, _glMatrix.vec3).min(min, min, position); + (0, _glMatrix.vec3).max(max, max, position); + } + (0, _glMatrix.vec3).copy(this._min, min); + (0, _glMatrix.vec3).copy(this._max, max); + } + fromCylinder(pa, pb, radius) { + const a = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).subtract(a, pb, pa); + const aa = (0, _glMatrix.vec3).dot(a, a); + const ex = radius * Math.sqrt(1 - a[0] * a[0] / aa); + const ey = radius * Math.sqrt(1 - a[1] * a[1] / aa); + const ez = radius * Math.sqrt(1 - a[2] * a[2] / aa); + this._min[0] = Math.min(pa[0] - ex, pb[0] - ex); + this._min[1] = Math.min(pa[1] - ey, pb[1] - ey); + this._min[2] = Math.min(pa[2] - ez, pb[2] - ez); + this._max[0] = Math.max(pa[0] + ex, pb[0] + ex); + this._max[1] = Math.max(pa[1] + ey, pb[1] + ey); + this._max[2] = Math.max(pa[2] + ez, pb[2] + ez); + } +} -},{"./color.js":"6tddj","./lab.js":false,"./cubehelix.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6tddj":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"gl-matrix":"5x28d","../../meshes/cube.js":"79I5N","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cAHlu":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Color", ()=>Color); -parcelHelpers.export(exports, "darker", ()=>darker); -parcelHelpers.export(exports, "brighter", ()=>brighter); -parcelHelpers.export(exports, "rgbConvert", ()=>rgbConvert); -parcelHelpers.export(exports, "rgb", ()=>rgb); -parcelHelpers.export(exports, "Rgb", ()=>Rgb); -parcelHelpers.export(exports, "hslConvert", ()=>hslConvert); -parcelHelpers.export(exports, "hsl", ()=>hsl); -var _defineJs = require("./define.js"); -var _defineJsDefault = parcelHelpers.interopDefault(_defineJs); -function Color() {} -var darker = 0.7; -var brighter = 1 / darker; -var reI = "\\s*([+-]?\\d+)\\s*", reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", reHex = /^#([0-9a-f]{3,8})$/, reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); -var named = { - aliceblue: 0xf0f8ff, - antiquewhite: 0xfaebd7, - aqua: 0x00ffff, - aquamarine: 0x7fffd4, - azure: 0xf0ffff, - beige: 0xf5f5dc, - bisque: 0xffe4c4, - black: 0x000000, - blanchedalmond: 0xffebcd, - blue: 0x0000ff, - blueviolet: 0x8a2be2, - brown: 0xa52a2a, - burlywood: 0xdeb887, - cadetblue: 0x5f9ea0, - chartreuse: 0x7fff00, - chocolate: 0xd2691e, - coral: 0xff7f50, - cornflowerblue: 0x6495ed, - cornsilk: 0xfff8dc, - crimson: 0xdc143c, - cyan: 0x00ffff, - darkblue: 0x00008b, - darkcyan: 0x008b8b, - darkgoldenrod: 0xb8860b, - darkgray: 0xa9a9a9, - darkgreen: 0x006400, - darkgrey: 0xa9a9a9, - darkkhaki: 0xbdb76b, - darkmagenta: 0x8b008b, - darkolivegreen: 0x556b2f, - darkorange: 0xff8c00, - darkorchid: 0x9932cc, - darkred: 0x8b0000, - darksalmon: 0xe9967a, - darkseagreen: 0x8fbc8f, - darkslateblue: 0x483d8b, - darkslategray: 0x2f4f4f, - darkslategrey: 0x2f4f4f, - darkturquoise: 0x00ced1, - darkviolet: 0x9400d3, - deeppink: 0xff1493, - deepskyblue: 0x00bfff, - dimgray: 0x696969, - dimgrey: 0x696969, - dodgerblue: 0x1e90ff, - firebrick: 0xb22222, - floralwhite: 0xfffaf0, - forestgreen: 0x228b22, - fuchsia: 0xff00ff, - gainsboro: 0xdcdcdc, - ghostwhite: 0xf8f8ff, - gold: 0xffd700, - goldenrod: 0xdaa520, - gray: 0x808080, - green: 0x008000, - greenyellow: 0xadff2f, - grey: 0x808080, - honeydew: 0xf0fff0, - hotpink: 0xff69b4, - indianred: 0xcd5c5c, - indigo: 0x4b0082, - ivory: 0xfffff0, - khaki: 0xf0e68c, - lavender: 0xe6e6fa, - lavenderblush: 0xfff0f5, - lawngreen: 0x7cfc00, - lemonchiffon: 0xfffacd, - lightblue: 0xadd8e6, - lightcoral: 0xf08080, - lightcyan: 0xe0ffff, - lightgoldenrodyellow: 0xfafad2, - lightgray: 0xd3d3d3, - lightgreen: 0x90ee90, - lightgrey: 0xd3d3d3, - lightpink: 0xffb6c1, - lightsalmon: 0xffa07a, - lightseagreen: 0x20b2aa, - lightskyblue: 0x87cefa, - lightslategray: 0x778899, - lightslategrey: 0x778899, - lightsteelblue: 0xb0c4de, - lightyellow: 0xffffe0, - lime: 0x00ff00, - limegreen: 0x32cd32, - linen: 0xfaf0e6, - magenta: 0xff00ff, - maroon: 0x800000, - mediumaquamarine: 0x66cdaa, - mediumblue: 0x0000cd, - mediumorchid: 0xba55d3, - mediumpurple: 0x9370db, - mediumseagreen: 0x3cb371, - mediumslateblue: 0x7b68ee, - mediumspringgreen: 0x00fa9a, - mediumturquoise: 0x48d1cc, - mediumvioletred: 0xc71585, - midnightblue: 0x191970, - mintcream: 0xf5fffa, - mistyrose: 0xffe4e1, - moccasin: 0xffe4b5, - navajowhite: 0xffdead, - navy: 0x000080, - oldlace: 0xfdf5e6, - olive: 0x808000, - olivedrab: 0x6b8e23, - orange: 0xffa500, - orangered: 0xff4500, - orchid: 0xda70d6, - palegoldenrod: 0xeee8aa, - palegreen: 0x98fb98, - paleturquoise: 0xafeeee, - palevioletred: 0xdb7093, - papayawhip: 0xffefd5, - peachpuff: 0xffdab9, - peru: 0xcd853f, - pink: 0xffc0cb, - plum: 0xdda0dd, - powderblue: 0xb0e0e6, - purple: 0x800080, - rebeccapurple: 0x663399, - red: 0xff0000, - rosybrown: 0xbc8f8f, - royalblue: 0x4169e1, - saddlebrown: 0x8b4513, - salmon: 0xfa8072, - sandybrown: 0xf4a460, - seagreen: 0x2e8b57, - seashell: 0xfff5ee, - sienna: 0xa0522d, - silver: 0xc0c0c0, - skyblue: 0x87ceeb, - slateblue: 0x6a5acd, - slategray: 0x708090, - slategrey: 0x708090, - snow: 0xfffafa, - springgreen: 0x00ff7f, - steelblue: 0x4682b4, - tan: 0xd2b48c, - teal: 0x008080, - thistle: 0xd8bfd8, - tomato: 0xff6347, - turquoise: 0x40e0d0, - violet: 0xee82ee, - wheat: 0xf5deb3, - white: 0xffffff, - whitesmoke: 0xf5f5f5, - yellow: 0xffff00, - yellowgreen: 0x9acd32 -}; -(0, _defineJsDefault.default)(Color, color, { - copy (channels) { - return Object.assign(new this.constructor, this, channels); - }, - displayable () { - return this.rgb().displayable(); - }, - hex: color_formatHex, - formatHex: color_formatHex, - formatHex8: color_formatHex8, - formatHsl: color_formatHsl, - formatRgb: color_formatRgb, - toString: color_formatRgb -}); -function color_formatHex() { - return this.rgb().formatHex(); -} -function color_formatHex8() { - return this.rgb().formatHex8(); -} -function color_formatHsl() { - return hslConvert(this).formatHsl(); -} -function color_formatRgb() { - return this.rgb().formatRgb(); +parcelHelpers.export(exports, "ComputeShaderWgsl", ()=>ComputeShaderWgsl); +parcelHelpers.export(exports, "ComputeUniformBufferData", ()=>ComputeUniformBufferData); +var _glMatrix = require("gl-matrix"); +const ComputeShaderWgsl = ` +const PI = 3.1415926535897932385f; +const TWO_PI = 6.2831853071795864769f; +const ROOT_THREE_OVER_TWO = 0.86602540378443864676f; + +struct ColorBuffer { + values: array<f32>, } -function color(format) { - var m, l; - format = (format + "").trim().toLowerCase(); - return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000 - : l === 3 ? new Rgb(m >> 8 & 0xf | m >> 4 & 0xf0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00 - : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000 - : l === 4 ? rgba(m >> 12 & 0xf | m >> 8 & 0xf0, m >> 8 & 0xf | m >> 4 & 0xf0, m >> 4 & 0xf | m & 0xf0, ((m & 0xf) << 4 | m & 0xf) / 0xff) // #f000 - : null // invalid hex - ) : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) - : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) - : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) - : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) - : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) - : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) - : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins - : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; + +// (normal.x, normal.y, normal.z, depth) +struct NormalDepthBuffer { + values: array<f32>, } -exports.default = color; -function rgbn(n) { - return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); + +// Min, max +// TODO: Convert to atomic add with uint +struct DepthMinMaxBuffer { + values: array<atomic<u32>>, } -function rgba(r, g, b, a) { - if (a <= 0) r = g = b = NaN; - return new Rgb(r, g, b, a); + +struct Ray { + origin: vec3<f32>, + direction: vec3<f32>, + time: f32, } -function rgbConvert(o) { - if (!(o instanceof Color)) o = color(o); - if (!o) return new Rgb; - o = o.rgb(); - return new Rgb(o.r, o.g, o.b, o.opacity); -} -function rgb(r, g, b, opacity) { - return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); -} -function Rgb(r, g, b, opacity) { - this.r = +r; - this.g = +g; - this.b = +b; - this.opacity = +opacity; -} -(0, _defineJsDefault.default)(Rgb, rgb, (0, _defineJs.extend)(Color, { - brighter (k) { - k = k == null ? brighter : Math.pow(brighter, k); - return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); - }, - darker (k) { - k = k == null ? darker : Math.pow(darker, k); - return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); - }, - rgb () { - return this; - }, - clamp () { - return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); - }, - displayable () { - return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1; - }, - hex: rgb_formatHex, - formatHex: rgb_formatHex, - formatHex8: rgb_formatHex8, - formatRgb: rgb_formatRgb, - toString: rgb_formatRgb -})); -function rgb_formatHex() { - return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; + +struct HitRecord { + normal: vec3<f32>, + t: f32, + frontFace: bool, + materialId: u32, + uv: vec2<f32>, + id: u32, + previousId: u32, + position: vec3<f32>, + previousPosition: vec3<f32>, + isAbsorbing: bool, + previousIsAbsorbing: bool, + absorption: vec3<f32>, + previousAbsorption: vec3<f32>, + sdfBorder: bool, } -function rgb_formatHex8() { - return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; + +struct Camera { + origin: vec3<f32>, + lowerLeftCorner: vec3<f32>, + horizontal: vec3<f32>, + vertical: vec3<f32>, + lookAt: vec3<f32>, + u: vec3<f32>, + v: vec3<f32>, + w: vec3<f32>, + aspectRatio: f32, + viewportWidth: f32, + viewportHeight: f32, + fov: f32, + aperture: f32, + time0: f32, + time1: f32, } -function rgb_formatRgb() { - const a = clampa(this.opacity); - return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`; + + // offest align size +struct Uniforms { // ------------------------------ + position: vec3<f32>, // 0 16 12 + width: f32, // 12 4 4 + right: vec3<f32>, // 16 16 12 + height: f32, // 28 4 4 + up: vec3<f32>, // 32 16 12 + seed: f32, // 44 4 4 + forward: vec3<f32>, // 48 16 12 + fov: f32, // 60 4 4 + lookAt: vec3<f32>, // 64 16 12 + aperture: f32, // 76 4 4 + backgroundColor: vec3<f32>, // 80 16 12 + time0: f32, // 92 4 4 + time1: f32, // 96 4 4 + tilesX : f32, // 100 4 4 + tilesY : f32, // 104 4 4 + tileOffsetX : f32, // 108 4 4 + tileOffsetY : f32, // 112 4 4 + raysPerFrame : f32, // 116 4 4 + // padding 120 4 8 + // ------------------------------ + // 16 128 } -function clampa(opacity) { - return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); + +// id type +// ---------------- +// 0 none +// 1 solidColor +// 2 image +// 3 sdfText +// 4 checker +// 5 grid + // offest align size stride +struct Texture { // --------------------------------------- + color0: vec3<f32>, // 0 16 12 + typeId: f32, // 12 4 4 + color1: vec3<f32>, // 16 12 12 + // padding 28 12 12 + size0: vec4<f32>, // 32 16 16 + size1: vec4<f32>, // 48 16 16 + clip: vec4<f32>, // 64 16 16 + offset: vec2<f32>, // 80 8 8 +} // --------------------------------------- + // 16 88 96 + +// id type +// --------------- +// 0 lambertian +// 1 metal +// 2 dielectric +// 3 diffuse light +// 4 glossy +// 5 isotropic +// 6 varnitsh + // offest align size stride +struct Material { // --------------------------------------- + typeId: f32, // 0 4 4 + fuzz: f32, // 4 4 4 + refractiveIndex: f32, // 8 4 4 + textureId: f32, // 12 4 4 + color: vec3<f32>, // 16 16 12 + glossiness: f32, // 28 4 4 + idColor: vec4<f32>, // 32 16 16 + density: f32, // 48 4 4 + // --------------------------------------- +} // 16 52 64 + +// id type +// ---------------- +// 0 distant +// 1 sphere +// 2 rect +// 3 disk +// 4 cylinder +// 5 dome + // offest align size stride +struct Light { // --------------------------------------- + rotation: vec4<f32>, // 0 16 16 + center: vec3<f32>, // 16 16 12 + typeId: f32, // 28 4 4 + size: vec3<f32>, // 32 16 12 + // padding 44 4 4 + color: vec3<f32>, // 48 16 12 +} // --------------------------------------- + // 16 60 64 + +// id type +// ---------------- +// 0 sphere +// 1 box +// 2 cylinder +// 3 hexPrism +// 4 rotatedBox +// 5 xyRect +// 6 xzRect +// 7 yzRect +// 8 rotatedXyRect +// 9 fontXyRect +// 10 rotatedFontXyRect +// 11 boxSdf +// 12 cylinderSdf +// 13 hexPrismSdf +// 14 constantMedium +// 15 sdfXyRect +// 16 rotatedSdfXyRect +// 17 rotatedBoxSdf +// 18 xyDisk +// 19 rotatedXyDisk +// 20 ringSdf +// 21 rotatedRingSdf + // offest align size stride +struct Hittable { // --------------------------------------- + center0: vec3<f32>, // 0 16 12 + typeId: f32, // 12 4 4 + size0: vec3<f32>, // 16 16 12 + materialId: f32, // 28 4 4 + rotation0: vec4<f32>, // 32 16 16 + rotation1: vec4<f32>, // 48 16 16 + texCoord0: vec2<f32>, // 64 8 8 + texCoord1: vec2<f32>, // 72 8 8 + center1: vec3<f32>, // 80 16 12 + rounding: f32, // 92 4 4 + size1: vec3<f32>, // 96 16 12 + boundaryTypeId: f32, // 108 4 4 + time0: f32, // 112 4 4 + time1: f32, // 116 4 4 + texId: f32, // 120 4 4 + sdfBuffer: f32, // 124 4 4 + sdfBorder: f32, // 128 4 4 + parameter1: f32, // 132 4 4 + parameter2: f32, // 136 4 4 + // padding 140 4 4 +} // --------------------------------------- + // 16 144 144 + + // offest align size stride +struct LinearBVHNode { // --------------------------------------- + center: vec3<f32>, // 0 16 12 + primitivesOffset: f32, // 12 4 4 + size: vec3<f32>, // 16 16 12 + secondChildOffset: f32, // 28 4 4 + nPrimitives: f32, // 32 4 4 + axis: f32, // 36 4 4 +} // --------------------------------------- + // 16 40 48 + +struct HittableBuffer { + hittables: array<Hittable>, } -function clampi(value) { - return Math.max(0, Math.min(255, Math.round(value) || 0)); + +struct MaterialBuffer { + materials: array<Material>, } -function hex(value) { - value = clampi(value); - return (value < 16 ? "0" : "") + value.toString(16); + +struct TextureBuffer { + textures: array<Texture>, } -function hsla(h, s, l, a) { - if (a <= 0) h = s = l = NaN; - else if (l <= 0 || l >= 1) h = s = NaN; - else if (s <= 0) h = NaN; - return new Hsl(h, s, l, a); + +struct LightBuffer { + lights: array<Light>, } -function hslConvert(o) { - if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); - if (!(o instanceof Color)) o = color(o); - if (!o) return new Hsl; - if (o instanceof Hsl) return o; - o = o.rgb(); - var r = o.r / 255, g = o.g / 255, b = o.b / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), h = NaN, s = max - min, l = (max + min) / 2; - if (s) { - if (r === max) h = (g - b) / s + (g < b) * 6; - else if (g === max) h = (b - r) / s + 2; - else h = (r - g) / s + 4; - s /= l < 0.5 ? max + min : 2 - max - min; - h *= 60; - } else s = l > 0 && l < 1 ? 0 : h; - return new Hsl(h, s, l, o.opacity); + +struct LinearBVHNodeBuffer { + nodes: array<LinearBVHNode>, } -function hsl(h, s, l, opacity) { - return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); + +// Schlick's approximation for reflectance +fn reflectance(cos: f32, refractiveIndex: f32) -> f32 { + var r = (1f - refractiveIndex) / (1f + refractiveIndex); + r = r * r; + return r + (1f - r) * pow(1f - cos, 5f); } -function Hsl(h, s, l, opacity) { - this.h = +h; - this.s = +s; - this.l = +l; - this.opacity = +opacity; + +fn refraction(uv: vec3<f32>, n: vec3<f32>, etaiOverEtat: f32) -> vec3<f32> { + let cosTheta = min(dot(-uv, n), 1f); + let rOutPerp = etaiOverEtat * (uv + cosTheta * n); + let rOutParallel = -sqrt(abs(1f - dot(rOutPerp, rOutPerp))) * n; + return rOutPerp + rOutParallel; } -(0, _defineJsDefault.default)(Hsl, hsl, (0, _defineJs.extend)(Color, { - brighter (k) { - k = k == null ? brighter : Math.pow(brighter, k); - return new Hsl(this.h, this.s, this.l * k, this.opacity); - }, - darker (k) { - k = k == null ? darker : Math.pow(darker, k); - return new Hsl(this.h, this.s, this.l * k, this.opacity); - }, - rgb () { - var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2; - return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity); - }, - clamp () { - return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); - }, - displayable () { - return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1; - }, - formatHsl () { - const a = clampa(this.opacity); - return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`; - } -})); -function clamph(value) { - value = (value || 0) % 360; - return value < 0 ? value + 360 : value; + +fn getCamera(uniforms: Uniforms) -> Camera { + var camera: Camera; + camera.aperture = uniforms.aperture; + camera.aspectRatio = uniforms.width / uniforms.height; + camera.fov = uniforms.fov; + camera.viewportHeight = 2f * tan(camera.fov / 2f); + camera.viewportWidth = camera.aspectRatio * camera.viewportHeight; + camera.origin = uniforms.position; + camera.lookAt = uniforms.lookAt; + camera.u = uniforms.right; + camera.v = uniforms.up; + camera.w = uniforms.forward; + let focusDistance = dot(camera.w, camera.origin - camera.lookAt); + camera.horizontal = camera.u * camera.viewportWidth * focusDistance; + camera.vertical = camera.v * camera.viewportHeight * focusDistance; + camera.lowerLeftCorner = camera.origin - camera.horizontal / 2f + camera.vertical / 2f - camera.w * focusDistance; + camera.time0 = uniforms.time0; + camera.time1 = uniforms.time1; + return camera; } -function clampt(value) { - return Math.max(0, Math.min(1, value || 0)); + +fn getCameraRay(camera: Camera, seed: ptr<function, u32>, texCoord: vec2<f32>) -> Ray { + // Depth of field + let rd = camera.aperture * randomInUnitDisk(seed); + let offset = camera.u * rd.x + camera.v * rd.y; + + var ray: Ray; + ray.origin = camera.origin + offset; + ray.direction = normalize(camera.lowerLeftCorner + texCoord.x * camera.horizontal - texCoord.y * camera.vertical - camera.origin - offset); + ray.time = camera.time0 + random(seed) * (camera.time1 - camera.time0); + return ray; } -/* From FvD 13.37, CSS Color Module Level 3 */ function hsl2rgb(h, m1, m2) { - return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; + +fn degreesToRadians(degrees: f32) -> f32 { + return degrees * PI / 180f; } -},{"./define.js":"4GFcV","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4GFcV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "extend", ()=>extend); -exports.default = function(constructor, factory, prototype) { - constructor.prototype = factory.prototype = prototype; - prototype.constructor = constructor; -}; -function extend(parent, definition) { - var prototype = Object.create(parent.prototype); - for(var key in definition)prototype[key] = definition[key]; - return prototype; +// See https://www.reedbeta.com/blog/hash-functions-for-gpu-rendering/ +fn random(seed: ptr<function, u32>) -> f32 { + var random = ((*seed >> ((*seed >> 28u) + 4u)) ^ *seed) * 277803737u; + random = (random >> 22u) ^ random; + *seed = *seed * 747796405u + 2891336453u; + return f32(random) / 4294967295f; // [0,1] } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4ObFg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "minHeight", ()=>minHeight); -parcelHelpers.export(exports, "minWidth", ()=>minWidth); -parcelHelpers.export(exports, "defaultPresenterStyle", ()=>defaultPresenterStyle); -parcelHelpers.export(exports, "defaultPresenterConfig", ()=>defaultPresenterConfig); -parcelHelpers.export(exports, "createStage", ()=>createStage); -parcelHelpers.export(exports, "groupStrokeWidth", ()=>groupStrokeWidth); -parcelHelpers.export(exports, "lineZ", ()=>lineZ); -parcelHelpers.export(exports, "defaultView", ()=>defaultView); -parcelHelpers.export(exports, "minZ", ()=>minZ); -parcelHelpers.export(exports, "min3dDepth", ()=>min3dDepth); -parcelHelpers.export(exports, "minPixelSize", ()=>minPixelSize); -parcelHelpers.export(exports, "defaultOnAxisItem", ()=>defaultOnAxisItem); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _color = require("./color"); -const minHeight = "100px"; -const minWidth = "100px"; -const defaultPresenterStyle = { - cssPrefix: "vega-morphcharts-", - defaultCubeColor: [ - 128, - 128, - 128, - 255 - ], - highlightColor: [ - 0, - 0, - 0, - 255 - ] -}; -const defaultPresenterConfig = { - onCubeClick: (e, cube)=>{}, - onCubeHover: (e, cube)=>{}, - transitionDurations: { - position: 600, - stagger: 600, - view: 600 - }, - renderer: { - advanced: false, - advancedOptions: {}, - basicOptions: { - antialias: true - } +fn randomInUnitDisk(seed: ptr<function, u32>) -> vec2<f32> { + var p: vec2<f32>; + loop { + p = 2f * vec2<f32>(random(seed), random(seed)) - vec2<f32>(1f, 1f); + if (dot(p, p) <= 1f) { break; } } -}; -function createStage(view) { - const stage = { - view, - cubeData: [], - pathData: [], - axes: { - x: [], - y: [], - z: [] - }, - gridLines: [], - textData: [], - legend: { - rows: {} - }, - facets: [] - }; - return stage; + return p; } -const groupStrokeWidth = 1; -const lineZ = 0; -const defaultView = "2d"; -const minZ = 0.5; -const min3dDepth = 0.05; -const minPixelSize = 0.5; -const zAxisEncodeColor = [ - 7, - 7, - 7, - 255 -]; -const zAxisOutColor = [ - 0, - 0, - 0, - 255 -]; -function defaultOnAxisItem(vegaItem, stageItem, stage, currAxis) { - if ((0, _color.colorIsEqual)(stageItem.color, zAxisEncodeColor)) { - stageItem.color = zAxisOutColor; - if (currAxis.axisRole !== "z") { - const previousAxisRole = removeCurrentAxes(stage, currAxis); - if (previousAxisRole) { - currAxis.axisRole = "z"; - stage.axes.z.push(currAxis); - } - } + +// fn randomInUnitDisk(seed: ptr<function, u32>) -> vec2<f32> { +// let t = TWO_PI * random(seed); +// let r = sqrt(random(seed)); +// return r * vec2<f32>(cos(t), sin(t)); +// } + +fn randomInUnitSphere(seed: ptr<function, u32>) -> vec3<f32> { + var p: vec3<f32>; + loop { + p = 2f * vec3<f32>(random(seed), random(seed), random(seed)) - vec3<f32>(1f, 1f, 1f); + if (dot(p, p) <= 1f) { break; } } + return p; } -function removeCurrentAxes(stage, currAxis) { - //find the current axis, remove it from parent - for(const axisRole in stage.axes){ - const axes = stage.axes[axisRole]; - for(let i = 0; i < axes.length; i++)if (axes[i] === currAxis) { - axes.splice(i, 1); - return axisRole; - } - } + +fn randomUnitVector(seed: ptr<function, u32>) -> vec3<f32> { + return normalize(randomInUnitSphere(seed)); } -},{"./color":"aVVvT","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"77OTl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "base", ()=>base); -/** - * Specify the dependency libraries to use for rendering. - * @param vega Vega library. - */ parcelHelpers.export(exports, "use", ()=>use); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ const vega = { - CanvasHandler: null, - inferType: null, - inferTypes: null, - loader: null, - parse: null, - read: null, - renderModule: null, - Renderer: null, - sceneVisit: null, - scheme: null, - truncate: null, - View: null -}; -const base = { - vega -}; -function use(vega) { - base.vega = vega; +// fn randomUnitVector(seed: ptr<function, u32>) -> vec3<f32> { +// let theta = TWO_PI * random(seed); // [0,2Pi] +// let phi = acos(2f * random(seed) - 1f); // [-1,1] +// return vec3<f32>(sin(phi) * cos(theta), sin(phi) * sin(theta), cos(phi)); +// } + +fn rayAt(ray: Ray, t: f32) -> vec3<f32> { + return ray.origin + ray.direction * t; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lSg1r":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Class which presents a Stage of chart data using MorphCharts to render. - */ parcelHelpers.export(exports, "Presenter", ()=>Presenter); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _clone = require("./clone"); -var _defaults = require("./defaults"); -var _enums = require("./enums"); -var _legend = require("./legend"); -var _panel = require("./panel"); -var _patchedCubeArray = require("./patchedCubeArray"); -var _stagers = require("./stagers"); -var _tsxCreateElement = require("tsx-create-element"); -var _morphcharts = require("./morphcharts"); -class Presenter { - /** - * Instantiate a new Presenter. - * @param el Parent HTMLElement to present within. - * @param style Optional PresenterStyle styling options. - */ constructor(el, style){ - this.el = el; - this.style = (0, _clone.deepMerge)((0, _defaults.defaultPresenterStyle), style); - (0, _panel.initializePanel)(this); - this._last = { - view: null, - height: null, - width: null, - cubeCount: null, - stage: null - }; - } - /** - * Get the previously rendered Stage object. - */ get stage() { - return this._last.stage; - } - /** - * Get the current View camera type. - */ get view() { - return this._last.view; - } - /** - * Cancels any pending animation, calling animationCanceled() on original queue. - */ animationCancel() { - if (this.animationTimer) { - clearTimeout(this.animationTimer); - this.animationTimer = null; - if (this.logger) this.logger(`canceling animation ${this.queuedAnimationOptions && this.queuedAnimationOptions.handlerLabel || "handler"}`); - if (this.queuedAnimationOptions && this.queuedAnimationOptions.animationCanceled) this.queuedAnimationOptions.animationCanceled.call(null); - } - } - /** - * Stops the current animation and queues a new animation. - * @param handler Function to invoke when timeout is complete. - * @param timeout Length of time to wait before invoking the handler. - * @param options Optional QueuedAnimationOptions object. - */ animationQueue(handler, timeout, options) { - if (this.logger) this.logger(`queueing animation ${options && options.waitingLabel || "waiting"}...(${timeout})`); - this.animationCancel(); - this.animationTimer = setTimeout(()=>{ - if (this.logger) this.logger(`queueing animation ${options && options.handlerLabel || "handler"}...`); - handler(); - }, timeout); - } - /** - * Retrieve a sub-element of the rendered output. - * @param type PresenterElement type of the HTMLElement to retrieve. - */ getElement(type) { - const elements = this.el.getElementsByClassName((0, _panel.className)(type, this)); - if (elements && elements.length) return elements[0]; - } - /** - * Present the Vega Scene, or Stage object using Morphcharts. - * @param sceneOrStage Vega Scene object, or Stage object containing chart layout info. - * @param height Height of the rendering area. - * @param width Width of the rendering area. - * @param config Optional presentation configuration object. - */ present(sceneOrStage, height, width, config) { - this.animationCancel(); - const scene = sceneOrStage; - let stage; - const options = { - maxOrdinal: 0, - currAxis: null, - defaultCubeColor: this.style.defaultCubeColor, - assignCubeOrdinal: config && config.onSceneRectAssignCubeOrdinal || (()=>options.maxOrdinal++), - modifyAxis: (config === null || config === void 0 ? void 0 : config.onAxisItem) ? config.onAxisItem : (0, _defaults.defaultOnAxisItem), - zAxisZindex: config === null || config === void 0 ? void 0 : config.zAxisZindex - }; - //determine if this is a vega scene - if (scene.marktype) { - stage = (0, _defaults.createStage)(scene.view); - (0, _stagers.sceneToStage)(options, stage, scene); - } else stage = sceneOrStage; - const c = (0, _clone.deepMerge)((0, _defaults.defaultPresenterConfig), config); - if (!this.morphchartsref) { - this._morphChartsOptions = { - container: this.getElement((0, _enums.PresenterElement).gl), - pickGridCallback: c.axisPickGridCallback, - onCubeHover: (e, ordinal)=>{ - c.onCubeHover(e, { - ordinal, - color: null, - position: null, - size: null - }); - }, - onCubeClick: (e, ordinal)=>{ - c.onCubeClick(e, { - ordinal, - color: null, - position: null, - size: null - }); - }, - onCanvasClick: config === null || config === void 0 ? void 0 : config.onLayerClick, - onLasso: config === null || config === void 0 ? void 0 : config.onLasso - }; - this.morphchartsref = (0, _morphcharts.init)(this._morphChartsOptions, c.renderer || (0, _defaults.defaultPresenterConfig).renderer); - } - let cubeCount = Math.max(this._last.cubeCount, stage.cubeData.length); - if (options.maxOrdinal) { - cubeCount = Math.max(cubeCount, options.maxOrdinal); - const empty = { - isEmpty: true - }; - stage.cubeData = (0, _patchedCubeArray.patchCubeArray)(cubeCount, empty, stage.cubeData); - } - config.preLayer && config.preLayer(stage); - this.morphChartsRenderResult = (0, _morphcharts.morphChartsRender)(this.morphchartsref, this._last.stage, stage, height, width, config && config.preStage, config && config.morphChartsColors, c); - delete stage.cubeData; - delete stage.redraw; - this._last = { - cubeCount, - height, - width, - stage, - view: stage.view - }; - const a = (0, _tsxCreateElement.getActiveElementInfo)(); - (0, _tsxCreateElement.mount)((0, _legend.LegendView)({ - legend: stage.legend, - onClick: config && config.onLegendClick - }), this.getElement((0, _enums.PresenterElement).legend)); - (0, _tsxCreateElement.setActiveElement)(a); - if (config && config.onPresent) config.onPresent(); - } - canvasToDataURL() { - return new Promise((resolve, reject)=>{ - this.morphchartsref.core.afterRenderCallback = ()=>{ - this.morphchartsref.core.afterRenderCallback = null; - const canvas = this.getElement((0, _enums.PresenterElement).gl).getElementsByTagName("canvas")[0]; - const png = canvas.toDataURL("image/png"); - resolve(png); - }; - }); - } - configColors(mcColors) { - (0, _morphcharts.colorConfig)(this.morphchartsref, mcColors); - } - /** - * Home the camera to the last initial position. - */ homeCamera() { - var _a; - (_a = this.morphchartsref) === null || _a === void 0 || _a.reset(); - } - /** - * Show guidelines of rendering height/width and center of OrbitView. - */ showGuides() { - this.getElement((0, _enums.PresenterElement).gl).classList.add("show-center"); - //TODO Morphcharts gridlines - } - finalize() { - this.animationCancel(); - if (this.morphchartsref) this.morphchartsref.core.stop(); - if (this.el) this.el.innerHTML = ""; - this._last = null; - this.morphchartsref = null; - this.el = null; - this.logger = null; - this.queuedAnimationOptions = null; - } +fn setFaceNormal(ray: Ray, outwardNormal: vec3<f32>, hitRecord: ptr<function, HitRecord>) { + (*hitRecord).frontFace = dot(ray.direction, outwardNormal) < 0f; + (*hitRecord).normal = select(-outwardNormal, outwardNormal, (*hitRecord).frontFace); } -},{"./clone":"kri2h","./defaults":"4ObFg","./enums":"cMvaW","./legend":"4ZV5X","./panel":"7F6fO","./patchedCubeArray":"ji0oV","./stagers":"94bP8","tsx-create-element":"c7YxA","./morphcharts":"hDIWp","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cMvaW":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "PresenterElement", ()=>PresenterElement); -var PresenterElement; -(function(PresenterElement) { - PresenterElement[PresenterElement["root"] = 0] = "root"; - PresenterElement[PresenterElement["gl"] = 1] = "gl"; - PresenterElement[PresenterElement["panel"] = 2] = "panel"; - PresenterElement[PresenterElement["legend"] = 3] = "legend"; - PresenterElement[PresenterElement["vegaControls"] = 4] = "vegaControls"; -})(PresenterElement || (PresenterElement = {})); +// fn hitWorld(ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { +// var hitAnything = false; +// var closestSoFar = tMax; +// let invDir = vec3<f32>(1f, 1f, 1f) / ray.direction; +// var tempHitRecord: HitRecord; +// for (var i: u32 = 0u; i < arrayLength(&hittableBuffer.hittables); i = i + 1u) { +// if (hit(i, ray, invDir, tMin, closestSoFar, &tempHitRecord, seed)) { +// hitAnything = true; +// closestSoFar = tempHitRecord.t; +// tempHitRecord.materialId = u32(hittableBuffer.hittables[i].materialId); +// *hitRecord = tempHitRecord; +// } +// } +// return hitAnything; +// } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4ZV5X":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "LegendView", ()=>LegendView); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _tsxCreateElement = require("tsx-create-element"); -var _controls = require("./controls"); -const LegendView = (props)=>{ - const rows = []; - const addRow = (row, i)=>{ - const fn = symbolMap[row.symbol.shape]; - let jsx; - if (fn) jsx = fn(row.symbol); - else jsx = (0, _tsxCreateElement.createElement)("span", null, "x"); - rows.push({ - cells: [ - { - className: "symbol", - content: jsx - }, - { - className: "label", - content: row.label, - title: row.label - }, - ] - }); - }; - const sorted = Object.keys(props.legend.rows).sort((a, b)=>+a - +b); - sorted.forEach((i)=>addRow(props.legend.rows[i], +i)); - if (sorted.length) return (0, _tsxCreateElement.createElement)((0, _controls.Table), { - rows: rows, - rowClassName: "legend-row", - onRowClick: (e, i)=>props.onClick(e, props.legend, i) - }, props.legend.title !== void 0 && (0, _tsxCreateElement.createElement)("tr", { - onClick: (e)=>props.onClick(e, props.legend, null) - }, (0, _tsxCreateElement.createElement)("th", { - colSpan: 2 - }, props.legend.title))); -}; -const symbolMap = { - square: function(symbol) { - return (0, _tsxCreateElement.createElement)("div", { - style: { - height: `${symbol.bounds.y2 - symbol.bounds.y1}px`, - width: `${symbol.bounds.x2 - symbol.bounds.x1}px`, - backgroundColor: symbol.fill, - borderColor: symbol.fill +fn hitBVH(ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { + var hitAnything = false; + var closestSoFar = tMax; + let invDir = vec3<f32>(1f, 1f, 1f) / ray.direction; + var tempHitRecord: HitRecord; + var toVisitOffset = 0u; + var currentNodeIndex = 0u; + var nodesToVisit: array<u32, 64>; + loop { + let node = &linearBVHNodeBuffer.nodes[currentNodeIndex]; + // Check ray against BVH node + if (intersectBox((*node).center, (*node).size, ray, invDir, tMin, closestSoFar)) { + let nPrimitives = u32((*node).nPrimitives); + if (nPrimitives > 0u) { + let primitiveOffset = u32((*node).primitivesOffset); + for (var i: u32 = 0u; i < nPrimitives; i = i + 1u) { + let id = primitiveOffset + i; + if (hit(id, ray, invDir, tMin, closestSoFar, &tempHitRecord, seed)) { + hitAnything = true; + closestSoFar = tempHitRecord.t; + tempHitRecord.materialId = u32(hittableBuffer.hittables[id].materialId); + tempHitRecord.id = id; + } + } + if (toVisitOffset == 0u) { break; } + toVisitOffset = toVisitOffset - 1u; + currentNodeIndex = nodesToVisit[toVisitOffset]; } - }); + else { + // Put far BVH node on nodesToVisit stack, advance to near node + if (ray.direction[u32((*node).axis)] < 0f) { + nodesToVisit[toVisitOffset] = currentNodeIndex + 1u; + currentNodeIndex = u32((*node).secondChildOffset); + } else { + nodesToVisit[toVisitOffset] = u32((*node).secondChildOffset); + currentNodeIndex = currentNodeIndex + 1u; + } + toVisitOffset = toVisitOffset + 1u; + } + } + else { + if (toVisitOffset == 0u) { break; } + toVisitOffset = toVisitOffset - 1u; + currentNodeIndex = nodesToVisit[toVisitOffset]; + } } -}; + if (hitAnything) { + tempHitRecord.previousId = (*hitRecord).id; + tempHitRecord.previousPosition = (*hitRecord).position; + tempHitRecord.previousIsAbsorbing = (*hitRecord).isAbsorbing; + tempHitRecord.previousAbsorption = (*hitRecord).absorption; + *hitRecord = tempHitRecord; + return true; + }; + return false; +} -},{"tsx-create-element":"c7YxA","./controls":"gjf7F","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7F6fO":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "initializePanel", ()=>initializePanel); -parcelHelpers.export(exports, "className", ()=>className); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _tsxCreateElement = require("tsx-create-element"); -var _defaults = require("./defaults"); -var _enums = require("./enums"); -function initializePanel(presenter) { - const rootDiv = (0, _tsxCreateElement.createElement)("div", { - className: className((0, _enums.PresenterElement).root, presenter) - }, (0, _tsxCreateElement.createElement)("div", { - className: className((0, _enums.PresenterElement).gl, presenter), - style: { - minHeight: (0, _defaults.minHeight), - minWidth: (0, _defaults.minWidth) +fn hit(id: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { + switch u32(hittableBuffer.hittables[id].typeId) { + default: { + return false; } - }), (0, _tsxCreateElement.createElement)("div", { - className: className((0, _enums.PresenterElement).panel, presenter) - }, (0, _tsxCreateElement.createElement)("div", { - className: className((0, _enums.PresenterElement).vegaControls, presenter) - }), (0, _tsxCreateElement.createElement)("div", { - className: className((0, _enums.PresenterElement).legend, presenter) - }))); - (0, _tsxCreateElement.mount)(rootDiv, presenter.el); -} -function className(type, presenter) { - return `${presenter.style.cssPrefix}${(0, _enums.PresenterElement)[type]}`; + case 0u: { + return hitSphere(id, ray, tMin, tMax, hitRecord); + } + case 1u: { + return hitBox(id, ray, invDir, tMin, tMax, hitRecord); + } + case 2u: { + return hitCylinder(id, ray, tMin, tMax, hitRecord); + } + case 3u: { + return hitHexPrism(id, ray, tMin, tMax, hitRecord); + } + case 4u: { + return hitRotatedBox(id, ray, tMin, tMax, hitRecord); + } + case 5u: { + return hitXyRect(id, ray, tMin, tMax, hitRecord); + } + case 6u: { + return hitXzRect(id, ray, tMin, tMax, hitRecord); + } + // case 7u: { + // return hitYzRect(hittable, ray, tMin, tMax, hitRecord); + // } + case 8u: { + return hitRotatedXyRect(id, ray, tMin, tMax, hitRecord); + } + case 9u: { + return hitFontXyRect(id, ray, tMin, tMax, hitRecord); + } + case 10u: { + return hitRotatedFontXyRect(id, ray, tMin, tMax, hitRecord); + } + case 11u: { + return hitBoxSdf(id, ray, tMin, tMax, hitRecord); + } + case 12u: { + return hitCylinderSdf(id, ray, tMin, tMax, hitRecord); + } + case 13u: { + return hitHexPrismSdf(id, ray, tMin, tMax, hitRecord); + } + case 14u: { + return hitConstantMedium(id, ray, invDir, tMin, tMax, hitRecord, seed); + } + case 15u: { + return hitSdfXyRect(id, ray, tMin, tMax, hitRecord, seed); + } + case 16u: { + return hitRotatedSdfXyRect(id, ray, tMin, tMax, hitRecord, seed); + } + case 17u: { + return hitRotatedBoxSdf(id, ray, tMin, tMax, hitRecord); + } + case 18u: { + return hitXyDisk(id, ray, tMin, tMax, hitRecord); + } + case 19u: { + return hitRotatedXyDisk(id, ray, tMin, tMax, hitRecord); + } + case 20u: { + return hitRingSdf(id, ray, tMin, tMax, hitRecord); + } + case 21u: { + return hitRotatedRingSdf(id, ray, tMin, tMax, hitRecord); + } + } } -},{"tsx-create-element":"c7YxA","./defaults":"4ObFg","./enums":"cMvaW","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ji0oV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ parcelHelpers.export(exports, "patchCubeArray", ()=>patchCubeArray); -function patchCubeArray(allocatedSize, empty, cubes) { - const patched = new Array(allocatedSize); - patched.fill(empty); - cubes.forEach((cube)=>patched[cube.ordinal] = cube); - return patched; +fn intersectBox(center: vec3<f32>, size: vec3<f32>, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32) -> bool { + let oc = ray.origin - center; + let n = invDir * oc; + let k = abs(invDir) * size; // Box size is from center to edge + let t0 = -n - k; + let t1 = -n + k; + let tNear = max(max(t0.x, t0.y), t0.z); + let tFar = min(min(t1.x, t1.y), t1.z); + if (tNear > tFar) { return false; } + return tNear < tMax && tFar > 0f; // Must return true when inside box, even if closestSoFar is closer than far box intersection } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"94bP8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "sceneToStage", ()=>sceneToStage); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _legend = require("./marks/legend"); -var _legendDefault = parcelHelpers.interopDefault(_legend); -var _image = require("./marks/image"); -var _imageDefault = parcelHelpers.interopDefault(_image); -var _rect = require("./marks/rect"); -var _rectDefault = parcelHelpers.interopDefault(_rect); -var _rule = require("./marks/rule"); -var _ruleDefault = parcelHelpers.interopDefault(_rule); -var _line = require("./marks/line"); -var _lineDefault = parcelHelpers.interopDefault(_line); -var _text = require("./marks/text"); -var _textDefault = parcelHelpers.interopDefault(_text); -var _base = require("./base"); -var _color = require("./color"); -var _defaults = require("./defaults"); -var _interfaces = require("./marks/interfaces"); -function getAxisGroupType(item, options) { - const axisItem = item; - const axisMark = axisItem === null || axisItem === void 0 ? void 0 : axisItem.mark; - if ((axisMark === null || axisMark === void 0 ? void 0 : axisMark.zindex) === options.zAxisZindex && options.zAxisZindex !== undefined) return (0, _interfaces.GroupType).zAxis; - switch(axisItem.orient){ - case "bottom": - case "top": - return (0, _interfaces.GroupType).xAxis; - case "left": - case "right": - return (0, _interfaces.GroupType).yAxis; - } -} -function convertGroupRole(item, options) { - if (item.mark.role === "legend") return (0, _interfaces.GroupType).legend; - if (item.mark.role === "axis") { - const groupType = getAxisGroupType(item, options); - if (groupType !== undefined) return groupType; +fn hitConstantMedium(id: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { + let constantMedium = &hittableBuffer.hittables[id]; + let boundaryTypeId = u32((*constantMedium).boundaryTypeId); + var tempHitRecord1: HitRecord; + if (!hitConstantMediumBoundary(id, boundaryTypeId, ray, invDir, -100f, 100f, &tempHitRecord1)) { return false; } + var tempHitRecord2: HitRecord; + // When raymarching narrow grazing angles, adding SHADOW_OFFSET is < epsilon from surface, so hit function returns tN not tF, hence distanceInsideBoundary is incorrect + // Add larger distance to t + if (!hitConstantMediumBoundary(id, boundaryTypeId, ray, invDir, tempHitRecord1.t + 0.001f, 100f, &tempHitRecord2)) { return false; } + if (tempHitRecord1.t < tMin) { tempHitRecord1.t = tMin; } + if (tempHitRecord2.t > tMax) { tempHitRecord2.t = tMax; } + if (tempHitRecord1.t >= tempHitRecord2.t) { + return false; } + tempHitRecord1.t = max(tempHitRecord1.t, 0f); + let distanceInsideBoundary = tempHitRecord2.t - tempHitRecord1.t; + let negativeInverseDensity = -1f / materialBuffer.materials[u32((*constantMedium).materialId)].density; + let hitDistance = negativeInverseDensity * log(random(seed)); + if (hitDistance > distanceInsideBoundary) { return false; } + let t = tempHitRecord1.t + hitDistance; + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + return true; } -const group = (options, stage, scene, x, y, groupType)=>{ - (0, _base.base).vega.sceneVisit(scene, function(g) { - const gx = g.x || 0, gy = g.y || 0; - if (g.context && g.context.background && !stage.backgroundColor) stage.backgroundColor = (0, _color.colorFromString)(g.context.background); - if (g.stroke) { - const facetRect = { - datum: g.datum, - lines: (0, _rule.box)(gx + x, gy + y, g.height, g.width, g.stroke, (0, _defaults.groupStrokeWidth)) - }; - stage.facets.push(facetRect); + +fn hitConstantMediumBoundary(id: u32, boundaryTypeId: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + switch boundaryTypeId { + default: { + return false; + } + case 0u: { + return hitSphere(id, ray, tMin, tMax, hitRecord); + } + case 1u: { + return hitBox(id, ray, invDir, tMin, tMax, hitRecord); + } + case 2u: { + return hitCylinder(id, ray, tMin, tMax, hitRecord); + } + case 3u: { + return hitHexPrism(id, ray, tMin, tMax, hitRecord); + } + case 4u: { + return hitRotatedBox(id, ray, tMin, tMax, hitRecord); + } + case 11u: { + return hitBoxSdf(id, ray, tMin, tMax, hitRecord); + } + case 12u: { + return hitCylinderSdf(id, ray, tMin, tMax, hitRecord); + } + case 13u: { + return hitHexPrismSdf(id, ray, tMin, tMax, hitRecord); + } + case 17u: { + return hitRotatedBoxSdf(id, ray, tMin, tMax, hitRecord); + } + case 20u: { + return hitRingSdf(id, ray, tMin, tMax, hitRecord); + } + case 21u: { + return hitRotatedRingSdf(id, ray, tMin, tMax, hitRecord); } - groupType = convertGroupRole(g, options) || groupType; - setCurrentAxis(options, stage, groupType); - // draw group contents - (0, _base.base).vega.sceneVisit(g, function(item) { - mainStager(options, stage, item, gx + x, gy + y, groupType); - }); - }); -}; -function setCurrentAxis(options, stage, groupType) { - let axisRole; - switch(groupType){ - case (0, _interfaces.GroupType).xAxis: - axisRole = "x"; - break; - case (0, _interfaces.GroupType).yAxis: - axisRole = "y"; - break; - case (0, _interfaces.GroupType).zAxis: - axisRole = "z"; - break; - default: - return; } - options.currAxis = { - axisRole, - domain: null, - tickText: [], - ticks: [] - }; - stage.axes[axisRole].push(options.currAxis); } -const markStagers = { - group, - legend: (0, _legendDefault.default), - image: (0, _imageDefault.default), - rect: (0, _rectDefault.default), - rule: (0, _ruleDefault.default), - line: (0, _lineDefault.default), - text: (0, _textDefault.default) -}; -const mainStager = (options, stage, scene, x, y, groupType)=>{ - if (scene.marktype !== "group" && groupType === (0, _interfaces.GroupType).legend) (0, _legendDefault.default)(options, stage, scene, x, y, groupType); - else { - const markStager = markStagers[scene.marktype]; - if (markStager) markStager(options, stage, scene, x, y, groupType); + +fn hitSphere(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let sphere = &hittableBuffer.hittables[id]; + let radius = (*sphere).size0.x; + let time = min(max((ray.time - (*sphere).time0) / ((*sphere).time1 - (*sphere).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*sphere).center0 + time * ((*sphere).center1 - (*sphere).center0); + let oc = ray.origin - center; + let b = dot(oc, ray.direction); + let c = dot(oc, oc) - radius * radius; + var h = b * b - c; + if (h < 0f) { return false; } + h = sqrt(h); + + // Find the nearest root in range + var root = -b - h; + if (root < tMin || root > tMax) { + root = -b + h; + if (root < tMin || root > tMax) { return false; } } -}; -function sceneToStage(options, stage, scene) { - mainStager(options, stage, scene, 0, 0, null); - sortAxis(stage.axes.x, 0); - sortAxis(stage.axes.y, 1); - sortAxis(stage.axes.z, 1); + + // (*hitRecord).t = root; + // (*hitRecord).position = rayAt(ray, root); + // let outwardNormal = ((*hitRecord).position - center) / radius; + // setFaceNormal(ray, outwardNormal, hitRecord); + + // Reduce precision error in t by ensuring hit position is on sphere surface + let outwardNormal = normalize(ray.origin + ray.direction * root - center); + setFaceNormal(ray, outwardNormal, hitRecord); + (*hitRecord).position = center + outwardNormal * radius; // Use outward normal with internal reflection + (*hitRecord).t = root; // I should also re-calculate t, but this would involve another normalization. t is only used to check closest hit, so only important with overlapping geometry + + // UV + let phi = atan2(outwardNormal.x, outwardNormal.z); // [-pi,pi] + let theta = asin(outwardNormal.y); // [-pi/2, pi/2] + (*hitRecord).uv = vec2<f32>(phi / TWO_PI + 0.5f, theta / PI + 0.5f); // [0,1] + return true; } -function sortAxis(axes, dim) { - axes.forEach((axis)=>{ - if (axis.domain) orderDomain(axis.domain, dim); - axis.ticks.sort((a, b)=>a.sourcePosition[dim] - b.sourcePosition[dim]); - axis.tickText.sort((a, b)=>a.position[dim] - b.position[dim]); - }); + +fn hitBox(id: u32, ray: Ray, invDir: vec3<f32>, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let box = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*box).time0) / ((*box).time1 - (*box).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*box).center0 + time * ((*box).center1 - (*box).center0); + let size = (*box).size0 + time * ((*box).size1 - (*box).size0); + let oc = ray.origin - center; + let n = invDir * oc; + let k = abs(invDir) * size; // Box size is from center to edge + let t1 = -n - k; + let t2 = -n + k; + let tNear = max(max(t1.x, t1.y), t1.z); + let tFar = min(min(t2.x, t2.y), t2.z); + // if (tFar <= tNear) { return false; } + if (tNear > tFar || tFar < 0f) { return false; } + + // Find nearest root in range + var outwardNormal: vec3<f32>; + var root = tNear; + if (root < tMin || root > tMax) { + root = tFar; + if (root < tMin || root > tMax) { return false; } + outwardNormal = sign(ray.direction) * step(t2.xyz, t2.yzx) * step(t2.xyz, t2.zxy); + } + else { + outwardNormal = -sign(ray.direction) * step(t1.yzx, t1.xyz) * step(t1.zxy, t1.xyz); + } + + (*hitRecord).t = root; + (*hitRecord).position = rayAt(ray, root); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } -function orderDomain(domain, dim) { - if (domain.sourcePosition[dim] > domain.targetPosition[dim]) { - const temp = domain.targetPosition; - domain.targetPosition = domain.sourcePosition; - domain.sourcePosition = temp; + +fn hitRotatedBox(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let rotatedBox = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*rotatedBox).time0) / ((*rotatedBox).time1 - (*rotatedBox).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedBox).center0 + time * ((*rotatedBox).center1 - (*rotatedBox).center0); + let rotation = slerpQuat((*rotatedBox).rotation0, (*rotatedBox).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let rotatedInvDir = vec3<f32>(1f, 1f, 1f) / rotatedRay.direction; + let hit = hitBox(id, rotatedRay, rotatedInvDir, tMin, tMax, hitRecord); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); + return true; } + return false; } -},{"./marks/legend":"dqeck","./marks/image":"Sn0XV","./marks/rect":"fM7Wc","./marks/rule":"eMal3","./marks/line":"3kZhd","./marks/text":"b176N","./base":"77OTl","./color":"aVVvT","./defaults":"4ObFg","./marks/interfaces":"bAHHl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dqeck":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -const legendMap = { - "legend-title": function(legend, textItem) { - legend.title = textItem.text; - }, - "legend-symbol": function(legend, symbol) { - const { bounds , fill , shape } = symbol; - //this object is safe for serialization - const legendRowSymbol = { - bounds, - fill, - shape - }; - const i = symbol.datum.index; - legend.rows[i] = legend.rows[i] || {}; - legend.rows[i].symbol = legendRowSymbol; - }, - "legend-label": function(legend, label) { - const i = label.datum.index; - legend.rows[i] = legend.rows[i] || {}; - const row = legend.rows[i]; - row.label = label.text; - row.value = label.datum.value; +fn hitXyDisk(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let xyDisk = &hittableBuffer.hittables[id]; + let oc = ray.origin - (*xyDisk).center0; + + // Distance to plane, t + let t = -oc.z / ray.direction.z; + + // If direction == 0, t = +/- infinity, which always returns false + if (t < tMin || t > tMax) { return false; } + + // Intersection point in model space + let p = oc + t * ray.direction; + + // Bounds + let radius = (*xyDisk).size0.x; + if (dot(p, p) > radius * radius) { return false; } // dot(p, p) is squared distance from disk center to intersection point + + // Texture coords + var uv = vec2<f32>(0.5 * p.xy / radius + vec2<f32>(0.5f, 0.5f)); + let texCoord0 = (*xyDisk).texCoord0; + let texCoord1 = (*xyDisk).texCoord1; + uv = texCoord0 + uv * (texCoord1 - texCoord0); + + (*hitRecord).uv = uv; + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + let outwardNormal = vec3<f32>(0f, 0f, 1f); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; +} + +fn hitRotatedXyDisk(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let rotatedXyDisk = &hittableBuffer.hittables[id]; + // let center = (*rotatedXyDisk).center0; + let time = min(max((ray.time - (*rotatedXyDisk).time0) / ((*rotatedXyDisk).time1 - (*rotatedXyDisk).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedXyDisk).center0 + time * ((*rotatedXyDisk).center1 - (*rotatedXyDisk).center0); + let rotation = slerpQuat((*rotatedXyDisk).rotation0, (*rotatedXyDisk).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let hit = hitXyDisk(id, rotatedRay, tMin, tMax, hitRecord); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); + return true; } -}; -const markStager = (options, stage, scene, x, y, groupType)=>{ - (0, _base.base).vega.sceneVisit(scene, function(item) { - const fn = legendMap[item.mark.role]; - if (fn) fn(stage.legend, item); - }); -}; -exports.default = markStager; + return false; +} -},{"../base":"77OTl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"Sn0XV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -const markStager = (options, stage, scene, x, y, groupType)=>{ - (0, _base.base).vega.sceneVisit(scene, function(item) { - const { bounds , height , url , width } = item; - let { x1 , x2 , y1 , y2 } = bounds; - x1 += x; - x2 += x; - y1 += y; - y2 += y; - if (!stage.backgroundImages) stage.backgroundImages = []; - stage.backgroundImages.push({ - bounds: { - x1, - x2, - y1, - y2 - }, - height, - url, - width - }); - }); -}; -exports.default = markStager; +fn hitXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let xyRect = &hittableBuffer.hittables[id]; + let oc = ray.origin - (*xyRect).center0; -},{"../base":"77OTl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fM7Wc":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _color = require("../color"); -var _defaults = require("../defaults"); -const markStager = (options, stage, scene, x, y, groupType)=>{ - (0, _base.base).vega.sceneVisit(scene, function(item) { - const noZ = item.z === undefined; - const z = noZ ? 0 : (item.z || 0) + (0, _defaults.minZ); - const depth = (noZ ? 0 : item.depth || 0) + (0, _defaults.min3dDepth); - //change direction of y from SVG to GL - const ty = -1; - const ordinal = options.assignCubeOrdinal(item.datum); - if (ordinal > options.maxOrdinal) options.maxOrdinal = ordinal; - if (ordinal === undefined) ; - else { - const cube = { - ordinal, - size: [ - item.width, - item.height, - depth - ], - position: [ - x + (+item.x || 0), - ty * (y + (+item.y || 0)) - +item.height, - z - ], - color: (0, _color.colorFromString)(item.fill) || options.defaultCubeColor || [ - 128, - 128, - 128, - 128 - ] - }; - cube.color[3] = item.opacity === undefined ? 255 : 255 * item.opacity; - stage.cubeData.push(cube); - } - }); -}; -exports.default = markStager; + // Distance to plane, t + let t = -oc.z / ray.direction.z; -},{"../base":"77OTl","../color":"aVVvT","../defaults":"4ObFg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eMal3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "box", ()=>box); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _color = require("../color"); -var _defaults = require("../defaults"); -const markStager = (options, stage, scene, x, y, groupType)=>{ - (0, _base.base).vega.sceneVisit(scene, function(item) { - const x1 = item.x || 0; - const y1 = item.y || 0; - const x2 = item.x2 != null ? item.x2 : x1; - const y2 = item.y2 != null ? item.y2 : y1; - const lineItem = styledLine(x1 + x, y1 + y, x2 + x, y2 + y, item.stroke, item.strokeWidth); - const { currAxis } = options; - if (options.modifyAxis) options.modifyAxis(item, lineItem, stage, currAxis); - if (item.mark.role === "axis-tick") currAxis.ticks.push(lineItem); - else if (item.mark.role === "axis-domain") currAxis.domain = lineItem; - else stage.gridLines.push(lineItem); - }); -}; -function styledLine(x1, y1, x2, y2, stroke, strokeWidth) { - const line = { - sourcePosition: [ - x1, - -y1, - (0, _defaults.lineZ) - ], - targetPosition: [ - x2, - -y2, - (0, _defaults.lineZ) - ], - color: (0, _color.colorFromString)(stroke), - strokeWidth: strokeWidth - }; - return line; + // If direction == 0, t = +/- infinity, which always returns false + if (t < tMin || t > tMax) { return false; } + + // Intersection point in model space + let p = oc + t * ray.direction; + + // Bounds + let size = (*xyRect).size0; + if (abs(p.x) > size.x || abs(p.y) > size.y) { return false; } + + // Texture coords + var uv = vec2<f32>(0.5 * p.xy / size.xy + vec2<f32>(0.5f, 0.5f)); + let texCoord0 = (*xyRect).texCoord0; + let texCoord1 = (*xyRect).texCoord1; + uv = texCoord0 + uv * (texCoord1 - texCoord0); + + (*hitRecord).uv = uv; + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + let outwardNormal = vec3<f32>(0f, 0f, 1f); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } -function box(gx, gy, height, width, stroke, strokeWidth, diagonals = false) { - const lines = [ - styledLine(gx, gy, gx + width, gy, stroke, strokeWidth), - styledLine(gx + width, gy, gx + width, gy + height, stroke, strokeWidth), - styledLine(gx + width, gy + height, gx, gy + height, stroke, strokeWidth), - styledLine(gx, gy + height, gx, gy, stroke, strokeWidth), - ]; - if (diagonals) { - lines.push(styledLine(gx, gy, gx + width, gy + height, stroke, strokeWidth)); - lines.push(styledLine(gx, gy + height, gx + width, gy, stroke, strokeWidth)); + +fn hitRotatedXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let rotatedXyRect = &hittableBuffer.hittables[id]; + // let center = (*rotatedXyRect).center0; + let time = min(max((ray.time - (*rotatedXyRect).time0) / ((*rotatedXyRect).time1 - (*rotatedXyRect).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedXyRect).center0 + time * ((*rotatedXyRect).center1 - (*rotatedXyRect).center0); + let rotation = slerpQuat((*rotatedXyRect).rotation0, (*rotatedXyRect).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let hit = hitXyRect(id, rotatedRay, tMin, tMax, hitRecord); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); + return true; } - return lines; + return false; } -exports.default = markStager; -},{"../base":"77OTl","../color":"aVVvT","../defaults":"4ObFg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3kZhd":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _color = require("../color"); -//change direction of y from SVG to GL -const ty = -1; -const markStager = (options, stage, scene, x, y, groupType)=>{ - const g = Object.assign({ - opacity: 1, - strokeOpacity: 1, - strokeWidth: 1 - }, scene.items[0]); - const path = { - strokeWidth: g.strokeWidth, - strokeColor: (0, _color.colorFromString)(g.stroke), - positions: scene.items.map((it)=>[ - it.x, - ty * it.y, - it.z || 0, - ]) - }; - path.strokeColor[3] *= g.strokeOpacity; - path.strokeColor[3] *= g.opacity; - stage.pathData.push(path); -}; -exports.default = markStager; +fn hitXzRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let xzRect = &hittableBuffer.hittables[id]; + let oc = ray.origin - (*xzRect).center0; -},{"../color":"aVVvT","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"b176N":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ // import { AlignmentBaseline, TextAnchor } from '@deck.gl/layers/text-layer/text-layer'; -var _base = require("../base"); -var _color = require("../color"); -const markStager = (options, stage, scene, x, y, groupType)=>{ - //change direction of y from SVG to GL - const ty = -1; - (0, _base.base).vega.sceneVisit(scene, function(item) { - if (!item.text) return; - const size = item.fontSize; - //const alignmentBaseline = convertBaseline(item.baseline); - //const yOffset = alignmentBaseline === 'top' ? item.fontSize / 2 : 0; //fixup to get tick text correct - const yOffset = 0; - const textItem = { - color: (0, _color.colorFromString)(item.fill), - text: item.limit === undefined ? item.text : (0, _base.base).vega.truncate(item.text, item.limit, "right", item.ellipsis || "..."), - position: [ - x + (item.x || 0), - ty * (y + (item.y || 0) + yOffset), - 0 - ], - size, - angle: convertAngle(item.angle), - //textAnchor: convertAlignment(item.align), - //alignmentBaseline, - metaData: item.metaData - }; - const { currAxis } = options; - if (options.modifyAxis) options.modifyAxis(item, textItem, stage, currAxis); - if (item.mark.role === "axis-label") { - const tickText = textItem; - tickText.value = item.datum.value; - currAxis.tickText.push(tickText); - } else if (item.mark.role === "axis-title") currAxis.title = textItem; - else stage.textData.push(textItem); - }); -}; -function convertAngle(vegaTextAngle) { - if (vegaTextAngle && !isNaN(vegaTextAngle)) return 360 - vegaTextAngle; - return 0; + // Distance to plane, t + let t = -oc.y / ray.direction.y; + + // If direction == 0, t = +/- infinity, which always returns false + if (t < tMin || t > tMax) { return false; } + + // Intersection point in model space + let p = oc + t * ray.direction; + + // Bounds + let size = (*xzRect).size0; + if (abs(p.x) > size.x || abs(p.z) > size.z) { return false; } + + // Texture coords + var uv = vec2<f32>(0.5 * p.xz / size.xz + vec2<f32>(0.5f, 0.5f)); + let texCoord0 = (*xzRect).texCoord0; + let texCoord1 = (*xzRect).texCoord1; + uv = texCoord0 + uv * (texCoord1 - texCoord0); + + (*hitRecord).uv = uv; + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + let outwardNormal = vec3<f32>(0f, 1f, 0f); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } -// function convertAlignment(textAlign: SceneTextAlign): TextAnchor { -// switch (textAlign) { -// case 'center': return 'middle'; -// case 'left': return 'start'; -// case 'right': return 'end'; -// } -// return 'start'; -// } -// function convertBaseline(baseline: SceneTextBaseline): AlignmentBaseline { -// switch (baseline) { -// case 'middle': return 'center'; -// } -// return baseline || 'bottom'; + +// fn hitYzRect(yzRect: Hittable, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { +// let oc = ray.origin - yzRect.center0; + +// // Distance to plane, t +// let t = -oc.x / ray.direction.x; + +// // If direction == 0, t = +/- infinity, which always returns false +// if (t < tMin || t > tMax) { return false; } + +// // Intersection point in model space +// let p = oc + t * ray.direction; + +// // Bounds +// if (abs(p.y) > yzRect.size0.y || abs(p.z) > yzRect.size0.z) { return false; } + +// // Texture coords +// var uv = vec2<f32>(0.5 * p.yz / yzRect.size0.yz + vec2<f32>(0.5f, 0.5f)); +// uv = yzRect.texCoord0 + uv * (yzRect.texCoord1 - yzRect.texCoord0); + +// (*hitRecord).uv = uv; +// (*hitRecord).t = t; +// (*hitRecord).position = rayAt(ray, t); +// let outwardNormal = vec3<f32>(1f, 0f, 0f); +// setFaceNormal(ray, outwardNormal, hitRecord); +// return true; // } -exports.default = markStager; -},{"../base":"77OTl","../color":"aVVvT","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bAHHl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "GroupType", ()=>GroupType); -var GroupType; -(function(GroupType) { - GroupType[GroupType["none"] = 0] = "none"; - GroupType[GroupType["legend"] = 1] = "legend"; - GroupType[GroupType["xAxis"] = 2] = "xAxis"; - GroupType[GroupType["yAxis"] = 3] = "yAxis"; - GroupType[GroupType["zAxis"] = 4] = "zAxis"; -})(GroupType || (GroupType = {})); +// TODO: Share hit function with XyRect +fn hitFontXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let xyRect = &hittableBuffer.hittables[id]; + + // let oc = ray.origin - (*xyRect).center0; + let time = min(max((ray.time - (*xyRect).time0) / ((*xyRect).time1 - (*xyRect).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*xyRect).center0 + time * ((*xyRect).center1 - (*xyRect).center0); + let oc = ray.origin - center; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hDIWp":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _render = require("./render"); -parcelHelpers.exportAll(_render, exports); -var _color = require("./color"); -parcelHelpers.exportAll(_color, exports); -var _init = require("./init"); -parcelHelpers.exportAll(_init, exports); + // Distance to plane, t + let t = -oc.z / ray.direction.z; -},{"./render":"g93O5","./color":"aWwlw","./init":"fdQK1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"g93O5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "morphChartsRender", ()=>morphChartsRender); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _axes = require("./axes"); -var _bounds = require("./bounds"); -var _cubes = require("./cubes"); -var _lines = require("./lines"); -var _text = require("./text"); -var _image = require("./image"); -var _defaults = require("../defaults"); -var _color = require("./color"); -var _defaults1 = require("./defaults"); -var _camera = require("./camera"); -function morphChartsRender(ref, prevStage, stage, height, width, preStage, colors, config) { - const { qCameraRotation2d , qCameraRotation3d , qModelRotation2d , qModelRotation3d , vCameraPosition } = (0, _defaults1.cameraDefaults); - const { core , cameraTransitioner , modelTransitioner , positionTransitioner } = ref; - let transistion2dOnly = false; - let cameraTo; - let holdCamera; - if (config.camera === "hold") holdCamera = true; - else cameraTo = config.camera; - if (prevStage && prevStage.view !== stage.view) { - modelTransitioner.shouldTransition = !holdCamera; - if (stage.view === "2d") { - modelTransitioner.qRotation.from = qModelRotation3d; - modelTransitioner.qRotation.to = qModelRotation2d; - cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation2d; - cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; - } else { - modelTransitioner.qRotation.from = qModelRotation2d; - modelTransitioner.qRotation.to = qModelRotation3d; - cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation3d; - cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; - } - } else { - modelTransitioner.shouldTransition = false; - if (stage.view === "2d") { - transistion2dOnly = true; - modelTransitioner.qRotation.to = qModelRotation2d; - cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation2d; - cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; - } else { - modelTransitioner.qRotation.to = qModelRotation3d; - cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation3d; - cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; - } - } - core.camera.getOrbit(cameraTransitioner.qRotation.from); - core.camera.getPosition(cameraTransitioner.vPosition.from); - if (!prevStage) { - core.setModelRotation(modelTransitioner.qRotation.to, false); - core.camera.setOrbit(cameraTransitioner.qRotation.to, false); - core.camera.setPosition(cameraTransitioner.vPosition.to, false); - } else if (!holdCamera) cameraTransitioner.begin(); - positionTransitioner.begin(); - if (modelTransitioner.shouldTransition) modelTransitioner.begin(); - const props = { - ref, - stage, - height, - width, - config - }; - const cubeLayer = (0, _cubes.createCubeLayer)(props); - const lineLayer = (0, _lines.createLineLayer)(props); - const textLayer = (0, _text.createTextLayer)(props); - const { backgroundImages } = stage; - let contentBounds = (0, _bounds.outerBounds)((0, _bounds.outerBounds)(cubeLayer === null || cubeLayer === void 0 ? void 0 : cubeLayer.bounds, lineLayer === null || lineLayer === void 0 ? void 0 : lineLayer.bounds), (0, _bounds.outerBounds)(textLayer === null || textLayer === void 0 ? void 0 : textLayer.bounds, null)); - backgroundImages === null || backgroundImages === void 0 || backgroundImages.forEach((backgroundImage)=>{ - contentBounds = (0, _bounds.outerBounds)(contentBounds, convertBounds(backgroundImage.bounds)); - }); - props.bounds = contentBounds; - core.renderer.previousAxes = core.renderer.currentAxes; - const axesLayer = (0, _axes.createAxesLayer)(props); - core.config.transitionStaggering = config.transitionDurations.stagger; - core.config.transitionDuration = config.transitionDurations.position; - let bounds; - if (axesLayer && axesLayer.bounds) bounds = axesLayer.bounds; - else bounds = contentBounds; - ref.setMorphChartsRendererOptions(config.renderer); - if (preStage) preStage(stage, cubeLayer); - //add images - core.renderer.images = []; - if (backgroundImages) { - const addImage = (imageBounds, imageData)=>{ - const imageWidth = imageBounds.maxBoundsX - imageBounds.minBoundsX; - const imageHeight = imageBounds.maxBoundsY - imageBounds.minBoundsY; - const position = [ - imageBounds.minBoundsX + imageWidth / 2, - imageBounds.minBoundsY + imageHeight / 2, - 0 - ]; - const imageQuad = (0, _image.createImageQuad)(core, imageData, contentBounds, position, imageWidth, imageHeight); - const imageVisual = core.renderer.createImageVisual(imageQuad); - core.renderer.images.push(imageVisual); - }; - const imageDataCache = {}; - backgroundImages.forEach((backgroundImage)=>{ - const imageBounds = convertBounds(backgroundImage.bounds); - const imageData = imageDataCache[backgroundImage.url]; - if (imageData) addImage(imageBounds, imageData); - else (0, _image.getImageData)(backgroundImage.url).then((imageData)=>{ - imageDataCache[backgroundImage.url] = imageData; - addImage(imageBounds, imageData); - }); - }); - } - //Now call update on each layout - layersWithSelection(cubeLayer, lineLayer, textLayer, config.layerSelection, bounds, ref.layerStagger); - (0, _camera.applyCameraCallbacks)(ref, config, stage.view, transistion2dOnly); - core.renderer.transitionTime = 0; // Set renderer transition time for this render pass to prevent rendering target buffer for single frame - (0, _color.colorConfig)(ref, colors); - return { - bounds, - getCubeLayer: ()=>cubeLayer, - update: (layerSelection)=>layersWithSelection(cubeLayer, lineLayer, textLayer, layerSelection, bounds, ref.layerStagger), - activate: (id)=>core.renderer.transitionBuffers[0].activeId = id, - moveCamera: (camera)=>{ - if (!(positionTransitioner.isTransitioning || modelTransitioner.isTransitioning)) { - core.camera.getOrbit(cameraTransitioner.qRotation.from); - core.camera.getPosition(cameraTransitioner.vPosition.from); - cameraTransitioner.move(camera.position, camera.rotation); - } - }, - setTransitionTimeAxesVisibility: ()=>{ - (0, _camera.setTransitionTimeAxesVisibility)(transistion2dOnly, core); - } - }; -} -function layersWithSelection(cubeLayer, lineLayer, textLayer, layerSelection, bounds, layerStagger) { - const layerItems = [ - { - layer: cubeLayer, - selection: layerSelection === null || layerSelection === void 0 ? void 0 : layerSelection.cubes, - stagger: layerStagger === null || layerStagger === void 0 ? void 0 : layerStagger.cubes - }, - { - layer: lineLayer, - selection: layerSelection === null || layerSelection === void 0 ? void 0 : layerSelection.lines, - stagger: layerStagger === null || layerStagger === void 0 ? void 0 : layerStagger.lines - }, - { - layer: textLayer, - selection: layerSelection === null || layerSelection === void 0 ? void 0 : layerSelection.texts, - stagger: layerStagger === null || layerStagger === void 0 ? void 0 : layerStagger.texts - }, - ]; - layerItems.forEach((layerItem)=>{ - var _a; - return (_a = layerItem.layer) === null || _a === void 0 ? void 0 : _a.update(bounds, layerItem.selection, layerItem.stagger); - }); -} -function convertBounds(bounds) { - if (!bounds) return; - return { - minBoundsX: bounds.x1, - maxBoundsX: bounds.x2, - minBoundsY: -bounds.y2, - maxBoundsY: -bounds.y1, - minBoundsZ: (0, _defaults.minZ), - maxBoundsZ: (0, _defaults.minZ) - }; + // If direction == 0, t = +/- infinity, which always returns false + if (t < tMin || t > tMax) { return false; } + + // Intersection point in model space + let p = oc + t * ray.direction; + + // Bounds + let size = (*xyRect).size0; + if (abs(p.x) > size.x || abs(p.y) > size.y) { return false; } + + // Texture coords + var uv = vec2<f32>(0.5 * p.xy / size.xy + vec2<f32>(0.5f, 0.5f)); + let texCoord0 = (*xyRect).texCoord0; + let texCoord1 = (*xyRect).texCoord1; + uv = texCoord0 + uv * (texCoord1 - texCoord0); + + // Sample sdf + let buffer = xyRect.sdfBuffer / 0xff; + let r = textureSampleLevel(fontTexture, linearSampler, uv, 0f).r; + if (r < buffer) { return false; } + + (*hitRecord).uv = uv; + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + let outwardNormal = vec3<f32>(0f, 0f, 1f); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } -},{"./axes":"bJN65","./bounds":"9GDgY","./cubes":"kEV6L","./lines":"336sD","./text":"hKMay","./image":"jF5e3","../defaults":"4ObFg","./color":"aWwlw","./defaults":"dUDEw","./camera":"69snG","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bJN65":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "createAxesLayer", ()=>createAxesLayer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -var _bounds = require("./bounds"); -const createAxesLayer = (props)=>{ - const { config , height , ref , stage } = props; - const { core } = ref; - const { renderer } = core; - const { x , y , z } = stage.axes; - const xyz = [ - ...x, - ...y, - ...z - ]; - renderer.currentAxes = []; - if (!xyz.length) { - renderer.axesVisibility = (0, _morphcharts.AxesVisibility).none; - return; - } - renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; - const correlation = new AxesCorrelation(stage, 3); - const { axesSets , labels } = correlation; - const grid = correlation.getGrid(); - if (grid.byColumn[0]) { - grid.byColumn[0].forEach((row)=>{ - row.axesSet.showFacetTitleY = true; - }); - grid.byRow[0].forEach((col)=>{ - col.axesSet.showFacetTitleX = true; - }); - } - if (grid.rows > 1) { - const { byRow } = grid; - byRow[0].forEach(({ axesSet }, col)=>{ - if (!axesSet.y) { - if (byRow[1][col].axesSet) { - //move x up - byRow[1][col].axesSet.x.tickText = axesSet.x.tickText; - byRow[1][col].axesSet.showFacetTitleX = axesSet.showFacetTitleX; - delete axesSet.x; - } - } - }); - } - let bounds; - const allAxesSetBounds = []; - let anyZ = false; - for(let i = 0; i < axesSets.length; i++)if (axesSets[i].z) { - anyZ = true; - break; - } - const is3d = stage.view === "3d" && anyZ; - axesSets.forEach((axesSet)=>{ - if (!axesSet.x && !axesSet.y) return; - const axesSetBounds = { - axesSet, - maxBoundsX: null, - maxBoundsY: null, - maxBoundsZ: null, - minBoundsX: null, - minBoundsY: null, - minBoundsZ: null - }; - if (is3d) { - const zBounds = getDomainBounds(1, axesSet.z); - axesSetBounds.minBoundsZ = -zBounds.maxBounds; - axesSetBounds.maxBoundsZ = -zBounds.minBounds; - } - const yBounds = getDomainBounds(1, axesSet.y); - axesSetBounds.minBoundsY = yBounds.minBounds; - axesSetBounds.maxBoundsY = yBounds.maxBounds; - axesSetBounds.y = yBounds.minBounds; - axesSetBounds.h = yBounds.maxBounds - yBounds.minBounds; - const xBounds = getDomainBounds(0, axesSet.x); - axesSetBounds.minBoundsX = xBounds.minBounds; - axesSetBounds.maxBoundsX = xBounds.maxBounds; - axesSetBounds.x = xBounds.minBounds; - axesSetBounds.w = xBounds.maxBounds - xBounds.minBounds; - allAxesSetBounds.push(axesSetBounds); - bounds = (0, _bounds.outerBounds)(bounds, axesSetBounds); - }); - const facetLabelX = labels.filter((label)=>label.axisRole === "x")[0]; - const facetLabelY = labels.filter((label)=>label.axisRole === "y")[0]; - core.inputManager.pickAxesTitleCallback = ({ axis , axes , manipulator })=>{ - const axesSet = axesSets[axes]; - let a; - let f; - switch(axis){ - case 0: - a = axesSet.x; - f = facetLabelX; - break; - case 1: - a = axesSet.y; - f = facetLabelY; - break; - case 2: - a = axesSet.z; - break; - } - if (a) config.onTextClick(manipulator.event, a.title || f.title); - }; - allAxesSetBounds.forEach((axesSetBounds)=>{ - const { axesSet } = axesSetBounds; - if (!axesSet.x && !axesSet.y) return; - const cartesian = new (is3d ? (0, _morphcharts.Axes).Cartesian3dAxes : (0, _morphcharts.Axes).Cartesian2dAxes)(core); - cartesian.isDivisionPickingEnabled = [ - false, - false, - false - ]; - cartesian.arePickDivisionsVisible = [ - false, - false, - false - ]; - cartesian.isLabelPickingEnabled = [ - false, - false, - false - ]; - cartesian.isTitlePickingEnabled = [ - false, - false, - false - ]; - cartesian.isGridPickingEnabled = false; - cartesian.isHeadingPickingEnabled = [ - false, - false, - false - ]; - createAxes(cartesian, 0, 0, axesSet.x, (0, _morphcharts.AxesTextOrientation).perpendicular, height, props, axesSet.showFacetTitleX && facetLabelX); - createAxes(cartesian, 1, 1, axesSet.y, (0, _morphcharts.AxesTextOrientation).perpendicular, height, props, axesSet.showFacetTitleY && facetLabelY); - if (is3d) createAxes(cartesian, 1, 2, axesSet.z, (0, _morphcharts.AxesTextOrientation).perpendicular, height, props); - configCartesianAxes(is3d, bounds, cartesian); - const { maxBoundsX , maxBoundsY , minBoundsX , minBoundsY , } = bounds; - const w = maxBoundsX - minBoundsX; - const h = maxBoundsY - minBoundsY; - cartesian.scalingX = axesSetBounds.w / w; - cartesian.scalingY = axesSetBounds.h / h; - cartesian.offsetX = (axesSetBounds.x - minBoundsX + axesSetBounds.w / 2) / w - 0.5; - cartesian.offsetY = (axesSetBounds.y - minBoundsY + axesSetBounds.h / 2) / h - 0.5; - const aspect = h / w; - if (aspect > 1) cartesian.offsetX /= aspect; - else cartesian.offsetY *= aspect; - const axes = is3d ? renderer.createCartesian3dAxesVisual(cartesian) : renderer.createCartesian2dAxesVisual(cartesian); - renderer.currentAxes.push(axes); - props.config.onAxesComplete && props.config.onAxesComplete(cartesian); - }); - return { - bounds - }; -}; -const nullDomain = { - sourcePosition: [ - 0, - 0, - 0 - ], - targetPosition: [ - 0, - 0, - 0 - ] -}; -class AxesCorrelation { - constructor(stage, dimensions){ - this.dimensions = dimensions; - const { x , y , z } = stage.axes; - this.axesSets = []; - this.labels = []; - [ - x, - y, - z - ].forEach((axes)=>{ - axes.forEach((axis)=>{ - if (this.axesSets.length === 0) this.initialize(axis); - else this.correlate(axis); - }); - }); - } - getGrid() { - const mapCols = {}; - const mapRows = {}; - this.axesSets.forEach((axesSet)=>{ - var _a; - const domain = (_a = axesSet === null || axesSet === void 0 ? void 0 : axesSet.x) === null || _a === void 0 ? void 0 : _a.domain; - if (!domain) return; - const col = domain.sourcePosition[0].toString(); - const row = domain.sourcePosition[1].toString(); - if (!mapCols[col]) mapCols[col] = {}; - mapCols[col][row] = axesSet; - mapRows[row] = null; - }); - const colKeys = Object.keys(mapCols).sort((a, b)=>+a - +b); - const rowKeys = Object.keys(mapRows).sort((a, b)=>+a - +b); - return { - cols: colKeys.length, - rows: rowKeys.length, - byColumn: colKeys.map((colKey)=>rowKeys.map((rowKey)=>{ - return { - colKey, - rowKey, - axesSet: mapCols[colKey][rowKey] - }; - })), - byRow: rowKeys.map((rowKey)=>colKeys.map((colKey)=>{ - return { - colKey, - rowKey, - axesSet: mapCols[colKey][rowKey] - }; - })) - }; - } - initialize(axis) { - if (!axis.domain) { - this.labels.push(axis); - return; - } - const axesSet = {}; - axesSet[axis.axisRole] = axis; - this.axesSets.push(axesSet); - } - correlate(axis) { - if (!axis.domain) { - this.labels.push(axis); - return; - } - for(let i = 0; i < this.axesSets.length; i++){ - const axesSet = this.axesSets[i]; - for(const axisRole in axesSet){ - const test = axesSet[axisRole]; - if (this.matchDomains(axis.domain, test.domain)) { - //prefer the axes with titles - if (!axesSet[axis.axisRole] || !axesSet[axis.axisRole].tickText.length && axis.tickText.length) axesSet[axis.axisRole] = axis; - return; - } - } - } - this.initialize(axis); - } - matchDomains(a, b) { - if (this.matchPoint(a.sourcePosition, b.sourcePosition)) return true; - if (this.matchPoint(a.sourcePosition, b.targetPosition)) return true; - if (this.matchPoint(a.targetPosition, b.targetPosition)) return true; - if (this.matchPoint(a.targetPosition, b.sourcePosition)) return true; - return false; - } - matchPoint(a, b) { - for(let i = 0; i < this.dimensions; i++){ - if (a[i] !== b[i]) return false; - } +fn hitRotatedFontXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let rotatedXyRect = &hittableBuffer.hittables[id]; + // let center = (*rotatedXyRect).center0; + let time = min(max((ray.time - (*rotatedXyRect).time0) / ((*rotatedXyRect).time1 - (*rotatedXyRect).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedXyRect).center0 + time * ((*rotatedXyRect).center1 - (*rotatedXyRect).center0); + let rotation = slerpQuat((*rotatedXyRect).rotation0, (*rotatedXyRect).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let hit = hitFontXyRect(id, rotatedRay, tMin, tMax, hitRecord); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); return true; } + return false; } -function createAxes(cartesian, dim2d, dim3d, axis, orientation, height, props, facetLabel) { - const domain = (axis === null || axis === void 0 ? void 0 : axis.domain) || nullDomain; - const { tickPositions , tickText , textPos , textSize } = convertAxis(axis, domain, dim2d, height); - if (axis.axisRole === "z") { - tickPositions.forEach((t, i)=>tickPositions[i] = 1 - t); - textPos.forEach((t, i)=>textPos[i] = 1 - t); - tickText.reverse(); - tickPositions.reverse(); - textPos.reverse(); + +// TODO: Share hit function with FontXyRect, specifying texture +fn hitSdfXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { + let xyRect = &hittableBuffer.hittables[id]; + + // let oc = ray.origin - (*xyRect).center0; + let time = min(max((ray.time - (*xyRect).time0) / ((*xyRect).time1 - (*xyRect).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*xyRect).center0 + time * ((*xyRect).center1 - (*xyRect).center0); + let oc = ray.origin - center; + + // Distance to plane, t + let t = -oc.z / ray.direction.z; + + // If direction == 0, t = +/- infinity, which always returns false + if (t < tMin || t > tMax) { return false; } + + // Intersection point in model space + let p = oc + t * ray.direction; + + // Bounds + // let size = (*xyRect).size0; + let size = (*xyRect).size0 + time * ((*xyRect).size1 - (*xyRect).size0); + if (abs(p.x) > (*xyRect).size0.x || abs(p.y) > (*xyRect).size0.y) { return false; } + + // Zero-thickness transparency + // TODO: Pre-multiplied alpha + // if (random(seed) > 0.5f) { return false; } + + // Texture coords + var uv = vec2<f32>(0.5 * p.xy / size.xy + vec2<f32>(0.5f, 0.5f)); + let texCoord0 = (*xyRect).texCoord0; + let texCoord1 = (*xyRect).texCoord1; + uv = texCoord0 + uv * (texCoord1 - texCoord0); + + // Sample sdf + let buffer = xyRect.sdfBuffer / 0xff; + // let r = textureSampleLevel(atlasTexture, linearSampler, uv, 0f).r; + var r: f32; + if ((*xyRect).texId == 0f) { + r = textureSampleLevel(atlasTexture, linearSampler, uv, 0f).r; } - cartesian.setTickPositions(dim3d, tickPositions); - cartesian.zero[dim3d] = 0; //TODO get any "zero" gridline position from vega - cartesian.setLabelPositions(dim3d, textPos); - cartesian.setLabels(dim3d, tickText); - cartesian.setLabelSizes(dim3d, textSize); - const title = (axis === null || axis === void 0 ? void 0 : axis.title) || (facetLabel === null || facetLabel === void 0 ? void 0 : facetLabel.title); - if (title === null || title === void 0 ? void 0 : title.text) { - cartesian.setTitle(dim3d, title.text); - cartesian.setTitleSize(dim3d, title.size / height); + else { + r = textureSampleLevel(fontTexture, linearSampler, uv, 0f).r; } - cartesian.setLabelOrientation(dim3d, orientation); - props.config.onAxisConfig && props.config.onAxisConfig(cartesian, dim3d, axis); - return { - tickText - }; + if (r < buffer) { return false; } + + // sdfBorder + let border = xyRect.sdfBorder / 0xff; + (*hitRecord).sdfBorder = r - buffer < border; + + (*hitRecord).uv = uv; + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + let outwardNormal = vec3<f32>(0f, 0f, 1f); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } -function configCartesianAxes(is3d, bounds, cartesian) { - if (is3d) cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).topBack] = false; - cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).backRight] = false; - cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).bottomRight] = false; - cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).frontRight] = false; - cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).topFront] = false; - cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).topRight] = false; - const { maxBoundsX , maxBoundsY , maxBoundsZ , minBoundsX , minBoundsY , minBoundsZ , } = bounds; - cartesian.minBoundsX = minBoundsX; - cartesian.maxBoundsX = maxBoundsX; - cartesian.minBoundsY = minBoundsY; - cartesian.maxBoundsY = maxBoundsY; - if (is3d) { - cartesian.minBoundsZ = minBoundsZ; - cartesian.maxBoundsZ = maxBoundsZ; + +fn hitRotatedSdfXyRect(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>, seed: ptr<function, u32>) -> bool { + let rotatedXyRect = &hittableBuffer.hittables[id]; + // let center = (*rotatedXyRect).center0; + let time = min(max((ray.time - (*rotatedXyRect).time0) / ((*rotatedXyRect).time1 - (*rotatedXyRect).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedXyRect).center0 + time * ((*rotatedXyRect).center1 - (*rotatedXyRect).center0); + let rotation = slerpQuat((*rotatedXyRect).rotation0, (*rotatedXyRect).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let hit = hitSdfXyRect(id, rotatedRay, tMin, tMax, hitRecord, seed); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); + return true; } + return false; } -function getDomainBounds(dim2d, axis) { - const domain = (axis === null || axis === void 0 ? void 0 : axis.domain) || nullDomain; - const minBounds = domain.sourcePosition[dim2d]; - const maxBounds = domain.targetPosition[dim2d]; - return { - maxBounds, - minBounds - }; + +fn rotateQuat(v: vec3<f32>, q: vec4<f32>) -> vec3<f32> { + return v + 2f * cross(q.xyz, cross(q.xyz, v) + q.w * v); } -function convertAxis(axis, domain, dim, height) { - const start = domain.sourcePosition[dim]; - const span = domain.targetPosition[dim] - start; - const tickPositions = axis ? axis.ticks.map((t)=>(t.sourcePosition[dim] - start) / span) : []; - const tickText = axis ? axis.tickText.map((t)=>t.text) : []; - const textPos = axis ? axis.tickText.map((t)=>(t.position[dim] - start) / span) : []; - const textSize = axis ? axis.tickText.map((t)=>t.size / height) : []; - if (tickPositions.length) { - if (tickPositions[0] !== 0) tickPositions[0] = 0; - if (tickPositions[tickPositions.length - 1] !== 1) tickPositions[tickPositions.length - 1] = 1; - } - return { - tickPositions, - tickText, - textPos, - textSize - }; + +fn slerpQuat(q0: vec4<f32>, q1: vec4<f32>, t: f32) -> vec4<f32> { + var cosom = dot(q0, q1); + var q2 = q1; + if (cosom < 0f) { + cosom = -cosom; + q2 = -q2; + } + var s0: f32; + var s1: f32; + if (1f - cosom > 0.000001f) { + // SLERP + let omega = acos(cosom); + let sinom = sin(omega); + s0 = sin((1f - t) * omega) / sinom; + s1 = sin(t * omega) / sinom; + } + else { + // Quaternions close enough for LERP + s0 = 1f - t; + s1 = t; + } + return s0 * q0 + s1 * q2; } -},{"morphcharts":"eKLJv","./bounds":"9GDgY","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9GDgY":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ parcelHelpers.export(exports, "outerBounds", ()=>outerBounds); -parcelHelpers.export(exports, "increment", ()=>increment); -function outerBounds(b1, b2) { - if (!b1 && !b2) return; - if (!b1) return b2; - if (!b2) return b1; - const minProps = [ - "minBoundsX", - "minBoundsY", - "minBoundsZ", - ]; - const maxProps = [ - "maxBoundsX", - "maxBoundsY", - "maxBoundsZ", - ]; - const result = {}; - minProps.forEach((p)=>result[p] = notNull(Math.min, b1[p], b2[p])); - maxProps.forEach((p)=>result[p] = notNull(Math.max, b1[p], b2[p])); - return result; +fn conjugate(q: vec4<f32>) -> vec4<f32> { + return vec4<f32>(-q.x, -q.y, -q.z, q.w); } -function notNull(fn, v1, v2) { - if (v1 == null && v2 == null) return null; - if (v1 == null) return v2; - if (v2 == null) return v1; - return fn(v1, v2); + +fn hitCylinder(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let cylinder = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*cylinder).time0) / ((*cylinder).time1 - (*cylinder).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*cylinder).center0 + time * ((*cylinder).center1 - (*cylinder).center0); + let size = (*cylinder).size0 + time * ((*cylinder).size1 - (*cylinder).size0); + let rotation = slerpQuat((*cylinder).rotation0, (*cylinder).rotation1, time); + let ra = size.x; // Radius + let ca = rotateQuat(vec3<f32>(0f, 1f, 0f), rotation); + let oc = ray.origin - center; + let card = dot(ca, ray.direction); + let caoc = dot(ca, oc); + let a = 1f - card * card; + let b = dot(oc, ray.direction) - caoc * card; + let c = dot(oc, oc) - caoc * caoc - ra * ra; + var h = b * b - a * c; + if (h < 0f) { return false; } + h = sqrt(h); + let br0 = (-b - h) / a; + let br1 = (-b + h) / a; + + // Body + let ch = size.y; // Half-height + let y0 = caoc + br0 * card; + let y1 = caoc + br1 * card; + let bt0 = select(10000000f, br0, abs(y0) < ch); + let bt1 = select(-10000000f, br1, abs(y1) < ch); + + // Caps + let sy0 = sign(y0); + let sy1 = sign(y1); + let cr0 = (sy0 * ch - caoc) / card; + let cr1 = (sy1 * ch - caoc) / card; + let ct0 = select(10000000f, cr0, abs(b + a * cr0) < h); + let ct1 = select(-10000000f, cr1, abs(b + a * cr1) < h); + + // Find the nearest root in range + let tN = min(bt0, ct0); + let tF = max(bt1, ct1); + var root = tN; + if (root < tMin || root > tMax) { + root = tF; + if (root < tMin || root > tMax) { return false; } + } + + // Normal + var outwardNormal: vec3<f32>; + if (root == bt0 || root == bt1) { + let y = select(y1, y0, root == bt0); + // outwardNormal = (oc + root * ray.direction - ca * y) / ra; + + // Reduce precision error in t by ensuring hit position is on cylinder surface + outwardNormal = normalize(oc + root * ray.direction - ca * y); + setFaceNormal(ray, outwardNormal, hitRecord); + (*hitRecord).position = center + ca * y + outwardNormal * ra; // Use outward normal with internal reflection + (*hitRecord).t = root; + } + else { + let sy = select(sy1, sy0, root == ct0); + outwardNormal = ca * sy; + + // TODO: Reduce precision error + setFaceNormal(ray, outwardNormal, hitRecord); + (*hitRecord).position = rayAt(ray, root); + (*hitRecord).t = root; + } + + // setFaceNormal(ray, outwardNormal, hitRecord); + // (*hitRecord).position = rayAt(ray, root); + // (*hitRecord).t = root; + return true; } -function increment(b, minBoundsX, minBoundsY, minBoundsZ, maxBoundsX, maxBoundsY, maxBoundsZ) { - return outerBounds(b, { - minBoundsX, - minBoundsY, - minBoundsZ, - maxBoundsX, - maxBoundsY, - maxBoundsZ - }); + +fn hitHexPrism(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let hexPrism = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*hexPrism).time0) / ((*hexPrism).time1 - (*hexPrism).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*hexPrism).center0 + time * ((*hexPrism).center1 - (*hexPrism).center0); + let oc = ray.origin - center; + let size = (*hexPrism).size0; + let ra = size.x; // Distance from center to edge + let he = size.y; // Half-height + let rd = ray.direction; + + // Normals + let n1 = vec3<f32>(1f, 0f, 0f); + let n2 = vec3<f32>(0.5f, 0f, ROOT_THREE_OVER_TWO); + let n3 = vec3<f32>(-0.5f, 0f, ROOT_THREE_OVER_TWO); + let n4 = vec3<f32>(0f, 1f, 0f); + + // Slabs intersections + var t1 = vec3<f32>((vec2<f32>(ra, -ra) - dot(oc, n1)) / dot(rd, n1), 1f); + var t2 = vec3<f32>((vec2<f32>(ra, -ra) - dot(oc, n2)) / dot(rd, n2), 1f); + var t3 = vec3<f32>((vec2<f32>(ra, -ra) - dot(oc, n3)) / dot(rd, n3), 1f); + var t4 = vec3<f32>((vec2<f32>(he, -he) - dot(oc, n4)) / dot(rd, n4), 1f); + + // Inetsection selection + if (t1.y < t1.x) { t1 = vec3<f32>(t1.yx, -1f); } + if (t2.y < t2.x) { t2 = vec3<f32>(t2.yx, -1f); } + if (t3.y < t3.x) { t3 = vec3<f32>(t3.yx, -1f); } + if (t4.y < t4.x) { t4 = vec3<f32>(t4.yx, -1f); } + + var tN = vec4<f32>(t1.x, t1.z * n1); + if (t2.x > tN.x) { tN = vec4<f32>(t2.x, t2.z * n2); } + if (t3.x > tN.x) { tN = vec4<f32>(t3.x, t3.z * n3); } + if (t4.x > tN.x) { tN = vec4<f32>(t4.x, t4.z * n4); } + + let tF = min(min(t1.y,t2.y),min(t3.y,t4.y)); + + if (tN.x > tF || tF < 0f) { return false; } + + // Find the nearest root in range + var outwardNormal: vec3<f32>; + var root = tN.x; + if (root < tMin || root > tMax) { + root = tF; + if (root < tMin || root > tMax) { return false; } + + // Normal + if (root == t1.y) { outwardNormal = -t1.z * n1; } + else if (root == t2.y) { outwardNormal = -t2.z * n2; } + else if (root == t3.y) { outwardNormal = -t3.z * n3; } + else if (root == t4.y) { outwardNormal = -t4.z * n4; } + } + else { + outwardNormal = tN.yzw; + } + + (*hitRecord).t = root; + (*hitRecord).position = rayAt(ray, root); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kEV6L":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "createCubeLayer", ()=>createCubeLayer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -var _bounds = require("./bounds"); -var _color = require("./color"); -const key = "cube"; -const createCubeLayer = (props)=>{ - const { ref , stage } = props; - const { core } = ref; - const scatter = new (0, _morphcharts.Layouts).Scatter(core); - const { ids , colors , positionsX , positionsY , positionsZ , sizesX , sizesY , sizesZ , bounds , maxColor , palette , } = convert(stage); - if (!ids.length) return; - const { renderer } = core; - let cubeTransitionBuffer = renderer.transitionBuffers.find((t)=>t.key === key); - if (!cubeTransitionBuffer) { - cubeTransitionBuffer = renderer.createTransitionBuffer(ids); - cubeTransitionBuffer.key = key; - renderer.transitionBuffers.push(cubeTransitionBuffer); - } else cubeTransitionBuffer.swap(); - scatter.layout(cubeTransitionBuffer.currentBuffer, ids, { - positionsX, - positionsY, - positionsZ - }); - const layer = { - positionsX, - positionsY, - positionsZ, - update: (newBounds, selected, stagger)=>{ - const { colors , maxColor , minColor , palette } = layer.unitColorMap; - // reference off of core.renderer to get the actual buffer - const currCubeTransitionBuffer = core.renderer.transitionBuffers.find((t)=>t.key === key); - currCubeTransitionBuffer.currentBuffer.unitType = (0, _morphcharts.UnitType).block; - currCubeTransitionBuffer.currentPalette.colors = palette; - let options = Object.assign({ - selected, - colors, - minColor, - maxColor, - sizesX, - sizesY, - sizesZ - }, newBounds); - if (stagger === null || stagger === void 0 ? void 0 : stagger.staggerOrders) { - const { maxStaggerOrder , minStaggerOrder , staggerOrders } = stagger; - options = Object.assign(Object.assign({}, options), { - maxStaggerOrder, - minStaggerOrder, - staggerOrders - }); - } - scatter.update(currCubeTransitionBuffer.currentBuffer, ids, options); - }, - bounds, - unitColorMap: { - colors, - ids, - minColor: 0, - maxColor, - palette - } - }; - return layer; -}; -function convert(stage) { - const { cubeData } = stage; - const { length } = cubeData; - const ids = []; - const colors = new Float64Array(length); - const positionsX = new Float64Array(length); - const positionsY = new Float64Array(length); - const positionsZ = new Float64Array(length); - const sizesX = new Float64Array(length); - const sizesY = new Float64Array(length); - const sizesZ = new Float64Array(length); - let bounds; - const colorMap = new (0, _color.ColorMap)(); - cubeData.forEach((cube, i)=>{ - ids.push(i); - if (cube.isEmpty) { - positionsX[i] = 0; - positionsY[i] = 0; - positionsZ[i] = 0; - sizesX[i] = 0; - sizesY[i] = 0; - sizesZ[i] = 0; - colors[i] = 0; - } else { - //ids.push(cube.ordinal); - positionsX[i] = cube.position[0] + cube.size[0] * 0.5; - positionsY[i] = cube.position[1] + cube.size[1] * 0.5; - positionsZ[i] = cube.position[2] + cube.size[2] * 0.5; - sizesX[i] = cube.size[0]; - sizesY[i] = cube.size[1]; - sizesZ[i] = cube.size[2]; - bounds = (0, _bounds.increment)(bounds, cube.position[0], cube.position[1], cube.position[2], cube.position[0] + cube.size[0], cube.position[1] + cube.size[1], cube.position[2] + cube.size[2]); - colors[i] = colorMap.registerColor(cube.color); - } - }); - const { palette , maxColor } = colorMap.getPalette(); - return { - ids: new Uint32Array(ids), - colors, - positionsX, - positionsY, - positionsZ, - sizesX, - sizesY, - sizesZ, - bounds, - maxColor, - palette - }; +fn mapBoxSdf(p: vec3<f32>, b: vec3<f32>, r: f32) -> f32 { + let q = abs(p) - b; + return length(max(q, vec3<f32>(0f, 0f, 0f))) + min(max(q.x, max(q.y, q.z)), 0f) - r; } -},{"morphcharts":"eKLJv","./bounds":"9GDgY","./color":"aWwlw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aWwlw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ColorMap", ()=>ColorMap); -parcelHelpers.export(exports, "colorConfig", ()=>colorConfig); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _color = require("../color"); -class ColorMap { - constructor(quant = 5){ - this.quant = quant; - this.colorMap = {}; - this.colorArray = []; +// Box frame +// fn mapBoxSdf(p: vec3<f32>, b: vec3<f32>, r: f32) -> f32 { +// let s = abs(p) - b; +// // let e = b.y / 3f; +// let e = 0.0002f; +// let q = abs(s + e) - e; +// return min(min( +// length(max(vec3<f32>(s.x, q.y, q.z), vec3<f32>(0f, 0f, 0f))) + min(max(s.x, max(q.y,q.z)), 0f), +// length(max(vec3<f32>(q.x, s.y, q.z), vec3<f32>(0f, 0f, 0f))) + min(max(q.x, max(s.y,q.z)), 0f)), +// length(max(vec3<f32>(q.x, q.y, s.z), vec3<f32>(0f, 0f, 0f))) + min(max(q.x, max(q.y,s.z)), 0f)); +// } + +fn hitBoxSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let boxSdf = &hittableBuffer.hittables[id]; + var t = tMin; + let r = (*boxSdf).rounding; + // let size = (*boxSdf).size0 - r; + let time = min(max((ray.time - (*boxSdf).time0) / ((*boxSdf).time1 - (*boxSdf).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*boxSdf).center0 + time * ((*boxSdf).center1 - (*boxSdf).center0); + // TODO: r0, r1 + let size = (*boxSdf).size0 + time * ((*boxSdf).size1 - (*boxSdf).size0) - r; + for (var i: u32 = 0u; i < 256u; i = i + 1u) { + let position = rayAt(ray, t); + let oc = position - center; + let distance = abs(mapBoxSdf(oc, size, r)); + t = t + distance; + if (t > tMax) { return false; } + if (distance < 0.000001f) { + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + + // Normal + let h = 0.000001f; // replace by an appropriate value + let k = vec2<f32>(1f, -1f); + let outwardNormal = normalize( + k.xyy * mapBoxSdf(oc + k.xyy * h, size, r) + + k.yyx * mapBoxSdf(oc + k.yyx * h, size, r) + + k.yxy * mapBoxSdf(oc + k.yxy * h, size, r) + + k.xxx * mapBoxSdf(oc + k.xxx * h, size, r)); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; + } } - getColorKey(rgbaColor) { - const color = rgbaColor.slice(0, 3).map((e)=>Math.floor(e / this.quant) * this.quant); - color[3] = rgbaColor[3]; //retain alpha - return JSON.stringify(color); + return false; +} + +fn hitRotatedBoxSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let rotatedBoxSdf = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*rotatedBoxSdf).time0) / ((*rotatedBoxSdf).time1 - (*rotatedBoxSdf).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedBoxSdf).center0 + time * ((*rotatedBoxSdf).center1 - (*rotatedBoxSdf).center0); + let rotation = slerpQuat((*rotatedBoxSdf).rotation0, (*rotatedBoxSdf).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let hit = hitBoxSdf(id, rotatedRay, tMin, tMax, hitRecord); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); + return true; } - registerColor(rgbaColor) { - const colorKey = this.getColorKey(rgbaColor); - if (!this.colorMap[colorKey]) { - this.colorMap[colorKey] = { - index: this.colorArray.length, - rgbaColor - }; - this.colorArray.push(rgbaColor); + return false; +} + +fn mapCylinderSdf(p: vec3<f32>, a: vec3<f32>, b: vec3<f32>, r0: f32, r1: f32) -> f32 { + let ba: vec3<f32> = b - a; + let pa: vec3<f32> = p - a; + let baba: f32 = dot(ba, ba); + let paba: f32 = dot(pa, ba); + let x: f32 = length(pa * baba - ba * paba) - r0 * baba; + let y: f32 = abs(paba - baba * 0.5f) - baba * 0.5f; + let x2: f32 = x * x; + let y2: f32 = y * y * baba; + // let d: f32 = (max(x, y) < 0f) ? -min(x2, y2) : (((x > 0f) ? x2 : 0f) + ((y > 0f) ? y2 : 0f)); + let d: f32 = select(select(0f, x2, x > 0f) + select(0f, y2, y > 0f), -min(x2, y2), max(x, y) < 0f); + return sign(d) * sqrt(abs(d)) / baba - r1; +} + +fn hitCylinderSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let cylinderSdf = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*cylinderSdf).time0) / ((*cylinderSdf).time1 - (*cylinderSdf).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*cylinderSdf).center0 + time * ((*cylinderSdf).center1 - (*cylinderSdf).center0); + let size = (*cylinderSdf).size0 + time * ((*cylinderSdf).size1 - (*cylinderSdf).size0); + let rotation = slerpQuat((*cylinderSdf).rotation0, (*cylinderSdf).rotation1, time); + var t = tMin; + let r1 = (*cylinderSdf).rounding; + let r0 = size.x - r1; + let h0 = size.y - r1; + let ca = rotateQuat(vec3<f32>(0f, 1f, 0f), rotation); + let pa = ca * h0; + let pb = -pa; + for (var i: u32 = 0u; i < 256u; i = i + 1u) { + let position = rayAt(ray, t); + let oc = position - center; + let distance = abs(mapCylinderSdf(oc, pa, pb, r0, r1)); + t = t + distance; + if (t > tMax) { return false; } + if (distance < 0.000001f) { + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + + // Normal + let h = 0.000001f; // replace by an appropriate value + let k = vec2<f32>(1f, -1f); + let outwardNormal = normalize( + k.xyy * mapCylinderSdf(oc + k.xyy * h, pa, pb, r0, r1) + + k.yyx * mapCylinderSdf(oc + k.yyx * h, pa, pb, r0, r1) + + k.yxy * mapCylinderSdf(oc + k.yxy * h, pa, pb, r0, r1) + + k.xxx * mapCylinderSdf(oc + k.xxx * h, pa, pb, r0, r1)); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; } - return this.colorMap[colorKey].index; } - getPalette() { - return { - palette: new Uint8Array(this.colorArray.flat()), - maxColor: this.colorArray.length - 1 - }; + return false; +} + +fn mapHexPrismSdf(p: vec3<f32>, hx: f32, hy: f32, r: f32) -> f32 { + let k = vec3<f32>(-0.8660254, 0.5, 0.57735); // (-sqrt(3)/2 or sin(60), 0.5, sqrt(3)/3 or tan(30)) + var p0 = abs(p.zxy); + let p1 = p0.xy - 2f * min(dot(k.xy, p0.xy), 0f) * k.xy; + let d = vec2<f32>(length(p1.xy - vec2(clamp(p1.x, -k.z * hx, k.z * hx), hx)) * sign(p1.y - hx), p0.z - hy); + return min(max(d.x, d.y), 0f) + length(max(d, vec2<f32>(0f, 0f))) - r; +} + +fn hitHexPrismSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let hexPrismSdf = &hittableBuffer.hittables[id]; + var t = tMin; + let r = (*hexPrismSdf).rounding; + let size = (*hexPrismSdf).size0; + let time = min(max((ray.time - (*hexPrismSdf).time0) / ((*hexPrismSdf).time1 - (*hexPrismSdf).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*hexPrismSdf).center0 + time * ((*hexPrismSdf).center1 - (*hexPrismSdf).center0); + let hx = size.x - r; + let hy = size.y - r; + for (var i: u32 = 0u; i < 256u; i = i + 1u) { + let position = rayAt(ray, t); + let oc = position - center; + let distance = abs(mapHexPrismSdf(oc, hx, hy, r)); + t = t + distance; + if (t > tMax) { return false; } + if (distance < 0.000001f) { + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + + // Normal + let h = 0.000001f; // Replace by an appropriate value + let k = vec2<f32>(1f, -1f); + let outwardNormal = normalize( + k.xyy * mapHexPrismSdf(oc + k.xyy * h, hx, hy, r) + + k.yyx * mapHexPrismSdf(oc + k.yyx * h, hx, hy, r) + + k.yxy * mapHexPrismSdf(oc + k.yxy * h, hx, hy, r) + + k.xxx * mapHexPrismSdf(oc + k.xxx * h, hx, hy, r)); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; + } } + return false; } -function convert(newColor) { - const c = (0, _color.colorFromString)(newColor).slice(0, 3); - return c.map((v)=>v / 255); + +fn mapRingSdf(p: vec3<f32>, n: vec2<f32>, r: f32, th: f32, h: f32, rounding: f32) -> f32 { + let px = abs(p.x); + // expand result of mat2x2(n.x,n.y,-n.y,n.x)*p; + // let p2 = vec2<f32>(n.x * px + n.y * p.y, -n.y * px + n.x * p.y); + // Column-major instead of row-major + let p2 = vec2<f32>(n.x * px - n.y * p.y, n.y * px + n.x * p.y); + let d = max(abs(length(p2) - r) - th * 0.5f, length(vec2<f32>(p2.x, max(0f, abs(r - p2.y) - th * 0.5f))) * sign(p2.x)); + + // Extrude + let w = vec2<f32>(d, abs(p.z) - h); + return min(max(w.x, w.y), 0f) + length(max(w, vec2<f32>(0f, 0f))) - rounding; } -function colorConfig(ref, colors) { - if (!colors) return; - const { config } = ref.core; - config.activeColor = convert(colors.activeItemColor); - config.backgroundColor = convert(colors.backgroundColor); - config.textColor = convert(colors.textColor); - config.textBorderColor = convert(colors.textBorderColor); - config.axesTextColor = convert(colors.axesTextLabelColor); - config.axesGridBackgroundColor = convert(colors.axesGridBackgroundColor); - config.axesGridHighlightColor = convert(colors.axesGridHighlightColor); - config.axesGridMinorColor = convert(colors.axesGridMinorColor); - config.axesGridMajorColor = convert(colors.axesGridMajorColor); - config.axesGridZeroColor = convert(colors.axesGridZeroColor); - //TODO fix this - hack to reset the background color - ref.core.renderer["_theme"] = null; + +fn hitRingSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let ringSdf = &hittableBuffer.hittables[id]; + var t = tMin; + let size = (*ringSdf).size0; + let center = (*ringSdf).center0; + let rounding = (*ringSdf).rounding; + let outerr = size.x; + let innerr = size.y; + // Reduce angle such that inner radius arc reduces by rounding + var angle = (*ringSdf).parameter1; + angle -= angle * rounding / innerr * PI * 2; + let cs = vec2<f32>(cos(angle), sin(angle)); + let r = (outerr + innerr) * 0.5f; + let th = (outerr - innerr) - rounding; + let e = size.z - rounding; + for (var i: u32 = 0u; i < 256u; i = i + 1u) { + let position = rayAt(ray, t); + let oc = position - center; + let distance = abs(mapRingSdf(oc, cs, r, th, e, rounding)); + t = t + distance; + if (t > tMax) { return false; } + if (distance < 0.000001f) { + (*hitRecord).t = t; + (*hitRecord).position = rayAt(ray, t); + + // Normal + let h = 0.00001f; // replace by an appropriate value + let k = vec2<f32>(1f, -1f); + let outwardNormal = normalize( + k.xyy * mapRingSdf(oc + k.xyy * h, cs, r, th, e, rounding) + + k.yyx * mapRingSdf(oc + k.yyx * h, cs, r, th, e, rounding) + + k.yxy * mapRingSdf(oc + k.yxy * h, cs, r, th, e, rounding) + + k.xxx * mapRingSdf(oc + k.xxx * h, cs, r, th, e, rounding)); + setFaceNormal(ray, outwardNormal, hitRecord); + return true; + } + } + return false; } -},{"../color":"aVVvT","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"336sD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "createLineLayer", ()=>createLineLayer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -var _bounds = require("./bounds"); -var _color = require("./color"); -const key = "line"; -const createLineLayer = (props)=>{ - const { height , ref , stage , width } = props; - const { core } = ref; - const lines = new (0, _morphcharts.Layouts).Line(core); - const { ids , fromIds , toIds , lineColors , lineSizes , bounds , positionsX , positionsY , positionsZ , lineMaxColor , palette , } = convert(stage, height, width); - if (!ids.length) return; - const { renderer } = core; - let lineTransitionBuffer = renderer.transitionBuffers.find((t)=>t.key === key); - if (!lineTransitionBuffer) { - lineTransitionBuffer = renderer.createTransitionBuffer(ids); - lineTransitionBuffer.key = key; - renderer.transitionBuffers.push(lineTransitionBuffer); - } else lineTransitionBuffer.swap(); - lines.layout(lineTransitionBuffer.currentBuffer, ids, fromIds, toIds, { - positionsX, - positionsY, - positionsZ, - lineSizes, - sizeScaling: 1 - }); - let options = { - lineColors, - lineMinColor: 0, - lineMaxColor - }; - // Unit type - lineTransitionBuffer.currentBuffer.unitType = (0, _morphcharts.UnitType).cylinder; - lineTransitionBuffer.currentPalette.colors = palette; - return { - update: (newBounds)=>{ - options = Object.assign(Object.assign({}, options), newBounds); - // reference off of core.renderer to get the actual buffer - const currLineTransitionBuffer = core.renderer.transitionBuffers.find((t)=>t.key === key); - lines.update(currLineTransitionBuffer.currentBuffer, ids, fromIds, toIds, options); - }, - bounds, - unitColorMap: { - ids, - colors: lineColors, - minColor: 0, - maxColor: lineMaxColor, - palette - } - }; -}; -function convert(stage, height, width) { - const { pathData } = stage; - const positions = []; - const lines = []; - const colorMap = new (0, _color.ColorMap)(); - pathData.forEach((path)=>{ - const color = colorMap.registerColor(path.strokeColor); - let from = positions.length; - positions.push(path.positions[0]); - for(let i = 1; i < path.positions.length; i++){ - const to = positions.length; - positions.push(path.positions[i]); - lines.push({ - id: lines.length, - from, - to, - color, - size: path.strokeWidth - }); - from = to; - } - }); - const ids = new Uint32Array(lines.length); - const fromIds = new Uint32Array(lines.length); - const toIds = new Uint32Array(lines.length); - const lineColors = new Float64Array(lines.length); - const lineSizes = new Float64Array(lines.length); - lines.forEach((line, i)=>{ - ids[i] = i; - fromIds[i] = line.from; - toIds[i] = line.to; - lineColors[i] = line.color; - lineSizes[i] = line.size; - }); - const positionsX = new Float64Array(positions.length); - const positionsY = new Float64Array(positions.length); - const positionsZ = new Float64Array(positions.length); - let bounds; - positions.forEach((p, i)=>{ - positionsX[i] = p[0]; - positionsY[i] = p[1] + height; - positionsZ[i] = p[2]; - bounds = (0, _bounds.increment)(bounds, positionsX[i], positionsY[i], positionsZ[i], positionsX[i], positionsY[i], positionsZ[i]); - }); - const { palette , maxColor: lineMaxColor } = colorMap.getPalette(); - return { - ids, - fromIds, - toIds, - lineColors, - lineSizes, - bounds, - positionsX, - positionsY, - positionsZ, - lineMaxColor, - palette - }; -} - -},{"morphcharts":"eKLJv","./bounds":"9GDgY","./color":"aWwlw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hKMay":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "createTextLayer", ()=>createTextLayer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -var _bounds = require("./bounds"); -var _color = require("./color"); -const createTextLayer = (props)=>{ - const { ref , stage } = props; - const { core } = ref; - const { positionsX , positionsY , positionsZ , sizes , bounds , maxGlyphs , text , } = convert(stage); - if (text.length === 0) { - core.renderer.labelSets = []; - return; +fn hitRotatedRingSdf(id: u32, ray: Ray, tMin: f32, tMax: f32, hitRecord: ptr<function, HitRecord>) -> bool { + let rotatedRingSdf = &hittableBuffer.hittables[id]; + let time = min(max((ray.time - (*rotatedRingSdf).time0) / ((*rotatedRingSdf).time1 - (*rotatedRingSdf).time0), 0f), 1f); // Normalize time to [0,1] + let center = (*rotatedRingSdf).center0 + time * ((*rotatedRingSdf).center1 - (*rotatedRingSdf).center0); + let rotation = slerpQuat((*rotatedRingSdf).rotation0, (*rotatedRingSdf).rotation1, time); + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + rotatedRay.time = ray.time; + let hit = hitRingSdf(id, rotatedRay, tMin, tMax, hitRecord); + if (hit) { + (*hitRecord).position = rotateQuat((*hitRecord).position - center, rotation) + center; + (*hitRecord).normal = rotateQuat((*hitRecord).normal, rotation); + return true; } - const options = { - text, - maxGlyphs, - scales: sizes - }; - const labelSet = new (0, _morphcharts.Components).LabelSet(core, options); - labelSet.positionsX = positionsX; - labelSet.positionsY = positionsY; - labelSet.positionsZ = positionsZ; - labelSet.horizontalAlignment = (0, _morphcharts.HorizontalAlignment).center; - labelSet.verticalAlignment = (0, _morphcharts.VerticalAlignment).center; - const layer = { - update: (bounds)=>{ - const { maxBoundsX , maxBoundsY , maxBoundsZ , minBoundsX , minBoundsY , minBoundsZ , } = bounds; - labelSet.minBoundsX = minBoundsX; - labelSet.minBoundsY = minBoundsY; - labelSet.minBoundsZ = minBoundsZ; - labelSet.maxBoundsX = maxBoundsX; - labelSet.maxBoundsY = maxBoundsY; - labelSet.maxBoundsZ = maxBoundsZ; - }, - bounds - }; - const labelSetVisual = core.renderer.createLabelSetVisual(labelSet); - core.renderer.labelSets = [ - labelSetVisual - ]; - return layer; -}; -function convert(stage) { - const { textData } = stage; - const { length } = textData; - const ids = []; - const text = []; - const colors = new Float64Array(length); - const positionsX = new Float64Array(length); - const positionsY = new Float64Array(length); - const positionsZ = new Float64Array(length); - const sizes = new Float64Array(length); - let bounds; - let maxGlyphs = 0; - const colorMap = new (0, _color.ColorMap)(); - textData.forEach((t, i)=>{ - ids.push(i); - text.push(t.text); - maxGlyphs += t.text.length; - positionsX[i] = t.position[0]; - positionsY[i] = t.position[1]; - positionsZ[i] = t.position[2]; - sizes[i] = 1.5 * t.size; //scale similar to axes - bounds = (0, _bounds.increment)(bounds, t.position[0], t.position[1], t.position[2], t.position[0], t.position[1], t.position[2]); - colors[i] = colorMap.registerColor(t.color); - }); - const { palette , maxColor } = colorMap.getPalette(); - return { - ids: new Uint32Array(ids), - colors, - positionsX, - positionsY, - positionsZ, - sizes, - bounds, - maxColor, - maxGlyphs, - palette, - text - }; -} - -},{"morphcharts":"eKLJv","./bounds":"9GDgY","./color":"aWwlw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jF5e3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getImageData", ()=>getImageData); -parcelHelpers.export(exports, "createImageQuad", ()=>createImageQuad); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -function getImageData(url) { - return new Promise((resolve, reject)=>{ - const imageElement = document.createElement("img"); - imageElement.onload = ()=>{ - const canvas = document.createElement("canvas"); - const ctx = canvas.getContext("2d"); - const { height , width } = imageElement; - canvas.width = width; - canvas.height = height; - ctx.drawImage(imageElement, 0, 0); - resolve(ctx.getImageData(0, 0, width, height)); - }; - imageElement.src = url; - }); -} -function createImageQuad(core, imageData, bounds, position, width, height) { - const { maxBoundsX , maxBoundsY , maxBoundsZ , minBoundsX , minBoundsY , minBoundsZ } = bounds; - const imageOptions = { - imageData, - position, - height, - width, - minBoundsX, - maxBoundsX, - minBoundsZ, - maxBoundsZ, - minBoundsY, - maxBoundsY - }; - return new (0, _morphcharts.Components).ImageQuad(core, imageOptions); -} - -},{"morphcharts":"eKLJv","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dUDEw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "cameraDefaults", ()=>cameraDefaults); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _glMatrix = require("gl-matrix"); -var _morphcharts = require("morphcharts"); -function createCameraDefaults() { - const qModelRotation2d = (0, _glMatrix.quat).create(); - const qModelRotation3d = (0, _morphcharts.Constants).QUAT_ROTATEX_MINUS_90; - const qCameraRotation2d = (0, _glMatrix.quat).create(); - const qCameraRotation3d = (0, _glMatrix.quat).create(); - const qAngle = (0, _glMatrix.quat).create(); - const vCameraPosition = (0, _glMatrix.vec3).create(); - // Altitude (pitch around local right axis) - (0, _glMatrix.quat).setAxisAngle(qCameraRotation3d, (0, _morphcharts.Constants).VECTOR3_UNITX, (0, _morphcharts.Helpers).AngleHelper.degreesToRadians(30)); - // Azimuth (yaw around global up axis) - (0, _glMatrix.quat).setAxisAngle(qAngle, (0, _morphcharts.Constants).VECTOR3_UNITY, (0, _morphcharts.Helpers).AngleHelper.degreesToRadians(-25)); - (0, _glMatrix.quat).multiply(qCameraRotation3d, qCameraRotation3d, qAngle); - return { - qModelRotation2d, - qModelRotation3d, - qCameraRotation2d, - qCameraRotation3d, - vCameraPosition - }; + return false; } -const cameraDefaults = createCameraDefaults(); -},{"gl-matrix":"9GjEQ","morphcharts":"eKLJv","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"69snG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "applyCameraCallbacks", ()=>applyCameraCallbacks); -parcelHelpers.export(exports, "setTransitionTimeAxesVisibility", ()=>setTransitionTimeAxesVisibility); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _glMatrix = require("gl-matrix"); -var _morphcharts = require("morphcharts"); -var _defaults = require("./defaults"); -const { qCameraRotation2d , qCameraRotation3d , qModelRotation2d , qModelRotation3d , vCameraPosition } = (0, _defaults.cameraDefaults); -function applyCameraCallbacks(ref, lastPresenterConfig, lastView, transistion2dOnly) { - const { cameraTransitioner , core , modelTransitioner , positionTransitioner } = ref; - ref.reset = ()=>{ - core.reset(true); - if (lastView === "3d") { - modelTransitioner.qRotation.to = qModelRotation3d; - cameraTransitioner.qRotation.to = qCameraRotation3d; - cameraTransitioner.vPosition.to = vCameraPosition; - } else { - modelTransitioner.qRotation.to = qModelRotation2d; - cameraTransitioner.qRotation.to = qCameraRotation2d; - cameraTransitioner.vPosition.to = vCameraPosition; - } - (0, _glMatrix.quat).slerp(modelTransitioner.qRotation.current, modelTransitioner.qRotation.to, modelTransitioner.qRotation.to, 0); - core.setModelRotation(modelTransitioner.qRotation.current, true); - core.camera.setOrbit(cameraTransitioner.qRotation.to, true); - core.camera.setPosition(cameraTransitioner.vPosition.to, true); - }; - const cam = (t)=>{ - (0, _glMatrix.quat).slerp(cameraTransitioner.qRotation.current, cameraTransitioner.qRotation.from, cameraTransitioner.qRotation.to, t); - (0, _glMatrix.vec3).lerp(cameraTransitioner.vPosition.current, cameraTransitioner.vPosition.from, cameraTransitioner.vPosition.to, t); - core.camera.setOrbit(cameraTransitioner.qRotation.current, false); - core.camera.setPosition(cameraTransitioner.vPosition.current, false); - // disable picking during transitions, as the performance degradation could reduce the framerate - core.inputManager.isPickingEnabled = false; - }; - core.updateCallback = (elapsedTime)=>{ - const { transitionDurations } = lastPresenterConfig; - if (positionTransitioner.isTransitioning) { - const t = positionTransitioner.elapse(elapsedTime, transitionDurations.position + transitionDurations.stagger); - core.renderer.transitionTime = t; - setTransitionTimeAxesVisibility(transistion2dOnly, core); - } else core.inputManager.isPickingEnabled = true; - if (modelTransitioner.isTransitioning) { - const tm = modelTransitioner.elapse(elapsedTime, transitionDurations.view, true); - if (modelTransitioner.shouldTransition) { - (0, _glMatrix.quat).slerp(modelTransitioner.qRotation.current, modelTransitioner.qRotation.from, modelTransitioner.qRotation.to, tm); - core.setModelRotation(modelTransitioner.qRotation.current, false); +fn hitLights(ray: Ray) -> vec3<f32> { + var hit: bool; + for (var i: u32 = 0u; i < arrayLength(&lightBuffer.lights); i = i + 1u) { + // let light = lightBuffer.lights[i]; + switch u32(lightBuffer.lights[i].typeId) { + default: { + hit = hitSphereLight(i, ray); + } + case 2u: { + hit = hitRectLight(i, ray); } - cam(tm); } - if (cameraTransitioner.isTransitioning) { - const t1 = cameraTransitioner.elapse(elapsedTime, transitionDurations.view, true); - cam(t1); + if (hit) { + return lightBuffer.lights[i].color; } - }; -} -function setTransitionTimeAxesVisibility(transistion2dOnly, core) { - const t = core.renderer.transitionTime; - if (transistion2dOnly) { - if (t < 0.5) core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).previous; - else core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; - } else { - if (t <= 0.01) core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).previous; - else if (t >= 0.99) core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; - else core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).none; } -} + + // Background color + // return vec3<f32>(0f, 0f, 0f); + // return vec3<f32>(1f, 1f, 1f); + return uniforms.backgroundColor; -},{"gl-matrix":"9GjEQ","morphcharts":"eKLJv","./defaults":"dUDEw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fdQK1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "init", ()=>init); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -var _renderer = require("./renderer"); -var _canvas = require("./canvas"); -var _transition = require("../transition"); -function init(options, mcRendererOptions) { - const { container } = options; - const core = new (0, _morphcharts.Core)({ - container - }); - (0, _renderer.getRenderer)(mcRendererOptions, core); - (0, _canvas.listenCanvasEvents)(core, options); - core.config.pickSelectDelay = 50; - const cameraTransitioner = new (0, _transition.CameraTransitioner)(); - const modelTransitioner = new (0, _transition.ModelTransitioner)(); - const positionTransitioner = new (0, _transition.Transitioner)(); - positionTransitioner.ended = ()=>{ - core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; - }; - const ref = { - supportedRenders: { - advanced: (0, _renderer.rendererEnabled)(true), - basic: (0, _renderer.rendererEnabled)(false) - }, - reset: null, - cameraTransitioner, - modelTransitioner, - positionTransitioner, - core, - setMorphChartsRendererOptions (mcRendererOptions) { - if ((0, _renderer.shouldChangeRenderer)(ref.lastMorphChartsRendererOptions, mcRendererOptions)) { - (0, _renderer.getRenderer)(mcRendererOptions, core); - (0, _canvas.listenCanvasEvents)(core, options); - } else if (mcRendererOptions.advanced) //same renderer, poke the config - (0, _renderer.setRendererOptions)(core.renderer, mcRendererOptions); - ref.lastMorphChartsRendererOptions = mcRendererOptions; - }, - lastMorphChartsRendererOptions: mcRendererOptions, - layerStagger: {} - }; - return ref; + // TODO: Dome light + // let t = 0.5f * (ray.direction.y + 1f); + // let background = (1f - t) * vec3<f32>(1f, 1f, 1f) + t * vec3<f32>(0.5f, 0.7f, 1.0f); + // return background; } -},{"morphcharts":"eKLJv","./renderer":"oAO2D","./canvas":"itJpT","../transition":"9krcl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"oAO2D":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "shouldChangeRenderer", ()=>shouldChangeRenderer); -parcelHelpers.export(exports, "getRenderer", ()=>getRenderer); -parcelHelpers.export(exports, "setRendererOptions", ()=>setRendererOptions); -parcelHelpers.export(exports, "rendererEnabled", ()=>rendererEnabled); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -function shouldChangeRenderer(prev, next) { - var _a, _b; - if (!prev || !next) return true; - if (prev.advanced !== next.advanced) return true; - if (!prev.advanced) return ((_a = prev.basicOptions) === null || _a === void 0 ? void 0 : _a.antialias) != ((_b = next.basicOptions) === null || _b === void 0 ? void 0 : _b.antialias); +fn hitSphereLight(id: u32, ray: Ray) -> bool { + let sphere = &lightBuffer.lights[id]; + let radius = (*sphere).size.x; + let oc = ray.origin - (*sphere).center; + let b = dot(oc, ray.direction); + let c = dot(oc, oc) - radius * radius; + var h = b * b - c; + if (h < 0f) { return false; } + return b < 0f; // Ensure ray towards light } -function getRenderer(mcRendererOptions, core) { - const advanced = mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.advanced; - const r = advanced ? new (0, _morphcharts.Renderers).Advanced.Main() : new (0, _morphcharts.Renderers).Basic.Main(mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.basicOptions); - core.renderer = r; - setRendererOptions(r, mcRendererOptions); - return r; + +fn hitRectLight(id: u32, ray: Ray) -> bool { + let rotatedXyRect = &lightBuffer.lights[id]; + let center = (*rotatedXyRect).center; + let rotation = (*rotatedXyRect).rotation; + let invRotation = conjugate(rotation); + var rotatedRay: Ray; + rotatedRay.origin = rotateQuat(ray.origin - center, invRotation) + center; + rotatedRay.direction = rotateQuat(ray.direction, invRotation); + if (dot(rotatedRay.direction, vec3<f32>(0f, 0f, 1f)) < 0f) { return false; } // Directional light + let oc = rotatedRay.origin - center; + let t = -oc.z / rotatedRay.direction.z; + if (t < 0f) { return false; } + let p = oc + t * rotatedRay.direction; + if (abs(p.x) > (*rotatedXyRect).size.x || abs(p.y) > (*rotatedXyRect).size.y) { return false; } + return true; } -function setRendererOptions(renderer, mcRendererOptions) { - const o = mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.advancedOptions; - if ((mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.advanced) && o) for(const key in o)renderer.config[key] = o[key]; + +fn nearZero(v: vec3<f32>) -> bool { + return max(max(abs(v.x), abs(v.y)), abs(v.z)) < 0.00000001f; // 1e-8 } -function rendererEnabled(advanced) { - const r = advanced ? new (0, _morphcharts.Renderers).Advanced.Main() : new (0, _morphcharts.Renderers).Basic.Main(); - return r.isSupported; + +fn scatterLambertian(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { + let scatterDirection = hitRecord.normal + randomUnitVector(seed); + + // Catch degenerate scatter direction + (*ray).direction = select(normalize(scatterDirection), hitRecord.normal, nearZero(scatterDirection)); + + (*ray).origin = hitRecord.position; + (*attenuation) = textureValue(hitRecord); + return true; } -},{"morphcharts":"eKLJv","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"itJpT":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "listenCanvasEvents", ()=>listenCanvasEvents); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _morphcharts = require("morphcharts"); -const rightButton = 2; -function listenCanvasEvents(core, options) { - const { container , pickGridCallback } = options; - const { inputManager } = core; - if (options.onLasso) inputManager.pickLassoCallback = (result)=>{ - options.onLasso(result.ids[0], result.manipulator.event); - }; - inputManager.singleTouchAction = (manipulator)=>{ - if (manipulator.button == rightButton || manipulator.shiftKey || manipulator.ctrlKey) return (0, _morphcharts.SingleTouchAction).rotate; - else if (manipulator.altKey) return (0, _morphcharts.SingleTouchAction).lasso; - else return (0, _morphcharts.SingleTouchAction).translate; - }; - inputManager.pickAxesGridCallback = ({ divisionX , divisionY , divisionZ , manipulator })=>{ - clearClickTimeout(); - const { altKey , button , shiftKey } = manipulator; - const me = { - altKey, - shiftKey, - button - }; - const e = me; - pickGridCallback([ - divisionX, - divisionY, - divisionZ - ], e); - }; - const canvas = container.getElementsByTagName("canvas")[0]; - let pickedId; - const hover = (e)=>{ - if (core.renderer.pickedId !== pickedId) { - pickedId = core.renderer.pickedId; - const ordinal = core.renderer.transitionBuffers[0].pickIdLookup[pickedId]; - options.onCubeHover(e, ordinal); - } - }; - canvas.addEventListener("mousemove", (e)=>{ - clearClickTimeout(); - if (mousedown) options.onCubeHover(e, null); - hover(e); - }); - canvas.addEventListener("mouseout", hover); - canvas.addEventListener("mouseover", hover); - let mousedown; - canvas.addEventListener("mousedown", ()=>{ - mousedown = true; - }); - canvas.addEventListener("mouseup", (e)=>{ - mousedown = false; - }); - let canvasClickTimeout; - const clearClickTimeout = ()=>{ - clearTimeout(canvasClickTimeout); - canvasClickTimeout = null; - }; - canvas.addEventListener("click", (e)=>{ - canvasClickTimeout = setTimeout(()=>{ - options.onCanvasClick(e); - }, 50); - }); - inputManager.pickItemCallback = ({ manipulator })=>{ - clearClickTimeout(); - const ordinal = core.renderer.transitionBuffers[0].pickIdLookup[pickedId]; - options.onCubeClick(manipulator.event, ordinal); - }; +fn scatterMetal(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { + (*ray).direction = normalize(reflect((*ray).direction, hitRecord.normal) + materialBuffer.materials[hitRecord.materialId].fuzz * randomInUnitSphere(seed)); + (*ray).origin = hitRecord.position; + (*attenuation) = textureValue(hitRecord); + + // Absorb any rays which fuzz scatters below the surface + return dot((*ray).direction, hitRecord.normal) > 0f; } -},{"morphcharts":"eKLJv","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9krcl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Transitioner", ()=>Transitioner); -parcelHelpers.export(exports, "CameraTransitioner", ()=>CameraTransitioner); -parcelHelpers.export(exports, "ModelTransitioner", ()=>ModelTransitioner); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _glMatrix = require("gl-matrix"); -var _easing = require("./easing"); -class Transitioner { - constructor(){ - this.isTransitioning = false; - } - begin() { - this.isTransitioning = true; - this.time = 0; +fn scatterGlossy(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { + // Specular + let material = &materialBuffer.materials[hitRecord.materialId]; + let refractiveIndex = (*material).refractiveIndex; + let refractionRatio = select(refractiveIndex, 1f / refractiveIndex, hitRecord.frontFace); + let cosTheta = min(dot(-(*ray).direction, hitRecord.normal), 1f); + if (reflectance(cosTheta, refractionRatio) * (*material).glossiness > random(seed)) { + (*ray).direction = normalize(reflect((*ray).direction, hitRecord.normal) + (*material).fuzz * randomInUnitSphere(seed)); + (*ray).origin = hitRecord.position; + (*attenuation) = vec3<f32>(1f, 1f, 1f); + + // Absorb any rays which fuzz scatters below the surface + return dot((*ray).direction, hitRecord.normal) > 0f; } - elapse(elapsedTime, totalTime, ease = false) { - this.time += elapsedTime; - if (this.time >= totalTime) { - this.isTransitioning = false; - this.time = totalTime; - this.ended && this.ended(); - } - const t = this.time / totalTime; - return ease ? (0, _easing.easing)(t) : t; + else { + // Lambertian + return scatterLambertian(ray, hitRecord, attenuation, seed); } } -class CameraTransitioner extends Transitioner { - constructor(){ - super(); - this.qRotation = { - from: (0, _glMatrix.quat).create(), - to: null, - current: (0, _glMatrix.quat).create() - }; - this.vPosition = { - from: (0, _glMatrix.vec3).create(), - to: null, - current: (0, _glMatrix.vec3).create() - }; + +fn scatterDielectric(ray: ptr<function, Ray>, hitRecord: ptr<function, HitRecord>, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { + let material = &materialBuffer.materials[(*hitRecord).materialId]; + let refractiveIndex = (*material).refractiveIndex; + // TODO: If still inside another material, use its refractive index + let refractionRatio = select(refractiveIndex, 1f / refractiveIndex, (*hitRecord).frontFace); + let cosTheta = min(dot(-(*ray).direction, (*hitRecord).normal), 1f); + let sinTheta = sqrt(1f - cosTheta * cosTheta); + let cannotRefract = refractionRatio * sinTheta > 1f; + // if (cannotRefract || reflectance(cosTheta, refractionRatio) > random(seed)) { + if (cannotRefract || reflectance(cosTheta, refractionRatio) * (*material).glossiness > random(seed)) { + (*ray).direction = reflect((*ray).direction, (*hitRecord).normal); } - move(position, rotation) { - this.begin(); - this.qRotation.to = rotation; - this.vPosition.to = position; + else { + (*ray).direction = refraction((*ray).direction, (*hitRecord).normal, refractionRatio); } -} -class ModelTransitioner extends Transitioner { - constructor(){ - super(); - this.shouldTransition = false; - this.qRotation = { - from: null, - to: null, - current: (0, _glMatrix.quat).create() - }; + (*ray).origin = (*hitRecord).position; + (*ray).direction = normalize((*ray).direction + (*material).fuzz * randomInUnitSphere(seed)); + + // Did the ray enter/stay inside? + (*attenuation) = vec3<f32>(1f, 1f, 1f); + // if (dot((*ray).direction, (*hitRecord).normal) < 0f) { + if (dot((*ray).direction, select(-(*hitRecord).normal, (*hitRecord).normal, (*hitRecord).frontFace)) < 0f) { + (*hitRecord).isAbsorbing = true; + (*hitRecord).absorption = (*material).color; + + // If already inside another absorbing dielectric, add to absorption + if ((*hitRecord).previousIsAbsorbing && (*hitRecord).id != (*hitRecord).previousId) { + (*hitRecord).absorption = (*hitRecord).absorption + (*hitRecord).previousAbsorption; + } } + return true; } -},{"gl-matrix":"9GjEQ","./easing":"hjMnj","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hjMnj":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "easing", ()=>easing); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _d3Ease = require("d3-ease"); -function easing(t) { - if (t === 0 || t === 1) return t; - return (0, _d3Ease.easeCubicInOut)(t); +fn scatterIsotropic(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { + (*ray).direction = randomUnitVector(seed); + (*ray).origin = hitRecord.position; + (*attenuation) = materialBuffer.materials[hitRecord.materialId].color; + return true; } -},{"d3-ease":"5FdFn","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5FdFn":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "easeLinear", ()=>(0, _linearJs.linear)); -parcelHelpers.export(exports, "easeQuad", ()=>(0, _quadJs.quadInOut)); -parcelHelpers.export(exports, "easeQuadIn", ()=>(0, _quadJs.quadIn)); -parcelHelpers.export(exports, "easeQuadOut", ()=>(0, _quadJs.quadOut)); -parcelHelpers.export(exports, "easeQuadInOut", ()=>(0, _quadJs.quadInOut)); -parcelHelpers.export(exports, "easeCubic", ()=>(0, _cubicJs.cubicInOut)); -parcelHelpers.export(exports, "easeCubicIn", ()=>(0, _cubicJs.cubicIn)); -parcelHelpers.export(exports, "easeCubicOut", ()=>(0, _cubicJs.cubicOut)); -parcelHelpers.export(exports, "easeCubicInOut", ()=>(0, _cubicJs.cubicInOut)); -parcelHelpers.export(exports, "easePoly", ()=>(0, _polyJs.polyInOut)); -parcelHelpers.export(exports, "easePolyIn", ()=>(0, _polyJs.polyIn)); -parcelHelpers.export(exports, "easePolyOut", ()=>(0, _polyJs.polyOut)); -parcelHelpers.export(exports, "easePolyInOut", ()=>(0, _polyJs.polyInOut)); -parcelHelpers.export(exports, "easeSin", ()=>(0, _sinJs.sinInOut)); -parcelHelpers.export(exports, "easeSinIn", ()=>(0, _sinJs.sinIn)); -parcelHelpers.export(exports, "easeSinOut", ()=>(0, _sinJs.sinOut)); -parcelHelpers.export(exports, "easeSinInOut", ()=>(0, _sinJs.sinInOut)); -parcelHelpers.export(exports, "easeExp", ()=>(0, _expJs.expInOut)); -parcelHelpers.export(exports, "easeExpIn", ()=>(0, _expJs.expIn)); -parcelHelpers.export(exports, "easeExpOut", ()=>(0, _expJs.expOut)); -parcelHelpers.export(exports, "easeExpInOut", ()=>(0, _expJs.expInOut)); -parcelHelpers.export(exports, "easeCircle", ()=>(0, _circleJs.circleInOut)); -parcelHelpers.export(exports, "easeCircleIn", ()=>(0, _circleJs.circleIn)); -parcelHelpers.export(exports, "easeCircleOut", ()=>(0, _circleJs.circleOut)); -parcelHelpers.export(exports, "easeCircleInOut", ()=>(0, _circleJs.circleInOut)); -parcelHelpers.export(exports, "easeBounce", ()=>(0, _bounceJs.bounceOut)); -parcelHelpers.export(exports, "easeBounceIn", ()=>(0, _bounceJs.bounceIn)); -parcelHelpers.export(exports, "easeBounceOut", ()=>(0, _bounceJs.bounceOut)); -parcelHelpers.export(exports, "easeBounceInOut", ()=>(0, _bounceJs.bounceInOut)); -parcelHelpers.export(exports, "easeBack", ()=>(0, _backJs.backInOut)); -parcelHelpers.export(exports, "easeBackIn", ()=>(0, _backJs.backIn)); -parcelHelpers.export(exports, "easeBackOut", ()=>(0, _backJs.backOut)); -parcelHelpers.export(exports, "easeBackInOut", ()=>(0, _backJs.backInOut)); -parcelHelpers.export(exports, "easeElastic", ()=>(0, _elasticJs.elasticOut)); -parcelHelpers.export(exports, "easeElasticIn", ()=>(0, _elasticJs.elasticIn)); -parcelHelpers.export(exports, "easeElasticOut", ()=>(0, _elasticJs.elasticOut)); -parcelHelpers.export(exports, "easeElasticInOut", ()=>(0, _elasticJs.elasticInOut)); -var _linearJs = require("./linear.js"); -var _quadJs = require("./quad.js"); -var _cubicJs = require("./cubic.js"); -var _polyJs = require("./poly.js"); -var _sinJs = require("./sin.js"); -var _expJs = require("./exp.js"); -var _circleJs = require("./circle.js"); -var _bounceJs = require("./bounce.js"); -var _backJs = require("./back.js"); -var _elasticJs = require("./elastic.js"); - -},{"./linear.js":false,"./quad.js":false,"./cubic.js":"iodag","./poly.js":false,"./sin.js":false,"./exp.js":false,"./circle.js":false,"./bounce.js":false,"./back.js":false,"./elastic.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iodag":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "cubicIn", ()=>cubicIn); -parcelHelpers.export(exports, "cubicOut", ()=>cubicOut); -parcelHelpers.export(exports, "cubicInOut", ()=>cubicInOut); -function cubicIn(t) { - return t * t * t; -} -function cubicOut(t) { - return --t * t * t + 1; -} -function cubicInOut(t) { - return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +fn scatterVarnish(ray: ptr<function, Ray>, hitRecord: HitRecord, attenuation: ptr<function, vec3<f32>>, seed: ptr<function, u32>) -> bool { + // Front-face only (no internal reflection or refraction) + let material = &materialBuffer.materials[hitRecord.materialId]; + if (hitRecord.frontFace && (*material).glossiness > random(seed)) { + let refractiveIndex = (*material).refractiveIndex; + let refractionRatio = select(refractiveIndex, 1f / refractiveIndex, hitRecord.frontFace); + let cosTheta = min(dot(-(*ray).direction, hitRecord.normal), 1f); + let sinTheta = sqrt(1f - cosTheta * cosTheta); + let cannotRefract = refractionRatio * sinTheta > 1f; + if (cannotRefract || reflectance(cosTheta, refractionRatio) > random(seed)) { + (*ray).direction = reflect((*ray).direction, hitRecord.normal); + } + else { + // Refraction improves definition at edges and deepens color on faces + (*ray).direction = refraction((*ray).direction, hitRecord.normal, refractionRatio); + } + (*ray).direction = normalize((*ray).direction + (*material).fuzz * randomInUnitSphere(seed)); + } + // Pass-through + (*ray).origin = hitRecord.position; + (*attenuation) = vec3<f32>(1f, 1f, 1f); + return true; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"58pd9":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ViewGl", ()=>ViewGl); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _defaults = require("../defaults"); -var _presenter = require("../presenter"); -var _enums = require("../enums"); -var _rendererGl = require("./rendererGl"); -let registered = false; -//dynamic superclass lets us create a subclass at execution phase instead of declaration phase. -//This allows us to retrieve vega.View from either UMD or ES6 consumers of this class. -//pass in the SuperClass, which should be a vega.View -function _ViewGl(runtime, config) { - //dynamic superclass, since we don't know have vega.View in the declaration phase - class ViewGlInternal extends (0, _base.base).vega.View { - constructor(runtime, config = {}){ - super(runtime, config); - this.config = config; - this.presenter = config.presenter; - config.presenterConfig = config.presenterConfig || {}; - config.presenterConfig.redraw = ()=>{ - this._redraw = true; //use Vega View private member _redraw - this.run(); - }; +fn textureValue(hitRecord: HitRecord) -> vec3<f32> { + let textureId = materialBuffer.materials[hitRecord.materialId].textureId; + let texture = &textureBuffer.textures[u32(textureId)]; + switch u32((*texture).typeId) { + // No texture + default: { + return vec3<f32>(); } - renderer(...args) { - if (args && args.length) { - const renderer = args[0]; - if (renderer === "morphcharts" && !registered) { - (0, _base.base).vega.renderModule("morphcharts", { - handler: (0, _base.base).vega.CanvasHandler, - renderer: (0, _rendererGl.RendererGl) - }); - registered = true; - } - return super.renderer(renderer); - } else return super.renderer(); + // Solid color + case 1u: { + if (hitRecord.sdfBorder) { + return (*texture).color1; + } + else { + return (*texture).color0; + } + + // Debug uv + // return vec3<f32>(hitRecord.uv, 0f); } - initialize(el) { - if (!this.presenter) this.presenter = new (0, _presenter.Presenter)(el); - super.initialize(this.presenter.getElement((0, _enums.PresenterElement).vegaControls)); - const renderer = this._renderer; - renderer.presenterConfig = this.config.presenterConfig; - renderer.presenter = this.presenter; - renderer.getView = this.config && this.config.getView || (()=>this.presenter.view || (0, _defaults.defaultView)); - return this; + // Image + case 2u: { + // Sample in linear space + return textureSampleLevel(backgroundTexture, linearSampler, hitRecord.uv, 0f).rgb; + // return vec3(hitRecord.uv.x, hitRecord.uv.y, 0f); } - error(e) { - if (this.presenter.logger) this.presenter.logger(e); + // Checker + case 4u: { + let q = trunc((hitRecord.uv + (*texture).offset) / (*texture).size0.xy); + return select((*texture).color0, (*texture).color1, (q.x + q.y) % 2f > 0f); + } + // Grid + case 5u: { + let size0 = (*texture).size0; + let size1 = (*texture).size1; + let clip = (*texture).clip; + if (hitRecord.uv.x < clip.x || hitRecord.uv.y < clip.y || hitRecord.uv.x > clip.z || hitRecord.uv.y > clip.w) { + return (*texture).color1; + } + let uv = hitRecord.uv + (*texture).offset; + var d = uv / size0.xy; + d = abs(d - round(d)) * size0.xy; + if (d.x < size1.x || d.y < size1.y) { + return (*texture).color0; + } + else { + d = uv / size0.zw; + d = abs(d - round(d)) * size0.zw; + if (d.x < size1.z || d.y < size1.w) { + return (*texture).color0; + } + return (*texture).color1; + } } } - const instance = new ViewGlInternal(runtime, config); - return instance; } -const ViewGl = _ViewGl; -},{"../base":"77OTl","../defaults":"4ObFg","../presenter":"lSg1r","../enums":"cMvaW","./rendererGl":"9V6jP","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9V6jP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "RendererGl", ()=>RendererGl); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -//pass in the SuperClass, which should be a vega.View -function _RendererGl(loader) { - //dynamic superclass, since we don't know have vega.View in the declaration phase - class RendererGlInternal extends (0, _base.base).vega.Renderer { - initialize(el, width, height, origin) { - this.height = height; - this.width = width; - // this method will invoke resize to size the canvas appropriately - return super.initialize(el, width, height, origin); - } - resize(width, height, origin) { - super.resize(width, height, origin); - this.origin = origin; - this.height = height; - this.width = width; - //rteturn this for vega - return this; +fn rayColor(ray: ptr<function, Ray>, seed: ptr<function, u32>) -> vec3<f32> { + let maxDepth = 16u; // TODO: Pass as uniform + var depth = 0u; + // var result: Color; + var color = vec3<f32>(1f, 1f, 1f); + var attenuation = vec3<f32>(1f, 1f, 1f); + var emitted = vec3<f32>(0f, 0f, 0f); + var hitRecord: HitRecord; + hitRecord.id = 4294967295; // -1 as u32 + var scatter: bool; + loop { + // if (hitWorld(*ray, 0.00001f, 100f, &hitRecord, seed)) { + if (hitBVH(*ray, 0.00001f, 100f, &hitRecord, seed)) { + // Debug normal, depth + // First hit + // if (depth == 0u) { + // result.normal = hitRecord.normal * 0.5f + vec3<f32>(0.5f, 0.5f, 0.5f); + // // result.normal = hitRecord.normal * 0.5f + vec3<f32>(0.5f, 0.5f, 0.5f) + // // result.depth = 1f / hitRecord.t; + // result.depth = -1f / dot(hitRecord.position - (*ray).origin, uniforms.forward); + // } + // return result; + + // Depth + depth = depth + 1u; + if (depth == maxDepth) { + // Exceeded bounce limit, no more light is gathered + // result.color = vec3<f32>(0f, 0f, 0f); + // return result; + return vec3<f32>(0f, 0f, 0f); + } + + // Bounce + // If last hit was travelling INTO a dielectric, use last hit position to calculate distance + // and apply Beer's law to attenuate the light. Modify the dielectric scattering function to + // recrord travelling INTO a dielectric based on hitRecord normal and ray direction. + // Reset this flag each time here. + if (hitRecord.previousIsAbsorbing) { + // Beer's law + let d = distance(hitRecord.previousPosition, hitRecord.position); + color = color * exp(-d * hitRecord.previousAbsorption); + } + // Reset absorption + hitRecord.isAbsorbing = false; + hitRecord.absorption = vec3<f32>(0f, 0f, 0f); + switch u32(materialBuffer.materials[hitRecord.materialId].typeId) { + default: { + scatter = false; + } + case 0u: { + scatter = scatterLambertian(ray, hitRecord, &attenuation, seed); + } + case 1u: { + scatter = scatterMetal(ray, hitRecord, &attenuation, seed); + } + case 2u: { + scatter = scatterDielectric(ray, &hitRecord, &attenuation, seed); + } + case 3u: { + scatter = scatterGlossy(ray, hitRecord, &attenuation, seed); + } + case 4u: { + // Diffuse light + scatter = false; + emitted = materialBuffer.materials[hitRecord.materialId].color; + } + case 5u: { + scatter = scatterIsotropic(ray, hitRecord, &attenuation, seed); + } + case 6u: { + scatter = scatterVarnish(ray, hitRecord, &attenuation, seed); + } + } + + if (scatter) { + // Attenuate + color = color * attenuation; + } + else { + // Emit + // result.color = color * emitted; + // return result; + return color * emitted; + } } - _render(scene, items) { - const scene3d = scene; - scene3d.view = this.getView(); - this.presenter.present(scene3d, this.height, this.width, this.presenterConfig); - //return this for vega - return this; + else { + // return color; + + // No hits + if (depth > 0u) { // Hide lights, background + return hitLights(*ray) * color; + // result.color = hitLights(*ray) * color; + // return result; + } + else { + // return vec3<f32>(0f, 0f, 0f); + return uniforms.backgroundColor; + // result.color = uniforms.backgroundColor; + // return result; + } + + // Background + // let t = 0.5f * ((*ray).direction.y + 1f); + // let background = (1f - t) * vec3<f32>(1f, 1f, 1f) + t * vec3<f32>(0.5f, 0.7f, 1.0f); + // return color * background; } } - const instance = new RendererGlInternal(loader); - return instance; } -const RendererGl = _RendererGl; -},{"../base":"77OTl","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lJKL8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "version", ()=>version); -const version = "1.0.6"; +// TODO: Try writing color directly using var outputTexture : texture_storage_2d<rgb32f,read_write>; +// textureStore(outputTexture, uv, vec3<f32>(1f, 1f, 1f)); +@group(0) @binding(0) var<storage, read_write> outputColorBuffer: ColorBuffer; +@group(0) @binding(1) var<uniform> uniforms: Uniforms; +@group(0) @binding(2) var<storage, read> hittableBuffer: HittableBuffer; +@group(0) @binding(3) var<storage, read> materialBuffer: MaterialBuffer; +@group(0) @binding(4) var<storage, read> textureBuffer: TextureBuffer; +@group(0) @binding(5) var<storage, read> lightBuffer: LightBuffer; +@group(0) @binding(6) var<storage, read> linearBVHNodeBuffer: LinearBVHNodeBuffer; +@group(0) @binding(7) var linearSampler: sampler; +@group(0) @binding(8) var fontTexture: texture_2d<f32>; +@group(0) @binding(9) var backgroundTexture: texture_2d<f32>; +@group(0) @binding(10) var atlasTexture: texture_2d<f32>; +@group(0) @binding(11) var<storage, read_write> outputNormalDepthBuffer: NormalDepthBuffer; +@group(0) @binding(12) var<storage, read_write> depthMinMaxBuffer: DepthMinMaxBuffer; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5MHBA":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "colorSchemes", ()=>colorSchemes); -parcelHelpers.export(exports, "registerColorSchemes", ()=>registerColorSchemes); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -var _defaults = require("./defaults"); -const dualPairs = [ - [ - (0, _defaults.dualColorSchemeColors).black, - (0, _defaults.dualColorSchemeColors).gray - ], - [ - (0, _defaults.dualColorSchemeColors).red, - (0, _defaults.dualColorSchemeColors).green - ], - [ - (0, _defaults.dualColorSchemeColors).red, - (0, _defaults.dualColorSchemeColors).blue - ], - [ - (0, _defaults.dualColorSchemeColors).black, - (0, _defaults.dualColorSchemeColors).red - ], - [ - (0, _defaults.dualColorSchemeColors).black, - (0, _defaults.dualColorSchemeColors).orange - ], - [ - (0, _defaults.dualColorSchemeColors).black, - (0, _defaults.dualColorSchemeColors).green - ], -]; -const colorSchemes = [ - { - scheme: (0, _sanddanceSpecs.ColorScaleNone), - colors: [ - (0, _defaults.defaultViewerOptions).colors.defaultCube - ] - }, -]; -createDualColorSchemes(); -function registerColorSchemes(vega) { - colorSchemes.forEach((cs)=>{ - if (cs.colors.length === 1) vega.scheme(cs.scheme, (x)=>cs.colors[0]); - else vega.scheme(cs.scheme, cs.colors); - }); +// TODO: Move lighting to seperate bind group so I can update it independently + +@compute @workgroup_size(256, 1, 1) +fn clear(@builtin(global_invocation_id) globalId : vec3<u32>) { + var index = globalId.x * 3u; + outputColorBuffer.values[index] = 0f; + outputColorBuffer.values[index + 1u] = 0f; + outputColorBuffer.values[index + 2u] = 0f; + index = globalId.x * 4u; + outputNormalDepthBuffer.values[index] = 0f; // Normal x + outputNormalDepthBuffer.values[index + 1u] = 0f; // Normal y + outputNormalDepthBuffer.values[index + 2u] = 0f; // Normal z + outputNormalDepthBuffer.values[index + 3u] = 0f; // Depth + atomicStore(&depthMinMaxBuffer.values[0], 4294967295u); + atomicStore(&depthMinMaxBuffer.values[1], 0u); } -function createPair(names, colors) { - const scheme = `dual_${names[0]}${names[1]}`; - colorSchemes.push({ - scheme, - colors - }); + +@compute @workgroup_size(256, 1, 1) +fn depthNormal(@builtin(global_invocation_id) globalId : vec3<u32>) { + let imageSize = vec2<f32>(uniforms.width * uniforms.tilesX, uniforms.height * uniforms.tilesY); + let tileSize = vec2<f32>(uniforms.width, uniforms.height); + + // Tex coords [0,1] + // let id = f32(globalId.x); + // let v = floor(id / imageSize.x); + // let u = (id - v * imageSize.x); + // let uv = vec2<f32>(u, v); + // let texCoord = uv / imageSize; + + // Pixel coords ([0,width-1], [0,height-1]) + let id = f32(globalId.x); + let tilePixelY = floor(id / tileSize.x); + let tilePixelX = id - tilePixelY * tileSize.x; + let imagePixelX = tilePixelX + uniforms.tileOffsetX * tileSize.x; + let imagePixelY = tilePixelY + uniforms.tileOffsetY * tileSize.y; + + // Tex coords ([0,1], [0,1]) + let texCoord = vec2<f32>(imagePixelX / imageSize.x, imagePixelY / imageSize.y); + + // Camera + var camera = getCamera(uniforms); + + // Sample position (sub-pixel sampling has same seed, but only sampled once per frame) + let samplePos = vec2<f32>(texCoord); + + // Ray + var seed = 0u; // No depth of field for depth, normal + var ray = getCameraRay(camera, &seed, samplePos); + + // Result + var normal = vec3<f32>(0f, 0f, 0f); + var depth = 0f; + var hitRecord: HitRecord; + if (hitBVH(ray, 0.00001f, 100f, &hitRecord, &seed)) { + normal = hitRecord.normal * 0.5f + vec3<f32>(0.5f, 0.5f, 0.5f); + depth = -1f / dot(hitRecord.position - ray.origin, uniforms.forward); + } + + let index = globalId.x * 4u; + // let index = u32(pixelY * imageSize.x + pixelX) * 4u; + outputNormalDepthBuffer.values[index] = normal.x; + outputNormalDepthBuffer.values[index + 1u] = normal.y; + outputNormalDepthBuffer.values[index + 2u] = normal.z; + outputNormalDepthBuffer.values[index + 3u] = depth; + + // Min, max depth + // When depth is 0, it means no hit, so ignore + if (depth > 0f) { + atomicMin(&depthMinMaxBuffer.values[0], u32(depth * 1000f)); + } + atomicMax(&depthMinMaxBuffer.values[1], u32(depth * 1000f)); } -function createDualColorSchemes() { - dualPairs.forEach((colors)=>{ - const names = colors.map((color)=>{ - for(const key in 0, _defaults.dualColorSchemeColors)if (color === (0, _defaults.dualColorSchemeColors)[key]) return key; - }); - createPair(names, colors); - createPair([ - ...names - ].reverse(), [ - ...colors - ].reverse()); - }); + +@compute @workgroup_size(256, 1, 1) +fn segment(@builtin(global_invocation_id) globalId : vec3<u32>) { + let imageSize = vec2<f32>(uniforms.width * uniforms.tilesX, uniforms.height * uniforms.tilesY); + let tileSize = vec2<f32>(uniforms.width, uniforms.height); + + // Tex coords [0,1] + // let id = f32(globalId.x); + // let v = floor(id / imageSize.x); + // let u = (id - v * imageSize.x); + // let uv = vec2<f32>(u, v); + // let texCoord = uv / imageSize; + + // Pixel coords ([0,width-1], [0,height-1]) + let id = f32(globalId.x); + let tilePixelY = floor(id / tileSize.x); + let tilePixelX = id - tilePixelY * tileSize.x; + let imagePixelX = tilePixelX + uniforms.tileOffsetX * tileSize.x; + let imagePixelY = tilePixelY + uniforms.tileOffsetY * tileSize.y; + + // Tex coords ([0,1], [0,1]) + let texCoord = vec2<f32>(imagePixelX / imageSize.x, imagePixelY / imageSize.y); + + // Camera + var camera = getCamera(uniforms); + + // Sample position (sub-pixel sampling has same seed, but only sampled once per frame) + let samplePos = vec2<f32>(texCoord); + + // Ray + var seed = 0u; // No depth of field for depth, normal + var ray = getCameraRay(camera, &seed, samplePos); + + // Result + var color = vec4<f32>(1f, 1f, 1f, 0f); + var hitRecord: HitRecord; + if (hitBVH(ray, 0.00001f, 100f, &hitRecord, &seed)) { + // color = materialBuffer.materials[hitRecord.materialId].idColor; + let id = f32(hitRecord.id & 255u) / 255f; + color.x = id; + color.y = id; + color.z = id; + // let color3 = textureValue(hitRecord); + // color.x = color3.x; + // color.y = color3.y; + // color.z = color3.z; + } + + let index = globalId.x * 4u; + // let index = u32(pixelY * imageSize.x + pixelX) * 4u; + outputNormalDepthBuffer.values[index] = color.x; + outputNormalDepthBuffer.values[index + 1u] = color.y; + outputNormalDepthBuffer.values[index + 2u] = color.z; + outputNormalDepthBuffer.values[index + 3u] = 1f; } -},{"@msrvida/sanddance-specs":"4hjOh","./defaults":"lNUGC","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hhZNh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Component to view a SandDance data visualization. - */ parcelHelpers.export(exports, "Viewer", ()=>Viewer); -var _animator = require("./animator"); -var _axisSelection = require("./axisSelection"); -var _colorCubes = require("./colorCubes"); -var _colorSchemes = require("./colorSchemes"); -var _constants = require("./constants"); -var _dataScope = require("./dataScope"); -var _defaults = require("./defaults"); -var _details = require("./details"); -var _headers = require("./headers"); -var _legend = require("./legend"); -var _ordinal = require("./ordinal"); -var _search = require("./search"); -var _signals = require("./signals"); -var _tooltip = require("./tooltip"); -var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -var _searchExpression = require("@msrvida/search-expression"); -var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -var _characterSet = require("./characterSet"); -var _transition = require("./transition"); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); +// @builtin(local_invocation_id) localId : vec3<u32>, +// @builtin(num_workgroups) numWorkgroups : vec3<u32>, +// @builtin(workgroup_id) workgroupId : vec3<u32> +// TODO: Use workgroup dimensions xy to get position directly froem globalId +// Then store using textureStore +// Check within bounds due to overdispatching + +@compute @workgroup_size(256, 1, 1) +fn main(@builtin(global_invocation_id) globalId : vec3<u32>) { + let imageSize = vec2<f32>(uniforms.width * uniforms.tilesX, uniforms.height * uniforms.tilesY); + let tileSize = vec2<f32>(uniforms.width, uniforms.height); + + // TODO: Is additional noise when tiling due to sdf iterations (try non-sdf), texel offsets, (size - 1) issues, overdispatching? + + // Tex coords [0,1] + // let id = f32(globalId.x); + // TODO: Divide by (imageSize.x - 1) + // let v = floor(id / imageSize.x); + // let u = (id - v * imageSize.x); + // let uv = vec2<f32>(u, v); + // let texCoord = uv / imageSize; + + // Pixel coords ([0,width-1], [0,height-1]) + let id = f32(globalId.x); + let tilePixelY = floor(id / tileSize.x); + let tilePixelX = id - tilePixelY * tileSize.x; + let imagePixelX = tilePixelX + uniforms.tileOffsetX * tileSize.x; + let imagePixelY = tilePixelY + uniforms.tileOffsetY * tileSize.y; + + // Tex coords ([0,1], [0,1]) + let texCoord = vec2<f32>(imagePixelX / imageSize.x, imagePixelY / imageSize.y); + + // Camera + var camera = getCamera(uniforms); + + // Frame seed + var frameSeed = u32(uniforms.seed); + let raysPerFrame = u32(uniforms.raysPerFrame); + var color = vec3<f32>(0f, 0f, 0f); + var depth = 0f; + var normal = vec3<f32>(0f, 0f, 0f); + var seed: u32; + + for (var i = 0u; i < raysPerFrame; i = i + 1u) { + // Random number generator + // See https://nelari.us/post/weekend_raytracing_with_wgpu_1/#implement-a-random-number-generator + // fn initRng(pixel: vec2<u32>, resolution: vec2<u32>, frame: u32) -> u32 { + // // Adapted from https://github.com/boksajak/referencePT + // let seed = dot(pixel, vec2<u32>(1u, resolution.x)) ^ jenkinsHash(frame); + // return jenkinsHash(seed); + // } + // + // fn jenkinsHash(input: u32) -> u32 { + // var x = input; + // x += x << 10u; + // x ^= x >> 6u; + // x += x << 3u; + // x ^= x >> 11u; + // x += x << 15u; + // return x; + // } + // TODO: Consider switching to u32 for uniforms and use vec3<u32> arithmetic + seed = u32(tilePixelY * tileSize.x + tilePixelX) + frameSeed * u32(tileSize.x * tileSize.y); + + // Sample position (sub-pixel sampling has same seed, but only sampled once per frame) + let samplePos = vec2<f32>(texCoord) + vec2<f32>(random(&seed), random(&seed)) / imageSize; + + // Ray + var ray = getCameraRay(camera, &seed, samplePos); + + // Color [0,1] + // let color = result.color; + // let color = clamp(result.color, vec3<f32>(0f, 0f, 0f), vec3<f32>(1f, 1f, 1f)); + // let color = clamp(result.color, vec3<f32>(0f, 0f, 0f), vec3<f32>(10f, 10f, 10f)); // Max light + color += clamp(rayColor(&ray, &seed), vec3<f32>(0f, 0f, 0f), vec3<f32>(10f, 10f, 10f)); // Max light + + // Depth + // let depth = 1f / rayColor(&ray, &seed).depth; + // color = vec3<f32>(depth, depth, depth); + // depth += result.depth; + + // Normal + // normal += result.normal; + + // Next frame + frameSeed = frameSeed + 1u; } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -const { defaultView } = _vegaMorphcharts.defaults; -const zAxisZindex = 1010; -let didRegisterColorSchemes = false; -class Viewer { - /** - * Instantiate a new Viewer. - * @param element Parent HTMLElement to present within. - * @param options Optional viewer options object. - */ constructor(element, options){ - this.element = element; - this.options = _vegaMorphcharts.util.deepMerge((0, _defaults.defaultViewerOptions), options); - this.presenter = new _vegaMorphcharts.Presenter(element, (0, _defaults.getPresenterStyle)(this.options)); - //this.presenter.logger = console.log; - this._characterSet = new (0, _characterSet.CharacterSet)(); - this._dataScope = new (0, _dataScope.DataScope)(); - this._animator = new (0, _animator.Animator)(this._dataScope, { - onDataChanged: this.onDataChanged.bind(this), - onAnimateDataChange: this.onAnimateDataChange.bind(this) - }); - this._details = new (0, _details.Details)(this.presenter.getElement(_vegaMorphcharts.PresenterElement.panel), this.options.language, this._animator, this._dataScope, (remap)=>{ - this.currentColorContext = ~~remap; - this.renderSameLayout(); - }, ()=>this.insight && this.insight.columns && !!this.insight.columns.color && this.colorContexts && this.colorContexts.length > 1); - this.insight = {}; + let index = globalId.x * 3u; + outputColorBuffer.values[index + 0u] = outputColorBuffer.values[index + 0u] + color.x; + outputColorBuffer.values[index + 1u] = outputColorBuffer.values[index + 1u] + color.y; + outputColorBuffer.values[index + 2u] = outputColorBuffer.values[index + 2u] + color.z; + // outputDepthBuffer.values[globalId.x] = outputDepthBuffer.values[globalId.x] + depth; + // outputNormalBuffer.values[index + 0u] = outputNormalBuffer.values[index + 0u] + normal.x; + // outputNormalBuffer.values[index + 1u] = outputNormalBuffer.values[index + 1u] + normal.y; + // outputNormalBuffer.values[index + 2u] = outputNormalBuffer.values[index + 2u] + normal.z; +}`; +class ComputeUniformBufferData extends Float32Array { + constructor(){ + super(ComputeUniformBufferData.SIZE); + this.POSITION_OFFSET = 0; + this.WIDTH_OFFSET = 3; + this.RIGHT_OFFSET = 4; + this.HEIGHT_OFFSET = 7; + this.UP_OFFSET = 8; + this.SEED_OFFSET = 11; + this.FORWARD_OFFSET = 12; + this.FOV_OFFSET = 15; + this.LOOKAT_OFFSET = 16; + this.APERTURE_OFFSET = 19; + this.BACKGROUND_COLOR_OFFSET = 20; + this.TIME0_OFFSET = 23; + this.TIME1_OFFSET = 24; + this.TILES_X = 25; + this.TILES_Y = 26; + this.TILE_OFFSET_X = 27; + this.TILE_OFFSET_Y = 28; + this.RAYS_PER_FRAME_OFFSET = 29; } - changeColorContexts(colorContexts) { - this.colorContexts = colorContexts; - this.currentColorContext = 0; - this.options.onColorContextChange && this.options.onColorContextChange(); + getWidth() { + return this[this.WIDTH_OFFSET]; } - applyLegendColorContext(colorContext) { - const a = _vegaMorphcharts.util.getActiveElementInfo(); - _vegaMorphcharts.util.mount(colorContext.legendElement, this.presenter.getElement(_vegaMorphcharts.PresenterElement.legend)); - _vegaMorphcharts.util.setActiveElement(a); - this.presenter.stage.legend = colorContext.legend; + setWidth(value) { + this[this.WIDTH_OFFSET] = value; } - onAnimateDataChange(dataChange, waitingLabel, handlerLabel, time) { - var _a; - if (time === undefined) { - const transitionDurations = ((_a = this.setup) === null || _a === void 0 ? void 0 : _a.transitionDurations) || _vegaMorphcharts.defaults.defaultPresenterConfig.transitionDurations; - time = transitionDurations.position + transitionDurations.stagger; - } - return new Promise((resolve, reject)=>{ - let innerPromise; - if (dataChange === (0, _animator.DataLayoutChange).refine) { - const oldColorContext = this.colorContexts[this.currentColorContext]; - innerPromise = new Promise((innerResolve)=>{ - this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { - preStage: (stage, cubeLayer)=>{ - (0, _legend.finalizeLegend)(this.insight.colorBin, this._specColumns.color, stage.legend, this.options.language); - this.overrideAxisLabels(stage); - cubeLayer.unitColorMap = oldColorContext.colorMap; - if (this.options.onStage) this.options.onStage(stage); - } - })).then(()=>{ - //apply old legend - this.applyLegendColorContext(oldColorContext); - innerResolve(); - }); - }); - } else innerPromise = this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { - preStage: (stage, colorMapper)=>{ - (0, _legend.finalizeLegend)(this.insight.colorBin, this._specColumns.color, stage.legend, this.options.language); - this.overrideAxisLabels(stage); - if (this.options.onStage) this.options.onStage(stage); - } - })); - innerPromise.then(()=>{ - this.presenter.animationQueue(resolve, time, { - waitingLabel, - handlerLabel, - animationCanceled: reject - }); - }); - }); + getHeight() { + return this[this.HEIGHT_OFFSET]; } - onDataChanged(dataLayout, filter) { - return __awaiter(this, void 0, void 0, function*() { - switch(dataLayout){ - case (0, _animator.DataLayoutChange).same: - { - const hasSelectedData = this._dataScope.hasSelectedData(); - const hasActive = !!this._dataScope.active; - if (hasSelectedData || hasActive) this.presenter.morphChartsRenderResult.update({ - cubes: this.convertSearchToSet() - }); - else this.presenter.morphChartsRenderResult.update({ - cubes: null - }); - break; - } - case (0, _animator.DataLayoutChange).refine: - { - //save cube colors - const oldColorContext = this.colorContexts[this.currentColorContext]; - let colorMap; - this.presenter.morphChartsRenderResult.update({ - cubes: null - }); - yield this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { - preStage: (stage, cubeLayer)=>{ - //save off the spec colors - colorMap = cubeLayer.unitColorMap; - cubeLayer.unitColorMap = oldColorContext.colorMap; - this.preStage(stage, cubeLayer); - }, - onPresent: ()=>{ - //save new legend - const newColorContext = { - colorMap, - legend: _vegaMorphcharts.util.clone(this.presenter.stage.legend), - legendElement: this.presenter.getElement(_vegaMorphcharts.PresenterElement.legend).children[0] - }; - //apply old legend - this.applyLegendColorContext(oldColorContext); - this.changeColorContexts([ - oldColorContext, - newColorContext - ]); - this.onPresent(); - } - })); - //narrow the filter only if it is different - if (!_searchExpression.compare(this.insight.filter, filter)) this.insight.filter = _searchExpression.narrow(this.insight.filter, filter); - if (this.options.onDataFilter) this.options.onDataFilter(this.insight.filter, this._dataScope.currentData()); - break; - } - case (0, _animator.DataLayoutChange).reset: - { - const colorContext = { - colorMap: null, - legend: null, - legendElement: null - }; - this.changeColorContexts([ - colorContext - ]); - this.presenter.morphChartsRenderResult.update({ - cubes: null - }); - yield this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { - onPresent: ()=>{ - //color needs to change instantly - (0, _colorCubes.populateColorContext)(colorContext, this.presenter); - this.onPresent(); - } - })); - delete this.insight.filter; - if (this.options.onDataFilter) this.options.onDataFilter(null, null); - break; - } - } - if (this.options.onSelectionChanged) { - const sel = this.getSelection(); - this.options.onSelectionChanged(sel && sel.search || null, 0, sel && sel.selectedData || null); - } - }); + setHeight(value) { + this[this.HEIGHT_OFFSET] = value; } - convertSearchToSet() { - if (this._dataScope.selection) { - const s = new Set(); - let found = false; - this._dataScope.selection.included.forEach((o, i)=>{ - s.add(o[0, _constants.GL_ORDINAL]); - found = true; - }); - if (!found) s.add(-1); - return s; - } + getSeed() { + return this[this.SEED_OFFSET]; } - convertSetToSearch(s) { - const search = { - expressions: [] - }; - s.forEach((value)=>{ - search.expressions.push({ - name: (0, _constants.GL_ORDINAL), - operator: "==", - value, - clause: "||" - }); - }); - return search; + setSeed(value) { + this[this.SEED_OFFSET] = value; } - getSpecColumnsWithFilteredStats() { - if (!this._dataScope.hasFilteredData()) return this._specColumns; - const roles = [ - "color", - "facet", - "group", - "size", - "sort", - "sum", - "x", - "y", - "z" - ]; - const specColumns = Object.assign({}, this._specColumns); - roles.forEach((r)=>{ - if (specColumns[r]) { - const column = Object.assign({}, specColumns[r]); - column.stats = this.getColumnStats(column); - specColumns[r] = column; - } - }); - return specColumns; + getRaysPerFrame() { + return this[this.RAYS_PER_FRAME_OFFSET]; } - renderNewLayout(signalValues, presenterConfig, view) { - return __awaiter(this, void 0, void 0, function*() { - const currData = this._dataScope.currentData(); - const context = { - specColumns: this.getSpecColumnsWithFilteredStats(), - insight: this.insight, - specViewOptions: Object.assign(Object.assign({}, this.options), { - zAxisOptions: { - showZAxis: true, - zIndex: zAxisZindex - }, - collapseFacetAxes: true - }) - }; - const specResult = (0, _sanddanceSpecs.build)(context, currData); - if (!specResult.errors) { - const uiValues = (0, _signals.extractSignalValuesFromView)(this.vegaViewGl, this.vegaSpec); - (0, _signals.applySignalValues)(Object.assign(Object.assign({}, uiValues), signalValues), specResult.vegaSpec); - (0, _signals.unbindSignalUI)(specResult.vegaSpec); - this.vegaSpec = specResult.vegaSpec; - this.options.onVegaSpec && this.options.onVegaSpec(this.vegaSpec); - this.specCapabilities = specResult.specCapabilities; - const config = this.createConfig(presenterConfig); - this._lastPresenterConfig = config.presenterConfig; - if (view) config.getView = ()=>view; - if (!didRegisterColorSchemes) { - (0, _colorSchemes.registerColorSchemes)(_vegaMorphcharts.base.vega); - didRegisterColorSchemes = true; - } - try { - if (this.vegaViewGl) this.vegaViewGl.finalize(); - const runtime = _vegaMorphcharts.base.vega.parse(this.vegaSpec); - this.vegaViewGl = new _vegaMorphcharts.ViewGl(runtime, config).renderer("morphcharts").initialize(this.element); - yield this.vegaViewGl.runAsync(); - const handler = (n, v)=>{ - this._characterSet.resetCharacterSet(true); - }; - this.vegaSpec.signals.forEach((s)=>{ - this.vegaViewGl.addSignalListener(s.name, handler); - }); - //capture new color color contexts via signals - this.configForSignalCapture(config.presenterConfig); - } catch (e) { - specResult.errors = [ - e.message - ]; - } - if (!specResult.errors) (0, _headers.ensureHeaders)(this.presenter, this.options.language.headers); - } - if (specResult.errors) { - if (this.options.onError) this.options.onError(specResult.errors); - else if (this.presenter.logger) this.presenter.logger(`errors rendering Vega spec:${specResult.errors.join("\n")}`); - } - return specResult; - }); + setRaysPerFrame(value) { + this[this.RAYS_PER_FRAME_OFFSET] = value; } - /** - * Render the same layout with new options. - * @param newViewerOptions New options object. - */ renderSameLayout(newViewerOptions) { - const colorContext = this.colorContexts[this.currentColorContext]; - this.applyLegendColorContext(colorContext); - if (newViewerOptions) { - if (newViewerOptions.colors) { - //set theme colors PresenterConfig - const mcColors = this.getMorphChartsColors(); - this.presenter.configColors(mcColors); - this._lastPresenterConfig.morphChartsColors = mcColors; - } - this.options = _vegaMorphcharts.util.deepMerge(this.options, newViewerOptions); - } - this.presenter.morphChartsRenderResult.getCubeLayer().unitColorMap = colorContext.colorMap; - this.presenter.morphChartsRenderResult.update({ - cubes: this.convertSearchToSet() - }); + getFieldOfView() { + return this[this.FOV_OFFSET]; } - getView(view) { - if (view === undefined) { - if (this.presenter.view === null) return defaultView; - else return this.presenter.view; - } else return view; + setFieldOfView(value) { + this[this.FOV_OFFSET] = value; } - transformData(values, transform) { - try { - const runtime = _vegaMorphcharts.base.vega.parse({ - $schema: "https://vega.github.io/schema/vega/v4.json", - data: [ - { - name: "source", - values, - transform - } - ] - }); - new _vegaMorphcharts.ViewGl(runtime).run(); - } catch (e) { - // continue regardless of error - } - return values; + getAperture() { + return this[this.APERTURE_OFFSET]; } - /** - * Render data into a visualization. - * @param insightSetup InsightSetup object to create a visualization rendering. - * @param data Array of data objects. - * @param renderOptions Optional RenderOptions object. - */ render(insightSetup, data, renderOptions = {}) { - return __awaiter(this, void 0, void 0, function*() { - const { insight , setup } = insightSetup; - let result; - //see if refine expression has changed - if (!_searchExpression.compare(insight.filter, this.insight.filter)) { - const transitionDurations = (setup === null || setup === void 0 ? void 0 : setup.transitionDurations) || _vegaMorphcharts.defaults.defaultPresenterConfig.transitionDurations; - const renderTime = transitionDurations.position + transitionDurations.stagger; - const allowAsyncRenderTime = renderTime + this.options.filterRenderingTimerPadding; - if (insight.filter) { - //refining - result = yield this._render(insightSetup, data, renderOptions, true); - this.presenter.animationQueue(()=>{ - this.filter(insight.filter, renderOptions.rebaseFilter && renderOptions.rebaseFilter()); - }, allowAsyncRenderTime, { - waitingLabel: "layout before refine", - handlerLabel: "refine after layout" - }); - } else { - //not refining - this._dataScope.setFilteredData(null); - result = yield this._render(insightSetup, data, renderOptions, true); - this.presenter.animationQueue(()=>{ - this.reset(); - }, allowAsyncRenderTime, { - waitingLabel: "layout before reset", - handlerLabel: "reset after layout" - }); - } - } else result = yield this._render(insightSetup, data, renderOptions, false); - return result; - }); + setAperture(value) { + this[this.APERTURE_OFFSET] = value; } - shouldViewstateTransition(newInsight, oldInsight) { - if (!oldInsight.columns) return false; - if (oldInsight.chart !== newInsight.chart) return true; - if (oldInsight.size.height !== newInsight.size.height) return true; - if (oldInsight.size.width !== newInsight.size.width) return true; - if (oldInsight.columns.facet !== newInsight.columns.facet) return true; - return false; + getPosition(value) { + (0, _glMatrix.vec3).set(value, this[this.POSITION_OFFSET], this[this.POSITION_OFFSET + 1], this[this.POSITION_OFFSET + 2]); } - configForSignalCapture(presenterConfig) { - const colorContext = { - colorMap: null, - legend: null, - legendElement: null - }; - //now be ready to capture color changing signals - presenterConfig.preStage = (stage, cubeLayer)=>{ - if (this._shouldSaveColorContext()) //save off the colors from Vega layout - colorContext.colorMap = cubeLayer.unitColorMap; - this.preStage(stage, cubeLayer); - }; - presenterConfig.onPresent = ()=>{ - if (this._shouldSaveColorContext()) { - (0, _colorCubes.populateColorContext)(colorContext, this.presenter); - this.changeColorContexts([ - colorContext - ]); - this._dataScope.deselect(); - } - this.onPresent(); - }; + setPosition(value) { + this[this.POSITION_OFFSET] = value[0]; + this[this.POSITION_OFFSET + 1] = value[1]; + this[this.POSITION_OFFSET + 2] = value[2]; } - onPresent() { - var _a; - if ((_a = this.setup) === null || _a === void 0 ? void 0 : _a.transition) (0, _transition.assignTransitionStagger)(this.setup.transition, this._dataScope.currentData(), this.convertSearchToSet(), this.presenter); - this.options.onPresent && this.options.onPresent(); + getRight(value) { + (0, _glMatrix.vec3).set(value, this[this.RIGHT_OFFSET], this[this.RIGHT_OFFSET + 1], this[this.RIGHT_OFFSET + 2]); } - _render(insightSetup, data, renderOptions, forceNewCharacterSet) { - return __awaiter(this, void 0, void 0, function*() { - const { insight , setup } = insightSetup; - if (this._tooltip) { - this._tooltip.destroy(); - this._tooltip = null; - } - if (this._dataScope.setData(data, renderOptions.columns)) //apply transform to the data - this.transformData(data, insight.transform); - this._specColumns = (0, _sanddanceSpecs.getSpecColumns)(insight, this._dataScope.getColumns(renderOptions.columnTypes)); - const ordinalMap = (0, _ordinal.assignOrdinals)(this._specColumns, data, renderOptions.ordinalMap); - this._characterSet.resetCharacterSet(forceNewCharacterSet, this.insight, insight); - this.insight = _vegaMorphcharts.util.clone(insight); - this.setup = setup; - this._shouldSaveColorContext = ()=>!renderOptions.initialColorContext; - const colorContext = renderOptions.initialColorContext || { - colorMap: null, - legend: null, - legendElement: null - }; - const specResult = yield this.renderNewLayout(insight.signalValues, Object.assign(Object.assign({}, setup || {}), { - preStage: (stage, cubeLayer)=>{ - if (this._shouldSaveColorContext()) //save off the colors from Vega layout - colorContext.colorMap = cubeLayer.unitColorMap; - else //apply passed colorContext - cubeLayer.unitColorMap = colorContext.colorMap; - //if items are selected, repaint - const hasSelectedData = !!this._dataScope.hasSelectedData(); - hasSelectedData || this._dataScope.active; - this.preStage(stage, cubeLayer); - }, - onPresent: ()=>{ - if (this._shouldSaveColorContext()) { - (0, _colorCubes.populateColorContext)(colorContext, this.presenter); - this.changeColorContexts([ - colorContext - ]); - } else //apply passed colorContext - this.applyLegendColorContext(colorContext); - this.onPresent(); - }, - shouldViewstateTransition: ()=>this.shouldViewstateTransition(insight, this.insight) - }), this.getView(insight.view)); - //future signal changes should save the color context - this._shouldSaveColorContext = ()=>!renderOptions.discardColorContextUpdates || !renderOptions.discardColorContextUpdates(); - this._details.render(); - const result = { - ordinalMap, - specResult - }; - return result; - }); - } - overrideAxisLabels(stage) { - // if (this._specColumns.x && this._specColumns.x.type === 'date') { - // stage.axes.x.forEach(axis => makeDateRange( - // axis.tickText, - // this.getColumnStats(this._specColumns.x) - // )); - // } - // if (this._specColumns.y && this._specColumns.y.type === 'date') { - // stage.axes.y.forEach(axis => makeDateRange( - // axis.tickText, - // this.getColumnStats(this._specColumns.y) - // )); - // } - } - preLayer(stage) { - //convert ticks - let axisRole; - for(axisRole in stage.axes){ - const capability = this.specCapabilities.roles.filter((r)=>r.role === axisRole)[0]; - if (capability && (capability.axisSelectionBetweenTicks || capability.axisSelection === "exact")) (0, _axisSelection.moveTicksBetween)(stage.axes[axisRole]); - } + setRight(value) { + this[this.RIGHT_OFFSET] = value[0]; + this[this.RIGHT_OFFSET + 1] = value[1]; + this[this.RIGHT_OFFSET + 2] = value[2]; } - preStage(stage, cubeLayer) { - this.overrideAxisLabels(stage); - this._axisSelection = new (0, _axisSelection.AxisSelection)(this.specCapabilities, this._specColumns, stage); - (0, _legend.finalizeLegend)(this.insight.colorBin, this._specColumns.color, stage.legend, this.options.language); - if (this.options.onStage) this.options.onStage(stage); + getUp(value) { + (0, _glMatrix.vec3).set(value, this[this.UP_OFFSET], this[this.UP_OFFSET + 1], this[this.UP_OFFSET + 2]); } - onCubeClick(e, cube) { - this.options.onCubeClick && this.options.onCubeClick(e, cube); - const hasSelectedData = this._dataScope.hasSelectedData(); - if (hasSelectedData && this._dataScope.selection.included.length > 1) { - //if active is within selection, keep the selection and activate the one. - const indexWithinSelection = this._dataScope.ordinalIndexWithinSelection(cube.ordinal); - if (indexWithinSelection.index >= 0) { - this.activate(indexWithinSelection.datum); - this._details.populate(this._dataScope.selection, indexWithinSelection.index); - if (this.options.onSelectionChanged) { - const sel = this.getSelection(); - this.options.onSelectionChanged(sel.search, indexWithinSelection.index, sel.selectedData); - } - return; - } - } - if (hasSelectedData && this._dataScope.selection.included.length === 1 && this._dataScope.selection.included[0][0, _constants.GL_ORDINAL] === cube.ordinal) { - this.deselect(); - return; - } - const search = { - name: (0, _constants.GL_ORDINAL), - operator: "==", - value: cube.ordinal - }; - this.select(search); + setUp(value) { + this[this.UP_OFFSET] = value[0]; + this[this.UP_OFFSET + 1] = value[1]; + this[this.UP_OFFSET + 2] = value[2]; } - onCubeHover(event, cube) { - var _a, _b; - if (this._tooltip) { - this._tooltip.destroy(); - this._tooltip = null; - } - if (!cube) return; - const currentData = this._dataScope.currentData(); - const index = (0, _ordinal.getDataIndexOfCube)(cube, currentData); - if (index >= 0) { - const dataItem = (0, _tooltip.cleanDataItem)(((_a = this.options.tooltipOptions) === null || _a === void 0 ? void 0 : _a.prepareDataItem(currentData[index])) || currentData[index]); - const tooltipCreateOptions = { - dataItem, - event - }; - if ((_b = this.options.tooltipOptions) === null || _b === void 0 ? void 0 : _b.create) this._tooltip = this.options.tooltipOptions.create(tooltipCreateOptions); - else this._tooltip = new (0, _tooltip.Tooltip)(Object.assign(Object.assign({}, tooltipCreateOptions), { - cssPrefix: this.presenter.style.cssPrefix - })); - } + getForward(value) { + (0, _glMatrix.vec3).set(value, this[this.FORWARD_OFFSET], this[this.FORWARD_OFFSET + 1], this[this.FORWARD_OFFSET + 2]); } - onTextHover(e, t) { - //return true if highlight color is different - if (!t || !this.options.getTextColor || !this.options.getTextHighlightColor) return false; - return !_vegaMorphcharts.util.colorIsEqual(this.options.getTextColor(t), this.options.getTextHighlightColor(t)); + setForward(value) { + this[this.FORWARD_OFFSET] = value[0]; + this[this.FORWARD_OFFSET + 1] = value[1]; + this[this.FORWARD_OFFSET + 2] = value[2]; } - getMorphChartsColors() { - const { colors } = this.options; - return { - activeItemColor: colors.activeCube, - axesGridBackgroundColor: colors.backgroundColor, - axesGridHighlightColor: colors.axisSelectHighlight, - axesGridMajorColor: colors.gridLine, - axesGridMinorColor: colors.gridLine, - axesGridZeroColor: colors.gridLine, - axesTextHeadingColor: colors.axisText, - axesTextLabelColor: colors.axisText, - axesTextTitleColor: colors.axisText, - backgroundColor: colors.backgroundColor, - textBorderColor: colors.backgroundColor, - textColor: colors.axisText - }; + getLookAt(value) { + (0, _glMatrix.vec3).set(value, this[this.LOOKAT_OFFSET], this[this.LOOKAT_OFFSET + 1], this[this.LOOKAT_OFFSET + 2]); } - createConfig(c) { - var _a; - const { getTextColor , getTextHighlightColor , onTextClick } = this.options; - const defaultPresenterConfig = { - morphChartsColors: this.getMorphChartsColors(), - zAxisZindex, - getCharacterSet: (stage)=>this._characterSet.getCharacterSet(stage), - getTextColor, - getTextHighlightColor, - onTextClick: (e, t)=>{ - if (t.metaData && t.metaData.search) { - //used by facets to select the facet - const search = (0, _search.getSearchGroupFromVegaValue)(t.metaData.search); - if (this.options.onAxisClick) this.options.onAxisClick(e, search); - else this.select(search); - } - if (onTextClick) onTextClick(e, t); - }, - onCubeClick: this.onCubeClick.bind(this), - onCubeHover: this.onCubeHover.bind(this), - onTextHover: this.onTextHover.bind(this), - preLayer: this.preLayer.bind(this), - preStage: this.preStage.bind(this), - onPresent: this.onPresent.bind(this), - onAxisConfig: (cartesian, dim3d, axis)=>{ - if (!axis) return; - const role = this.specCapabilities.roles.filter((r)=>r.role === axis.axisRole)[0]; - if (role === null || role === void 0 ? void 0 : role.axisSelection) { - cartesian.isDivisionPickingEnabled[dim3d] = true; - cartesian.arePickDivisionsVisible[dim3d] = axis.tickText.length > 0; - cartesian.isLabelPickingEnabled[dim3d] = true; - cartesian.isTitlePickingEnabled[dim3d] = true; - cartesian.isHeadingPickingEnabled[dim3d] = true; - cartesian.isGridPickingEnabled = false; - } - }, - onAxesComplete: (cartesian)=>{}, - axisPickGridCallback: (divisions, e)=>{ - const search = this._axisSelection.convert(divisions); - if (this.options.onAxisClick) this.options.onAxisClick(e, search); //TODO change onAxisClick to accept Search - else this.select(search); - }, - onLayerClick: (e)=>{ - this.options.onCanvasClick && this.options.onCanvasClick(e); - this.deselect(); - }, - onLegendClick: (e, legend, clickedIndex)=>{ - const legendRow = clickedIndex !== null && legend.rows[clickedIndex]; - if (legendRow) { - if (this.options.onLegendRowClick) this.options.onLegendRowClick(e, legendRow); - else this.select(legendRow.search); - } else if (this.options.onLegendHeaderClick) //header clicked - this.options.onLegendHeaderClick(e); - }, - onSceneRectAssignCubeOrdinal: (datum)=>{ - //TODO see if datum is a facet selection rect - return datum[0, _constants.GL_ORDINAL]; - }, - onTargetViewState: (h, w)=>{ - const { height , width } = this.insight.size; - let newViewStateTarget; - if (this.options.onNewViewStateTarget) newViewStateTarget = this.options.onNewViewStateTarget(); - return { - height, - width, - newViewStateTarget - }; - }, - layerSelection: { - cubes: this.convertSearchToSet() - }, - preserveDrawingBuffer: this.options.preserveDrawingBuffer - }; - if (!this.options.disableLasso) defaultPresenterConfig.onLasso = (ids, e)=>{ - this.deselect(); - const search = this.convertSetToSearch(ids); - this.select(search); - }; - if (this.options.onBeforeCreateLayers) defaultPresenterConfig.preLayer = (stage)=>{ - this.preLayer(stage); - this.options.onBeforeCreateLayers(stage, this.specCapabilities); - }; - const config = { - presenter: this.presenter, - presenterConfig: Object.assign(defaultPresenterConfig, c) - }; - if ((_a = this.setup) === null || _a === void 0 ? void 0 : _a.transitionDurations) config.presenterConfig.transitionDurations = this.setup.transitionDurations; - return config; + setLookAt(value) { + this[this.LOOKAT_OFFSET] = value[0]; + this[this.LOOKAT_OFFSET + 1] = value[1]; + this[this.LOOKAT_OFFSET + 2] = value[2]; } - /** - * Filter the data and animate. - * @param search Filter expression, see https://vega.github.io/vega/docs/expressions/ - * @param rebase Optional flag to apply to entire dataset. A false value will apply the filter upon any existing filter. - */ filter(search, rebase = false) { - const u = this._dataScope.createUserSelection(search, false, rebase); - return new Promise((resolve, reject)=>{ - this._animator.filter(search, u.included, u.excluded, rebase).then(()=>{ - this._details.clear(); - this._details.clearSelection(); - this._details.populate(this._dataScope.selection); - resolve(); - }); - }); + getBackgroundColor(value) { + (0, _glMatrix.vec4).set(value, this[this.BACKGROUND_COLOR_OFFSET], this[this.BACKGROUND_COLOR_OFFSET + 1], this[this.BACKGROUND_COLOR_OFFSET + 2], 1); } - /** - * Remove any filtration and animate. - */ reset() { - return new Promise((resolve, reject)=>{ - this._animator.reset().then(()=>{ - this._details.clear(); - this._details.clearSelection(); - resolve(); - }); - }); + setBackgroundColor(value) { + this[this.BACKGROUND_COLOR_OFFSET] = value[0]; + this[this.BACKGROUND_COLOR_OFFSET + 1] = value[1]; + this[this.BACKGROUND_COLOR_OFFSET + 2] = value[2]; } - /** - * Select cubes by a filter expression. - * @param search Filter expression, see https://vega.github.io/vega/docs/expressions/ - */ select(search) { - return new Promise((resolve, reject)=>{ - this._animator.select(search).then(()=>{ - this._details.populate(this._dataScope.selection); - resolve(); - }); - }); + getTime0() { + return this[this.TIME0_OFFSET]; } - /** - * Removes any selection. - */ deselect() { - return new Promise((resolve, reject)=>{ - this._animator.deselect().then(()=>{ - this._details.clearSelection(); - resolve(); - }); - }); + setTime0(value) { + this[this.TIME0_OFFSET] = value; } - /** - * Gets the current selection. - */ getSelection() { - if (!this._dataScope) return null; - const selectionState = { - search: this._dataScope.selection && this._dataScope.selection.search || null, - selectedData: this._dataScope.selection && this._dataScope.selection.included || null, - active: this._dataScope.active - }; - return selectionState; + getTime1() { + return this[this.TIME1_OFFSET]; } - /** - * Set one data row to the active state. - */ activate(datum) { - return new Promise((resolve, reject)=>{ - this._animator.activate(datum).then(()=>{ - this.presenter.morphChartsRenderResult.activate(datum[0, _constants.GL_ORDINAL]); - this._details.render(); - resolve(); - }); - }); + setTime1(value) { + this[this.TIME1_OFFSET] = value; } - /** - * Deactivate item. - */ deActivate() { - return new Promise((resolve, reject)=>{ - if (this._dataScope && this._dataScope.active) this._animator.deactivate().then(()=>{ - this.presenter.morphChartsRenderResult.activate(-1); - this._details.render(); - resolve(); - }); - else resolve(); - }); + getTilesX() { + return this[this.TILES_X]; } - /** - * Gets the current camera. - * @param transitionFinal Optional flag to get camera destination when transition completes. - */ getCamera(transitionFinal = false) { - var _a, _b, _c, _d, _e, _f, _g; - let position = [ - 0, - 0, - 0 - ]; - let rotation = [ - 0, - 0, - 0, - 0 - ]; - if (transitionFinal) { - position = Array.from((_b = (_a = this.presenter) === null || _a === void 0 ? void 0 : _a.morphchartsref) === null || _b === void 0 ? void 0 : _b.cameraTransitioner.vPosition.to); - rotation = Array.from((_d = (_c = this.presenter) === null || _c === void 0 ? void 0 : _c.morphchartsref) === null || _d === void 0 ? void 0 : _d.cameraTransitioner.qRotation.to); - } else { - const camera = (_g = (_f = (_e = this.presenter) === null || _e === void 0 ? void 0 : _e.morphchartsref) === null || _f === void 0 ? void 0 : _f.core) === null || _g === void 0 ? void 0 : _g.camera; - if (camera) { - camera.getPosition(position); - camera.getOrbit(rotation); - } - } - return { - position, - rotation, - captureSize: this.insight.size - }; + setTilesX(value) { + this[this.TILES_X] = value; } - /** - * Sets the current camera. - * @param camera Camera to set. - */ setCamera(camera) { - var _a, _b; - if (camera) (_b = (_a = this.presenter) === null || _a === void 0 ? void 0 : _a.morphChartsRenderResult) === null || _b === void 0 || _b.moveCamera(camera); + getTilesY() { + return this[this.TILES_Y]; } - /** - * Gets the current insight with signal values. - */ getInsight() { - const insight = Object.assign({}, this.insight); - insight.signalValues = this.getSignalValues(); - return insight; + setTilesY(value) { + this[this.TILES_Y] = value; } - /** - * Gets column stats from current data (filtered or all). - * @param column Column to get stats for. - */ getColumnStats(column) { - return this._dataScope.hasFilteredData() ? this._dataScope.getFilteredColumnStats(column.name) : column.stats; + getTileOffsetX() { + return this[this.TILE_OFFSET_X]; } - /** - * Gets current signal values. - */ getSignalValues() { - return (0, _signals.extractSignalValuesFromView)(this.vegaViewGl, this.vegaSpec); + setTileOffsetX(value) { + this[this.TILE_OFFSET_X] = value; } - assignTransitionStagger(transition) { - (0, _transition.assignTransitionStagger)(transition, this._dataScope.currentData(), this.convertSearchToSet(), this.presenter); + getTileOffsetY() { + return this[this.TILE_OFFSET_Y]; } - finalize() { - if (this._dataScope) this._dataScope.finalize(); - if (this._details) this._details.finalize(); - if (this._tooltip) this._tooltip.destroy(); - if (this.vegaViewGl) this.vegaViewGl.finalize(); - if (this.presenter) this.presenter.finalize(); - if (this.element) this.element.innerHTML = ""; - this.colorContexts = null; - this.element = null; - this.options = null; - this.presenter = null; - this.vegaSpec = null; - this.vegaViewGl = null; - this._animator = null; - this._dataScope = null; - this._details = null; - this._tooltip = null; + setTileOffsetY(value) { + this[this.TILE_OFFSET_Y] = value; } } -/** - * Default Viewer options. - */ Viewer.defaultViewerOptions = (0, _defaults.defaultViewerOptions); +ComputeUniformBufferData.SIZE = 32; -},{"./animator":"aONCF","./axisSelection":"a3NCj","./colorCubes":"9PNtZ","./colorSchemes":"5MHBA","./constants":"ghoOR","./dataScope":"1pzB5","./defaults":"lNUGC","./details":"g9vCR","./headers":"1LQHC","./legend":"bhn8i","./ordinal":"aRxP1","./search":"dSvxZ","./signals":"iFNr3","./tooltip":"h3Rlc","@msrvida/sanddance-specs":"4hjOh","@msrvida/search-expression":"j6CcD","@msrvida/vega-morphcharts":"guKLg","./characterSet":"bXSAa","./transition":"atUZx","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aONCF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1gtMg":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DataLayoutChange", ()=>DataLayoutChange); -parcelHelpers.export(exports, "Animator", ()=>Animator); -var DataLayoutChange; -(function(DataLayoutChange) { - DataLayoutChange[DataLayoutChange["same"] = 0] = "same"; - DataLayoutChange[DataLayoutChange["reset"] = 1] = "reset"; - DataLayoutChange[DataLayoutChange["refine"] = 2] = "refine"; -})(DataLayoutChange || (DataLayoutChange = {})); -class Animator { - constructor(dataScope, props){ - this.dataScope = dataScope; - this.props = props; - } - select(search) { - return new Promise((resolve, reject)=>{ - this.dataScope.select(search); - this.props.onDataChanged(DataLayoutChange.same); - resolve(); - }); - } - deselect() { - return new Promise((resolve, reject)=>{ - this.dataScope.deselect(); - this.props.onDataChanged(DataLayoutChange.same); - resolve(); - }); - } - filter(search, keepData, collapseData, rebase) { - if (rebase) this.dataScope.collapse(false, keepData); - this.dataScope.collapse(true, collapseData); - return new Promise((resolve, reject)=>{ - this.props.onAnimateDataChange(DataLayoutChange.refine, "before refine", "refine").then(()=>{ - this.dataScope.deselect(); - this.dataScope.setFilteredData(keepData); - this.props.onDataChanged(DataLayoutChange.refine, search); - resolve(); - }).catch(reject); - }); +parcelHelpers.export(exports, "FullscreenQuadWgsl", ()=>FullscreenQuadWgsl); +parcelHelpers.export(exports, "FullscreenQuadUniformBufferData", ()=>FullscreenQuadUniformBufferData); +const FullscreenQuadWgsl = ` +const GAMMA = vec3<f32>(0.45454545f); // 1 / 2.2 + +struct ColorData { + data : array<f32>, +} + +struct NormalDepthData { + data : array<f32>, +} + + // offest align size +struct Uniforms { // ------------------------------ + width: f32, // 0 4 4 + height: f32, // 4 4 4 + samplesPerPixel: f32, // 8 4 4 + exposure: f32, // 12 4 4 + minDepth: f32, // 16 4 4 + maxDepth: f32, // 20 4 4 + normalEdge: f32, // 24 4 4 + depthEdge: f32, // 28 4 4 +} // ------------------------------ + // 4 32 + +@group(0) @binding(0) var<uniform> uniforms : Uniforms; +@group(0) @binding(1) var<storage, read> colorBuffer : ColorData; +@group(0) @binding(2) var<storage, read> normalDepthBuffer : NormalDepthData; + +struct VertexOutput { + @builtin(position) Position : vec4<f32>, +}; + +@vertex +fn vert_main(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput { + var pos = array<vec2<f32>, 6>( + vec2<f32>( 1f, 1f), + vec2<f32>( 1f, -1f), + vec2<f32>(-1f, -1f), + vec2<f32>( 1f, 1f), + vec2<f32>(-1f, -1f), + vec2<f32>(-1f, 1f)); + var output : VertexOutput; + output.Position = vec4<f32>(pos[vertexIndex], 0f, 1f); + return output; +} + +@fragment +fn frag_main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { + let x = floor(coord.x); + let y = floor(coord.y); + let index = u32(x + y * uniforms.width) * 3u; + // [0,1] + var color = vec3<f32>(colorBuffer.data[index + 0u], colorBuffer.data[index + 1u], colorBuffer.data[index + 2u]) / uniforms.samplesPerPixel; + // Gamma-correct + return vec4<f32>(pow(color, GAMMA), 1f); +} + +@fragment +fn frag_depth(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { + let x = floor(coord.x); + let y = floor(coord.y); + let index = u32(x + y * uniforms.width) * 4u; + let depth = normalDepthBuffer.data[index + 3u]; + let minDepth = uniforms.minDepth; + let maxDepth = uniforms.maxDepth; + if (minDepth == maxDepth) { + // Raw, unnormalized depth + return vec4<f32>(vec3<f32>(depth, depth, depth), 1f); } - reset() { - return new Promise((resolve, reject)=>{ - this.dataScope.deselect(); - let time; - if (!this.dataScope.hasFilteredData()) time = 0; - else this.dataScope.setFilteredData(null); - this.props.onAnimateDataChange(DataLayoutChange.reset, "before reset", "reset", time).then(()=>{ - this.dataScope.collapse(false); - this.props.onDataChanged(DataLayoutChange.reset); - resolve(); - }).catch(reject); - }); + else { + // Normalize depth + var normalizedDepth = (depth - minDepth) / (maxDepth - minDepth); + return vec4<f32>(normalizedDepth, normalizedDepth, normalizedDepth, 1f); } - activate(datum) { - return new Promise((resolve, reject)=>{ - this.dataScope.activate(datum); - this.props.onDataChanged(DataLayoutChange.same); - resolve(); - }); +} + +@fragment +fn frag_normal(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { + let x = floor(coord.x); + let y = floor(coord.y); + let index = u32(x + y * uniforms.width) * 4u; + return vec4<f32>(normalDepthBuffer.data[index + 0u], normalDepthBuffer.data[index + 1u], normalDepthBuffer.data[index + 2u], 1f); +} + +// @fragment +// fn frag_edge(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { +// let x = floor(coord.x); +// let y = floor(coord.y); +// let index = u32(x + y * uniforms.width) * 4u; + +// // Prevent edge detection at screen edges +// if (x == 0 || x == uniforms.width - 1 || y == 0 || y == uniforms.height - 1) { +// return vec4<f32>(0f, 0f, 0f, 1f); +// } + +// // Normal derivatives +// let p = vec3<f32>(normalDepthBuffer.data[index + 0u], normalDepthBuffer.data[index + 1u], normalDepthBuffer.data[index + 2u]); +// let px = vec3<f32>(normalDepthBuffer.data[index + 4u], normalDepthBuffer.data[index + 5u], normalDepthBuffer.data[index + 6u]); +// let py = vec3<f32>(normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 0u], normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 1u], normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 2u]); +// let dpdx = px - p; +// let dpdy = py - p; +// let fwidth = abs(dpdx) + abs(dpdy); + +// // Depth derivatives +// let d = normalDepthBuffer.data[index + 3u]; +// let dx = normalDepthBuffer.data[index + 7u]; +// let dy = normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 3u]; +// let ddpx = dx - d; +// let ddpy = dy - d; + +// // Normalize depth +// // let minDepth = uniforms.minDepth; +// // let maxDepth = uniforms.maxDepth; +// // let nd = (d - minDepth) / (maxDepth - minDepth); +// // let ndx = (dx - minDepth) / (maxDepth - minDepth); +// // let ndy = (dy - minDepth) / (maxDepth - minDepth); +// // let ddpx = ndx - nd; +// // let ddpy = ndy - nd; + +// let dfwidth = abs(ddpx) + abs(ddpy); + +// // Output white when magnitude of dpdx over a threshold +// let depthEdge = uniforms.depthEdge; +// let normalEdge = uniforms.normalEdge; +// if (dot(fwidth, fwidth) > normalEdge || dfwidth > depthEdge) { +// return vec4<f32>(1f, 1f, 1f, 1f); +// } else { +// return vec4<f32>(0f, 0f, 0f, 1f); +// } +// } + +@fragment +fn frag_edge(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { + let x = floor(coord.x); + let y = floor(coord.y); + let index = u32(x + y * uniforms.width) * 4u; + + // Prevent edge detection at screen edges + if (x == 0 || x == uniforms.width - 1 || y == 0 || y == uniforms.height - 1) { + return vec4<f32>(0f, 0f, 0f, 1f); } - deactivate() { - return new Promise((resolve, reject)=>{ - this.dataScope.deactivate(); - this.props.onDataChanged(DataLayoutChange.same); - resolve(); - }); + + // Segment derivatives + let p = vec4<f32>(normalDepthBuffer.data[index + 0u], normalDepthBuffer.data[index + 1u], normalDepthBuffer.data[index + 2u], normalDepthBuffer.data[index + 3u]); + let px = vec4<f32>(normalDepthBuffer.data[index + 4u], normalDepthBuffer.data[index + 5u], normalDepthBuffer.data[index + 6u], normalDepthBuffer.data[index + 7u]); + let py = vec4<f32>(normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 0u], normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 1u], normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 2u], normalDepthBuffer.data[index + u32(uniforms.width) * 4u + 3u]); + let dpdx = px - p; + let dpdy = py - p; + let fwidth = abs(dpdx) + abs(dpdy); + + // Output white when magnitude of dpdx over a threshold + if (dot(fwidth, fwidth) > 0f) { + return vec4<f32>(1f, 1f, 1f, 1f); + } else { + return vec4<f32>(0f, 0f, 0f, 1f); + // return p; } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"a3NCj":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AxisSelection", ()=>AxisSelection); -parcelHelpers.export(exports, "moveTicksBetween", ()=>moveTicksBetween); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _expression = require("./expression"); -const dimToRole = { - 0: "x", - 1: "y", - 2: "z" -}; -const roleToDim = { - x: 0, - y: 1, - z: 1 -}; -class AxisSelection { - constructor(specCapabilities, columns, stage){ - this.specCapabilities = specCapabilities; - this.columns = columns; - this.stage = stage; - } - convert(divisions) { - const searchRoles = []; - divisions.forEach((division, i)=>{ - const role = dimToRole[i]; - const axes = this.stage.axes[role]; - //all axes in a faceted chart should be the same - const axis = axes.filter((axis)=>axis.tickText.length)[0]; - if (axis) { - const capabilities = this.specCapabilities.roles.filter((r)=>r.role === role)[0]; - const column = this.columns[role]; - if (division >= 0 && (capabilities === null || capabilities === void 0 ? void 0 : capabilities.axisSelection)) searchRoles.push({ - axis, - role, - capabilities, - column, - division - }); - } - }); - switch(searchRoles.length){ - case 0: - return null; - case 1: - return this.getSearchFromSearchRole(searchRoles[0]); - default: - { - const roles = searchRoles.map((searchRole)=>this.getSearchFromSearchRole(searchRole)); - roles.forEach((role, i)=>{ - if (i === 0) return; - role.clause = "&&"; - }); - return roles; - } - } - } - getSearchFromSearchRole(searchRole) { - const getSearch = searchRole.capabilities.axisSelection === "exact" ? (a, c, i)=>({ - expressions: [ - (0, _expression.selectExactAxis)(a, c, i) - ] - }) : (0, _expression.selectBetweenAxis); - const { axis , column , division } = searchRole; - return getSearch(axis, column, division); - } -} -function moveTicksBetween(axes) { - axes.forEach((axis)=>{ - if (axis.ticks.length === 0) return; - const dim = roleToDim[axis.axisRole]; - const { color } = axis.ticks[0]; - const newLine = (value)=>{ - const line = { - sourcePosition: [ - 0, - 0, - 0 - ], - targetPosition: [ - 0, - 0, - 0 - ], - color - }; - line.sourcePosition[dim] = value; - return line; - }; - const newTicks = []; - newTicks.push(newLine(axis.domain.sourcePosition[dim])); - for(let i = 1; i < axis.ticks.length; i++)newTicks.push(newLine((axis.ticks[i].sourcePosition[dim] + axis.ticks[i - 1].sourcePosition[dim]) / 2)); - newTicks.push(newLine(axis.domain.targetPosition[dim])); - axis.ticks = newTicks; - }); +@fragment +fn frag_segment(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { + let x = floor(coord.x); + let y = floor(coord.y); + let index = u32(x + y * uniforms.width) * 4u; + return vec4<f32>(normalDepthBuffer.data[index + 0u], normalDepthBuffer.data[index + 1u], normalDepthBuffer.data[index + 2u], 1f); } -},{"./expression":"lR8EB","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lR8EB":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ parcelHelpers.export(exports, "notNice", ()=>notNice); -parcelHelpers.export(exports, "selectNullOrEmpty", ()=>selectNullOrEmpty); -parcelHelpers.export(exports, "selectExact", ()=>selectExact); -parcelHelpers.export(exports, "selectNone", ()=>selectNone); -parcelHelpers.export(exports, "selectExactAxis", ()=>selectExactAxis); -parcelHelpers.export(exports, "selectBetween", ()=>selectBetween); -parcelHelpers.export(exports, "selectBetweenAxis", ()=>selectBetweenAxis); -function notNice(niceValue) { - //convert "nice" numbers to numeric value - return (niceValue + "").replace(/[\s,]/g, ""); -} -function tickValue(axis, i) { - const tick = axis.tickText[i]; - let value; - if (tick) value = axis.tickText[i].value; - return { - tick, - value - }; -} -function selectNullOrEmpty(column) { - const searchExpression = { - name: column.name, - operator: "isnullorEmpty" - }; - return searchExpression; -} -function selectExact(column, value) { - if (value == null) return selectNullOrEmpty(column); - const searchExpression = { - name: column.name, - operator: "==", - value - }; - return searchExpression; -} -function selectNone(column, values) { - const expressions = values.map((value, i)=>{ - const searchExpression = { - name: column.name, - operator: "!=", - value - }; - if (i) searchExpression.clause = "&&"; - return searchExpression; - }); - const searchExpressionGroup = { - expressions - }; - return searchExpressionGroup; -} -function selectExactAxis(axis, column, i) { - const result = tickValue(axis, i); - if (result.tick) return selectExact(column, result.value); -} -function selectBetween(column, lowValue, highValue, lowOperator = ">=", highOperator = "<") { - const expressions = []; - if (lowValue !== undefined) expressions.push({ - name: column.name, - operator: lowOperator, - value: lowValue - }); - if (highValue !== undefined) expressions.push({ - name: column.name, - operator: highOperator, - value: highValue - }); - if (expressions.length > 1) expressions[1].clause = "&&"; - const searchExpressionGroup = { - expressions - }; - return searchExpressionGroup; -} -function selectBetweenAxis(axis, column, i) { - const low = tickValue(axis, i); - const high = tickValue(axis, i + 1); - return selectBetween(column, low.value, high.value); -} +@fragment +fn frag_main_hdr(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> { + let x = floor(coord.x); + let y = floor(coord.y); + let index = u32(x + y * uniforms.width) * 3u; + var color = vec3<f32>(colorBuffer.data[index + 0u], colorBuffer.data[index + 1u], colorBuffer.data[index + 2u]) / uniforms.samplesPerPixel; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9PNtZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "populateColorContext", ()=>populateColorContext); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -function populateColorContext(colorContext, presenter) { - if (!colorContext.colorMap) colorContext.colorMap = presenter.morphChartsRenderResult.getCubeLayer().unitColorMap; - colorContext.legend = _vegaMorphcharts.util.clone(presenter.stage.legend); - colorContext.legendElement = presenter.getElement(_vegaMorphcharts.PresenterElement.legend).children[0]; -} + // Simple tone-mapping from HDR to LDR + // if (uniforms.exposure > 0f) { + // color = color * uniforms.exposure; + // color = color / (color + vec3<f32>(1f, 1f, 1f)); + // } + + color = color * uniforms.exposure; + // ACES + // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ + let a = 2.51f; + let b = 0.03f; + let c = 2.43f; + let d = 0.59f; + let e = 0.14f; + color = (color * (a * color + b)) / (color * (c * color + d) + e); + + // See https://bruop.github.io/tonemapping/ + // See https://www.shadertoy.com/view/WdjSW3 -},{"@msrvida/vega-morphcharts":"guKLg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1pzB5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DataScope", ()=>DataScope); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -var _searchExpression = require("@msrvida/search-expression"); -var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -var _constants = require("./constants"); -class DataScope { + // Gamma-correct + return vec4<f32>(pow(color, GAMMA), 1f); +}`; +class FullscreenQuadUniformBufferData extends Float32Array { constructor(){ - this.filteredColumnsStats = {}; + super(FullscreenQuadUniformBufferData.SIZE); + this.WIDTH_OFFSET = 0; + this.HEIGHT_OFFSET = 1; + this.SPP_OFFSET = 2; + this.EXPOSURE_OFFSET = 3; + this.MIN_DEPTH_OFFSET = 4; + this.MAX_DEPTH_OFFSET = 5; + this.EDGE_NORMAL_OFFSET = 6; + this.EDGE_DEPTH_OFFSET = 7; } - setData(data, columns) { - const differentData = this.data !== data; - if (differentData) { - if (this.data) //clean up things we added to old data - this.deselect(); - this.data = data; - this.columns = columns; - this.filteredData = null; - this.filteredColumnsStats = {}; - } - return differentData; + getWidth() { + return this[this.WIDTH_OFFSET]; } - setFilteredData(filteredData) { - this.filteredData = filteredData; - this.filteredColumnsStats = {}; + setWidth(value) { + this[this.WIDTH_OFFSET] = value; } - getColumns(columnTypes) { - if (!this.columns) this.columns = (0, _sanddanceSpecs.getColumnsFromData)(_vegaMorphcharts.base.vega.inferTypes, this.data, columnTypes); - return this.columns; + getHeight() { + return this[this.HEIGHT_OFFSET]; } - getFilteredColumnStats(columnName) { - if (!this.filteredColumnsStats[columnName]) this.filteredColumnsStats[columnName] = (0, _sanddanceSpecs.getStats)(this.filteredData, this.columns.filter((c)=>c.name === columnName)[0]); - return this.filteredColumnsStats[columnName]; + setHeight(value) { + this[this.HEIGHT_OFFSET] = value; } - currentData() { - return this.filteredData || this.data; + getSamplesPerPixel() { + return this[this.SPP_OFFSET]; } - select(search) { - this.deselect(); - if (search) { - this.selection = this.createUserSelection(search, true, false); - if (this.selection.included.length) this.activate(this.selection.included[0]); - } + setSamplesPerPixel(value) { + this[this.SPP_OFFSET] = value; } - createUserSelection(search, assign, rebase) { - const exec = new (0, _searchExpression.Exec)(search, this.getColumns()); - const s = { - search, - included: [], - excluded: [] - }; - const data = rebase ? this.data : this.currentData(); - data.forEach((datum)=>{ - if (exec.run(datum)) { - if (assign) datum[(0, _sanddanceSpecs.FieldNames).Selected] = true; - s.included.push(datum); - } else s.excluded.push(datum); - }); - return s; + getExposure() { + return this[this.EXPOSURE_OFFSET]; } - deselect() { - this.deactivate(); - this.data.forEach((datum)=>{ - delete datum[(0, _sanddanceSpecs.FieldNames).Selected]; - }); - this.selection = null; + setExposure(value) { + this[this.EXPOSURE_OFFSET] = value; } - hasFilteredData() { - return !!this.filteredData; + getMinDepth() { + return this[this.MIN_DEPTH_OFFSET]; } - hasSelectedData() { - return !!this.selection; + setMinDepth(value) { + this[this.MIN_DEPTH_OFFSET] = value; } - collapse(collapsed, data = this.data) { - data.forEach((datum)=>{ - datum[(0, _sanddanceSpecs.FieldNames).Collapsed] = collapsed; - }); - this.isCollapsed = collapsed; + getMaxDepth() { + return this[this.MAX_DEPTH_OFFSET]; } - activate(datum) { - this.deactivate(); - datum[(0, _sanddanceSpecs.FieldNames).Active] = true; - this.active = datum; + setMaxDepth(value) { + this[this.MAX_DEPTH_OFFSET] = value; } - deactivate() { - if (this.active) delete this.active[(0, _sanddanceSpecs.FieldNames).Active]; - this.active = null; + getEdgeDepth() { + return this[this.EDGE_DEPTH_OFFSET]; } - ordinalIndexWithinSelection(ordinal) { - if (this.selection) for(let i = 0; i < this.selection.included.length; i++){ - const datum = this.selection.included[i]; - if (datum[0, _constants.GL_ORDINAL] === ordinal) return { - datum, - index: i - }; - } - return { - datum: null, - index: -1 - }; + setEdgeDepth(value) { + this[this.EDGE_DEPTH_OFFSET] = value; } - finalize() { - this.data = null; - this.filteredData = null; - this.filteredColumnsStats = null; - if (this.selection) { - this.selection.excluded = null; - this.selection.included = null; - this.selection = null; - } + getEdgeNormal() { + return this[this.EDGE_NORMAL_OFFSET]; + } + setEdgeNormal(value) { + this[this.EDGE_NORMAL_OFFSET] = value; } } +FullscreenQuadUniformBufferData.SIZE = 8; -},{"@msrvida/vega-morphcharts":"guKLg","@msrvida/search-expression":"j6CcD","@msrvida/sanddance-specs":"4hjOh","./constants":"ghoOR","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"g9vCR":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Details", ()=>Details); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8lb3C":[function(require,module,exports,__globalThis) { /*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -var _defaults = require("./defaults"); -var _constants = require("./constants"); -var _searchExpression = require("@msrvida/search-expression"); -var _util = require("./util"); -var Action; -(function(Action) { - Action[Action["deselect"] = 0] = "deselect"; - Action[Action["isolate"] = 1] = "isolate"; - Action[Action["exclude"] = 2] = "exclude"; - Action[Action["reset"] = 3] = "reset"; - Action[Action["next"] = 4] = "next"; - Action[Action["previous"] = 5] = "previous"; -})(Action || (Action = {})); -class Details { - constructor(parentElement, language, animator, dataScope, colorMapHandler, hasColorMaps){ - this.language = language; - this.animator = animator; - this.dataScope = dataScope; - this.colorMapHandler = colorMapHandler; - this.hasColorMaps = hasColorMaps; - this.element = (0, _vegaMorphcharts.util).addDiv(parentElement, `${(0, _defaults.cssPrefix)}unitControls`); - this.clear(); + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "SplitMethod", ()=>SplitMethod); +parcelHelpers.export(exports, "LinearBVHNode", ()=>LinearBVHNode); +parcelHelpers.export(exports, "BVHAccel", ()=>BVHAccel); +parcelHelpers.export(exports, "LinearBVHNodeBufferData", ()=>LinearBVHNodeBufferData); +var _glMatrix = require("gl-matrix"); +var _mainJs = require("../../main.js"); +var _aabbJs = require("./aabb.js"); +const SplitMethod = { + middle: "middle", + equalCounts: "equalCounts", + sah: "sah" +}; +class BVHPrimitiveInfo { + get primitiveNumber() { + return this._primitiveNumber; } - finalize() { - if (this.element) this.element.innerHTML = ""; - this.dataScope = null; - this.element = null; + get bounds() { + return this._bounds; } - clear() { - this.state = { - userSelection: null, - index: -1, - remapColor: false - }; - this.render(); + get centroid() { + return this._centroid; } - clearSelection() { - this.state.userSelection = null; - this.state.index = -1; - this.render(); + constructor(primitiveNumber, bounds){ + this._primitiveNumber = primitiveNumber; + this._bounds = bounds; + this._centroid = (0, _glMatrix.vec3).create(); + bounds.centroid(this._centroid); } - populate(userSelection, index = 0) { - this.state.userSelection = userSelection; - this.state.index = index; - this.render(); +} +class BVHBuildNode { + get bounds() { + return this._bounds; } - selectByNameValue(columnName, value) { - const search = { - name: columnName, - operator: "==", - value - }; - this.clearSelection(); - this.animator.select(search); - this.populate(this.dataScope.selection); + get left() { + return this._left; } - remapChanged(remap) { - this.state.remapColor = remap; - this.colorMapHandler(remap); - this.render(); + get right() { + return this._right; } - handleAction(action) { - let p; - const u = this.state.userSelection; - switch(action){ - case Action.deselect: - this.clearSelection(); - p = this.animator.deselect(); - break; - case Action.exclude: - this.clearSelection(); - p = this.animator.filter((0, _searchExpression.invert)(u.search), u.excluded, u.included, false); - this.state.remapColor = false; - break; - case Action.isolate: - this.clearSelection(); - p = this.animator.filter(u.search, u.included, u.excluded, false); - this.state.remapColor = false; - break; - case Action.reset: - this.clear(); - p = this.animator.reset(); - break; - default: - switch(action){ - case Action.previous: - this.state.index--; - if (this.state.index < 0) this.state.index = this.state.userSelection.included.length - 1; - break; - case Action.next: - this.state.index++; - if (this.state.index >= this.state.userSelection.included.length) this.state.index = 0; - break; - } - this.render(); - p = this.animator.activate(this.state.userSelection.included[this.state.index]); - } - p.then(()=>this.render()); + get splitAxis() { + return this._splitAxis; } - render() { - const hasRefinedData = this.dataScope.hasFilteredData(); - const renderProps = { - language: this.language, - actionHandler: (action)=>this.handleAction(action), - selectionHandler: (columnName, value)=>this.selectByNameValue(columnName, value), - count: this.state.userSelection && this.state.userSelection.included.length, - hasRefinedData, - item: this.state.userSelection && this.state.userSelection.included[this.state.index], - remapColorHandler: (remap)=>this.remapChanged(remap), - hasColorMaps: this.hasColorMaps() && hasRefinedData, - remapColor: this.state.remapColor - }; - const a = _vegaMorphcharts.util.getActiveElementInfo(); - _vegaMorphcharts.util.mount(renderDetails(renderProps), this.element); - _vegaMorphcharts.util.setActiveElement(a); + get firstPrimOffset() { + return this._firstPrimOffset; } -} -const renderDetails = (props)=>{ - const controlButtons = [ - _vegaMorphcharts.util.createElement("button", { - disabled: !props.item, - onClick: (e)=>props.actionHandler(Action.deselect) - }, props.language.deselect), - _vegaMorphcharts.util.createElement("button", { - disabled: !props.item, - onClick: (e)=>props.actionHandler(Action.isolate) - }, props.language.isolate), - _vegaMorphcharts.util.createElement("button", { - disabled: !props.item, - onClick: (e)=>props.actionHandler(Action.exclude) - }, props.language.exclude), - ]; - const colorMapping = _vegaMorphcharts.util.createElement("div", null, _vegaMorphcharts.util.createElement("button", { - disabled: props.remapColor, - onClick: (e)=>props.remapColorHandler(true) - }, props.language.newColorMap), _vegaMorphcharts.util.createElement("button", { - disabled: !props.remapColor, - onClick: (e)=>props.remapColorHandler(false) - }, props.language.oldColorMap)); - const singleItem = props.count === 1; - const scrollButtons = [ - _vegaMorphcharts.util.createElement("button", { - disabled: singleItem, - onClick: (e)=>props.actionHandler(Action.previous) - }, props.language.previousDetail), - _vegaMorphcharts.util.createElement("button", { - disabled: singleItem, - onClick: (e)=>props.actionHandler(Action.next) - }, props.language.nextDetail), - _vegaMorphcharts.util.createElement("span", null, " ", props.language.selectionCount(props.count)), - ]; - const rows = []; - for(const prop in props.item){ - if (prop === (0, _constants.GL_ORDINAL)) continue; - if ((0, _util.isInternalFieldName)(prop)) continue; - rows.push({ - cells: [ - { - content: prop - }, - { - content: linkSelect(props.language, prop, props.item[prop], props.selectionHandler) - }, - ] - }); + get nPrimitives() { + return this._nPrimitives; + } + get start() { + return this._start; + } + get end() { + return this._end; + } + constructor(start, end){ + this._start = start; + this._end = end; + } + initLeaf(first, n, bounds) { + this._firstPrimOffset = first; + this._nPrimitives = n; + this._bounds = bounds; + this._left = null; + this._right = null; + } + initInterior(axis, left, right) { + this._left = left; + this._right = right; + this._bounds = new (0, _aabbJs.AABB)(); + this._bounds.unionBounds(this._left.bounds); + this._bounds.unionBounds(this._right.bounds); + this._splitAxis = axis; + this._nPrimitives = 0; } - return _vegaMorphcharts.util.createElement("div", null, props.hasColorMaps && colorMapping, _vegaMorphcharts.util.createElement("h4", null, props.language.headers.selection), _vegaMorphcharts.util.createElement("div", { - className: `${(0, _defaults.cssPrefix)}selection` - }, controlButtons, _vegaMorphcharts.util.createElement("button", { - disabled: !props.hasRefinedData, - onClick: (e)=>props.actionHandler(Action.reset) - }, "reset")), props.item && _vegaMorphcharts.util.createElement("h4", null, props.language.headers.details), _vegaMorphcharts.util.createElement("div", null, _vegaMorphcharts.util.createElement("div", { - className: `${(0, _defaults.cssPrefix)}details-scroll` - }, props.item && scrollButtons), _vegaMorphcharts.util.createElement("div", { - className: `${(0, _defaults.cssPrefix)}details` - }, props.item && _vegaMorphcharts.util.createElement((0, _vegaMorphcharts.controls).Table, { - rows: rows - })))); -}; -function linkSelect(language, columnName, value, selectionHandler) { - return _vegaMorphcharts.util.createElement("span", null, _vegaMorphcharts.util.createElement("a", { - href: "#", - onClick: (e)=>selectionHandler(columnName, value) - }, value), isNaN(value) ? [ - " ", - _vegaMorphcharts.util.createElement("a", { - className: "bing-search", - href: `https://www.bing.com/search?q=${encodeURIComponent(value)}`, - target: "_blank" - }, language.bing) - ] : ""); -} - -},{"@msrvida/vega-morphcharts":"guKLg","./defaults":"lNUGC","./constants":"ghoOR","@msrvida/search-expression":"j6CcD","./util":"3kvmX","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1LQHC":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ensureHeaders", ()=>ensureHeaders); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -function ensureHeaders(presenter, headers) { - const vegaControls = presenter.getElement((0, _vegaMorphcharts.PresenterElement).vegaControls); - conditionalHeader(!!vegaControls.querySelectorAll(".vega-bindings > *").length, vegaControls, headers.chart); - const legend = presenter.getElement((0, _vegaMorphcharts.PresenterElement).legend); - conditionalHeader(!!legend.children.length, legend, headers.legend); -} -function conditionalHeader(condition, element, header) { - const existing = existingHeader(element, header); - if (condition && !existing) addHeader(element, header); - if (!condition && existing) existing.remove(); -} -function addHeader(element, header) { - const h = document.createElement("h4"); - h.innerHTML = header; - element.insertAdjacentElement("beforebegin", h); -} -function existingHeader(element, header) { - const { previousElementSibling } = element; - if (previousElementSibling && previousElementSibling.innerHTML === header) return previousElementSibling; -} - -},{"@msrvida/vega-morphcharts":"guKLg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bhn8i":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "finalizeLegend", ()=>finalizeLegend); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -var _expression = require("./expression"); -function legendRange(colorBinType, column, legend, clickedIndex) { - if (column.quantitative) return selectQuantitative(colorBinType, column, legend, clickedIndex); - else return selectCategorical(column, legend, clickedIndex); } -function selectCategorical(column, legend, clickedIndex) { - const value = legend.rows[clickedIndex].value; - if (value === (0, _sanddanceSpecs.Other)) { - const values = []; - for(const i in legend.rows)if (+i !== clickedIndex) values.push(legend.rows[i].value); - return (0, _expression.selectNone)(column, values); - } else //select equal - return { - expressions: [ - (0, _expression.selectExact)(column, legend.rows[clickedIndex].value) - ] - }; +class LinearBVHNode { + constructor(){ + this.bounds = new (0, _aabbJs.AABB)(); + this.primitivesOffset = 0; + this.secondChildOffset = 0; + this.nPrimitives = 0; + this.axis = 0; + this._centroid = (0, _glMatrix.vec3).create(); + this._size = (0, _glMatrix.vec3).create(); + } + toBuffer(buffer, index) { + this.bounds.centroid(this._centroid); + buffer.setCenter(index, this._centroid); + this.bounds.size(this._size); + (0, _glMatrix.vec3).scale(this._size, this._size, 0.5); + buffer.setSize(index, this._size); + buffer.setPrimitivesOffset(index, this.primitivesOffset); + buffer.setSecondChildOffset(index, this.secondChildOffset); + buffer.setNPrimitives(index, this.nPrimitives); + buffer.setAxis(index, this.axis); + } } -function selectQuantitative(colorBinType, column, legend, clickedIndex) { - const keys = Object.keys(legend.rows).map((key)=>+key).sort((a, b)=>+a - +b); - let lowValue; - let lowOperator; - let highValue; - let highOperator; - const rowText = legend.rows[clickedIndex].label; - switch(colorBinType){ - case "continuous": - lowValue = rowText; - if (clickedIndex < keys.length - 1) highValue = legend.rows[clickedIndex + 1].value; - break; - default: - { - if (rowText.indexOf("null") > 0) { - const ex = { - expressions: [ - (0, _expression.selectNullOrEmpty)(column) - ] - }; - return ex; +class BVHAccel { + get orderedPrimitives() { + return this._orderedPrimitives; + } + get nodes() { + return this._nodes; + } + constructor(core, primitives, maxPrimsInNode, splitMethod){ + this._core = core; + if (!primitives || primitives.length == 0) return; + let start = performance.now(); + this._maxPrimsInNode = maxPrimsInNode; + this._splitMethod = splitMethod; + this._primitives = primitives; + this._normalized = (0, _glMatrix.vec3).create(); + this._primitiveInfo = []; + for(let i = 0; i < primitives.length; i++)this._primitiveInfo.push(new BVHPrimitiveInfo(i, primitives[i].bounds)); + this._totalNodes = 0; + this._orderedPrimitives = []; + const root = this._recursiveBuild(0, primitives.length); + this._core.log.write((0, _mainJs.LogLevel).info, `bvh ${this._totalNodes} nodes split ${this._splitMethod} ${Math.round(window.performance.now() - start)}ms`); + start = performance.now(); + this._nodes = []; + for(let i = 0; i < this._totalNodes; i++)this._nodes.push(new LinearBVHNode()); + this._offset = 0; + this._flattenBVHTree(root); + this._core.log.write((0, _mainJs.LogLevel).info, `bvh flattened ${Math.round(window.performance.now() - start)}ms`); + } + _recursiveBuild(start, end) { + const node = new BVHBuildNode(start, end - 1); + this._totalNodes++; + const bounds = new (0, _aabbJs.AABB)(); + for(let i = start; i < end; i++)bounds.unionBounds(this._primitiveInfo[i].bounds); + const nPrimitives = end - start; + if (nPrimitives == 1) { + const firstPrimOffset = this._orderedPrimitives.length; + for(let i = start; i < end; i++){ + const primNum = this._primitiveInfo[i].primitiveNumber; + this._orderedPrimitives.push(this._primitives[primNum]); + } + node.initLeaf(firstPrimOffset, nPrimitives, bounds); + return node; + } else { + const centroidBounds = new (0, _aabbJs.AABB)(); + for(let i = start; i < end; i++)centroidBounds.unionPoint(this._primitiveInfo[i].centroid); + const dim = centroidBounds.maximumExtent(); + let mid = Math.floor((start + end) / 2); + if (centroidBounds.max[dim] == centroidBounds.min[dim]) { + const firstPrimOffset = this._orderedPrimitives.length; + for(let i = start; i < end; i++){ + const primNum = this._primitiveInfo[i].primitiveNumber; + this._orderedPrimitives.push(this._primitives[primNum]); } - const dash = rowText.indexOf("–"); //this is not the common dash character! - if (dash > 0) { - //bug in Vega for quantize? - //lowOperator = '>'; - //highOperator = '<='; - lowValue = rowText.substr(0, dash); - highValue = rowText.substr(dash + 1); - } else { - if (rowText.indexOf("<") >= 0) highValue = rowText.substring(2); - else if (rowText.indexOf("≥") >= 0) lowValue = rowText.substring(2); + node.initLeaf(firstPrimOffset, nPrimitives, bounds); + return node; + } else { + switch(this._splitMethod){ + case SplitMethod.middle: + break; + case SplitMethod.equalCounts: + mid = Math.floor((start + end) / 2); + const primtiveInfo = this._primitiveInfo.slice(start, end); + primtiveInfo.sort(function(a, b) { + return a.centroid[dim] - b.centroid[dim]; + }); + for(let i = start; i < end; i++)this._primitiveInfo[i] = primtiveInfo[i - start]; + break; + case SplitMethod.sah: + default: + if (nPrimitives <= 4) { + mid = Math.floor((start + end) / 2); + const primtiveInfo = this._primitiveInfo.slice(start, end); + primtiveInfo.sort(function(a, b) { + return a.centroid[dim] - b.centroid[dim]; + }); + for(let i = start; i < end; i++)this._primitiveInfo[i] = primtiveInfo[i - start]; + } else { + const nBuckets = 12; + const buckets = []; + for(let i = 0; i < nBuckets; i++)buckets.push({ + count: 0, + bounds: new (0, _aabbJs.AABB)() + }); + for(let i = start; i < end; i++){ + centroidBounds.offset(this._primitiveInfo[i].centroid, this._normalized); + const b = Math.min(Math.round(nBuckets * this._normalized[dim]), nBuckets - 1); + buckets[b].count++; + buckets[b].bounds.unionBounds(this._primitiveInfo[i].bounds); + } + const cost = []; + for(let i = 0; i < nBuckets - 1; i++){ + const b0 = new (0, _aabbJs.AABB)(); + const b1 = new (0, _aabbJs.AABB)(); + let count0 = 0; + let count1 = 0; + for(let j = 0; j <= i; j++){ + b0.unionBounds(buckets[j].bounds); + count0 += buckets[j].count; + } + for(let j = i + 1; j < nBuckets; j++){ + b1.unionBounds(buckets[j].bounds); + count1 += buckets[j].count; + } + cost.push(0.125 + (count0 * b0.surfaceArea() + count1 * b1.surfaceArea()) / bounds.surfaceArea()); + } + let minCost = cost[0]; + let minCostSplitBucket = 0; + for(let i = 1; i < nBuckets - 1; i++)if (cost[i] < minCost) { + minCost = cost[i]; + minCostSplitBucket = i; + } + const leafCost = nPrimitives; + if (nPrimitives > this._maxPrimsInNode || minCost < leafCost) { + const primtiveInfo = this._primitiveInfo.slice(start, end); + primtiveInfo.sort(function(a, b) { + return a.centroid[dim] - b.centroid[dim]; + }); + for(let i = start; i < end; i++)this._primitiveInfo[i] = primtiveInfo[i - start]; + for(let i = start; i < end; i++){ + centroidBounds.offset(this._primitiveInfo[i].centroid, this._normalized); + const b = Math.min(Math.round(nBuckets * this._normalized[dim]), nBuckets - 1); + if (b > minCostSplitBucket) { + mid = i; + break; + } + } + } else { + const firstPrimOffset = this._orderedPrimitives.length; + for(let i = start; i < end; i++){ + const primNum = this._primitiveInfo[i].primitiveNumber; + this._orderedPrimitives.push(this._primitives[primNum]); + } + node.initLeaf(firstPrimOffset, nPrimitives, bounds); + return node; + } + } + break; } + node.initInterior(dim, this._recursiveBuild(start, mid), this._recursiveBuild(mid, end)); } + } + return node; + } + _flattenBVHTree(node) { + const linearNode = this._nodes[this._offset]; + linearNode.bounds = node.bounds; + const myOffset = this._offset++; + if (node.nPrimitives > 0) { + linearNode.primitivesOffset = node.firstPrimOffset; + linearNode.nPrimitives = node.nPrimitives; + } else { + linearNode.axis = node.splitAxis; + linearNode.nPrimitives = 0; + this._flattenBVHTree(node.left); + linearNode.secondChildOffset = this._flattenBVHTree(node.right); + } + return myOffset; } - if (lowValue) lowValue = (0, _expression.notNice)(lowValue); - if (highValue) highValue = (0, _expression.notNice)(highValue); - if (lowValue === highValue) return { - expressions: [ - (0, _expression.selectExact)(column, lowValue) - ] - }; - else return (0, _expression.selectBetween)(column, lowValue, highValue, lowOperator, highOperator); } -function finalizeLegend(colorBinType, colorColumn, legend, language) { - const rowTexts = []; - for(const i in legend.rows){ - const row = legend.rows[i]; - row.search = legendRange(colorBinType, colorColumn, legend, +i); - if (row.value === (0, _sanddanceSpecs.Other)) row.label = language.legendOther; - else rowTexts.push(row.value); +class LinearBVHNodeBufferData extends Float32Array { + constructor(count){ + super(count * LinearBVHNodeBufferData.SIZE); + this.CENTER_OFFSET = 0; + this.SIZE_OFFSET = 4; + this.PRIMITIVES_OFFSET_OFFSET = 3; + this.SECOND_CHILD_OFFSET_OFFSET = 7; + this.N_PRIMITIVES_OFFSET = 8; + this.AXIS_OFFSET = 9; + } + getCenter(index, value) { + const offset = LinearBVHNodeBufferData.SIZE * index + this.CENTER_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setCenter(index, value) { + const offset = LinearBVHNodeBufferData.SIZE * index + this.CENTER_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getSize(index, value) { + const offset = LinearBVHNodeBufferData.SIZE * index + this.SIZE_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setSize(index, value) { + const offset = LinearBVHNodeBufferData.SIZE * index + this.SIZE_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getPrimitivesOffset(index) { + return this[LinearBVHNodeBufferData.SIZE * index + this.PRIMITIVES_OFFSET_OFFSET]; + } + setPrimitivesOffset(index, value) { + this[LinearBVHNodeBufferData.SIZE * index + this.PRIMITIVES_OFFSET_OFFSET] = value; + } + getSecondChildOffset(index) { + return this[LinearBVHNodeBufferData.SIZE * index + this.SECOND_CHILD_OFFSET_OFFSET]; + } + setSecondChildOffset(index, value) { + this[LinearBVHNodeBufferData.SIZE * index + this.SECOND_CHILD_OFFSET_OFFSET] = value; + } + getNPrimitives(index) { + return this[LinearBVHNodeBufferData.SIZE * index + this.N_PRIMITIVES_OFFSET]; + } + setNPrimitives(index, value) { + this[LinearBVHNodeBufferData.SIZE * index + this.N_PRIMITIVES_OFFSET] = value; + } + getAxis(index) { + return this[LinearBVHNodeBufferData.SIZE * index + this.AXIS_OFFSET]; + } + setAxis(index, value) { + this[LinearBVHNodeBufferData.SIZE * index + this.AXIS_OFFSET] = value; } } +LinearBVHNodeBufferData.SIZE = 12; -},{"@msrvida/sanddance-specs":"4hjOh","./expression":"lR8EB","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aRxP1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "assignOrdinals", ()=>assignOrdinals); -parcelHelpers.export(exports, "getDataIndexOfCube", ()=>getDataIndexOfCube); +},{"gl-matrix":"5x28d","../../main.js":"f421K","./aabb.js":"7wAtJ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2sMdC":[function(require,module,exports,__globalThis) { /*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _constants = require("./constants"); -function assignOrdinals(columns, data, ordinalMap) { - const uCol = columns.uid && columns.uid.name; - if (ordinalMap) data.forEach((d, i)=>{ - const key = uCol ? d[uCol] : i; - d[0, _constants.GL_ORDINAL] = ordinalMap[key]; - }); - else { - ordinalMap = {}; - data.forEach((d, i)=>{ - d[0, _constants.GL_ORDINAL] = i; - const uColValue = uCol ? d[uCol] : i; - ordinalMap[uColValue] = i; - }); + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LightType", ()=>LightType); +parcelHelpers.export(exports, "LightBufferData", ()=>LightBufferData); +parcelHelpers.export(exports, "Light", ()=>Light); +parcelHelpers.export(exports, "SphereLight", ()=>SphereLight); +parcelHelpers.export(exports, "RectLight", ()=>RectLight); +var _glMatrix = require("gl-matrix"); +const LightType = { + distant: 0, + sphere: 1, + rect: 2, + disc: 3, + cylinder: 4, + dome: 5 +}; +class LightBufferData extends Float32Array { + constructor(count){ + super(count * LightBufferData.SIZE); + this.ROTATION_OFFSET = 0; + this.CENTER_OFFSET = 4; + this.TYPE_OFFSET = 7; + this.SIZE_OFFSET = 8; + this.COLOR_OFFSET = 12; + } + getType(index) { + return this[LightBufferData.SIZE * index + this.TYPE_OFFSET]; + } + setType(index, value) { + this[LightBufferData.SIZE * index + this.TYPE_OFFSET] = value; + } + getCenter(index, value) { + const offset = LightBufferData.SIZE * index + this.CENTER_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setCenter(index, value) { + const offset = LightBufferData.SIZE * index + this.CENTER_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getSize(index, value) { + const offset = LightBufferData.SIZE * index + this.SIZE_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setSize(index, value) { + const offset = LightBufferData.SIZE * index + this.SIZE_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getColor(index, value) { + const offset = LightBufferData.SIZE * index + this.COLOR_OFFSET; + (0, _glMatrix.vec3).set(value, this[offset], this[offset + 1], this[offset + 2]); + } + setColor(index, value) { + const offset = LightBufferData.SIZE * index + this.COLOR_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + } + getRotation(index, value) { + const offset = LightBufferData.SIZE * index + this.ROTATION_OFFSET; + (0, _glMatrix.quat).set(value, this[offset], this[offset + 1], this[offset + 2], this[offset + 3]); + } + setRotation(index, value) { + const offset = LightBufferData.SIZE * index + this.ROTATION_OFFSET; + this[offset] = value[0]; + this[offset + 1] = value[1]; + this[offset + 2] = value[2]; + this[offset + 3] = value[3]; } - return ordinalMap; } -function getDataIndexOfCube(cube, data) { - const len = data.length; - for(let i = 0; i < len; i++){ - if (data[i][0, _constants.GL_ORDINAL] === cube.ordinal) return i; +LightBufferData.SIZE = 16; +class Light { + constructor(options){ + this.color = options.color; + this.center = options.center; + } + toBuffer(buffer, index) { + buffer.setCenter(index, this.center); + buffer.setColor(index, this.color); } } - -},{"./constants":"ghoOR","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dSvxZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getSearchGroupFromVegaValue", ()=>getSearchGroupFromVegaValue); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -var _array = require("./array"); -function getSearchGroupFromVegaValue(search) { - let group; - const vegaSearch = search; - if (Array.isArray(vegaSearch)) { - //flatten into one group - group = { - expressions: [] - }; - vegaSearch.forEach((g)=>{ - const clonedExpressions = _vegaMorphcharts.util.clone(g.expressions).filter(Boolean); - clonedExpressions[0].clause = "&&"; - (0, _array.push)(group.expressions, clonedExpressions); - }); - } else group = vegaSearch ? { - expressions: vegaSearch.expressions.filter(Boolean) - } : null; - return group; +class SphereLight extends Light { + constructor(options){ + super(options); + this.radius = options.radius / 2; + } + toBuffer(buffer, index) { + super.toBuffer(buffer, index); + buffer.setType(index, LightType.sphere); + buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this.radius, this.radius, this.radius)); + } +} +class RectLight extends Light { + constructor(options){ + super(options); + this._thickness = 0.00001; + this.size = options.size; + this.rotation = options.rotation; + } + toBuffer(buffer, index) { + super.toBuffer(buffer, index); + buffer.setType(index, LightType.rect); + buffer.setSize(index, (0, _glMatrix.vec3).fromValues(this.size[0], this.size[1], this._thickness)); + buffer.setRotation(index, this.rotation); + } } -},{"@msrvida/vega-morphcharts":"guKLg","./array":"35wVZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"35wVZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "allTruthy", ()=>allTruthy); -parcelHelpers.export(exports, "concat", ()=>concat); -parcelHelpers.export(exports, "push", ()=>push); +},{"gl-matrix":"5x28d","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3rF26":[function(require,module,exports,__globalThis) { /*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -const { allTruthy , concat , push } = (0, _vegaMorphcharts.util); - -},{"@msrvida/vega-morphcharts":"guKLg","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iFNr3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "applySignalValues", ()=>applySignalValues); -parcelHelpers.export(exports, "extractSignalValuesFromView", ()=>extractSignalValuesFromView); -parcelHelpers.export(exports, "unbindSignalUI", ()=>unbindSignalUI); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -function applySignalValues(sv, b) { - if (!sv || !b || !b.signals || !b.signals.length) return; - for(const key in sv){ - const value = sv[key]; - const signalB = b.signals.filter((signal)=>signal.name === key)[0]; - if (signalB && signalB.bind) signalB.value = value; +parcelHelpers.export(exports, "FontVisual", ()=>FontVisual); +var _mainJs = require("../../main.js"); +class FontVisual { + get isInitialized() { + return this._isInitialized; } -} -function extractSignalValuesFromView(view, spec) { - if (!view || !spec || !spec.signals || !spec.signals.length) return; - const result = {}; - spec.signals.forEach((signalA)=>{ - //bound to a UI control - if (signalA.bind) try { - result[signalA.name] = view.signal(signalA.name); - } catch (e) { - // continue regardless of error + get font() { + return this._font; + } + constructor(core, font){ + this._core = core; + this._font = font; + font.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; + } + initializeContext(device) { + this._device = device; + this._hasChanged = true; + this._isInitialized = true; + } + update() { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + const start = window.performance.now(); + const imageData = this._font.atlas.imageData; + const textureSize = { + width: imageData.width, + height: imageData.height + }; + createImageBitmap(imageData).then((imageBitmap)=>{ + const textureDescriptor = { + size: textureSize, + format: 'rgba8unorm', + usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT + }; + this.texture = this._device.createTexture(textureDescriptor); + const imageCopyExternalImage = { + source: imageBitmap + }; + const imageCopyTextureTagged = { + texture: this.texture + }; + const copySize = { + width: imageData.width, + height: imageData.height + }; + this._device.queue.copyExternalImageToTexture(imageCopyExternalImage, imageCopyTextureTagged, copySize); + if (this.hasChangedCallback) this.hasChangedCallback(); + this._core.log.write((0, _mainJs.LogLevel).info, `${this._font.name} texture updated ${Math.round(window.performance.now() - start)}ms`); + }); } - }); - return result; -} -//signals not capable of handling with MorphCharts -const hideSignalUI = [ - (0, _sanddanceSpecs.SignalNames).MarkOpacity, - (0, _sanddanceSpecs.SignalNames).TextAngleX, - (0, _sanddanceSpecs.SignalNames).TextAngleY, -]; -function unbindSignalUI(spec) { - spec.signals.forEach((signal)=>{ - if (hideSignalUI.indexOf(signal.name) >= 0) delete signal.bind; - }); + } } -},{"@msrvida/sanddance-specs":"4hjOh","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"h3Rlc":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Tooltip", ()=>Tooltip); -parcelHelpers.export(exports, "cleanDataItem", ()=>cleanDataItem); +},{"../../main.js":"f421K","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"enHlm":[function(require,module,exports,__globalThis) { /*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); -var _constants = require("./constants"); -var _util = require("./util"); -const { outerSize } = _vegaMorphcharts.util; -const { Table } = _vegaMorphcharts.controls; -class Tooltip { - constructor(props){ - this.props = props; - const renderProps = { - cssPrefix: props.cssPrefix, - rows: getRows(props.dataItem) + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ImageVisual", ()=>ImageVisual); +var _glMatrix = require("gl-matrix"); +var _imageJs = require("../../components/image.js"); +var _hittableJs = require("./hittable.js"); +class ImageVisual { + get isInitialized() { + return this._isInitialized; + } + get image() { + return this._image; + } + render(elapsedTime) {} + constructor(core, main, image){ + this._core = core; + this._main = main; + this._image = image; + this.isVisible = true; + image.hasChangedCallback = ()=>{ + this._hasChanged = true; }; - this.finalizeHandler = ()=>this.destroy(); - this.element = renderTooltip(renderProps); - if (this.element) { - this.element.style.position = "absolute"; - this.child = this.element.firstChild; - document.body.appendChild(this.element); - //measure and move as necessary - let m = outerSize(this.child); - while(m.height > document.documentElement.clientHeight){ - const tr = this.child.querySelector("tr:last-child"); - if (tr) tr.parentElement.removeChild(tr); - else break; - m = outerSize(this.child); - } - let position; - const te = props.event; - if (te.touches) position = te[0]; - else { - const pme = props.event; - position = pme; - } - if (position.clientX + m.width >= document.documentElement.clientWidth) this.child.style.right = "0"; - let moveTop = true; - if (position.clientY + m.height >= document.documentElement.clientHeight) { - if (position.clientY - m.height > 0) this.child.style.bottom = "0"; - else moveTop = false; + } + initializeContext(device) { + if (!this._image.isInitialized) this._image.initialize(); + this._hasChanged = true; + this._isInitialized = true; + } + update() { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + const material = this._image.material == -1 ? this._main.config.defaultMaterial : this._main.materials[this._image.material]; + const modelPosition = (0, _glMatrix.vec3).create(); + const modelScale = this._core.getModelScale(); + const modelRotation = (0, _glMatrix.quat).create(); + this._core.getModelRotation(modelRotation); + const modelSizeX = this._image.maxBoundsX - this._image.minBoundsX; + const modelSizeY = this._image.maxBoundsY - this._image.minBoundsY; + const modelSizeZ = this._image.maxBoundsZ - this._image.minBoundsZ; + const maxBounds = Math.max(modelSizeX, Math.max(modelSizeY, modelSizeZ)); + const boundsScaling = maxBounds == 0 ? 1 : 1 / maxBounds; + (0, _glMatrix.vec3).set(modelPosition, this._main.mMatrix[12], this._main.mMatrix[13], this._main.mMatrix[14]); + if (this._image instanceof (0, _imageJs.ImageQuad)) { + const imageQuad = this._image; + const position = (0, _glMatrix.vec3).fromValues((imageQuad.minBoundsX + imageQuad.maxBoundsX) / 2, (imageQuad.minBoundsY + imageQuad.maxBoundsY) / 2, (imageQuad.minBoundsZ + imageQuad.maxBoundsZ) / 2); + (0, _glMatrix.vec3).subtract(position, imageQuad.position, position); + (0, _glMatrix.vec3).scale(position, position, boundsScaling); + (0, _glMatrix.vec3).scale(position, position, modelScale); + (0, _glMatrix.vec3).transformQuat(position, position, modelRotation); + (0, _glMatrix.vec3).add(position, position, modelPosition); + const hittableRotatedXyRectOptions = { + center0: position, + center1: position, + time0: 1, + time1: 1, + size0: (0, _glMatrix.vec2).fromValues(imageQuad.width * boundsScaling * modelScale / 2, imageQuad.height * boundsScaling * modelScale / 2), + size1: (0, _glMatrix.vec2).fromValues(imageQuad.width * boundsScaling * modelScale / 2, imageQuad.height * boundsScaling * modelScale / 2), + material: material, + texCoord0: imageQuad.texCoord0, + texCoord1: imageQuad.texCoord1, + rotation0: imageQuad.rotation, + rotation1: imageQuad.rotation + }; + this.hittable = new (0, _hittableJs.HittableRotatedXyRect)(hittableRotatedXyRectOptions); + } else if (this._image instanceof (0, _imageJs.ImageSphere)) { + const imageSphere = this._image; + const position = imageSphere.position; + (0, _glMatrix.vec3).subtract(position, imageSphere.position, position); + (0, _glMatrix.vec3).scale(position, position, boundsScaling); + (0, _glMatrix.vec3).scale(position, position, modelScale); + (0, _glMatrix.vec3).transformQuat(position, position, modelRotation); + (0, _glMatrix.vec3).add(position, position, modelPosition); + const hittableSphereOptions = { + center0: position, + center1: position, + time0: 1, + time1: 1, + radius: imageSphere.radius * boundsScaling, + material: material + }; + this.hittable = new (0, _hittableJs.HittableSphere)(hittableSphereOptions); } - if (moveTop) this.element.style.top = `${position.clientY}px`; - this.element.style.left = `${position.clientX}px`; - this.child.addEventListener("mouseenter", this.finalizeHandler); - this.child.addEventListener("mousemove", this.finalizeHandler); - this.child.addEventListener("mouseover", this.finalizeHandler); + if (this.hasChangedCallback) this.hasChangedCallback(); } } - destroy() { - this.child.removeEventListener("mouseenter", this.finalizeHandler); - this.child.removeEventListener("mousemove", this.finalizeHandler); - this.child.removeEventListener("mouseover", this.finalizeHandler); - if (this.element) document.body.removeChild(this.element); - this.element = null; - } } -function cleanDataItem(item) { - const ret = {}; - for(const columnName in item){ - if (columnName === (0, _constants.GL_ORDINAL)) continue; - if ((0, _util.isInternalFieldName)(columnName)) continue; - ret[columnName] = item[columnName]; + +},{"gl-matrix":"5x28d","../../components/image.js":"kwtZG","./hittable.js":"5cw7N","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"72uDI":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "LabelSetVisual", ()=>LabelSetVisual); +var _glMatrix = require("gl-matrix"); +var _vertexJs = require("../../vertex.js"); +var _hittableJs = require("./hittable.js"); +class LabelSetVisual { + get isInitialized() { + return this._isInitialized; } - return ret; -} -function getRows(item) { - const rows = []; - for(const columnName in item){ - const value = item[columnName]; - let content; - switch(value){ - case null: - content = _vegaMorphcharts.util.createElement("i", null, "null"); - break; - case undefined: - content = _vegaMorphcharts.util.createElement("i", null, "undefined"); - break; - default: - content = value.toString(); + get label() { + return this._labelSet; + } + render(elapsedTime) {} + constructor(core, main, labelSet){ + this._core = core; + this._main = main; + this._labelSet = labelSet; + this.isVisible = true; + labelSet.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; + if (!this._labelSet.isInitialized) this._labelSet.initialize(); + if (this._labelSet.text && this._labelSet.text.length > 0) this._hasChanged = true; + this._isInitialized = true; + } + update() { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + this.hittables = []; + const modelPosition = (0, _glMatrix.vec3).create(); + const modelScale = this._core.getModelScale(); + const modelRotation = (0, _glMatrix.quat).create(); + this._core.getModelRotation(modelRotation); + (0, _glMatrix.vec3).set(modelPosition, this._main.mMatrix[12], this._main.mMatrix[13], this._main.mMatrix[14]); + const glpyhRotation = (0, _glMatrix.quat).create(); + const glyphInvRotation = (0, _glMatrix.quat).create(); + const position0 = (0, _glMatrix.vec3).create(); + const position1 = (0, _glMatrix.vec3).create(); + const dataView = this._labelSet.verticesView; + const labelCount = this._labelSet.text.length; + let glyphIndex = 0; + for(let i = 0; i < labelCount; i++){ + const material = this._labelSet.material !== undefined ? this._main.materials[this._labelSet.material] : this._labelSet.materials ? this._main.materials[this._labelSet.materials[i]] : this._main.config.defaultTextMaterial; + const glyphCount = this._labelSet.text[i].length; + for(let j = 0; j < glyphCount; j++){ + (0, _vertexJs.PositionTexturePickVertex).getPosition(dataView, glyphIndex * 4 + 2, position0); + (0, _vertexJs.PositionTexturePickVertex).getPosition(dataView, glyphIndex * 4 + 1, position1); + (0, _glMatrix.vec3).scale(position0, position0, modelScale); + (0, _glMatrix.vec3).scale(position1, position1, modelScale); + (0, _glMatrix.vec3).transformQuat(position0, position0, modelRotation); + (0, _glMatrix.vec3).transformQuat(position1, position1, modelRotation); + (0, _glMatrix.vec3).add(position0, position0, modelPosition); + (0, _glMatrix.vec3).add(position1, position1, modelPosition); + const centroid = (0, _glMatrix.vec3).create(); + (0, _glMatrix.vec3).add(centroid, position0, position1); + (0, _glMatrix.vec3).scale(centroid, centroid, 0.5); + if (this._labelSet.rotation) (0, _glMatrix.quat).set(glpyhRotation, this._labelSet.rotation[0], this._labelSet.rotation[1], this._labelSet.rotation[2], this._labelSet.rotation[3]); + else if (this._labelSet.rotations) (0, _glMatrix.quat).set(glpyhRotation, this._labelSet.rotations[i * 4], this._labelSet.rotations[i * 4 + 1], this._labelSet.rotations[i * 4 + 2], this._labelSet.rotations[i * 4 + 3]); + else (0, _glMatrix.quat).identity(glpyhRotation); + const rotation = (0, _glMatrix.quat).clone(glpyhRotation); + (0, _glMatrix.quat).multiply(rotation, modelRotation, rotation); + (0, _glMatrix.quat).conjugate(glyphInvRotation, rotation); + (0, _glMatrix.vec3).subtract(position0, position0, centroid); + (0, _glMatrix.vec3).subtract(position1, position1, centroid); + (0, _glMatrix.vec3).transformQuat(position0, position0, glyphInvRotation); + (0, _glMatrix.vec3).transformQuat(position1, position1, glyphInvRotation); + (0, _glMatrix.vec3).add(position0, position0, centroid); + (0, _glMatrix.vec3).add(position1, position1, centroid); + const texCoord0 = (0, _glMatrix.vec2).create(); + const texCoord1 = (0, _glMatrix.vec2).create(); + (0, _vertexJs.PositionTexturePickVertex).getTexCoord(dataView, glyphIndex * 4 + 2, texCoord0); + (0, _vertexJs.PositionTexturePickVertex).getTexCoord(dataView, glyphIndex * 4 + 1, texCoord1); + const hittableFontOptions = { + center0: centroid, + center1: centroid, + time0: 1, + time1: 1, + size0: (0, _glMatrix.vec2).fromValues((position1[0] - position0[0]) / 2, (position1[1] - position0[1]) / 2), + size1: (0, _glMatrix.vec2).fromValues((position1[0] - position0[0]) / 2, (position1[1] - position0[1]) / 2), + material: material, + texCoord0: texCoord0, + texCoord1: texCoord1, + rotation0: rotation, + rotation1: rotation, + sdfBuffer: this._core.config.sdfBuffer + }; + const hittable = new (0, _hittableJs.HittableRotatedFontXyRect)(hittableFontOptions); + this.hittables.push(hittable); + glyphIndex++; + } + } + if (this.hasChangedCallback) this.hasChangedCallback(); } - //} - rows.push({ - cells: [ - { - content: columnName + ":" - }, - { - content - }, - ] - }); } - return rows; } -const renderTooltip = (props)=>{ - return props.rows.length === 0 ? null : _vegaMorphcharts.util.createElement("div", { - className: `${props.cssPrefix}tooltip` - }, Table({ - rows: props.rows - })); -}; -},{"@msrvida/vega-morphcharts":"guKLg","./constants":"ghoOR","./util":"3kvmX","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bXSAa":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"gl-matrix":"5x28d","../../vertex.js":"4J2YE","./hittable.js":"5cw7N","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dRm64":[function(require,module,exports,__globalThis) { /*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ parcelHelpers.export(exports, "CharacterSet", ()=>CharacterSet); -class CharacterSet { - resetCharacterSet(forceNewCharacterSet, oldInsight, newInsight) { - if (forceNewCharacterSet || needsNewCharacterSet(oldInsight, newInsight)) this.chars = undefined; + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Buffer", ()=>Buffer); +parcelHelpers.export(exports, "TransitionBuffer", ()=>TransitionBuffer); +var _glMatrix = require("gl-matrix"); +var _atlasJs = require("../../atlas.js"); +var _bufferJs = require("../../buffer.js"); +var _indexJs = require("../../index.js"); +var _mainJs = require("../../main.js"); +var _paletteJs = require("../../palette.js"); +var _vertexJs = require("../../vertex.js"); +var _hittableJs = require("./hittable.js"); +var _materialJs = require("./material.js"); +var _mathJs = require("../../helpers/math.js"); +class Buffer extends (0, _bufferJs.BufferBase) { + constructor(core, ids){ + super(core, ids); + this._isInitialized = true; } - getCharacterSet(stage) { - if (!this.chars) { - const map = {}; - const addText = (text)=>{ - Array.from(text).forEach((char)=>{ - map[char] = true; - }); - }; - stage.textData.forEach((t)=>addText(t.text)); - const { x , y } = stage.axes; - [ - x, - y - ].forEach((axes)=>{ - axes.forEach((axis)=>{ - if (axis.tickText) axis.tickText.forEach((t)=>addText(t.text)); - if (axis.title) addText(axis.title.text); - }); - }); - this.chars = Object.keys(map); + update() { + if (this._isInitialized) { + if (this.hasChangedCallback) this.hasChangedCallback(); } - return this.chars; } } -function needsNewCharacterSet(oldInsight, newInsight) { - if (!oldInsight) return true; - if (!newInsight) return true; - if (oldInsight.chart !== newInsight.chart) return true; - if (oldInsight.facetStyle !== newInsight.facetStyle) return true; - if (oldInsight.totalStyle !== newInsight.totalStyle) return true; - if (oldInsight.hideAxes !== newInsight.hideAxes) return true; - if (differentObjectValues(oldInsight.signalValues, newInsight.signalValues)) return true; - if (differentObjectValues(oldInsight.size, newInsight.size)) return true; - const oldColumns = oldInsight.columns; - const newColumns = newInsight.columns; - if (oldColumns.facet !== newColumns.facet) return true; - if (oldColumns.facetV !== newColumns.facetV) return true; - if (oldColumns.x !== newColumns.x) return true; - if (oldColumns.y !== newColumns.y) return true; - if (oldColumns.z !== newColumns.z) return true; - return false; -} -function differentObjectValues(a, b) { - if (!a && !b) return false; - if (!a || !b) return true; - const keys = Object.keys(b); - for(let i = 0; i < keys.length; i++){ - const key = keys[i]; - const ta = typeof a; - const tb = typeof b; - if (ta !== tb) return true; - if (ta === "object") return differentObjectValues(a[key], b[key]); - else { - if (a[key] !== b[key]) return true; +class TransitionBuffer extends (0, _bufferJs.TransitionBufferBase) { + get time0() { + return this._time0; + } + set time0(value) { + if (this._time0 != value) { + this._time0 = value; + this._hasChanged = true; } } - return false; -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"atUZx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "assignTransitionStagger", ()=>assignTransitionStagger); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceSpecs = require("@msrvida/sanddance-specs"); -var _d3Scale = require("d3-scale"); -var _constants = require("./constants"); -function assignTransitionStagger(transition, currentData, selection, presenter) { - const { layerStagger } = presenter.morphchartsref; - const { morphChartsRenderResult } = presenter; - const cubelayer = morphChartsRenderResult.getCubeLayer(); - const range = transition.reverse ? [ - 1, - 0 - ] : [ - 0, - 1 - ]; - if (!transition || transition.type === "ordinal" && !transition.reverse) delete layerStagger.cubes; - else { - const staggerOrders = new Float64Array(cubelayer.positionsX.length); - switch(transition.type){ - case "ordinal": - { - //reverse ordinal - const scale = (0, _d3Scale.scaleLinear)(range).domain([ - 0, - currentData.length - ]); - currentData.forEach((datum, i)=>{ - const glOrdinal = datum[0, _constants.GL_ORDINAL]; - staggerOrders[glOrdinal] = scale(i); - }); - break; - } - case "column": - if (transition.column.quantitative) { - const values = new Float64Array(currentData.length); - currentData.forEach((datum, i)=>{ - values[i] = datum[transition.column.name]; - }); - const stats = (0, _sanddanceSpecs.getStats)(currentData, transition.column); - const scale1 = (0, _d3Scale.scaleLinear)(range).domain([ - stats.min, - stats.max - ]); - currentData.forEach((datum, i)=>{ - const glOrdinal = datum[0, _constants.GL_ORDINAL]; - staggerOrders[glOrdinal] = scale1(values[i]); - }); - } else { - const strings = new Array(currentData.length); - currentData.forEach((datum, i)=>{ - strings[i] = datum[transition.column.name]; - }); - (0, _sanddanceSpecs.getStats)(currentData, transition.column, (distictValues)=>{ - currentData.forEach((datum, i)=>{ - const glOrdinal = datum[0, _constants.GL_ORDINAL]; - const index = distictValues.indexOf(strings[i]); - const staggerOrder = index / distictValues.length; - staggerOrders[glOrdinal] = transition.reverse ? 1 - staggerOrder : staggerOrder; - }); - }); - } - break; - case "position": - { - const dimensions = { - x: cubelayer.positionsX, - y: cubelayer.positionsY, - z: cubelayer.positionsZ - }; - const positions = dimensions[transition.dimension]; - const values1 = new Float64Array(currentData.length); - currentData.forEach((datum, i)=>{ - const glOrdinal = datum[0, _constants.GL_ORDINAL]; - values1[i] = positions[glOrdinal]; - }); - const stats1 = (0, _sanddanceSpecs.getStats)(values1, null, "number", true); - const scale2 = (0, _d3Scale.scaleLinear)(range).domain([ - stats1.min, - stats1.max - ]); - currentData.forEach((datum, i)=>{ - const glOrdinal = datum[0, _constants.GL_ORDINAL]; - staggerOrders[glOrdinal] = scale2(values1[i]); - }); - break; - } + get time1() { + return this._time1; + } + set time1(value) { + if (this._time1 != value) { + this._time1 = value; + this._hasChanged = true; } - layerStagger.cubes = { - staggerOrders, - maxStaggerOrder: 1, - minStaggerOrder: 0 + } + get duration() { + return this._duration; + } + set duration(value) { + if (this._duration != value) { + this._duration = value; + this._hasChanged = true; + } + } + get stagger() { + return this.stagger; + } + set stagger(value) { + if (this._stagger != value) { + this._stagger = value; + this._hasChanged = true; + } + } + constructor(core, main, ids){ + super(core, ids, Buffer, (0, _paletteJs.Palette), (0, _atlasJs.Atlas)); + this._main = main; + this._time0 = 0; + this._time1 = 1; + this._buffer1.hasChangedCallback = ()=>{ + this._hasChanged = true; + }; + this._buffer2.hasChangedCallback = ()=>{ + this._hasChanged = true; }; + this._isInitialized = true; } - cubelayer.update(morphChartsRenderResult.bounds, selection, layerStagger.cubes); -} + update() { + if (this._hasChanged && this._isInitialized) { + this._hasChanged = false; + const start = window.performance.now(); + this.hittables = []; + const modelPosition = (0, _glMatrix.vec3).create(); + const modelScale = this._core.getModelScale(); + const modelRotation = (0, _glMatrix.quat).create(); + this._core.getModelRotation(modelRotation); + this.minY = Number.MAX_VALUE; + (0, _glMatrix.vec3).set(modelPosition, this._main.mMatrix[12], this._main.mMatrix[13], this._main.mMatrix[14]); + const previousBuffer = this.previousBuffer; + const currentBuffer = this.currentBuffer; + const currentUnitTranslation = (0, _glMatrix.vec3).create(); + const previousUnitTranslation = (0, _glMatrix.vec3).create(); + const currentUnitScale = (0, _glMatrix.vec3).create(); + const previousUnitScale = (0, _glMatrix.vec3).create(); + const currentUnitRotation = (0, _glMatrix.quat).create(); + const previousUnitRotation = (0, _glMatrix.quat).create(); + const unitOrder = (0, _glMatrix.vec2).create(); + const transitionDuration = this._duration / (this._duration + this._stagger); + for(let j = 0; j < currentBuffer.ids.length; j++){ + (0, _vertexJs.UnitVertex).getOrder(currentBuffer.dataView, j, unitOrder); + const startTime = unitOrder[1] * (1 - transitionDuration); + const animation0 = (0, _mathJs.MathHelper).clamp((this._time0 - startTime) / transitionDuration, 0, 1); + const animation1 = (0, _mathJs.MathHelper).clamp((this._time1 - startTime) / transitionDuration, 0, 1); + const unitScale0 = (0, _glMatrix.vec3).create(); + const unitScale1 = (0, _glMatrix.vec3).create(); + (0, _vertexJs.UnitVertex).getScale(currentBuffer.dataView, j, currentUnitScale); + (0, _vertexJs.UnitVertex).getScale(previousBuffer.dataView, j, previousUnitScale); + (0, _glMatrix.vec3).lerp(unitScale0, previousUnitScale, currentUnitScale, animation0); + (0, _glMatrix.vec3).lerp(unitScale1, previousUnitScale, currentUnitScale, animation1); + const unitTranslation0 = (0, _glMatrix.vec3).create(); + const unitTranslation1 = (0, _glMatrix.vec3).create(); + (0, _vertexJs.UnitVertex).getTranslation(currentBuffer.dataView, j, currentUnitTranslation); + (0, _vertexJs.UnitVertex).getTranslation(previousBuffer.dataView, j, previousUnitTranslation); + (0, _glMatrix.vec3).lerp(unitTranslation0, previousUnitTranslation, currentUnitTranslation, animation0); + (0, _glMatrix.vec3).lerp(unitTranslation1, previousUnitTranslation, currentUnitTranslation, animation1); + const unitRotation0 = (0, _glMatrix.quat).create(); + const unitRotation1 = (0, _glMatrix.quat).create(); + (0, _vertexJs.UnitVertex).getRotation(currentBuffer.dataView, j, currentUnitRotation); + (0, _vertexJs.UnitVertex).getRotation(previousBuffer.dataView, j, previousUnitRotation); + (0, _glMatrix.quat).slerp(unitRotation0, previousUnitRotation, currentUnitRotation, animation0); + (0, _glMatrix.quat).slerp(unitRotation1, previousUnitRotation, currentUnitRotation, animation1); + (0, _glMatrix.quat).multiply(unitRotation0, modelRotation, unitRotation0); + (0, _glMatrix.quat).multiply(unitRotation1, modelRotation, unitRotation1); + (0, _glMatrix.vec3).scale(unitTranslation0, unitTranslation0, modelScale); + (0, _glMatrix.vec3).scale(unitTranslation1, unitTranslation1, modelScale); + (0, _glMatrix.vec3).transformQuat(unitTranslation0, unitTranslation0, modelRotation); + (0, _glMatrix.vec3).transformQuat(unitTranslation1, unitTranslation1, modelRotation); + (0, _glMatrix.vec3).add(unitTranslation0, unitTranslation0, modelPosition); + (0, _glMatrix.vec3).add(unitTranslation1, unitTranslation1, modelPosition); + (0, _glMatrix.vec3).scale(unitScale0, unitScale0, modelScale / 2); + (0, _glMatrix.vec3).scale(unitScale1, unitScale1, modelScale / 2); + unitScale0[0] = Math.max(unitScale0[0], 0.00001); + unitScale0[1] = Math.max(unitScale0[1], 0.00001); + unitScale0[2] = Math.max(unitScale0[2], 0.00001); + unitScale1[0] = Math.max(unitScale1[0], 0.00001); + unitScale1[1] = Math.max(unitScale1[1], 0.00001); + unitScale1[2] = Math.max(unitScale1[2], 0.00001); + const endTime = startTime + transitionDuration; + const time0 = Math.min(Math.max((startTime - this._time0) / (this._time1 - this.time0), 0), 1); + const time1 = Math.min(Math.max((endTime - this._time0) / (this._time1 - this.time0), 0), 1); + const materialId = (0, _vertexJs.UnitVertex).getMaterial(currentBuffer.dataView, j); + const material = this._main.materials && this._main.materials.length > materialId ? this._main.materials[materialId] : this._main.config.defaultMaterial; + let hittable; + let unitTexCoord; + switch(currentBuffer.unitType){ + case (0, _indexJs.UnitType).sphere: + case (0, _indexJs.UnitType).sphereSdf: + hittable = new (0, _hittableJs.HittableSphere)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius: unitScale0[0], + material: material + }); + break; + case (0, _indexJs.UnitType).disk: + unitTexCoord = (0, _glMatrix.vec4).create(); + (0, _vertexJs.UnitVertex).getTexCoord(currentBuffer.dataView, j, unitTexCoord); + if (unitRotation1[3] == 1) hittable = new (0, _hittableJs.HittableXyDisk)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius0: unitScale0[0], + radius1: unitScale1[0], + material: material, + texCoord0: (0, _glMatrix.vec2).fromValues(unitTexCoord[0], unitTexCoord[3]), + texCoord1: (0, _glMatrix.vec2).fromValues(unitTexCoord[2], unitTexCoord[1]) + }); + else hittable = new (0, _hittableJs.HittableRotatedXyDisk)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius0: unitScale0[0], + radius1: unitScale1[0], + rotation0: unitRotation0, + rotation1: unitRotation1, + material: material, + texCoord0: (0, _glMatrix.vec2).fromValues(unitTexCoord[0], unitTexCoord[3]), + texCoord1: (0, _glMatrix.vec2).fromValues(unitTexCoord[2], unitTexCoord[1]) + }); + break; + case (0, _indexJs.UnitType).block: + if (unitRotation1[3] == 1) hittable = new (0, _hittableJs.HittableBox)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: unitScale0, + size1: unitScale1, + material: material + }); + else hittable = new (0, _hittableJs.HittableRotatedBox)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: unitScale0, + size1: unitScale1, + rotation0: unitRotation0, + rotation1: unitRotation1, + material: material + }); + break; + case (0, _indexJs.UnitType).sdf: + unitTexCoord = (0, _glMatrix.vec4).create(); + (0, _vertexJs.UnitVertex).getTexCoord(currentBuffer.dataView, j, unitTexCoord); + const texId = (0, _vertexJs.UnitVertex).getTexture(currentBuffer.dataView, j); + const sdfBuffer = (0, _vertexJs.UnitVertex).getSdfBuffer(currentBuffer.dataView, j); + const sdfBorder = (0, _vertexJs.UnitVertex).getSdfBorder(currentBuffer.dataView, j); + const options = { + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: (0, _glMatrix.vec2).fromValues(unitScale0[0], unitScale0[1]), + size1: (0, _glMatrix.vec2).fromValues(unitScale1[0], unitScale1[1]), + texCoord0: (0, _glMatrix.vec2).fromValues(unitTexCoord[0], unitTexCoord[3]), + texCoord1: (0, _glMatrix.vec2).fromValues(unitTexCoord[2], unitTexCoord[1]), + rotation0: unitRotation0, + rotation1: unitRotation1, + material: material, + texId: texId, + sdfBuffer: sdfBuffer, + sdfBorder: sdfBorder + }; + hittable = unitRotation1[3] == 1 ? new (0, _hittableJs.HittableSdfXyRect)(options) : new (0, _hittableJs.HittableRotatedSdfXyRect)(options); + break; + case (0, _indexJs.UnitType).blockSdf: + if (unitRotation1[3] == 1) hittable = new (0, _hittableJs.HittableBoxSdf)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: unitScale0, + size1: unitScale1, + rounding: Math.min(Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale0[0]), unitScale0[1]), unitScale0[2]), + material: material + }); + else hittable = new (0, _hittableJs.HittableRotatedBoxSdf)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: unitScale0, + size1: unitScale1, + rounding: Math.min(Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale0[0]), unitScale0[1]), unitScale0[2]), + material: material, + rotation0: unitRotation0, + rotation1: unitRotation1 + }); + break; + case (0, _indexJs.UnitType).ringSdf: + if (unitRotation1[3] == 1) hittable = new (0, _hittableJs.HittableRingSdf)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: unitScale0, + size1: unitScale1, + angle0: (0, _vertexJs.UnitVertex).getParameter1(currentBuffer.dataView, j), + innerRadius0: (0, _vertexJs.UnitVertex).getParameter2(currentBuffer.dataView, j), + rounding: Math.min(Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale0[0]), unitScale0[1]), unitScale0[2]), + material: material + }); + else hittable = new (0, _hittableJs.HittableRotatedRingSdf)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + size0: unitScale0, + size1: unitScale1, + angle0: (0, _vertexJs.UnitVertex).getParameter1(currentBuffer.dataView, j), + innerRadius0: (0, _vertexJs.UnitVertex).getParameter2(currentBuffer.dataView, j), + rounding: Math.min(Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale0[0]), unitScale0[1]), unitScale0[2]), + material: material, + rotation0: unitRotation0, + rotation1: unitRotation1 + }); + break; + case (0, _indexJs.UnitType).cylinder: + hittable = new (0, _hittableJs.HittableCylinder)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius: unitScale0[0], + height: unitScale0[1], + rotation0: unitRotation0, + rotation1: unitRotation1, + material: material + }); + break; + case (0, _indexJs.UnitType).cylinderSdf: + hittable = new (0, _hittableJs.HittableCylinderSdf)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius: unitScale0[0], + height: unitScale0[1], + rounding: Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale0[0]), unitScale0[1]), + material: material, + rotation0: unitRotation0, + rotation1: unitRotation1 + }); + break; + case (0, _indexJs.UnitType).hexPrism: + hittable = new (0, _hittableJs.HittableHexPrism)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius: unitScale0[0], + height: unitScale0[1], + material: material + }); + break; + case (0, _indexJs.UnitType).hexPrismSdf: + hittable = new (0, _hittableJs.HittableHexPrismSdf)({ + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + radius: unitScale0[0], + height: unitScale0[1], + rounding: Math.min(Math.min((0, _vertexJs.UnitVertex).getRounding(currentBuffer.dataView, j) * modelScale, unitScale0[0]), unitScale0[1]), + material: material + }); + break; + } + if (hittable.material instanceof (0, _materialJs.IsotropicMaterial)) this.hittables.push(new (0, _hittableJs.HittableConstantMedium)({ + boundary: hittable, + center0: unitTranslation0, + center1: unitTranslation1, + time0: time0, + time1: time1, + material: hittable.material + })); + else this.hittables.push(hittable); + this.minY = Math.min(hittable.bounds.min[1], this.minY); + } + if (this.hasChangedCallback) this.hasChangedCallback(); + this._core.log.write((0, _mainJs.LogLevel).info, `buffer updated ${this._length} ${Math.round(window.performance.now() - start)}ms`); + } + } +} -},{"@msrvida/sanddance-specs":"4hjOh","d3-scale":"dmwZW","./constants":"ghoOR","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dmwZW":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"gl-matrix":"5x28d","../../atlas.js":"2peXi","../../buffer.js":"itbJk","../../index.js":"9s7CR","../../main.js":"f421K","../../palette.js":"hZb65","../../vertex.js":"4J2YE","./hittable.js":"5cw7N","./material.js":"jQJhi","../../helpers/math.js":"f65d0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6DWH0":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "scaleBand", ()=>(0, _bandJsDefault.default)); -parcelHelpers.export(exports, "scalePoint", ()=>(0, _bandJs.point)); -parcelHelpers.export(exports, "scaleIdentity", ()=>(0, _identityJsDefault.default)); -parcelHelpers.export(exports, "scaleLinear", ()=>(0, _linearJsDefault.default)); -parcelHelpers.export(exports, "scaleLog", ()=>(0, _logJsDefault.default)); -parcelHelpers.export(exports, "scaleSymlog", ()=>(0, _symlogJsDefault.default)); -parcelHelpers.export(exports, "scaleOrdinal", ()=>(0, _ordinalJsDefault.default)); -parcelHelpers.export(exports, "scaleImplicit", ()=>(0, _ordinalJs.implicit)); -parcelHelpers.export(exports, "scalePow", ()=>(0, _powJsDefault.default)); -parcelHelpers.export(exports, "scaleSqrt", ()=>(0, _powJs.sqrt)); -parcelHelpers.export(exports, "scaleRadial", ()=>(0, _radialJsDefault.default)); -parcelHelpers.export(exports, "scaleQuantile", ()=>(0, _quantileJsDefault.default)); -parcelHelpers.export(exports, "scaleQuantize", ()=>(0, _quantizeJsDefault.default)); -parcelHelpers.export(exports, "scaleThreshold", ()=>(0, _thresholdJsDefault.default)); -parcelHelpers.export(exports, "scaleTime", ()=>(0, _timeJsDefault.default)); -parcelHelpers.export(exports, "scaleUtc", ()=>(0, _utcTimeJsDefault.default)); -parcelHelpers.export(exports, "scaleSequential", ()=>(0, _sequentialJsDefault.default)); -parcelHelpers.export(exports, "scaleSequentialLog", ()=>(0, _sequentialJs.sequentialLog)); -parcelHelpers.export(exports, "scaleSequentialPow", ()=>(0, _sequentialJs.sequentialPow)); -parcelHelpers.export(exports, "scaleSequentialSqrt", ()=>(0, _sequentialJs.sequentialSqrt)); -parcelHelpers.export(exports, "scaleSequentialSymlog", ()=>(0, _sequentialJs.sequentialSymlog)); -parcelHelpers.export(exports, "scaleSequentialQuantile", ()=>(0, _sequentialQuantileJsDefault.default)); -parcelHelpers.export(exports, "scaleDiverging", ()=>(0, _divergingJsDefault.default)); -parcelHelpers.export(exports, "scaleDivergingLog", ()=>(0, _divergingJs.divergingLog)); -parcelHelpers.export(exports, "scaleDivergingPow", ()=>(0, _divergingJs.divergingPow)); -parcelHelpers.export(exports, "scaleDivergingSqrt", ()=>(0, _divergingJs.divergingSqrt)); -parcelHelpers.export(exports, "scaleDivergingSymlog", ()=>(0, _divergingJs.divergingSymlog)); -parcelHelpers.export(exports, "tickFormat", ()=>(0, _tickFormatJsDefault.default)); -var _bandJs = require("./band.js"); -var _bandJsDefault = parcelHelpers.interopDefault(_bandJs); -var _identityJs = require("./identity.js"); -var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); -var _linearJs = require("./linear.js"); -var _linearJsDefault = parcelHelpers.interopDefault(_linearJs); -var _logJs = require("./log.js"); -var _logJsDefault = parcelHelpers.interopDefault(_logJs); -var _symlogJs = require("./symlog.js"); -var _symlogJsDefault = parcelHelpers.interopDefault(_symlogJs); -var _ordinalJs = require("./ordinal.js"); -var _ordinalJsDefault = parcelHelpers.interopDefault(_ordinalJs); -var _powJs = require("./pow.js"); -var _powJsDefault = parcelHelpers.interopDefault(_powJs); -var _radialJs = require("./radial.js"); -var _radialJsDefault = parcelHelpers.interopDefault(_radialJs); -var _quantileJs = require("./quantile.js"); -var _quantileJsDefault = parcelHelpers.interopDefault(_quantileJs); -var _quantizeJs = require("./quantize.js"); -var _quantizeJsDefault = parcelHelpers.interopDefault(_quantizeJs); -var _thresholdJs = require("./threshold.js"); -var _thresholdJsDefault = parcelHelpers.interopDefault(_thresholdJs); -var _timeJs = require("./time.js"); -var _timeJsDefault = parcelHelpers.interopDefault(_timeJs); -var _utcTimeJs = require("./utcTime.js"); -var _utcTimeJsDefault = parcelHelpers.interopDefault(_utcTimeJs); -var _sequentialJs = require("./sequential.js"); -var _sequentialJsDefault = parcelHelpers.interopDefault(_sequentialJs); -var _sequentialQuantileJs = require("./sequentialQuantile.js"); -var _sequentialQuantileJsDefault = parcelHelpers.interopDefault(_sequentialQuantileJs); -var _divergingJs = require("./diverging.js"); -var _divergingJsDefault = parcelHelpers.interopDefault(_divergingJs); -var _tickFormatJs = require("./tickFormat.js"); -var _tickFormatJsDefault = parcelHelpers.interopDefault(_tickFormatJs); +parcelHelpers.export(exports, "Constants", ()=>Constants); +class Constants { +} +Constants.SHADOW_OFFSET = 0.001; -},{"./band.js":false,"./identity.js":false,"./linear.js":"3T3ag","./log.js":false,"./symlog.js":false,"./ordinal.js":false,"./pow.js":false,"./radial.js":false,"./quantile.js":false,"./quantize.js":false,"./threshold.js":false,"./time.js":false,"./utcTime.js":false,"./sequential.js":false,"./sequentialQuantile.js":false,"./diverging.js":false,"./tickFormat.js":"3sBVK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3T3ag":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"54e1Z":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "linearish", ()=>linearish); -var _d3Array = require("d3-array"); -var _continuousJs = require("./continuous.js"); -var _continuousJsDefault = parcelHelpers.interopDefault(_continuousJs); -var _initJs = require("./init.js"); -var _tickFormatJs = require("./tickFormat.js"); -var _tickFormatJsDefault = parcelHelpers.interopDefault(_tickFormatJs); -function linearish(scale) { - var domain = scale.domain; - scale.ticks = function(count) { - var d = domain(); - return (0, _d3Array.ticks)(d[0], d[d.length - 1], count == null ? 10 : count); - }; - scale.tickFormat = function(count, specifier) { - var d = domain(); - return (0, _tickFormatJsDefault.default)(d[0], d[d.length - 1], count == null ? 10 : count, specifier); - }; - scale.nice = function(count) { - if (count == null) count = 10; - var d = domain(); - var i0 = 0; - var i1 = d.length - 1; - var start = d[i0]; - var stop = d[i1]; - var prestep; - var step; - var maxIter = 10; - if (stop < start) { - step = start, start = stop, stop = step; - step = i0, i0 = i1, i1 = step; - } - while(maxIter-- > 0){ - step = (0, _d3Array.tickIncrement)(start, stop, count); - if (step === prestep) { - d[i0] = start; - d[i1] = stop; - return domain(d); - } else if (step > 0) { - start = Math.floor(start / step) * step; - stop = Math.ceil(stop / step) * step; - } else if (step < 0) { - start = Math.ceil(start * step) / step; - stop = Math.floor(stop * step) / step; - } else break; - prestep = step; +parcelHelpers.export(exports, "Ground", ()=>Ground); +class Ground { + constructor(options){ + if (options) { + this.position = options.position; + this.size = options.size; + this.material = options.material; } - return scale; - }; - return scale; -} -function linear() { - var scale = (0, _continuousJsDefault.default)(); - scale.copy = function() { - return (0, _continuousJs.copy)(scale, linear()); - }; - (0, _initJs.initRange).apply(scale, arguments); - return linearish(scale); + } } -exports.default = linear; -},{"d3-array":"48u5D","./continuous.js":"2CuUG","./init.js":"fnuZg","./tickFormat.js":"3sBVK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"48u5D":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dUaaI":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "bisect", ()=>(0, _bisectJsDefault.default)); -parcelHelpers.export(exports, "bisectRight", ()=>(0, _bisectJs.bisectRight)); -parcelHelpers.export(exports, "bisectLeft", ()=>(0, _bisectJs.bisectLeft)); -parcelHelpers.export(exports, "bisectCenter", ()=>(0, _bisectJs.bisectCenter)); -parcelHelpers.export(exports, "ascending", ()=>(0, _ascendingJsDefault.default)); -parcelHelpers.export(exports, "bisector", ()=>(0, _bisectorJsDefault.default)); -parcelHelpers.export(exports, "blur", ()=>(0, _blurJs.blur)); -parcelHelpers.export(exports, "blur2", ()=>(0, _blurJs.blur2)); -parcelHelpers.export(exports, "blurImage", ()=>(0, _blurJs.blurImage)); -parcelHelpers.export(exports, "count", ()=>(0, _countJsDefault.default)); -parcelHelpers.export(exports, "cross", ()=>(0, _crossJsDefault.default)); -parcelHelpers.export(exports, "cumsum", ()=>(0, _cumsumJsDefault.default)); -parcelHelpers.export(exports, "descending", ()=>(0, _descendingJsDefault.default)); -parcelHelpers.export(exports, "deviation", ()=>(0, _deviationJsDefault.default)); -parcelHelpers.export(exports, "extent", ()=>(0, _extentJsDefault.default)); -parcelHelpers.export(exports, "Adder", ()=>(0, _fsumJs.Adder)); -parcelHelpers.export(exports, "fsum", ()=>(0, _fsumJs.fsum)); -parcelHelpers.export(exports, "fcumsum", ()=>(0, _fsumJs.fcumsum)); -parcelHelpers.export(exports, "group", ()=>(0, _groupJsDefault.default)); -parcelHelpers.export(exports, "flatGroup", ()=>(0, _groupJs.flatGroup)); -parcelHelpers.export(exports, "flatRollup", ()=>(0, _groupJs.flatRollup)); -parcelHelpers.export(exports, "groups", ()=>(0, _groupJs.groups)); -parcelHelpers.export(exports, "index", ()=>(0, _groupJs.index)); -parcelHelpers.export(exports, "indexes", ()=>(0, _groupJs.indexes)); -parcelHelpers.export(exports, "rollup", ()=>(0, _groupJs.rollup)); -parcelHelpers.export(exports, "rollups", ()=>(0, _groupJs.rollups)); -parcelHelpers.export(exports, "groupSort", ()=>(0, _groupSortJsDefault.default)); -parcelHelpers.export(exports, "bin", ()=>(0, _binJsDefault.default)) // Deprecated; use bin. -; -parcelHelpers.export(exports, "histogram", ()=>(0, _binJsDefault.default)); -parcelHelpers.export(exports, "thresholdFreedmanDiaconis", ()=>(0, _freedmanDiaconisJsDefault.default)); -parcelHelpers.export(exports, "thresholdScott", ()=>(0, _scottJsDefault.default)); -parcelHelpers.export(exports, "thresholdSturges", ()=>(0, _sturgesJsDefault.default)); -parcelHelpers.export(exports, "max", ()=>(0, _maxJsDefault.default)); -parcelHelpers.export(exports, "maxIndex", ()=>(0, _maxIndexJsDefault.default)); -parcelHelpers.export(exports, "mean", ()=>(0, _meanJsDefault.default)); -parcelHelpers.export(exports, "median", ()=>(0, _medianJsDefault.default)); -parcelHelpers.export(exports, "medianIndex", ()=>(0, _medianJs.medianIndex)); -parcelHelpers.export(exports, "merge", ()=>(0, _mergeJsDefault.default)); -parcelHelpers.export(exports, "min", ()=>(0, _minJsDefault.default)); -parcelHelpers.export(exports, "minIndex", ()=>(0, _minIndexJsDefault.default)); -parcelHelpers.export(exports, "mode", ()=>(0, _modeJsDefault.default)); -parcelHelpers.export(exports, "nice", ()=>(0, _niceJsDefault.default)); -parcelHelpers.export(exports, "pairs", ()=>(0, _pairsJsDefault.default)); -parcelHelpers.export(exports, "permute", ()=>(0, _permuteJsDefault.default)); -parcelHelpers.export(exports, "quantile", ()=>(0, _quantileJsDefault.default)); -parcelHelpers.export(exports, "quantileIndex", ()=>(0, _quantileJs.quantileIndex)); -parcelHelpers.export(exports, "quantileSorted", ()=>(0, _quantileJs.quantileSorted)); -parcelHelpers.export(exports, "quickselect", ()=>(0, _quickselectJsDefault.default)); -parcelHelpers.export(exports, "range", ()=>(0, _rangeJsDefault.default)); -parcelHelpers.export(exports, "rank", ()=>(0, _rankJsDefault.default)); -parcelHelpers.export(exports, "least", ()=>(0, _leastJsDefault.default)); -parcelHelpers.export(exports, "leastIndex", ()=>(0, _leastIndexJsDefault.default)); -parcelHelpers.export(exports, "greatest", ()=>(0, _greatestJsDefault.default)); -parcelHelpers.export(exports, "greatestIndex", ()=>(0, _greatestIndexJsDefault.default)); -parcelHelpers.export(exports, "scan", ()=>(0, _scanJsDefault.default)) // Deprecated; use leastIndex. -; -parcelHelpers.export(exports, "shuffle", ()=>(0, _shuffleJsDefault.default)); -parcelHelpers.export(exports, "shuffler", ()=>(0, _shuffleJs.shuffler)); -parcelHelpers.export(exports, "sum", ()=>(0, _sumJsDefault.default)); -parcelHelpers.export(exports, "ticks", ()=>(0, _ticksJsDefault.default)); -parcelHelpers.export(exports, "tickIncrement", ()=>(0, _ticksJs.tickIncrement)); -parcelHelpers.export(exports, "tickStep", ()=>(0, _ticksJs.tickStep)); -parcelHelpers.export(exports, "transpose", ()=>(0, _transposeJsDefault.default)); -parcelHelpers.export(exports, "variance", ()=>(0, _varianceJsDefault.default)); -parcelHelpers.export(exports, "zip", ()=>(0, _zipJsDefault.default)); -parcelHelpers.export(exports, "every", ()=>(0, _everyJsDefault.default)); -parcelHelpers.export(exports, "some", ()=>(0, _someJsDefault.default)); -parcelHelpers.export(exports, "filter", ()=>(0, _filterJsDefault.default)); -parcelHelpers.export(exports, "map", ()=>(0, _mapJsDefault.default)); -parcelHelpers.export(exports, "reduce", ()=>(0, _reduceJsDefault.default)); -parcelHelpers.export(exports, "reverse", ()=>(0, _reverseJsDefault.default)); -parcelHelpers.export(exports, "sort", ()=>(0, _sortJsDefault.default)); -parcelHelpers.export(exports, "difference", ()=>(0, _differenceJsDefault.default)); -parcelHelpers.export(exports, "disjoint", ()=>(0, _disjointJsDefault.default)); -parcelHelpers.export(exports, "intersection", ()=>(0, _intersectionJsDefault.default)); -parcelHelpers.export(exports, "subset", ()=>(0, _subsetJsDefault.default)); -parcelHelpers.export(exports, "superset", ()=>(0, _supersetJsDefault.default)); -parcelHelpers.export(exports, "union", ()=>(0, _unionJsDefault.default)); -parcelHelpers.export(exports, "InternMap", ()=>(0, _internmap.InternMap)); -parcelHelpers.export(exports, "InternSet", ()=>(0, _internmap.InternSet)); -var _bisectJs = require("./bisect.js"); -var _bisectJsDefault = parcelHelpers.interopDefault(_bisectJs); -var _ascendingJs = require("./ascending.js"); -var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); -var _bisectorJs = require("./bisector.js"); -var _bisectorJsDefault = parcelHelpers.interopDefault(_bisectorJs); -var _blurJs = require("./blur.js"); -var _countJs = require("./count.js"); -var _countJsDefault = parcelHelpers.interopDefault(_countJs); -var _crossJs = require("./cross.js"); -var _crossJsDefault = parcelHelpers.interopDefault(_crossJs); -var _cumsumJs = require("./cumsum.js"); -var _cumsumJsDefault = parcelHelpers.interopDefault(_cumsumJs); -var _descendingJs = require("./descending.js"); -var _descendingJsDefault = parcelHelpers.interopDefault(_descendingJs); -var _deviationJs = require("./deviation.js"); -var _deviationJsDefault = parcelHelpers.interopDefault(_deviationJs); -var _extentJs = require("./extent.js"); -var _extentJsDefault = parcelHelpers.interopDefault(_extentJs); -var _fsumJs = require("./fsum.js"); -var _groupJs = require("./group.js"); -var _groupJsDefault = parcelHelpers.interopDefault(_groupJs); -var _groupSortJs = require("./groupSort.js"); -var _groupSortJsDefault = parcelHelpers.interopDefault(_groupSortJs); -var _binJs = require("./bin.js"); -var _binJsDefault = parcelHelpers.interopDefault(_binJs); -var _freedmanDiaconisJs = require("./threshold/freedmanDiaconis.js"); -var _freedmanDiaconisJsDefault = parcelHelpers.interopDefault(_freedmanDiaconisJs); -var _scottJs = require("./threshold/scott.js"); -var _scottJsDefault = parcelHelpers.interopDefault(_scottJs); -var _sturgesJs = require("./threshold/sturges.js"); -var _sturgesJsDefault = parcelHelpers.interopDefault(_sturgesJs); -var _maxJs = require("./max.js"); -var _maxJsDefault = parcelHelpers.interopDefault(_maxJs); -var _maxIndexJs = require("./maxIndex.js"); -var _maxIndexJsDefault = parcelHelpers.interopDefault(_maxIndexJs); -var _meanJs = require("./mean.js"); -var _meanJsDefault = parcelHelpers.interopDefault(_meanJs); -var _medianJs = require("./median.js"); -var _medianJsDefault = parcelHelpers.interopDefault(_medianJs); -var _mergeJs = require("./merge.js"); -var _mergeJsDefault = parcelHelpers.interopDefault(_mergeJs); -var _minJs = require("./min.js"); -var _minJsDefault = parcelHelpers.interopDefault(_minJs); -var _minIndexJs = require("./minIndex.js"); -var _minIndexJsDefault = parcelHelpers.interopDefault(_minIndexJs); -var _modeJs = require("./mode.js"); -var _modeJsDefault = parcelHelpers.interopDefault(_modeJs); -var _niceJs = require("./nice.js"); -var _niceJsDefault = parcelHelpers.interopDefault(_niceJs); -var _pairsJs = require("./pairs.js"); -var _pairsJsDefault = parcelHelpers.interopDefault(_pairsJs); -var _permuteJs = require("./permute.js"); -var _permuteJsDefault = parcelHelpers.interopDefault(_permuteJs); -var _quantileJs = require("./quantile.js"); -var _quantileJsDefault = parcelHelpers.interopDefault(_quantileJs); -var _quickselectJs = require("./quickselect.js"); -var _quickselectJsDefault = parcelHelpers.interopDefault(_quickselectJs); -var _rangeJs = require("./range.js"); -var _rangeJsDefault = parcelHelpers.interopDefault(_rangeJs); -var _rankJs = require("./rank.js"); -var _rankJsDefault = parcelHelpers.interopDefault(_rankJs); -var _leastJs = require("./least.js"); -var _leastJsDefault = parcelHelpers.interopDefault(_leastJs); -var _leastIndexJs = require("./leastIndex.js"); -var _leastIndexJsDefault = parcelHelpers.interopDefault(_leastIndexJs); -var _greatestJs = require("./greatest.js"); -var _greatestJsDefault = parcelHelpers.interopDefault(_greatestJs); -var _greatestIndexJs = require("./greatestIndex.js"); -var _greatestIndexJsDefault = parcelHelpers.interopDefault(_greatestIndexJs); -var _scanJs = require("./scan.js"); -var _scanJsDefault = parcelHelpers.interopDefault(_scanJs); -var _shuffleJs = require("./shuffle.js"); -var _shuffleJsDefault = parcelHelpers.interopDefault(_shuffleJs); -var _sumJs = require("./sum.js"); -var _sumJsDefault = parcelHelpers.interopDefault(_sumJs); -var _ticksJs = require("./ticks.js"); -var _ticksJsDefault = parcelHelpers.interopDefault(_ticksJs); -var _transposeJs = require("./transpose.js"); -var _transposeJsDefault = parcelHelpers.interopDefault(_transposeJs); -var _varianceJs = require("./variance.js"); -var _varianceJsDefault = parcelHelpers.interopDefault(_varianceJs); -var _zipJs = require("./zip.js"); -var _zipJsDefault = parcelHelpers.interopDefault(_zipJs); -var _everyJs = require("./every.js"); -var _everyJsDefault = parcelHelpers.interopDefault(_everyJs); -var _someJs = require("./some.js"); -var _someJsDefault = parcelHelpers.interopDefault(_someJs); +parcelHelpers.export(exports, "Table", ()=>(0, _tableJs.Table)); +parcelHelpers.export(exports, "ColumnType", ()=>(0, _tableJs.ColumnType)); +parcelHelpers.export(exports, "Filter", ()=>(0, _filterJs.Filter)); +var _tableJs = require("./table.js"); var _filterJs = require("./filter.js"); -var _filterJsDefault = parcelHelpers.interopDefault(_filterJs); -var _mapJs = require("./map.js"); -var _mapJsDefault = parcelHelpers.interopDefault(_mapJs); -var _reduceJs = require("./reduce.js"); -var _reduceJsDefault = parcelHelpers.interopDefault(_reduceJs); -var _reverseJs = require("./reverse.js"); -var _reverseJsDefault = parcelHelpers.interopDefault(_reverseJs); -var _sortJs = require("./sort.js"); -var _sortJsDefault = parcelHelpers.interopDefault(_sortJs); -var _differenceJs = require("./difference.js"); -var _differenceJsDefault = parcelHelpers.interopDefault(_differenceJs); -var _disjointJs = require("./disjoint.js"); -var _disjointJsDefault = parcelHelpers.interopDefault(_disjointJs); -var _intersectionJs = require("./intersection.js"); -var _intersectionJsDefault = parcelHelpers.interopDefault(_intersectionJs); -var _subsetJs = require("./subset.js"); -var _subsetJsDefault = parcelHelpers.interopDefault(_subsetJs); -var _supersetJs = require("./superset.js"); -var _supersetJsDefault = parcelHelpers.interopDefault(_supersetJs); -var _unionJs = require("./union.js"); -var _unionJsDefault = parcelHelpers.interopDefault(_unionJs); -var _internmap = require("internmap"); -},{"./bisect.js":"lxTlH","./ascending.js":"dWA2i","./bisector.js":"9LEno","./blur.js":false,"./count.js":false,"./cross.js":false,"./cumsum.js":false,"./descending.js":"j9J60","./deviation.js":false,"./extent.js":false,"./fsum.js":false,"./group.js":false,"./groupSort.js":false,"./bin.js":false,"./threshold/freedmanDiaconis.js":false,"./threshold/scott.js":false,"./threshold/sturges.js":false,"./max.js":false,"./maxIndex.js":false,"./mean.js":false,"./median.js":false,"./merge.js":false,"./min.js":false,"./minIndex.js":false,"./mode.js":false,"./nice.js":false,"./pairs.js":false,"./permute.js":false,"./quantile.js":false,"./quickselect.js":false,"./range.js":false,"./rank.js":false,"./least.js":false,"./leastIndex.js":false,"./greatest.js":false,"./greatestIndex.js":false,"./scan.js":false,"./shuffle.js":false,"./sum.js":false,"./ticks.js":"hhQBz","./transpose.js":false,"./variance.js":false,"./zip.js":false,"./every.js":false,"./some.js":false,"./filter.js":false,"./map.js":false,"./reduce.js":false,"./reverse.js":false,"./sort.js":false,"./difference.js":false,"./disjoint.js":false,"./intersection.js":false,"./subset.js":false,"./superset.js":false,"./union.js":false,"internmap":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lxTlH":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./table.js":"1Nyfw","./filter.js":"b6FuS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h7YGk":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "bisectRight", ()=>bisectRight); -parcelHelpers.export(exports, "bisectLeft", ()=>bisectLeft); -parcelHelpers.export(exports, "bisectCenter", ()=>bisectCenter); -var _ascendingJs = require("./ascending.js"); -var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); -var _bisectorJs = require("./bisector.js"); -var _bisectorJsDefault = parcelHelpers.interopDefault(_bisectorJs); -var _numberJs = require("./number.js"); -var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); -const ascendingBisect = (0, _bisectorJsDefault.default)((0, _ascendingJsDefault.default)); -const bisectRight = ascendingBisect.right; -const bisectLeft = ascendingBisect.left; -const bisectCenter = (0, _bisectorJsDefault.default)((0, _numberJsDefault.default)).center; -exports.default = bisectRight; - -},{"./ascending.js":"dWA2i","./bisector.js":"9LEno","./number.js":"itBye","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dWA2i":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -function ascending(a, b) { - return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; -} -exports.default = ascending; +parcelHelpers.export(exports, "CameraBase", ()=>(0, _cameraJs.CameraBase)); +parcelHelpers.export(exports, "CameraView", ()=>(0, _cameraJs.CameraView)); +parcelHelpers.export(exports, "AltAzimuthCamera", ()=>(0, _altazimuthJs.AltAzimuthCamera)); +parcelHelpers.export(exports, "AltAzimuthCameraView", ()=>(0, _altazimuthJs.AltAzimuthCameraView)); +parcelHelpers.export(exports, "OrbitCamera", ()=>(0, _orbitJs.OrbitCamera)); +var _cameraJs = require("./camera.js"); +var _altazimuthJs = require("./altazimuth.js"); +var _orbitJs = require("./orbit.js"); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9LEno":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./camera.js":"h35rS","./altazimuth.js":"gRqOf","./orbit.js":"6JwjD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6JwjD":[function(require,module,exports,__globalThis) { +/*! + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -var _ascendingJs = require("./ascending.js"); -var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); -var _descendingJs = require("./descending.js"); -var _descendingJsDefault = parcelHelpers.interopDefault(_descendingJs); -function bisector(f) { - let compare1, compare2, delta; - // If an accessor is specified, promote it to a comparator. In this case we - // can test whether the search value is (self-) comparable. We can’t do this - // for a comparator (except for specific, known comparators) because we can’t - // tell if the comparator is symmetric, and an asymmetric comparator can’t be - // used to test whether a single value is comparable. - if (f.length !== 2) { - compare1 = (0, _ascendingJsDefault.default); - compare2 = (d, x)=>(0, _ascendingJsDefault.default)(f(d), x); - delta = (d, x)=>f(d) - x; - } else { - compare1 = f === (0, _ascendingJsDefault.default) || f === (0, _descendingJsDefault.default) ? f : zero; - compare2 = f; - delta = f; +parcelHelpers.export(exports, "OrbitCamera", ()=>OrbitCamera); +var _glMatrix = require("gl-matrix"); +var _constantsJs = require("../constants.js"); +var _cameraJs = require("./camera.js"); +class OrbitCamera extends (0, _cameraJs.CameraBase) { + getTwist(value) { + (0, _glMatrix.quat).copy(value, this._cameraRotation); } - function left(a, x, lo = 0, hi = a.length) { - if (lo < hi) { - if (compare1(x, x) !== 0) return hi; - do { - const mid = lo + hi >>> 1; - if (compare2(a[mid], x) < 0) lo = mid + 1; - else hi = mid; - }while (lo < hi); - } - return lo; + setTwist(value, isSmooth) { + (0, _glMatrix.quat).copy(this._cameraRotation, value); + if (!isSmooth) (0, _glMatrix.quat).copy(this._smoothedCameraRotation, value); } - function right(a, x, lo = 0, hi = a.length) { - if (lo < hi) { - if (compare1(x, x) !== 0) return hi; - do { - const mid = lo + hi >>> 1; - if (compare2(a[mid], x) <= 0) lo = mid + 1; - else hi = mid; - }while (lo < hi); - } - return lo; + twist(angle, x, y) { + this.unproject(this._vec3, x, y, 1); + (0, _glMatrix.vec3).normalize(this._vec3, this._vec3); + (0, _glMatrix.vec3).transformQuat(this._vec3, this._vec3, this._orbitRotation); + this._twist(this._vec3, angle); } - function center(a, x, lo = 0, hi = a.length) { - const i = left(a, x, lo, hi - 1); - return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; + _twist(axis, angle) { + (0, _glMatrix.quat).setAxisAngle(this._quat, axis, angle); + (0, _glMatrix.quat).multiply(this._cameraRotation, this._quat, this._cameraRotation); + } + rotate(translationDelta) { + (0, _glMatrix.vec3).set(this._vec3, translationDelta[1], translationDelta[0], 0); + const length = (0, _glMatrix.vec3).length(this._vec3); + const angle = length * (0, _constantsJs.Constants).PI / Math.min(this.width, this.height); + (0, _glMatrix.vec3).scale(this._vec3, this._vec3, 1 / length); + (0, _glMatrix.quat).setAxisAngle(this._quat, this._vec3, angle); + (0, _glMatrix.quat).multiply(this._orbitRotation, this._quat, this._orbitRotation); } - return { - left, - center, - right - }; -} -exports.default = bisector; -function zero() { - return 0; } -},{"./ascending.js":"dWA2i","./descending.js":"j9J60","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"j9J60":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"gl-matrix":"5x28d","../constants.js":"lD0bG","./camera.js":"h35rS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iZ1f5":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ /** + * This file is for external facing export only, do not use this for internal references, + * as it may cause circular dependencies in Rollup. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -function descending(a, b) { - return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; -} -exports.default = descending; +//alphabetize for documentation +parcelHelpers.export(exports, "addDiv", ()=>(0, _htmlHelpers.addDiv)); +parcelHelpers.export(exports, "addEl", ()=>(0, _htmlHelpers.addEl)); +parcelHelpers.export(exports, "allTruthy", ()=>(0, _array.allTruthy)); +parcelHelpers.export(exports, "clone", ()=>(0, _clone.clone)); +parcelHelpers.export(exports, "colorFromString", ()=>(0, _color.colorFromString)); +parcelHelpers.export(exports, "colorIsEqual", ()=>(0, _color.colorIsEqual)); +parcelHelpers.export(exports, "colorToString", ()=>(0, _color.colorToString)); +parcelHelpers.export(exports, "concat", ()=>(0, _array.concat)); +parcelHelpers.export(exports, "createElement", ()=>(0, _tsxCreateElement.createElement)); +parcelHelpers.export(exports, "deepMerge", ()=>(0, _clone.deepMerge)); +parcelHelpers.export(exports, "desaturate", ()=>(0, _color.desaturate)); +parcelHelpers.export(exports, "getActiveElementInfo", ()=>(0, _tsxCreateElement.getActiveElementInfo)); +parcelHelpers.export(exports, "mount", ()=>(0, _tsxCreateElement.mount)); +parcelHelpers.export(exports, "outerSize", ()=>(0, _htmlHelpers.outerSize)); +parcelHelpers.export(exports, "push", ()=>(0, _array.push)); +parcelHelpers.export(exports, "setActiveElement", ()=>(0, _tsxCreateElement.setActiveElement)); +var _array = require("../array"); +var _htmlHelpers = require("../htmlHelpers"); +var _clone = require("../clone"); +var _color = require("../color"); +var _tsxCreateElement = require("tsx-create-element"); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"itBye":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../array":"cecnk","../htmlHelpers":"fuoG9","../clone":"4Kzai","../color":"cgTtg","tsx-create-element":"dPDUq","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cecnk":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "numbers", ()=>numbers); -function number(x) { - return x === null ? NaN : +x; +parcelHelpers.export(exports, "concat", ()=>concat); +/** + * Returns array with items which are truthy. + * @param args array or arrays to concat into a single array. + */ parcelHelpers.export(exports, "allTruthy", ()=>allTruthy); +/** + * Add an array to an existing array in place. + * @param arr Array to append to. + * @param items Arrof of items to append. + */ parcelHelpers.export(exports, "push", ()=>push); +function concat(...args) { + return args.reduce((p, c)=>c ? p.concat(c) : p, []); } -exports.default = number; -function* numbers(values, valueof) { - if (valueof === undefined) { - for (let value of values)if (value != null && (value = +value) >= value) yield value; - } else { - let index = -1; - for (let value1 of values)if ((value1 = valueof(value1, ++index, values)) != null && (value1 = +value1) >= value1) yield value1; - } +function allTruthy(...args) { + return args.reduce((p, c)=>c ? p.concat(c) : p, []).filter(Boolean); +} +function push(arr, items) { + arr.push.apply(arr, items); } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hhQBz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fuoG9":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ /** + * Create a new element as a child of another element. + * @param tagName Tag name of the new tag to create. + * @param parentElement Reference of the element to append to. + * @returns new HTMLElement. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "tickIncrement", ()=>tickIncrement); -parcelHelpers.export(exports, "tickStep", ()=>tickStep); -const e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2); -function tickSpec(start, stop, count) { - const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; - let i1, i2, inc; - if (power < 0) { - inc = Math.pow(10, -power) / factor; - i1 = Math.round(start * inc); - i2 = Math.round(stop * inc); - if (i1 / inc < start) ++i1; - if (i2 / inc > stop) --i2; - inc = -inc; - } else { - inc = Math.pow(10, power) * factor; - i1 = Math.round(start / inc); - i2 = Math.round(stop / inc); - if (i1 * inc < start) ++i1; - if (i2 * inc > stop) --i2; - } - if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); - return [ - i1, - i2, - inc - ]; +parcelHelpers.export(exports, "addEl", ()=>addEl); +/** + * Create a new div HTMLElement as a child of another element. + * @param parentElement Reference of the element to append to. + * @param className Optional css class name to apply to the div. + */ parcelHelpers.export(exports, "addDiv", ()=>addDiv); +/** + * Measure the outer height and width of an HTMLElement, including margin, padding and border. + * @param el HTML Element to measure. + */ parcelHelpers.export(exports, "outerSize", ()=>outerSize); +function addEl(tagName, parentElement) { + const el = document.createElement(tagName); + parentElement.appendChild(el); + return el; } -function ticks(start, stop, count) { - stop = +stop, start = +start, count = +count; - if (!(count > 0)) return []; - if (start === stop) return [ - start - ]; - const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count); - if (!(i2 >= i1)) return []; - const n = i2 - i1 + 1, ticks = new Array(n); - if (reverse) { - if (inc < 0) for(let i = 0; i < n; ++i)ticks[i] = (i2 - i) / -inc; - else for(let i3 = 0; i3 < n; ++i3)ticks[i3] = (i2 - i3) * inc; - } else { - if (inc < 0) for(let i4 = 0; i4 < n; ++i4)ticks[i4] = (i1 + i4) / -inc; - else for(let i5 = 0; i5 < n; ++i5)ticks[i5] = (i1 + i5) * inc; - } - return ticks; +function addDiv(parentElement, className) { + const div = addEl('div', parentElement); + if (className) div.className = className; + return div; } -exports.default = ticks; -function tickIncrement(start, stop, count) { - stop = +stop, start = +start, count = +count; - return tickSpec(start, stop, count)[2]; +function outerSize(el) { + const cs = getComputedStyle(el); + const height = parseFloat(cs.marginTop) + parseFloat(cs.paddingTop) + parseFloat(cs.borderTopWidth) + el.offsetHeight + parseFloat(cs.borderBottomWidth) + parseFloat(cs.paddingBottom) + parseFloat(cs.marginBottom); + const width = parseFloat(cs.marginLeft) + parseFloat(cs.paddingLeft) + parseFloat(cs.borderLeftWidth) + el.offsetWidth + parseFloat(cs.borderRightWidth) + parseFloat(cs.paddingRight) + parseFloat(cs.marginRight); + return { + height, + width + }; } -function tickStep(start, stop, count) { - stop = +stop, start = +start, count = +count; - const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count); - return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4Kzai":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "clone", ()=>clone); +parcelHelpers.export(exports, "deepMerge", ()=>deepMerge); +var _deepmerge = require("deepmerge"); +var _isPlainObject = require("is-plain-object"); +const deepmerge = _deepmerge.default || _deepmerge; +function clone(objectToClone) { + if (!objectToClone) return objectToClone; + return deepmerge.all([ + objectToClone + ]); +} +const dontMerge = (destination, source)=>source; +function deepMerge(...objectsToMerge) { + const objects = objectsToMerge.filter(Boolean); + return deepmerge.all(objects, { + arrayMerge: dontMerge, + isMergeableObject: (0, _isPlainObject.isPlainObject) + }); } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2CuUG":[function(require,module,exports) { +},{"deepmerge":"doQxS","is-plain-object":"83B8P","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"doQxS":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "identity", ()=>identity); -parcelHelpers.export(exports, "copy", ()=>copy); -parcelHelpers.export(exports, "transformer", ()=>transformer); -var _d3Array = require("d3-array"); -var _d3Interpolate = require("d3-interpolate"); -var _constantJs = require("./constant.js"); -var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); -var _numberJs = require("./number.js"); -var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); -var unit = [ - 0, - 1 -]; -function identity(x) { - return x; +var isMergeableObject = function isMergeableObject(value) { + return isNonNullObject(value) && !isSpecial(value); +}; +function isNonNullObject(value) { + return !!value && typeof value === 'object'; } -function normalize(a, b) { - return (b -= a = +a) ? function(x) { - return (x - a) / b; - } : (0, _constantJsDefault.default)(isNaN(b) ? NaN : 0.5); +function isSpecial(value) { + var stringValue = Object.prototype.toString.call(value); + return stringValue === '[object RegExp]' || stringValue === '[object Date]' || isReactElement(value); } -function clamper(a, b) { - var t; - if (a > b) t = a, a = b, b = t; - return function(x) { - return Math.max(a, Math.min(b, x)); - }; +// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 +var canUseSymbol = typeof Symbol === 'function' && Symbol.for; +var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; +function isReactElement(value) { + return value.$$typeof === REACT_ELEMENT_TYPE; } -// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. -// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b]. -function bimap(domain, range, interpolate) { - var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; - if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); - else d0 = normalize(d0, d1), r0 = interpolate(r0, r1); - return function(x) { - return r0(d0(x)); - }; +function emptyTarget(val) { + return Array.isArray(val) ? [] : {}; } -function polymap(domain, range, interpolate) { - var j = Math.min(domain.length, range.length) - 1, d = new Array(j), r = new Array(j), i = -1; - // Reverse descending domains. - if (domain[j] < domain[0]) { - domain = domain.slice().reverse(); - range = range.slice().reverse(); - } - while(++i < j){ - d[i] = normalize(domain[i], domain[i + 1]); - r[i] = interpolate(range[i], range[i + 1]); - } - return function(x) { - var i = (0, _d3Array.bisect)(domain, x, 1, j) - 1; - return r[i](d[i](x)); - }; +function cloneUnlessOtherwiseSpecified(value, options) { + return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value; } -function copy(source, target) { - return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown()); +function defaultArrayMerge(target, source, options) { + return target.concat(source).map(function(element) { + return cloneUnlessOtherwiseSpecified(element, options); + }); } -function transformer() { - var domain = unit, range = unit, interpolate = (0, _d3Interpolate.interpolate), transform, untransform, unknown, clamp = identity, piecewise, output, input; - function rescale() { - var n = Math.min(domain.length, range.length); - if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]); - piecewise = n > 2 ? polymap : bimap; - output = input = null; - return scale; - } - function scale(x) { - return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x))); - } - scale.invert = function(y) { - return clamp(untransform((input || (input = piecewise(range, domain.map(transform), (0, _d3Interpolate.interpolateNumber))))(y))); - }; - scale.domain = function(_) { - return arguments.length ? (domain = Array.from(_, (0, _numberJsDefault.default)), rescale()) : domain.slice(); - }; - scale.range = function(_) { - return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); - }; - scale.rangeRound = function(_) { - return range = Array.from(_), interpolate = (0, _d3Interpolate.interpolateRound), rescale(); - }; - scale.clamp = function(_) { - return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity; - }; - scale.interpolate = function(_) { - return arguments.length ? (interpolate = _, rescale()) : interpolate; - }; - scale.unknown = function(_) { - return arguments.length ? (unknown = _, scale) : unknown; - }; - return function(t, u) { - transform = t, untransform = u; - return rescale(); - }; +function mergeObject(target, source, options) { + var destination = {}; + if (options.isMergeableObject(target)) Object.keys(target).forEach(function(key) { + destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); + }); + Object.keys(source).forEach(function(key) { + if (!options.isMergeableObject(source[key]) || !target[key]) destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); + else destination[key] = deepmerge(target[key], source[key], options); + }); + return destination; } -function continuous() { - return transformer()(identity, identity); +function deepmerge(target, source, options) { + options = options || {}; + options.arrayMerge = options.arrayMerge || defaultArrayMerge; + options.isMergeableObject = options.isMergeableObject || isMergeableObject; + var sourceIsArray = Array.isArray(source); + var targetIsArray = Array.isArray(target); + var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; + if (!sourceAndTargetTypesMatch) return cloneUnlessOtherwiseSpecified(source, options); + else if (sourceIsArray) return options.arrayMerge(target, source, options); + else return mergeObject(target, source, options); } -exports.default = continuous; +deepmerge.all = function deepmergeAll(array, options) { + if (!Array.isArray(array)) throw new Error('first argument should be an array'); + return array.reduce(function(prev, next) { + return deepmerge(prev, next, options); + }, {}); +}; +var deepmerge_1 = deepmerge; +exports.default = deepmerge_1; -},{"d3-array":"48u5D","d3-interpolate":"epauS","./constant.js":"c7tIV","./number.js":"4rviI","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"epauS":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"83B8P":[function(require,module,exports,__globalThis) { +/*! + * is-plain-object <https://github.com/jonschlinkert/is-plain-object> + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "interpolate", ()=>(0, _valueJsDefault.default)); -parcelHelpers.export(exports, "interpolateArray", ()=>(0, _arrayJsDefault.default)); -parcelHelpers.export(exports, "interpolateBasis", ()=>(0, _basisJsDefault.default)); -parcelHelpers.export(exports, "interpolateBasisClosed", ()=>(0, _basisClosedJsDefault.default)); -parcelHelpers.export(exports, "interpolateDate", ()=>(0, _dateJsDefault.default)); -parcelHelpers.export(exports, "interpolateDiscrete", ()=>(0, _discreteJsDefault.default)); -parcelHelpers.export(exports, "interpolateHue", ()=>(0, _hueJsDefault.default)); -parcelHelpers.export(exports, "interpolateNumber", ()=>(0, _numberJsDefault.default)); -parcelHelpers.export(exports, "interpolateNumberArray", ()=>(0, _numberArrayJsDefault.default)); -parcelHelpers.export(exports, "interpolateObject", ()=>(0, _objectJsDefault.default)); -parcelHelpers.export(exports, "interpolateRound", ()=>(0, _roundJsDefault.default)); -parcelHelpers.export(exports, "interpolateString", ()=>(0, _stringJsDefault.default)); -parcelHelpers.export(exports, "interpolateTransformCss", ()=>(0, _indexJs.interpolateTransformCss)); -parcelHelpers.export(exports, "interpolateTransformSvg", ()=>(0, _indexJs.interpolateTransformSvg)); -parcelHelpers.export(exports, "interpolateZoom", ()=>(0, _zoomJsDefault.default)); -parcelHelpers.export(exports, "interpolateRgb", ()=>(0, _rgbJsDefault.default)); -parcelHelpers.export(exports, "interpolateRgbBasis", ()=>(0, _rgbJs.rgbBasis)); -parcelHelpers.export(exports, "interpolateRgbBasisClosed", ()=>(0, _rgbJs.rgbBasisClosed)); -parcelHelpers.export(exports, "interpolateHsl", ()=>(0, _hslJsDefault.default)); -parcelHelpers.export(exports, "interpolateHslLong", ()=>(0, _hslJs.hslLong)); -parcelHelpers.export(exports, "interpolateLab", ()=>(0, _labJsDefault.default)); -parcelHelpers.export(exports, "interpolateHcl", ()=>(0, _hclJsDefault.default)); -parcelHelpers.export(exports, "interpolateHclLong", ()=>(0, _hclJs.hclLong)); -parcelHelpers.export(exports, "interpolateCubehelix", ()=>(0, _cubehelixJsDefault.default)); -parcelHelpers.export(exports, "interpolateCubehelixLong", ()=>(0, _cubehelixJs.cubehelixLong)); -parcelHelpers.export(exports, "piecewise", ()=>(0, _piecewiseJsDefault.default)); -parcelHelpers.export(exports, "quantize", ()=>(0, _quantizeJsDefault.default)); -var _valueJs = require("./value.js"); -var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); -var _arrayJs = require("./array.js"); -var _arrayJsDefault = parcelHelpers.interopDefault(_arrayJs); -var _basisJs = require("./basis.js"); -var _basisJsDefault = parcelHelpers.interopDefault(_basisJs); -var _basisClosedJs = require("./basisClosed.js"); -var _basisClosedJsDefault = parcelHelpers.interopDefault(_basisClosedJs); -var _dateJs = require("./date.js"); -var _dateJsDefault = parcelHelpers.interopDefault(_dateJs); -var _discreteJs = require("./discrete.js"); -var _discreteJsDefault = parcelHelpers.interopDefault(_discreteJs); -var _hueJs = require("./hue.js"); -var _hueJsDefault = parcelHelpers.interopDefault(_hueJs); -var _numberJs = require("./number.js"); -var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); -var _numberArrayJs = require("./numberArray.js"); -var _numberArrayJsDefault = parcelHelpers.interopDefault(_numberArrayJs); -var _objectJs = require("./object.js"); -var _objectJsDefault = parcelHelpers.interopDefault(_objectJs); -var _roundJs = require("./round.js"); -var _roundJsDefault = parcelHelpers.interopDefault(_roundJs); -var _stringJs = require("./string.js"); -var _stringJsDefault = parcelHelpers.interopDefault(_stringJs); -var _indexJs = require("./transform/index.js"); -var _zoomJs = require("./zoom.js"); -var _zoomJsDefault = parcelHelpers.interopDefault(_zoomJs); -var _rgbJs = require("./rgb.js"); -var _rgbJsDefault = parcelHelpers.interopDefault(_rgbJs); -var _hslJs = require("./hsl.js"); -var _hslJsDefault = parcelHelpers.interopDefault(_hslJs); -var _labJs = require("./lab.js"); -var _labJsDefault = parcelHelpers.interopDefault(_labJs); -var _hclJs = require("./hcl.js"); -var _hclJsDefault = parcelHelpers.interopDefault(_hclJs); -var _cubehelixJs = require("./cubehelix.js"); -var _cubehelixJsDefault = parcelHelpers.interopDefault(_cubehelixJs); -var _piecewiseJs = require("./piecewise.js"); -var _piecewiseJsDefault = parcelHelpers.interopDefault(_piecewiseJs); -var _quantizeJs = require("./quantize.js"); -var _quantizeJsDefault = parcelHelpers.interopDefault(_quantizeJs); +parcelHelpers.export(exports, "isPlainObject", ()=>isPlainObject); +function isObject(o) { + return Object.prototype.toString.call(o) === '[object Object]'; +} +function isPlainObject(o) { + var ctor, prot; + if (isObject(o) === false) return false; + // If has modified constructor + ctor = o.constructor; + if (ctor === undefined) return true; + // If has modified prototype + prot = ctor.prototype; + if (isObject(prot) === false) return false; + // If constructor does not have an Object-specific method + if (prot.hasOwnProperty('isPrototypeOf') === false) return false; + // Most likely a plain Object + return true; +} -},{"./value.js":"9Xx7S","./array.js":"7kr8D","./basis.js":"gRzRK","./basisClosed.js":"eP8qB","./date.js":"cCDtl","./discrete.js":false,"./hue.js":false,"./number.js":"axMae","./numberArray.js":"dU04p","./object.js":"3YY4i","./round.js":"68Krm","./string.js":"6necD","./transform/index.js":false,"./zoom.js":false,"./rgb.js":"5ujQo","./hsl.js":false,"./lab.js":false,"./hcl.js":false,"./cubehelix.js":false,"./piecewise.js":false,"./quantize.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9Xx7S":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cgTtg":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); +/** + * Compares 2 colors to see if they are equal. + * @param a RGBAColor to compare + * @param b RGBAColor to compare + * @returns True if colors are equal. + */ parcelHelpers.export(exports, "colorIsEqual", ()=>colorIsEqual); +/** + * Convert a CSS color string to a Deck.gl RGBAColor array - (The rgba color of each object, in r, g, b, [a]. Each component is in the 0-255 range.). + * @param cssColorSpecifier A CSS Color Module Level 3 specifier string. + */ parcelHelpers.export(exports, "colorFromString", ()=>colorFromString); +/** + * Convert a Deck.gl color to a CSS rgba() string. + * @param color A Deck.gl RGBAColor array - (The rgba color of each object, in r, g, b, [a]. Each component is in the 0-255 range.) + */ parcelHelpers.export(exports, "colorToString", ()=>colorToString); +parcelHelpers.export(exports, "desaturate", ()=>desaturate); var _d3Color = require("d3-color"); -var _rgbJs = require("./rgb.js"); -var _rgbJsDefault = parcelHelpers.interopDefault(_rgbJs); -var _arrayJs = require("./array.js"); -var _dateJs = require("./date.js"); -var _dateJsDefault = parcelHelpers.interopDefault(_dateJs); -var _numberJs = require("./number.js"); -var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); -var _objectJs = require("./object.js"); -var _objectJsDefault = parcelHelpers.interopDefault(_objectJs); -var _stringJs = require("./string.js"); -var _stringJsDefault = parcelHelpers.interopDefault(_stringJs); -var _constantJs = require("./constant.js"); -var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); -var _numberArrayJs = require("./numberArray.js"); -var _numberArrayJsDefault = parcelHelpers.interopDefault(_numberArrayJs); -exports.default = function(a, b) { - var t = typeof b, c; - return b == null || t === "boolean" ? (0, _constantJsDefault.default)(b) : (t === "number" ? (0, _numberJsDefault.default) : t === "string" ? (c = (0, _d3Color.color)(b)) ? (b = c, _rgbJsDefault.default) : (0, _stringJsDefault.default) : b instanceof (0, _d3Color.color) ? (0, _rgbJsDefault.default) : b instanceof Date ? (0, _dateJsDefault.default) : (0, _numberArrayJs.isNumberArray)(b) ? (0, _numberArrayJsDefault.default) : Array.isArray(b) ? (0, _arrayJs.genericArray) : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? (0, _objectJsDefault.default) : (0, _numberJsDefault.default))(a, b); -}; - -},{"d3-color":"fZSrs","./rgb.js":"5ujQo","./array.js":"7kr8D","./date.js":"cCDtl","./number.js":"axMae","./object.js":"3YY4i","./string.js":"6necD","./constant.js":"g0Qgs","./numberArray.js":"dU04p","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fZSrs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "color", ()=>(0, _colorJsDefault.default)); -parcelHelpers.export(exports, "rgb", ()=>(0, _colorJs.rgb)); -parcelHelpers.export(exports, "hsl", ()=>(0, _colorJs.hsl)); -parcelHelpers.export(exports, "lab", ()=>(0, _labJsDefault.default)); -parcelHelpers.export(exports, "hcl", ()=>(0, _labJs.hcl)); -parcelHelpers.export(exports, "lch", ()=>(0, _labJs.lch)); -parcelHelpers.export(exports, "gray", ()=>(0, _labJs.gray)); -parcelHelpers.export(exports, "cubehelix", ()=>(0, _cubehelixJsDefault.default)); -var _colorJs = require("./color.js"); -var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); -var _labJs = require("./lab.js"); -var _labJsDefault = parcelHelpers.interopDefault(_labJs); -var _cubehelixJs = require("./cubehelix.js"); -var _cubehelixJsDefault = parcelHelpers.interopDefault(_cubehelixJs); - -},{"./color.js":"kKw4w","./lab.js":false,"./cubehelix.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kKw4w":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Color", ()=>Color); -parcelHelpers.export(exports, "darker", ()=>darker); -parcelHelpers.export(exports, "brighter", ()=>brighter); -parcelHelpers.export(exports, "rgbConvert", ()=>rgbConvert); -parcelHelpers.export(exports, "rgb", ()=>rgb); -parcelHelpers.export(exports, "Rgb", ()=>Rgb); -parcelHelpers.export(exports, "hslConvert", ()=>hslConvert); -parcelHelpers.export(exports, "hsl", ()=>hsl); -var _defineJs = require("./define.js"); -var _defineJsDefault = parcelHelpers.interopDefault(_defineJs); -function Color() {} -var darker = 0.7; -var brighter = 1 / darker; -var reI = "\\s*([+-]?\\d+)\\s*", reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", reHex = /^#([0-9a-f]{3,8})$/, reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); -var named = { - aliceblue: 0xf0f8ff, - antiquewhite: 0xfaebd7, - aqua: 0x00ffff, - aquamarine: 0x7fffd4, - azure: 0xf0ffff, - beige: 0xf5f5dc, - bisque: 0xffe4c4, - black: 0x000000, - blanchedalmond: 0xffebcd, - blue: 0x0000ff, - blueviolet: 0x8a2be2, - brown: 0xa52a2a, - burlywood: 0xdeb887, - cadetblue: 0x5f9ea0, - chartreuse: 0x7fff00, - chocolate: 0xd2691e, - coral: 0xff7f50, - cornflowerblue: 0x6495ed, - cornsilk: 0xfff8dc, - crimson: 0xdc143c, - cyan: 0x00ffff, - darkblue: 0x00008b, - darkcyan: 0x008b8b, - darkgoldenrod: 0xb8860b, - darkgray: 0xa9a9a9, - darkgreen: 0x006400, - darkgrey: 0xa9a9a9, - darkkhaki: 0xbdb76b, - darkmagenta: 0x8b008b, - darkolivegreen: 0x556b2f, - darkorange: 0xff8c00, - darkorchid: 0x9932cc, - darkred: 0x8b0000, - darksalmon: 0xe9967a, - darkseagreen: 0x8fbc8f, - darkslateblue: 0x483d8b, - darkslategray: 0x2f4f4f, - darkslategrey: 0x2f4f4f, - darkturquoise: 0x00ced1, - darkviolet: 0x9400d3, - deeppink: 0xff1493, - deepskyblue: 0x00bfff, - dimgray: 0x696969, - dimgrey: 0x696969, - dodgerblue: 0x1e90ff, - firebrick: 0xb22222, - floralwhite: 0xfffaf0, - forestgreen: 0x228b22, - fuchsia: 0xff00ff, - gainsboro: 0xdcdcdc, - ghostwhite: 0xf8f8ff, - gold: 0xffd700, - goldenrod: 0xdaa520, - gray: 0x808080, - green: 0x008000, - greenyellow: 0xadff2f, - grey: 0x808080, - honeydew: 0xf0fff0, - hotpink: 0xff69b4, - indianred: 0xcd5c5c, - indigo: 0x4b0082, - ivory: 0xfffff0, - khaki: 0xf0e68c, - lavender: 0xe6e6fa, - lavenderblush: 0xfff0f5, - lawngreen: 0x7cfc00, - lemonchiffon: 0xfffacd, - lightblue: 0xadd8e6, - lightcoral: 0xf08080, - lightcyan: 0xe0ffff, - lightgoldenrodyellow: 0xfafad2, - lightgray: 0xd3d3d3, - lightgreen: 0x90ee90, - lightgrey: 0xd3d3d3, - lightpink: 0xffb6c1, - lightsalmon: 0xffa07a, - lightseagreen: 0x20b2aa, - lightskyblue: 0x87cefa, - lightslategray: 0x778899, - lightslategrey: 0x778899, - lightsteelblue: 0xb0c4de, - lightyellow: 0xffffe0, - lime: 0x00ff00, - limegreen: 0x32cd32, - linen: 0xfaf0e6, - magenta: 0xff00ff, - maroon: 0x800000, - mediumaquamarine: 0x66cdaa, - mediumblue: 0x0000cd, - mediumorchid: 0xba55d3, - mediumpurple: 0x9370db, - mediumseagreen: 0x3cb371, - mediumslateblue: 0x7b68ee, - mediumspringgreen: 0x00fa9a, - mediumturquoise: 0x48d1cc, - mediumvioletred: 0xc71585, - midnightblue: 0x191970, - mintcream: 0xf5fffa, - mistyrose: 0xffe4e1, - moccasin: 0xffe4b5, - navajowhite: 0xffdead, - navy: 0x000080, - oldlace: 0xfdf5e6, - olive: 0x808000, - olivedrab: 0x6b8e23, - orange: 0xffa500, - orangered: 0xff4500, - orchid: 0xda70d6, - palegoldenrod: 0xeee8aa, - palegreen: 0x98fb98, - paleturquoise: 0xafeeee, - palevioletred: 0xdb7093, - papayawhip: 0xffefd5, - peachpuff: 0xffdab9, - peru: 0xcd853f, - pink: 0xffc0cb, - plum: 0xdda0dd, - powderblue: 0xb0e0e6, - purple: 0x800080, - rebeccapurple: 0x663399, - red: 0xff0000, - rosybrown: 0xbc8f8f, - royalblue: 0x4169e1, - saddlebrown: 0x8b4513, - salmon: 0xfa8072, - sandybrown: 0xf4a460, - seagreen: 0x2e8b57, - seashell: 0xfff5ee, - sienna: 0xa0522d, - silver: 0xc0c0c0, - skyblue: 0x87ceeb, - slateblue: 0x6a5acd, - slategray: 0x708090, - slategrey: 0x708090, - snow: 0xfffafa, - springgreen: 0x00ff7f, - steelblue: 0x4682b4, - tan: 0xd2b48c, - teal: 0x008080, - thistle: 0xd8bfd8, - tomato: 0xff6347, - turquoise: 0x40e0d0, - violet: 0xee82ee, - wheat: 0xf5deb3, - white: 0xffffff, - whitesmoke: 0xf5f5f5, - yellow: 0xffff00, - yellowgreen: 0x9acd32 -}; -(0, _defineJsDefault.default)(Color, color, { - copy (channels) { - return Object.assign(new this.constructor, this, channels); - }, - displayable () { - return this.rgb().displayable(); - }, - hex: color_formatHex, - formatHex: color_formatHex, - formatHex8: color_formatHex8, - formatHsl: color_formatHsl, - formatRgb: color_formatRgb, - toString: color_formatRgb -}); -function color_formatHex() { - return this.rgb().formatHex(); -} -function color_formatHex8() { - return this.rgb().formatHex8(); -} -function color_formatHsl() { - return hslConvert(this).formatHsl(); -} -function color_formatRgb() { - return this.rgb().formatRgb(); -} -function color(format) { - var m, l; - format = (format + "").trim().toLowerCase(); - return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000 - : l === 3 ? new Rgb(m >> 8 & 0xf | m >> 4 & 0xf0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00 - : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000 - : l === 4 ? rgba(m >> 12 & 0xf | m >> 8 & 0xf0, m >> 8 & 0xf | m >> 4 & 0xf0, m >> 4 & 0xf | m & 0xf0, ((m & 0xf) << 4 | m & 0xf) / 0xff) // #f000 - : null // invalid hex - ) : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) - : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) - : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) - : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) - : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) - : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) - : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins - : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; -} -exports.default = color; -function rgbn(n) { - return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); -} -function rgba(r, g, b, a) { - if (a <= 0) r = g = b = NaN; - return new Rgb(r, g, b, a); -} -function rgbConvert(o) { - if (!(o instanceof Color)) o = color(o); - if (!o) return new Rgb; - o = o.rgb(); - return new Rgb(o.r, o.g, o.b, o.opacity); -} -function rgb(r, g, b, opacity) { - return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); -} -function Rgb(r, g, b, opacity) { - this.r = +r; - this.g = +g; - this.b = +b; - this.opacity = +opacity; -} -(0, _defineJsDefault.default)(Rgb, rgb, (0, _defineJs.extend)(Color, { - brighter (k) { - k = k == null ? brighter : Math.pow(brighter, k); - return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); - }, - darker (k) { - k = k == null ? darker : Math.pow(darker, k); - return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); - }, - rgb () { - return this; - }, - clamp () { - return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); - }, - displayable () { - return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1; - }, - hex: rgb_formatHex, - formatHex: rgb_formatHex, - formatHex8: rgb_formatHex8, - formatRgb: rgb_formatRgb, - toString: rgb_formatRgb -})); -function rgb_formatHex() { - return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; -} -function rgb_formatHex8() { - return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; -} -function rgb_formatRgb() { - const a = clampa(this.opacity); - return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`; -} -function clampa(opacity) { - return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); -} -function clampi(value) { - return Math.max(0, Math.min(255, Math.round(value) || 0)); -} -function hex(value) { - value = clampi(value); - return (value < 16 ? "0" : "") + value.toString(16); -} -function hsla(h, s, l, a) { - if (a <= 0) h = s = l = NaN; - else if (l <= 0 || l >= 1) h = s = NaN; - else if (s <= 0) h = NaN; - return new Hsl(h, s, l, a); -} -function hslConvert(o) { - if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); - if (!(o instanceof Color)) o = color(o); - if (!o) return new Hsl; - if (o instanceof Hsl) return o; - o = o.rgb(); - var r = o.r / 255, g = o.g / 255, b = o.b / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), h = NaN, s = max - min, l = (max + min) / 2; - if (s) { - if (r === max) h = (g - b) / s + (g < b) * 6; - else if (g === max) h = (b - r) / s + 2; - else h = (r - g) / s + 4; - s /= l < 0.5 ? max + min : 2 - max - min; - h *= 60; - } else s = l > 0 && l < 1 ? 0 : h; - return new Hsl(h, s, l, o.opacity); -} -function hsl(h, s, l, opacity) { - return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); +function rgbToDeckglColor(c) { + return [ + c.r, + c.g, + c.b, + c.opacity * 255 + ]; } -function Hsl(h, s, l, opacity) { - this.h = +h; - this.s = +s; - this.l = +l; - this.opacity = +opacity; +function colorIsEqual(a, b) { + if (a.length !== b.length) return false; + for(let i = 0; i < a.length; i++){ + if (a[i] !== b[i]) return false; + } + return true; } -(0, _defineJsDefault.default)(Hsl, hsl, (0, _defineJs.extend)(Color, { - brighter (k) { - k = k == null ? brighter : Math.pow(brighter, k); - return new Hsl(this.h, this.s, this.l * k, this.opacity); - }, - darker (k) { - k = k == null ? darker : Math.pow(darker, k); - return new Hsl(this.h, this.s, this.l * k, this.opacity); - }, - rgb () { - var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2; - return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity); - }, - clamp () { - return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); - }, - displayable () { - return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1; - }, - formatHsl () { - const a = clampa(this.opacity); - return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`; +function colorFromString(cssColorSpecifier) { + if (cssColorSpecifier) { + const dc = (0, _d3Color.color)(cssColorSpecifier); + if (dc) { + const c = dc.rgb(); + return rgbToDeckglColor(c); + } } -})); -function clamph(value) { - value = (value || 0) % 360; - return value < 0 ? value + 360 : value; } -function clampt(value) { - return Math.max(0, Math.min(1, value || 0)); +function colorToString(color) { + const c = [ + ...color + ]; + if (c.length > 3) c[3] /= 255; + return `rgba(${c.join(',')})`; } -/* From FvD 13.37, CSS Color Module Level 3 */ function hsl2rgb(h, m1, m2) { - return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; +function desaturate(color, value) { + const rgb = (0, _d3Color.rgb)(color[0], color[1], color[2], color[3] / 255); + const hslColor = (0, _d3Color.hsl)(rgb); + hslColor.s = value; + const c = hslColor.rgb(); + return rgbToDeckglColor(c); } -},{"./define.js":"8nMD8","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8nMD8":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"d3-color":"37LNF","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4Q1zd":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "extend", ()=>extend); -exports.default = function(constructor, factory, prototype) { - constructor.prototype = factory.prototype = prototype; - prototype.constructor = constructor; +parcelHelpers.export(exports, "minHeight", ()=>minHeight); +parcelHelpers.export(exports, "minWidth", ()=>minWidth); +parcelHelpers.export(exports, "defaultPresenterStyle", ()=>defaultPresenterStyle); +parcelHelpers.export(exports, "defaultPresenterConfig", ()=>defaultPresenterConfig); +parcelHelpers.export(exports, "createStage", ()=>createStage); +parcelHelpers.export(exports, "groupStrokeWidth", ()=>groupStrokeWidth); +parcelHelpers.export(exports, "lineZ", ()=>lineZ); +parcelHelpers.export(exports, "defaultView", ()=>defaultView); +parcelHelpers.export(exports, "minZ", ()=>minZ); +parcelHelpers.export(exports, "min3dDepth", ()=>min3dDepth); +parcelHelpers.export(exports, "minPixelSize", ()=>minPixelSize); +parcelHelpers.export(exports, "defaultOnAxisItem", ()=>defaultOnAxisItem); +var _color = require("./color"); +const minHeight = '100px'; +const minWidth = '100px'; +const defaultPresenterStyle = { + cssPrefix: 'vega-morphcharts-', + defaultCubeColor: [ + 128, + 128, + 128, + 255 + ], + highlightColor: [ + 0, + 0, + 0, + 255 + ] }; -function extend(parent, definition) { - var prototype = Object.create(parent.prototype); - for(var key in definition)prototype[key] = definition[key]; - return prototype; -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5ujQo":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "rgbBasis", ()=>rgbBasis); -parcelHelpers.export(exports, "rgbBasisClosed", ()=>rgbBasisClosed); -var _d3Color = require("d3-color"); -var _basisJs = require("./basis.js"); -var _basisJsDefault = parcelHelpers.interopDefault(_basisJs); -var _basisClosedJs = require("./basisClosed.js"); -var _basisClosedJsDefault = parcelHelpers.interopDefault(_basisClosedJs); -var _colorJs = require("./color.js"); -var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); -exports.default = function rgbGamma(y) { - var color = (0, _colorJs.gamma)(y); - function rgb(start, end) { - var r = color((start = (0, _d3Color.rgb)(start)).r, (end = (0, _d3Color.rgb)(end)).r), g = color(start.g, end.g), b = color(start.b, end.b), opacity = (0, _colorJsDefault.default)(start.opacity, end.opacity); - return function(t) { - start.r = r(t); - start.g = g(t); - start.b = b(t); - start.opacity = opacity(t); - return start + ""; - }; - } - rgb.gamma = rgbGamma; - return rgb; -}(1); -function rgbSpline(spline) { - return function(colors) { - var n = colors.length, r = new Array(n), g = new Array(n), b = new Array(n), i, color; - for(i = 0; i < n; ++i){ - color = (0, _d3Color.rgb)(colors[i]); - r[i] = color.r || 0; - g[i] = color.g || 0; - b[i] = color.b || 0; +const defaultPresenterConfig = { + onCubeClick: (e, cube)=>{}, + onCubeHover: (e, cube)=>{}, + transitionDurations: { + position: 600, + stagger: 600, + view: 600 + }, + renderer: { + advanced: false, + advancedOptions: {}, + basicOptions: { + antialias: true } - r = spline(r); - g = spline(g); - b = spline(b); - color.opacity = 1; - return function(t) { - color.r = r(t); - color.g = g(t); - color.b = b(t); - return color + ""; - }; + } +}; +function createStage(view) { + const stage = { + view, + cubeData: [], + pathData: [], + axes: { + x: [], + y: [], + z: [] + }, + gridLines: [], + textData: [], + legend: { + rows: {} + }, + facets: [] }; + return stage; } -var rgbBasis = rgbSpline((0, _basisJsDefault.default)); -var rgbBasisClosed = rgbSpline((0, _basisClosedJsDefault.default)); - -},{"d3-color":"fZSrs","./basis.js":"gRzRK","./basisClosed.js":"eP8qB","./color.js":"9NnUe","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gRzRK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "basis", ()=>basis); -function basis(t1, v0, v1, v2, v3) { - var t2 = t1 * t1, t3 = t2 * t1; - return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6; -} -exports.default = function(values) { - var n = values.length - 1; - return function(t) { - var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), v1 = values[i], v2 = values[i + 1], v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1; - return basis((t - i / n) * n, v0, v1, v2, v3); - }; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eP8qB":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _basisJs = require("./basis.js"); -exports.default = function(values) { - var n = values.length; - return function(t) { - var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), v0 = values[(i + n - 1) % n], v1 = values[i % n], v2 = values[(i + 1) % n], v3 = values[(i + 2) % n]; - return (0, _basisJs.basis)((t - i / n) * n, v0, v1, v2, v3); - }; -}; - -},{"./basis.js":"gRzRK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9NnUe":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "hue", ()=>hue); -parcelHelpers.export(exports, "gamma", ()=>gamma); -var _constantJs = require("./constant.js"); -var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); -function linear(a, d) { - return function(t) { - return a + t * d; - }; -} -function exponential(a, b, y) { - return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { - return Math.pow(a + t * b, y); - }; -} -function hue(a, b) { - var d = b - a; - return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : (0, _constantJsDefault.default)(isNaN(a) ? b : a); -} -function gamma(y) { - return (y = +y) === 1 ? nogamma : function(a, b) { - return b - a ? exponential(a, b, y) : (0, _constantJsDefault.default)(isNaN(a) ? b : a); - }; +const groupStrokeWidth = 1; +const lineZ = 0; +const defaultView = '2d'; +const minZ = 0.5; +const min3dDepth = 0.05; +const minPixelSize = 0.5; +const zAxisEncodeColor = [ + 7, + 7, + 7, + 255 +]; +const zAxisOutColor = [ + 0, + 0, + 0, + 255 +]; +function defaultOnAxisItem(vegaItem, stageItem, stage, currAxis) { + if ((0, _color.colorIsEqual)(stageItem.color, zAxisEncodeColor)) { + stageItem.color = zAxisOutColor; + if (currAxis.axisRole !== 'z') { + const previousAxisRole = removeCurrentAxes(stage, currAxis); + if (previousAxisRole) { + currAxis.axisRole = 'z'; + stage.axes.z.push(currAxis); + } + } + } } -function nogamma(a, b) { - var d = b - a; - return d ? linear(a, d) : (0, _constantJsDefault.default)(isNaN(a) ? b : a); +function removeCurrentAxes(stage, currAxis) { + //find the current axis, remove it from parent + for(const axisRole in stage.axes){ + const axes = stage.axes[axisRole]; + for(let i = 0; i < axes.length; i++)if (axes[i] === currAxis) { + axes.splice(i, 1); + return axisRole; + } + } } -exports.default = nogamma; - -},{"./constant.js":"g0Qgs","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"g0Qgs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = (x)=>()=>x; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7kr8D":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./color":"cgTtg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hIePf":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "genericArray", ()=>genericArray); -var _valueJs = require("./value.js"); -var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); -var _numberArrayJs = require("./numberArray.js"); -var _numberArrayJsDefault = parcelHelpers.interopDefault(_numberArrayJs); -exports.default = function(a, b) { - return ((0, _numberArrayJs.isNumberArray)(b) ? (0, _numberArrayJsDefault.default) : genericArray)(a, b); +parcelHelpers.export(exports, "base", ()=>base); +/** + * Specify the dependency libraries to use for rendering. + * @param vega Vega library. + */ parcelHelpers.export(exports, "use", ()=>use); +const vega = { + CanvasHandler: null, + inferType: null, + inferTypes: null, + loader: null, + parse: null, + read: null, + renderModule: null, + Renderer: null, + sceneVisit: null, + scheme: null, + truncate: null, + View: null }; -function genericArray(a, b) { - var nb = b ? b.length : 0, na = a ? Math.min(nb, a.length) : 0, x = new Array(na), c = new Array(nb), i; - for(i = 0; i < na; ++i)x[i] = (0, _valueJsDefault.default)(a[i], b[i]); - for(; i < nb; ++i)c[i] = b[i]; - return function(t) { - for(i = 0; i < na; ++i)c[i] = x[i](t); - return c; - }; -} - -},{"./value.js":"9Xx7S","./numberArray.js":"dU04p","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dU04p":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "isNumberArray", ()=>isNumberArray); -exports.default = function(a, b) { - if (!b) b = []; - var n = a ? Math.min(b.length, a.length) : 0, c = b.slice(), i; - return function(t) { - for(i = 0; i < n; ++i)c[i] = a[i] * (1 - t) + b[i] * t; - return c; - }; +const base = { + vega }; -function isNumberArray(x) { - return ArrayBuffer.isView(x) && !(x instanceof DataView); +function use(vega) { + base.vega = vega; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cCDtl":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(a, b) { - var d = new Date; - return a = +a, b = +b, function(t) { - return d.setTime(a * (1 - t) + b * t), d; - }; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"axMae":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(a, b) { - return a = +a, b = +b, function(t) { - return a * (1 - t) + b * t; - }; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3YY4i":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _valueJs = require("./value.js"); -var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); -exports.default = function(a, b) { - var i = {}, c = {}, k; - if (a === null || typeof a !== "object") a = {}; - if (b === null || typeof b !== "object") b = {}; - for(k in b)if (k in a) i[k] = (0, _valueJsDefault.default)(a[k], b[k]); - else c[k] = b[k]; - return function(t) { - for(k in i)c[k] = i[k](t); - return c; - }; -}; - -},{"./value.js":"9Xx7S","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6necD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9yYY0":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -var _numberJs = require("./number.js"); -var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); -var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, reB = new RegExp(reA.source, "g"); -function zero(b) { - return function() { - return b; - }; -} -function one(b) { - return function(t) { - return b(t) + ""; - }; -} -exports.default = function(a, b) { - var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; // number interpolators - // Coerce inputs to strings. - a = a + "", b = b + ""; - // Interpolate pairs of numbers in a & b. - while((am = reA.exec(a)) && (bm = reB.exec(b))){ - if ((bs = bm.index) > bi) { - bs = b.slice(bi, bs); - if (s[i]) s[i] += bs; // coalesce with previous string - else s[++i] = bs; +/** + * Class which presents a Stage of chart data using MorphCharts to render. + */ parcelHelpers.export(exports, "Presenter", ()=>Presenter); +var _clone = require("./clone"); +var _defaults = require("./defaults"); +var _enums = require("./enums"); +var _legend = require("./legend"); +var _panel = require("./panel"); +var _patchedCubeArray = require("./patchedCubeArray"); +var _stagers = require("./stagers"); +var _tsxCreateElement = require("tsx-create-element"); +var _morphcharts = require("./morphcharts"); +class Presenter { + /** + * Get the previously rendered Stage object. + */ get stage() { + return this._last.stage; + } + /** + * Get the current View camera type. + */ get view() { + return this._last.view; + } + /** + * Instantiate a new Presenter. + * @param el Parent HTMLElement to present within. + * @param style Optional PresenterStyle styling options. + */ constructor(el, style){ + this.el = el; + this.style = (0, _clone.deepMerge)((0, _defaults.defaultPresenterStyle), style); + (0, _panel.initializePanel)(this); + this._last = { + view: null, + height: null, + width: null, + cubeCount: null, + stage: null + }; + } + /** + * Cancels any pending animation, calling animationCanceled() on original queue. + */ animationCancel() { + if (this.animationTimer) { + clearTimeout(this.animationTimer); + this.animationTimer = null; + if (this.logger) this.logger(`canceling animation ${this.queuedAnimationOptions && this.queuedAnimationOptions.handlerLabel || 'handler'}`); + if (this.queuedAnimationOptions && this.queuedAnimationOptions.animationCanceled) this.queuedAnimationOptions.animationCanceled.call(null); } - if ((am = am[0]) === (bm = bm[0])) { - if (s[i]) s[i] += bm; // coalesce with previous string - else s[++i] = bm; - } else { - s[++i] = null; - q.push({ - i: i, - x: (0, _numberJsDefault.default)(am, bm) - }); + } + /** + * Stops the current animation and queues a new animation. + * @param handler Function to invoke when timeout is complete. + * @param timeout Length of time to wait before invoking the handler. + * @param options Optional QueuedAnimationOptions object. + */ animationQueue(handler, timeout, options) { + if (this.logger) this.logger(`queueing animation ${options && options.waitingLabel || 'waiting'}...(${timeout})`); + this.animationCancel(); + this.animationTimer = setTimeout(()=>{ + if (this.logger) this.logger(`queueing animation ${options && options.handlerLabel || 'handler'}...`); + handler(); + }, timeout); + } + /** + * Retrieve a sub-element of the rendered output. + * @param type PresenterElement type of the HTMLElement to retrieve. + */ getElement(type) { + const elements = this.el.getElementsByClassName((0, _panel.className)(type, this)); + if (elements && elements.length) return elements[0]; + } + /** + * Present the Vega Scene, or Stage object using Morphcharts. + * @param sceneOrStage Vega Scene object, or Stage object containing chart layout info. + * @param height Height of the rendering area. + * @param width Width of the rendering area. + * @param config Optional presentation configuration object. + */ present(sceneOrStage, height, width, config) { + this.animationCancel(); + const scene = sceneOrStage; + let stage; + const options = { + maxOrdinal: 0, + currAxis: null, + defaultCubeColor: this.style.defaultCubeColor, + assignCubeOrdinal: config && config.onSceneRectAssignCubeOrdinal || (()=>options.maxOrdinal++), + modifyAxis: (config === null || config === void 0 ? void 0 : config.onAxisItem) ? config.onAxisItem : (0, _defaults.defaultOnAxisItem), + zAxisZindex: config === null || config === void 0 ? void 0 : config.zAxisZindex + }; + //determine if this is a vega scene + if (scene.marktype) { + stage = (0, _defaults.createStage)(scene.view); + (0, _stagers.sceneToStage)(options, stage, scene); + } else stage = sceneOrStage; + const c = (0, _clone.deepMerge)((0, _defaults.defaultPresenterConfig), config); + if (!this.morphchartsref) { + this._morphChartsOptions = { + container: this.getElement((0, _enums.PresenterElement).gl), + pickGridCallback: c.axisPickGridCallback, + onCubeHover: (e, ordinal)=>{ + c.onCubeHover(e, { + ordinal, + color: null, + position: null, + size: null + }); + }, + onCubeClick: (e, ordinal)=>{ + c.onCubeClick(e, { + ordinal, + color: null, + position: null, + size: null + }); + }, + onCanvasClick: config === null || config === void 0 ? void 0 : config.onLayerClick, + onLasso: config === null || config === void 0 ? void 0 : config.onLasso + }; + this.morphchartsref = (0, _morphcharts.init)(this._morphChartsOptions, c.renderer || (0, _defaults.defaultPresenterConfig).renderer); + } + let cubeCount = Math.max(this._last.cubeCount, stage.cubeData.length); + if (options.maxOrdinal) { + cubeCount = Math.max(cubeCount, options.maxOrdinal); + const empty = { + isEmpty: true + }; + stage.cubeData = (0, _patchedCubeArray.patchCubeArray)(cubeCount, empty, stage.cubeData); } - bi = reB.lastIndex; + config.preLayer && config.preLayer(stage); + this.morphChartsRenderResult = (0, _morphcharts.morphChartsRender)(this.morphchartsref, this._last.stage, stage, height, width, config && config.preStage, config && config.morphChartsColors, c); + delete stage.cubeData; + delete stage.redraw; + this._last = { + cubeCount, + height, + width, + stage, + view: stage.view + }; + const a = (0, _tsxCreateElement.getActiveElementInfo)(); + (0, _tsxCreateElement.mount)((0, _legend.LegendView)({ + legend: stage.legend, + onClick: config && config.onLegendClick + }), this.getElement((0, _enums.PresenterElement).legend)); + (0, _tsxCreateElement.setActiveElement)(a); + if (config && config.onPresent) config.onPresent(); } - // Add remains of b. - if (bi < b.length) { - bs = b.slice(bi); - if (s[i]) s[i] += bs; // coalesce with previous string - else s[++i] = bs; + canvasToDataURL() { + return new Promise((resolve, reject)=>{ + this.morphchartsref.core.afterRenderCallback = ()=>{ + this.morphchartsref.core.afterRenderCallback = null; + const canvas = this.getElement((0, _enums.PresenterElement).gl).getElementsByTagName('canvas')[0]; + const png = canvas.toDataURL('image/png'); + resolve(png); + }; + }); } - // Special optimization for only a single match. - // Otherwise, interpolate each of the numbers and rejoin the string. - return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function(t) { - for(var i = 0, o; i < b; ++i)s[(o = q[i]).i] = o.x(t); - return s.join(""); - }); -}; + configColors(mcColors) { + (0, _morphcharts.colorConfig)(this.morphchartsref, mcColors); + } + /** + * Home the camera to the last initial position. + */ homeCamera() { + var _a; + (_a = this.morphchartsref) === null || _a === void 0 || _a.reset(); + } + /** + * Show guidelines of rendering height/width and center of OrbitView. + */ showGuides() { + this.getElement((0, _enums.PresenterElement).gl).classList.add('show-center'); + //TODO Morphcharts gridlines + } + finalize() { + this.animationCancel(); + if (this.morphchartsref) this.morphchartsref.core.stop(); + if (this.el) this.el.innerHTML = ''; + this._last = null; + this.morphchartsref = null; + this.el = null; + this.logger = null; + this.queuedAnimationOptions = null; + } +} -},{"./number.js":"axMae","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"68Krm":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./clone":"4Kzai","./defaults":"4Q1zd","./enums":"hnVHt","./legend":"aunMk","./panel":"l2IQQ","./patchedCubeArray":"eWKaN","./stagers":"6p1Cn","tsx-create-element":"dPDUq","./morphcharts":"6vcDa","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hnVHt":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ /** + * HTML elements outputted by the presenter. + */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "PresenterElement", ()=>PresenterElement); +var PresenterElement; +(function(PresenterElement) { + PresenterElement[PresenterElement["root"] = 0] = "root"; + PresenterElement[PresenterElement["gl"] = 1] = "gl"; + PresenterElement[PresenterElement["panel"] = 2] = "panel"; + PresenterElement[PresenterElement["legend"] = 3] = "legend"; + PresenterElement[PresenterElement["vegaControls"] = 4] = "vegaControls"; +})(PresenterElement || (PresenterElement = {})); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aunMk":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -exports.default = function(a, b) { - return a = +a, b = +b, function(t) { - return Math.round(a * (1 - t) + b * t); +parcelHelpers.export(exports, "LegendView", ()=>LegendView); +var _tsxCreateElement = require("tsx-create-element"); +var _controls = require("./controls"); +const LegendView = (props)=>{ + const rows = []; + const addRow = (row, i)=>{ + const fn = symbolMap[row.symbol.shape]; + let jsx; + if (fn) jsx = fn(row.symbol); + else jsx = (0, _tsxCreateElement.createElement)("span", null, "x"); + rows.push({ + cells: [ + { + className: 'symbol', + content: jsx + }, + { + className: 'label', + content: row.label, + title: row.label + } + ] + }); }; + const sorted = Object.keys(props.legend.rows).sort((a, b)=>+a - +b); + sorted.forEach((i)=>addRow(props.legend.rows[i], +i)); + if (sorted.length) return (0, _tsxCreateElement.createElement)((0, _controls.Table), { + rows: rows, + rowClassName: "legend-row", + onRowClick: (e, i)=>props.onClick(e, props.legend, i) + }, props.legend.title !== void 0 && (0, _tsxCreateElement.createElement)("tr", { + onClick: (e)=>props.onClick(e, props.legend, null) + }, (0, _tsxCreateElement.createElement)("th", { + colSpan: 2 + }, props.legend.title))); +}; +const symbolMap = { + square: function(symbol) { + return (0, _tsxCreateElement.createElement)("div", { + style: { + height: `${symbol.bounds.y2 - symbol.bounds.y1}px`, + width: `${symbol.bounds.x2 - symbol.bounds.x1}px`, + backgroundColor: symbol.fill, + borderColor: symbol.fill + } + }); + } }; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"c7tIV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"tsx-create-element":"dPDUq","./controls":"9lm1L","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"l2IQQ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -function constants(x) { - return function() { - return x; - }; +parcelHelpers.export(exports, "initializePanel", ()=>initializePanel); +parcelHelpers.export(exports, "className", ()=>className); +var _tsxCreateElement = require("tsx-create-element"); +var _defaults = require("./defaults"); +var _enums = require("./enums"); +function initializePanel(presenter) { + const rootDiv = (0, _tsxCreateElement.createElement)("div", { + className: className((0, _enums.PresenterElement).root, presenter) + }, (0, _tsxCreateElement.createElement)("div", { + className: className((0, _enums.PresenterElement).gl, presenter), + style: { + minHeight: (0, _defaults.minHeight), + minWidth: (0, _defaults.minWidth) + } + }), (0, _tsxCreateElement.createElement)("div", { + className: className((0, _enums.PresenterElement).panel, presenter) + }, (0, _tsxCreateElement.createElement)("div", { + className: className((0, _enums.PresenterElement).vegaControls, presenter) + }), (0, _tsxCreateElement.createElement)("div", { + className: className((0, _enums.PresenterElement).legend, presenter) + }))); + (0, _tsxCreateElement.mount)(rootDiv, presenter.el); +} +function className(type, presenter) { + return `${presenter.style.cssPrefix}${(0, _enums.PresenterElement)[type]}`; } -exports.default = constants; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4rviI":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"tsx-create-element":"dPDUq","./defaults":"4Q1zd","./enums":"hnVHt","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eWKaN":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -function number(x) { - return +x; +parcelHelpers.export(exports, "patchCubeArray", ()=>patchCubeArray); +function patchCubeArray(allocatedSize, empty, cubes) { + const patched = new Array(allocatedSize); + patched.fill(empty); + cubes.forEach((cube)=>patched[cube.ordinal] = cube); + return patched; } -exports.default = number; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fnuZg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6p1Cn":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "initRange", ()=>initRange); -parcelHelpers.export(exports, "initInterpolator", ()=>initInterpolator); -function initRange(domain, range) { - switch(arguments.length){ - case 0: - break; - case 1: - this.range(domain); - break; - default: - this.range(range).domain(domain); - break; +parcelHelpers.export(exports, "sceneToStage", ()=>sceneToStage); +var _legend = require("./marks/legend"); +var _legendDefault = parcelHelpers.interopDefault(_legend); +var _image = require("./marks/image"); +var _imageDefault = parcelHelpers.interopDefault(_image); +var _rect = require("./marks/rect"); +var _rectDefault = parcelHelpers.interopDefault(_rect); +var _rule = require("./marks/rule"); +var _ruleDefault = parcelHelpers.interopDefault(_rule); +var _line = require("./marks/line"); +var _lineDefault = parcelHelpers.interopDefault(_line); +var _text = require("./marks/text"); +var _textDefault = parcelHelpers.interopDefault(_text); +var _base = require("./base"); +var _color = require("./color"); +var _defaults = require("./defaults"); +var _interfaces = require("./marks/interfaces"); +function getAxisGroupType(item, options) { + const axisItem = item; + const axisMark = axisItem === null || axisItem === void 0 ? void 0 : axisItem.mark; + if ((axisMark === null || axisMark === void 0 ? void 0 : axisMark.zindex) === options.zAxisZindex && options.zAxisZindex !== undefined) return (0, _interfaces.GroupType).zAxis; + switch(axisItem.orient){ + case 'bottom': + case 'top': + return (0, _interfaces.GroupType).xAxis; + case 'left': + case 'right': + return (0, _interfaces.GroupType).yAxis; } - return this; } -function initInterpolator(domain, interpolator) { - switch(arguments.length){ - case 0: - break; - case 1: - if (typeof domain === "function") this.interpolator(domain); - else this.range(domain); - break; - default: - this.domain(domain); - if (typeof interpolator === "function") this.interpolator(interpolator); - else this.range(interpolator); - break; +function convertGroupRole(item, options) { + if (item.mark.role === 'legend') return (0, _interfaces.GroupType).legend; + if (item.mark.role === 'axis') { + const groupType = getAxisGroupType(item, options); + if (groupType !== undefined) return groupType; } - return this; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3sBVK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _d3Array = require("d3-array"); -var _d3Format = require("d3-format"); -function tickFormat(start, stop, count, specifier) { - var step = (0, _d3Array.tickStep)(start, stop, count), precision; - specifier = (0, _d3Format.formatSpecifier)(specifier == null ? ",f" : specifier); - switch(specifier.type){ - case "s": - var value = Math.max(Math.abs(start), Math.abs(stop)); - if (specifier.precision == null && !isNaN(precision = (0, _d3Format.precisionPrefix)(step, value))) specifier.precision = precision; - return (0, _d3Format.formatPrefix)(specifier, value); - case "": - case "e": - case "g": - case "p": - case "r": - if (specifier.precision == null && !isNaN(precision = (0, _d3Format.precisionRound)(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); +const group = (options, stage, scene, x, y, groupType)=>{ + (0, _base.base).vega.sceneVisit(scene, function(g) { + const gx = g.x || 0, gy = g.y || 0; + if (g.context && g.context.background && !stage.backgroundColor) stage.backgroundColor = (0, _color.colorFromString)(g.context.background); + if (g.stroke) { + const facetRect = { + datum: g.datum, + lines: (0, _rule.box)(gx + x, gy + y, g.height, g.width, g.stroke, (0, _defaults.groupStrokeWidth)) + }; + stage.facets.push(facetRect); + } + groupType = convertGroupRole(g, options) || groupType; + setCurrentAxis(options, stage, groupType); + // draw group contents + (0, _base.base).vega.sceneVisit(g, function(item) { + mainStager(options, stage, item, gx + x, gy + y, groupType); + }); + }); +}; +function setCurrentAxis(options, stage, groupType) { + let axisRole; + switch(groupType){ + case (0, _interfaces.GroupType).xAxis: + axisRole = 'x'; break; - case "f": - case "%": - if (specifier.precision == null && !isNaN(precision = (0, _d3Format.precisionFixed)(step))) specifier.precision = precision - (specifier.type === "%") * 2; + case (0, _interfaces.GroupType).yAxis: + axisRole = 'y'; + break; + case (0, _interfaces.GroupType).zAxis: + axisRole = 'z'; break; + default: + return; } - return (0, _d3Format.format)(specifier); + options.currAxis = { + axisRole, + domain: null, + tickText: [], + ticks: [] + }; + stage.axes[axisRole].push(options.currAxis); } -exports.default = tickFormat; - -},{"d3-array":"48u5D","d3-format":"hKs66","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hKs66":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "formatDefaultLocale", ()=>(0, _defaultLocaleJsDefault.default)); -parcelHelpers.export(exports, "format", ()=>(0, _defaultLocaleJs.format)); -parcelHelpers.export(exports, "formatPrefix", ()=>(0, _defaultLocaleJs.formatPrefix)); -parcelHelpers.export(exports, "formatLocale", ()=>(0, _localeJsDefault.default)); -parcelHelpers.export(exports, "formatSpecifier", ()=>(0, _formatSpecifierJsDefault.default)); -parcelHelpers.export(exports, "FormatSpecifier", ()=>(0, _formatSpecifierJs.FormatSpecifier)); -parcelHelpers.export(exports, "precisionFixed", ()=>(0, _precisionFixedJsDefault.default)); -parcelHelpers.export(exports, "precisionPrefix", ()=>(0, _precisionPrefixJsDefault.default)); -parcelHelpers.export(exports, "precisionRound", ()=>(0, _precisionRoundJsDefault.default)); -var _defaultLocaleJs = require("./defaultLocale.js"); -var _defaultLocaleJsDefault = parcelHelpers.interopDefault(_defaultLocaleJs); -var _localeJs = require("./locale.js"); -var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); -var _formatSpecifierJs = require("./formatSpecifier.js"); -var _formatSpecifierJsDefault = parcelHelpers.interopDefault(_formatSpecifierJs); -var _precisionFixedJs = require("./precisionFixed.js"); -var _precisionFixedJsDefault = parcelHelpers.interopDefault(_precisionFixedJs); -var _precisionPrefixJs = require("./precisionPrefix.js"); -var _precisionPrefixJsDefault = parcelHelpers.interopDefault(_precisionPrefixJs); -var _precisionRoundJs = require("./precisionRound.js"); -var _precisionRoundJsDefault = parcelHelpers.interopDefault(_precisionRoundJs); - -},{"./defaultLocale.js":"jBcGg","./locale.js":"a2jOq","./formatSpecifier.js":"e5jGZ","./precisionFixed.js":"f7bS0","./precisionPrefix.js":"8xg0b","./precisionRound.js":"8uO5J","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jBcGg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "format", ()=>format); -parcelHelpers.export(exports, "formatPrefix", ()=>formatPrefix); -var _localeJs = require("./locale.js"); -var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); -var locale; -var format; -var formatPrefix; -defaultLocale({ - thousands: ",", - grouping: [ - 3 - ], - currency: [ - "$", - "" - ] -}); -function defaultLocale(definition) { - locale = (0, _localeJsDefault.default)(definition); - format = locale.format; - formatPrefix = locale.formatPrefix; - return locale; +const markStagers = { + group, + legend: (0, _legendDefault.default), + image: (0, _imageDefault.default), + rect: (0, _rectDefault.default), + rule: (0, _ruleDefault.default), + line: (0, _lineDefault.default), + text: (0, _textDefault.default) +}; +const mainStager = (options, stage, scene, x, y, groupType)=>{ + if (scene.marktype !== 'group' && groupType === (0, _interfaces.GroupType).legend) (0, _legendDefault.default)(options, stage, scene, x, y, groupType); + else { + const markStager = markStagers[scene.marktype]; + if (markStager) markStager(options, stage, scene, x, y, groupType); + } +}; +function sceneToStage(options, stage, scene) { + mainStager(options, stage, scene, 0, 0, null); + sortAxis(stage.axes.x, 0); + sortAxis(stage.axes.y, 1); + sortAxis(stage.axes.z, 1); +} +function sortAxis(axes, dim) { + axes.forEach((axis)=>{ + if (axis.domain) orderDomain(axis.domain, dim); + axis.ticks.sort((a, b)=>a.sourcePosition[dim] - b.sourcePosition[dim]); + axis.tickText.sort((a, b)=>a.position[dim] - b.position[dim]); + }); +} +function orderDomain(domain, dim) { + if (domain.sourcePosition[dim] > domain.targetPosition[dim]) { + const temp = domain.targetPosition; + domain.targetPosition = domain.sourcePosition; + domain.sourcePosition = temp; + } } -exports.default = defaultLocale; -},{"./locale.js":"a2jOq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"a2jOq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./marks/legend":"jtBG9","./marks/image":"1Vs56","./marks/rect":"7DefN","./marks/rule":"aqAq7","./marks/line":"axYMN","./marks/text":"geL5J","./base":"hIePf","./color":"cgTtg","./defaults":"4Q1zd","./marks/interfaces":"96Qp6","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jtBG9":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -var _exponentJs = require("./exponent.js"); -var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -var _formatGroupJs = require("./formatGroup.js"); -var _formatGroupJsDefault = parcelHelpers.interopDefault(_formatGroupJs); -var _formatNumeralsJs = require("./formatNumerals.js"); -var _formatNumeralsJsDefault = parcelHelpers.interopDefault(_formatNumeralsJs); -var _formatSpecifierJs = require("./formatSpecifier.js"); -var _formatSpecifierJsDefault = parcelHelpers.interopDefault(_formatSpecifierJs); -var _formatTrimJs = require("./formatTrim.js"); -var _formatTrimJsDefault = parcelHelpers.interopDefault(_formatTrimJs); -var _formatTypesJs = require("./formatTypes.js"); -var _formatTypesJsDefault = parcelHelpers.interopDefault(_formatTypesJs); -var _formatPrefixAutoJs = require("./formatPrefixAuto.js"); -var _identityJs = require("./identity.js"); -var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); -var map = Array.prototype.map, prefixes = [ - "y", - "z", - "a", - "f", - "p", - "n", - "\xb5", - "m", - "", - "k", - "M", - "G", - "T", - "P", - "E", - "Z", - "Y" -]; -exports.default = function(locale) { - var group = locale.grouping === undefined || locale.thousands === undefined ? (0, _identityJsDefault.default) : (0, _formatGroupJsDefault.default)(map.call(locale.grouping, Number), locale.thousands + ""), currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", decimal = locale.decimal === undefined ? "." : locale.decimal + "", numerals = locale.numerals === undefined ? (0, _identityJsDefault.default) : (0, _formatNumeralsJsDefault.default)(map.call(locale.numerals, String)), percent = locale.percent === undefined ? "%" : locale.percent + "", minus = locale.minus === undefined ? "−" : locale.minus + "", nan = locale.nan === undefined ? "NaN" : locale.nan + ""; - function newFormat(specifier) { - specifier = (0, _formatSpecifierJsDefault.default)(specifier); - var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type; - // The "n" type is an alias for ",g". - if (type === "n") comma = true, type = "g"; - else if (!(0, _formatTypesJsDefault.default)[type]) precision === undefined && (precision = 12), trim = true, type = "g"; - // If zero fill is specified, padding goes after sign and before digits. - if (zero || fill === "0" && align === "=") zero = true, fill = "0", align = "="; - // Compute the prefix and suffix. - // For SI-prefix, the suffix is lazily computed. - var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; - // What format function should we use? - // Is this an integer type? - // Can this type generate exponential notation? - var formatType = (0, _formatTypesJsDefault.default)[type], maybeSuffix = /[defgprs%]/.test(type); - // Set the default precision if not specified, - // or clamp the specified precision to the supported range. - // For significant precision, it must be in [1, 21]. - // For fixed precision, it must be in [0, 20]. - precision = precision === undefined ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); - function format(value) { - var valuePrefix = prefix, valueSuffix = suffix, i, n, c; - if (type === "c") { - valueSuffix = formatType(value) + valueSuffix; - value = ""; - } else { - value = +value; - // Determine the sign. -0 is not less than 0, but 1 / -0 is! - var valueNegative = value < 0 || 1 / value < 0; - // Perform the initial formatting. - value = isNaN(value) ? nan : formatType(Math.abs(value), precision); - // Trim insignificant zeros. - if (trim) value = (0, _formatTrimJsDefault.default)(value); - // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. - if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; - // Compute the prefix and suffix. - valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; - valueSuffix = (type === "s" ? prefixes[8 + (0, _formatPrefixAutoJs.prefixExponent) / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); - // Break the formatted value into the integer “value” part that can be - // grouped, and fractional or exponential “suffix” part that is not. - if (maybeSuffix) { - i = -1, n = value.length; - while(++i < n)if (c = value.charCodeAt(i), 48 > c || c > 57) { - valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; - value = value.slice(0, i); - break; - } - } - } - // If the fill character is not "0", grouping is applied before padding. - if (comma && !zero) value = group(value, Infinity); - // Compute the padding. - var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : ""; - // If the fill character is "0", grouping is applied after padding. - if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; - // Reconstruct the final output based on the desired alignment. - switch(align){ - case "<": - value = valuePrefix + value + valueSuffix + padding; - break; - case "=": - value = valuePrefix + padding + value + valueSuffix; - break; - case "^": - value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); - break; - default: - value = padding + valuePrefix + value + valueSuffix; - break; - } - return numerals(value); - } - format.toString = function() { - return specifier + ""; - }; - return format; - } - function formatPrefix(specifier, value) { - var f = newFormat((specifier = (0, _formatSpecifierJsDefault.default)(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor((0, _exponentJsDefault.default)(value) / 3))) * 3, k = Math.pow(10, -e), prefix = prefixes[8 + e / 3]; - return function(value) { - return f(k * value) + prefix; +var _base = require("../base"); +const legendMap = { + 'legend-title': function(legend, textItem) { + legend.title = textItem.text; + }, + 'legend-symbol': function(legend, symbol) { + const { bounds, fill, shape } = symbol; + //this object is safe for serialization + const legendRowSymbol = { + bounds, + fill, + shape }; + const i = symbol.datum.index; + legend.rows[i] = legend.rows[i] || {}; + legend.rows[i].symbol = legendRowSymbol; + }, + 'legend-label': function(legend, label) { + const i = label.datum.index; + legend.rows[i] = legend.rows[i] || {}; + const row = legend.rows[i]; + row.label = label.text; + row.value = label.datum.value; } - return { - format: newFormat, - formatPrefix: formatPrefix - }; }; - -},{"./exponent.js":"jnySw","./formatGroup.js":"bU5oP","./formatNumerals.js":"eVuhg","./formatSpecifier.js":"e5jGZ","./formatTrim.js":"etxCJ","./formatTypes.js":"2VcPH","./formatPrefixAuto.js":"ixhk3","./identity.js":"8AiBy","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jnySw":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _formatDecimalJs = require("./formatDecimal.js"); -exports.default = function(x) { - return x = (0, _formatDecimalJs.formatDecimalParts)(Math.abs(x)), x ? x[1] : NaN; +const markStager = (options, stage, scene, x, y, groupType)=>{ + (0, _base.base).vega.sceneVisit(scene, function(item) { + const fn = legendMap[item.mark.role]; + if (fn) fn(stage.legend, item); + }); }; +exports.default = markStager; -},{"./formatDecimal.js":"bhu3s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bhu3s":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"hIePf","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1Vs56":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -// Computes the decimal coefficient and exponent of the specified number x with -// significant digits p, where x is positive and p is in [1, 21] or undefined. -// For example, formatDecimalParts(1.23) returns ["123", 0]. -parcelHelpers.export(exports, "formatDecimalParts", ()=>formatDecimalParts); -exports.default = function(x) { - return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10); +var _base = require("../base"); +const markStager = (options, stage, scene, x, y, groupType)=>{ + (0, _base.base).vega.sceneVisit(scene, function(item) { + const { bounds, height, url, width } = item; + let { x1, x2, y1, y2 } = bounds; + x1 += x; + x2 += x; + y1 += y; + y2 += y; + if (!stage.backgroundImages) stage.backgroundImages = []; + stage.backgroundImages.push({ + bounds: { + x1, + x2, + y1, + y2 + }, + height, + url, + width + }); + }); }; -function formatDecimalParts(x, p) { - if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity - var i, coefficient = x.slice(0, i); - // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ - // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). - return [ - coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, - +x.slice(i + 1) - ]; -} +exports.default = markStager; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bU5oP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"hIePf","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7DefN":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -exports.default = function(grouping, thousands) { - return function(value, width) { - var i = value.length, t = [], j = 0, g = grouping[0], length = 0; - while(i > 0 && g > 0){ - if (length + g + 1 > width) g = Math.max(1, width - length); - t.push(value.substring(i -= g, i + g)); - if ((length += g + 1) > width) break; - g = grouping[j = (j + 1) % grouping.length]; +var _base = require("../base"); +var _color = require("../color"); +var _defaults = require("../defaults"); +const markStager = (options, stage, scene, x, y, groupType)=>{ + (0, _base.base).vega.sceneVisit(scene, function(item) { + const noZ = item.z === undefined; + const z = noZ ? 0 : (item.z || 0) + (0, _defaults.minZ); + const depth = (noZ ? 0 : item.depth || 0) + (0, _defaults.min3dDepth); + //change direction of y from SVG to GL + const ty = -1; + const ordinal = options.assignCubeOrdinal(item.datum); + if (ordinal > options.maxOrdinal) options.maxOrdinal = ordinal; + if (ordinal === undefined) ; + else { + const cube = { + ordinal, + size: [ + item.width, + item.height, + depth + ], + position: [ + x + (+item.x || 0), + ty * (y + (+item.y || 0)) - +item.height, + z + ], + color: (0, _color.colorFromString)(item.fill) || options.defaultCubeColor || [ + 128, + 128, + 128, + 128 + ] + }; + cube.color[3] = item.opacity === undefined ? 255 : 255 * item.opacity; + stage.cubeData.push(cube); } - return t.reverse().join(thousands); - }; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eVuhg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(numerals) { - return function(value) { - return value.replace(/[0-9]/g, function(i) { - return numerals[+i]; - }); - }; + }); }; +exports.default = markStager; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"e5jGZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"hIePf","../color":"cgTtg","../defaults":"4Q1zd","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aqAq7":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FormatSpecifier", ()=>FormatSpecifier); -// [[fill]align][sign][symbol][0][width][,][.precision][~][type] -var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; -function formatSpecifier(specifier) { - if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); - var match; - return new FormatSpecifier({ - fill: match[1], - align: match[2], - sign: match[3], - symbol: match[4], - zero: match[5], - width: match[6], - comma: match[7], - precision: match[8] && match[8].slice(1), - trim: match[9], - type: match[10] +parcelHelpers.export(exports, "box", ()=>box); +var _base = require("../base"); +var _color = require("../color"); +var _defaults = require("../defaults"); +const markStager = (options, stage, scene, x, y, groupType)=>{ + (0, _base.base).vega.sceneVisit(scene, function(item) { + const x1 = item.x || 0; + const y1 = item.y || 0; + const x2 = item.x2 != null ? item.x2 : x1; + const y2 = item.y2 != null ? item.y2 : y1; + const lineItem = styledLine(x1 + x, y1 + y, x2 + x, y2 + y, item.stroke, item.strokeWidth); + const { currAxis } = options; + if (options.modifyAxis) options.modifyAxis(item, lineItem, stage, currAxis); + if (item.mark.role === 'axis-tick') currAxis.ticks.push(lineItem); + else if (item.mark.role === 'axis-domain') currAxis.domain = lineItem; + else stage.gridLines.push(lineItem); }); +}; +function styledLine(x1, y1, x2, y2, stroke, strokeWidth) { + const line = { + sourcePosition: [ + x1, + -y1, + (0, _defaults.lineZ) + ], + targetPosition: [ + x2, + -y2, + (0, _defaults.lineZ) + ], + color: (0, _color.colorFromString)(stroke), + strokeWidth: strokeWidth + }; + return line; } -exports.default = formatSpecifier; -formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof -function FormatSpecifier(specifier) { - this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; - this.align = specifier.align === undefined ? ">" : specifier.align + ""; - this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; - this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; - this.zero = !!specifier.zero; - this.width = specifier.width === undefined ? undefined : +specifier.width; - this.comma = !!specifier.comma; - this.precision = specifier.precision === undefined ? undefined : +specifier.precision; - this.trim = !!specifier.trim; - this.type = specifier.type === undefined ? "" : specifier.type + ""; +function box(gx, gy, height, width, stroke, strokeWidth, diagonals = false) { + const lines = [ + styledLine(gx, gy, gx + width, gy, stroke, strokeWidth), + styledLine(gx + width, gy, gx + width, gy + height, stroke, strokeWidth), + styledLine(gx + width, gy + height, gx, gy + height, stroke, strokeWidth), + styledLine(gx, gy + height, gx, gy, stroke, strokeWidth) + ]; + if (diagonals) { + lines.push(styledLine(gx, gy, gx + width, gy + height, stroke, strokeWidth)); + lines.push(styledLine(gx, gy + height, gx + width, gy, stroke, strokeWidth)); + } + return lines; } -FormatSpecifier.prototype.toString = function() { - return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type; -}; +exports.default = markStager; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"etxCJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"hIePf","../color":"cgTtg","../defaults":"4Q1zd","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"axYMN":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. -exports.default = function(s) { - out: for(var n = s.length, i = 1, i0 = -1, i1; i < n; ++i)switch(s[i]){ - case ".": - i0 = i1 = i; - break; - case "0": - if (i0 === 0) i0 = i; - i1 = i; - break; - default: - if (!+s[i]) break out; - if (i0 > 0) i0 = 0; - break; - } - return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; +var _color = require("../color"); +//change direction of y from SVG to GL +const ty = -1; +const markStager = (options, stage, scene, x, y, groupType)=>{ + const g = Object.assign({ + opacity: 1, + strokeOpacity: 1, + strokeWidth: 1 + }, scene.items[0]); + const path = { + strokeWidth: g.strokeWidth, + strokeColor: (0, _color.colorFromString)(g.stroke), + positions: scene.items.map((it)=>[ + it.x, + ty * it.y, + it.z || 0 + ]) + }; + path.strokeColor[3] *= g.strokeOpacity; + path.strokeColor[3] *= g.opacity; + stage.pathData.push(path); }; +exports.default = markStager; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2VcPH":[function(require,module,exports) { +},{"../color":"cgTtg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"geL5J":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ // import { AlignmentBaseline, TextAnchor } from '@deck.gl/layers/text-layer/text-layer'; var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -var _formatDecimalJs = require("./formatDecimal.js"); -var _formatDecimalJsDefault = parcelHelpers.interopDefault(_formatDecimalJs); -var _formatPrefixAutoJs = require("./formatPrefixAuto.js"); -var _formatPrefixAutoJsDefault = parcelHelpers.interopDefault(_formatPrefixAutoJs); -var _formatRoundedJs = require("./formatRounded.js"); -var _formatRoundedJsDefault = parcelHelpers.interopDefault(_formatRoundedJs); -exports.default = { - "%": (x, p)=>(x * 100).toFixed(p), - "b": (x)=>Math.round(x).toString(2), - "c": (x)=>x + "", - "d": (0, _formatDecimalJsDefault.default), - "e": (x, p)=>x.toExponential(p), - "f": (x, p)=>x.toFixed(p), - "g": (x, p)=>x.toPrecision(p), - "o": (x)=>Math.round(x).toString(8), - "p": (x, p)=>(0, _formatRoundedJsDefault.default)(x * 100, p), - "r": (0, _formatRoundedJsDefault.default), - "s": (0, _formatPrefixAutoJsDefault.default), - "X": (x)=>Math.round(x).toString(16).toUpperCase(), - "x": (x)=>Math.round(x).toString(16) +var _base = require("../base"); +var _color = require("../color"); +const markStager = (options, stage, scene, x, y, groupType)=>{ + //change direction of y from SVG to GL + const ty = -1; + (0, _base.base).vega.sceneVisit(scene, function(item) { + if (!item.text) return; + const size = item.fontSize; + //const alignmentBaseline = convertBaseline(item.baseline); + //const yOffset = alignmentBaseline === 'top' ? item.fontSize / 2 : 0; //fixup to get tick text correct + const yOffset = 0; + const textItem = { + color: (0, _color.colorFromString)(item.fill), + text: item.limit === undefined ? item.text : (0, _base.base).vega.truncate(item.text, item.limit, 'right', item.ellipsis || '...'), + position: [ + x + (item.x || 0), + ty * (y + (item.y || 0) + yOffset), + 0 + ], + size, + angle: convertAngle(item.angle), + //textAnchor: convertAlignment(item.align), + //alignmentBaseline, + metaData: item.metaData + }; + const { currAxis } = options; + if (options.modifyAxis) options.modifyAxis(item, textItem, stage, currAxis); + if (item.mark.role === 'axis-label') { + const tickText = textItem; + tickText.value = item.datum.value; + currAxis.tickText.push(tickText); + } else if (item.mark.role === 'axis-title') currAxis.title = textItem; + else stage.textData.push(textItem); + }); }; +function convertAngle(vegaTextAngle) { + if (vegaTextAngle && !isNaN(vegaTextAngle)) return 360 - vegaTextAngle; + return 0; +} +// function convertAlignment(textAlign: SceneTextAlign): TextAnchor { +// switch (textAlign) { +// case 'center': return 'middle'; +// case 'left': return 'start'; +// case 'right': return 'end'; +// } +// return 'start'; +// } +// function convertBaseline(baseline: SceneTextBaseline): AlignmentBaseline { +// switch (baseline) { +// case 'middle': return 'center'; +// } +// return baseline || 'bottom'; +// } +exports.default = markStager; -},{"./formatDecimal.js":"bhu3s","./formatPrefixAuto.js":"ixhk3","./formatRounded.js":"a0xY7","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ixhk3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"hIePf","../color":"cgTtg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"96Qp6":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "prefixExponent", ()=>prefixExponent); -var _formatDecimalJs = require("./formatDecimal.js"); -var prefixExponent; -exports.default = function(x, p) { - var d = (0, _formatDecimalJs.formatDecimalParts)(x, p); - if (!d) return x + ""; - var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length; - return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + (0, _formatDecimalJs.formatDecimalParts)(x, Math.max(0, p + i - 1))[0]; // less than 1y! -}; +parcelHelpers.export(exports, "GroupType", ()=>GroupType); +var GroupType; +(function(GroupType) { + GroupType[GroupType["none"] = 0] = "none"; + GroupType[GroupType["legend"] = 1] = "legend"; + GroupType[GroupType["xAxis"] = 2] = "xAxis"; + GroupType[GroupType["yAxis"] = 3] = "yAxis"; + GroupType[GroupType["zAxis"] = 4] = "zAxis"; +})(GroupType || (GroupType = {})); -},{"./formatDecimal.js":"bhu3s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"a0xY7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6vcDa":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -var _formatDecimalJs = require("./formatDecimal.js"); -exports.default = function(x, p) { - var d = (0, _formatDecimalJs.formatDecimalParts)(x, p); - if (!d) return x + ""; - var coefficient = d[0], exponent = d[1]; - return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0"); -}; - -},{"./formatDecimal.js":"bhu3s","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8AiBy":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(x) { - return x; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"f7bS0":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _exponentJs = require("./exponent.js"); -var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -exports.default = function(step) { - return Math.max(0, -(0, _exponentJsDefault.default)(Math.abs(step))); -}; - -},{"./exponent.js":"jnySw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8xg0b":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _exponentJs = require("./exponent.js"); -var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -exports.default = function(step, value) { - return Math.max(0, Math.max(-8, Math.min(8, Math.floor((0, _exponentJsDefault.default)(value) / 3))) * 3 - (0, _exponentJsDefault.default)(Math.abs(step))); -}; - -},{"./exponent.js":"jnySw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8uO5J":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _exponentJs = require("./exponent.js"); -var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -exports.default = function(step, max) { - step = Math.abs(step), max = Math.abs(max) - step; - return Math.max(0, (0, _exponentJsDefault.default)(max) - (0, _exponentJsDefault.default)(step)) + 1; -}; - -},{"./exponent.js":"jnySw","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2xUqU":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "version", ()=>version); -const version = "4.0.6"; +var _render = require("./render"); +parcelHelpers.exportAll(_render, exports); +var _color = require("./color"); +parcelHelpers.exportAll(_color, exports); +var _init = require("./init"); +parcelHelpers.exportAll(_init, exports); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"drIds":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "classList", ()=>classList); -parcelHelpers.export(exports, "deepCompare", ()=>deepCompare); -parcelHelpers.export(exports, "compareInsight", ()=>compareInsight); +},{"./render":"k7EOz","./color":"7T6SC","./init":"dMNNU","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"k7EOz":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _justCompare = require("just-compare"); -const classList = (...args)=>{ - return args.filter(Boolean).join(" "); -}; -const deepCompare = _justCompare.default || _justCompare; -function addNullable(insight, signalValues) { - const withNulls = Object.assign(Object.assign({ - view: null, - filter: null - }, insight), { - signalValues - }); - return withNulls; -} -function compareInsight(viewer, insight) { - const currentInsight = viewer.getInsight(); - const a = addNullable(currentInsight, Object.assign(Object.assign({}, viewer.insight.signalValues), currentInsight.signalValues)); - const b = addNullable(insight, Object.assign(Object.assign({}, a.signalValues), insight.signalValues)); - const compare = deepCompare(a, b); - return { - a, - b, - compare - }; -} - -},{"just-compare":"Sc8QX","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"Sc8QX":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "default", ()=>collectionCompare); -var collectionCompare = compare; -/* - primitives: value1 === value2 - functions: value1.toString == value2.toString - arrays: if length, sequence and values of properties are identical - objects: if length, names and values of properties are identical - compare([[1, [2, 3]], [[1, [2, 3]]); // true - compare([[1, [2, 3], 4], [[1, [2, 3]]); // false - compare({a: 2, b: 3}, {a: 2, b: 3}); // true - compare({a: 2, b: 3}, {b: 3, a: 2}); // true - compare({a: 2, b: 3, c: 4}, {a: 2, b: 3}); // false - compare({a: 2, b: 3}, {a: 2, b: 3, c: 4}); // false - compare([[1, [2, {a: 4}], 4], [[1, [2, {a: 4}]]); // true -*/ function compare(value1, value2) { - if (value1 === value2) return true; - /* eslint-disable no-self-compare */ // if both values are NaNs return true - if (value1 !== value1 && value2 !== value2) return true; - if (({}).toString.call(value1) != ({}).toString.call(value2)) return false; - if (value1 !== Object(value1)) // non equal primitives - return false; - if (!value1) return false; - if (Array.isArray(value1)) return compareArrays(value1, value2); - if (({}).toString.call(value1) == "[object Set]") return compareArrays(Array.from(value1), Array.from(value2)); - if (({}).toString.call(value1) == "[object Object]") return compareObjects(value1, value2); - else return compareNativeSubtypes(value1, value2); -} -function compareNativeSubtypes(value1, value2) { - // e.g. Function, RegExp, Date - return value1.toString() === value2.toString(); -} -function compareArrays(value1, value2) { - var len = value1.length; - if (len != value2.length) return false; - var alike = true; - for(var i = 0; i < len; i++)if (!compare(value1[i], value2[i])) { - alike = false; - break; - } - return alike; -} -function compareObjects(value1, value2) { - var keys1 = Object.keys(value1).sort(); - var keys2 = Object.keys(value2).sort(); - var len = keys1.length; - if (len != keys2.length) return false; - for(var i = 0; i < len; i++){ - var key1 = keys1[i]; - var key2 = keys2[i]; - if (!(key1 == key2 && compare(value1[key1], value2[key2]))) return false; - } - return true; -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lbyGU":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Viewer", ()=>Viewer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("./base"); -var _util = require("./util"); -var _sanddance = require("@msrvida/sanddance"); -function _Viewer(_props) { - class __Viewer extends (0, _base.base).react.Component { - layout() { - const { props } = this; - this.lastData = props.data; - this.viewer.render({ - insight: props.insight, - setup: props.setup - }, props.data, props.renderOptions).then((renderResult)=>{ - //TODO: show errors if any - //console.log('viewer render'); - props.onView && props.onView(renderResult); - }).catch((e)=>{ - //console.log('viewer error'); - props.onError && props.onError(e); - }); - } - view() { - var _a, _b, _c, _d, _e; - const { props } = this; - let didLayout = false; - if (props.insight && props.data) { - const c = (0, _util.compareInsight)(this.viewer, props.insight); - const sameDataRef = props.data === this.lastData; - if (!c.compare || !sameDataRef) { - this.layout(); - didLayout = true; - } - } - if (!didLayout && props.setup) { - const { camera } = props.setup; - //compare setup, move camera - if (camera !== "hold") { - if (!(0, _util.deepCompare)(this.viewer.setup.camera, camera)) { - //camera is different - if (!camera) (_b = (_a = this.viewer) === null || _a === void 0 ? void 0 : _a.presenter) === null || _b === void 0 || _b.homeCamera(); - else this.viewer.setCamera(camera); - //save this for next comparison - const setup = (0, _sanddance.VegaMorphCharts).util.clone(this.viewer.setup); - setup.camera = camera; - this.viewer.setup = setup; - } - } - if (props.setup.renderer) (_e = (_d = (_c = this.viewer) === null || _c === void 0 ? void 0 : _c.presenter) === null || _d === void 0 ? void 0 : _d.morphchartsref) === null || _e === void 0 || _e.setMorphChartsRendererOptions(props.setup.renderer); - } - } - componentDidMount() { - const { props } = this; - const element = (0, _base.base).reactDOM.findDOMNode(this.viewerDiv); - this.viewer = new (0, _sanddance.Viewer)(element, props.viewerOptions); - if (props.onMount) { - if (props.onMount(this.viewer.presenter.getElement((0, _sanddance.VegaMorphCharts).PresenterElement.gl))) this.view(); - } else this.view(); - } - componentDidUpdate() { - const { props } = this; - this.viewer.options = (0, _sanddance.VegaMorphCharts).util.deepMerge(this.viewer.options, props.viewerOptions); - this.view(); +parcelHelpers.export(exports, "morphChartsRender", ()=>morphChartsRender); +var _axes = require("./axes"); +var _bounds = require("./bounds"); +var _cubes = require("./cubes"); +var _lines = require("./lines"); +var _text = require("./text"); +var _image = require("./image"); +var _defaults = require("../defaults"); +var _color = require("./color"); +var _defaults1 = require("./defaults"); +var _camera = require("./camera"); +function morphChartsRender(ref, prevStage, stage, height, width, preStage, colors, config) { + const { qCameraRotation2d, qCameraRotation3d, qModelRotation2d, qModelRotation3d, vCameraPosition } = (0, _defaults1.cameraDefaults); + const { core, cameraTransitioner, modelTransitioner, positionTransitioner } = ref; + let transistion2dOnly = false; + let cameraTo; + let holdCamera; + if (config.camera === 'hold') holdCamera = true; + else cameraTo = config.camera; + if (prevStage && prevStage.view !== stage.view) { + modelTransitioner.shouldTransition = !holdCamera; + if (stage.view === '2d') { + modelTransitioner.qRotation.from = qModelRotation3d; + modelTransitioner.qRotation.to = qModelRotation2d; + cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation2d; + cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; + } else { + modelTransitioner.qRotation.from = qModelRotation2d; + modelTransitioner.qRotation.to = qModelRotation3d; + cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation3d; + cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; } - componentWillUnmount() { - this.viewer.finalize(); + } else { + modelTransitioner.shouldTransition = false; + if (stage.view === '2d') { + transistion2dOnly = true; + modelTransitioner.qRotation.to = qModelRotation2d; + cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation2d; + cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; + } else { + modelTransitioner.qRotation.to = qModelRotation3d; + cameraTransitioner.qRotation.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.rotation) || qCameraRotation3d; + cameraTransitioner.vPosition.to = (cameraTo === null || cameraTo === void 0 ? void 0 : cameraTo.position) || vCameraPosition; } - render() { - return (0, _base.base).react.createElement("div", { - className: "sanddance-ReactViewer", - ref: (div)=>this.viewerDiv = div + } + core.camera.getOrbit(cameraTransitioner.qRotation.from); + core.camera.getPosition(cameraTransitioner.vPosition.from); + if (!prevStage) { + core.setModelRotation(modelTransitioner.qRotation.to, false); + core.camera.setOrbit(cameraTransitioner.qRotation.to, false); + core.camera.setPosition(cameraTransitioner.vPosition.to, false); + } else if (!holdCamera) cameraTransitioner.begin(); + positionTransitioner.begin(); + if (modelTransitioner.shouldTransition) modelTransitioner.begin(); + const props = { + ref, + stage, + height, + width, + config + }; + const cubeLayer = (0, _cubes.createCubeLayer)(props); + const lineLayer = (0, _lines.createLineLayer)(props); + const textLayer = (0, _text.createTextLayer)(props); + const { backgroundImages } = stage; + let contentBounds = (0, _bounds.outerBounds)((0, _bounds.outerBounds)(cubeLayer === null || cubeLayer === void 0 ? void 0 : cubeLayer.bounds, lineLayer === null || lineLayer === void 0 ? void 0 : lineLayer.bounds), (0, _bounds.outerBounds)(textLayer === null || textLayer === void 0 ? void 0 : textLayer.bounds, null)); + backgroundImages === null || backgroundImages === void 0 || backgroundImages.forEach((backgroundImage)=>{ + contentBounds = (0, _bounds.outerBounds)(contentBounds, convertBounds(backgroundImage.bounds)); + }); + props.bounds = contentBounds; + core.renderer.previousAxes = core.renderer.currentAxes; + const axesLayer = (0, _axes.createAxesLayer)(props); + core.config.transitionStaggering = config.transitionDurations.stagger; + core.config.transitionDuration = config.transitionDurations.position; + let bounds; + if (axesLayer && axesLayer.bounds) bounds = axesLayer.bounds; + else bounds = contentBounds; + ref.setMorphChartsRendererOptions(config.renderer); + if (preStage) preStage(stage, cubeLayer); + //add images + core.renderer.images = []; + if (backgroundImages) { + const addImage = (imageBounds, imageData)=>{ + const imageWidth = imageBounds.maxBoundsX - imageBounds.minBoundsX; + const imageHeight = imageBounds.maxBoundsY - imageBounds.minBoundsY; + const position = [ + imageBounds.minBoundsX + imageWidth / 2, + imageBounds.minBoundsY + imageHeight / 2, + 0 + ]; + const imageQuad = (0, _image.createImageQuad)(core, imageData, contentBounds, position, imageWidth, imageHeight); + const imageVisual = core.renderer.createImageVisual(imageQuad); + core.renderer.images.push(imageVisual); + }; + const imageDataCache = {}; + backgroundImages.forEach((backgroundImage)=>{ + const imageBounds = convertBounds(backgroundImage.bounds); + const imageData = imageDataCache[backgroundImage.url]; + if (imageData) addImage(imageBounds, imageData); + else (0, _image.getImageData)(backgroundImage.url).then((imageData)=>{ + imageDataCache[backgroundImage.url] = imageData; + addImage(imageBounds, imageData); }); - } + }); } - return new __Viewer(_props); -} -const Viewer = _Viewer; - -},{"./base":"jKLdn","./util":"drIds","@msrvida/sanddance":"cN6Hq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jKLdn":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "base", ()=>base); -/** - * Specify the dependency libraries to use for rendering. - * @param react React library. - * @param vega Vega library. - * @param deck @deck.gl/core library. - * @param layers @deck.gl/layers library. - * @param luma @luma.gl/core library. - */ parcelHelpers.export(exports, "use", ()=>use); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _viewer = require("./viewer"); -var _sanddance = require("@msrvida/sanddance"); -const base = { - react: null, - reactDOM: null -}; -function use(react, reactDOM, vega) { - _sanddance.VegaMorphCharts.use(vega); - base.react = react; - base.reactDOM = reactDOM; - //inform React that we are using a dynamic base class - (0, _viewer.Viewer).prototype = react.Component.prototype; -} - -},{"./viewer":"lbyGU","@msrvida/sanddance":"cN6Hq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dImTG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "version", ()=>version); -const version = "4.0.2"; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kzoCJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "strings", ()=>strings); -const strings = { - appName: "SandDance", - bingsearch: "Bing", - bingsearchDescription: (term)=>`Search Bing for "${term}"`, - buttonClose: "Close", - buttonSelect: "Search & Select", - buttonColorSchemeMap: "Map color scheme to filtered data", - buttonColorSchemeRemap: "Remap color to filtered data", - buttonColorSchemeKeep: "Keep same color scheme", - buttonCopyToClipboard: "Copy to clipboard", - buttonExclude: "Exclude", - buttonExport: "Export", - buttonExportCount: (total)=>total == 1 ? "Export 1 row..." : `Export ${total} rows...`, - buttonIsolate: "Isolate", - buttonReset: "Stop filtering", - buttonDeselect: "Clear selection", - buttonToolbarFloat: "Float toolbar", - buttonToolbarDock: "Dock toolbar", - buttonToolbarHide: "Hide toolbar", - buttonToolbarShow: "Show toolbar", - buttonNextDataItem: "Next data item", - buttonPrevDataItem: "Previous data item", - buttonCreateSnapshot: "Create snapshot", - buttonNextSnapshot: "Next snapshot", - buttonPrevSnapshot: "Previous snapshot", - buttonUpdateSnapshot: "Update snapshot", - buttonAddExpression: "Add expression", - buttonAddExpressionGroup: "Add group", - buttonDeleteExpression: "Delete", - buttonDeleteExpressionGroup: "Delete group", - buttonClearSnapshots: "Clear snapshots", - buttonDeleteSnapshot: "Delete snapshot", - buttonEditSnapshot: "Edit snapshot", - buttonMoveUp: "Move up", - buttonMoveDown: "Move down", - buttonShowVegaSpec: "Show Vega spec", - buttonLaunchVegaEditor: "Open Vega Editor", - buttonCameraHome: "Center chart in window", - buttonTooltipMapping: "Tooltip columns...", - buttonBackgroundImage: "Background image...", - buttonTransitionReverse: "Play Reverse", - buttonTransitionPause: "Pause", - buttonTransitionPlay: "Play", - buttonUndo: "Undo", - buttonRedo: "Redo", - buttonColumnTypes: "Column types...", - buttonApply: "Apply", - buttonRemove: "Remove", - buttonResetToDefault: "Reset to default", - chartTypeBarChartH: "Bar", - chartTypeBarChartV: "Column", - chartTypeDensity: "Density", - chartTypeGrid: "Grid", - chartTypeScatterPlot: "Scatter", - chartTypeStacks: "Stacks", - chartTypeStrips: "Strips", - chartTypeTreeMap: "Treemap", - defaultFileName: "sanddance-data", - errorExportFilenameEmpty: "Filename cannot be blank", - errorExportFilenameCharacters: (characters)=>`A filename cannot contain any of the following characters: ${characters}`, - errorColumnMustBeNumeric: "Numeric column required for this chart type.", - errorNumericValue: "Value must be numeric", - errorImageFormat: "File is not an image", - labelBackgroundImageDialogTitle: "Background image", - labelBackgroundImageSubtext: "Background image can only be shown on Scatterplot, Density, and Stacks charts. Columns must be numeric type.", - labelBackgroundLeft: "Left extent", - labelBackgroundRight: "Right extent", - labelBackgroundBottom: "Bottom extent", - labelBackgroundTop: "Top extent", - labelBlank: "blank", - labelNull: "null", - labelTrue: "true", - labelFalse: "false", - labelSystemInfo: "System info", - labelChangeColumnType: "Change column type", - labelChartSettings: "Chart settings", - labelEditColumn: "Edit", - labelColumnName: "Column name", - labelColumnType: "Column type", - labelColumnDistinct: "Distinct values", - labelColumnHasColorData: "Has color data", - labelColumnIsColorData: "Is color data", - labelColumnQuantitativeMin: "Min", - labelColumnQuantitativeMax: "Max", - labelColumnQuantitativeMean: "Mean", - labelDataBrowser: "Data browser", - labelDataScope: "Scope", - labelExport: "Export Data", - labelExportFormat: "File format", - labelExportCSV: ".CSV - Comma separated values", - labelExportHTML: ".HTML - A SandDance html page embedding this data", - labelExportJSON: ".JSON - JavaScript object notation", - labelExportTSV: ".TSV - Tab separated values", - labelHistory: "History", - labelHistoryWarning: "This will erase your current history.", - labelTools: "Tools", - labelHoldCamera: "Keep previous camera position", - labelVegaSpec: "Vega specification", - labelColor: "Chart color", - labelError: "Error", - labelExportFileName: "File name", - labelSnapshots: "Snapshots", - labelSnapshotSettingThumbnailWidth: "Thumbnail image width", - labelSearch: "Select by search", - labelSearchClause: "Clause", - labelSearchColumn: "Field", - labelSearchOperator: "Operator", - labelSearchValue: "Value", - labelSearchValuePlaceholder: "Value to search for", - labelChart: "Chart", - labelChartCanvas: "Chart canvas", - labelColumnMapping: "Column Mapping", - labelChartTypeOptions: "Chart options", - labelColorBin: "Color binning", - labelColorOptions: "Color options", - labelColorBinExplanation: "For numeric columns", - labelColorFieldInfo: (colorColumnName, colorColumnType, categoricalNumeric, distinctValueCount)=>`Field <span className="fieldname">${colorColumnName}</span> is of type <span className="fieldtype">${colorColumnType}</span>${categoricalNumeric ? ` and has ${distinctValueCount} distinct values` : ""}.`, - labelColorFieldIsColorData: (colorColumnName)=>`Field <span className="fieldname">${colorColumnName}</span> contains direct color data.`, - labelColorBinNone: "None (continuous)", - labelColorBinQuantize: "Quantize", - labelColorBinQuantile: "Quantile", - labelColorFilter: "Note: Colors will be re-mapped to the filter when viewing this snapshot.", - labelColorScheme: "Scheme", - labelTotal: "Total by", - labelTotalByCountSquare: "Count (Grid layout)", - labelTotalByCountStrip: "Count (Strip layout)", - labelTotalBySumStrip: "Sum (Strip layout)", - labelTotalBySumTreemap: "Sum (Treemap layout)", - labelTotalBySumStripPercent: "Sum as percentage (Strip layout)", - labelColumnColor: "Color by", - labelColumnFacet: "Facet by", - labelFacetLayout: "Facet layout", - labelFacetLayoutWrap: "Wrap", - // labelFacetLayoutHorizontal: 'Horizontal', - // labelFacetLayoutVertical: 'Vertical', - labelFacetLayoutCross: "⊞", - labelColumnFacetV: "Cross facet by", - labelColumnSort: "Sort by", - labelColumnX: "X Axis", - labelColumnY: "Y Axis", - labelColumnZ: "Z Axis", - labelColumnSize: "Size by", - labelColumnGroup: "Group by", - labelAliasColor: "Color", - labelAliasFacet: "Facet", - labelAliasFacetV: "Vertical facet", - labelAliasSort: "Sort", - labelAliasX: "X Axis", - labelAliasY: "Y Axis", - labelAliasZ: "Z Axis", - labelAliasSize: "Size", - labelAliasGroup: "Group", - labelDataItemIsFiltered: "Item is filtered from view", - labelHistoryInit: "Initial view", - labelHistoryFilterClear: "Clear filter", - labelHistoryFilterIExclude: "Exclude filter", - labelHistoryFilterIsolate: "Isolate filter", - labelHistoryChangeChartType: (chart)=>`Change chart type to ${chart}`, - labelHistoryMapColumn: (column)=>`Map ${column} role`, - labelHistoryUnMapColumn: (column)=>`Unmap ${column} role`, - labelHistoryReviveSnapshot: "Revive snapshot", - labelHistoryColorBin: "Change color binning", - labelHistoryDirectColor: "Change direct color", - labelRenderer: "Renderer quality", - labelRendererAdvancedDisabled: "Renderer quality (Enhanced 3D mode not supported on this device)", - labelRendererBasic: "Standard mode", - labelRendererAdvanced: "Enhanced 3D mode", - labelRendererOptions: "Renderer options ...", - labelRendererOptionsDialogTitle: "Renderer options", - labelRendererOptionsAntialias: "Antialias", - labelRendererOptionsBloom: "Bloom highlighting (for selections)", - labelRendererOptionsBloomIntensity: "Intensity", - labelRendererOptionsDof: "Depth of Field", - labelRendererOptionsDofRange: "Focus Range", - labelRendererOptionsFxaa: "Antialias", - labelRendererOptionsShadow: "Shadows", - labelRendererOptionsSsao: "Screen Space Ambient Occlusion", - labelShowLegend: "Show legend", - labelShowAxes: "Show axes", - labelSnapshotTitle: "Title", - labelSnapshotDescription: "Note (optional)", - labelTooltipMapping: "Tooltip columns", - labelTransition: "Transition", - labelTransitionOptions: "Transition options", - labelTransitionScrubber: "Scrub transition", - labelTransitionStaggerBy: "Stagger by", - labelTransitionStaggerByOrdinal: "Data order", - labelTransitionStaggerByColumn: "Column", - labelTransitionStaggerByPosition: "Axis position", - labelTransitionStaggerOptions: "Stagger options", - labelTransitionStaggerReverse: "Reverse", - labelTransitionDurations: "Transition durations", - labelTransitionCamera: "2D / 3D view", - labelTransitionDuration: "Duration", - labelTransitionStagger: "Stagger", - labelVegaSpecData: "Data reference", - labelVegaSpecNotes: "Note: You may need to change the color scheme to make this visible in Vega.", - labelYes: "Yes", - labelNo: "No", - labelConfirmation: "Are you sure?", - labelColumnTypes: "Column types", - loading: "Loading...", - schemeCategorical: "Categorical", - schemeCyclical: "Cyclical", - schemeDiverging: "Diverging", - schemeDual: "Dual", - schemeSequentialMultiHue: "Sequential Multi Hue", - schemeSequentialMultiHueDark: "For dark backgrounds", - schemeSequentialMultiHueLight: "For light backgrounds", - schemeSequentialSingleHue: "Sequential Single Hue", - selectDataSpanAll: "All rows", - selectDataSpanFilter: "Filtered", - selectDataSpanSelection: "Selected", - selectVegaSpecDataNone: "None", - selectVegaSpecDataInline: "Inline - WARNING this may use substantial browser/clipboard memory for large data sets.", - selectVegaSpecDataUrl: "URL", - record: (current, total)=>`${current} of ${total}`, - searchEQ: "=", - searchNEQ: "<>", - searchGT: ">", - searchGTE: ">=", - searchLT: "<", - searchLTE: "<=", - searchNULL: "is null or empty", - searchIN: "contains", - searchSW: "starts with", - searchWHERE: "Where", - searchAND: "and", - searchOR: "or", - selectAny: "-- any --", - selectNone: "-- none --", - selectNumeric: "Numeric", - selectNonNumeric: "Categorical", - selectDirectColor: "Direct color", - selectReference: "Column mappings", - tooltipSearch: (column, value)=>`Click to search in '${column}' for "${value}"`, - labelRequired: "required", - labelSystem: "System", - labelViewType2d: "View in 2D", - labelViewType3d: "View in 3D", - labelDataColors: "Enabled if this data column contains any CSS color values.", - labelDataNullAll: "Loading data...", - labelDataNullFiltered: "You can filter by first making a selection, then choosing <b>Isolate</b> or <b>Exclude</b> in the top bar.", - labelDataNullSelection: "You can select by: <ul><li>clicking the chart axes</li><li>clicking in the legend</li><li>searching</li</ul>", - labelZeroAll: "Dataset contains zero rows.", - labelZeroSearchResults: "No rows matched your search.", - signalGroups: [ - { - prefix: "Chart", - label: "Chart options" - }, - { - prefix: "Mark", - label: "Mark options" - }, - { - prefix: "RoleColor", - label: "Color options" - }, - { - prefix: "RoleFacet", - label: "Facet options" - }, - { - prefix: "RoleSort", - label: "Sort options" - }, - { - prefix: "RoleX", - label: "X axis options" - }, - { - prefix: "RoleY", - label: "Y axis options" + //Now call update on each layout + layersWithSelection(cubeLayer, lineLayer, textLayer, config.layerSelection, bounds, ref.layerStagger); + (0, _camera.applyCameraCallbacks)(ref, config, stage.view, transistion2dOnly); + core.renderer.transitionTime = 0; // Set renderer transition time for this render pass to prevent rendering target buffer for single frame + (0, _color.colorConfig)(ref, colors); + return { + bounds, + getCubeLayer: ()=>cubeLayer, + update: (layerSelection)=>layersWithSelection(cubeLayer, lineLayer, textLayer, layerSelection, bounds, ref.layerStagger), + activate: (id)=>core.renderer.transitionBuffers[0].activeId = id, + moveCamera: (camera)=>{ + if (!(positionTransitioner.isTransitioning || modelTransitioner.isTransitioning)) { + core.camera.getOrbit(cameraTransitioner.qRotation.from); + core.camera.getPosition(cameraTransitioner.vPosition.from); + cameraTransitioner.move(camera.position, camera.rotation); + } }, + setTransitionTimeAxesVisibility: ()=>{ + (0, _camera.setTransitionTimeAxesVisibility)(transistion2dOnly, core); + } + }; +} +function layersWithSelection(cubeLayer, lineLayer, textLayer, layerSelection, bounds, layerStagger) { + const layerItems = [ { - prefix: "RoleZ", - label: "Z axis options" + layer: cubeLayer, + selection: layerSelection === null || layerSelection === void 0 ? void 0 : layerSelection.cubes, + stagger: layerStagger === null || layerStagger === void 0 ? void 0 : layerStagger.cubes }, { - prefix: "Text", - label: "Text options" + layer: lineLayer, + selection: layerSelection === null || layerSelection === void 0 ? void 0 : layerSelection.lines, + stagger: layerStagger === null || layerStagger === void 0 ? void 0 : layerStagger.lines }, { - prefix: "*", - label: "Options" - }, - ], - percentValueFormat: (value)=>`${value}%` -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6gzbB":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "IconButton", ()=>IconButton); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -function IconButton(props) { - return (0, _base.base).react.createElement((0, _base.base).fluentUI.IconButton, Object.assign({}, props, { - styles: props.styles || { - root: { - color: props.themePalette.black - }, - rootHovered: { - background: "transparent", - color: props.themePalette.themePrimary - }, - rootPressed: { - background: "transparent" - }, - menuIcon: { - display: "none" - } - }, - iconProps: { - iconName: props.iconName - }, - menuProps: props.menuProps - })); -} - -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9L5VX":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "attachSpecRoleToAxisTitle", ()=>attachSpecRoleToAxisTitle); -parcelHelpers.export(exports, "PositionedColumnMap", ()=>PositionedColumnMap); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("./base"); -var _columnMap = require("./controls/columnMap"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function attachSpecRoleToAxisTitle(stage, specCapabilities) { - for(const axisName in stage.axes)specCapabilities.roles.forEach((specRole)=>{ - if (specRole.role === axisName) { - const axes = stage.axes[axisName]; - axes.forEach((axis)=>{ - if (axis.title) { - const textItem = axis.title; - textItem.specRole = specRole; - } - }); + layer: textLayer, + selection: layerSelection === null || layerSelection === void 0 ? void 0 : layerSelection.texts, + stagger: layerStagger === null || layerStagger === void 0 ? void 0 : layerStagger.texts } + ]; + layerItems.forEach((layerItem)=>{ + var _a; + return (_a = layerItem.layer) === null || _a === void 0 ? void 0 : _a.update(bounds, layerItem.selection, layerItem.stagger); }); } -function px(n) { - return n + "px"; -} -function _PositionedColumnMap(_props) { - class __PositionedColumnMap extends (0, _base.base).react.Component { - constructor(props){ - super(props); - const { left , top } = props; - this.state = { - left, - top - }; - this.dropdownRef = (0, _base.base).react.createRef(); - } - focus() { - if (!this.focused) { - this.focused = true; - this.dropdownRef.current.focus(true); - } - } - componentDidMount() { - const size = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.outerSize(this.div); - const over = { - left: Math.max(0, this.state.left + size.width - this.props.container.offsetWidth), - top: Math.max(0, this.state.top + size.height - this.props.container.offsetHeight) - }; - if (over.left || over.top) { - let { left , top } = this.state; - left -= over.left; - top -= over.top; - this.setState({ - left, - top - }); - } else this.focus(); - } - componentDidUpdate() { - this.focus(); - } - render() { - return (0, _base.base).react.createElement("div", { - ref: (div)=>{ - if (div) this.div = div; - }, - className: "sanddance-columnMap-absolute", - style: { - position: "absolute", - left: px(this.state.left), - top: px(this.state.top) - } - }, (0, _base.base).react.createElement((0, _columnMap.ColumnMap), Object.assign({}, this.props, { - componentRef: this.dropdownRef, - hideSignals: true - }))); - } - } - return new __PositionedColumnMap(_props); +function convertBounds(bounds) { + if (!bounds) return; + return { + minBoundsX: bounds.x1, + maxBoundsX: bounds.x2, + minBoundsY: -bounds.y2, + maxBoundsY: -bounds.y1, + minBoundsZ: (0, _defaults.minZ), + maxBoundsZ: (0, _defaults.minZ) + }; } -const PositionedColumnMap = _PositionedColumnMap; -},{"./base":"9M4eu","./controls/columnMap":"5sGIS","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5sGIS":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getColumnMapOptions", ()=>getColumnMapOptions); -parcelHelpers.export(exports, "ColumnMap", ()=>ColumnMap); +},{"./axes":"a0VSy","./bounds":"g9F83","./cubes":"9hPmh","./lines":"cM6w1","./text":"6hAIv","./image":"k12os","../defaults":"4Q1zd","./color":"7T6SC","./defaults":"baEhk","./camera":"cPRXr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"a0VSy":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); -var _dropdown = require("./dropdown"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _signal = require("./signal"); -var _language = require("../language"); -const maxFacets = 50; -const roleLabels = { - color: (0, _language.strings).labelColumnColor, - facet: (0, _language.strings).labelColumnFacet, - facetV: (0, _language.strings).labelColumnFacetV, - group: (0, _language.strings).labelColumnGroup, - size: (0, _language.strings).labelColumnSize, - sort: (0, _language.strings).labelColumnSort, - uid: null, - x: (0, _language.strings).labelColumnX, - y: (0, _language.strings).labelColumnY, - z: (0, _language.strings).labelColumnZ -}; -const aliasLabels = { - color: (0, _language.strings).labelAliasColor, - facet: (0, _language.strings).labelAliasFacet, - facetV: (0, _language.strings).labelAliasFacetV, - group: (0, _language.strings).labelAliasGroup, - size: (0, _language.strings).labelAliasSize, - sort: (0, _language.strings).labelAliasSort, - uid: null, - x: (0, _language.strings).labelAliasX, - y: (0, _language.strings).labelAliasY, - z: (0, _language.strings).labelAliasZ -}; -function filterColumnList(context, columns) { - switch(context){ - case "facet": - case "facetV": - return columns.filter((column)=>column.quantitative || column.stats.distinctValueCount && column.stats.distinctValueCount < maxFacets); - default: - return columns.slice(); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "createAxesLayer", ()=>createAxesLayer); +var _morphcharts = require("morphcharts"); +var _bounds = require("./bounds"); +const createAxesLayer = (props)=>{ + const { config, height, ref, stage } = props; + const { core } = ref; + const { renderer } = core; + const { x, y, z } = stage.axes; + const xyz = [ + ...x, + ...y, + ...z + ]; + renderer.currentAxes = []; + if (!xyz.length) { + renderer.axesVisibility = (0, _morphcharts.AxesVisibility).none; + return; } -} -function optionsForSpecColumn(sectionName, columns, role, disabledColumnName, selectedColumnName) { - const filtered = filterColumnList(role, columns); - const options = filtered.map((column)=>{ - const option = { - key: `column:${column.name}`, - text: column.name, - data: column, - selected: selectedColumnName === column.name, - disabled: disabledColumnName === column.name + renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; + const correlation = new AxesCorrelation(stage, 3); + const { axesSets, labels } = correlation; + const grid = correlation.getGrid(); + if (grid.byColumn[0]) { + grid.byColumn[0].forEach((row)=>{ + row.axesSet.showFacetTitleY = true; + }); + grid.byRow[0].forEach((col)=>{ + col.axesSet.showFacetTitleX = true; + }); + } + if (grid.rows > 1) { + const { byRow } = grid; + byRow[0].forEach(({ axesSet }, col)=>{ + if (!axesSet.y) { + if (byRow[1][col].axesSet) { + //move x up + byRow[1][col].axesSet.x.tickText = axesSet.x.tickText; + byRow[1][col].axesSet.showFacetTitleX = axesSet.showFacetTitleX; + delete axesSet.x; + } + } + }); + } + let bounds; + const allAxesSetBounds = []; + let anyZ = false; + for(let i = 0; i < axesSets.length; i++)if (axesSets[i].z) { + anyZ = true; + break; + } + const is3d = stage.view === '3d' && anyZ; + axesSets.forEach((axesSet)=>{ + if (!axesSet.x && !axesSet.y) return; + const axesSetBounds = { + axesSet, + maxBoundsX: null, + maxBoundsY: null, + maxBoundsZ: null, + minBoundsX: null, + minBoundsY: null, + minBoundsZ: null }; - return option; + if (is3d) { + const zBounds = getDomainBounds(1, axesSet.z); + axesSetBounds.minBoundsZ = -zBounds.maxBounds; + axesSetBounds.maxBoundsZ = -zBounds.minBounds; + } + const yBounds = getDomainBounds(1, axesSet.y); + axesSetBounds.minBoundsY = yBounds.minBounds; + axesSetBounds.maxBoundsY = yBounds.maxBounds; + axesSetBounds.y = yBounds.minBounds; + axesSetBounds.h = yBounds.maxBounds - yBounds.minBounds; + const xBounds = getDomainBounds(0, axesSet.x); + axesSetBounds.minBoundsX = xBounds.minBounds; + axesSetBounds.maxBoundsX = xBounds.maxBounds; + axesSetBounds.x = xBounds.minBounds; + axesSetBounds.w = xBounds.maxBounds - xBounds.minBounds; + allAxesSetBounds.push(axesSetBounds); + bounds = (0, _bounds.outerBounds)(bounds, axesSetBounds); }); - if (options.length) { - const option = { - key: sectionName, - text: sectionName, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header - }; - options.unshift(option); + const facetLabelX = labels.filter((label)=>label.axisRole === 'x')[0]; + const facetLabelY = labels.filter((label)=>label.axisRole === 'y')[0]; + core.inputManager.pickAxesTitleCallback = ({ axis, axes, manipulator })=>{ + const axesSet = axesSets[axes]; + let a; + let f; + switch(axis){ + case 0: + a = axesSet.x; + f = facetLabelX; + break; + case 1: + a = axesSet.y; + f = facetLabelY; + break; + case 2: + a = axesSet.z; + break; + } + if (a) config.onTextClick(manipulator.event, a.title || f.title); + }; + allAxesSetBounds.forEach((axesSetBounds)=>{ + const { axesSet } = axesSetBounds; + if (!axesSet.x && !axesSet.y) return; + const cartesian = new (is3d ? (0, _morphcharts.Axes).Cartesian3dAxes : (0, _morphcharts.Axes).Cartesian2dAxes)(core); + cartesian.isDivisionPickingEnabled = [ + false, + false, + false + ]; + cartesian.arePickDivisionsVisible = [ + false, + false, + false + ]; + cartesian.isLabelPickingEnabled = [ + false, + false, + false + ]; + cartesian.isTitlePickingEnabled = [ + false, + false, + false + ]; + cartesian.isGridPickingEnabled = false; + cartesian.isHeadingPickingEnabled = [ + false, + false, + false + ]; + createAxes(cartesian, 0, 0, axesSet.x, (0, _morphcharts.AxesTextOrientation).perpendicular, height, props, axesSet.showFacetTitleX && facetLabelX); + createAxes(cartesian, 1, 1, axesSet.y, (0, _morphcharts.AxesTextOrientation).perpendicular, height, props, axesSet.showFacetTitleY && facetLabelY); + if (is3d) createAxes(cartesian, 1, 2, axesSet.z, (0, _morphcharts.AxesTextOrientation).perpendicular, height, props); + configCartesianAxes(is3d, bounds, cartesian); + const { maxBoundsX, maxBoundsY, minBoundsX, minBoundsY } = bounds; + const w = maxBoundsX - minBoundsX; + const h = maxBoundsY - minBoundsY; + cartesian.scalingX = axesSetBounds.w / w; + cartesian.scalingY = axesSetBounds.h / h; + cartesian.offsetX = (axesSetBounds.x - minBoundsX + axesSetBounds.w / 2) / w - 0.5; + cartesian.offsetY = (axesSetBounds.y - minBoundsY + axesSetBounds.h / 2) / h - 0.5; + const aspect = h / w; + if (aspect > 1) cartesian.offsetX /= aspect; + else cartesian.offsetY *= aspect; + const axes = is3d ? renderer.createCartesian3dAxesVisual(cartesian) : renderer.createCartesian2dAxesVisual(cartesian); + renderer.currentAxes.push(axes); + props.config.onAxesComplete && props.config.onAxesComplete(cartesian); + }); + return { + bounds + }; +}; +const nullDomain = { + sourcePosition: [ + 0, + 0, + 0 + ], + targetPosition: [ + 0, + 0, + 0 + ] +}; +class AxesCorrelation { + constructor(stage, dimensions){ + this.dimensions = dimensions; + const { x, y, z } = stage.axes; + this.axesSets = []; + this.labels = []; + [ + x, + y, + z + ].forEach((axes)=>{ + axes.forEach((axis)=>{ + if (this.axesSets.length === 0) this.initialize(axis); + else this.correlate(axis); + }); + }); } - return options; -} -function optionsForReference(sectionName, specRoles) { - const options = specRoles.map((specRole)=>{ - const option = { - key: `role:${specRole.role}`, - text: aliasLabels[specRole.role], - data: specRole.role - }; - return option; - }).sort((a, b)=>a.text.localeCompare(b.text)); - if (options.length) { - const option = { - key: sectionName, - text: sectionName, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header + getGrid() { + const mapCols = {}; + const mapRows = {}; + this.axesSets.forEach((axesSet)=>{ + var _a; + const domain = (_a = axesSet === null || axesSet === void 0 ? void 0 : axesSet.x) === null || _a === void 0 ? void 0 : _a.domain; + if (!domain) return; + const col = domain.sourcePosition[0].toString(); + const row = domain.sourcePosition[1].toString(); + if (!mapCols[col]) mapCols[col] = {}; + mapCols[col][row] = axesSet; + mapRows[row] = null; + }); + const colKeys = Object.keys(mapCols).sort((a, b)=>+a - +b); + const rowKeys = Object.keys(mapRows).sort((a, b)=>+a - +b); + return { + cols: colKeys.length, + rows: rowKeys.length, + byColumn: colKeys.map((colKey)=>rowKeys.map((rowKey)=>{ + return { + colKey, + rowKey, + axesSet: mapCols[colKey][rowKey] + }; + })), + byRow: rowKeys.map((rowKey)=>colKeys.map((colKey)=>{ + return { + colKey, + rowKey, + axesSet: mapCols[colKey][rowKey] + }; + })) }; - options.unshift(option); } - return options; -} -function selectFirst(options) { - for(let i = 0; i < options.length; i++){ - if (options[i].itemType === (0, _base.base).fluentUI.DropdownMenuItemType.Header) continue; - options[i].selected = true; - return; + initialize(axis) { + if (!axis.domain) { + this.labels.push(axis); + return; + } + const axesSet = {}; + axesSet[axis.axisRole] = axis; + this.axesSets.push(axesSet); } -} -function getColumnMapOptions(props) { - if (!props.specRole) return null; - let categoricalColumns; - let directColorColumns; - let directColorGroup; - let referenceGroup = []; - if (props.specRole.role === "color") { - categoricalColumns = props.categoricalColumns.filter((c)=>!c.isColorData); - directColorColumns = props.categoricalColumns.filter((c)=>c.isColorData); - directColorGroup = optionsForSpecColumn((0, _language.strings).selectDirectColor, directColorColumns, "color", props.disabledColumnName, props.selectedColumnName); - } else categoricalColumns = props.categoricalColumns; - if (props.specRole.role === "sort") { - const others = props.specCapabilities.roles.filter((specRole)=>specRole.role !== props.specRole.role); - referenceGroup = optionsForReference((0, _language.strings).selectReference, others); + correlate(axis) { + if (!axis.domain) { + this.labels.push(axis); + return; + } + for(let i = 0; i < this.axesSets.length; i++){ + const axesSet = this.axesSets[i]; + for(const axisRole in axesSet){ + const test = axesSet[axisRole]; + if (this.matchDomains(axis.domain, test.domain)) { + //prefer the axes with titles + if (!axesSet[axis.axisRole] || !axesSet[axis.axisRole].tickText.length && axis.tickText.length) axesSet[axis.axisRole] = axis; + return; + } + } + } + this.initialize(axis); } - const quantitativeGroup = optionsForSpecColumn((0, _language.strings).selectNumeric, props.quantitativeColumns, props.specRole.role, props.disabledColumnName, props.selectedColumnName); - const categoricGroup = props.specRole.excludeCategoric ? null : optionsForSpecColumn((0, _language.strings).selectNonNumeric, categoricalColumns, props.specRole.role, props.disabledColumnName, props.selectedColumnName); - const options = referenceGroup.concat(quantitativeGroup).concat(categoricGroup).concat(directColorGroup).filter(Boolean); - return options; -} -function ColumnMap(props) { - const options = getColumnMapOptions(props); - if (props.specRole.allowNone) options.unshift({ - key: -1, - text: (0, _language.strings).selectNone - }); - const hasSelection = options.reduce((p, c)=>{ - return p || c.selected; - }, false); - if (!hasSelection) selectFirst(options); - let signals; - if (props.explorer.viewer && props.explorer.viewer.vegaSpec) { - if (props.specRole.signals) signals = props.explorer.viewer.vegaSpec.signals.filter((s)=>props.specRole.signals.indexOf(s.name) >= 0); + matchDomains(a, b) { + if (this.matchPoint(a.sourcePosition, b.sourcePosition)) return true; + if (this.matchPoint(a.sourcePosition, b.targetPosition)) return true; + if (this.matchPoint(a.targetPosition, b.targetPosition)) return true; + if (this.matchPoint(a.targetPosition, b.sourcePosition)) return true; + return false; } - const label = roleLabels[props.specRole.role]; - const signalElements = !props.hideSignals && signals && signals.map((signal, i)=>{ - let initialValue; - try { - initialValue = props.explorer.viewer.vegaViewGl.signal(signal.name); - } catch (error) { - // continue regardless of error + matchPoint(a, b) { + for(let i = 0; i < this.dimensions; i++){ + if (a[i] !== b[i]) return false; } - return (0, _base.base).react.createElement((0, _signal.Signal), { - key: signal.name + i + initialValue, - explorer: props.explorer, - signal: signal, - initialValue: initialValue, - onChange: (value)=>props.onChangeSignal && props.onChangeSignal(signal.name, value), - collapseLabel: props.collapseLabel - }); - }); - return (0, _base.base).react.createElement("div", { - className: "sanddance-columnMap" - }, props.prefix, !props.hideDropdown && (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - componentRef: props.componentRef, - collapseLabel: props.collapseLabel, - disabled: props.disabled, - label: label, - options: options, - onChange: (e, o)=>props.changeColumnMapping(props.specRole.role, typeof o.data === "string" ? o.data : (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(o.data)), - onDismiss: props.onDismiss - }), signalElements, props.suffix); + return true; + } } - -},{"../base":"9M4eu","./dropdown":"2Udzo","@msrvida/sanddance-react":"73dPQ","./signal":"847y5","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2Udzo":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "dropdownWidth", ()=>dropdownWidth); -parcelHelpers.export(exports, "Dropdown", ()=>Dropdown); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -const dropdownWidth = 200; -function Dropdown(props) { - const newProps = Object.assign({}, props); - let selectedKey = null; - if (newProps.options && newProps.options.length > 1) { - const selectedOptions = newProps.options.filter((option)=>option.selected); - if (selectedOptions && selectedOptions.length > 0) selectedKey = selectedOptions[0].key; +function createAxes(cartesian, dim2d, dim3d, axis, orientation, height, props, facetLabel) { + const domain = (axis === null || axis === void 0 ? void 0 : axis.domain) || nullDomain; + const { tickPositions, tickText, textPos, textSize } = convertAxis(axis, domain, dim2d, height); + if (axis.axisRole === 'z') { + tickPositions.forEach((t, i)=>tickPositions[i] = 1 - t); + textPos.forEach((t, i)=>textPos[i] = 1 - t); + tickText.reverse(); + tickPositions.reverse(); + textPos.reverse(); } - if (newProps.collapseLabel) newProps.onRenderTitle = (a, b)=>{ - return (0, _base.base).react.createElement("span", null, newProps.label, ": ", a[0].text); + cartesian.setTickPositions(dim3d, tickPositions); + cartesian.zero[dim3d] = 0; //TODO get any "zero" gridline position from vega + cartesian.setLabelPositions(dim3d, textPos); + cartesian.setLabels(dim3d, tickText); + cartesian.setLabelSizes(dim3d, textSize); + const title = (axis === null || axis === void 0 ? void 0 : axis.title) || (facetLabel === null || facetLabel === void 0 ? void 0 : facetLabel.title); + if (title === null || title === void 0 ? void 0 : title.text) { + cartesian.setTitle(dim3d, title.text); + cartesian.setTitleSize(dim3d, title.size / height); + } + cartesian.setLabelOrientation(dim3d, orientation); + props.config.onAxisConfig && props.config.onAxisConfig(cartesian, dim3d, axis); + return { + tickText }; - return (0, _base.base).react.createElement((0, _base.base).fluentUI.Dropdown, Object.assign({ - dropdownWidth: dropdownWidth - }, newProps, { - label: newProps.collapseLabel ? null : newProps.label, - selectedKey: selectedKey - })); } - -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"847y5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getInitialSignalValue", ()=>getInitialSignalValue); -parcelHelpers.export(exports, "Signal", ()=>Signal); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -function getInitialSignalValue(explorer, signal) { - let initialValue; - try { - initialValue = explorer.viewer.vegaViewGl.signal(signal.name); - } catch (error) { - // continue regardless of error +function configCartesianAxes(is3d, bounds, cartesian) { + if (is3d) cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).topBack] = false; + cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).backRight] = false; + cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).bottomRight] = false; + cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).frontRight] = false; + cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).topFront] = false; + cartesian.isEdgeVisible[(0, _morphcharts.Edge3D).topRight] = false; + const { maxBoundsX, maxBoundsY, maxBoundsZ, minBoundsX, minBoundsY, minBoundsZ } = bounds; + cartesian.minBoundsX = minBoundsX; + cartesian.maxBoundsX = maxBoundsX; + cartesian.minBoundsY = minBoundsY; + cartesian.maxBoundsY = maxBoundsY; + if (is3d) { + cartesian.minBoundsZ = minBoundsZ; + cartesian.maxBoundsZ = maxBoundsZ; } - return initialValue; } -function Signal(props) { - if (!props.explorer.viewer || !props.signal) return null; - if (props.signal.bind) { - const input = props.signal.bind.input; - if (input) { - const fn = map[input]; - if (fn) { - const prefix = props.prefix ? `${props.prefix} ` : ""; - const control = fn(prefix, props.signal.bind, props.initialValue, (value)=>{ - props.onChange && props.onChange(value); - props.explorer.signal(props.signal.name, value, props.newViewStateTarget); - }, props.disabled, props.collapseLabel, props.componentRef); - return (0, _base.base).react.createElement("div", { - className: "sanddance-signal" - }, control); - } - } +function getDomainBounds(dim2d, axis) { + const domain = (axis === null || axis === void 0 ? void 0 : axis.domain) || nullDomain; + const minBounds = domain.sourcePosition[dim2d]; + const maxBounds = domain.targetPosition[dim2d]; + return { + maxBounds, + minBounds + }; +} +function convertAxis(axis, domain, dim, height) { + const start = domain.sourcePosition[dim]; + const span = domain.targetPosition[dim] - start; + const tickPositions = axis ? axis.ticks.map((t)=>(t.sourcePosition[dim] - start) / span) : []; + const tickText = axis ? axis.tickText.map((t)=>t.text) : []; + const textPos = axis ? axis.tickText.map((t)=>(t.position[dim] - start) / span) : []; + const textSize = axis ? axis.tickText.map((t)=>t.size / height) : []; + if (tickPositions.length) { + if (tickPositions[0] !== 0) tickPositions[0] = 0; + if (tickPositions[tickPositions.length - 1] !== 1) tickPositions[tickPositions.length - 1] = 1; } - return null; + return { + tickPositions, + tickText, + textPos, + textSize + }; } -const map = {}; -map["range"] = (prefix, bind, initialValue, onChange, disabled, collapseLabel, ref)=>{ - let debouncer; - return (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - componentRef: ref, - label: prefix + bind.name, - max: bind.max, - min: bind.min, - step: bind.step, - defaultValue: initialValue, - onChange: (value)=>{ - if (debouncer) clearTimeout(debouncer); - debouncer = setTimeout(()=>onChange(value), bind.debounce || 0); - }, - disabled: disabled - }); -}; -map["select"] = (prefix, bind, initialValue, onChange, disabled, collapseLabel, ref)=>{ - const options = bind.options.map((o, i)=>{ - const option = { - key: o, - text: o - }; - return option; - }); - const label = prefix + bind.name; - return (0, _base.base).react.createElement((0, _base.base).fluentUI.Dropdown, { - componentRef: ref, - onRenderTitle: collapseLabel ? (a, b)=>(0, _base.base).react.createElement("span", null, label, ": ", a[0].text) : undefined, - defaultSelectedKey: initialValue, - label: collapseLabel ? undefined : label, - options: options, - onChange: (e, o)=>onChange(o.text), - disabled: disabled - }); -}; -map["checkbox"] = (prefix, bind, initialValue, onChange, disabled, collapseLabel, ref)=>{ - return (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - componentRef: ref, - defaultChecked: initialValue, - label: prefix + bind.name, - onChange: (e, checked)=>onChange(checked), - disabled: disabled - }); -}; //TODO other signal types -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"86e3b":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ColumnTypeChanger", ()=>ColumnTypeChanger); +},{"morphcharts":"9s7CR","./bounds":"g9F83","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g9F83":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); -var _dialog = require("./dialog"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _language = require("../language"); -var _iconButton = require("./iconButton"); -function _ColumnTypeChanger(_props) { - class __ColumnTypeChanger extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = this.getInitialState(); - } - getInitialState() { - const { props } = this; - return { - dialogHidden: true, - confirmationHidden: true, - quantitativeColumns: props.initialQuantitativeColumns.map((c)=>(0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(c)), - categoricalColumns: props.initialCategoricalColumns.map((c)=>(0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(c)), - columnTypes: null - }; - } - closeDialog() { - this.setState(this.getInitialState()); - } - openConfirmation(columnTypes) { - this.setState({ - columnTypes, - confirmationHidden: false - }); - } - render() { - const { props , state } = this; - const hasChanges = props.initialQuantitativeColumns.some((c, i)=>{ - return c.quantitative !== state.quantitativeColumns[i].quantitative; - }); - return (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - text: (0, _language.strings).buttonColumnTypes, - onClick: ()=>this.setState({ - dialogHidden: false - }) - }), (0, _base.base).react.createElement((0, _dialog.Dialog), { - minWidth: "80%", - hidden: state.dialogHidden, - onDismiss: ()=>this.closeDialog(), - dialogContentProps: { - className: `sanddance-dialog ${props.theme}`, - type: (0, _base.base).fluentUI.DialogType.normal, - title: (0, _language.strings).labelColumnTypes - }, - buttons: [ - (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - key: "revert", - text: (0, _language.strings).buttonResetToDefault, - onClick: ()=>this.openConfirmation(null), - iconProps: { - iconName: "Undo" - } - }), - (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - key: "apply", - text: (0, _language.strings).buttonApply, - onClick: ()=>{ - const columnTypes = {}; - state.quantitativeColumns.forEach((c)=>{ - columnTypes[c.name] = c.quantitative ? c.type : "string"; - }); - state.categoricalColumns.forEach((c)=>{ - columnTypes[c.name] = "string"; - }); - this.openConfirmation(columnTypes); - }, - iconProps: { - iconName: "Accept" - }, - disabled: !hasChanges - }), - ] - }, (0, _base.base).react.createElement("div", { - className: "sanddance-columnTypes" - }, state.quantitativeColumns.length > 0 && (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement("h3", null, (0, _language.strings).selectNumeric), (0, _base.base).react.createElement("table", null, (0, _base.base).react.createElement("thead", null, (0, _base.base).react.createElement("tr", null, (0, _base.base).react.createElement("th", null, (0, _language.strings).labelEditColumn), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnName), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnQuantitativeMin), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnQuantitativeMax), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnQuantitativeMean), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnDistinct))), (0, _base.base).react.createElement("tbody", null, state.quantitativeColumns.map((c, i)=>(0, _base.base).react.createElement("tr", { - key: i, - className: c.quantitative ? "" : "changed" - }, (0, _base.base).react.createElement("td", null, (0, _base.base).react.createElement((0, _iconButton.IconButton), { - iconName: "Edit", - onClick: undefined, - menuProps: { - items: [ - (0, _language.strings).selectNumeric, - (0, _language.strings).selectNonNumeric - ].map((t)=>{ - return { - key: t, - text: t, - onClick: ()=>{ - c.quantitative = t === (0, _language.strings).selectNumeric; - this.setState({ - quantitativeColumns: [ - ...state.quantitativeColumns - ] - }); - } - }; - }) - }, - themePalette: props.themePalette, - title: (0, _language.strings).labelChangeColumnType - })), (0, _base.base).react.createElement("td", null, c.name), (0, _base.base).react.createElement("td", null, c.stats.min), (0, _base.base).react.createElement("td", null, c.stats.max), (0, _base.base).react.createElement("td", null, c.stats.mean), (0, _base.base).react.createElement("td", null, c.stats.distinctValueCount)))))), state.categoricalColumns.length > 0 && (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement("h3", null, (0, _language.strings).selectNonNumeric), (0, _base.base).react.createElement("table", null, (0, _base.base).react.createElement("thead", null, (0, _base.base).react.createElement("tr", null, (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnName), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnType), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnDistinct), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnHasColorData), (0, _base.base).react.createElement("th", null, (0, _language.strings).labelColumnIsColorData))), (0, _base.base).react.createElement("tbody", null, state.categoricalColumns.map((c, i)=>(0, _base.base).react.createElement("tr", { - key: i - }, (0, _base.base).react.createElement("td", null, c.name), (0, _base.base).react.createElement("td", null, c.type), (0, _base.base).react.createElement("td", null, c.stats.distinctValueCount), (0, _base.base).react.createElement("td", null, (!!c.stats.hasColorData).toString()), (0, _base.base).react.createElement("td", null, (!!c.isColorData).toString())))))))), (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: state.confirmationHidden, - onDismiss: ()=>this.setState({ - confirmationHidden: true - }), - dialogContentProps: { - className: `sanddance-dialog ${props.theme}`, - type: (0, _base.base).fluentUI.DialogType.normal, - title: (0, _language.strings).labelConfirmation, - subText: (0, _language.strings).labelHistoryWarning - }, - buttons: (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - text: (0, _language.strings).buttonApply, - onClick: ()=>{ - this.closeDialog(); - this.props.onConfirmUpdate(this.state.columnTypes); - }, - iconProps: { - iconName: "Accept" - } - }) - })); - } - } - return new __ColumnTypeChanger(_props); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "outerBounds", ()=>outerBounds); +parcelHelpers.export(exports, "increment", ()=>increment); +function outerBounds(b1, b2) { + if (!b1 && !b2) return; + if (!b1) return b2; + if (!b2) return b1; + const minProps = [ + 'minBoundsX', + 'minBoundsY', + 'minBoundsZ' + ]; + const maxProps = [ + 'maxBoundsX', + 'maxBoundsY', + 'maxBoundsZ' + ]; + const result = {}; + minProps.forEach((p)=>result[p] = notNull(Math.min, b1[p], b2[p])); + maxProps.forEach((p)=>result[p] = notNull(Math.max, b1[p], b2[p])); + return result; +} +function notNull(fn, v1, v2) { + if (v1 == null && v2 == null) return null; + if (v1 == null) return v2; + if (v2 == null) return v1; + return fn(v1, v2); +} +function increment(b, minBoundsX, minBoundsY, minBoundsZ, maxBoundsX, maxBoundsY, maxBoundsZ) { + return outerBounds(b, { + minBoundsX, + minBoundsY, + minBoundsZ, + maxBoundsX, + maxBoundsY, + maxBoundsZ + }); } -const ColumnTypeChanger = _ColumnTypeChanger; -},{"../base":"9M4eu","./dialog":"ep4zG","@msrvida/sanddance-react":"73dPQ","../language":"kzoCJ","./iconButton":"6gzbB","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"789YP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DataExportPicker", ()=>DataExportPicker); -parcelHelpers.export(exports, "removeExtensions", ()=>removeExtensions); -parcelHelpers.export(exports, "getEmbedHTML", ()=>getEmbedHTML); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9hPmh":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _dataExporterHtml = require("./dataExporterHtml"); -var _dialog = require("./dialog"); -var _base = require("../base"); -var _exportDelimited = require("../exportDelimited"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -const exportTypes = [ - [ - "json", - (0, _language.strings).labelExportJSON - ], - [ - "csv", - (0, _language.strings).labelExportCSV - ], - [ - "tsv", - (0, _language.strings).labelExportTSV - ], - [ - "html", - (0, _language.strings).labelExportHTML - ], -]; -function _DataExportPicker(_props) { - class __DataExportPicker extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = this.getInitialState(this.props); - } - getInitialState(props) { - const initialState = { - initializer: props.initializer, - dialogHidden: true, - exportType: exportTypes[0][0], - fileName: props.initializer.fileName, - fileNameError: "", - working: false - }; - return initialState; - } - componentDidUpdate() { - if (!(0, _sanddanceReact.util).deepCompare(this.props.initializer, this.state.initializer)) this.setState(this.getInitialState(this.props)); - } - // Converts to dataExport type and calls dataExportHandler to deal with data - createExport(exportType, displayName) { - const final = (data)=>{ - this.props.dataExportHandler(data, exportType, displayName); - this.close(); - }; - const json = JSON.stringify(this.props.data, columnReplacer); - switch(exportType){ - case "json": - final(json); - break; - case "csv": - final((0, _exportDelimited.convertToDelimited)(JSON.parse(json), ",")); - break; - case "tsv": - final((0, _exportDelimited.convertToDelimited)(JSON.parse(json), " ")); - break; - case "html": - { - const csv = (0, _exportDelimited.convertToDelimited)(JSON.parse(json), ","); - const html = (0, _dataExporterHtml.embedHtml)(`${(0, _language.strings).appName} - ${escape(displayName)}`, embedScript(csv, displayName)); - final(html); - } +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "createCubeLayer", ()=>createCubeLayer); +var _morphcharts = require("morphcharts"); +var _bounds = require("./bounds"); +var _color = require("./color"); +const key = 'cube'; +const createCubeLayer = (props)=>{ + const { ref, stage } = props; + const { core } = ref; + const scatter = new (0, _morphcharts.Layouts).Scatter(core); + const { ids, colors, positionsX, positionsY, positionsZ, sizesX, sizesY, sizesZ, bounds, maxColor, palette } = convert(stage); + if (!ids.length) return; + const { renderer } = core; + let cubeTransitionBuffer = renderer.transitionBuffers.find((t)=>t.key === key); + if (!cubeTransitionBuffer) { + cubeTransitionBuffer = renderer.createTransitionBuffer(ids); + cubeTransitionBuffer.key = key; + renderer.transitionBuffers.push(cubeTransitionBuffer); + } else cubeTransitionBuffer.swap(); + scatter.layout(cubeTransitionBuffer.currentBuffer, ids, { + positionsX, + positionsY, + positionsZ + }); + const layer = { + positionsX, + positionsY, + positionsZ, + update: (newBounds, selected, stagger)=>{ + const { colors, maxColor, minColor, palette } = layer.unitColorMap; + // reference off of core.renderer to get the actual buffer + const currCubeTransitionBuffer = core.renderer.transitionBuffers.find((t)=>t.key === key); + currCubeTransitionBuffer.currentBuffer.unitType = (0, _morphcharts.UnitType).block; + currCubeTransitionBuffer.currentPalette.colors = palette; + let options = Object.assign({ + selected, + colors, + minColor, + maxColor, + sizesX, + sizesY, + sizesZ + }, newBounds); + if (stagger === null || stagger === void 0 ? void 0 : stagger.staggerOrders) { + const { maxStaggerOrder, minStaggerOrder, staggerOrders } = stagger; + options = Object.assign(Object.assign({}, options), { + maxStaggerOrder, + minStaggerOrder, + staggerOrders + }); } + scatter.update(currCubeTransitionBuffer.currentBuffer, ids, options); + }, + bounds, + unitColorMap: { + colors, + ids, + minColor: 0, + maxColor, + palette } - close() { - this.setState({ - dialogHidden: true, - working: false - }); - } - render() { - const closeDialog = ()=>this.close(); - if (this.state.delayAction) requestAnimationFrame(()=>{ - //allow render to complete - if (this.state.delayAction) { - this.state.delayAction(); - this.setState({ - delayAction: null - }); - } - }); - const disabled = this.state.working || this.state.dialogHidden; - return (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - className: "search-action search-bottom-action", - text: (0, _language.strings).buttonExportCount(this.props.data.length), - onClick: ()=>this.setState({ - dialogHidden: false - }), - disabled: this.props.disabled - }), (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: this.state.dialogHidden, - onDismiss: closeDialog, - dialogContentProps: { - className: `sanddance-dialog ${this.props.theme}`, - type: (0, _base.base).fluentUI.DialogType.normal, - title: (0, _language.strings).labelExport - }, - buttons: [ - (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - key: 0, - disabled: disabled || !!this.state.fileNameError, - onClick: (e)=>this.setState({ - delayAction: ()=>this.createExport(this.state.exportType, this.state.fileName), - working: true - }), - text: (0, _language.strings).buttonExport, - iconProps: { - iconName: "Download" - } - }), - ] - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.TextField, { - label: (0, _language.strings).labelExportFileName, - onChange: (e, displayName)=>{ - const displayNameError = getFileNameError(displayName); - this.setState({ - fileName: displayName, - fileNameError: displayNameError - }); - }, - errorMessage: this.state.fileNameError, - value: this.state.fileName - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.ChoiceGroup, { - className: "sanddance-form-separate", - disabled: disabled, - selectedKey: this.state.exportType, - options: exportTypes.map(([exportType, text])=>{ - return { - key: exportType, - text, - disabled: false - }; - }), - onChange: (ev, option)=>this.setState({ - exportType: option.key - }), - label: (0, _language.strings).labelExportFormat - }))); + }; + return layer; +}; +function convert(stage) { + const { cubeData } = stage; + const { length } = cubeData; + const ids = []; + const colors = new Float64Array(length); + const positionsX = new Float64Array(length); + const positionsY = new Float64Array(length); + const positionsZ = new Float64Array(length); + const sizesX = new Float64Array(length); + const sizesY = new Float64Array(length); + const sizesZ = new Float64Array(length); + let bounds; + const colorMap = new (0, _color.ColorMap)(); + cubeData.forEach((cube, i)=>{ + ids.push(i); + if (cube.isEmpty) { + positionsX[i] = 0; + positionsY[i] = 0; + positionsZ[i] = 0; + sizesX[i] = 0; + sizesY[i] = 0; + sizesZ[i] = 0; + colors[i] = 0; + } else { + //ids.push(cube.ordinal); + positionsX[i] = cube.position[0] + cube.size[0] * 0.5; + positionsY[i] = cube.position[1] + cube.size[1] * 0.5; + positionsZ[i] = cube.position[2] + cube.size[2] * 0.5; + sizesX[i] = cube.size[0]; + sizesY[i] = cube.size[1]; + sizesZ[i] = cube.size[2]; + bounds = (0, _bounds.increment)(bounds, cube.position[0], cube.position[1], cube.position[2], cube.position[0] + cube.size[0], cube.position[1] + cube.size[1], cube.position[2] + cube.size[2]); + colors[i] = colorMap.registerColor(cube.color); } - } - return new __DataExportPicker(_props); -} -const DataExportPicker = _DataExportPicker; -const illegalChars = '\\/:*?"<>|'; -function getFileNameError(displayName) { - if (!displayName) return (0, _language.strings).errorExportFilenameEmpty; - for(let i = 0; i < illegalChars.length; i++){ - if (displayName.indexOf(illegalChars[i]) >= 0) return (0, _language.strings).errorExportFilenameCharacters(illegalChars); - } -} -function removeExtensions(fileName) { - exportTypes.forEach(([exportType])=>{ - const re = new RegExp(`\\.${exportType}`, "ig"); - fileName = fileName.replace(re, ""); }); - return fileName; -} -function columnReplacer(name, value) { - if ((0, _sanddanceReact.SandDance).util.isInternalFieldName(name, true)) return undefined; - return value === null ? "" : value; -} -function embedScript(csv, displayName, snapshots) { - const dataFile = { - type: "csv", - displayName, - snapshots + const { palette, maxColor } = colorMap.getPalette(); + return { + ids: new Uint32Array(ids), + colors, + positionsX, + positionsY, + positionsZ, + sizesX, + sizesY, + sizesZ, + bounds, + maxColor, + palette }; - return `<pre id='csv-data' style='display:none'>${csv}</pre> - <script>SandDanceEmbed.load(Object.assign({rawText: document.getElementById('csv-data').innerText}, ${JSON.stringify(dataFile)}))</script>`; -} -function getEmbedHTML(data, displayName, snapshots) { - const json = JSON.stringify(data, columnReplacer); - const csv = (0, _exportDelimited.convertToDelimited)(JSON.parse(json), ","); - const html = (0, _dataExporterHtml.embedHtml)(`${(0, _language.strings).appName} - ${escape(displayName)}`, embedScript(csv, displayName, snapshots)); - return html; } -},{"./dataExporterHtml":"flKn4","./dialog":"ep4zG","../base":"9M4eu","../exportDelimited":"dWwYn","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"flKn4":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "embedHtml", ()=>embedHtml); -const embedHtml = (title, embed)=>`<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>${title} - - - - - - - - - - - ${embed} - -`; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dWwYn":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"morphcharts":"9s7CR","./bounds":"g9F83","./color":"7T6SC","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7T6SC":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "convertToDelimited", ()=>convertToDelimited); -function convertToDelimited(data, delimiter) { - const fields = Object.keys(data[0]); - const file = data.map((row)=>{ - return fields.map((fieldName)=>{ - const value = row[fieldName]; - if (typeof value === "number") return value; - if (typeof value === "string") { - if (value.indexOf(delimiter) >= 0) return `"${value.replace(/"/g, '""')}"`; - else return value; - } - return ""; - }).join(delimiter); - }); - file.unshift(fields.join(delimiter)); - return file.join("\n"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ColorMap", ()=>ColorMap); +parcelHelpers.export(exports, "colorConfig", ()=>colorConfig); +var _color = require("../color"); +class ColorMap { + constructor(quant = 5){ + this.quant = quant; + this.colorMap = {}; + this.colorArray = []; + } + getColorKey(rgbaColor) { + const color = rgbaColor.slice(0, 3).map((e)=>Math.floor(e / this.quant) * this.quant); + color[3] = rgbaColor[3]; //retain alpha + return JSON.stringify(color); + } + registerColor(rgbaColor) { + const colorKey = this.getColorKey(rgbaColor); + if (!this.colorMap[colorKey]) { + this.colorMap[colorKey] = { + index: this.colorArray.length, + rgbaColor + }; + this.colorArray.push(rgbaColor); + } + return this.colorMap[colorKey].index; + } + getPalette() { + return { + palette: new Uint8Array(this.colorArray.flat()), + maxColor: this.colorArray.length - 1 + }; + } +} +function convert(newColor) { + const c = (0, _color.colorFromString)(newColor).slice(0, 3); + return c.map((v)=>v / 255); +} +function colorConfig(ref, colors) { + if (!colors) return; + const { config } = ref.core; + config.activeColor = convert(colors.activeItemColor); + config.backgroundColor = new Float32Array(convert(colors.backgroundColor)); + config.textColor = convert(colors.textColor); + config.textBorderColor = convert(colors.textBorderColor); + config.axesTextColor = convert(colors.axesTextLabelColor); + config.axesGridBackgroundColor = convert(colors.axesGridBackgroundColor); + config.axesGridHighlightColor = convert(colors.axesGridHighlightColor); + config.axesGridMinorColor = convert(colors.axesGridMinorColor); + config.axesGridMajorColor = convert(colors.axesGridMajorColor); + config.axesGridZeroColor = convert(colors.axesGridZeroColor); + //TODO fix this - hack to reset the background color + ref.core.renderer['_theme'] = null; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9MRcr":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "chartLabelMap", ()=>chartLabelMap); -parcelHelpers.export(exports, "chartLabel", ()=>chartLabel); -parcelHelpers.export(exports, "Chart", ()=>Chart); +},{"../color":"cgTtg","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cM6w1":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); -var _columnMap = require("../controls/columnMap"); -var _dialog = require("../controls/dialog"); -var _dropdown = require("../controls/dropdown"); -var _group = require("../controls/group"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _signal = require("../controls/signal"); -var _language = require("../language"); -var _toggleColumns = require("../controls/toggleColumns"); -var _columns = require("../columns"); -var _backgroundImageEditor = require("./backgroundImageEditor"); -const singleFacetLayouts = [ - { - facetStyle: "wrap", - text: (0, _language.strings).labelFacetLayoutWrap - } -]; -const chartLabelMap = [ - { - key: "grid", - text: (0, _language.strings).chartTypeGrid - }, - { - key: "scatterplot", - text: (0, _language.strings).chartTypeScatterPlot - }, - { - key: "density", - text: (0, _language.strings).chartTypeDensity - }, - { - key: "barchartV", - text: (0, _language.strings).chartTypeBarChartV - }, - { - key: "barchartH", - text: (0, _language.strings).chartTypeBarChartH - }, - { - key: "treemap", - text: (0, _language.strings).chartTypeTreeMap - }, - { - key: "strips", - text: (0, _language.strings).chartTypeStrips - }, - { - key: "stacks", - text: (0, _language.strings).chartTypeStacks - }, -]; -function chartLabel(key) { - for(let i = 0; i < chartLabelMap.length; i++){ - if (key === chartLabelMap[i].key) return chartLabelMap[i].text; - } -} -function _Chart(_props) { - class __Chart extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = { - showTooltipDialog: false - }; - this.choiceRef = (0, _base.base).react.createRef(); - props.explorer.dialogFocusHandler.focus = ()=>{ - var _a; - return (_a = this.choiceRef.current) === null || _a === void 0 ? void 0 : _a.focus(); - }; - } - render() { - const { props } = this; - const { explorer , specCapabilities } = props; - const signals = explorer.viewer && explorer.viewer.vegaSpec && specCapabilities && specCapabilities.signals && explorer.viewer.vegaSpec.signals.filter((s)=>specCapabilities.signals.indexOf(s.name) >= 0); - const hasOptions = !!signals || (specCapabilities === null || specCapabilities === void 0 ? void 0 : specCapabilities.backgroundImage); - return (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelChart - }, (0, _base.base).react.createElement("div", { - className: "calculator" - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.ChoiceGroup, { - componentRef: this.choiceRef, - selectedKey: props.chart, - className: "sanddance-chart-type", - options: chartLabelMap.map((o)=>{ - return Object.assign(Object.assign({}, o), { - disabled: props.disabled || o.key === "treemap" && props.quantitativeColumns.length === 0 - }); - }), - onChange: (e, o)=>props.explorer.changeChartType(o.key) - }))), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelColumnMapping - }, (0, _base.base).react.createElement("div", null, specCapabilities && specCapabilities.roles.map((specRole, i)=>{ - const specColumnInRole = props.insightColumns[specRole.role]; - const selectedColumnName = specColumnInRole; - let disabledColumnName; - let prefix; - let suffix; - let hideDropdown = false; - let { totalStyle } = props; - if (!totalStyle) totalStyle = "count-square"; - let { facetStyle } = props; - if (!facetStyle) facetStyle = "wrap"; - switch(specRole.role){ - case "facet": - suffix = (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - disabled: !props.insightColumns.facet, - collapseLabel: props.collapseLabels, - label: (0, _language.strings).labelFacetLayout, - calloutProps: { - style: { - minWidth: "18em" - } - }, - options: [ - { - key: "header1", - text: `${(0, _language.strings).labelFacetLayout}:`, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header - }, - ...singleFacetLayouts.map((f)=>{ - const o = { - key: f.facetStyle, - text: f.text, - data: f, - selected: facetStyle === f.facetStyle - }; - return o; - }), - { - key: "divider", - text: "-", - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Divider - }, - { - key: "header2", - text: `${(0, _language.strings).labelColumnFacetV}:`, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header - }, - ...(0, _columnMap.getColumnMapOptions)(Object.assign(Object.assign({}, props), { - specRole, - selectedColumnName: props.insightColumns.facetV - })).map((o)=>{ - if (o.itemType !== (0, _base.base).fluentUI.DropdownMenuItemType.Header) { - const facetData = { - facetStyle: "cross", - column: o.data - }; - o.data = facetData; - o.text = `${(0, _language.strings).labelFacetLayoutCross} ${o.text}`; - } - return o; - }), - ], - onChange: (e, o)=>{ - const facetData = o.data; - props.changeColumnMapping("facet", "facet", null, { - facetStyle: facetData.facetStyle - }); - if (facetData.facetStyle === "cross") props.changeColumnMapping("facetV", (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(facetData.column)); - } - }); - break; - case "facetV": - hideDropdown = true; - break; - case "size": - { - const options = [ - { - key: "count-square", - text: (0, _language.strings).labelTotalByCountSquare, - data: "count-square", - selected: !totalStyle || totalStyle === "count-square" - }, - { - key: "count-strip", - text: (0, _language.strings).labelTotalByCountStrip, - data: "count-strip", - selected: totalStyle === "count-strip" - }, - { - key: "sum-strip", - text: (0, _language.strings).labelTotalBySumStrip, - data: "sum-strip", - selected: totalStyle === "sum-strip" - }, - { - key: "sum-treemap", - text: (0, _language.strings).labelTotalBySumTreemap, - data: "sum-treemap", - selected: totalStyle === "sum-treemap", - disabled: props.quantitativeColumns.length === 0 - }, - ]; - if (specCapabilities.percentage) options.push({ - key: "sum-strip-percent", - text: (0, _language.strings).labelTotalBySumStripPercent, - data: "sum-strip-percent", - selected: totalStyle === "sum-strip-percent", - disabled: props.quantitativeColumns.length === 0 - }); - prefix = !specCapabilities.countsAndSums ? null : (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: props.collapseLabels, - label: (0, _language.strings).labelTotal, - calloutProps: { - style: { - minWidth: "18em" - } - }, - options: options, - onChange: (e, o)=>{ - const totalStyle = o.data; - let defaultColumn; - if (totalStyle.indexOf("sum-") === 0) { - if (totalStyle === "sum-treemap") defaultColumn = (0, _columns.getTreemapColumn)(props.allColumns); - defaultColumn = defaultColumn || props.quantitativeColumns[0]; - } - props.changeColumnMapping("size", "size", defaultColumn, { - totalStyle - }); - } - }); - break; - } - } - const disabled = props.disabled || specRole.disabled || specRole.role === "size" && !(!specCapabilities.countsAndSums || totalStyle.indexOf("sum-") === 0) || specRole.role === "sort" && specCapabilities.countsAndSums && totalStyle === "sum-treemap"; - return (0, _base.base).react.createElement((0, _columnMap.ColumnMap), Object.assign({}, props, { - prefix: prefix, - suffix: suffix, - collapseLabel: props.collapseLabels, - disabled: disabled, - disabledColumnName: disabledColumnName, - selectedColumnName: selectedColumnName, - specRole: specRole, - key: i, - onChangeSignal: (name, value)=>props.onChangeSignal(specRole.role, selectedColumnName, name, value), - hideDropdown: hideDropdown - })); - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - className: "sanddance-chart-button", - text: (0, _language.strings).buttonTooltipMapping, - onClick: ()=>this.setState({ - showTooltipDialog: true - }) - }))), hasOptions && (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelChartTypeOptions - }, signals && signals.map((signal, i)=>(0, _base.base).react.createElement((0, _signal.Signal), { - key: i, - signal: signal, - explorer: explorer, - initialValue: (0, _signal.getInitialSignalValue)(explorer, signal), - disabled: props.disabled || this.disableSignal(signal), - collapseLabel: props.collapseLabels, - newViewStateTarget: false - })), (specCapabilities === null || specCapabilities === void 0 ? void 0 : specCapabilities.backgroundImage) && (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - className: "sanddance-chart-button", - text: (0, _language.strings).buttonBackgroundImage, - onClick: ()=>{ - let insightColumns; - switch(props.chart){ - case "scatterplot": - case "stacks": - insightColumns = props.insightColumns; - break; - } - if (!insightColumns) insightColumns = props.explorer.changeChartType("scatterplot"); - this.backgroundImageEditor.show(insightColumns); - } - })), (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: !this.state.showTooltipDialog, - onDismiss: ()=>this.setState({ - showTooltipDialog: false - }), - title: (0, _language.strings).labelTooltipMapping - }, (0, _base.base).react.createElement((0, _toggleColumns.ToggleColumns), { - allColumns: props.allColumns, - exclusions: props.tooltipExclusions, - toggleExclusion: props.toggleTooltipExclusion - })), (0, _base.base).react.createElement((0, _backgroundImageEditor.BackgroundImageEditor), Object.assign({}, props, { - ref: (e)=>this.backgroundImageEditor = e - }))); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "createLineLayer", ()=>createLineLayer); +var _morphcharts = require("morphcharts"); +var _bounds = require("./bounds"); +var _color = require("./color"); +const key = 'line'; +const createLineLayer = (props)=>{ + const { height, ref, stage, width } = props; + const { core } = ref; + const lines = new (0, _morphcharts.Layouts).Line(core); + const { ids, fromIds, toIds, lineColors, lineSizes, bounds, positionsX, positionsY, positionsZ, lineMaxColor, palette } = convert(stage, height, width); + if (!ids.length) return; + const { renderer } = core; + let lineTransitionBuffer = renderer.transitionBuffers.find((t)=>t.key === key); + if (!lineTransitionBuffer) { + lineTransitionBuffer = renderer.createTransitionBuffer(ids); + lineTransitionBuffer.key = key; + renderer.transitionBuffers.push(lineTransitionBuffer); + } else lineTransitionBuffer.swap(); + lines.layout(lineTransitionBuffer.currentBuffer, ids, fromIds, toIds, { + positionsX, + positionsY, + positionsZ, + lineSizes, + sizeScaling: 1 + }); + let options = { + lineColors, + lineMinColor: 0, + lineMaxColor + }; + // Unit type + lineTransitionBuffer.currentBuffer.unitType = (0, _morphcharts.UnitType).cylinder; + lineTransitionBuffer.currentPalette.colors = palette; + return { + update: (newBounds)=>{ + options = Object.assign(Object.assign({}, options), newBounds); + // reference off of core.renderer to get the actual buffer + const currLineTransitionBuffer = core.renderer.transitionBuffers.find((t)=>t.key === key); + lines.update(currLineTransitionBuffer.currentBuffer, ids, fromIds, toIds, options); + }, + bounds, + unitColorMap: { + ids, + colors: lineColors, + minColor: 0, + maxColor: lineMaxColor, + palette } - disableSignal(signal) { - if (this.props.view === "2d" && signal.name === (0, _sanddanceReact.SandDance).constants.SignalNames.ZGrounded) return true; - return false; + }; +}; +function convert(stage, height, width) { + const { pathData } = stage; + const positions = []; + const lines = []; + const colorMap = new (0, _color.ColorMap)(); + pathData.forEach((path)=>{ + const color = colorMap.registerColor(path.strokeColor); + let from = positions.length; + positions.push(path.positions[0]); + for(let i = 1; i < path.positions.length; i++){ + const to = positions.length; + positions.push(path.positions[i]); + lines.push({ + id: lines.length, + from, + to, + color, + size: path.strokeWidth + }); + from = to; } - } - return new __Chart(_props); -} -const Chart = _Chart; - -},{"../base":"9M4eu","../controls/columnMap":"5sGIS","../controls/dialog":"ep4zG","../controls/dropdown":"2Udzo","../controls/group":"hggjF","@msrvida/sanddance-react":"73dPQ","../controls/signal":"847y5","../language":"kzoCJ","../controls/toggleColumns":"jQGIs","../columns":"aWo5j","./backgroundImageEditor":"02TgK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hggjF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Group", ()=>Group); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function Group(props) { - return (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("sanddance-group", props.className) - }, (0, _base.base).react.createElement("div", { - className: "group-head" - }, (0, _base.base).react.createElement("label", null, props.label), props.labelCount && (0, _base.base).react.createElement("span", { - className: "count" - }, "(", props.labelCount, ")")), props.children && (0, _base.base).react.createElement("div", { - className: "group-body" - }, props.children)); + }); + const ids = new Uint32Array(lines.length); + const fromIds = new Uint32Array(lines.length); + const toIds = new Uint32Array(lines.length); + const lineColors = new Float64Array(lines.length); + const lineSizes = new Float64Array(lines.length); + lines.forEach((line, i)=>{ + ids[i] = i; + fromIds[i] = line.from; + toIds[i] = line.to; + lineColors[i] = line.color; + lineSizes[i] = line.size; + }); + const positionsX = new Float64Array(positions.length); + const positionsY = new Float64Array(positions.length); + const positionsZ = new Float64Array(positions.length); + let bounds; + positions.forEach((p, i)=>{ + positionsX[i] = p[0]; + positionsY[i] = p[1] + height; + positionsZ[i] = p[2]; + bounds = (0, _bounds.increment)(bounds, positionsX[i], positionsY[i], positionsZ[i], positionsX[i], positionsY[i], positionsZ[i]); + }); + const { palette, maxColor: lineMaxColor } = colorMap.getPalette(); + return { + ids, + fromIds, + toIds, + lineColors, + lineSizes, + bounds, + positionsX, + positionsY, + positionsZ, + lineMaxColor, + palette + }; } -},{"../base":"9M4eu","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jQGIs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ToggleColumns", ()=>ToggleColumns); +},{"morphcharts":"9s7CR","./bounds":"g9F83","./color":"7T6SC","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6hAIv":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); -function ToggleColumns(props) { - return (0, _base.base).react.createElement("div", null, props.allColumns.map((c, i)=>(0, _base.base).react.createElement("div", { - key: c.name - }, (0, _base.base).react.createElement("label", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: props.exclusions.indexOf(c.name) < 0, - inlineLabel: true, - label: c.name, - onChange: ()=>props.toggleExclusion(c.name) - }))))); -} - -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aWo5j":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ensureColumnsExist", ()=>ensureColumnsExist); -parcelHelpers.export(exports, "ensureColumnsPopulated", ()=>ensureColumnsPopulated); -parcelHelpers.export(exports, "getTreemapColumn", ()=>getTreemapColumn); -parcelHelpers.export(exports, "colorMapping", ()=>colorMapping); -parcelHelpers.export(exports, "getBackgroundImageColumnBounds", ()=>getBackgroundImageColumnBounds); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _chartRecommender = require("@msrvida/chart-recommender"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _language = require("./language"); -function ensureColumnsExist(insightColumns, actualColumns, transform) { - //ensure columns exist - for(const role in insightColumns){ - const columnName = insightColumns[role]; - const column = actualColumns.filter((c)=>c.name === columnName)[0]; - const transformColumn = transform ? transform.filter((t)=>{ - switch(t.type){ - case "formula": - return t.as === columnName; - } - })[0] : null; - if (!(column || transformColumn)) delete insightColumns[role]; +parcelHelpers.export(exports, "createTextLayer", ()=>createTextLayer); +var _morphcharts = require("morphcharts"); +var _bounds = require("./bounds"); +var _color = require("./color"); +const createTextLayer = (props)=>{ + const { ref, stage } = props; + const { core } = ref; + const { positionsX, positionsY, positionsZ, sizes, bounds, maxGlyphs, text } = convert(stage); + if (text.length === 0) { + core.renderer.labelSets = []; + return; } -} -function ensureColumnsPopulated(chart, totalStyle, insightColumns, actualColumns) { - //ensure columns are populated - const nonInternal = actualColumns.filter((c)=>!(0, _sanddanceReact.SandDance).util.isInternalFieldName(c.name)); - const firstColumn = nonInternal[0]; - const firstColumnName = firstColumn && firstColumn.name; - const firstQuantitative = nonInternal.filter((c)=>c.quantitative)[0]; - const firstQuantitativeColumnName = firstQuantitative && firstQuantitative.name; - const ensureColumn = (role, quantitative, treemap)=>{ - if (!insightColumns[role]) { - if (treemap) insightColumns[role] = getTreemapColumn(actualColumns).name; - else insightColumns[role] = quantitative ? firstQuantitativeColumnName : firstColumnName; - } + const options = { + text, + maxGlyphs, + scales: sizes }; - function checkRequiresSize() { - switch(totalStyle){ - case "sum-strip": - case "sum-strip-percent": - ensureColumn("size", true); - break; - case "sum-treemap": - ensureColumn("size", true, true); - break; - } - } - switch(chart){ - case "barchart": - case "barchartV": - ensureColumn("x"); - checkRequiresSize(); - break; - case "barchartH": - ensureColumn("y"); - checkRequiresSize(); - break; - case "density": - ensureColumn("x"); - ensureColumn("y"); - checkRequiresSize(); - break; - case "scatterplot": - case "stacks": - ensureColumn("x"); - ensureColumn("y"); - break; - case "treemap": - if (!insightColumns.size) insightColumns.size = getTreemapColumn(actualColumns).name; - if (!insightColumns.size) //error - no numeric column - return [ - (0, _language.strings).errorColumnMustBeNumeric - ]; - break; - } -} -function getTreemapColumn(columns) { - let column = (0, _chartRecommender.preferredColumnForTreemapSize)(columns, true); - if (!column) column = (0, _chartRecommender.preferredColumnForTreemapSize)(columns, false); - return column; -} -function colorMapping(insight, columns) { - if (columns && insight.columns && insight.columns.color) return columns.filter((c)=>c.name === insight.columns.color)[0]; -} -function getBackgroundImageColumnBounds(columns) { - const bounds = []; - const getBound = (dimension, dataExtent, column)=>{ - const { stats } = column; - const numericValue = dataExtent === "max" ? stats.max : stats.min; - return { - columnName: column.name, - dimension, - valid: true, - dataExtent, - numericValue, - stringValue: numericValue.toString() - }; + const labelSet = new (0, _morphcharts.Components).LabelSet(core, options); + labelSet.positionsX = positionsX; + labelSet.positionsY = positionsY; + labelSet.positionsZ = positionsZ; + labelSet.horizontalAlignment = (0, _morphcharts.HorizontalAlignment).center; + labelSet.verticalAlignment = (0, _morphcharts.VerticalAlignment).center; + const layer = { + update: (bounds)=>{ + const { maxBoundsX, maxBoundsY, maxBoundsZ, minBoundsX, minBoundsY, minBoundsZ } = bounds; + labelSet.minBoundsX = minBoundsX; + labelSet.minBoundsY = minBoundsY; + labelSet.minBoundsZ = minBoundsZ; + labelSet.maxBoundsX = maxBoundsX; + labelSet.maxBoundsY = maxBoundsY; + labelSet.maxBoundsZ = maxBoundsZ; + }, + bounds }; - const dataExtents = [ - "max", - "min" - ]; - const dimensions = [ - "x", - "y" + const labelSetVisual = core.renderer.createLabelSetVisual(labelSet); + core.renderer.labelSets = [ + labelSetVisual ]; - columns.forEach((c)=>{ - if (c.quantitative) dimensions.forEach((dimension)=>dataExtents.forEach((dataExtent)=>bounds.push(getBound(dimension, dataExtent, c)))); + return layer; +}; +function convert(stage) { + const { textData } = stage; + const { length } = textData; + const ids = []; + const text = []; + const colors = new Float64Array(length); + const positionsX = new Float64Array(length); + const positionsY = new Float64Array(length); + const positionsZ = new Float64Array(length); + const sizes = new Float64Array(length); + let bounds; + let maxGlyphs = 0; + const colorMap = new (0, _color.ColorMap)(); + textData.forEach((t, i)=>{ + ids.push(i); + text.push(t.text); + maxGlyphs += t.text.length; + positionsX[i] = t.position[0]; + positionsY[i] = t.position[1]; + positionsZ[i] = t.position[2]; + sizes[i] = 1.5 * t.size; //scale similar to axes + bounds = (0, _bounds.increment)(bounds, t.position[0], t.position[1], t.position[2], t.position[0], t.position[1], t.position[2]); + colors[i] = colorMap.registerColor(t.color); }); - return bounds; + const { palette, maxColor } = colorMap.getPalette(); + return { + ids: new Uint32Array(ids), + colors, + positionsX, + positionsY, + positionsZ, + sizes, + bounds, + maxColor, + maxGlyphs, + palette, + text + }; } -},{"@msrvida/chart-recommender":"lJbBT","@msrvida/sanddance-react":"73dPQ","./language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lJbBT":[function(require,module,exports) { -"use strict"; +},{"morphcharts":"9s7CR","./bounds":"g9F83","./color":"7T6SC","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"k12os":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { - enumerable: true, - get: function() { - return m[k]; - } +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getImageData", ()=>getImageData); +parcelHelpers.export(exports, "createImageQuad", ()=>createImageQuad); +var _morphcharts = require("morphcharts"); +function getImageData(url) { + return new Promise((resolve, reject)=>{ + const imageElement = document.createElement('img'); + imageElement.onload = ()=>{ + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + const { height, width } = imageElement; + canvas.width = width; + canvas.height = height; + ctx.drawImage(imageElement, 0, 0); + resolve(ctx.getImageData(0, 0, width, height)); + }; + imageElement.src = url; }); -} : function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}); -var __exportStar = this && this.__exportStar || function(m, exports1) { - for(var p in m)if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports1, p)) __createBinding(exports1, m, p); -}; -Object.defineProperty(exports, "__esModule", { - value: true -}); -__exportStar(require("./barChart"), exports); -__exportStar(require("./geo"), exports); -__exportStar(require("./scatterPlot"), exports); -__exportStar(require("./treemap"), exports); -__exportStar(require("./recommenderSummary"), exports); +} +function createImageQuad(core, imageData, bounds, position, width, height) { + const { maxBoundsX, maxBoundsY, maxBoundsZ, minBoundsX, minBoundsY, minBoundsZ } = bounds; + const imageOptions = { + imageData, + position, + height, + width, + minBoundsX, + maxBoundsX, + minBoundsZ, + maxBoundsZ, + minBoundsY, + maxBoundsY + }; + return new (0, _morphcharts.Components).ImageQuad(core, imageOptions); +} -},{"./barChart":"8KAbz","./geo":"3mt2H","./scatterPlot":"294DH","./treemap":"jcEK7","./recommenderSummary":"gabh4"}],"8KAbz":[function(require,module,exports) { -"use strict"; +},{"morphcharts":"9s7CR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"baEhk":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.BarChartRecommender = exports.BarChartRecommenderSummary = void 0; -var recommender_1 = require("./recommender"); -var maxDistinctVal = 20; -var minDistinctVal = 2; -var BarChartRecommenderSummary = /** @class */ function() { - function BarChartRecommenderSummary(columns, data) { - var score = -1; - for(var i = 0; i < columns.length; i++){ - var recommendation = new BarChartRecommender(columns[i], data).recommend(); - if (recommendation.score > score) { - this.best = recommendation; - score = recommendation.score; - } - if (score === 1) break; +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "cameraDefaults", ()=>cameraDefaults); +var _glMatrix = require("gl-matrix"); +var _morphcharts = require("morphcharts"); +function createCameraDefaults() { + const qModelRotation2d = (0, _glMatrix.quat).create(); + const qModelRotation3d = (0, _morphcharts.Constants).QUAT_ROTATEX_MINUS_90; + const qCameraRotation2d = (0, _glMatrix.quat).create(); + const qCameraRotation3d = (0, _glMatrix.quat).create(); + const qAngle = (0, _glMatrix.quat).create(); + const vCameraPosition = (0, _glMatrix.vec3).create(); + // Altitude (pitch around local right axis) + (0, _glMatrix.quat).setAxisAngle(qCameraRotation3d, (0, _morphcharts.Constants).VECTOR3_UNITX, (0, _morphcharts.Helpers).AngleHelper.degreesToRadians(30)); + // Azimuth (yaw around global up axis) + (0, _glMatrix.quat).setAxisAngle(qAngle, (0, _morphcharts.Constants).VECTOR3_UNITY, (0, _morphcharts.Helpers).AngleHelper.degreesToRadians(-25)); + (0, _glMatrix.quat).multiply(qCameraRotation3d, qCameraRotation3d, qAngle); + return { + qModelRotation2d, + qModelRotation3d, + qCameraRotation2d, + qCameraRotation3d, + vCameraPosition + }; +} +const cameraDefaults = createCameraDefaults(); + +},{"gl-matrix":"5x28d","morphcharts":"9s7CR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cPRXr":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "applyCameraCallbacks", ()=>applyCameraCallbacks); +parcelHelpers.export(exports, "setTransitionTimeAxesVisibility", ()=>setTransitionTimeAxesVisibility); +var _glMatrix = require("gl-matrix"); +var _morphcharts = require("morphcharts"); +var _defaults = require("./defaults"); +const { qCameraRotation2d, qCameraRotation3d, qModelRotation2d, qModelRotation3d, vCameraPosition } = (0, _defaults.cameraDefaults); +function applyCameraCallbacks(ref, lastPresenterConfig, lastView, transistion2dOnly) { + const { cameraTransitioner, core, modelTransitioner, positionTransitioner } = ref; + ref.reset = ()=>{ + core.reset(true); + if (lastView === '3d') { + modelTransitioner.qRotation.to = qModelRotation3d; + cameraTransitioner.qRotation.to = qCameraRotation3d; + cameraTransitioner.vPosition.to = vCameraPosition; + } else { + modelTransitioner.qRotation.to = qModelRotation2d; + cameraTransitioner.qRotation.to = qCameraRotation2d; + cameraTransitioner.vPosition.to = vCameraPosition; } - for(var k = 0; k < columns.length; k++){ - var column = columns[k]; - if (column.name === this.best.columns.x || column.stats.isSequential) continue; - if (column.quantitative || column.stats.distinctValueCount < recommender_1.maxCategoricalColors && column.stats.distinctValueCount > 1) { - this.best.columns.color = this.best.columns.sort = column.name; - this.best.scheme = (0, recommender_1.defaultColorScheme)(column); - if (column.quantitative) this.best.colorBin = "quantile"; - break; + (0, _glMatrix.quat).slerp(modelTransitioner.qRotation.current, modelTransitioner.qRotation.to, modelTransitioner.qRotation.to, 0); + core.setModelRotation(modelTransitioner.qRotation.current, true); + core.camera.setOrbit(cameraTransitioner.qRotation.to, true); + core.camera.setPosition(cameraTransitioner.vPosition.to, true); + }; + const cam = (t)=>{ + (0, _glMatrix.quat).slerp(cameraTransitioner.qRotation.current, cameraTransitioner.qRotation.from, cameraTransitioner.qRotation.to, t); + (0, _glMatrix.vec3).lerp(cameraTransitioner.vPosition.current, cameraTransitioner.vPosition.from, cameraTransitioner.vPosition.to, t); + core.camera.setOrbit(cameraTransitioner.qRotation.current, false); + core.camera.setPosition(cameraTransitioner.vPosition.current, false); + // disable picking during transitions, as the performance degradation could reduce the framerate + core.inputManager.isPickingEnabled = false; + }; + core.updateCallback = (elapsedTime)=>{ + const { transitionDurations } = lastPresenterConfig; + if (positionTransitioner.isTransitioning) { + const t = positionTransitioner.elapse(elapsedTime, transitionDurations.position + transitionDurations.stagger); + core.renderer.transitionTime = t; + setTransitionTimeAxesVisibility(transistion2dOnly, core); + } else core.inputManager.isPickingEnabled = true; + if (modelTransitioner.isTransitioning) { + const tm = modelTransitioner.elapse(elapsedTime, transitionDurations.view, true); + if (modelTransitioner.shouldTransition) { + (0, _glMatrix.quat).slerp(modelTransitioner.qRotation.current, modelTransitioner.qRotation.from, modelTransitioner.qRotation.to, tm); + core.setModelRotation(modelTransitioner.qRotation.current, false); } + cam(tm); + } + if (cameraTransitioner.isTransitioning) { + const t = cameraTransitioner.elapse(elapsedTime, transitionDurations.view, true); + cam(t); } - } - BarChartRecommenderSummary.prototype.recommend = function() { - return this.best; }; - return BarChartRecommenderSummary; -}(); -exports.BarChartRecommenderSummary = BarChartRecommenderSummary; -var BarChartRecommender = /** @class */ function() { - function BarChartRecommender(column, data) { - this.score = 0; - this.column = column; - //the total score for bar chart is 1 - this.rules = [ - function(column) { - if (column.stats.isSequential) return false; - else if (column.quantitative) return true; - else if (!column.quantitative && column.stats.distinctValueCount <= maxDistinctVal && column.stats.distinctValueCount >= minDistinctVal) return true; - else return false; - }, - ]; - for(var i = 0; i < this.rules.length; i++)if (this.rules[i](column)) this.score++; +} +function setTransitionTimeAxesVisibility(transistion2dOnly, core) { + const t = core.renderer.transitionTime; + if (transistion2dOnly) { + if (t < 0.5) core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).previous; + else core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; + } else { + if (t <= 0.01) core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).previous; + else if (t >= 0.99) core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; + else core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).none; } - BarChartRecommender.prototype.recommend = function() { - var rec = { - chart: "barchart", - columns: { - x: this.column.name - }, - score: this.score, - scheme: undefined, - view: "2d" - }; - return rec; - }; - return BarChartRecommender; -}(); -exports.BarChartRecommender = BarChartRecommender; +} -},{"./recommender":"diVQz"}],"diVQz":[function(require,module,exports) { -"use strict"; +},{"gl-matrix":"5x28d","morphcharts":"9s7CR","./defaults":"baEhk","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dMNNU":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.defaultColorScheme = exports.Recommender = exports.maxCategoricalColors = void 0; -exports.maxCategoricalColors = 20; -var Recommender = /** @class */ function() { - function Recommender(columns, data) {} - return Recommender; -}(); -exports.Recommender = Recommender; -function defaultColorScheme(c) { - if (c.quantitative) return "redyellowgreen"; - else if (c.stats.distinctValueCount === 2) return "dual_redgreen"; - else if (c.stats.distinctValueCount <= 10) return "category10"; - return "category20"; +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "init", ()=>init); +var _morphcharts = require("morphcharts"); +var _renderer = require("./renderer"); +var _canvas = require("./canvas"); +var _transition = require("../transition"); +function init(options, mcRendererOptions) { + const { container } = options; + const core = new (0, _morphcharts.Core)({ + container + }); + (0, _renderer.getRenderer)(mcRendererOptions, core); + (0, _canvas.listenCanvasEvents)(core, options); + core.config.pickSelectDelay = 50; + const cameraTransitioner = new (0, _transition.CameraTransitioner)(); + const modelTransitioner = new (0, _transition.ModelTransitioner)(); + const positionTransitioner = new (0, _transition.Transitioner)(); + positionTransitioner.ended = ()=>{ + core.renderer.axesVisibility = (0, _morphcharts.AxesVisibility).current; + }; + const ref = { + supportedRenders: { + advanced: (0, _renderer.rendererEnabled)(true), + basic: (0, _renderer.rendererEnabled)(false) + }, + reset: null, + cameraTransitioner, + modelTransitioner, + positionTransitioner, + core, + setMorphChartsRendererOptions (mcRendererOptions) { + if ((0, _renderer.shouldChangeRenderer)(ref.lastMorphChartsRendererOptions, mcRendererOptions)) { + (0, _renderer.getRenderer)(mcRendererOptions, core); + (0, _canvas.listenCanvasEvents)(core, options); + } else if (mcRendererOptions.advanced) //same renderer, poke the config + (0, _renderer.setRendererOptions)(core.renderer, mcRendererOptions); + ref.lastMorphChartsRendererOptions = mcRendererOptions; + }, + lastMorphChartsRendererOptions: mcRendererOptions, + layerStagger: {} + }; + return ref; } -exports.defaultColorScheme = defaultColorScheme; -},{}],"3mt2H":[function(require,module,exports) { -"use strict"; +},{"morphcharts":"9s7CR","./renderer":"8SaPq","./canvas":"ckfEx","../transition":"78Jmh","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8SaPq":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.isGeo = exports.isLatitude = exports.isLongitude = void 0; -//TODO: languages other than english -var longitudeNames = [ - "lon", - "long", - "longitude" -]; -var latitudeNames = [ - "lat", - "latitude" -]; -function isSpec(names, limits, column, data) { - var is = false; - var cname = column.name.toLowerCase(); - for(var i = 0; i < names.length; i++)if (names[i] === cname) { - is = true; - break; - } - data; - return is; +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "shouldChangeRenderer", ()=>shouldChangeRenderer); +parcelHelpers.export(exports, "getRenderer", ()=>getRenderer); +parcelHelpers.export(exports, "setRendererOptions", ()=>setRendererOptions); +parcelHelpers.export(exports, "rendererEnabled", ()=>rendererEnabled); +var _morphcharts = require("morphcharts"); +function shouldChangeRenderer(prev, next) { + var _a, _b; + if (!prev || !next) return true; + if (prev.advanced !== next.advanced) return true; + if (!prev.advanced) return ((_a = prev.basicOptions) === null || _a === void 0 ? void 0 : _a.antialias) != ((_b = next.basicOptions) === null || _b === void 0 ? void 0 : _b.antialias); } -function isLongitude(column, data) { - return isSpec(longitudeNames, [ - -180, - 180 - ], column, data); +function getRenderer(mcRendererOptions, core) { + const advanced = mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.advanced; + const r = advanced ? new (0, _morphcharts.Renderers).Advanced.Main() : new (0, _morphcharts.Renderers).Basic.Main(mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.basicOptions); + core.renderer = r; + setRendererOptions(r, mcRendererOptions); + return r; } -exports.isLongitude = isLongitude; -function isLatitude(column, data) { - return isSpec(latitudeNames, [ - -90, - 90 - ], column, data); +function setRendererOptions(renderer, mcRendererOptions) { + const o = mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.advancedOptions; + if ((mcRendererOptions === null || mcRendererOptions === void 0 ? void 0 : mcRendererOptions.advanced) && o) for(const key in o)renderer.config[key] = o[key]; } -exports.isLatitude = isLatitude; -function isGeo(column, data) { - return isLatitude(column, data) || isLongitude(column, data); +function rendererEnabled(advanced) { + const r = advanced ? new (0, _morphcharts.Renderers).Advanced.Main() : new (0, _morphcharts.Renderers).Basic.Main(); + return r.isSupported; } -exports.isGeo = isGeo; -},{}],"294DH":[function(require,module,exports) { -"use strict"; +},{"morphcharts":"9s7CR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ckfEx":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ScatterPlotRecommenderSummary = void 0; -var recommender_1 = require("./recommender"); -var geo_1 = require("./geo"); -var ScatterPlotRecommenderSummary = /** @class */ function() { - function ScatterPlotRecommenderSummary(columns, data) { - var rec = { - chart: "scatterplot", - score: undefined, - columns: {}, - scheme: undefined, - view: "2d" +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "listenCanvasEvents", ()=>listenCanvasEvents); +var _morphcharts = require("morphcharts"); +const rightButton = 2; +function listenCanvasEvents(core, options) { + const { container, pickGridCallback } = options; + const { inputManager } = core; + if (options.onLasso) inputManager.pickLassoCallback = (result)=>{ + options.onLasso(result.ids[0], result.manipulator.event); + }; + inputManager.singleTouchAction = (manipulator)=>{ + if (manipulator.button == rightButton || manipulator.shiftKey || manipulator.ctrlKey) return (0, _morphcharts.SingleTouchAction).rotate; + else if (manipulator.altKey) return (0, _morphcharts.SingleTouchAction).lasso; + else return (0, _morphcharts.SingleTouchAction).translate; + }; + inputManager.pickAxesGridCallback = ({ divisionX, divisionY, divisionZ, manipulator })=>{ + clearClickTimeout(); + const { altKey, button, shiftKey } = manipulator; + const me = { + altKey, + shiftKey, + button }; - columns.forEach(function(column) { - if (!rec.columns.x) { - if (column.name.toLowerCase() === "x") return rec.columns.x = column.name; - else if ((0, geo_1.isLongitude)(column)) return rec.columns.x = column.name; - } - if (!rec.columns.y) { - if (column.name.toLowerCase() === "y") return rec.columns.y = column.name; - else if ((0, geo_1.isLatitude)(column)) return rec.columns.y = column.name; - } - if (!rec.columns.color && !column.stats.isSequential) { - if (column.quantitative || column.stats.distinctValueCount < recommender_1.maxCategoricalColors) { - rec.columns.color = rec.columns.sort = column.name; - rec.scheme = (0, recommender_1.defaultColorScheme)(column); - if (column.quantitative) rec.colorBin = "quantile"; - return; - } - } - }); - if (rec.columns.x && rec.columns.y) this.best = rec; - } - ScatterPlotRecommenderSummary.prototype.recommend = function() { - return this.best; + const e = me; + pickGridCallback([ + divisionX, + divisionY, + divisionZ + ], e); }; - return ScatterPlotRecommenderSummary; -}(); -exports.ScatterPlotRecommenderSummary = ScatterPlotRecommenderSummary; - -},{"./recommender":"diVQz","./geo":"3mt2H"}],"jcEK7":[function(require,module,exports) { -"use strict"; -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.preferredColumnForTreemapSize = void 0; -var geo_1 = require("./geo"); -function preferredColumnForTreemapSize(columns, strict) { - for(var i = 0; i < columns.length; i++){ - var c = columns[i]; - if (c.quantitative) { - if (strict && c.stats.hasNegative) continue; - if (strict && c.stats.isSequential) continue; - if (strict && (0, geo_1.isGeo)(c)) continue; - return c; + const canvas = container.getElementsByTagName('canvas')[0]; + let pickedId; + const hover = (e)=>{ + if (core.renderer.pickedId !== pickedId) { + pickedId = core.renderer.pickedId; + const ordinal = core.renderer.transitionBuffers[0].pickIdLookup[pickedId]; + options.onCubeHover(e, ordinal); } - } + }; + canvas.addEventListener('mousemove', (e)=>{ + clearClickTimeout(); + if (mousedown) options.onCubeHover(e, null); + hover(e); + }); + canvas.addEventListener('mouseout', hover); + canvas.addEventListener('mouseover', hover); + let mousedown; + canvas.addEventListener('mousedown', ()=>{ + mousedown = true; + }); + canvas.addEventListener('mouseup', (e)=>{ + mousedown = false; + }); + let canvasClickTimeout; + const clearClickTimeout = ()=>{ + clearTimeout(canvasClickTimeout); + canvasClickTimeout = null; + }; + canvas.addEventListener('click', (e)=>{ + canvasClickTimeout = setTimeout(()=>{ + options.onCanvasClick(e); + }, 50); + }); + inputManager.pickItemCallback = ({ manipulator })=>{ + clearClickTimeout(); + const ordinal = core.renderer.transitionBuffers[0].pickIdLookup[pickedId]; + options.onCubeClick(manipulator.event, ordinal); + }; } -exports.preferredColumnForTreemapSize = preferredColumnForTreemapSize; -},{"./geo":"3mt2H"}],"gabh4":[function(require,module,exports) { -"use strict"; +},{"morphcharts":"9s7CR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"78Jmh":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.RecommenderSummary = void 0; -var barChart_1 = require("./barChart"); -var scatterPlot_1 = require("./scatterPlot"); -var RecommenderSummary = /** @class */ function() { - function RecommenderSummary(columns, data) { - var quickRec = new scatterPlot_1.ScatterPlotRecommenderSummary(columns, data).recommend(); - if (quickRec) this.rec = quickRec; - else { - var barChartrec = new barChart_1.BarChartRecommenderSummary(columns, data).recommend(); - if (barChartrec && barChartrec.score >= 1) this.rec = barChartrec; - else this.rec = { - chart: "grid", - columns: {}, - score: 1 - }; - } - } - RecommenderSummary.prototype.recommend = function() { - return this.rec; - }; - return RecommenderSummary; -}(); -exports.RecommenderSummary = RecommenderSummary; - -},{"./barChart":"8KAbz","./scatterPlot":"294DH"}],"dda71":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Search", ()=>Search); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _searchTerm = require("../controls/searchTerm"); -var _base = require("../base"); -var _button = require("../controls/button"); -var _dropdown = require("../controls/dropdown"); -var _group = require("../controls/group"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _language = require("../language"); -const maxClauses = 5; -function getColumnWithName(columnName, columns) { - for(let i = 0; i < columns.length; i++){ - if (columns[i].name === columnName) return columns[i]; +parcelHelpers.export(exports, "Transitioner", ()=>Transitioner); +parcelHelpers.export(exports, "CameraTransitioner", ()=>CameraTransitioner); +parcelHelpers.export(exports, "ModelTransitioner", ()=>ModelTransitioner); +var _glMatrix = require("gl-matrix"); +var _easing = require("./easing"); +class Transitioner { + constructor(){ + this.isTransitioning = false; } -} -function validateExpression(ex) { - if (ex.operator === "isnullorEmpty") { - ex.errorMessage = null; - return; + begin() { + this.isTransitioning = true; + this.time = 0; } - const s = (0, _searchTerm.getText)(ex); - if (s.length === 0) ex.errorMessage = (0, _language.strings).labelRequired; - else ex.errorMessage = null; -} -function clearExpressionValidation(ex) { - if (ex.operator === "isnullorEmpty") { - ex.errorMessage = null; - return; + elapse(elapsedTime, totalTime, ease = false) { + this.time += elapsedTime; + if (this.time >= totalTime) { + this.isTransitioning = false; + this.time = totalTime; + this.ended && this.ended(); + } + const t = this.time / totalTime; + return ease ? (0, _easing.easing)(t) : t; } - const s = (0, _searchTerm.getText)(ex); - if (s.length !== 0) ex.errorMessage = null; } -function getGroupClauses(currClause, index, disableGroupOR) { - let keys; - if (index === 0) keys = [ - [ - null, - (0, _language.strings).searchWHERE - ], - ]; - else { - keys = [ - [ - "&&", - (0, _language.strings).searchAND - ], - ]; - if (!disableGroupOR) keys.push([ - "||", - (0, _language.strings).searchOR - ]); +class CameraTransitioner extends Transitioner { + constructor(){ + super(); + this.qRotation = { + from: (0, _glMatrix.quat).create(), + to: null, + current: (0, _glMatrix.quat).create() + }; + this.vPosition = { + from: (0, _glMatrix.vec3).create(), + to: null, + current: (0, _glMatrix.vec3).create() + }; } - return keys.map((key, i)=>{ - const [clause, text] = key; - const selected = currClause == clause; //deliberate double equal - const option = { - key: i, - text, - data: clause, - selected + move(position, rotation) { + this.begin(); + this.qRotation.to = rotation; + this.vPosition.to = position; + } +} +class ModelTransitioner extends Transitioner { + constructor(){ + super(); + this.shouldTransition = false; + this.qRotation = { + from: null, + to: null, + current: (0, _glMatrix.quat).create() }; - return option; - }); + } } -function _Search(_props) { - class __Search extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = this.getInitialState(this.props); - this.dropdownRef = (0, _base.base).react.createRef(); - props.explorer.dialogFocusHandler.focus = ()=>{ - var _a; - return (_a = this.dropdownRef.current) === null || _a === void 0 ? void 0 : _a.focus(); - }; - } - getInitialState(props) { - const initialState = { - groups: props.initializer.search || [ - this.newGroup(0, null) - ], - sortedColumns: [ - ...props.initializer.columns - ].sort((a, b)=>a.name.localeCompare(b.name)), - initializer: props.initializer - }; - initialState.groups.forEach((group)=>{ - group.expressions.forEach((ex)=>ex.unlocked = group.expressions.length <= 2); - }); - return initialState; - } - componentDidUpdate() { - if (!(0, _sanddanceReact.util).deepCompare(this.props.initializer, this.state.initializer)) this.setState(this.getInitialState(this.props)); - } - validateAndSearch() { - const groups = [ - ...this.state.groups - ]; - groups.forEach((group)=>{ - group.expressions.forEach(validateExpression); - const errors = group.expressions.reduce((p, c)=>p || c.errorMessage, ""); - if (errors) this.setState({ - groups - }); - else this.props.onSelect(this.state.groups); - }); - } - newGroup(key, clause) { - const group = { - key, - clause, - expressions: [ - this.newExpression(0, null) - ] + +},{"gl-matrix":"5x28d","./easing":"kLGAR","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kLGAR":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "easing", ()=>easing); +var _d3Ease = require("d3-ease"); +function easing(t) { + if (t === 0 || t === 1) return t; + return (0, _d3Ease.easeCubicInOut)(t); +} + +},{"d3-ease":"ejK9C","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ejK9C":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "easeLinear", ()=>(0, _linearJs.linear)); +parcelHelpers.export(exports, "easeQuad", ()=>(0, _quadJs.quadInOut)); +parcelHelpers.export(exports, "easeQuadIn", ()=>(0, _quadJs.quadIn)); +parcelHelpers.export(exports, "easeQuadOut", ()=>(0, _quadJs.quadOut)); +parcelHelpers.export(exports, "easeQuadInOut", ()=>(0, _quadJs.quadInOut)); +parcelHelpers.export(exports, "easeCubic", ()=>(0, _cubicJs.cubicInOut)); +parcelHelpers.export(exports, "easeCubicIn", ()=>(0, _cubicJs.cubicIn)); +parcelHelpers.export(exports, "easeCubicOut", ()=>(0, _cubicJs.cubicOut)); +parcelHelpers.export(exports, "easeCubicInOut", ()=>(0, _cubicJs.cubicInOut)); +parcelHelpers.export(exports, "easePoly", ()=>(0, _polyJs.polyInOut)); +parcelHelpers.export(exports, "easePolyIn", ()=>(0, _polyJs.polyIn)); +parcelHelpers.export(exports, "easePolyOut", ()=>(0, _polyJs.polyOut)); +parcelHelpers.export(exports, "easePolyInOut", ()=>(0, _polyJs.polyInOut)); +parcelHelpers.export(exports, "easeSin", ()=>(0, _sinJs.sinInOut)); +parcelHelpers.export(exports, "easeSinIn", ()=>(0, _sinJs.sinIn)); +parcelHelpers.export(exports, "easeSinOut", ()=>(0, _sinJs.sinOut)); +parcelHelpers.export(exports, "easeSinInOut", ()=>(0, _sinJs.sinInOut)); +parcelHelpers.export(exports, "easeExp", ()=>(0, _expJs.expInOut)); +parcelHelpers.export(exports, "easeExpIn", ()=>(0, _expJs.expIn)); +parcelHelpers.export(exports, "easeExpOut", ()=>(0, _expJs.expOut)); +parcelHelpers.export(exports, "easeExpInOut", ()=>(0, _expJs.expInOut)); +parcelHelpers.export(exports, "easeCircle", ()=>(0, _circleJs.circleInOut)); +parcelHelpers.export(exports, "easeCircleIn", ()=>(0, _circleJs.circleIn)); +parcelHelpers.export(exports, "easeCircleOut", ()=>(0, _circleJs.circleOut)); +parcelHelpers.export(exports, "easeCircleInOut", ()=>(0, _circleJs.circleInOut)); +parcelHelpers.export(exports, "easeBounce", ()=>(0, _bounceJs.bounceOut)); +parcelHelpers.export(exports, "easeBounceIn", ()=>(0, _bounceJs.bounceIn)); +parcelHelpers.export(exports, "easeBounceOut", ()=>(0, _bounceJs.bounceOut)); +parcelHelpers.export(exports, "easeBounceInOut", ()=>(0, _bounceJs.bounceInOut)); +parcelHelpers.export(exports, "easeBack", ()=>(0, _backJs.backInOut)); +parcelHelpers.export(exports, "easeBackIn", ()=>(0, _backJs.backIn)); +parcelHelpers.export(exports, "easeBackOut", ()=>(0, _backJs.backOut)); +parcelHelpers.export(exports, "easeBackInOut", ()=>(0, _backJs.backInOut)); +parcelHelpers.export(exports, "easeElastic", ()=>(0, _elasticJs.elasticOut)); +parcelHelpers.export(exports, "easeElasticIn", ()=>(0, _elasticJs.elasticIn)); +parcelHelpers.export(exports, "easeElasticOut", ()=>(0, _elasticJs.elasticOut)); +parcelHelpers.export(exports, "easeElasticInOut", ()=>(0, _elasticJs.elasticInOut)); +var _linearJs = require("./linear.js"); +var _quadJs = require("./quad.js"); +var _cubicJs = require("./cubic.js"); +var _polyJs = require("./poly.js"); +var _sinJs = require("./sin.js"); +var _expJs = require("./exp.js"); +var _circleJs = require("./circle.js"); +var _bounceJs = require("./bounce.js"); +var _backJs = require("./back.js"); +var _elasticJs = require("./elastic.js"); + +},{"./linear.js":false,"./quad.js":false,"./cubic.js":"9VY6p","./poly.js":false,"./sin.js":false,"./exp.js":false,"./circle.js":false,"./bounce.js":false,"./back.js":false,"./elastic.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9VY6p":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "cubicIn", ()=>cubicIn); +parcelHelpers.export(exports, "cubicOut", ()=>cubicOut); +parcelHelpers.export(exports, "cubicInOut", ()=>cubicInOut); +function cubicIn(t) { + return t * t * t; +} +function cubicOut(t) { + return --t * t * t + 1; +} +function cubicInOut(t) { + return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3abZO":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ViewGl", ()=>ViewGl); +var _base = require("../base"); +var _defaults = require("../defaults"); +var _presenter = require("../presenter"); +var _enums = require("../enums"); +var _rendererGl = require("./rendererGl"); +let registered = false; +//dynamic superclass lets us create a subclass at execution phase instead of declaration phase. +//This allows us to retrieve vega.View from either UMD or ES6 consumers of this class. +//pass in the SuperClass, which should be a vega.View +function _ViewGl(runtime, config) { + //dynamic superclass, since we don't know have vega.View in the declaration phase + class ViewGlInternal extends (0, _base.base).vega.View { + constructor(runtime, config = {}){ + super(runtime, config); + this.config = config; + this.presenter = config.presenter; + config.presenterConfig = config.presenterConfig || {}; + config.presenterConfig.redraw = ()=>{ + this._redraw = true; //use Vega View private member _redraw + this.run(); }; - return group; - } - updateGroup(partialGroup, groupIndex) { - const groups = [ - ...this.state.groups - ]; - const group = Object.assign(Object.assign({}, groups[groupIndex]), partialGroup); - groups[groupIndex] = group; - this.setState({ - groups - }); - } - addGroup() { - const groups = [ - ...this.state.groups - ]; - const maxKey = groups.reduce((max, p)=>p.key > max ? p.key : max, groups[0].key); - const newGroup = this.newGroup(maxKey + 1, "&&"); - groups.push(newGroup); - this.setState({ - groups - }); } - deleteGroup(groupIndex) { - const groups = [ - ...this.state.groups - ]; - groups.splice(groupIndex, 1); - this.setState({ - groups - }); + renderer(...args) { + if (args && args.length) { + const renderer = args[0]; + if (renderer === 'morphcharts' && !registered) { + (0, _base.base).vega.renderModule('morphcharts', { + handler: (0, _base.base).vega.CanvasHandler, + renderer: (0, _rendererGl.RendererGl) + }); + registered = true; + } + return super.renderer(renderer); + } else return super.renderer(); } - newExpression(key, clause) { - const ex = { - key, - clause, - name: null, - operator: "contains", - value: "" - }; - return ex; + initialize(el) { + if (!this.presenter) this.presenter = new (0, _presenter.Presenter)(el); + super.initialize(this.presenter.getElement((0, _enums.PresenterElement).vegaControls)); + const renderer = this._renderer; + renderer.presenterConfig = this.config.presenterConfig; + renderer.presenter = this.presenter; + renderer.getView = this.config && this.config.getView || (()=>this.presenter.view || (0, _defaults.defaultView)); + return this; } - addExpression(groupIndex) { - const groups = [ - ...this.state.groups - ]; - const group = groups[groupIndex]; - const maxKey = group.expressions.reduce((max, p)=>p.key > max ? p.key : max, group.expressions[0].key); - const newEx = this.newExpression(maxKey + 1, "&&"); - group.expressions.push(newEx); - if (group.expressions.length === 2) newEx.unlocked = true; - else { - group.expressions.forEach((ex)=>ex.unlocked = false); - newEx.clause = group.expressions[1].clause; - } - this.setState({ - groups - }); + error(e) { + if (this.presenter.logger) this.presenter.logger(e); } - updateExpression(partialEx, groupIndex, index) { - const groups = [ - ...this.state.groups - ]; - const group = groups[groupIndex]; - const ex = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(group.expressions[index]); - if (ex.name !== partialEx.name) { - //choose an appropriate operator when switching data type - const oldColumn = getColumnWithName(ex.name, this.state.sortedColumns); - const newColumn = getColumnWithName(partialEx.name, this.state.sortedColumns); - const oldType = oldColumn && oldColumn.type; - const newType = newColumn && newColumn.type; - if (oldType !== newType) { - const newOperators = (0, _searchTerm.getValidOperators)(newColumn).map((validOperator)=>validOperator[0]); - //see if old operator is compatible - if (newOperators.indexOf(ex.operator) < 0) //not compatible, so choose "equal" - partialEx.operator = "=="; - } - } - Object.assign(ex, partialEx); - clearExpressionValidation(ex); - group.expressions[index] = ex; - this.setState({ - groups - }); + } + const instance = new ViewGlInternal(runtime, config); + return instance; +} +const ViewGl = _ViewGl; + +},{"../base":"hIePf","../defaults":"4Q1zd","../presenter":"9yYY0","../enums":"hnVHt","./rendererGl":"cfqe0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cfqe0":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "RendererGl", ()=>RendererGl); +var _base = require("../base"); +//pass in the SuperClass, which should be a vega.View +function _RendererGl(loader) { + //dynamic superclass, since we don't know have vega.View in the declaration phase + class RendererGlInternal extends (0, _base.base).vega.Renderer { + initialize(el, width, height, origin) { + this.height = height; + this.width = width; + // this method will invoke resize to size the canvas appropriately + return super.initialize(el, width, height, origin); } - deleteExpression(groupIndex, index) { - const groups = [ - ...this.state.groups - ]; - const group = groups[groupIndex]; - const expressions = [ - ...group.expressions - ]; - expressions.splice(index, 1); - if (expressions.length === 2) expressions[1].unlocked = true; - group.expressions = expressions; - this.setState({ - groups - }); + resize(width, height, origin) { + super.resize(width, height, origin); + this.origin = origin; + this.height = height; + this.width = width; + //rteturn this for vega + return this; } - render() { - return (0, _base.base).react.createElement((0, _group.Group), { - className: "sanddance-search", - label: (0, _language.strings).labelSearch - }, (0, _base.base).react.createElement("div", null, this.state.groups.map((group, groupIndex)=>(0, _base.base).react.createElement("div", { - className: "sanddance-search-group", - key: group.key - }, (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: this.props.collapseLabels, - className: "search-group-clause", - label: (0, _language.strings).labelSearchClause, - disabled: groupIndex === 0 || this.props.disableGroupOR, - dropdownWidth: 120, - options: getGroupClauses(group.clause, groupIndex, this.props.disableGroupOR), - onChange: (e, o)=>this.updateGroup({ - clause: o.data - }, groupIndex) - }), (0, _base.base).react.createElement("div", null, group.expressions.map((ex, i)=>(0, _base.base).react.createElement("div", { - className: "sanddance-search-expression", - key: ex.key - }, (0, _base.base).react.createElement((0, _searchTerm.SearchTerm), { - dropdownRef: groupIndex === 0 && i === 0 ? this.dropdownRef : undefined, - collapseLabels: this.props.collapseLabels, - onUpdateExpression: (ex, i)=>this.updateExpression(ex, groupIndex, i), - autoCompleteDistinctValues: this.props.autoCompleteDistinctValues, - index: i, - columns: this.state.sortedColumns, - data: this.props.data, - searchExpression: ex, - disableOR: this.props.disableExpressionOR, - column: getColumnWithName(ex.name, this.state.sortedColumns) - }), group.expressions.length > 1 && (0, _base.base).react.createElement((0, _button.Button), { - themePalette: this.props.themePalette, - className: "search-action", - iconName: "Cancel", - onClick: ()=>this.deleteExpression(groupIndex, i), - text: (0, _language.strings).buttonDeleteExpression - })))), group.expressions.length < maxClauses && (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _button.Button), { - themePalette: this.props.themePalette, - className: "search-action", - iconName: "Add", - onClick: ()=>this.addExpression(groupIndex), - text: (0, _language.strings).buttonAddExpression - })), this.state.groups.length > 1 && (0, _base.base).react.createElement((0, _button.Button), { - themePalette: this.props.themePalette, - className: "search-action", - iconName: "Cancel", - onClick: ()=>this.deleteGroup(groupIndex), - text: (0, _language.strings).buttonDeleteExpressionGroup - }))), this.state.groups.length < maxClauses && (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _button.Button), { - themePalette: this.props.themePalette, - className: "search-action search-bottom-action", - iconName: "Add", - onClick: ()=>this.addGroup(), - text: (0, _language.strings).buttonAddExpressionGroup - }))), (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - className: "search-action search-bottom-action", - text: (0, _language.strings).buttonSelect, - onClick: ()=>this.validateAndSearch() - })); + _render(scene, items) { + const scene3d = scene; + scene3d.view = this.getView(); + this.presenter.present(scene3d, this.height, this.width, this.presenterConfig); + //return this for vega + return this; } } - return new __Search(_props); + const instance = new RendererGlInternal(loader); + return instance; } -const Search = _Search; +const RendererGl = _RendererGl; -},{"../controls/searchTerm":"RKS2M","../base":"9M4eu","../controls/button":"j0llx","../controls/dropdown":"2Udzo","../controls/group":"hggjF","@msrvida/sanddance-react":"73dPQ","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"RKS2M":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"../base":"hIePf","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eMVZG":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "maxAutocomplete", ()=>maxAutocomplete); -parcelHelpers.export(exports, "getValidOperators", ()=>getValidOperators); -parcelHelpers.export(exports, "getText", ()=>getText); -parcelHelpers.export(exports, "SearchTerm", ()=>SearchTerm); +parcelHelpers.export(exports, "version", ()=>version); +const version = '1.0.6'; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iDNR0":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _dropdown = require("./dropdown"); -var _textfield = require("./textfield"); -var _base = require("../base"); -var _language = require("../language"); -const maxAutocomplete = 100; -function getValidOperators(column) { - const type = column && column.type; - switch(type){ - case "boolean": - return [ - [ - "==", - (0, _language.strings).searchEQ - ], - [ - "!=", - (0, _language.strings).searchNEQ - ], - [ - "isnullorEmpty", - (0, _language.strings).searchNULL - ], - ]; - case "date": - case "integer": - case "number": - return [ - [ - "==", - (0, _language.strings).searchEQ - ], - [ - "!=", - (0, _language.strings).searchNEQ - ], - [ - ">", - (0, _language.strings).searchGT - ], - [ - ">=", - (0, _language.strings).searchGTE - ], - [ - "<", - (0, _language.strings).searchLT - ], - [ - "<=", - (0, _language.strings).searchLTE - ], - [ - "isnullorEmpty", - (0, _language.strings).searchNULL - ], - ]; - case "string": - default: - return [ - [ - "==", - (0, _language.strings).searchEQ - ], - [ - "!=", - (0, _language.strings).searchNEQ - ], - [ - ">", - (0, _language.strings).searchGT - ], - [ - ">=", - (0, _language.strings).searchGTE - ], - [ - "<", - (0, _language.strings).searchLT - ], - [ - "<=", - (0, _language.strings).searchLTE - ], - [ - "contains", - (0, _language.strings).searchIN - ], - [ - "starts", - (0, _language.strings).searchSW - ], - [ - "isnullorEmpty", - (0, _language.strings).searchNULL - ], - ]; +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "colorSchemes", ()=>colorSchemes); +parcelHelpers.export(exports, "registerColorSchemes", ()=>registerColorSchemes); +var _sanddanceSpecs = require("@msrvida/sanddance-specs"); +var _defaults = require("./defaults"); +const dualPairs = [ + [ + (0, _defaults.dualColorSchemeColors).black, + (0, _defaults.dualColorSchemeColors).gray + ], + [ + (0, _defaults.dualColorSchemeColors).red, + (0, _defaults.dualColorSchemeColors).green + ], + [ + (0, _defaults.dualColorSchemeColors).red, + (0, _defaults.dualColorSchemeColors).blue + ], + [ + (0, _defaults.dualColorSchemeColors).black, + (0, _defaults.dualColorSchemeColors).red + ], + [ + (0, _defaults.dualColorSchemeColors).black, + (0, _defaults.dualColorSchemeColors).orange + ], + [ + (0, _defaults.dualColorSchemeColors).black, + (0, _defaults.dualColorSchemeColors).green + ] +]; +const colorSchemes = [ + { + scheme: (0, _sanddanceSpecs.ColorScaleNone), + colors: [ + (0, _defaults.defaultViewerOptions).colors.defaultCube + ] } -} -function getExpressionClauses(currClause, disableOR) { - const keys = [ - [ - "&&", - (0, _language.strings).searchAND - ], - ]; - if (!disableOR) keys.push([ - "||", - (0, _language.strings).searchOR - ]); - return keys.map((key, i)=>{ - const [clause, text] = key; - const selected = currClause == clause; //deliberate double equal - const option = { - key: i, - text, - data: clause, - selected - }; - return option; +]; +createDualColorSchemes(); +function registerColorSchemes(vega) { + colorSchemes.forEach((cs)=>{ + if (cs.colors.length === 1) vega.scheme(cs.scheme, (x)=>cs.colors[0]); + else vega.scheme(cs.scheme, cs.colors); }); } -function getOperators(ex, column) { - let anySelected = false; - const validOperators = getValidOperators(column); - const options = validOperators.map((validoperator)=>{ - const [op, text] = validoperator; - const selected = ex.operator === op; - anySelected = anySelected || selected; - const option = { - key: op, - text, - data: op, - selected - }; - return option; +function createPair(names, colors) { + const scheme = `dual_${names[0]}${names[1]}`; + colorSchemes.push({ + scheme, + colors }); - if (!anySelected) options[0].selected = true; - return options; } -function getDistinctValues(data, columnName) { - const distinctMap = {}; - for(let i = 0; i < data.length; i++){ - const row = data[i]; - const value = row[columnName]; - distinctMap[value] = true; - } - return Object.keys(distinctMap).sort(); -} -function getValues(ex, column, data, autoCompleteDistinctValues) { - const stats = column && column.stats; - if (stats && stats.distinctValueCount < maxAutocomplete) { - if (!autoCompleteDistinctValues[column.name]) autoCompleteDistinctValues[column.name] = getDistinctValues(data, column.name); - return autoCompleteDistinctValues[column.name].map((v, i)=>({ - key: i, - text: v - })); - } - return []; -} -function getText(ex) { - if (ex.operator === "isnullorEmpty") return ""; - return typeof ex.value === "string" ? ex.value : ex.value == null ? "" : ex.value.toString(); -} -function SearchTerm(props) { - const ex = props.searchExpression; - const possibleValues = getValues(ex, props.column, props.data, props.autoCompleteDistinctValues); - //TODO better date handling with calendar picker - return (0, _base.base).react.createElement("div", null, props.index > 0 && (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: props.collapseLabels, - className: "search-field", - label: (0, _language.strings).labelSearchClause, - dropdownWidth: 120, - disabled: !ex.unlocked || props.disableOR, - options: getExpressionClauses(ex.clause, props.disableOR), - onChange: (e, o)=>props.onUpdateExpression({ - clause: o.data - }, props.index) - }), (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - componentRef: props.dropdownRef, - collapseLabel: props.collapseLabels, - className: "search-field", - label: (0, _language.strings).labelSearchColumn, - options: [ - { - key: "", - text: (0, _language.strings).selectAny, - data: null, - selected: ex.name === null - }, - ].concat(props.columns.map((c, i)=>({ - key: c.name, - text: c.name, - data: c, - selected: c.name === ex.name - }))), - onChange: (e, o)=>props.onUpdateExpression({ - name: o.data && o.data.name || null - }, props.index) - }), (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: props.collapseLabels, - className: "search-field", - label: (0, _language.strings).labelSearchOperator, - dropdownWidth: 120, - options: getOperators(ex, props.column), - onChange: (e, o)=>props.onUpdateExpression({ - operator: o.data - }, props.index) - }), possibleValues.length > 0 && (0, _base.base).react.createElement((0, _base.base).fluentUI.ComboBox, { - className: "search-field", - label: props.collapseLabels ? null : (0, _language.strings).labelSearchValue, - placeholder: (0, _language.strings).labelSearchValuePlaceholder, - disabled: ex.operator === "isnullorEmpty", - dropdownWidth: (0, _dropdown.dropdownWidth), - allowFreeform: true, - autoComplete: "on", - errorMessage: ex.errorMessage, - text: getText(ex), - options: getValues(ex, props.column, props.data, props.autoCompleteDistinctValues), - onChange: (e, o, i, value)=>{ - if (o) value = o.text; - props.onUpdateExpression({ - value - }, props.index); - } - }), possibleValues.length === 0 && (0, _base.base).react.createElement((0, _textfield.TextField), { - className: "search-field", - label: props.collapseLabels ? null : (0, _language.strings).labelSearchValue, - placeholder: (0, _language.strings).labelSearchValuePlaceholder, - disabled: ex.operator === "isnullorEmpty", - errorMessage: ex.errorMessage, - value: getText(ex), - onChange: (e, v)=>props.onUpdateExpression({ - value: v - }, props.index) - })); +function createDualColorSchemes() { + dualPairs.forEach((colors)=>{ + const names = colors.map((color)=>{ + for(const key in 0, _defaults.dualColorSchemeColors)if (color === (0, _defaults.dualColorSchemeColors)[key]) return key; + }); + createPair(names, colors); + createPair([ + ...names + ].reverse(), [ + ...colors + ].reverse()); + }); } -},{"./dropdown":"2Udzo","./textfield":"llyb0","../base":"9M4eu","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"llyb0":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "TextField", ()=>TextField); +},{"@msrvida/sanddance-specs":"aOvSr","./defaults":"7bMd0","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9IMa3":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("../base"); -function TextField(props) { - return (0, _base.base).react.createElement((0, _base.base).fluentUI.TextField, Object.assign({ - onKeyUp: (e)=>{ - e.nativeEvent.stopImmediatePropagation(); - } - }, props)); -} - -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"j0llx":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Button", ()=>Button); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -function Button(props) { - return (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, Object.assign({}, props, { - styles: { - root: Object.assign({ - backgroundColor: "transparent", - height: "30px", - width: props.width, - padding: 0 - }, props.rootStyle), - rootDisabled: { - backgroundColor: "transparent" - }, - icon: { - color: props.themePalette.themePrimary - }, - label: { - fontWeight: "400", - textAlign: props.textAlign || "left" +/** + * Component to view a SandDance data visualization. + */ parcelHelpers.export(exports, "Viewer", ()=>Viewer); +var _animator = require("./animator"); +var _axisSelection = require("./axisSelection"); +var _colorCubes = require("./colorCubes"); +var _colorSchemes = require("./colorSchemes"); +var _constants = require("./constants"); +var _dataScope = require("./dataScope"); +var _defaults = require("./defaults"); +var _details = require("./details"); +var _headers = require("./headers"); +var _legend = require("./legend"); +var _ordinal = require("./ordinal"); +var _search = require("./search"); +var _signals = require("./signals"); +var _tooltip = require("./tooltip"); +var _sanddanceSpecs = require("@msrvida/sanddance-specs"); +var _searchExpression = require("@msrvida/search-expression"); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +var _characterSet = require("./characterSet"); +var _transition = require("./transition"); +var __awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); } - }, - iconProps: { - iconName: props.iconName } - })); -} - -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1PLto":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Settings", ()=>Settings); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceReact = require("@msrvida/sanddance-react"); -var _base = require("../base"); -var _canvas = require("../canvas"); -var _dialog = require("../controls/dialog"); -var _dropdown = require("../controls/dropdown"); -var _group = require("../controls/group"); -var _signal = require("../controls/signal"); -var _language = require("../language"); -var _version = require("../version"); -var SandDance = _sanddanceReact.SandDance; -var DataRefType; -(function(DataRefType) { - DataRefType[DataRefType["none"] = 0] = "none"; - DataRefType[DataRefType["inline"] = 1] = "inline"; - DataRefType[DataRefType["url"] = 2] = "url"; -})(DataRefType || (DataRefType = {})); -function filterSignals(signal) { - switch(signal.name){ - case SandDance.constants.SignalNames.XBins: - case SandDance.constants.SignalNames.YBins: - case SandDance.constants.SignalNames.FacetBins: - case SandDance.constants.SignalNames.FacetVBins: - case SandDance.constants.SignalNames.ColorBinCount: - case SandDance.constants.SignalNames.ColorReverse: - case SandDance.constants.SignalNames.PointScale: - case SandDance.constants.SignalNames.TreeMapMethod: - case SandDance.constants.SignalNames.ZGrounded: - return false; - default: - return !!signal.bind; - } -} -function cloneData(vegaSpec) { - const data0 = vegaSpec.data[0]; - const valuesData = data0; - const values = valuesData.values; - delete valuesData.values; - const data = SandDance.VegaMorphCharts.util.clone(vegaSpec.data); - valuesData.values = values; - return { - data, - values - }; -} -function cloneScales(vegaSpec) { - return SandDance.VegaMorphCharts.util.clone(vegaSpec.scales); -} -function serializeSpec(vegaSpec, datafile, dataRefType, transform, scheme) { - const scales = cloneScales(vegaSpec); - const colorScale = scales.filter((scale)=>scale.name === SandDance.constants.ScaleNames.Color)[0]; - if (scheme.indexOf("dual_") >= 0) colorScale.range = SandDance.colorSchemes.filter((cs)=>cs.scheme === scheme)[0].colors; - const clone = cloneData(vegaSpec); - const data0 = clone.data[0]; - if (dataRefType === DataRefType.inline) { - const valuesData = data0; - valuesData.format = { - parse: "auto", - type: "json" - }; - valuesData.values = clone.values; - } else if (dataRefType === DataRefType.none) { - const valuesData1 = data0; - valuesData1.values = []; - if (transform) { - if (valuesData1.transform) valuesData1.transform.push.apply(valuesData1.transform, transform); - else valuesData1.transform = transform; + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } } - } else if (dataRefType === DataRefType.url) { - const urlData = data0; - urlData.url = datafile.dataUrl; - urlData.format = { - parse: "auto", - type: datafile.type - }; - if (transform) { - if (urlData.transform) urlData.transform.push.apply(urlData.transform, transform); - else urlData.transform = transform; + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - } - return Object.assign(Object.assign({}, vegaSpec), { - data: clone.data, - scales + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); -} -function defaultDataRefType(datafile) { - if (datafile.dataUrl) return DataRefType.url; - return DataRefType.none; -} -function initState(props) { - return { - showSystemDialog: false, - showVegaDialog: false, - dataRefType: defaultDataRefType(props.dataFile), - spec: null - }; -} -function signalGroupKey(key) { - for(let i = 0; i < (0, _language.strings).signalGroups.length; i++){ - if ((0, _language.strings).signalGroups[i].prefix === key) return key; +}; +const { defaultView } = _vegaMorphcharts.defaults; +const zAxisZindex = 1010; +let didRegisterColorSchemes = false; +class Viewer { + /** + * Instantiate a new Viewer. + * @param element Parent HTMLElement to present within. + * @param options Optional viewer options object. + */ constructor(element, options){ + this.element = element; + this.options = _vegaMorphcharts.util.deepMerge((0, _defaults.defaultViewerOptions), options); + this.presenter = new _vegaMorphcharts.Presenter(element, (0, _defaults.getPresenterStyle)(this.options)); + //this.presenter.logger = console.log; + this._characterSet = new (0, _characterSet.CharacterSet)(); + this._dataScope = new (0, _dataScope.DataScope)(); + this._animator = new (0, _animator.Animator)(this._dataScope, { + onDataChanged: this.onDataChanged.bind(this), + onAnimateDataChange: this.onAnimateDataChange.bind(this) + }); + this._details = new (0, _details.Details)(this.presenter.getElement(_vegaMorphcharts.PresenterElement.panel), this.options.language, this._animator, this._dataScope, (remap)=>{ + this.currentColorContext = ~~remap; + this.renderSameLayout(); + }, ()=>this.insight && this.insight.columns && !!this.insight.columns.color && this.colorContexts && this.colorContexts.length > 1); + this.insight = {}; } - return "*"; -} -function vegaSignalGroups(vegaSignals) { - const signalGroupMap = {}; - vegaSignals.forEach((vs)=>{ - const split = vs.name.split("_"); - const key = signalGroupKey(split[0]); - signalGroupMap[key] = signalGroupMap[key] || []; - signalGroupMap[key].push(vs); - }); - return signalGroupMap; -} -function _Settings(_props) { - class __Settings extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = initState(props); + changeColorContexts(colorContexts) { + this.colorContexts = colorContexts; + this.currentColorContext = 0; + this.options.onColorContextChange && this.options.onColorContextChange(); + } + applyLegendColorContext(colorContext) { + const a = _vegaMorphcharts.util.getActiveElementInfo(); + _vegaMorphcharts.util.mount(colorContext.legendElement, this.presenter.getElement(_vegaMorphcharts.PresenterElement.legend)); + _vegaMorphcharts.util.setActiveElement(a); + this.presenter.stage.legend = colorContext.legend; + } + onAnimateDataChange(dataChange, waitingLabel, handlerLabel, time) { + var _a; + if (time === undefined) { + const transitionDurations = ((_a = this.setup) === null || _a === void 0 ? void 0 : _a.transitionDurations) || _vegaMorphcharts.defaults.defaultPresenterConfig.transitionDurations; + time = transitionDurations.position + transitionDurations.stagger; } - render() { - const { props , state } = this; - if (!props.explorer.viewer || !props.explorer.viewer.vegaSpec) return null; - const options = [ - { - key: DataRefType.none, - text: (0, _language.strings).selectVegaSpecDataNone, - selected: this.state.dataRefType === DataRefType.none, - data: DataRefType.none - }, - !props.dataFile.rawText && { - key: DataRefType.url, - text: (0, _language.strings).selectVegaSpecDataUrl, - selected: this.state.dataRefType === DataRefType.url, - data: DataRefType.url - }, - { - key: DataRefType.inline, - text: (0, _language.strings).selectVegaSpecDataInline, - selected: this.state.dataRefType === DataRefType.inline, - data: DataRefType.inline - }, - ].filter(Boolean); - const signalGroupMap = vegaSignalGroups(props.explorer.viewer.vegaSpec.signals); - let first = true; - return (0, _base.base).react.createElement("div", null, (0, _language.strings).signalGroups.map((sg, gi)=>{ - const vegaSignals = signalGroupMap[sg.prefix]; - if (vegaSignals) { - const filteredVegaSignals = vegaSignals.filter(filterSignals); - if (filteredVegaSignals.length > 0) return (0, _base.base).react.createElement((0, _group.Group), { - key: sg.prefix, - label: sg.label - }, filteredVegaSignals.map((signal, i)=>{ - const ref = (0, _base.base).react.createRef(); - if (first) { - first = false; - props.explorer.dialogFocusHandler.focus = ()=>{ - const f = ref.current; - if (f === null || f === void 0 ? void 0 : f.focus) f.focus(); - }; + return new Promise((resolve, reject)=>{ + let innerPromise; + if (dataChange === (0, _animator.DataLayoutChange).refine) { + const oldColorContext = this.colorContexts[this.currentColorContext]; + innerPromise = new Promise((innerResolve)=>{ + this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { + preStage: (stage, cubeLayer)=>{ + (0, _legend.finalizeLegend)(this.insight.colorBin, this._specColumns.color, stage.legend, this.options.language); + this.overrideAxisLabels(stage); + cubeLayer.unitColorMap = oldColorContext.colorMap; + if (this.options.onStage) this.options.onStage(stage); } - return (0, _base.base).react.createElement((0, _signal.Signal), { - componentRef: ref, - key: i, - signal: signal, - explorer: props.explorer, - initialValue: (0, _signal.getInitialSignalValue)(props.explorer, signal), - newViewStateTarget: false - }); - })); + })).then(()=>{ + //apply old legend + this.applyLegendColorContext(oldColorContext); + innerResolve(); + }); + }); + } else innerPromise = this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { + preStage: (stage, colorMapper)=>{ + (0, _legend.finalizeLegend)(this.insight.colorBin, this._specColumns.color, stage.legend, this.options.language); + this.overrideAxisLabels(stage); + if (this.options.onStage) this.options.onStage(stage); } - }), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelChartCanvas - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - label: (0, _language.strings).labelShowAxes, - defaultChecked: !props.hideAxes, - onChange: (e, checked)=>props.onToggleAxes(!checked) - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - label: (0, _language.strings).labelShowLegend, - defaultChecked: !props.hideLegend, - onChange: (e, checked)=>props.onToggleLegend(!checked) - })), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelTools - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - text: (0, _language.strings).buttonShowVegaSpec, - onClick: ()=>this.setState({ - showVegaDialog: true, - spec: serializeSpec(props.explorer.viewer.vegaSpec, props.dataFile, this.state.dataRefType, props.explorer.viewer.getInsight().transform, this.props.scheme) - }) - })), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelSnapshots - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - label: (0, _language.strings).labelSnapshotSettingThumbnailWidth, - onChange: (value)=>{ - this.props.explorer.snapshotThumbWidth = value; - }, - min: 100, - max: 800, - defaultValue: this.props.explorer.snapshotThumbWidth - })), props.additionalSettings && props.additionalSettings.map((g, i)=>(0, _base.base).react.createElement((0, _group.Group), { - key: i, - label: g.groupLabel - }, g.children)), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelSystem - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - text: (0, _language.strings).labelSystemInfo, - onClick: ()=>this.setState({ - showSystemDialog: true - }) - })), (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: !state.showVegaDialog, - onDismiss: ()=>this.setState(initState(this.props)), - minWidth: "80%", - title: (0, _language.strings).labelVegaSpec, - buttons: [ - (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - key: "copy", - iconProps: { - iconName: "Copy" - }, - text: (0, _language.strings).buttonCopyToClipboard, - onClick: ()=>{ - const pre = document.getElementById("sanddance-vega-spec"); - const range = document.createRange(); - range.selectNode(pre); - const selection = window.getSelection(); - selection.removeAllRanges(); - selection.addRange(range); - document.execCommand("copy"); - } - }), - (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - key: "edit", - iconProps: { - iconName: "OpenInNewWindow" - }, - text: (0, _language.strings).buttonLaunchVegaEditor, - onClick: ()=>{ - window.open("https://vega.github.io/editor/", "_blank"); - } - }), - ] - }, (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - label: (0, _language.strings).labelVegaSpecData, - options: options, - onChange: (e, o)=>this.setState({ - dataRefType: o.data, - spec: serializeSpec(props.explorer.viewer.vegaSpec, props.dataFile, o.data, props.explorer.viewer.getInsight().transform, this.props.scheme) - }) - }), (0, _base.base).react.createElement("pre", { - id: "sanddance-vega-spec" - }, JSON.stringify(this.state.spec, null, 2)), (0, _base.base).react.createElement("div", null, (0, _language.strings).labelVegaSpecNotes)), (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: !state.showSystemDialog, - onDismiss: ()=>this.setState(initState(this.props)), - title: (0, _language.strings).labelSystemInfo - }, (0, _base.base).react.createElement("ul", null, this.props.children, (0, _base.base).react.createElement("li", null, "SandDanceExplorer version: ", (0, _version.version)), (0, _base.base).react.createElement("li", null, "SandDanceReact version: ", _sanddanceReact.version), (0, _base.base).react.createElement("li", null, "SandDance version: ", SandDance.version), (0, _base.base).react.createElement("li", null, "Vega-MorphCharts version: ", SandDance.VegaMorphCharts.version), (0, _base.base).react.createElement("li", null, "WebGL enabled: ", (0, _canvas.capabilities).webgl ? (0, _language.strings).labelYes : (0, _language.strings).labelNo), (0, _base.base).react.createElement("li", null, "WebGL2 enabled: ", (0, _canvas.capabilities).webgl2 ? (0, _language.strings).labelYes : (0, _language.strings).labelNo)))); - } + })); + innerPromise.then(()=>{ + this.presenter.animationQueue(resolve, time, { + waitingLabel, + handlerLabel, + animationCanceled: reject + }); + }); + }); } - return new __Settings(_props); -} -const Settings = _Settings; - -},{"@msrvida/sanddance-react":"73dPQ","../base":"9M4eu","../canvas":"7FRqY","../controls/dialog":"ep4zG","../controls/dropdown":"2Udzo","../controls/group":"hggjF","../controls/signal":"847y5","../language":"kzoCJ","../version":"7rYwz","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7FRqY":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getCanvas", ()=>getCanvas); -parcelHelpers.export(exports, "removeTabIndex", ()=>removeTabIndex); -parcelHelpers.export(exports, "capabilities", ()=>capabilities); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var PresenterElement = (0, _sanddanceReact.SandDance).VegaMorphCharts.PresenterElement; -function getCanvas(viewer) { - const tags = viewer.presenter.getElement(PresenterElement.gl).getElementsByTagName("canvas"); - if (tags) return tags[0]; -} -function removeTabIndex(viewer) { - const canvas = getCanvas(viewer); - if (canvas) canvas.tabIndex = -1; -} -const capabilities = { - webgl: !!document.createElement("canvas").getContext("webgl"), - webgl2: !!document.createElement("canvas").getContext("webgl2") -}; - -},{"@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7rYwz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "version", ()=>version); -const version = "4.1.5"; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2kESg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SnapshotEditor", ()=>SnapshotEditor); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _dialog = require("../controls/dialog"); -var _canvas = require("../canvas"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _language = require("../language"); -function _SnapshotEditor(_props) { - class __SnapshotEditor extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = { - showEditFormDialog: false, - title: "", - description: "", - image: null, - bgColor: null, - insight: null, - editIndex: -1 - }; - } - resize(src, thumbWidth) { - if (!src) return; - const img = new Image(); - img.onload = ()=>{ - const canvas = document.createElement("canvas"), ctx = canvas.getContext("2d"); - const ratio = img.width / thumbWidth; - canvas.height = img.height / ratio; - canvas.width = thumbWidth; - ctx.drawImage(img, 0, 0, canvas.width, canvas.height); - const image = canvas.toDataURL(); - this.setState({ - image - }); - }; - img.src = src; - } - editSnapshot(snapshot, editIndex = -1) { - if (snapshot) this.setState(Object.assign(Object.assign({ - showEditFormDialog: true - }, snapshot), { - editIndex - })); - else { - const { explorer } = this.props; - const signalValues = explorer.viewer.getSignalValues(); - explorer.viewer.deselect().then(()=>{ - const canvas = (0, _canvas.getCanvas)(explorer.viewer); - const bgColor = canvas && window.getComputedStyle(canvas).backgroundColor; - const insight = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(explorer.viewer.getInsight()); - delete insight.size; - insight.signalValues = signalValues; - const title = this.props.getTitle && this.props.getTitle(insight) || ""; - const description = this.props.getDescription && this.props.getDescription(insight) || ""; - this.setState({ - showEditFormDialog: true, - bgColor, - title, - description, - insight, - image: null, - editIndex - }); - //allow deselection to render - setTimeout(()=>{ - explorer.viewer.presenter.canvasToDataURL().then((dataUrl)=>{ - this.resize(dataUrl, explorer.snapshotThumbWidth); - }); - }, 500); - }); - } - } - render() { - var _a, _b; - const { explorer } = this.props; - return (0, _base.base).react.createElement((0, _dialog.Dialog), { - modalProps: { - className: (0, _sanddanceReact.util).classList("sanddance-snapshot-dialog", this.props.theme) - }, - minWidth: `${explorer.snapshotThumbWidth + 64}px`, - hidden: !this.state.showEditFormDialog, - onDismiss: ()=>this.setState({ - showEditFormDialog: false - }), - title: this.state.editIndex >= 0 ? (0, _language.strings).buttonEditSnapshot : (0, _language.strings).buttonCreateSnapshot, - buttons: (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - disabled: !this.state.image || !this.state.title, - key: 0, - onClick: (e)=>{ - const setup = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone(explorer.getSetup()); - if (setup.camera !== "hold") //get the latest camera movement, instead of what's in state - setup.camera = explorer.viewer.getCamera(); - const snapshot = { - title: this.state.title, - description: this.state.description, - insight: this.state.insight, - image: this.state.image, - bgColor: this.state.bgColor, - setup - }; - this.props.modifySnapShot && this.props.modifySnapShot(snapshot); - this.props.onWriteSnapshot(snapshot, this.state.editIndex); - this.setState({ - showEditFormDialog: false, - title: "", - description: "", - image: null + onDataChanged(dataLayout, filter) { + return __awaiter(this, void 0, void 0, function*() { + switch(dataLayout){ + case (0, _animator.DataLayoutChange).same: + { + const hasSelectedData = this._dataScope.hasSelectedData(); + const hasActive = !!this._dataScope.active; + if (hasSelectedData || hasActive) this.presenter.morphChartsRenderResult.update({ + cubes: this.convertSearchToSet() }); - }, - iconProps: { - iconName: "Camera" - }, - text: this.state.editIndex >= 0 ? (0, _language.strings).buttonUpdateSnapshot : (0, _language.strings).buttonCreateSnapshot - }) - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.TextField, { - label: (0, _language.strings).labelSnapshotTitle, - onChange: (e, title)=>this.setState({ - title - }), - value: this.state.title - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.TextField, { - label: (0, _language.strings).labelSnapshotDescription, - onChange: (e, description)=>this.setState({ - description - }), - value: this.state.description, - multiline: true - }), (0, _base.base).react.createElement("div", { - className: "thumbnail" - }, !this.state.image && (0, _base.base).react.createElement((0, _base.base).fluentUI.Spinner, null), this.state.image && (0, _base.base).react.createElement("img", { - src: this.state.image, - style: { - backgroundColor: this.state.bgColor - } - })), ((_b = (_a = explorer.viewer) === null || _a === void 0 ? void 0 : _a.colorContexts) === null || _b === void 0 ? void 0 : _b.length) > 1 && (0, _base.base).react.createElement("div", null, (0, _language.strings).labelColorFilter)); - } - } - return new __SnapshotEditor(_props); -} -const SnapshotEditor = _SnapshotEditor; - -},{"../base":"9M4eu","../controls/dialog":"ep4zG","../canvas":"7FRqY","@msrvida/sanddance-react":"73dPQ","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"k9WKc":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Snapshots", ()=>Snapshots); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _dialog = require("../controls/dialog"); -var _group = require("../controls/group"); -var _iconButton = require("../controls/iconButton"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _language = require("../language"); -function _Snapshots(_props) { - class __Snapshots extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = { - confirmation: null, - title: "", - description: "", - image: null, - bgColor: null, - insight: null - }; - } - render() { - const items = [ - { - key: "clear", - text: (0, _language.strings).buttonClearSnapshots, - onClick: ()=>this.setState({ - confirmation: { - buttonText: (0, _language.strings).buttonClearSnapshots, - handler: ()=>this.props.onClearSnapshots() - } - }), - disabled: this.props.snapshots.length === 0 - }, - ]; - if (this.props.getTopActions) items.push.apply(items, this.props.getTopActions(this.props.snapshots)); - const ref = (0, _base.base).react.createRef(); - this.props.explorer.dialogFocusHandler.focus = ()=>{ - var _a; - (_a = ref.current) === null || _a === void 0 || _a.focus(); - }; - return (0, _base.base).react.createElement((0, _group.Group), { - className: "sanddance-snapshots", - label: (0, _language.strings).labelSnapshots - }, (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - componentRef: ref, - text: (0, _language.strings).buttonCreateSnapshot, - onClick: (e)=>this.props.editor.editSnapshot(), - split: true, - menuProps: { - items - } - }), this.props.getChildren && this.props.getChildren(this.props.snapshots), this.state.confirmation && (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: false, - buttons: (0, _base.base).react.createElement((0, _base.base).fluentUI.PrimaryButton, { - key: 0, - onClick: (e)=>{ - this.setState({ - confirmation: null + else this.presenter.morphChartsRenderResult.update({ + cubes: null }); - this.state.confirmation.handler(); - }, - iconProps: { - iconName: "Delete" - }, - text: this.state.confirmation.buttonText - }), - onDismiss: ()=>this.setState({ - confirmation: null - }) - }, (0, _language.strings).labelConfirmation), (0, _base.base).react.createElement("div", null, this.props.snapshots.map((snapshot, i)=>{ - const actions = this.props.getActions && this.props.getActions(snapshot, i) || []; - actions.push({ - iconButtonProps: { - themePalette: this.props.themePalette, - title: (0, _language.strings).buttonEditSnapshot, - onClick: (e)=>this.props.editor.editSnapshot(snapshot, i), - iconName: "Edit" - } - }); - if (this.props.snapshots.length > 1) actions.push({ - iconButtonProps: { - disabled: i === 0, - themePalette: this.props.themePalette, - title: (0, _language.strings).buttonMoveUp, - onClick: (e)=>this.props.onMoveUp(i), - iconName: "SortUp" - } - }, { - iconButtonProps: { - disabled: i > this.props.snapshots.length - 2, - themePalette: this.props.themePalette, - title: (0, _language.strings).buttonMoveDown, - onClick: (e)=>this.props.onMoveDown(i), - iconName: "SortDown" + break; } - }); - actions.push({ - iconButtonProps: { - themePalette: this.props.themePalette, - title: (0, _language.strings).buttonDeleteSnapshot, - onClick: ()=>this.setState({ - confirmation: { - buttonText: (0, _language.strings).buttonDeleteSnapshot, - handler: ()=>this.props.onRemoveSnapshot(i) - } - }), - iconName: "Delete" + case (0, _animator.DataLayoutChange).refine: + { + //save cube colors + const oldColorContext = this.colorContexts[this.currentColorContext]; + let colorMap; + this.presenter.morphChartsRenderResult.update({ + cubes: null + }); + yield this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { + preStage: (stage, cubeLayer)=>{ + //save off the spec colors + colorMap = cubeLayer.unitColorMap; + cubeLayer.unitColorMap = oldColorContext.colorMap; + this.preStage(stage, cubeLayer); + }, + onPresent: ()=>{ + //save new legend + const newColorContext = { + colorMap, + legend: _vegaMorphcharts.util.clone(this.presenter.stage.legend), + legendElement: this.presenter.getElement(_vegaMorphcharts.PresenterElement.legend).children[0] + }; + //apply old legend + this.applyLegendColorContext(oldColorContext); + this.changeColorContexts([ + oldColorContext, + newColorContext + ]); + this.onPresent(); + } + })); + //narrow the filter only if it is different + if (!_searchExpression.compare(this.insight.filter, filter)) this.insight.filter = _searchExpression.narrow(this.insight.filter, filter); + if (this.options.onDataFilter) this.options.onDataFilter(this.insight.filter, this._dataScope.currentData()); + break; } - }); - return (0, _base.base).react.createElement("div", { - key: i, - className: (0, _sanddanceReact.util).classList("snapshot", i === this.props.selectedSnapshotIndex && "selected") - }, (0, _base.base).react.createElement("div", { - onClick: (e)=>this.props.onSnapshotClick(snapshot, i) - }, (0, _base.base).react.createElement("div", { - className: "title" - }, snapshot.title), (0, _base.base).react.createElement("div", { - className: "thumbnail" - }, (0, _base.base).react.createElement("img", { - title: snapshot.description, - src: snapshot.image, - style: { - backgroundColor: snapshot.bgColor + case (0, _animator.DataLayoutChange).reset: + { + const colorContext = { + colorMap: null, + legend: null, + legendElement: null + }; + this.changeColorContexts([ + colorContext + ]); + this.presenter.morphChartsRenderResult.update({ + cubes: null + }); + yield this.renderNewLayout({}, Object.assign(Object.assign({}, this.setup || {}), { + onPresent: ()=>{ + //color needs to change instantly + (0, _colorCubes.populateColorContext)(colorContext, this.presenter); + this.onPresent(); + } + })); + delete this.insight.filter; + if (this.options.onDataFilter) this.options.onDataFilter(null, null); + break; } - }))), (0, _base.base).react.createElement(Actions, { - actions: actions, - snapshot: snapshot - })); - })))); - } + } + if (this.options.onSelectionChanged) { + const sel = this.getSelection(); + this.options.onSelectionChanged(sel && sel.search || null, 0, sel && sel.selectedData || null); + } + }); } - return new __Snapshots(_props); -} -const Snapshots = _Snapshots; -function Actions(props) { - return (0, _base.base).react.createElement("div", { - className: "actions" - }, props.actions.map((action, i)=>{ - if (action.iconButtonProps) return (0, _base.base).react.createElement((0, _iconButton.IconButton), Object.assign({ - key: i - }, action.iconButtonProps)); - if (action.element) return action.element; - })); -} - -},{"../base":"9M4eu","../controls/dialog":"ep4zG","../controls/group":"hggjF","../controls/iconButton":"6gzbB","@msrvida/sanddance-react":"73dPQ","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2vaDJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "TransitionEditor", ()=>TransitionEditor); -parcelHelpers.export(exports, "getTransition", ()=>getTransition); -parcelHelpers.export(exports, "syncTansitionDurations", ()=>syncTansitionDurations); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _group = require("../controls/group"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _dropdown = require("../controls/dropdown"); -var _iconButton = require("../controls/iconButton"); -var _button = require("../controls/button"); -const positions = [ - [ - "x", - (0, _language.strings).labelAliasX - ], - [ - "y", - (0, _language.strings).labelAliasY - ], - [ - "z", - (0, _language.strings).labelAliasZ - ], -]; -const autoScrubInterval = 50; //tune to get the smoothest animation while able to do an update pass through React -function _TransitionEditor(_props) { - class __TransitionEditor extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.state = Object.assign({ - scrub: 100, - pauseDisabled: true - }, this.initialCalc(props.transitionDurations)); - this.autoScrubber = new AutoScrubber(autoScrubInterval, (direction, interval)=>{ - const totalMs = this.state.totalTransition * 1000; - const currentMs = this.state.scrub / 100 * totalMs; - const scrubMs = currentMs + direction * interval; - let scrub = scrubMs / totalMs * 100; - if (direction < 0 && scrub <= 0) { - scrub = 0; - this.autoScrubber.stop(); - } - if (direction > 0 && scrub >= 100) { - scrub = 100; - this.autoScrubber.stop(); - } - this.setScrubState(scrub); - }); - } - initialCalc(transitionDurations) { - const totalTransition = (transitionDurations.position + transitionDurations.stagger) / 1000; - const staggerPercent = transitionDurations.stagger === 0 ? 1 : transitionDurations.stagger / (totalTransition * 1000) * 100; - const viewTransition = transitionDurations.view / 1000; - return { - totalTransition, - staggerPercent, - viewTransition - }; - } - setScrubState(scrub) { - const { morphChartsRenderResult , morphchartsref } = this.props.explorer.viewer.presenter; - morphchartsref.core.renderer.transitionTime = scrub / 100; - morphChartsRenderResult.setTransitionTimeAxesVisibility(); - scrub = Math.round(scrub); - this.setState({ - scrub, - pauseDisabled: this.autoScrubber.isStopped() + convertSearchToSet() { + if (this._dataScope.selection) { + const s = new Set(); + let found = false; + this._dataScope.selection.included.forEach((o, i)=>{ + s.add(o[0, _constants.GL_ORDINAL]); + found = true; }); + if (!found) s.add(-1); + return s; } - setDurations() { - setTimeout(()=>{ - const { props , state } = this; - const { totalTransition , staggerPercent , viewTransition } = state; - const stagger = totalTransition * staggerPercent / 100; - const { transitionDurations } = props; - transitionDurations.position = (totalTransition - stagger) * 1000; - transitionDurations.stagger = stagger * 1000; - transitionDurations.view = viewTransition * 1000; - syncTansitionDurations(props.explorer.viewer, transitionDurations); - props.changeSetup(null, false); + } + convertSetToSearch(s) { + const search = { + expressions: [] + }; + s.forEach((value)=>{ + search.expressions.push({ + name: (0, _constants.GL_ORDINAL), + operator: '==', + value, + clause: '||' }); - } - render() { - const { props , state } = this; - const { explorer , transitionDurations , changeSetup } = props; - const sliderRef = (0, _base.base).react.createRef(); - explorer.dialogFocusHandler.focus = ()=>{ - var _a; - return (_a = sliderRef.current) === null || _a === void 0 ? void 0 : _a.focus(); + }); + return search; + } + getSpecColumnsWithFilteredStats() { + if (!this._dataScope.hasFilteredData()) return this._specColumns; + const roles = [ + 'color', + 'facet', + 'group', + 'size', + 'sort', + 'sum', + 'x', + 'y', + 'z' + ]; + const specColumns = Object.assign({}, this._specColumns); + roles.forEach((r)=>{ + if (specColumns[r]) { + const column = Object.assign({}, specColumns[r]); + column.stats = this.getColumnStats(column); + specColumns[r] = column; + } + }); + return specColumns; + } + renderNewLayout(signalValues, presenterConfig, view) { + return __awaiter(this, void 0, void 0, function*() { + const currData = this._dataScope.currentData(); + const context = { + specColumns: this.getSpecColumnsWithFilteredStats(), + insight: this.insight, + specViewOptions: Object.assign(Object.assign({}, this.options), { + zAxisOptions: { + showZAxis: true, + zIndex: zAxisZindex + }, + collapseFacetAxes: true + }) }; - return (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelTransition - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - componentRef: sliderRef, - label: (0, _language.strings).labelTransitionScrubber, - min: 0, - max: 100, - valueFormat: (0, _language.strings).percentValueFormat, - value: state.scrub, - onChange: (scrub)=>{ - this.autoScrubber.stop(); - this.setScrubState(scrub); + const specResult = (0, _sanddanceSpecs.build)(context, currData); + if (!specResult.errors) { + const uiValues = (0, _signals.extractSignalValuesFromView)(this.vegaViewGl, this.vegaSpec); + (0, _signals.applySignalValues)(Object.assign(Object.assign({}, uiValues), signalValues), specResult.vegaSpec); + (0, _signals.unbindSignalUI)(specResult.vegaSpec); + this.vegaSpec = specResult.vegaSpec; + this.options.onVegaSpec && this.options.onVegaSpec(this.vegaSpec); + this.specCapabilities = specResult.specCapabilities; + const config = this.createConfig(presenterConfig); + this._lastPresenterConfig = config.presenterConfig; + if (view) config.getView = ()=>view; + if (!didRegisterColorSchemes) { + (0, _colorSchemes.registerColorSchemes)(_vegaMorphcharts.base.vega); + didRegisterColorSchemes = true; } - }), (0, _base.base).react.createElement((0, _iconButton.IconButton), { - themePalette: props.themePalette, - title: (0, _language.strings).buttonTransitionReverse, - iconName: "PlayReverseResume", - onClick: ()=>{ - this.autoScrubber.toggleScrubbing(-1); - if (state.scrub === 0) this.setState({ - scrub: 100 + try { + if (this.vegaViewGl) this.vegaViewGl.finalize(); + const runtime = _vegaMorphcharts.base.vega.parse(this.vegaSpec); + this.vegaViewGl = new _vegaMorphcharts.ViewGl(runtime, config).renderer('morphcharts').initialize(this.element); + yield this.vegaViewGl.runAsync(); + const handler = (n, v)=>{ + this._characterSet.resetCharacterSet(true); + }; + this.vegaSpec.signals.forEach((s)=>{ + this.vegaViewGl.addSignalListener(s.name, handler); }); + //capture new color color contexts via signals + this.configForSignalCapture(config.presenterConfig); + } catch (e) { + specResult.errors = [ + e.message + ]; } - }), (0, _base.base).react.createElement((0, _iconButton.IconButton), { - themePalette: props.themePalette, - title: (0, _language.strings).buttonTransitionPause, - iconName: "Pause", - onClick: ()=>{ - this.autoScrubber.togglePause(); - }, - disabled: state.pauseDisabled - }), (0, _base.base).react.createElement((0, _iconButton.IconButton), { - themePalette: props.themePalette, - title: (0, _language.strings).buttonTransitionPlay, - iconName: "PlayResume", - onClick: ()=>{ - this.autoScrubber.toggleScrubbing(1); - if (state.scrub === 100) this.setState({ - scrub: 0 - }); - } - })), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelTransitionOptions - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - label: (0, _language.strings).labelHoldCamera, - checked: explorer.state.holdCamera, - onChange: (e, holdCamera)=>{ - changeSetup({ - holdCamera - }, false); - } - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.ChoiceGroup, { - label: (0, _language.strings).labelTransitionStaggerBy, - selectedKey: props.transitionType, - options: [ - { - key: "ordinal", - text: (0, _language.strings).labelTransitionStaggerByOrdinal - }, - { - key: "column", - text: (0, _language.strings).labelTransitionStaggerByColumn - }, + if (!specResult.errors) (0, _headers.ensureHeaders)(this.presenter, this.options.language.headers); + } + if (specResult.errors) { + if (this.options.onError) this.options.onError(specResult.errors); + else if (this.presenter.logger) this.presenter.logger(`errors rendering Vega spec:${specResult.errors.join('\n')}`); + } + return specResult; + }); + } + /** + * Render the same layout with new options. + * @param newViewerOptions New options object. + */ renderSameLayout(newViewerOptions) { + const colorContext = this.colorContexts[this.currentColorContext]; + this.applyLegendColorContext(colorContext); + if (newViewerOptions) { + if (newViewerOptions.colors) { + //set theme colors PresenterConfig + const mcColors = this.getMorphChartsColors(); + this.presenter.configColors(mcColors); + this._lastPresenterConfig.morphChartsColors = mcColors; + } + this.options = _vegaMorphcharts.util.deepMerge(this.options, newViewerOptions); + } + this.presenter.morphChartsRenderResult.getCubeLayer().unitColorMap = colorContext.colorMap; + this.presenter.morphChartsRenderResult.update({ + cubes: this.convertSearchToSet() + }); + } + getView(view) { + if (view === undefined) { + if (this.presenter.view === null) return defaultView; + else return this.presenter.view; + } else return view; + } + transformData(values, transform) { + try { + const runtime = _vegaMorphcharts.base.vega.parse({ + $schema: 'https://vega.github.io/schema/vega/v4.json', + data: [ { - key: "position", - text: (0, _language.strings).labelTransitionStaggerByPosition - }, - ], - onChange: (e, o)=>{ - const transitionType = o.key; - changeSetup({ - transitionType - }, true); - } - })), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelTransitionStaggerOptions - }, (()=>{ - switch(props.transitionType){ - case "column": - return (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: props.compactUI, - label: (0, _language.strings).labelTransitionStaggerByColumn, - options: getColumnOptions(props, props.transitionColumn.name), - onChange: (e, o)=>{ - changeSetup({ - transitionColumn: o.data - }, true); - } - }); - case "position": - return (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: props.compactUI, - label: (0, _language.strings).labelTransitionStaggerByPosition, - options: positions.map(([key, text])=>{ - return { - key, - text, - selected: props.transitionDimension === key - }; - }), - onChange: (e, o)=>{ - changeSetup({ - transitionDimension: o.key - }, true); - } - }); - } - })(), (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - label: (0, _language.strings).labelTransitionStaggerReverse, - checked: props.transitionReverse, - onChange: (e, transitionReverse)=>changeSetup({ - transitionReverse - }, true) - })), (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelTransitionDurations - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - label: (0, _language.strings).labelTransitionDuration, - onChange: (totalTransition)=>{ - this.setState({ - totalTransition - }); - this.setDurations(); - }, - min: 0, - max: 5, - step: 0.1, - value: state.totalTransition - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - label: (0, _language.strings).labelTransitionStagger, - onChange: (staggerPercent)=>{ - this.setState({ - staggerPercent + name: 'source', + values, + transform + } + ] + }); + new _vegaMorphcharts.ViewGl(runtime).run(); + } catch (e) { + // continue regardless of error + } + return values; + } + /** + * Render data into a visualization. + * @param insightSetup InsightSetup object to create a visualization rendering. + * @param data Array of data objects. + * @param renderOptions Optional RenderOptions object. + */ render(insightSetup_1, data_1) { + return __awaiter(this, arguments, void 0, function*(insightSetup, data, renderOptions = {}) { + const { insight, setup } = insightSetup; + let result; + //see if refine expression has changed + if (!_searchExpression.compare(insight.filter, this.insight.filter)) { + const transitionDurations = (setup === null || setup === void 0 ? void 0 : setup.transitionDurations) || _vegaMorphcharts.defaults.defaultPresenterConfig.transitionDurations; + const renderTime = transitionDurations.position + transitionDurations.stagger; + const allowAsyncRenderTime = renderTime + this.options.filterRenderingTimerPadding; + if (insight.filter) { + //refining + result = yield this._render(insightSetup, data, renderOptions, true); + this.presenter.animationQueue(()=>{ + this.filter(insight.filter, renderOptions.rebaseFilter && renderOptions.rebaseFilter()); + }, allowAsyncRenderTime, { + waitingLabel: 'layout before refine', + handlerLabel: 'refine after layout' }); - this.setDurations(); - }, - min: 0, - max: 100, - valueFormat: (0, _language.strings).percentValueFormat, - value: state.staggerPercent - }), (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - label: (0, _language.strings).labelTransitionCamera, - onChange: (viewTransition)=>{ - this.setState({ - viewTransition + } else { + //not refining + this._dataScope.setFilteredData(null); + result = yield this._render(insightSetup, data, renderOptions, true); + this.presenter.animationQueue(()=>{ + this.reset(); + }, allowAsyncRenderTime, { + waitingLabel: 'layout before reset', + handlerLabel: 'reset after layout' }); - this.setDurations(); - }, - min: 0, - max: 5, - step: 0.1, - value: state.viewTransition - }), (0, _base.base).react.createElement((0, _button.Button), { - themePalette: props.themePalette, - onClick: ()=>{ - const defaults = (0, _sanddanceReact.SandDance).VegaMorphCharts.defaults.defaultPresenterConfig.transitionDurations; - const { position , stagger , view } = defaults; - transitionDurations.position = position; - transitionDurations.stagger = stagger; - transitionDurations.view = view; - this.setState(Object.assign({}, this.initialCalc(transitionDurations))); - this.setDurations(); - }, - text: (0, _language.strings).buttonResetToDefault - }))); - } + } + } else result = yield this._render(insightSetup, data, renderOptions, false); + return result; + }); } - return new __TransitionEditor(_props); -} -const TransitionEditor = _TransitionEditor; -function groupOptions(sectionName, columns, selectedKey) { - const options = columns.map((column)=>{ - const option = { - key: `column:${column.name}`, - text: column.name, - data: column, - selected: column.name === selectedKey + shouldViewstateTransition(newInsight, oldInsight) { + if (!oldInsight.columns) return false; + if (oldInsight.chart !== newInsight.chart) return true; + if (oldInsight.size.height !== newInsight.size.height) return true; + if (oldInsight.size.width !== newInsight.size.width) return true; + if (oldInsight.columns.facet !== newInsight.columns.facet) return true; + return false; + } + configForSignalCapture(presenterConfig) { + const colorContext = { + colorMap: null, + legend: null, + legendElement: null }; - return option; - }); - if (options.length) { - const option = { - key: sectionName, - text: sectionName, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header + //now be ready to capture color changing signals + presenterConfig.preStage = (stage, cubeLayer)=>{ + if (this._shouldSaveColorContext()) //save off the colors from Vega layout + colorContext.colorMap = cubeLayer.unitColorMap; + this.preStage(stage, cubeLayer); + }; + presenterConfig.onPresent = ()=>{ + if (this._shouldSaveColorContext()) { + (0, _colorCubes.populateColorContext)(colorContext, this.presenter); + this.changeColorContexts([ + colorContext + ]); + this._dataScope.deselect(); + } + this.onPresent(); }; - options.unshift(option); } - return options; -} -function getColumnOptions(props, selectedKey) { - const quantitativeGroup = groupOptions((0, _language.strings).selectNumeric, props.quantitativeColumns, selectedKey); - const categoricGroup = groupOptions((0, _language.strings).selectNonNumeric, props.categoricalColumns, selectedKey); - return quantitativeGroup.concat(categoricGroup); -} -function getTransition(state) { - const reverse = state.transitionReverse; - switch(state.transitionType){ - case "ordinal": - return { - type: "ordinal", - reverse - }; - case "column": - return { - type: "column", - column: state.transitionColumn, - reverse + onPresent() { + var _a; + if ((_a = this.setup) === null || _a === void 0 ? void 0 : _a.transition) (0, _transition.assignTransitionStagger)(this.setup.transition, this._dataScope.currentData(), this.convertSearchToSet(), this.presenter); + this.options.onPresent && this.options.onPresent(); + } + _render(insightSetup, data, renderOptions, forceNewCharacterSet) { + return __awaiter(this, void 0, void 0, function*() { + const { insight, setup } = insightSetup; + if (this._tooltip) { + this._tooltip.destroy(); + this._tooltip = null; + } + if (this._dataScope.setData(data, renderOptions.columns)) //apply transform to the data + this.transformData(data, insight.transform); + this._specColumns = (0, _sanddanceSpecs.getSpecColumns)(insight, this._dataScope.getColumns(renderOptions.columnTypes)); + const ordinalMap = (0, _ordinal.assignOrdinals)(this._specColumns, data, renderOptions.ordinalMap); + this._characterSet.resetCharacterSet(forceNewCharacterSet, this.insight, insight); + this.insight = _vegaMorphcharts.util.clone(insight); + this.setup = setup; + this._shouldSaveColorContext = ()=>!renderOptions.initialColorContext; + const colorContext = renderOptions.initialColorContext || { + colorMap: null, + legend: null, + legendElement: null }; - case "position": - return { - type: "position", - dimension: state.transitionDimension, - reverse + const specResult = yield this.renderNewLayout(insight.signalValues, Object.assign(Object.assign({}, setup || {}), { + preStage: (stage, cubeLayer)=>{ + if (this._shouldSaveColorContext()) //save off the colors from Vega layout + colorContext.colorMap = cubeLayer.unitColorMap; + else //apply passed colorContext + cubeLayer.unitColorMap = colorContext.colorMap; + //if items are selected, repaint + const hasSelectedData = !!this._dataScope.hasSelectedData(); + //const hasActive = !!this._dataScope.active; + hasSelectedData || this._dataScope.active; + this.preStage(stage, cubeLayer); + }, + onPresent: ()=>{ + if (this._shouldSaveColorContext()) { + (0, _colorCubes.populateColorContext)(colorContext, this.presenter); + this.changeColorContexts([ + colorContext + ]); + } else //apply passed colorContext + this.applyLegendColorContext(colorContext); + this.onPresent(); + }, + shouldViewstateTransition: ()=>this.shouldViewstateTransition(insight, this.insight) + }), this.getView(insight.view)); + //future signal changes should save the color context + this._shouldSaveColorContext = ()=>!renderOptions.discardColorContextUpdates || !renderOptions.discardColorContextUpdates(); + this._details.render(); + const result = { + ordinalMap, + specResult }; + return result; + }); } -} -function syncTansitionDurations(viewer, transitionDurations) { - var _a, _b; - const config = (_b = (_a = viewer === null || viewer === void 0 ? void 0 : viewer.presenter) === null || _a === void 0 ? void 0 : _a.morphchartsref) === null || _b === void 0 ? void 0 : _b.core.config; - if (config) { - const { position , stagger } = transitionDurations; - config.transitionDuration = position; - config.transitionStaggering = stagger; - } -} -class AutoScrubber { - constructor(interval, onInterval){ - this.interval = interval; - this.onInterval = onInterval; - } - getSignedInterval() { - return this.interval * this.direction; - } - toggleScrubbing(direction) { - if (this.isScrubbing() && direction === this.direction) this.pause(); - else this.start(direction); - } - isPaused() { - return !this.isScrubbing() && this.direction !== undefined; + overrideAxisLabels(stage) { + // if (this._specColumns.x && this._specColumns.x.type === 'date') { + // stage.axes.x.forEach(axis => makeDateRange( + // axis.tickText, + // this.getColumnStats(this._specColumns.x) + // )); + // } + // if (this._specColumns.y && this._specColumns.y.type === 'date') { + // stage.axes.y.forEach(axis => makeDateRange( + // axis.tickText, + // this.getColumnStats(this._specColumns.y) + // )); + // } } - isStopped() { - return !this.isScrubbing() && this.direction === undefined; + preLayer(stage) { + //convert ticks + let axisRole; + for(axisRole in stage.axes){ + const capability = this.specCapabilities.roles.filter((r)=>r.role === axisRole)[0]; + if (capability && (capability.axisSelectionBetweenTicks || capability.axisSelection === 'exact')) (0, _axisSelection.moveTicksBetween)(stage.axes[axisRole]); + } } - isScrubbing() { - return this.autoScrubTimer !== undefined; + preStage(stage, cubeLayer) { + this.overrideAxisLabels(stage); + this._axisSelection = new (0, _axisSelection.AxisSelection)(this.specCapabilities, this._specColumns, stage); + (0, _legend.finalizeLegend)(this.insight.colorBin, this._specColumns.color, stage.legend, this.options.language); + if (this.options.onStage) this.options.onStage(stage); } - togglePause() { - if (this.isScrubbing()) this.pause(); - else if (this.direction) this.start(this.direction); + onCubeClick(e, cube) { + this.options.onCubeClick && this.options.onCubeClick(e, cube); + const hasSelectedData = this._dataScope.hasSelectedData(); + if (hasSelectedData && this._dataScope.selection.included.length > 1) { + //if active is within selection, keep the selection and activate the one. + const indexWithinSelection = this._dataScope.ordinalIndexWithinSelection(cube.ordinal); + if (indexWithinSelection.index >= 0) { + this.activate(indexWithinSelection.datum); + this._details.populate(this._dataScope.selection, indexWithinSelection.index); + if (this.options.onSelectionChanged) { + const sel = this.getSelection(); + this.options.onSelectionChanged(sel.search, indexWithinSelection.index, sel.selectedData); + } + return; + } + } + if (hasSelectedData && this._dataScope.selection.included.length === 1 && this._dataScope.selection.included[0][0, _constants.GL_ORDINAL] === cube.ordinal) { + this.deselect(); + return; + } + const search = { + name: (0, _constants.GL_ORDINAL), + operator: '==', + value: cube.ordinal + }; + this.select(search); } - start(direction) { - this.direction = direction; - if (!this.isScrubbing()) this.autoScrubTimer = setInterval(()=>this.onInterval(this.direction, this.interval), this.interval); + onCubeHover(event, cube) { + var _a, _b; + if (this._tooltip) { + this._tooltip.destroy(); + this._tooltip = null; + } + if (!cube) return; + const currentData = this._dataScope.currentData(); + const index = (0, _ordinal.getDataIndexOfCube)(cube, currentData); + if (index >= 0) { + const dataItem = (0, _tooltip.cleanDataItem)(((_a = this.options.tooltipOptions) === null || _a === void 0 ? void 0 : _a.prepareDataItem(currentData[index])) || currentData[index]); + const tooltipCreateOptions = { + dataItem, + event + }; + if ((_b = this.options.tooltipOptions) === null || _b === void 0 ? void 0 : _b.create) this._tooltip = this.options.tooltipOptions.create(tooltipCreateOptions); + else this._tooltip = new (0, _tooltip.Tooltip)(Object.assign(Object.assign({}, tooltipCreateOptions), { + cssPrefix: this.presenter.style.cssPrefix + })); + } } - pause() { - clearInterval(this.autoScrubTimer); - this.autoScrubTimer = undefined; + onTextHover(e, t) { + //return true if highlight color is different + if (!t || !this.options.getTextColor || !this.options.getTextHighlightColor) return false; + return !_vegaMorphcharts.util.colorIsEqual(this.options.getTextColor(t), this.options.getTextHighlightColor(t)); } - stop() { - this.pause(); - this.direction = undefined; + getMorphChartsColors() { + const { colors } = this.options; + return { + activeItemColor: colors.activeCube, + axesGridBackgroundColor: colors.backgroundColor, + axesGridHighlightColor: colors.axisSelectHighlight, + axesGridMajorColor: colors.gridLine, + axesGridMinorColor: colors.gridLine, + axesGridZeroColor: colors.gridLine, + axesTextHeadingColor: colors.axisText, + axesTextLabelColor: colors.axisText, + axesTextTitleColor: colors.axisText, + backgroundColor: colors.backgroundColor, + textBorderColor: colors.backgroundColor, + textColor: colors.axisText + }; } -} - -},{"../base":"9M4eu","../controls/group":"hggjF","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","../controls/dropdown":"2Udzo","../controls/iconButton":"6gzbB","../controls/button":"j0llx","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6D4Qi":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Explorer", ()=>Explorer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("./base"); -var _canvas = require("./canvas"); -var _clickableTextLayer = require("./clickableTextLayer"); -var _colorMap = require("./colorMap"); -var _colorScheme = require("./colorScheme"); -var _columns = require("./columns"); -var _dataScope = require("./controls/dataScope"); -var _dialog = require("./controls/dialog"); -var _iconButton = require("./controls/iconButton"); -var _sidebar = require("./controls/sidebar"); -var _topbar = require("./controls/topbar"); -var _dataLoader = require("./dataLoader"); -var _defaults = require("./defaults"); -var _chart = require("./dialogs/chart"); -var _color = require("./dialogs/color"); -var _dataBrowser = require("./dialogs/dataBrowser"); -var _history = require("./dialogs/history"); -var _search = require("./dialogs/search"); -var _settings = require("./dialogs/settings"); -var _snapshotEditor = require("./dialogs/snapshotEditor"); -var _snapshots = require("./dialogs/snapshots"); -var _transition = require("./dialogs/transition"); -var _interfaces = require("./interfaces"); -var _language = require("./language"); -var _mouseEvent = require("./mouseEvent"); -var _partialInsight = require("./partialInsight"); -var _themes = require("./themes"); -var _searchGroups = require("./searchGroups"); -var _chartRecommender = require("@msrvida/chart-recommender"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _renderer = require("./controls/renderer"); -var _backgroundImageEditor = require("./dialogs/backgroundImageEditor"); -function _Explorer(_props) { - class __Explorer extends (0, _base.base).react.Component { - constructor(props){ - super(props); - this.dialogFocusHandler = {}; - this.state = (0, _defaults.initialExplorerState)(props); - this.imageHolder = { - img: null, - backgroundImageColumnBounds: [], - showBackgroundImage: false - }; - this.snapshotThumbWidth = (0, _defaults.snapshotThumbWidth); - this.discardColorContextUpdates = true; - this.updateViewerOptions(Object.assign(Object.assign({}, (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone((0, _sanddanceReact.SandDance).Viewer.defaultViewerOptions)), props.viewerOptions)); - } - finalize() { - if (this.viewer) this.viewer.finalize(); - } - updateViewerOptions(viewerOptions) { - this.viewerOptions = Object.assign(Object.assign({}, (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge((0, _defaults.defaultViewerOptions), { - tooltipOptions: { - prepareDataItem: (item)=>{ - const ret = {}; - for(const columnName in item)if (this.state.tooltipExclusions.indexOf(columnName) < 0) ret[columnName] = item[columnName]; - return ret; - } - } - }, this.viewerOptions, viewerOptions)), { - onColorContextChange: ()=>this.manageColorToolbar(), - onDataFilter: (filter, filteredData)=>{ - const selectedItemIndex = Object.assign({}, this.state.selectedItemIndex); - selectedItemIndex[(0, _dataScope.DataScopeId).FilteredData] = 0; - this.changeInsight({ - filter - }, { - label: this.historicFilterChange, - omit: !this.historicFilterChange - }); - this.historicFilterChange = null; - this.setState({ - filteredData, - selectedItemIndex - }); - if (this.state.sideTabId === (0, _interfaces.SideTabId).Data && this.state.dataScopeId === (0, _dataScope.DataScopeId).FilteredData) //make sure item is active - requestAnimationFrame(()=>filteredData && this.silentActivation(filteredData[0])); - viewerOptions && viewerOptions.onDataFilter && viewerOptions.onDataFilter(filter, filteredData); - }, - onSelectionChanged: (newSearch, index, selectedData)=>{ - if (this.ignoreSelectionChange) return; - const selectedItemIndex = Object.assign({}, this.state.selectedItemIndex); - selectedItemIndex[(0, _dataScope.DataScopeId).SelectedData] = index || 0; - let { search } = this.state; - const { sideTabId } = this.state; - if (newSearch) search = (0, _searchGroups.createInputSearch)(newSearch); - this.setState({ - search, - selectedItemIndex, - sideTabId - }); - viewerOptions && viewerOptions.onSelectionChanged && viewerOptions.onSelectionChanged(newSearch, index, selectedData); - }, - onAxisClick: (e, search)=>{ - this.toggleableSearch(e, search); - viewerOptions && viewerOptions.onAxisClick && viewerOptions.onAxisClick(e, search); - }, - onLegendHeaderClick: (e)=>{ - const pos = (0, _mouseEvent.getPosition)(e); - const specRole = this.state.specCapabilities && this.state.specCapabilities.roles.filter((r)=>r.role === "color")[0]; - const positionedColumnMapProps = Object.assign(Object.assign({}, this.getColumnMapBaseProps()), { - collapseLabel: true, - container: this.div, - selectedColumnName: this.state.columns["color"], - onDismiss: ()=>{ - this.setState({ - positionedColumnMapProps: null - }); - }, - specRole, - left: pos.left - this.div.clientLeft, - top: pos.top - this.div.clientTop - }); - this.setState({ - positionedColumnMapProps - }); - }, - onLegendRowClick: (e, legendRow)=>{ - this.toggleableSearch(e, legendRow.search); - viewerOptions && viewerOptions.onLegendRowClick && viewerOptions.onLegendRowClick(e, legendRow); - }, - onError: (errors)=>{ - this.setState({ - errors - }); - viewerOptions && viewerOptions.onError && viewerOptions.onError(errors); - }, - onBeforeCreateLayers: (stage, specCapabilities)=>{ - (0, _clickableTextLayer.attachSpecRoleToAxisTitle)(stage, specCapabilities); - }, - getTextColor: (o)=>{ - if (o.specRole) return (0, _sanddanceReact.SandDance).VegaMorphCharts.util.colorFromString(this.viewerOptions.colors.clickableText); - else if (o.metaData && o.metaData.search) return (0, _sanddanceReact.SandDance).VegaMorphCharts.util.colorFromString(this.viewerOptions.colors.searchText); - else return o.color; - }, - getTextHighlightColor: (o)=>{ - if (o.specRole) return (0, _sanddanceReact.SandDance).VegaMorphCharts.util.colorFromString(this.viewerOptions.colors.clickableTextHighlight); - else if (o.metaData && o.metaData.search) return (0, _sanddanceReact.SandDance).VegaMorphCharts.util.colorFromString(this.viewerOptions.colors.searchTextHighlight); - else return [ - 0, - 0, - 0, - 0 - ]; - }, - onTextClick: (e, text)=>{ - if (e && text) { - const pos = (0, _mouseEvent.getPosition)(e); - const rect = this.viewer.element.getBoundingClientRect(); - pos.left += rect.left; - pos.top += rect.top; - const { specRole } = text; - if (pos && specRole) { - const positionedColumnMapProps = Object.assign(Object.assign({}, this.getColumnMapBaseProps()), { - collapseLabel: true, - container: this.div, - selectedColumnName: this.state.columns[specRole.role], - onDismiss: ()=>{ - this.setState({ - positionedColumnMapProps: null - }); - }, - specRole, - left: pos.left, - top: pos.top - }); - this.setState({ - positionedColumnMapProps - }); - } else this.setState({ - positionedColumnMapProps: null - }); - } - }, - onNewViewStateTarget: ()=>this.newViewStateTarget - }); - if (this.viewer && this.viewer.presenter) { - const newPresenterStyle = (0, _sanddanceReact.SandDance).util.getPresenterStyle(this.viewerOptions); - const mergePrenterStyle = Object.assign(Object.assign({}, this.viewer.presenter.style), newPresenterStyle); - this.viewer.presenter.style = mergePrenterStyle; - this.viewer.options = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge(this.viewer.options, this.props.viewerOptions, this.viewerOptions); - } - } - signal(signalName, signalValue, newViewStateTarget) { - switch(signalName){ - case (0, _sanddanceReact.SandDance).constants.SignalNames.ColorBinCount: - case (0, _sanddanceReact.SandDance).constants.SignalNames.ColorReverse: - case (0, _sanddanceReact.SandDance).constants.SignalNames.MarkOpacity: - this.discardColorContextUpdates = false; - break; - } - this.newViewStateTarget = newViewStateTarget; - this.viewer.vegaViewGl.signal(signalName, signalValue); - this.viewer.vegaViewGl.runAsync().then(()=>{ - //deeply set the state without a state change. This prevents a redraw if re-rendered - if (this.state.signalValues) this.state.signalValues[signalName] = signalValue; - this.discardColorContextUpdates = true; - this.newViewStateTarget = undefined; - this.props.onSignalChanged && this.props.onSignalChanged(signalName, signalValue); - }); - } - manageColorToolbar() { - const canRemap = this.viewer.colorContexts && this.viewer.colorContexts.length > 1; - (0, _colorMap.applyColorButtons)(this.viewer.presenter, !!this.state.columns.color, { - themePalette: (0, _themes.themePalettes)[this.props.theme || ""], - canRemap, - isRemap: canRemap && this.viewer.currentColorContext > 0, - colorMapHandler: (remap)=>{ - this.viewer.currentColorContext = ~~remap; - this.viewer.renderSameLayout(); - this.manageColorToolbar(); - } - }); - } - getInsight() { - return this.viewer.getInsight(); - } - getSetup() { - return { - camera: this.state.holdCamera ? "hold" : this.state.camera, - renderer: this.state.renderer, - transition: (0, _transition.getTransition)(this.state), - transitionDurations: this.state.transitionDurations - }; - } - setSetup(setup, newState) { - newState.camera = undefined; - if (setup) { - this.props.onSetupOptionsChanged && this.props.onSetupOptionsChanged(setup); - const { camera , renderer , transition , transitionDurations } = setup; - newState.renderer = renderer; - newState.transitionType = transition.type; - if (camera === "hold") newState.holdCamera = true; - else { - newState.holdCamera = false; - newState.camera = camera; - } - if (transition.type === "column") newState.transitionColumn = transition.column; - else if (transition.type === "position") newState.transitionDimension = transition.dimension; - if (transitionDurations) { - newState.transitionDurations = transitionDurations; - (0, _transition.syncTansitionDurations)(this.viewer, transitionDurations); - } - } - } - setInsight(historyAction, newState = {}, partialInsight = this.viewer.getInsight(), rebaseFilter, setup) { - const selectedItemIndex = Object.assign({}, this.state.selectedItemIndex); - (0, _dataScope.resetSelectedItemIndex)(selectedItemIndex); - const historicInsight = Object.assign({ - chart: null, - scheme: null, - columns: null, - filter: null, - rebaseFilter - }, partialInsight); - const state = Object.assign({ - filteredData: null, - selectedItemIndex, - search: (0, _searchGroups.createInputSearch)(historicInsight.filter) - }, newState); - const changeInsight = ()=>{ - this.getColorContext = null; - this.setSetup(setup, historicInsight); - this.changeInsight(historicInsight, historyAction, state, setup); - }; - const currentFilter = this.viewer.getInsight().filter; - if (rebaseFilter && currentFilter && historicInsight.filter) { - if ((0, _sanddanceReact.SandDance).searchExpression.startsWith(historicInsight.filter, currentFilter)) changeInsight(); - else { - const { transitionDurations } = this.state; - const renderTime = transitionDurations.position + transitionDurations.stagger; - const allowAsyncRenderTime = renderTime + this.viewerOptions.filterRenderingTimerPadding; - this.viewer.reset().then(()=>new Promise((resolve, reject)=>{ - setTimeout(resolve, allowAsyncRenderTime); - })).then(changeInsight); - } - } else changeInsight(); - } - handleReviveSnapshot(snapshot, selectedSnapshotIndex) { - let handled = false; - if (this.props.onSnapshotClick) { - this.setState({ - selectedSnapshotIndex - }); - handled = this.props.onSnapshotClick(snapshot, selectedSnapshotIndex); - } - if (!handled) this.reviveSnapshot(selectedSnapshotIndex); - } - reviveSnapshot(snapshotOrIndex) { - if (typeof snapshotOrIndex === "number") { - const selectedSnapshotIndex = snapshotOrIndex; - const snapshot = this.state.snapshots[selectedSnapshotIndex]; - const newState = { - note: snapshot.description, - selectedSnapshotIndex - }; - if (!this.state.sidebarClosed) { - newState.sideTabId = (0, _interfaces.SideTabId).Snapshots; - this.scrollSnapshotIntoView(selectedSnapshotIndex); + createConfig(c) { + var _a; + const { getTextColor, getTextHighlightColor, onTextClick } = this.options; + const defaultPresenterConfig = { + morphChartsColors: this.getMorphChartsColors(), + zAxisZindex, + getCharacterSet: (stage)=>this._characterSet.getCharacterSet(stage), + getTextColor, + getTextHighlightColor, + onTextClick: (e, t)=>{ + if (t.metaData && t.metaData.search) { + //used by facets to select the facet + const search = (0, _search.getSearchGroupFromVegaValue)(t.metaData.search); + if (this.options.onAxisClick) this.options.onAxisClick(e, search); + else this.select(search); } - if (snapshot.insight) { - const { backgroundImage } = snapshot.insight; - this.imageHolder.showBackgroundImage = !!backgroundImage; - if (backgroundImage) this.imageHolder.img = { - src: backgroundImage.url, - height: backgroundImage.size.height, - width: backgroundImage.size.width - }; + if (onTextClick) onTextClick(e, t); + }, + onCubeClick: this.onCubeClick.bind(this), + onCubeHover: this.onCubeHover.bind(this), + onTextHover: this.onTextHover.bind(this), + preLayer: this.preLayer.bind(this), + preStage: this.preStage.bind(this), + onPresent: this.onPresent.bind(this), + onAxisConfig: (cartesian, dim3d, axis)=>{ + if (!axis) return; + const role = this.specCapabilities.roles.filter((r)=>r.role === axis.axisRole)[0]; + if (role === null || role === void 0 ? void 0 : role.axisSelection) { + cartesian.isDivisionPickingEnabled[dim3d] = true; + cartesian.arePickDivisionsVisible[dim3d] = axis.tickText.length > 0; + cartesian.isLabelPickingEnabled[dim3d] = true; + cartesian.isTitlePickingEnabled[dim3d] = true; + cartesian.isHeadingPickingEnabled[dim3d] = true; + cartesian.isGridPickingEnabled = false; } - this.setInsight({ - label: (0, _language.strings).labelHistoryReviveSnapshot - }, newState, snapshot.insight, true, snapshot.setup); - } else { - const snapshot1 = snapshotOrIndex; - if (snapshot1.insight) this.setInsight({ - label: (0, _language.strings).labelHistoryReviveSnapshot - }, { - note: snapshot1.description, - selectedSnapshotIndex: -1 - }, snapshot1.insight, true, snapshot1.setup); //don't navigate to sideTab - else this.setState({ - note: snapshot1.description, - selectedSnapshotIndex: -1 - }); - } - } - load(data, getPartialInsight, optionsOrPrefs) { - this.setState({ - historyIndex: -1, - historyItems: [] - }); - this.changeInsight({ - columns: null - }, { - label: null, - omit: true - }, { - note: null - }); - return new Promise((resolve, reject)=>{ - const loadFinal = (dataContent)=>{ - let partialInsight; - this.prefs = optionsOrPrefs && optionsOrPrefs.chartPrefs || optionsOrPrefs || {}; - this.imageHolder.backgroundImageColumnBounds = (0, _columns.getBackgroundImageColumnBounds)(dataContent.columns); - if (getPartialInsight) { - partialInsight = getPartialInsight(dataContent.columns); - (0, _partialInsight.initPrefs)(this.prefs, partialInsight); - } - if (!partialInsight) { - //load recommendation - const r = new (0, _chartRecommender.RecommenderSummary)(dataContent.columns, dataContent.data); - partialInsight = r.recommend(); - } - partialInsight = Object.assign({ - facetStyle: "wrap", - filter: null, - totalStyle: null, - transform: null - }, partialInsight); - if (partialInsight.chart === "barchart") partialInsight.chart = "barchartV"; - const selectedItemIndex = Object.assign({}, this.state.selectedItemIndex); - const sideTabId = (0, _interfaces.SideTabId).ChartType; - (0, _dataScope.resetSelectedItemIndex)(selectedItemIndex); - const newState = Object.assign({ - camera: undefined, - dataFile, - dataContent, - snapshots: dataContent.snapshots || this.state.snapshots, - autoCompleteDistinctValues: {}, - filteredData: null, - tooltipExclusions: optionsOrPrefs && optionsOrPrefs.tooltipExclusions || [], - selectedItemIndex, - sideTabId - }, partialInsight); - this.getColorContext = null; - (0, _columns.ensureColumnsExist)(newState.columns, dataContent.columns, newState.transform); - const errors = (0, _columns.ensureColumnsPopulated)(partialInsight === null || partialInsight === void 0 ? void 0 : partialInsight.chart, partialInsight === null || partialInsight === void 0 ? void 0 : partialInsight.totalStyle, newState.columns, dataContent.columns); - newState.errors = errors; - newState.transitionColumn = dataContent.columns[0]; - const setup = optionsOrPrefs && optionsOrPrefs.setup; - this.setSetup(setup, newState); - //change insight - this.changeInsight(partialInsight, { - label: (0, _language.strings).labelHistoryInit, - insert: true - }, newState, optionsOrPrefs && optionsOrPrefs.setup); - //make sure item is active - this.activateDataBrowserItem(sideTabId, this.state.dataScopeId); - resolve(); + }, + onAxesComplete: (cartesian)=>{}, + axisPickGridCallback: (divisions, e)=>{ + const search = this._axisSelection.convert(divisions); + if (this.options.onAxisClick) this.options.onAxisClick(e, search); //TODO change onAxisClick to accept Search + else this.select(search); + }, + onLayerClick: (e)=>{ + this.options.onCanvasClick && this.options.onCanvasClick(e); + this.deselect(); + }, + onLegendClick: (e, legend, clickedIndex)=>{ + const legendRow = clickedIndex !== null && legend.rows[clickedIndex]; + if (legendRow) { + if (this.options.onLegendRowClick) this.options.onLegendRowClick(e, legendRow); + else this.select(legendRow.search); + } else if (this.options.onLegendHeaderClick) //header clicked + this.options.onLegendHeaderClick(e); + }, + onSceneRectAssignCubeOrdinal: (datum)=>{ + //TODO see if datum is a facet selection rect + return datum[0, _constants.GL_ORDINAL]; + }, + onTargetViewState: (h, w)=>{ + const { height, width } = this.insight.size; + let newViewStateTarget; + if (this.options.onNewViewStateTarget) newViewStateTarget = this.options.onNewViewStateTarget(); + return { + height, + width, + newViewStateTarget }; - let dataFile; - if (Array.isArray(data)) return (0, _dataLoader.loadDataArray)(data, "json", optionsOrPrefs && optionsOrPrefs.columnTypes).then((result)=>{ - dataFile = { - type: "json" - }; - loadFinal(result); - }).catch(reject); - else { - dataFile = data; - return (0, _dataLoader.loadDataFile)(dataFile, optionsOrPrefs && optionsOrPrefs.columnTypes).then(loadFinal).catch(reject); - } + }, + layerSelection: { + cubes: this.convertSearchToSet() + }, + preserveDrawingBuffer: this.options.preserveDrawingBuffer + }; + if (!this.options.disableLasso) defaultPresenterConfig.onLasso = (ids, e)=>{ + this.deselect(); + const search = this.convertSetToSearch(ids); + this.select(search); + }; + if (this.options.onBeforeCreateLayers) defaultPresenterConfig.preLayer = (stage)=>{ + this.preLayer(stage); + this.options.onBeforeCreateLayers(stage, this.specCapabilities); + }; + const config = { + presenter: this.presenter, + presenterConfig: Object.assign(defaultPresenterConfig, c) + }; + if ((_a = this.setup) === null || _a === void 0 ? void 0 : _a.transitionDurations) config.presenterConfig.transitionDurations = this.setup.transitionDurations; + return config; + } + /** + * Filter the data and animate. + * @param search Filter expression, see https://vega.github.io/vega/docs/expressions/ + * @param rebase Optional flag to apply to entire dataset. A false value will apply the filter upon any existing filter. + */ filter(search, rebase = false) { + const u = this._dataScope.createUserSelection(search, false, rebase); + return new Promise((resolve, reject)=>{ + this._animator.filter(search, u.included, u.excluded, rebase).then(()=>{ + this._details.clear(); + this._details.clearSelection(); + this._details.populate(this._dataScope.selection); + resolve(); }); - } - changeChartType(chart) { - const partialInsight = Object.assign({}, (0, _partialInsight.copyPrefToNewState)(this.prefs, chart, "*", "*")); - const insight = Object.assign({ - chart - }, partialInsight); - const columns = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge({}, partialInsight.columns, this.state.columns); - const { signalValues } = this.viewer.getInsight(); - insight.signalValues = Object.assign(Object.assign({}, this.state.signalValues), signalValues); - insight.columns = Object.assign({}, columns); - insight.totalStyle = this.state.totalStyle; - let errors; - //special case mappings when switching chart type - if (this.state.chart === "scatterplot" && (chart === "barchart" || chart === "barchartV")) insight.columns = Object.assign(Object.assign({}, columns), { - sort: columns.y + }); + } + /** + * Remove any filtration and animate. + */ reset() { + return new Promise((resolve, reject)=>{ + this._animator.reset().then(()=>{ + this._details.clear(); + this._details.clearSelection(); + resolve(); }); - else if (this.state.chart === "scatterplot" && chart === "barchartH") insight.columns = Object.assign(Object.assign({}, columns), { - sort: columns.x + }); + } + /** + * Select cubes by a filter expression. + * @param search Filter expression, see https://vega.github.io/vega/docs/expressions/ + */ select(search) { + return new Promise((resolve, reject)=>{ + this._animator.select(search).then(()=>{ + this._details.populate(this._dataScope.selection); + resolve(); }); - else if (chart === "treemap") { - insight.view = "2d"; - if (!columns.size) { - //make sure size exists and is numeric - let sizeColumn; - //first check prefs - if (partialInsight && partialInsight.columns && partialInsight.columns.size) { - const prefSizeColumn = this.state.dataContent.columns.filter((c)=>c.name === partialInsight.columns.size)[0]; - if (prefSizeColumn && prefSizeColumn.quantitative) sizeColumn = prefSizeColumn; - } - if (!sizeColumn) sizeColumn = (0, _columns.getTreemapColumn)(this.state.dataContent.columns); - if (!sizeColumn) //error - no numeric columns - errors = [ - (0, _language.strings).errorColumnMustBeNumeric - ]; - else insight.columns = Object.assign(Object.assign({}, columns), { - size: sizeColumn.name - }); - } - } else if (chart === "stacks") insight.view = "3d"; - (0, _columns.ensureColumnsExist)(insight.columns, this.state.dataContent.columns, this.state.transform); - errors = (0, _columns.ensureColumnsPopulated)(chart, insight.totalStyle, insight.columns, this.state.dataContent.columns); - this.calculate(()=>{ - this.changeInsight(insight, { - label: (0, _language.strings).labelHistoryChangeChartType((0, _chart.chartLabel)(chart)) - }, errors ? { - errors, - camera: undefined - } : { - camera: undefined - }); + }); + } + /** + * Removes any selection. + */ deselect() { + return new Promise((resolve, reject)=>{ + this._animator.deselect().then(()=>{ + this._details.clearSelection(); + resolve(); }); - return insight.columns; - } - calculate(calculating) { - this.setState({ - calculating + }); + } + /** + * Gets the current selection. + */ getSelection() { + if (!this._dataScope) return null; + const selectionState = { + search: this._dataScope.selection && this._dataScope.selection.search || null, + selectedData: this._dataScope.selection && this._dataScope.selection.included || null, + active: this._dataScope.active + }; + return selectionState; + } + /** + * Set one data row to the active state. + */ activate(datum) { + return new Promise((resolve, reject)=>{ + this._animator.activate(datum).then(()=>{ + this.presenter.morphChartsRenderResult.activate(datum[0, _constants.GL_ORDINAL]); + this._details.render(); + resolve(); }); - } - changeView(view) { - this.changeInsight({ - view - }, { - label: view === "2d" ? (0, _language.strings).labelViewType2d : (0, _language.strings).labelViewType3d + }); + } + /** + * Deactivate item. + */ deActivate() { + return new Promise((resolve, reject)=>{ + if (this._dataScope && this._dataScope.active) this._animator.deactivate().then(()=>{ + this.presenter.morphChartsRenderResult.activate(-1); + this._details.render(); + resolve(); }); - } - //state members which change the insight - changeInsight(partialInsight, historyAction, additionalUIState, historicSetup) { - if (!partialInsight.signalValues) partialInsight.signalValues = null; - if (partialInsight.chart === "barchart") partialInsight.chart = "barchartV"; - this.addHistory(Object.assign(Object.assign({}, partialInsight), { - historicSetup - }), historyAction, additionalUIState); - } - addHistory(historicInsight, historyAction, additionalUIState) { - const setCleanState = (newState)=>{ - const cleanState = Object.assign(Object.assign({}, newState), additionalUIState); - if (!cleanState.note) cleanState.note = null; - delete cleanState.rebaseFilter; - if (this.viewer) { - const { signalValues } = this.viewer.getInsight(); - cleanState.signalValues = Object.assign(Object.assign(Object.assign({}, this.state.signalValues), signalValues), cleanState.signalValues); - } - this.setState(cleanState); - }; - if (historyAction.omit) { - setCleanState(historicInsight); - return; + else resolve(); + }); + } + /** + * Gets the current camera. + * @param transitionFinal Optional flag to get camera destination when transition completes. + */ getCamera(transitionFinal = false) { + var _a, _b, _c, _d, _e, _f, _g; + let position = [ + 0, + 0, + 0 + ]; + let rotation = [ + 0, + 0, + 0, + 0 + ]; + if (transitionFinal) { + position = Array.from((_b = (_a = this.presenter) === null || _a === void 0 ? void 0 : _a.morphchartsref) === null || _b === void 0 ? void 0 : _b.cameraTransitioner.vPosition.to); + rotation = Array.from((_d = (_c = this.presenter) === null || _c === void 0 ? void 0 : _c.morphchartsref) === null || _d === void 0 ? void 0 : _d.cameraTransitioner.qRotation.to); + } else { + const camera = (_g = (_f = (_e = this.presenter) === null || _e === void 0 ? void 0 : _e.morphchartsref) === null || _f === void 0 ? void 0 : _f.core) === null || _g === void 0 ? void 0 : _g.camera; + if (camera) { + camera.getPosition(position); + camera.getOrbit(rotation); } - const historyItems = this.state.historyItems.slice(0, this.state.historyIndex + 1); - const historyIndex = historyItems.length; - historyItems.push({ - label: historyAction.label, - historicInsight - }); - if (historyAction.insert) setCleanState({ - historyIndex, - historyItems - }); - else setCleanState(Object.assign(Object.assign({}, historicInsight), { - historyIndex, - historyItems - })); } - replay(index) { - return (0, _history.replay)(this.state.historyItems, index); + return { + position, + rotation, + captureSize: this.insight.size + }; + } + /** + * Sets the current camera. + * @param camera Camera to set. + */ setCamera(camera) { + var _a, _b; + if (camera) (_b = (_a = this.presenter) === null || _a === void 0 ? void 0 : _a.morphChartsRenderResult) === null || _b === void 0 || _b.moveCamera(camera); + } + /** + * Gets the current insight with signal values. + */ getInsight() { + const insight = Object.assign({}, this.insight); + insight.signalValues = this.getSignalValues(); + return insight; + } + /** + * Gets column stats from current data (filtered or all). + * @param column Column to get stats for. + */ getColumnStats(column) { + return this._dataScope.hasFilteredData() ? this._dataScope.getFilteredColumnStats(column.name) : column.stats; + } + /** + * Gets current signal values. + */ getSignalValues() { + return (0, _signals.extractSignalValuesFromView)(this.vegaViewGl, this.vegaSpec); + } + assignTransitionStagger(transition) { + (0, _transition.assignTransitionStagger)(transition, this._dataScope.currentData(), this.convertSearchToSet(), this.presenter); + } + finalize() { + if (this._dataScope) this._dataScope.finalize(); + if (this._details) this._details.finalize(); + if (this._tooltip) this._tooltip.destroy(); + if (this.vegaViewGl) this.vegaViewGl.finalize(); + if (this.presenter) this.presenter.finalize(); + if (this.element) this.element.innerHTML = ''; + this.colorContexts = null; + this.element = null; + this.options = null; + this.presenter = null; + this.vegaSpec = null; + this.vegaViewGl = null; + this._animator = null; + this._dataScope = null; + this._details = null; + this._tooltip = null; + } +} +/** + * Default Viewer options. + */ Viewer.defaultViewerOptions = (0, _defaults.defaultViewerOptions); + +},{"./animator":"g3bB0","./axisSelection":"3Bo2C","./colorCubes":"a2zcs","./colorSchemes":"iDNR0","./constants":"ix2qh","./dataScope":"3xxVJ","./defaults":"7bMd0","./details":"5q1eU","./headers":"bOtA3","./legend":"buMaw","./ordinal":"eRzwB","./search":"6kluJ","./signals":"xDtCn","./tooltip":"bKbCn","@msrvida/sanddance-specs":"aOvSr","@msrvida/search-expression":"4F93b","@msrvida/vega-morphcharts":"9Sd5M","./characterSet":"grMul","./transition":"fNWAw","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g3bB0":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DataLayoutChange", ()=>DataLayoutChange); +parcelHelpers.export(exports, "Animator", ()=>Animator); +var DataLayoutChange; +(function(DataLayoutChange) { + DataLayoutChange[DataLayoutChange["same"] = 0] = "same"; + DataLayoutChange[DataLayoutChange["reset"] = 1] = "reset"; + DataLayoutChange[DataLayoutChange["refine"] = 2] = "refine"; +})(DataLayoutChange || (DataLayoutChange = {})); +class Animator { + constructor(dataScope, props){ + this.dataScope = dataScope; + this.props = props; + } + select(search) { + return new Promise((resolve, reject)=>{ + this.dataScope.select(search); + this.props.onDataChanged(DataLayoutChange.same); + resolve(); + }); + } + deselect() { + return new Promise((resolve, reject)=>{ + this.dataScope.deselect(); + this.props.onDataChanged(DataLayoutChange.same); + resolve(); + }); + } + filter(search, keepData, collapseData, rebase) { + if (rebase) this.dataScope.collapse(false, keepData); + this.dataScope.collapse(true, collapseData); + return new Promise((resolve, reject)=>{ + this.props.onAnimateDataChange(DataLayoutChange.refine, 'before refine', 'refine').then(()=>{ + this.dataScope.deselect(); + this.dataScope.setFilteredData(keepData); + this.props.onDataChanged(DataLayoutChange.refine, search); + resolve(); + }).catch(reject); + }); + } + reset() { + return new Promise((resolve, reject)=>{ + this.dataScope.deselect(); + let time; + if (!this.dataScope.hasFilteredData()) time = 0; + else this.dataScope.setFilteredData(null); + this.props.onAnimateDataChange(DataLayoutChange.reset, 'before reset', 'reset', time).then(()=>{ + this.dataScope.collapse(false); + this.props.onDataChanged(DataLayoutChange.reset); + resolve(); + }).catch(reject); + }); + } + activate(datum) { + return new Promise((resolve, reject)=>{ + this.dataScope.activate(datum); + this.props.onDataChanged(DataLayoutChange.same); + resolve(); + }); + } + deactivate() { + return new Promise((resolve, reject)=>{ + this.dataScope.deactivate(); + this.props.onDataChanged(DataLayoutChange.same); + resolve(); + }); + } +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3Bo2C":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "AxisSelection", ()=>AxisSelection); +parcelHelpers.export(exports, "moveTicksBetween", ()=>moveTicksBetween); +var _expression = require("./expression"); +const dimToRole = { + 0: 'x', + 1: 'y', + 2: 'z' +}; +const roleToDim = { + x: 0, + y: 1, + z: 1 +}; +class AxisSelection { + constructor(specCapabilities, columns, stage){ + this.specCapabilities = specCapabilities; + this.columns = columns; + this.stage = stage; + } + convert(divisions) { + const searchRoles = []; + divisions.forEach((division, i)=>{ + const role = dimToRole[i]; + const axes = this.stage.axes[role]; + //all axes in a faceted chart should be the same + const axis = axes.filter((axis)=>axis.tickText.length)[0]; + if (axis) { + const capabilities = this.specCapabilities.roles.filter((r)=>r.role === role)[0]; + const column = this.columns[role]; + if (division >= 0 && (capabilities === null || capabilities === void 0 ? void 0 : capabilities.axisSelection)) searchRoles.push({ + axis, + role, + capabilities, + column, + division + }); + } + }); + switch(searchRoles.length){ + case 0: + return null; + case 1: + return this.getSearchFromSearchRole(searchRoles[0]); + default: + { + const roles = searchRoles.map((searchRole)=>this.getSearchFromSearchRole(searchRole)); + roles.forEach((role, i)=>{ + if (i === 0) return; + role.clause = '&&'; + }); + return roles; + } } - undo() { - const historyIndex = this.state.historyIndex - 1; - if (historyIndex < 0) return; - this.doReplay(historyIndex); + } + getSearchFromSearchRole(searchRole) { + const getSearch = searchRole.capabilities.axisSelection === 'exact' ? (a, c, i)=>({ + expressions: [ + (0, _expression.selectExactAxis)(a, c, i) + ] + }) : (0, _expression.selectBetweenAxis); + const { axis, column, division } = searchRole; + return getSearch(axis, column, division); + } +} +function moveTicksBetween(axes) { + axes.forEach((axis)=>{ + if (axis.ticks.length === 0) return; + const dim = roleToDim[axis.axisRole]; + const { color } = axis.ticks[0]; + const newLine = (value)=>{ + const line = { + sourcePosition: [ + 0, + 0, + 0 + ], + targetPosition: [ + 0, + 0, + 0 + ], + color + }; + line.sourcePosition[dim] = value; + return line; + }; + const newTicks = []; + newTicks.push(newLine(axis.domain.sourcePosition[dim])); + for(let i = 1; i < axis.ticks.length; i++)newTicks.push(newLine((axis.ticks[i].sourcePosition[dim] + axis.ticks[i - 1].sourcePosition[dim]) / 2)); + newTicks.push(newLine(axis.domain.targetPosition[dim])); + axis.ticks = newTicks; + }); +} + +},{"./expression":"2foo2","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2foo2":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "notNice", ()=>notNice); +parcelHelpers.export(exports, "selectNullOrEmpty", ()=>selectNullOrEmpty); +parcelHelpers.export(exports, "selectExact", ()=>selectExact); +parcelHelpers.export(exports, "selectNone", ()=>selectNone); +parcelHelpers.export(exports, "selectExactAxis", ()=>selectExactAxis); +parcelHelpers.export(exports, "selectBetween", ()=>selectBetween); +parcelHelpers.export(exports, "selectBetweenAxis", ()=>selectBetweenAxis); +function notNice(niceValue) { + //convert "nice" numbers to numeric value + return (niceValue + '').replace(/[\s,]/g, ''); +} +function tickValue(axis, i) { + const tick = axis.tickText[i]; + let value; + if (tick) value = axis.tickText[i].value; + return { + tick, + value + }; +} +function selectNullOrEmpty(column) { + const searchExpression = { + name: column.name, + operator: 'isnullorEmpty' + }; + return searchExpression; +} +function selectExact(column, value) { + if (value == null) return selectNullOrEmpty(column); + const searchExpression = { + name: column.name, + operator: '==', + value + }; + return searchExpression; +} +function selectNone(column, values) { + const expressions = values.map((value, i)=>{ + const searchExpression = { + name: column.name, + operator: '!=', + value + }; + if (i) searchExpression.clause = '&&'; + return searchExpression; + }); + const searchExpressionGroup = { + expressions + }; + return searchExpressionGroup; +} +function selectExactAxis(axis, column, i) { + const result = tickValue(axis, i); + if (result.tick) return selectExact(column, result.value); +} +function selectBetween(column, lowValue, highValue, lowOperator = '>=', highOperator = '<') { + const expressions = []; + if (lowValue !== undefined) expressions.push({ + name: column.name, + operator: lowOperator, + value: lowValue + }); + if (highValue !== undefined) expressions.push({ + name: column.name, + operator: highOperator, + value: highValue + }); + if (expressions.length > 1) expressions[1].clause = '&&'; + const searchExpressionGroup = { + expressions + }; + return searchExpressionGroup; +} +function selectBetweenAxis(axis, column, i) { + const low = tickValue(axis, i); + const high = tickValue(axis, i + 1); + return selectBetween(column, low.value, high.value); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"a2zcs":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "populateColorContext", ()=>populateColorContext); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +function populateColorContext(colorContext, presenter) { + if (!colorContext.colorMap) colorContext.colorMap = presenter.morphChartsRenderResult.getCubeLayer().unitColorMap; + colorContext.legend = _vegaMorphcharts.util.clone(presenter.stage.legend); + colorContext.legendElement = presenter.getElement(_vegaMorphcharts.PresenterElement.legend).children[0]; +} + +},{"@msrvida/vega-morphcharts":"9Sd5M","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3xxVJ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "DataScope", ()=>DataScope); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +var _searchExpression = require("@msrvida/search-expression"); +var _sanddanceSpecs = require("@msrvida/sanddance-specs"); +var _constants = require("./constants"); +class DataScope { + constructor(){ + this.filteredColumnsStats = {}; + } + setData(data, columns) { + const differentData = this.data !== data; + if (differentData) { + if (this.data) //clean up things we added to old data + this.deselect(); + this.data = data; + this.columns = columns; + this.filteredData = null; + this.filteredColumnsStats = {}; } - redo(historyIndex = this.state.historyIndex + 1) { - if (historyIndex >= this.state.historyItems.length) return; - this.doReplay(historyIndex); + return differentData; + } + setFilteredData(filteredData) { + this.filteredData = filteredData; + this.filteredColumnsStats = {}; + } + getColumns(columnTypes) { + if (!this.columns) this.columns = (0, _sanddanceSpecs.getColumnsFromData)(_vegaMorphcharts.base.vega.inferTypes, this.data, columnTypes); + return this.columns; + } + getFilteredColumnStats(columnName) { + if (!this.filteredColumnsStats[columnName]) this.filteredColumnsStats[columnName] = (0, _sanddanceSpecs.getStats)(this.filteredData, this.columns.filter((c)=>c.name === columnName)[0]); + return this.filteredColumnsStats[columnName]; + } + currentData() { + return this.filteredData || this.data; + } + select(search) { + this.deselect(); + if (search) { + this.selection = this.createUserSelection(search, true, false); + if (this.selection.included.length) this.activate(this.selection.included[0]); } - doReplay(historyIndex) { - const newState = this.replay(historyIndex); - this.rebaseFilter = true; - this.setSetup(newState.historicSetup, newState); - this.setState(Object.assign(Object.assign({}, newState), { - historyIndex - })); + } + createUserSelection(search, assign, rebase) { + const exec = new (0, _searchExpression.Exec)(search, this.getColumns()); + const s = { + search, + included: [], + excluded: [] + }; + const data = rebase ? this.data : this.currentData(); + data.forEach((datum)=>{ + if (exec.run(datum)) { + if (assign) datum[(0, _sanddanceSpecs.FieldNames).Selected] = true; + s.included.push(datum); + } else s.excluded.push(datum); + }); + return s; + } + deselect() { + this.deactivate(); + this.data.forEach((datum)=>{ + delete datum[(0, _sanddanceSpecs.FieldNames).Selected]; + }); + this.selection = null; + } + hasFilteredData() { + return !!this.filteredData; + } + hasSelectedData() { + return !!this.selection; + } + collapse(collapsed, data = this.data) { + data.forEach((datum)=>{ + datum[(0, _sanddanceSpecs.FieldNames).Collapsed] = collapsed; + }); + this.isCollapsed = collapsed; + } + activate(datum) { + this.deactivate(); + datum[(0, _sanddanceSpecs.FieldNames).Active] = true; + this.active = datum; + } + deactivate() { + if (this.active) delete this.active[(0, _sanddanceSpecs.FieldNames).Active]; + this.active = null; + } + ordinalIndexWithinSelection(ordinal) { + if (this.selection) for(let i = 0; i < this.selection.included.length; i++){ + const datum = this.selection.included[i]; + if (datum[0, _constants.GL_ORDINAL] === ordinal) return { + datum, + index: i + }; } - changespecCapabilities(specCapabilities) { - this.setState({ - specCapabilities - }); + return { + datum: null, + index: -1 + }; + } + finalize() { + this.data = null; + this.filteredData = null; + this.filteredColumnsStats = null; + if (this.selection) { + this.selection.excluded = null; + this.selection.included = null; + this.selection = null; } - changeColumnMapping(role, column, options) { - const columns = Object.assign({}, this.state.columns); - const label = column ? (0, _language.strings).labelHistoryMapColumn(role) : (0, _language.strings).labelHistoryUnMapColumn(role); - const final = ()=>{ - const partialInsight = { - columns, - totalStyle: options ? options.totalStyle : this.state.totalStyle - }; - const errors = (0, _columns.ensureColumnsPopulated)(this.state.chart, partialInsight.totalStyle, partialInsight.columns, this.state.dataContent.columns); - columns[role] = column && column.name; - this.changeInsight(partialInsight, { - label - }, errors ? { - errors, - camera: this.viewer.getCamera() - } : { - camera: this.viewer.getCamera() - }); - }; - const _changeInsight = (newInsight, columnUpdate, historyAction)=>{ - newInsight.columns = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge({}, columns, columnUpdate); - (0, _partialInsight.savePref)(this.prefs, this.state.chart, "*", "*", { - columns: columnUpdate - }); - this.changeInsight(newInsight, historyAction, { - camera: this.viewer.getCamera() - }); - }; - if (column) { - let columnUpdate; - switch(role){ - case "facet": - { - (0, _partialInsight.copyPrefToNewState)(this.prefs, this.state.chart, "facet", column.name); - const historicInsight = { - columns, - facetStyle: options ? options.facetStyle : this.state.facetStyle - }; - columnUpdate = { - facet: column.name - }; - _changeInsight(historicInsight, columnUpdate, { - label - }); - break; - } - case "color": - { - let calculating = null; - const historicInsight1 = { - scheme: options && options.scheme, - columns, - colorBin: this.state.colorBin - }; - if (!historicInsight1.scheme) (0, _partialInsight.copyPrefToNewState)(this.prefs, this.state.chart, "color", column.name); - if (!historicInsight1.scheme) historicInsight1.scheme = (0, _colorScheme.bestColorScheme)(column, null, this.state.scheme); - if (!column.stats.hasColorData) { - historicInsight1.directColor = false; - if (this.state.directColor !== historicInsight1.directColor) calculating = ()=>this._resize(); - } - if (this.state.columns && this.state.columns.color && this.state.columns.color !== column.name) { - const currColorColumn = this.state.dataContent.columns.filter((c)=>c.name === this.state.columns.color)[0]; - if (column.isColorData != currColorColumn.isColorData) calculating = ()=>this._resize(); - } - this.ignoreSelectionChange = true; - this.viewer.deselect().then(()=>{ - this.ignoreSelectionChange = false; - //allow deselection to render - requestAnimationFrame(()=>{ - columnUpdate = { - color: column.name - }; - this.getColorContext = null; - this.setState({ - calculating - }); - _changeInsight(historicInsight1, columnUpdate, { - label - }); - }); - }); - break; - } - case "x": - { - (0, _partialInsight.copyPrefToNewState)(this.prefs, this.state.chart, "x", column.name); - const historicInsight2 = { - columns - }; - columnUpdate = { - x: column.name - }; - _changeInsight(historicInsight2, columnUpdate, { - label - }); - break; - } - case "size": - { - (0, _partialInsight.copyPrefToNewState)(this.prefs, this.state.chart, "size", column.name); - const historicInsight3 = { - totalStyle: options ? options.totalStyle : this.state.totalStyle - }; - columnUpdate = { - size: column.name - }; - _changeInsight(historicInsight3, columnUpdate, { - label - }); - break; - } - default: - final(); + } +} + +},{"@msrvida/vega-morphcharts":"9Sd5M","@msrvida/search-expression":"4F93b","@msrvida/sanddance-specs":"aOvSr","./constants":"ix2qh","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5q1eU":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Details", ()=>Details); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +var _defaults = require("./defaults"); +var _constants = require("./constants"); +var _searchExpression = require("@msrvida/search-expression"); +var _util = require("./util"); +var Action; +(function(Action) { + Action[Action["deselect"] = 0] = "deselect"; + Action[Action["isolate"] = 1] = "isolate"; + Action[Action["exclude"] = 2] = "exclude"; + Action[Action["reset"] = 3] = "reset"; + Action[Action["next"] = 4] = "next"; + Action[Action["previous"] = 5] = "previous"; +})(Action || (Action = {})); +class Details { + constructor(parentElement, language, animator, dataScope, colorMapHandler, hasColorMaps){ + this.language = language; + this.animator = animator; + this.dataScope = dataScope; + this.colorMapHandler = colorMapHandler; + this.hasColorMaps = hasColorMaps; + this.element = (0, _vegaMorphcharts.util).addDiv(parentElement, `${(0, _defaults.cssPrefix)}unitControls`); + this.clear(); + } + finalize() { + if (this.element) this.element.innerHTML = ''; + this.dataScope = null; + this.element = null; + } + clear() { + this.state = { + userSelection: null, + index: -1, + remapColor: false + }; + this.render(); + } + clearSelection() { + this.state.userSelection = null; + this.state.index = -1; + this.render(); + } + populate(userSelection, index = 0) { + this.state.userSelection = userSelection; + this.state.index = index; + this.render(); + } + selectByNameValue(columnName, value) { + const search = { + name: columnName, + operator: '==', + value + }; + this.clearSelection(); + this.animator.select(search); + this.populate(this.dataScope.selection); + } + remapChanged(remap) { + this.state.remapColor = remap; + this.colorMapHandler(remap); + this.render(); + } + handleAction(action) { + let p; + const u = this.state.userSelection; + switch(action){ + case Action.deselect: + this.clearSelection(); + p = this.animator.deselect(); + break; + case Action.exclude: + this.clearSelection(); + p = this.animator.filter((0, _searchExpression.invert)(u.search), u.excluded, u.included, false); + this.state.remapColor = false; + break; + case Action.isolate: + this.clearSelection(); + p = this.animator.filter(u.search, u.included, u.excluded, false); + this.state.remapColor = false; + break; + case Action.reset: + this.clear(); + p = this.animator.reset(); + break; + default: + switch(action){ + case Action.previous: + this.state.index--; + if (this.state.index < 0) this.state.index = this.state.userSelection.included.length - 1; break; - } - } else switch(role){ - case "facet": - columns.facet = null; - columns.facetV = null; - this.changeInsight({ - columns, - facetStyle: "wrap" - }, { - label - }); - break; - default: - final(); - break; - } - } - setSideTabId(sideTabId, dataScopeId) { - if (sideTabId === (0, _interfaces.SideTabId).Data && dataScopeId == null) //choose most relevant DataScopeId - dataScopeId = this.getBestDataScopeId(); - if (dataScopeId == null) dataScopeId = this.state.dataScopeId; - const calculating = ()=>{ - this.dialogFocusHandler.focus && this.dialogFocusHandler.focus(); - }; - this.setState({ - sideTabId, - dataScopeId, - sidebarClosed: false, - calculating - }); - this.activateDataBrowserItem(sideTabId, dataScopeId); - } - getBestDataScopeId() { - let dataScopeId; - const selectionState = this.viewer && this.viewer.getSelection(); - if (selectionState && selectionState.selectedData && selectionState.selectedData.length) dataScopeId = (0, _dataScope.DataScopeId).SelectedData; - else if (this.state.filteredData) dataScopeId = (0, _dataScope.DataScopeId).FilteredData; - else dataScopeId = (0, _dataScope.DataScopeId).AllData; - return dataScopeId; - } - activateDataBrowserItem(sideTabId, dataScopeId) { - if (!this.viewer) return; - let itemToActivate; - if (sideTabId === (0, _interfaces.SideTabId).Data) switch(dataScopeId){ - case (0, _dataScope.DataScopeId).AllData: - itemToActivate = this.state.dataContent && this.state.dataContent.data[this.state.selectedItemIndex[(0, _dataScope.DataScopeId).AllData]]; - break; - case (0, _dataScope.DataScopeId).FilteredData: - itemToActivate = this.state.filteredData && this.state.filteredData[this.state.selectedItemIndex[(0, _dataScope.DataScopeId).FilteredData]]; - break; - case (0, _dataScope.DataScopeId).SelectedData: - { - const selection = this.viewer.getSelection() || {}; - itemToActivate = selection.selectedData && selection.selectedData[this.state.selectedItemIndex[(0, _dataScope.DataScopeId).SelectedData]]; + case Action.next: + this.state.index++; + if (this.state.index >= this.state.userSelection.included.length) this.state.index = 0; break; - } - } - this.silentActivation(itemToActivate); - } - silentActivation(itemToActivate) { - this.ignoreSelectionChange = true; - const done = ()=>{ - this.ignoreSelectionChange = false; - }; - if (itemToActivate) return this.viewer.activate(itemToActivate).then(done); - else return this.viewer.deActivate().then(done); - } - sidebar(sidebarClosed, sidebarPinned) { - this.setState({ - sidebarClosed, - sidebarPinned - }); - } - resize() { - this.setState({ - calculating: ()=>this._resize() - }); - } - _resize() { - this.changeInsight({ - size: this.getLayoutDivSize(this.state.sidebarPinned, this.state.sidebarClosed) - }, { - label: "resize", - omit: true - }); - } - viewerMounted(glDiv) { - this.setState({ - size: this.getLayoutDivSize(this.state.sidebarPinned, this.state.sidebarClosed), - signalValues: this.state.signalValues - }); - } - getLayoutDivSize(pinned, closed) { - const div = pinned && !closed ? this.layoutDivPinned : this.layoutDivUnpinned; - return { - height: div.offsetHeight, - width: div.offsetWidth - }; - } - toggleableSearch(e, search) { - if (e.ctrlKey) { - this.setState({ - search: (0, _searchGroups.createInputSearch)(search) - }); - this.setSideTabId((0, _interfaces.SideTabId).Search); - } else { - const oldSelection = this.viewer.getSelection(); - if (oldSelection.search) { - //look for matching groups and toggle them - const result = (0, _searchGroups.compareGroups)((0, _sanddanceReact.SandDance).searchExpression.ensureSearchExpressionGroupArray(oldSelection.search), search); - if (result.found) { - //removing a group - if (result.groups.length === 0) this.doDeselect(); - else //select with new search removed - this.doSelect(result.groups); - } else //adding a new group - if (e.altKey || e.shiftKey) { - let group = true; - if (e.altKey) search.clause = "&&"; - else if (e.shiftKey) { - if (this.props.searchORDisabled) group = false; - else search.clause = "||"; - } - if (group) { - result.groups.push(search); - this.doSelect(result.groups); - } else this.doSelect(search); - } else //replace - this.doSelect(search); - } else this.doSelect(search); - } - } - doFilter(search, historicFilterChange) { - this.historicFilterChange = historicFilterChange; - this.viewer.filter(search); - } - doUnfilter(historicFilterChange) { - this.historicFilterChange = historicFilterChange; - this.viewer.reset(); - } - doSelect(search) { - return this.viewer.select(search); - } - doDeselect() { - return this.viewer.deselect(); - } - writeSnapshot(snapshot, editIndex) { - let { selectedSnapshotIndex } = this.state; - let snapshots; - if (editIndex >= 0) { - snapshots = [ - ...this.state.snapshots - ]; - snapshots[editIndex] = snapshot; - this.setState({ - snapshots, - selectedSnapshotIndex - }); - } else { - const note = snapshot.description; - snapshots = this.state.snapshots.concat(snapshot); - selectedSnapshotIndex = snapshots.length - 1; - this.scrollSnapshotIntoView(selectedSnapshotIndex); - this.setState({ - sideTabId: (0, _interfaces.SideTabId).Snapshots, - snapshots, - selectedSnapshotIndex, - note - }); - } - this.props.onSnapshotsChanged && this.props.onSnapshotsChanged(snapshots); - } - scrollSnapshotIntoView(selectedSnapshotIndex) { - clearTimeout(this.scrollSnapshotTimer); - if (this.state.sidebarClosed) return; - this.scrollSnapshotTimer = setTimeout(()=>{ - const selectedSnapshotElement = this.div.querySelector(`.snapshot:nth-child(${selectedSnapshotIndex + 1})`); - if (selectedSnapshotElement) selectedSnapshotElement.scrollIntoView({ - behavior: "smooth", - block: "nearest" - }); - }, 500); - } - componentDidMount() { - if (this.props.mounted) this.props.mounted(this); - } - render() { - var _a, _b, _c; - const insight = (0, _history.getPureInsight)(this.state); - const loaded = !!(insight.columns && this.state.dataContent); - if (loaded) (0, _backgroundImageEditor.setInsightBackgroundImage)(insight, this.imageHolder, this.state.columns); - const selectionState = this.viewer && this.viewer.getSelection() || {}; - const selectionSearch = selectionState && selectionState.search; - const columnMapProps = this.getColumnMapBaseProps(); - const datas = {}; - datas[(0, _dataScope.DataScopeId).AllData] = this.state.dataContent && this.state.dataContent.data; - datas[(0, _dataScope.DataScopeId).FilteredData] = this.state.filteredData; - datas[(0, _dataScope.DataScopeId).SelectedData] = selectionState && selectionState.selectedData; - if (this.state.calculating) requestAnimationFrame(()=>{ - //allow render to complete - if (this.state.calculating) { - this.state.calculating(); - this.setState({ - calculating: null - }); } - }); - const theme = this.props.theme || ""; - const themePalette = (0, _themes.themePalettes)[theme]; - let renderOptions; - if (loaded) renderOptions = Object.assign(Object.assign({}, this.props.renderOptions), { - rebaseFilter: ()=>this.rebaseFilter, - initialColorContext: this.getColorContext && this.getColorContext(this.viewer.insight, insight), - discardColorContextUpdates: ()=>this.discardColorContextUpdates, - columns: (_a = this.state.dataContent) === null || _a === void 0 ? void 0 : _a.columns - }); - return (0, _base.base).react.createElement("div", { - ref: (div)=>{ - if (div) this.div = div; - }, - className: (0, _sanddanceReact.util).classList("sanddance-explorer", this.props.theme) - }, (0, _base.base).react.createElement((0, _topbar.Topbar), { - collapseLabels: this.props.compactUI, - historyIndex: this.state.historyIndex, - historyItems: this.state.historyItems, - undo: ()=>this.undo(), - redo: ()=>this.redo(), - logoClickUrl: this.props.logoClickUrl, - logoClickTarget: this.props.logoClickTarget, - themePalette: themePalette, - loaded: loaded, - doDeselect: this.doDeselect.bind(this), - doFilter: this.doFilter.bind(this), - doUnfilter: this.doUnfilter.bind(this), - filter: this.state.filter, - selectionSearch: selectionSearch, - selectionState: selectionState, - buttons: this.props.topBarButtonProps, - iconButtons: this.props.topBarIconButtonProps, - view: this.state.view, - snapshotsHidden: (_b = this.props.snapshotProps) === null || _b === void 0 ? void 0 : _b.hidden, - snapshots: this.state.snapshots, - onSnapshotPreviousClick: ()=>{ - let selectedSnapshotIndex; - if (this.state.selectedSnapshotIndex === -1) selectedSnapshotIndex = this.state.snapshots.length - 1; - else { - selectedSnapshotIndex = this.state.selectedSnapshotIndex; - selectedSnapshotIndex--; - if (selectedSnapshotIndex < 0) selectedSnapshotIndex = this.state.snapshots.length - 1; - } - this.handleReviveSnapshot(this.state.snapshots[selectedSnapshotIndex], selectedSnapshotIndex); - }, - onSnapshotClick: ()=>this.snapshotEditor.editSnapshot(), - onSnapshotNextClick: ()=>{ - let selectedSnapshotIndex; - if (this.state.selectedSnapshotIndex === -1) selectedSnapshotIndex = 0; - else { - selectedSnapshotIndex = this.state.selectedSnapshotIndex; - selectedSnapshotIndex++; - if (selectedSnapshotIndex > this.state.snapshots.length - 1) selectedSnapshotIndex = 0; - } - this.handleReviveSnapshot(this.state.snapshots[selectedSnapshotIndex], selectedSnapshotIndex); + this.render(); + p = this.animator.activate(this.state.userSelection.included[this.state.index]); + } + p.then(()=>this.render()); + } + render() { + const hasRefinedData = this.dataScope.hasFilteredData(); + const renderProps = { + language: this.language, + actionHandler: (action)=>this.handleAction(action), + selectionHandler: (columnName, value)=>this.selectByNameValue(columnName, value), + count: this.state.userSelection && this.state.userSelection.included.length, + hasRefinedData, + item: this.state.userSelection && this.state.userSelection.included[this.state.index], + remapColorHandler: (remap)=>this.remapChanged(remap), + hasColorMaps: this.hasColorMaps() && hasRefinedData, + remapColor: this.state.remapColor + }; + const a = _vegaMorphcharts.util.getActiveElementInfo(); + _vegaMorphcharts.util.mount(renderDetails(renderProps), this.element); + _vegaMorphcharts.util.setActiveElement(a); + } +} +const renderDetails = (props)=>{ + const controlButtons = [ + _vegaMorphcharts.util.createElement("button", { + disabled: !props.item, + onClick: (e)=>props.actionHandler(Action.deselect) + }, props.language.deselect), + _vegaMorphcharts.util.createElement("button", { + disabled: !props.item, + onClick: (e)=>props.actionHandler(Action.isolate) + }, props.language.isolate), + _vegaMorphcharts.util.createElement("button", { + disabled: !props.item, + onClick: (e)=>props.actionHandler(Action.exclude) + }, props.language.exclude) + ]; + const colorMapping = _vegaMorphcharts.util.createElement("div", null, _vegaMorphcharts.util.createElement("button", { + disabled: props.remapColor, + onClick: (e)=>props.remapColorHandler(true) + }, props.language.newColorMap), _vegaMorphcharts.util.createElement("button", { + disabled: !props.remapColor, + onClick: (e)=>props.remapColorHandler(false) + }, props.language.oldColorMap)); + const singleItem = props.count === 1; + const scrollButtons = [ + _vegaMorphcharts.util.createElement("button", { + disabled: singleItem, + onClick: (e)=>props.actionHandler(Action.previous) + }, props.language.previousDetail), + _vegaMorphcharts.util.createElement("button", { + disabled: singleItem, + onClick: (e)=>props.actionHandler(Action.next) + }, props.language.nextDetail), + _vegaMorphcharts.util.createElement("span", null, " ", props.language.selectionCount(props.count)) + ]; + const rows = []; + for(const prop in props.item){ + if (prop === (0, _constants.GL_ORDINAL)) continue; + if ((0, _util.isInternalFieldName)(prop)) continue; + rows.push({ + cells: [ + { + content: prop }, - onViewClick: ()=>{ - const view = this.state.view === "2d" ? "3d" : "2d"; - this.changeInsight({ - view - }, { - label: view === "2d" ? (0, _language.strings).labelViewType2d : (0, _language.strings).labelViewType3d - }); + { + content: linkSelect(props.language, prop, props.item[prop], props.selectionHandler) } - }), (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("sanddance-main", this.state.sidebarPinned && "pinned", this.state.sidebarClosed && "closed", (insight.hideLegend || insight.directColor || !(0, _columns.colorMapping)(insight, this.state.dataContent && this.state.dataContent.columns)) && "hide-legend") - }, (0, _base.base).react.createElement("div", { - ref: (div)=>{ - if (div && !this.layoutDivUnpinned) this.layoutDivUnpinned = div; - }, - className: "sanddance-layout-unpinned" - }), (0, _base.base).react.createElement("div", { - ref: (div)=>{ - if (div && !this.layoutDivPinned) this.layoutDivPinned = div; - }, - className: "sanddance-layout-pinned" - }), !loaded && (0, _base.base).react.createElement("div", { - className: "loading" - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Spinner, { - size: (0, _base.base).fluentUI.SpinnerSize.large, - label: (0, _language.strings).loading - })), (0, _base.base).react.createElement((0, _sidebar.Sidebar), { - themePalette: themePalette, - calculating: !!this.state.calculating, - closed: this.state.sidebarClosed, - hideSidebarControls: this.props.hideSidebarControls, - snapshotsHidden: (_c = this.props.snapshotProps) === null || _c === void 0 ? void 0 : _c.hidden, - pinned: this.state.sidebarPinned, - disabled: !loaded, - dataScopeProps: { - themePalette, - compact: this.state.sidebarClosed, - onCompactClick: ()=>{ - this.changeInsight({ - size: this.getLayoutDivSize(this.state.sidebarPinned, false) - }, { - label: null, - omit: true - }, { - sidebarClosed: false - }); - }, - dataSet: this.props.datasetElement, - dataCount: loaded && { - all: this.state.dataContent && this.state.dataContent.data.length, - filtered: this.state.filteredData && this.state.filteredData.length, - selected: selectionState && selectionState.selectedData && selectionState.selectedData.length - }, - active: this.state.sideTabId === (0, _interfaces.SideTabId).Data, - onDataScopeClick: (dataScopeId)=>this.setSideTabId((0, _interfaces.SideTabId).Data, dataScopeId), - selectedDataScope: this.state.dataScopeId, - disabled: !loaded - }, - onSideTabClick: (sideTabId)=>{ - //collapse or toggle - if (sideTabId === (0, _interfaces.SideTabId).Collapse || this.state.sideTabId === sideTabId) { - let { dataScopeId , sidebarClosed } = this.state; - if (sidebarClosed && sideTabId === (0, _interfaces.SideTabId).Data) dataScopeId = this.getBestDataScopeId(); - sidebarClosed = !this.state.sidebarClosed; - this.changeInsight({ - size: this.getLayoutDivSize(this.state.sidebarPinned, sidebarClosed) - }, { - label: null, - omit: true - }, { - dataScopeId, - sidebarClosed - }); - } else if (sideTabId === (0, _interfaces.SideTabId).Pin) this.changeInsight({ - size: this.getLayoutDivSize(!this.state.sidebarPinned, this.state.sidebarClosed) - }, { - label: null, - omit: true - }, { - sidebarPinned: !this.state.sidebarPinned - }); - else this.setSideTabId(sideTabId); - }, - selectedSideTab: this.state.sideTabId - }, loaded && (()=>{ - switch(this.state.sideTabId){ - case (0, _interfaces.SideTabId).ChartType: - return (0, _base.base).react.createElement((0, _chart.Chart), Object.assign({ - themePalette: themePalette, - collapseLabels: this.props.compactUI, - tooltipExclusions: this.state.tooltipExclusions, - toggleTooltipExclusion: (columnName)=>{ - const tooltipExclusions = [ - ...this.state.tooltipExclusions - ]; - const i = tooltipExclusions.indexOf(columnName); - if (i < 0) tooltipExclusions.push(columnName); - else tooltipExclusions.splice(i, 1); - this.setState({ - tooltipExclusions - }); - this.props.onTooltipExclusionsChanged && this.props.onTooltipExclusionsChanged(tooltipExclusions); - }, - disabled: !loaded || this.state.sidebarClosed - }, columnMapProps, { - chart: this.state.chart, - view: this.state.view, - insightColumns: this.state.columns, - onChangeSignal: (role, column, name, value)=>(0, _partialInsight.saveSignalValuePref)(this.prefs, this.state.chart, role, column, name, value) - })); - case (0, _interfaces.SideTabId).Color: - return (0, _base.base).react.createElement((0, _color.Color), Object.assign({ - compactUI: this.props.compactUI, - specCapabilities: this.state.specCapabilities, - disabled: !loaded || this.state.sidebarClosed - }, columnMapProps, { - dataContent: this.state.dataContent, - scheme: this.state.scheme, - colorBin: this.state.colorBin, - colorBinSignal: this.viewer && this.viewer.vegaSpec && this.viewer.vegaSpec.signals.filter((s)=>s.name === (0, _sanddanceReact.SandDance).constants.SignalNames.ColorBinCount)[0], - colorReverseSignal: this.viewer && this.viewer.vegaSpec && this.viewer.vegaSpec.signals.filter((s)=>s.name === (0, _sanddanceReact.SandDance).constants.SignalNames.ColorReverse)[0], - colorColumn: this.state.columns.color, - onColorBinChange: (colorBin)=>{ - this.ignoreSelectionChange = true; - this.viewer.deselect().then(()=>{ - this.ignoreSelectionChange = false; - //allow deselection to render - requestAnimationFrame(()=>{ - this.getColorContext = null; - this.changeInsight({ - colorBin - }, { - label: (0, _language.strings).labelHistoryColorBin - }); - (0, _partialInsight.savePref)(this.prefs, this.state.chart, "color", this.state.columns.color, { - colorBin - }); - }); - }); - }, - onColorSchemeChange: (scheme)=>{ - this.changeColumnMapping("color", this.state.dataContent.columns.filter((c)=>c.name === this.state.columns.color)[0], { - scheme - }); - (0, _partialInsight.savePref)(this.prefs, this.state.chart, "color", this.state.columns.color, { - scheme - }); - }, - onColorBinCountChange: (value)=>{ - const signalValues = {}; - signalValues[(0, _sanddanceReact.SandDance).constants.SignalNames.ColorBinCount] = value; - (0, _partialInsight.savePref)(this.prefs, this.state.chart, "color", this.state.columns.color, { - signalValues - }); - }, - onColorReverseChange: (value)=>{ - this.getColorContext = null; - }, - directColor: this.state.directColor, - onDirectColorChange: (directColor)=>{ - this.changeInsight({ - directColor - }, { - label: (0, _language.strings).labelHistoryDirectColor - }, { - calculating: ()=>this._resize() - }); - } - })); - case (0, _interfaces.SideTabId).Data: - { - const data = datas[this.state.dataScopeId]; - let itemVisible = true; - switch(this.state.dataScopeId){ - case (0, _dataScope.DataScopeId).AllData: - { - const item = this.state.selectedItemIndex[this.state.dataScopeId]; - itemVisible = this.state.dataContent && !this.state.filteredData || this.state.filteredData.indexOf(data[item]) >= 0; - } - } - return (0, _base.base).react.createElement((0, _dataBrowser.DataBrowser), { - explorer: this, - theme: this.props.theme, - themePalette: themePalette, - disabled: !loaded || this.state.sidebarClosed, - columns: this.state.dataContent && this.state.dataContent.columns, - categoricalColumns: columnMapProps.categoricalColumns, - quantitativeColumns: columnMapProps.quantitativeColumns, - data: data, - displayName: this.state.dataFile && this.state.dataFile.displayName || (0, _language.strings).defaultFileName, - nullMessage: (0, _dataBrowser.dataBrowserNullMessages)[this.state.dataScopeId], - zeroMessage: (0, _dataBrowser.dataBrowserZeroMessages)[this.state.dataScopeId], - index: this.state.selectedItemIndex[this.state.dataScopeId], - itemVisible: itemVisible, - dataExportHandler: this.props.dataExportHandler, - selectedDataScope: this.state.dataScopeId, - onDataScopeClick: (dataScopeId)=>this.setSideTabId((0, _interfaces.SideTabId).Data, dataScopeId), - onActivate: (row, index)=>{ - const selectedItemIndex = Object.assign({}, this.state.selectedItemIndex); - selectedItemIndex[this.state.dataScopeId] = index; - this.setState({ - selectedItemIndex - }); - this.silentActivation(row); - }, - onSearch: (e, search)=>{ - if (e.ctrlKey) this.setState({ - sideTabId: (0, _interfaces.SideTabId).Search, - search - }); - else this.doSelect(search); - }, - bingSearchDisabled: this.props.bingSearchDisabled, - onUpdateColumnTypes: (columnTypes)=>{ - this.load(this.state.dataFile, null, { - prefs: this.prefs, - columnTypes - }); - } - }); - } - case (0, _interfaces.SideTabId).Search: - return (0, _base.base).react.createElement((0, _search.Search), { - explorer: this, - collapseLabels: this.props.compactUI, - themePalette: themePalette, - disabled: !loaded || this.state.sidebarClosed, - disableGroupOR: this.props.searchORDisabled, - disableExpressionOR: this.props.searchORDisabled, - initializer: { - columns: columnMapProps.allColumns, - search: this.state.search - }, - autoCompleteDistinctValues: this.state.autoCompleteDistinctValues, - onSelect: (expr)=>this.doSelect(expr), - data: this.state.dataContent.data - }); - case (0, _interfaces.SideTabId).Snapshots: - return (0, _base.base).react.createElement((0, _snapshots.Snapshots), Object.assign({}, this.props.snapshotProps, { - editor: this.snapshotEditor, - themePalette: themePalette, - explorer: this, - snapshots: this.state.snapshots, - selectedSnapshotIndex: this.state.selectedSnapshotIndex, - onClearSnapshots: ()=>{ - const snapshots = []; - this.setState({ - snapshots, - selectedSnapshotIndex: -1 - }); - this.props.onSnapshotsChanged && this.props.onSnapshotsChanged(snapshots); - }, - onWriteSnapshot: (s, i)=>this.writeSnapshot(s, i), - onRemoveSnapshot: (i)=>{ - const snapshots = [ - ...this.state.snapshots - ]; - snapshots.splice(i, 1); - let { selectedSnapshotIndex } = this.state; - if (i === selectedSnapshotIndex) selectedSnapshotIndex = -1; - else if (selectedSnapshotIndex > i) selectedSnapshotIndex--; - this.setState({ - snapshots, - selectedSnapshotIndex - }); - this.props.onSnapshotsChanged && this.props.onSnapshotsChanged(snapshots); - }, - onSnapshotClick: (snapshot, selectedSnapshotIndex)=>{ - this.setState({ - selectedSnapshotIndex - }); - this.calculate(()=>{ - this.handleReviveSnapshot(snapshot, selectedSnapshotIndex); - }); - }, - onMoveUp: (i)=>{ - if (i > 0) { - const snapshots = [ - ...this.state.snapshots - ]; - const temp = snapshots[i - 1]; - snapshots[i - 1] = snapshots[i]; - snapshots[i] = temp; - let { selectedSnapshotIndex } = this.state; - if (i === selectedSnapshotIndex) selectedSnapshotIndex = i - 1; - else if (i - 1 === selectedSnapshotIndex) selectedSnapshotIndex = i; - this.setState({ - snapshots, - selectedSnapshotIndex - }); - this.props.onSnapshotsChanged && this.props.onSnapshotsChanged(snapshots); - } - }, - onMoveDown: (i)=>{ - if (i < this.state.snapshots.length - 1) { - const snapshots = [ - ...this.state.snapshots - ]; - const temp = snapshots[i + 1]; - snapshots[i + 1] = snapshots[i]; - snapshots[i] = temp; - let { selectedSnapshotIndex } = this.state; - if (i === selectedSnapshotIndex) selectedSnapshotIndex = i + 1; - else if (i + 1 === selectedSnapshotIndex) selectedSnapshotIndex = i; - this.setState({ - snapshots, - selectedSnapshotIndex - }); - this.props.onSnapshotsChanged && this.props.onSnapshotsChanged(snapshots); - } - } - })); - case (0, _interfaces.SideTabId).History: - return (0, _base.base).react.createElement((0, _history.History), { - explorer: this, - themePalette: themePalette, - historyIndex: this.state.historyIndex, - historyItems: this.state.historyItems, - redo: (i)=>this.redo(i) - }); - case (0, _interfaces.SideTabId).Transition: - return (0, _base.base).react.createElement((0, _transition.TransitionEditor), Object.assign({}, columnMapProps, this.state, { - compactUI: this.props.compactUI, - explorer: this, - themePalette: themePalette, - changeSetup: (newState, affectsStagger)=>{ - const calculating = ()=>{ - if (affectsStagger) this.viewer.assignTransitionStagger((0, _transition.getTransition)(this.state)); - this.props.onSetupOptionsChanged && this.props.onSetupOptionsChanged(this.getSetup()); - }; - if (newState) this.setState(Object.assign(Object.assign({}, newState), { - calculating - })); - else calculating(); - } - })); - case (0, _interfaces.SideTabId).Settings: - return (0, _base.base).react.createElement((0, _settings.Settings), { - explorer: this, - dataFile: this.state.dataFile, - scheme: this.state.scheme, - hideLegend: this.state.hideLegend, - onToggleLegend: (hideLegend)=>this.setState({ - hideLegend, - calculating: ()=>this._resize() - }), - hideAxes: this.state.hideAxes, - onToggleAxes: (hideAxes)=>this.setState({ - calculating: ()=>this.setState({ - hideAxes - }) - }), - additionalSettings: this.props.additionalSettings - }, this.props.systemInfoChildren); - } - })()), loaded && (0, _base.base).react.createElement("div", { - className: "sanddance-view" - }, (0, _base.base).react.createElement((0, _sanddanceReact.Viewer), { - renderOptions: renderOptions, - viewerOptions: this.viewerOptions, - ref: (reactViewer)=>{ - if (reactViewer) this.viewer = reactViewer.viewer; - }, - onView: (renderResult)=>{ - this.rebaseFilter = false; - this.changespecCapabilities(renderResult.specResult.errors ? renderResult.specResult.specCapabilities : this.viewer.specCapabilities); - this.getColorContext = (oldInsight, newInsight)=>{ - if (!oldInsight && !newInsight) return null; - if (!oldInsight || !newInsight) return null; - if (oldInsight.scheme !== newInsight.scheme) return null; - if (oldInsight.columns.color !== newInsight.columns.color) return null; - if (oldInsight.directColor != newInsight.directColor) return null; - return this.viewer.colorContexts && this.viewer.colorContexts[this.viewer.currentColorContext]; - }; - //don't allow tabbing to the canvas - (0, _canvas.removeTabIndex)(this.viewer); - this.props.onView && this.props.onView(); - }, - onError: (e)=>{ - this.props.onError && this.props.onError(e); - }, - data: this.state.dataContent.data, - insight: insight, - setup: this.getSetup(), - onMount: (el)=>this.viewerMounted(el) - }), this.state.note && (0, _base.base).react.createElement("div", { - className: "sanddance-note" - }, (0, _base.base).react.createElement((0, _iconButton.IconButton), { - className: "cancel", - themePalette: themePalette, - title: (0, _language.strings).buttonClose, - iconName: "Cancel", - onClick: ()=>this.setState({ - note: null - }) - }), (0, _base.base).react.createElement("div", null, this.state.note)), (0, _base.base).react.createElement((0, _renderer.Renderer), { - explorer: this, - advanced: this.state.renderer.advanced, - advancedOptions: this.state.renderer.advancedOptions, - basicOptions: this.state.renderer.basicOptions, - themePalette: themePalette, - onHomeClick: ()=>{ - this.setState({ - camera: undefined - }); - this.viewer.presenter.homeCamera(); - } - })), (0, _base.base).react.createElement((0, _dialog.Dialog), { - title: (0, _language.strings).labelError, - hidden: !this.state.errors, - onDismiss: ()=>{ - this.setState({ - errors: null - }); - } - }, this.state.errors && this.state.errors.map((error, i)=>(0, _base.base).react.createElement("div", { - key: i - }, error))), (0, _base.base).react.createElement((0, _snapshotEditor.SnapshotEditor), Object.assign({ - ref: (se)=>this.snapshotEditor = se - }, this.props.snapshotProps, { - explorer: this, - onWriteSnapshot: (s, i)=>this.writeSnapshot(s, i), - theme: this.props.theme, - themePalette: themePalette - }))), this.state.positionedColumnMapProps && (0, _base.base).react.createElement((0, _clickableTextLayer.PositionedColumnMap), Object.assign({}, this.state.positionedColumnMapProps))); - } - getColumnMapBaseProps() { - const allColumns = this.state.dataContent && this.state.dataContent.columns.filter((c)=>!(0, _sanddanceReact.SandDance).util.isInternalFieldName(c.name, true)); - const quantitativeColumns = allColumns && allColumns.filter((c)=>c.quantitative); - const categoricalColumns = allColumns && allColumns.filter((c)=>!c.quantitative); - const props = { - changeColumnMapping: (role, columnOrRole, defaultColumn, options)=>{ - let column; - if (typeof columnOrRole === "string") { - //look up current insight - const columnName = this.state.columns[columnOrRole]; - column = allColumns.filter((c)=>c.name === columnName)[0] || defaultColumn; - } else column = columnOrRole; - this.changeColumnMapping(role, column, options); - }, - facetStyle: this.state.facetStyle, - totalStyle: this.state.totalStyle, - allColumns, - quantitativeColumns, - categoricalColumns, - specCapabilities: this.state.specCapabilities, - explorer: this - }; - return props; - } + ] + }); } - return new __Explorer(_props); + return _vegaMorphcharts.util.createElement("div", null, props.hasColorMaps && colorMapping, _vegaMorphcharts.util.createElement("h4", null, props.language.headers.selection), _vegaMorphcharts.util.createElement("div", { + className: `${(0, _defaults.cssPrefix)}selection` + }, controlButtons, _vegaMorphcharts.util.createElement("button", { + disabled: !props.hasRefinedData, + onClick: (e)=>props.actionHandler(Action.reset) + }, "reset")), props.item && _vegaMorphcharts.util.createElement("h4", null, props.language.headers.details), _vegaMorphcharts.util.createElement("div", null, _vegaMorphcharts.util.createElement("div", { + className: `${(0, _defaults.cssPrefix)}details-scroll` + }, props.item && scrollButtons), _vegaMorphcharts.util.createElement("div", { + className: `${(0, _defaults.cssPrefix)}details` + }, props.item && _vegaMorphcharts.util.createElement((0, _vegaMorphcharts.controls).Table, { + rows: rows + })))); +}; +function linkSelect(language, columnName, value, selectionHandler) { + return _vegaMorphcharts.util.createElement("span", null, _vegaMorphcharts.util.createElement("a", { + href: "#", + onClick: (e)=>selectionHandler(columnName, value) + }, value), isNaN(value) ? [ + ' ', + _vegaMorphcharts.util.createElement("a", { + className: "bing-search", + href: `https://www.bing.com/search?q=${encodeURIComponent(value)}`, + target: "_blank" + }, language.bing) + ] : ''); } -const Explorer = _Explorer; -},{"./base":"9M4eu","./canvas":"7FRqY","./clickableTextLayer":"9L5VX","./colorMap":"2KdcV","./colorScheme":"jh1sg","./columns":"aWo5j","./controls/dataScope":"i7FKh","./controls/dialog":"ep4zG","./controls/iconButton":"6gzbB","./controls/sidebar":"hiOgE","./controls/topbar":"dJZY5","./dataLoader":"kuJuZ","./defaults":"oAoKB","./dialogs/chart":"9MRcr","./dialogs/color":"7Mylg","./dialogs/dataBrowser":"dQuoi","./dialogs/history":"1YLAA","./dialogs/search":"dda71","./dialogs/settings":"1PLto","./dialogs/snapshotEditor":"2kESg","./dialogs/snapshots":"k9WKc","./dialogs/transition":"2vaDJ","./interfaces":"8LHoz","./language":"kzoCJ","./mouseEvent":"9fxMb","./partialInsight":"8eFp1","./themes":"CJpaJ","./searchGroups":"6id2x","@msrvida/chart-recommender":"lJbBT","@msrvida/sanddance-react":"73dPQ","./controls/renderer":"2N3JL","./dialogs/backgroundImageEditor":"02TgK","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2KdcV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "applyColorButtons", ()=>applyColorButtons); +},{"@msrvida/vega-morphcharts":"9Sd5M","./defaults":"7bMd0","./constants":"ix2qh","@msrvida/search-expression":"4F93b","./util":"g08sL","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bOtA3":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _base = require("./base"); -var _iconButton = require("./controls/iconButton"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _language = require("./language"); -const className = "sanddance-panel-tools"; -function ensureToolbar(panel) { - const existing = panel.getElementsByClassName(className); - if (existing.length > 0) return existing[0]; - else { - const div = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.addDiv(panel, className); - panel.insertAdjacentElement("afterbegin", div); - return div; - } +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "ensureHeaders", ()=>ensureHeaders); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +function ensureHeaders(presenter, headers) { + const vegaControls = presenter.getElement((0, _vegaMorphcharts.PresenterElement).vegaControls); + conditionalHeader(!!vegaControls.querySelectorAll('.vega-bindings > *').length, vegaControls, headers.chart); + const legend = presenter.getElement((0, _vegaMorphcharts.PresenterElement).legend); + conditionalHeader(!!legend.children.length, legend, headers.legend); } -function applyColorButtons(presenter, showLegend, props) { - const panel = presenter.getElement((0, _sanddanceReact.SandDance).VegaMorphCharts.PresenterElement.panel); - const div = ensureToolbar(panel); - (0, _base.base).reactDOM.render(ColorMap(props), div); - panel.style.display = showLegend ? "" : "none"; +function conditionalHeader(condition, element, header) { + const existing = existingHeader(element, header); + if (condition && !existing) addHeader(element, header); + if (!condition && existing) existing.remove(); } -function ColorMap(props) { - const menuProps = { - items: [ - { - key: "new", - text: (0, _language.strings).buttonColorSchemeRemap, - disabled: !props.canRemap || props.isRemap, - onClick: ()=>props.colorMapHandler(true) - }, - { - key: "old", - text: (0, _language.strings).buttonColorSchemeKeep, - disabled: !props.canRemap || !props.isRemap, - onClick: ()=>props.colorMapHandler(false) - }, - ] - }; - return (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _iconButton.IconButton), { - styles: { - menuIcon: { - display: "none" - } - }, - themePalette: props.themePalette, - title: (0, _language.strings).buttonColorSchemeMap, - onClick: null, - iconName: props.canRemap ? "FiltersSolid" : "Filters", - menuProps: menuProps - })); +function addHeader(element, header) { + const h = document.createElement('h4'); + h.innerHTML = header; + element.insertAdjacentElement('beforebegin', h); +} +function existingHeader(element, header) { + const { previousElementSibling } = element; + if (previousElementSibling && previousElementSibling.innerHTML === header) return previousElementSibling; } -},{"./base":"9M4eu","./controls/iconButton":"6gzbB","@msrvida/sanddance-react":"73dPQ","./language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jh1sg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); +},{"@msrvida/vega-morphcharts":"9Sd5M","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"buMaw":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ parcelHelpers.export(exports, "bestColorScheme", ()=>bestColorScheme); -function bestColorScheme(newColumn, oldColumn, oldScheme) { - if (oldColumn && oldColumn.quantitative === newColumn.quantitative && defaultColorScheme(oldColumn) === defaultColorScheme(newColumn)) return oldScheme; - return defaultColorScheme(newColumn); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "finalizeLegend", ()=>finalizeLegend); +var _sanddanceSpecs = require("@msrvida/sanddance-specs"); +var _expression = require("./expression"); +function legendRange(colorBinType, column, legend, clickedIndex) { + if (column.quantitative) return selectQuantitative(colorBinType, column, legend, clickedIndex); + else return selectCategorical(column, legend, clickedIndex); } -function defaultColorScheme(c) { - if (c.quantitative) return "redyellowgreen"; - else if (c.stats.distinctValueCount === 2) return "dual_redgreen"; - else if (c.stats.distinctValueCount <= 10) return "category10"; - return "category20"; +function selectCategorical(column, legend, clickedIndex) { + const value = legend.rows[clickedIndex].value; + if (value === (0, _sanddanceSpecs.Other)) { + const values = []; + for(const i in legend.rows)if (+i !== clickedIndex) values.push(legend.rows[i].value); + return (0, _expression.selectNone)(column, values); + } else //select equal + return { + expressions: [ + (0, _expression.selectExact)(column, legend.rows[clickedIndex].value) + ] + }; +} +function selectQuantitative(colorBinType, column, legend, clickedIndex) { + const keys = Object.keys(legend.rows).map((key)=>+key).sort((a, b)=>+a - +b); + let lowValue; + let lowOperator; + let highValue; + let highOperator; + const rowText = legend.rows[clickedIndex].label; + switch(colorBinType){ + case 'continuous': + lowValue = rowText; + if (clickedIndex < keys.length - 1) highValue = legend.rows[clickedIndex + 1].value; + break; + default: + { + if (rowText.indexOf('null') > 0) { + const ex = { + expressions: [ + (0, _expression.selectNullOrEmpty)(column) + ] + }; + return ex; + } + const dash = rowText.indexOf("\u2013"); //this is not the common dash character! + if (dash > 0) { + //bug in Vega for quantize? + //lowOperator = '>'; + //highOperator = '<='; + lowValue = rowText.substr(0, dash); + highValue = rowText.substr(dash + 1); + } else { + if (rowText.indexOf('<') >= 0) highValue = rowText.substring(2); + else if (rowText.indexOf("\u2265") >= 0) lowValue = rowText.substring(2); + } + } + } + if (lowValue) lowValue = (0, _expression.notNice)(lowValue); + if (highValue) highValue = (0, _expression.notNice)(highValue); + if (lowValue === highValue) return { + expressions: [ + (0, _expression.selectExact)(column, lowValue) + ] + }; + else return (0, _expression.selectBetween)(column, lowValue, highValue, lowOperator, highOperator); +} +function finalizeLegend(colorBinType, colorColumn, legend, language) { + const rowTexts = []; + for(const i in legend.rows){ + const row = legend.rows[i]; + row.search = legendRange(colorBinType, colorColumn, legend, +i); + if (row.value === (0, _sanddanceSpecs.Other)) row.label = language.legendOther; + else rowTexts.push(row.value); + } } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i7FKh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DataScopeId", ()=>DataScopeId); -parcelHelpers.export(exports, "resetSelectedItemIndex", ()=>resetSelectedItemIndex); -parcelHelpers.export(exports, "DataScope", ()=>DataScope); +},{"@msrvida/sanddance-specs":"aOvSr","./expression":"2foo2","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eRzwB":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _button = require("./button"); -var _base = require("../base"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _d3Format = require("d3-format"); -var DataScopeId; -(function(DataScopeId) { - DataScopeId[DataScopeId["AllData"] = 0] = "AllData"; - DataScopeId[DataScopeId["SelectedData"] = 1] = "SelectedData"; - DataScopeId[DataScopeId["FilteredData"] = 2] = "FilteredData"; -})(DataScopeId || (DataScopeId = {})); -function resetSelectedItemIndex(selectedItemIndex) { - selectedItemIndex[DataScopeId.AllData] = 0; - selectedItemIndex[DataScopeId.FilteredData] = 0; - selectedItemIndex[DataScopeId.SelectedData] = 0; -} -const shortFormat = (0, _d3Format.format)(".2~s"); -function short(n) { - return n === -1 ? "--" : n ? n < 1000 ? n.toString() : shortFormat(n) : "0"; -} -function DataScope(props) { - const dataCount = Object.assign({ - all: -1, - filtered: -1, - selected: -1 - }, props.dataCount); - return props.compact ? (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("sanddance-datascope", "compact"), - onClick: props.onCompactClick - }, (0, _base.base).react.createElement(Compact, Object.assign({}, props, { - dataScopeId: DataScopeId.AllData, - text: (0, _language.strings).selectDataSpanAll, - count: dataCount.all - })), (0, _base.base).react.createElement(Compact, Object.assign({}, props, { - dataScopeId: DataScopeId.FilteredData, - text: (0, _language.strings).selectDataSpanFilter, - count: dataCount.filtered - })), (0, _base.base).react.createElement(Compact, Object.assign({}, props, { - dataScopeId: DataScopeId.SelectedData, - text: (0, _language.strings).selectDataSpanSelection, - count: dataCount.selected - }))) : (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("sanddance-datascope", "extended", props.active && "active") - }, (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement("div", null, props.dataSet), (0, _base.base).react.createElement("div", { - className: "datascope-buttons" - }, (0, _base.base).react.createElement(DataScopeButton, Object.assign({}, props, { - dataScopeId: DataScopeId.AllData, - text: (0, _language.strings).selectDataSpanAll, - count: dataCount.all - })), (0, _base.base).react.createElement(DataScopeButton, Object.assign({}, props, { - dataScopeId: DataScopeId.FilteredData, - text: (0, _language.strings).selectDataSpanFilter, - count: dataCount.filtered - })), (0, _base.base).react.createElement(DataScopeButton, Object.assign({}, props, { - dataScopeId: DataScopeId.SelectedData, - text: (0, _language.strings).selectDataSpanSelection, - count: dataCount.selected - }))))); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "assignOrdinals", ()=>assignOrdinals); +parcelHelpers.export(exports, "getDataIndexOfCube", ()=>getDataIndexOfCube); +var _constants = require("./constants"); +function assignOrdinals(columns, data, ordinalMap) { + const uCol = columns.uid && columns.uid.name; + if (ordinalMap) data.forEach((d, i)=>{ + const key = uCol ? d[uCol] : i; + d[0, _constants.GL_ORDINAL] = ordinalMap[key]; + }); + else { + ordinalMap = {}; + data.forEach((d, i)=>{ + d[0, _constants.GL_ORDINAL] = i; + const uColValue = uCol ? d[uCol] : i; + ordinalMap[uColValue] = i; + }); + } + return ordinalMap; } -function Compact(props) { - return (0, _base.base).react.createElement("div", { - title: props.text, - onClick: ()=>{ - props.onDataScopeClick(props.dataScopeId); - } - }, short(props.count)); +function getDataIndexOfCube(cube, data) { + const len = data.length; + for(let i = 0; i < len; i++){ + if (data[i][0, _constants.GL_ORDINAL] === cube.ordinal) return i; + } } -function DataScopeButton(props) { - return (0, _base.base).react.createElement((0, _button.Button), { - themePalette: props.themePalette, - className: (0, _sanddanceReact.util).classList("datascope-button", props.selectedDataScope === props.dataScopeId && "selected"), - disabled: props.disabled, - text: props.text, - onClick: ()=>{ - props.onDataScopeClick(props.dataScopeId); - }, - onRenderText: ()=>{ - return (0, _base.base).react.createElement("div", { - title: props.count > 0 ? props.count.toString() : "" - }, (0, _base.base).react.createElement("label", null, props.text), (0, _base.base).react.createElement("div", null, short(props.count))); - }, - onRenderIcon: ()=>null - }); + +},{"./constants":"ix2qh","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6kluJ":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "getSearchGroupFromVegaValue", ()=>getSearchGroupFromVegaValue); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +var _array = require("./array"); +function getSearchGroupFromVegaValue(search) { + let group; + const vegaSearch = search; + if (Array.isArray(vegaSearch)) { + //flatten into one group + group = { + expressions: [] + }; + vegaSearch.forEach((g)=>{ + const clonedExpressions = _vegaMorphcharts.util.clone(g.expressions).filter(Boolean); + clonedExpressions[0].clause = '&&'; + (0, _array.push)(group.expressions, clonedExpressions); + }); + } else group = vegaSearch ? { + expressions: vegaSearch.expressions.filter(Boolean) + } : null; + return group; } -},{"./button":"j0llx","../base":"9M4eu","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","d3-format":"81UdZ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"81UdZ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/vega-morphcharts":"9Sd5M","./array":"cis83","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cis83":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "formatDefaultLocale", ()=>(0, _defaultLocaleJsDefault.default)); -parcelHelpers.export(exports, "format", ()=>(0, _defaultLocaleJs.format)); -parcelHelpers.export(exports, "formatPrefix", ()=>(0, _defaultLocaleJs.formatPrefix)); -parcelHelpers.export(exports, "formatLocale", ()=>(0, _localeJsDefault.default)); -parcelHelpers.export(exports, "formatSpecifier", ()=>(0, _formatSpecifierJsDefault.default)); -parcelHelpers.export(exports, "FormatSpecifier", ()=>(0, _formatSpecifierJs.FormatSpecifier)); -parcelHelpers.export(exports, "precisionFixed", ()=>(0, _precisionFixedJsDefault.default)); -parcelHelpers.export(exports, "precisionPrefix", ()=>(0, _precisionPrefixJsDefault.default)); -parcelHelpers.export(exports, "precisionRound", ()=>(0, _precisionRoundJsDefault.default)); -var _defaultLocaleJs = require("./defaultLocale.js"); -var _defaultLocaleJsDefault = parcelHelpers.interopDefault(_defaultLocaleJs); -var _localeJs = require("./locale.js"); -var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); -var _formatSpecifierJs = require("./formatSpecifier.js"); -var _formatSpecifierJsDefault = parcelHelpers.interopDefault(_formatSpecifierJs); -var _precisionFixedJs = require("./precisionFixed.js"); -var _precisionFixedJsDefault = parcelHelpers.interopDefault(_precisionFixedJs); -var _precisionPrefixJs = require("./precisionPrefix.js"); -var _precisionPrefixJsDefault = parcelHelpers.interopDefault(_precisionPrefixJs); -var _precisionRoundJs = require("./precisionRound.js"); -var _precisionRoundJsDefault = parcelHelpers.interopDefault(_precisionRoundJs); +parcelHelpers.export(exports, "allTruthy", ()=>allTruthy); +parcelHelpers.export(exports, "concat", ()=>concat); +parcelHelpers.export(exports, "push", ()=>push); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +const { allTruthy, concat, push } = (0, _vegaMorphcharts.util); -},{"./defaultLocale.js":"40yW9","./locale.js":"daHaT","./formatSpecifier.js":"fYxaC","./precisionFixed.js":false,"./precisionPrefix.js":false,"./precisionRound.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"40yW9":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/vega-morphcharts":"9Sd5M","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"xDtCn":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "format", ()=>format); -parcelHelpers.export(exports, "formatPrefix", ()=>formatPrefix); -var _localeJs = require("./locale.js"); -var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); -var locale; -var format; -var formatPrefix; -defaultLocale({ - decimal: ".", - thousands: ",", - grouping: [ - 3 - ], - currency: [ - "$", - "" - ], - minus: "-" -}); -function defaultLocale(definition) { - locale = (0, _localeJsDefault.default)(definition); - format = locale.format; - formatPrefix = locale.formatPrefix; - return locale; +parcelHelpers.export(exports, "applySignalValues", ()=>applySignalValues); +parcelHelpers.export(exports, "extractSignalValuesFromView", ()=>extractSignalValuesFromView); +parcelHelpers.export(exports, "unbindSignalUI", ()=>unbindSignalUI); +var _sanddanceSpecs = require("@msrvida/sanddance-specs"); +function applySignalValues(sv, b) { + if (!sv || !b || !b.signals || !b.signals.length) return; + for(const key in sv){ + const value = sv[key]; + const signalB = b.signals.filter((signal)=>signal.name === key)[0]; + if (signalB && signalB.bind) signalB.value = value; + } +} +function extractSignalValuesFromView(view, spec) { + if (!view || !spec || !spec.signals || !spec.signals.length) return; + const result = {}; + spec.signals.forEach((signalA)=>{ + //bound to a UI control + if (signalA.bind) try { + result[signalA.name] = view.signal(signalA.name); + } catch (e) { + // continue regardless of error + } + }); + return result; +} +//signals not capable of handling with MorphCharts +const hideSignalUI = [ + (0, _sanddanceSpecs.SignalNames).MarkOpacity, + (0, _sanddanceSpecs.SignalNames).TextAngleX, + (0, _sanddanceSpecs.SignalNames).TextAngleY +]; +function unbindSignalUI(spec) { + spec.signals.forEach((signal)=>{ + if (hideSignalUI.indexOf(signal.name) >= 0) delete signal.bind; + }); } -exports.default = defaultLocale; -},{"./locale.js":"daHaT","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"daHaT":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/sanddance-specs":"aOvSr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bKbCn":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -var _exponentJs = require("./exponent.js"); -var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -var _formatGroupJs = require("./formatGroup.js"); -var _formatGroupJsDefault = parcelHelpers.interopDefault(_formatGroupJs); -var _formatNumeralsJs = require("./formatNumerals.js"); -var _formatNumeralsJsDefault = parcelHelpers.interopDefault(_formatNumeralsJs); -var _formatSpecifierJs = require("./formatSpecifier.js"); -var _formatSpecifierJsDefault = parcelHelpers.interopDefault(_formatSpecifierJs); -var _formatTrimJs = require("./formatTrim.js"); -var _formatTrimJsDefault = parcelHelpers.interopDefault(_formatTrimJs); -var _formatTypesJs = require("./formatTypes.js"); -var _formatTypesJsDefault = parcelHelpers.interopDefault(_formatTypesJs); -var _formatPrefixAutoJs = require("./formatPrefixAuto.js"); -var _identityJs = require("./identity.js"); -var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); -var map = Array.prototype.map, prefixes = [ - "y", - "z", - "a", - "f", - "p", - "n", - "\xb5", - "m", - "", - "k", - "M", - "G", - "T", - "P", - "E", - "Z", - "Y" -]; -exports.default = function(locale) { - var group = locale.grouping === undefined || locale.thousands === undefined ? (0, _identityJsDefault.default) : (0, _formatGroupJsDefault.default)(map.call(locale.grouping, Number), locale.thousands + ""), currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", decimal = locale.decimal === undefined ? "." : locale.decimal + "", numerals = locale.numerals === undefined ? (0, _identityJsDefault.default) : (0, _formatNumeralsJsDefault.default)(map.call(locale.numerals, String)), percent = locale.percent === undefined ? "%" : locale.percent + "", minus = locale.minus === undefined ? "-" : locale.minus + "", nan = locale.nan === undefined ? "NaN" : locale.nan + ""; - function newFormat(specifier) { - specifier = (0, _formatSpecifierJsDefault.default)(specifier); - var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type; - // The "n" type is an alias for ",g". - if (type === "n") comma = true, type = "g"; - else if (!(0, _formatTypesJsDefault.default)[type]) precision === undefined && (precision = 12), trim = true, type = "g"; - // If zero fill is specified, padding goes after sign and before digits. - if (zero || fill === "0" && align === "=") zero = true, fill = "0", align = "="; - // Compute the prefix and suffix. - // For SI-prefix, the suffix is lazily computed. - var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; - // What format function should we use? - // Is this an integer type? - // Can this type generate exponential notation? - var formatType = (0, _formatTypesJsDefault.default)[type], maybeSuffix = /[defgprs%]/.test(type); - // Set the default precision if not specified, - // or clamp the specified precision to the supported range. - // For significant precision, it must be in [1, 21]. - // For fixed precision, it must be in [0, 20]. - precision = precision === undefined ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); - function format(value) { - var valuePrefix = prefix, valueSuffix = suffix, i, n, c; - if (type === "c") { - valueSuffix = formatType(value) + valueSuffix; - value = ""; - } else { - value = +value; - // Determine the sign. -0 is not less than 0, but 1 / -0 is! - var valueNegative = value < 0 || 1 / value < 0; - // Perform the initial formatting. - value = isNaN(value) ? nan : formatType(Math.abs(value), precision); - // Trim insignificant zeros. - if (trim) value = (0, _formatTrimJsDefault.default)(value); - // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. - if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; - // Compute the prefix and suffix. - valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; - valueSuffix = (type === "s" ? prefixes[8 + (0, _formatPrefixAutoJs.prefixExponent) / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); - // Break the formatted value into the integer “value” part that can be - // grouped, and fractional or exponential “suffix” part that is not. - if (maybeSuffix) { - i = -1, n = value.length; - while(++i < n)if (c = value.charCodeAt(i), 48 > c || c > 57) { - valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; - value = value.slice(0, i); - break; - } - } +parcelHelpers.export(exports, "Tooltip", ()=>Tooltip); +parcelHelpers.export(exports, "cleanDataItem", ()=>cleanDataItem); +var _vegaMorphcharts = require("@msrvida/vega-morphcharts"); +var _constants = require("./constants"); +var _util = require("./util"); +const { outerSize } = _vegaMorphcharts.util; +const { Table } = _vegaMorphcharts.controls; +class Tooltip { + constructor(props){ + this.props = props; + const renderProps = { + cssPrefix: props.cssPrefix, + rows: getRows(props.dataItem) + }; + this.finalizeHandler = ()=>this.destroy(); + this.element = renderTooltip(renderProps); + if (this.element) { + this.element.style.position = 'absolute'; + this.child = this.element.firstChild; + document.body.appendChild(this.element); + //measure and move as necessary + let m = outerSize(this.child); + while(m.height > document.documentElement.clientHeight){ + const tr = this.child.querySelector('tr:last-child'); + if (tr) tr.parentElement.removeChild(tr); + else break; + m = outerSize(this.child); } - // If the fill character is not "0", grouping is applied before padding. - if (comma && !zero) value = group(value, Infinity); - // Compute the padding. - var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : ""; - // If the fill character is "0", grouping is applied after padding. - if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; - // Reconstruct the final output based on the desired alignment. - switch(align){ - case "<": - value = valuePrefix + value + valueSuffix + padding; - break; - case "=": - value = valuePrefix + padding + value + valueSuffix; - break; - case "^": - value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); - break; - default: - value = padding + valuePrefix + value + valueSuffix; - break; + let position; + const te = props.event; + if (te.touches) position = te[0]; + else { + const pme = props.event; + position = pme; + } + if (position.clientX + m.width >= document.documentElement.clientWidth) this.child.style.right = '0'; + let moveTop = true; + if (position.clientY + m.height >= document.documentElement.clientHeight) { + if (position.clientY - m.height > 0) this.child.style.bottom = '0'; + else moveTop = false; } - return numerals(value); + if (moveTop) this.element.style.top = `${position.clientY}px`; + this.element.style.left = `${position.clientX}px`; + this.child.addEventListener('mouseenter', this.finalizeHandler); + this.child.addEventListener('mousemove', this.finalizeHandler); + this.child.addEventListener('mouseover', this.finalizeHandler); } - format.toString = function() { - return specifier + ""; - }; - return format; } - function formatPrefix(specifier, value) { - var f = newFormat((specifier = (0, _formatSpecifierJsDefault.default)(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor((0, _exponentJsDefault.default)(value) / 3))) * 3, k = Math.pow(10, -e), prefix = prefixes[8 + e / 3]; - return function(value) { - return f(k * value) + prefix; - }; + destroy() { + this.child.removeEventListener('mouseenter', this.finalizeHandler); + this.child.removeEventListener('mousemove', this.finalizeHandler); + this.child.removeEventListener('mouseover', this.finalizeHandler); + if (this.element) document.body.removeChild(this.element); + this.element = null; } - return { - format: newFormat, - formatPrefix: formatPrefix - }; -}; - -},{"./exponent.js":"44cmE","./formatGroup.js":"9WiqM","./formatNumerals.js":"cMk82","./formatSpecifier.js":"fYxaC","./formatTrim.js":"kGdg9","./formatTypes.js":"fXsmM","./formatPrefixAuto.js":"eZlv6","./identity.js":"3lygE","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"44cmE":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _formatDecimalJs = require("./formatDecimal.js"); -exports.default = function(x) { - return x = (0, _formatDecimalJs.formatDecimalParts)(Math.abs(x)), x ? x[1] : NaN; -}; - -},{"./formatDecimal.js":"dx3LJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dx3LJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -// Computes the decimal coefficient and exponent of the specified number x with -// significant digits p, where x is positive and p is in [1, 21] or undefined. -// For example, formatDecimalParts(1.23) returns ["123", 0]. -parcelHelpers.export(exports, "formatDecimalParts", ()=>formatDecimalParts); -exports.default = function(x) { - return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10); -}; -function formatDecimalParts(x, p) { - if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity - var i, coefficient = x.slice(0, i); - // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ - // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). - return [ - coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, - +x.slice(i + 1) - ]; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9WiqM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(grouping, thousands) { - return function(value, width) { - var i = value.length, t = [], j = 0, g = grouping[0], length = 0; - while(i > 0 && g > 0){ - if (length + g + 1 > width) g = Math.max(1, width - length); - t.push(value.substring(i -= g, i + g)); - if ((length += g + 1) > width) break; - g = grouping[j = (j + 1) % grouping.length]; +function cleanDataItem(item) { + const ret = {}; + for(const columnName in item){ + if (columnName === (0, _constants.GL_ORDINAL)) continue; + if ((0, _util.isInternalFieldName)(columnName)) continue; + ret[columnName] = item[columnName]; + } + return ret; +} +function getRows(item) { + const rows = []; + for(const columnName in item){ + const value = item[columnName]; + let content; + switch(value){ + case null: + content = _vegaMorphcharts.util.createElement("i", null, "null"); + break; + case undefined: + content = _vegaMorphcharts.util.createElement("i", null, "undefined"); + break; + default: + content = value.toString(); } - return t.reverse().join(thousands); - }; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cMk82":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(numerals) { - return function(value) { - return value.replace(/[0-9]/g, function(i) { - return numerals[+i]; + //} + rows.push({ + cells: [ + { + content: columnName + ':' + }, + { + content + } + ] }); - }; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fYxaC":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FormatSpecifier", ()=>FormatSpecifier); -// [[fill]align][sign][symbol][0][width][,][.precision][~][type] -var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; -function formatSpecifier(specifier) { - if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); - var match; - return new FormatSpecifier({ - fill: match[1], - align: match[2], - sign: match[3], - symbol: match[4], - zero: match[5], - width: match[6], - comma: match[7], - precision: match[8] && match[8].slice(1), - trim: match[9], - type: match[10] - }); -} -exports.default = formatSpecifier; -formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof -function FormatSpecifier(specifier) { - this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; - this.align = specifier.align === undefined ? ">" : specifier.align + ""; - this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; - this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; - this.zero = !!specifier.zero; - this.width = specifier.width === undefined ? undefined : +specifier.width; - this.comma = !!specifier.comma; - this.precision = specifier.precision === undefined ? undefined : +specifier.precision; - this.trim = !!specifier.trim; - this.type = specifier.type === undefined ? "" : specifier.type + ""; + } + return rows; } -FormatSpecifier.prototype.toString = function() { - return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type; +const renderTooltip = (props)=>{ + return props.rows.length === 0 ? null : _vegaMorphcharts.util.createElement("div", { + className: `${props.cssPrefix}tooltip` + }, Table({ + rows: props.rows + })); }; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kGdg9":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@msrvida/vega-morphcharts":"9Sd5M","./constants":"ix2qh","./util":"g08sL","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"grMul":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. -exports.default = function(s) { - out: for(var n = s.length, i = 1, i0 = -1, i1; i < n; ++i)switch(s[i]){ - case ".": - i0 = i1 = i; - break; - case "0": - if (i0 === 0) i0 = i; - i1 = i; - break; - default: - if (!+s[i]) break out; - if (i0 > 0) i0 = 0; - break; +parcelHelpers.export(exports, "CharacterSet", ()=>CharacterSet); +class CharacterSet { + resetCharacterSet(forceNewCharacterSet, oldInsight, newInsight) { + if (forceNewCharacterSet || needsNewCharacterSet(oldInsight, newInsight)) this.chars = undefined; } - return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fXsmM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _formatDecimalJs = require("./formatDecimal.js"); -var _formatDecimalJsDefault = parcelHelpers.interopDefault(_formatDecimalJs); -var _formatPrefixAutoJs = require("./formatPrefixAuto.js"); -var _formatPrefixAutoJsDefault = parcelHelpers.interopDefault(_formatPrefixAutoJs); -var _formatRoundedJs = require("./formatRounded.js"); -var _formatRoundedJsDefault = parcelHelpers.interopDefault(_formatRoundedJs); -exports.default = { - "%": function(x, p) { - return (x * 100).toFixed(p); - }, - "b": function(x) { - return Math.round(x).toString(2); - }, - "c": function(x) { - return x + ""; - }, - "d": (0, _formatDecimalJsDefault.default), - "e": function(x, p) { - return x.toExponential(p); - }, - "f": function(x, p) { - return x.toFixed(p); - }, - "g": function(x, p) { - return x.toPrecision(p); - }, - "o": function(x) { - return Math.round(x).toString(8); - }, - "p": function(x, p) { - return (0, _formatRoundedJsDefault.default)(x * 100, p); - }, - "r": (0, _formatRoundedJsDefault.default), - "s": (0, _formatPrefixAutoJsDefault.default), - "X": function(x) { - return Math.round(x).toString(16).toUpperCase(); - }, - "x": function(x) { - return Math.round(x).toString(16); + getCharacterSet(stage) { + if (!this.chars) { + const map = {}; + const addText = (text)=>{ + Array.from(text).forEach((char)=>{ + map[char] = true; + }); + }; + stage.textData.forEach((t)=>addText(t.text)); + const { x, y } = stage.axes; + [ + x, + y + ].forEach((axes)=>{ + axes.forEach((axis)=>{ + if (axis.tickText) axis.tickText.forEach((t)=>addText(t.text)); + if (axis.title) addText(axis.title.text); + }); + }); + this.chars = Object.keys(map); + } + return this.chars; } -}; - -},{"./formatDecimal.js":"dx3LJ","./formatPrefixAuto.js":"eZlv6","./formatRounded.js":"6wFZM","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eZlv6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "prefixExponent", ()=>prefixExponent); -var _formatDecimalJs = require("./formatDecimal.js"); -var prefixExponent; -exports.default = function(x, p) { - var d = (0, _formatDecimalJs.formatDecimalParts)(x, p); - if (!d) return x + ""; - var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length; - return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + (0, _formatDecimalJs.formatDecimalParts)(x, Math.max(0, p + i - 1))[0]; // less than 1y! -}; - -},{"./formatDecimal.js":"dx3LJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6wFZM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _formatDecimalJs = require("./formatDecimal.js"); -exports.default = function(x, p) { - var d = (0, _formatDecimalJs.formatDecimalParts)(x, p); - if (!d) return x + ""; - var coefficient = d[0], exponent = d[1]; - return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0"); -}; - -},{"./formatDecimal.js":"dx3LJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"3lygE":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -exports.default = function(x) { - return x; -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hiOgE":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Sidebar", ()=>Sidebar); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _dataScope = require("./dataScope"); -var _scrollable = require("./scrollable"); -var _interfaces = require("../interfaces"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _sideButton = require("./sideButton"); -function Sidebar(props) { - const sidebuttons = [ - { - sideTabId: (0, _interfaces.SideTabId).ChartType, - iconName: "BIDashboard", - title: (0, _language.strings).labelChart - }, - { - sideTabId: (0, _interfaces.SideTabId).Color, - iconName: "Color", - title: (0, _language.strings).labelColor - }, - { - sideTabId: (0, _interfaces.SideTabId).Data, - iconName: "Table", - title: (0, _language.strings).labelDataBrowser - }, - { - sideTabId: (0, _interfaces.SideTabId).Search, - iconName: "Search", - title: (0, _language.strings).labelSearch - }, - !props.snapshotsHidden && { - sideTabId: (0, _interfaces.SideTabId).Snapshots, - iconName: "Camera", - title: (0, _language.strings).labelSnapshots - }, - { - sideTabId: (0, _interfaces.SideTabId).History, - iconName: "History", - title: (0, _language.strings).labelHistory - }, - { - sideTabId: (0, _interfaces.SideTabId).Transition, - iconName: "Flow", - title: (0, _language.strings).labelTransition - }, - { - sideTabId: (0, _interfaces.SideTabId).Settings, - iconName: "Settings", - title: (0, _language.strings).labelChartSettings - }, - ].filter(Boolean); - return (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("sanddance-sidebar", "calculator", props.pinned && "pinned", props.closed && "closed") - }, (0, _base.base).react.createElement("div", { - className: "sidebar-content" - }, (0, _base.base).react.createElement((0, _dataScope.DataScope), Object.assign({}, props.dataScopeProps)), (0, _base.base).react.createElement("div", { - className: "vbuttons", - role: "tablist" - }, (0, _base.base).react.createElement("div", { - className: "sidebar-dialogs" - }, sidebuttons.map((sidebutton, i)=>(0, _base.base).react.createElement((0, _sideButton.Sidebutton), Object.assign({ - key: i - }, props, sidebutton, { - themePalette: props.themePalette - })))), !props.hideSidebarControls && (0, _base.base).react.createElement("div", { - className: "sidebar-controls" - }, (0, _base.base).react.createElement((0, _sideButton.Sidebutton), Object.assign({}, props, { - role: "button", - sideTabId: (0, _interfaces.SideTabId).Pin, - iconName: props.pinned ? "Pinned" : "Pin", - title: props.pinned ? (0, _language.strings).buttonToolbarFloat : (0, _language.strings).buttonToolbarDock - })), (0, _base.base).react.createElement((0, _sideButton.Sidebutton), Object.assign({}, props, { - role: "button", - sideTabId: (0, _interfaces.SideTabId).Collapse, - iconName: props.closed ? "DoubleChevronRight12" : "DoubleChevronLeft12", - title: props.closed ? (0, _language.strings).buttonToolbarShow : (0, _language.strings).buttonToolbarHide - })))), (0, _base.base).react.createElement((0, _scrollable.Scrollable), { - role: "tabpanel" - }, (0, _base.base).react.createElement("div", { - className: "sidetab" - }, props.children)), props.calculating && (0, _base.base).react.createElement("div", { - className: "calculating" - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Spinner, { - size: (0, _base.base).fluentUI.SpinnerSize.large - })))); } - -},{"../base":"9M4eu","./dataScope":"i7FKh","./scrollable":"cPwQr","../interfaces":"8LHoz","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","./sideButton":"flhRz","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cPwQr":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Scrollable", ()=>Scrollable); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function Scrollable(props) { - return (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("scrollable-container", props.className), - role: props.role - }, (0, _base.base).react.createElement("div", { - className: "scrollable" - }, props.children)); +function needsNewCharacterSet(oldInsight, newInsight) { + if (!oldInsight) return true; + if (!newInsight) return true; + if (oldInsight.chart !== newInsight.chart) return true; + if (oldInsight.facetStyle !== newInsight.facetStyle) return true; + if (oldInsight.totalStyle !== newInsight.totalStyle) return true; + if (oldInsight.hideAxes !== newInsight.hideAxes) return true; + if (differentObjectValues(oldInsight.signalValues, newInsight.signalValues)) return true; + if (differentObjectValues(oldInsight.size, newInsight.size)) return true; + const oldColumns = oldInsight.columns; + const newColumns = newInsight.columns; + if (oldColumns.facet !== newColumns.facet) return true; + if (oldColumns.facetV !== newColumns.facetV) return true; + if (oldColumns.x !== newColumns.x) return true; + if (oldColumns.y !== newColumns.y) return true; + if (oldColumns.z !== newColumns.z) return true; + return false; } - -},{"../base":"9M4eu","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8LHoz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "SideTabId", ()=>SideTabId); -var SideTabId; -(function(SideTabId) { - SideTabId[SideTabId["ChartType"] = 0] = "ChartType"; - SideTabId[SideTabId["Data"] = 1] = "Data"; - SideTabId[SideTabId["Search"] = 2] = "Search"; - SideTabId[SideTabId["Color"] = 3] = "Color"; - SideTabId[SideTabId["Snapshots"] = 4] = "Snapshots"; - SideTabId[SideTabId["History"] = 5] = "History"; - SideTabId[SideTabId["Transition"] = 6] = "Transition"; - SideTabId[SideTabId["Settings"] = 7] = "Settings"; - SideTabId[SideTabId["Pin"] = 8] = "Pin"; - SideTabId[SideTabId["Collapse"] = 9] = "Collapse"; -})(SideTabId || (SideTabId = {})); - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"flhRz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Sidebutton", ()=>Sidebutton); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _iconButton = require("./iconButton"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function Sidebutton(props) { - const selected = !props.closed && props.selectedSideTab === props.sideTabId; - return (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("vbutton", selected && "selected") - }, props.badgeText && (0, _base.base).react.createElement("div", { - className: "count" - }, props.badgeText), (0, _base.base).react.createElement((0, _iconButton.IconButton), { - role: props.role || "tab", - "aria-selected": selected, - themePalette: props.themePalette, - className: "vbutton", - iconName: props.iconName, - title: props.title, - onClick: ()=>{ - props.onSideTabClick(props.sideTabId); +function differentObjectValues(a, b) { + if (!a && !b) return false; + if (!a || !b) return true; + const keys = Object.keys(b); + for(let i = 0; i < keys.length; i++){ + const key = keys[i]; + const ta = typeof a; + const tb = typeof b; + if (ta !== tb) return true; + if (ta === 'object') return differentObjectValues(a[key], b[key]); + else { + if (a[key] !== b[key]) return true; } - })); + } + return false; } -},{"../base":"9M4eu","./iconButton":"6gzbB","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dJZY5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Topbar", ()=>Topbar); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fNWAw":[function(require,module,exports,__globalThis) { /*! * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. -*/ var _commandBarButtonStyles = require("./CommandBarButton.styles"); -var _logo = require("./logo"); -var _base = require("../base"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function Topbar(props) { - var _a; - const zeroResults = props.selectionState.selectedData && props.selectionState.selectedData.length === 0; - const disabled = !props.loaded; - const items = [ - { - key: "undo", - name: (0, _language.strings).buttonUndo, - iconProps: { - iconName: "Undo" - }, - disabled: disabled || props.historyItems.length === 0 || props.historyIndex === 0, - onClick: props.undo - }, - { - key: "redo", - name: (0, _language.strings).buttonRedo, - iconProps: { - iconName: "Redo" - }, - disabled: disabled || props.historyItems.length <= 1 || props.historyIndex >= props.historyItems.length - 1, - onClick: props.redo - }, - { - key: "deselect", - name: (0, _language.strings).buttonDeselect, - iconProps: { - iconName: "Cancel" - }, - disabled: disabled || !props.selectionSearch, - onClick: props.doDeselect - }, - { - key: "isolate", - name: (0, _language.strings).buttonIsolate, - iconProps: { - iconName: "Filter" - }, - disabled: disabled || !props.selectionSearch || zeroResults, - onClick: ()=>props.doFilter(props.selectionSearch, (0, _language.strings).labelHistoryFilterIsolate) - }, - { - key: "exclude", - name: (0, _language.strings).buttonExclude, - iconProps: { - iconName: "ClearFilter" - }, - disabled: disabled || !props.selectionSearch || zeroResults, - onClick: ()=>props.doFilter((0, _sanddanceReact.SandDance).searchExpression.invert(props.selectionSearch), (0, _language.strings).labelHistoryFilterIExclude) - }, - { - key: "reset", - name: (0, _language.strings).buttonReset, - iconProps: { - iconName: "RemoveFilter" - }, - disabled: disabled || !props.filter, - onClick: ()=>props.doUnfilter((0, _language.strings).labelHistoryFilterClear) - }, - ]; - if (props.buttons) items.push.apply(items, props.buttons); - if (props.collapseLabels) items.forEach((item)=>item.iconOnly = true); - const farItems = []; - if (!props.snapshotsHidden) farItems.push({ - key: "previous-snapshot", - iconProps: { - iconName: "Previous" - }, - title: (0, _language.strings).buttonPrevSnapshot, - onClick: props.onSnapshotPreviousClick, - disabled: !props.snapshots || props.snapshots.length < 2 - }, { - key: "snapshot", - iconProps: { - iconName: "Camera" - }, - title: (0, _language.strings).buttonCreateSnapshot, - onClick: props.onSnapshotClick, - disabled: !props.loaded - }, { - key: "next-snapshot", - iconProps: { - iconName: "Next" - }, - title: (0, _language.strings).buttonNextSnapshot, - onClick: props.onSnapshotNextClick, - disabled: !props.snapshots || props.snapshots.length < 2 - }); - farItems.push({ - key: "view", - iconProps: { - iconName: props.view === "2d" ? "CubeShape" : "Page" - }, - title: props.view === "2d" ? (0, _language.strings).labelViewType3d : (0, _language.strings).labelViewType2d, - onClick: props.onViewClick, - disabled: !props.loaded - }); - if ((_a = props.iconButtons) === null || _a === void 0 ? void 0 : _a.length) farItems.push(...props.iconButtons); - return (0, _base.base).react.createElement("div", { - className: "sanddance-explorer-topbar" - }, (0, _base.base).react.createElement("div", { - className: "logo" - }, (0, _base.base).react.createElement((0, _logo.Logo), null), (0, _base.base).react.createElement("a", { - href: props.logoClickUrl || "/", - target: props.logoClickTarget || "_blank" - }, (0, _language.strings).appName)), (0, _base.base).react.createElement("div", { - className: "sanddance-explorer-commandbar" - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Customizer, { - scopedSettings: { - CommandBarButton: { - styles: (buttonProps)=>{ - buttonProps.theme.palette = props.themePalette; - return (0, _commandBarButtonStyles.CommandBarButtonStyles)(buttonProps); - } - } - } - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.CommandBar, { - items: items, - farItems: farItems, - styles: { - root: { - backgroundColor: "transparent", - height: "unset", - paddingLeft: 0, - paddingRight: 0 - } - } - })))); -} - -},{"./CommandBarButton.styles":"5RfxM","./logo":"27kdL","../base":"9M4eu","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5RfxM":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "CommandBarButtonStyles", ()=>CommandBarButtonStyles); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ //adapted from https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/fluent-theme/src/fluent/styles/CommandBarButton.styles.ts -var _base = require("../base"); -const CommandBarButtonStyles = (props)=>{ - const { theme } = props; - if (!theme) throw new Error("Theme is undefined or null."); - const { palette , semanticColors } = theme; - const BUTTON_ICON_CLASSNAME = ".ms-Button-icon"; - return { - root: [ - Object.assign({}, (0, _base.base).fluentUI.getFocusStyle(theme, { - inset: 2 - })), - { - backgroundColor: palette.white - }, - ], - rootHovered: { - backgroundColor: palette.neutralLighter, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: palette.themeDarkAlt - } - } - }, - rootPressed: { - backgroundColor: palette.neutralLight, - color: palette.neutralDark, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: palette.themeDark - } - } - }, - rootChecked: { - backgroundColor: palette.neutralLight, - color: palette.neutralDark, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: palette.themeDark - } - } - }, - rootCheckedHovered: { - backgroundColor: palette.neutralQuaternaryAlt, - color: palette.neutralDark - }, - rootExpanded: { - color: palette.neutralDark, - backgroundColor: palette.neutralLight, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: palette.themeDark +parcelHelpers.export(exports, "assignTransitionStagger", ()=>assignTransitionStagger); +var _sanddanceSpecs = require("@msrvida/sanddance-specs"); +var _d3Scale = require("d3-scale"); +var _constants = require("./constants"); +function assignTransitionStagger(transition, currentData, selection, presenter) { + const { layerStagger } = presenter.morphchartsref; + const { morphChartsRenderResult } = presenter; + const cubelayer = morphChartsRenderResult.getCubeLayer(); + const range = transition.reverse ? [ + 1, + 0 + ] : [ + 0, + 1 + ]; + if (!transition || transition.type === 'ordinal' && !transition.reverse) delete layerStagger.cubes; + else { + const staggerOrders = new Float64Array(cubelayer.positionsX.length); + switch(transition.type){ + case 'ordinal': + { + //reverse ordinal + const scale = (0, _d3Scale.scaleLinear)(range).domain([ + 0, + currentData.length + ]); + currentData.forEach((datum, i)=>{ + const glOrdinal = datum[0, _constants.GL_ORDINAL]; + staggerOrders[glOrdinal] = scale(i); + }); + break; } - } - }, - rootExpandedHovered: { - background: palette.neutralQuaternaryAlt - }, - rootDisabled: { - backgroundColor: palette.white, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: semanticColors.disabledBodySubtext + case 'column': + if (transition.column.quantitative) { + const values = new Float64Array(currentData.length); + currentData.forEach((datum, i)=>{ + values[i] = datum[transition.column.name]; + }); + const stats = (0, _sanddanceSpecs.getStats)(currentData, transition.column); + const scale = (0, _d3Scale.scaleLinear)(range).domain([ + stats.min, + stats.max + ]); + currentData.forEach((datum, i)=>{ + const glOrdinal = datum[0, _constants.GL_ORDINAL]; + staggerOrders[glOrdinal] = scale(values[i]); + }); + } else { + const strings = new Array(currentData.length); + currentData.forEach((datum, i)=>{ + strings[i] = datum[transition.column.name]; + }); + (0, _sanddanceSpecs.getStats)(currentData, transition.column, (distictValues)=>{ + currentData.forEach((datum, i)=>{ + const glOrdinal = datum[0, _constants.GL_ORDINAL]; + const index = distictValues.indexOf(strings[i]); + const staggerOrder = index / distictValues.length; + staggerOrders[glOrdinal] = transition.reverse ? 1 - staggerOrder : staggerOrder; + }); + }); } - } - }, - splitButtonMenuButton: { - backgroundColor: palette.white, - color: palette.neutralSecondary, - selectors: { - ":hover": { - backgroundColor: palette.neutralLighter, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: palette.neutralPrimary - } - } - }, - ":active": { - backgroundColor: palette.neutralLight, - selectors: { - [BUTTON_ICON_CLASSNAME]: { - color: palette.neutralPrimary - } - } + break; + case 'position': + { + const dimensions = { + x: cubelayer.positionsX, + y: cubelayer.positionsY, + z: cubelayer.positionsZ + }; + const positions = dimensions[transition.dimension]; + const values = new Float64Array(currentData.length); + currentData.forEach((datum, i)=>{ + const glOrdinal = datum[0, _constants.GL_ORDINAL]; + values[i] = positions[glOrdinal]; + }); + const stats = (0, _sanddanceSpecs.getStats)(values, null, 'number', true); + const scale = (0, _d3Scale.scaleLinear)(range).domain([ + stats.min, + stats.max + ]); + currentData.forEach((datum, i)=>{ + const glOrdinal = datum[0, _constants.GL_ORDINAL]; + staggerOrders[glOrdinal] = scale(values[i]); + }); + break; } - } - }, - splitButtonMenuButtonDisabled: { - backgroundColor: palette.white - }, - icon: { - color: palette.themePrimary } - }; -}; + layerStagger.cubes = { + staggerOrders, + maxStaggerOrder: 1, + minStaggerOrder: 0 + }; + } + cubelayer.update(morphChartsRenderResult.bounds, selection, layerStagger.cubes); +} -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"27kdL":[function(require,module,exports) { +},{"@msrvida/sanddance-specs":"aOvSr","d3-scale":"1PRVx","./constants":"ix2qh","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1PRVx":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Logo", ()=>Logo); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -const s = ` - ...... -....... -... -...... - ...... - ... -....... -...... -`; -const d = s.split("\n").map((row, irow)=>row.length ? row.split("").map((char, icol)=>char.trim() ? `M${2 * icol + 1} ${2 * (irow - 1) + 1} v1 h1 v-1 Z` : "").join(" ") : "").join("\n"); -function Logo() { - return (0, _base.base).react.createElement("svg", { - xmlns: "http://www.w3.org/2000/svg", - viewBox: "0 0 16 16" - }, (0, _base.base).react.createElement("path", { - d: d - })); -} +parcelHelpers.export(exports, "scaleBand", ()=>(0, _bandJsDefault.default)); +parcelHelpers.export(exports, "scalePoint", ()=>(0, _bandJs.point)); +parcelHelpers.export(exports, "scaleIdentity", ()=>(0, _identityJsDefault.default)); +parcelHelpers.export(exports, "scaleLinear", ()=>(0, _linearJsDefault.default)); +parcelHelpers.export(exports, "scaleLog", ()=>(0, _logJsDefault.default)); +parcelHelpers.export(exports, "scaleSymlog", ()=>(0, _symlogJsDefault.default)); +parcelHelpers.export(exports, "scaleOrdinal", ()=>(0, _ordinalJsDefault.default)); +parcelHelpers.export(exports, "scaleImplicit", ()=>(0, _ordinalJs.implicit)); +parcelHelpers.export(exports, "scalePow", ()=>(0, _powJsDefault.default)); +parcelHelpers.export(exports, "scaleSqrt", ()=>(0, _powJs.sqrt)); +parcelHelpers.export(exports, "scaleRadial", ()=>(0, _radialJsDefault.default)); +parcelHelpers.export(exports, "scaleQuantile", ()=>(0, _quantileJsDefault.default)); +parcelHelpers.export(exports, "scaleQuantize", ()=>(0, _quantizeJsDefault.default)); +parcelHelpers.export(exports, "scaleThreshold", ()=>(0, _thresholdJsDefault.default)); +parcelHelpers.export(exports, "scaleTime", ()=>(0, _timeJsDefault.default)); +parcelHelpers.export(exports, "scaleUtc", ()=>(0, _utcTimeJsDefault.default)); +parcelHelpers.export(exports, "scaleSequential", ()=>(0, _sequentialJsDefault.default)); +parcelHelpers.export(exports, "scaleSequentialLog", ()=>(0, _sequentialJs.sequentialLog)); +parcelHelpers.export(exports, "scaleSequentialPow", ()=>(0, _sequentialJs.sequentialPow)); +parcelHelpers.export(exports, "scaleSequentialSqrt", ()=>(0, _sequentialJs.sequentialSqrt)); +parcelHelpers.export(exports, "scaleSequentialSymlog", ()=>(0, _sequentialJs.sequentialSymlog)); +parcelHelpers.export(exports, "scaleSequentialQuantile", ()=>(0, _sequentialQuantileJsDefault.default)); +parcelHelpers.export(exports, "scaleDiverging", ()=>(0, _divergingJsDefault.default)); +parcelHelpers.export(exports, "scaleDivergingLog", ()=>(0, _divergingJs.divergingLog)); +parcelHelpers.export(exports, "scaleDivergingPow", ()=>(0, _divergingJs.divergingPow)); +parcelHelpers.export(exports, "scaleDivergingSqrt", ()=>(0, _divergingJs.divergingSqrt)); +parcelHelpers.export(exports, "scaleDivergingSymlog", ()=>(0, _divergingJs.divergingSymlog)); +parcelHelpers.export(exports, "tickFormat", ()=>(0, _tickFormatJsDefault.default)); +var _bandJs = require("./band.js"); +var _bandJsDefault = parcelHelpers.interopDefault(_bandJs); +var _identityJs = require("./identity.js"); +var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); +var _linearJs = require("./linear.js"); +var _linearJsDefault = parcelHelpers.interopDefault(_linearJs); +var _logJs = require("./log.js"); +var _logJsDefault = parcelHelpers.interopDefault(_logJs); +var _symlogJs = require("./symlog.js"); +var _symlogJsDefault = parcelHelpers.interopDefault(_symlogJs); +var _ordinalJs = require("./ordinal.js"); +var _ordinalJsDefault = parcelHelpers.interopDefault(_ordinalJs); +var _powJs = require("./pow.js"); +var _powJsDefault = parcelHelpers.interopDefault(_powJs); +var _radialJs = require("./radial.js"); +var _radialJsDefault = parcelHelpers.interopDefault(_radialJs); +var _quantileJs = require("./quantile.js"); +var _quantileJsDefault = parcelHelpers.interopDefault(_quantileJs); +var _quantizeJs = require("./quantize.js"); +var _quantizeJsDefault = parcelHelpers.interopDefault(_quantizeJs); +var _thresholdJs = require("./threshold.js"); +var _thresholdJsDefault = parcelHelpers.interopDefault(_thresholdJs); +var _timeJs = require("./time.js"); +var _timeJsDefault = parcelHelpers.interopDefault(_timeJs); +var _utcTimeJs = require("./utcTime.js"); +var _utcTimeJsDefault = parcelHelpers.interopDefault(_utcTimeJs); +var _sequentialJs = require("./sequential.js"); +var _sequentialJsDefault = parcelHelpers.interopDefault(_sequentialJs); +var _sequentialQuantileJs = require("./sequentialQuantile.js"); +var _sequentialQuantileJsDefault = parcelHelpers.interopDefault(_sequentialQuantileJs); +var _divergingJs = require("./diverging.js"); +var _divergingJsDefault = parcelHelpers.interopDefault(_divergingJs); +var _tickFormatJs = require("./tickFormat.js"); +var _tickFormatJsDefault = parcelHelpers.interopDefault(_tickFormatJs); -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kuJuZ":[function(require,module,exports) { +},{"./band.js":"a1xEx","./identity.js":"e07Nz","./linear.js":"ik2PQ","./log.js":"5BBe1","./symlog.js":"26cMO","./ordinal.js":"cg12q","./pow.js":"ah9R8","./radial.js":"eL6SH","./quantile.js":"ENbdr","./quantize.js":"4Cxz6","./threshold.js":"lQqvO","./time.js":"dtq1F","./utcTime.js":"iLPRP","./sequential.js":"e0eA3","./sequentialQuantile.js":"i0IcB","./diverging.js":"6Pqcc","./tickFormat.js":"fHwUM","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"a1xEx":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "loadDataFile", ()=>loadDataFile); -parcelHelpers.export(exports, "loadDataArray", ()=>loadDataArray); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceReact = require("@msrvida/sanddance-react"); -const loadDataFile = (dataFile, columnTypes)=>new Promise((resolve, reject)=>{ - const vega = (0, _sanddanceReact.SandDance).VegaMorphCharts.base.vega; - const loader = vega.loader(); - function handleRawText(text) { - let data; - try { - data = vega.read(text, { - type: dataFile.type, - parse: {} - }); - } catch (e) { - reject(e); - } - if (data) loadDataArray(data, dataFile.type, columnTypes).then((dc)=>{ - if (dataFile.snapshotsUrl) fetch(dataFile.snapshotsUrl).then((response)=>response.json()).then((snapshots)=>{ - dc.snapshots = snapshots; - resolve(dc); - }).catch(reject); - else if (dataFile.snapshots) { - dc.snapshots = dataFile.snapshots; - resolve(dc); - } else resolve(dc); - }).catch(reject); - } - if (dataFile.dataUrl) loader.load(dataFile.dataUrl).then(handleRawText).catch(reject); - else if (dataFile.rawText) handleRawText(dataFile.rawText); - else reject("dataFile object must have either dataUrl or rawText property set."); - }); -const loadDataArray = (data, type, columnTypes)=>new Promise((resolve, reject)=>{ - const parse = type === "csv" || type === "tsv"; - if (parse) //convert empty strings to null so that vega.inferType will get dates - data.forEach((row)=>{ - for(const column in row)if (row[column] === "") row[column] = null; - }); - const columns = (0, _sanddanceReact.SandDance).util.getColumnsFromData((0, _sanddanceReact.SandDance).VegaMorphCharts.base.vega.inferTypes, data, columnTypes).filter((c)=>c.name && c.name.trim()).sort((a, b)=>a.name.localeCompare(b.name)); - if (parse) { - const booleanColumns = columns.filter((c)=>c.type === "boolean"); - const dateColumns = columns.filter((c)=>c.type === "date"); - const numericColumns = columns.filter((c)=>c.type === "integer" || c.type === "number"); - data.forEach((obj)=>{ - booleanColumns.forEach((c)=>{ - obj[c.name] = ("" + obj[c.name]).toLowerCase() === "true"; - }); - dateColumns.forEach((c)=>{ - const input = obj[c.name]; - if (input !== null) { - const d = new Date(input); - d.input = input; - obj[c.name] = d; - } - }); - numericColumns.forEach((c)=>{ - const n = parseFloat(obj[c.name]); - obj[c.name] = isNaN(n) ? null : n; - }); - }); - } - resolve({ - data, - columns +parcelHelpers.export(exports, "default", ()=>band); +parcelHelpers.export(exports, "point", ()=>point); +var _d3Array = require("d3-array"); +var _initJs = require("./init.js"); +var _ordinalJs = require("./ordinal.js"); +var _ordinalJsDefault = parcelHelpers.interopDefault(_ordinalJs); +function band() { + var scale = (0, _ordinalJsDefault.default)().unknown(undefined), domain = scale.domain, ordinalRange = scale.range, r0 = 0, r1 = 1, step, bandwidth, round = false, paddingInner = 0, paddingOuter = 0, align = 0.5; + delete scale.unknown; + function rescale() { + var n = domain().length, reverse = r1 < r0, start = reverse ? r1 : r0, stop = reverse ? r0 : r1; + step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2); + if (round) step = Math.floor(step); + start += (stop - start - step * (n - paddingInner)) * align; + bandwidth = step * (1 - paddingInner); + if (round) start = Math.round(start), bandwidth = Math.round(bandwidth); + var values = (0, _d3Array.range)(n).map(function(i) { + return start + step * i; }); - }); - -},{"@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"oAoKB":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "fontFamily", ()=>fontFamily); -parcelHelpers.export(exports, "defaultViewerOptions", ()=>defaultViewerOptions); -parcelHelpers.export(exports, "snapshotThumbWidth", ()=>snapshotThumbWidth); -parcelHelpers.export(exports, "defaultRenderer", ()=>defaultRenderer); -parcelHelpers.export(exports, "initialExplorerState", ()=>initialExplorerState); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _themes = require("./themes"); -var _interfaces = require("./interfaces"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _dataScope = require("./controls/dataScope"); -const fontFamily = "Segoe UI, sans-serif"; -const defaultViewerOptions = { - colors: (0, _themes.getColorSettingsFromThemePalette)((0, _themes.themePalettes)[""]), - fontFamily -}; -const snapshotThumbWidth = 300; -const defaultRenderer = { - advanced: false, - advancedOptions: { - bloomIntensity: 2, - isBloomEnabled: false, - isDofEnabled: false, - dofFocusRange: 0.25, - isFxaaEnabled: false, - isShadowEnabled: true, - isSsaoEnabled: true - }, - basicOptions: { - antialias: true + return ordinalRange(reverse ? values.reverse() : values); } -}; -function initialExplorerState(props) { - const renderer = props.initialRenderer || defaultRenderer; - if (!renderer.advancedOptions) renderer.advancedOptions = defaultRenderer.advancedOptions; - if (!renderer.basicOptions) renderer.basicOptions = defaultRenderer.basicOptions; - const state = { - calculating: null, - errors: null, - autoCompleteDistinctValues: {}, - colorBin: null, - dataContent: null, - dataFile: null, - search: null, - totalStyle: null, - facetStyle: "wrap", - filter: null, - filteredData: null, - specCapabilities: null, - size: { - height: null, - width: null - }, - scheme: null, - transform: null, - columns: null, - chart: "grid", - signalValues: null, - hideAxes: false, - hideLegend: false, - sideTabId: (0, _interfaces.SideTabId).ChartType, - dataScopeId: (0, _dataScope.DataScopeId).AllData, - selectedItemIndex: {}, - sidebarClosed: props.initialSidebarClosed === undefined ? false : props.initialSidebarClosed, - sidebarPinned: props.initialSidebarPinned === undefined ? true : props.initialSidebarPinned, - view: props.initialView || "2d", - snapshots: [], - selectedSnapshotIndex: -1, - tooltipExclusions: [], - positionedColumnMapProps: null, - note: null, - historyIndex: -1, - historyItems: [], - renderer, - transitionType: "ordinal", - transitionDimension: "x", - transitionDurations: (0, _sanddanceReact.SandDance).VegaMorphCharts.util.clone((0, _sanddanceReact.SandDance).VegaMorphCharts.defaults.defaultPresenterConfig.transitionDurations) + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); }; - (0, _dataScope.resetSelectedItemIndex)(state.selectedItemIndex); - return state; -} - -},{"./themes":"CJpaJ","./interfaces":"8LHoz","@msrvida/sanddance-react":"73dPQ","./controls/dataScope":"i7FKh","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"CJpaJ":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "themePalettes", ()=>themePalettes); -parcelHelpers.export(exports, "getColorSettingsFromThemePalette", ()=>getColorSettingsFromThemePalette); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceReact = require("@msrvida/sanddance-react"); -var util = (0, _sanddanceReact.SandDance).VegaMorphCharts.util; -const themePalettes = {}; -themePalettes[""] = { - themePrimary: "#0078d4", - themeLighterAlt: "#eff6fc", - themeLighter: "#deecf9", - themeLight: "#c7e0f4", - themeTertiary: "#71afe5", - themeSecondary: "#2b88d8", - themeDarkAlt: "#106ebe", - themeDark: "#005a9e", - themeDarker: "#004578", - neutralLighterAlt: "#faf9f8", - neutralLighter: "#f3f2f1", - neutralLight: "#edebe9", - neutralQuaternaryAlt: "#e1dfdd", - neutralQuaternary: "#d0d0d0", - neutralTertiaryAlt: "#c8c6c4", - neutralTertiary: "#595959", - neutralSecondary: "#373737", - neutralSecondaryAlt: "#373737", - neutralPrimaryAlt: "#2f2f2f", - neutralPrimary: "#000000", - neutralDark: "#151515", - black: "#0b0b0b", - white: "#ffffff" -}; -themePalettes["dark-theme"] = { - themePrimary: "#0078d4", - themeLighterAlt: "#eff6fc", - themeLighter: "#deecf9", - themeLight: "#c7e0f4", - themeTertiary: "#71afe5", - themeSecondary: "#2b88d8", - themeDarkAlt: "#106ebe", - themeDark: "#005a9e", - themeDarker: "#004578", - neutralLighterAlt: "#0b0b0b", - neutralLighter: "#151515", - neutralLight: "#252525", - neutralQuaternaryAlt: "#2f2f2f", - neutralQuaternary: "#373737", - neutralTertiaryAlt: "#595959", - neutralTertiary: "#c8c8c8", - neutralSecondary: "#d0d0d0", - neutralSecondaryAlt: "#d0d0d0", - neutralPrimaryAlt: "#dadada", - neutralPrimary: "#ffffff", - neutralDark: "#f4f4f4", - black: "#f8f8f8", - white: "#000000" -}; -function getColorSettingsFromThemePalette(themePalette) { - const c = util.colorFromString(themePalette.themeSecondary); - c[3] = 256 / 3; // one-third opacity background - return { - axisLine: themePalette.black, - axisText: themePalette.black, - gridLine: themePalette.neutralLight, - backgroundColor: themePalette.white, - hoveredCube: themePalette.black, - clickableText: themePalette.themeDark, - clickableTextHighlight: util.colorToString(c), - searchText: themePalette.neutralPrimary, - searchTextHighlight: themePalette.neutralPrimaryAlt + scale.range = function(_) { + return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [ + r0, + r1 + ]; + }; + scale.rangeRound = function(_) { + return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale(); + }; + scale.bandwidth = function() { + return bandwidth; + }; + scale.step = function() { + return step; + }; + scale.round = function(_) { + return arguments.length ? (round = !!_, rescale()) : round; + }; + scale.padding = function(_) { + return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner; + }; + scale.paddingInner = function(_) { + return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner; + }; + scale.paddingOuter = function(_) { + return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter; + }; + scale.align = function(_) { + return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align; }; + scale.copy = function() { + return band(domain(), [ + r0, + r1 + ]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align); + }; + return (0, _initJs.initRange).apply(rescale(), arguments); } - -},{"@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7Mylg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Color", ()=>Color); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _columnMap = require("../controls/columnMap"); -var _palettes = require("../palettes"); -var _signal = require("../controls/signal"); -var _language = require("../language"); -var _group = require("../controls/group"); -function Color(props) { - const colorColumn = props.dataContent.columns.filter((c)=>c.name === props.colorColumn)[0]; - const disabledColorBin = !colorColumn || !colorColumn.quantitative || props.directColor; - const colorBin = props.colorBin || "quantize"; - const dropdownRef = (0, _base.base).react.createRef(); - props.explorer.dialogFocusHandler.focus = ()=>{ - var _a; - return (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.focus(); +function pointish(scale) { + var copy = scale.copy; + scale.padding = scale.paddingOuter; + delete scale.paddingInner; + delete scale.paddingOuter; + scale.copy = function() { + return pointish(copy()); }; - return (0, _base.base).react.createElement("div", { - className: "sanddance-color-dialog" - }, (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelColor - }, (0, _base.base).react.createElement((0, _columnMap.ColumnMap), Object.assign({}, props, { - componentRef: dropdownRef, - collapseLabel: props.compactUI, - selectedColumnName: props.colorColumn, - specRole: props.specCapabilities && props.specCapabilities.roles.filter((r)=>r.role === "color")[0], - key: 0 - })), colorColumn && colorColumn.isColorData && (0, _base.base).react.createElement("div", { - className: "sanddance-explanation", - dangerouslySetInnerHTML: { - __html: (0, _language.strings).labelColorFieldIsColorData(colorColumn.name) - } - }), colorColumn && !colorColumn.isColorData && (0, _base.base).react.createElement((0, _palettes.Palette), { - collapseLabel: props.compactUI, - scheme: props.scheme, - colorColumn: colorColumn, - changeColorScheme: (scheme)=>{ - props.onColorSchemeChange(scheme); - }, - disabled: props.disabled || props.directColor || colorColumn && colorColumn.isColorData - }), colorColumn && !colorColumn.isColorData && (0, _base.base).react.createElement((0, _signal.Signal), { - disabled: props.disabled || !colorColumn || props.directColor || colorColumn && colorColumn.isColorData, - signal: props.colorReverseSignal, - explorer: props.explorer, - initialValue: (0, _signal.getInitialSignalValue)(props.explorer, props.colorReverseSignal), - onChange: props.onColorReverseChange, - collapseLabel: props.compactUI - })), colorColumn && !colorColumn.isColorData && (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelColorBin - }, (0, _base.base).react.createElement("div", { - className: "sanddance-explanation" - }, (0, _language.strings).labelColorBinExplanation), (0, _base.base).react.createElement((0, _base.base).fluentUI.ChoiceGroup, { - selectedKey: colorBin, - options: [ - { - key: "continuous", - text: (0, _language.strings).labelColorBinNone, - disabled: disabledColorBin - }, - { - key: "quantize", - text: (0, _language.strings).labelColorBinQuantize, - disabled: disabledColorBin - }, - { - key: "quantile", - text: (0, _language.strings).labelColorBinQuantile, - disabled: disabledColorBin - }, - ], - onChange: (e, o)=>{ - props.onColorBinChange(o.key); - } - }), (0, _base.base).react.createElement((0, _signal.Signal), { - disabled: props.disabled || disabledColorBin || props.colorBin === "continuous", - signal: props.colorBinSignal, - explorer: props.explorer, - initialValue: (0, _signal.getInitialSignalValue)(props.explorer, props.colorBinSignal), - onChange: props.onColorBinCountChange, - collapseLabel: props.compactUI - })), colorColumn && !colorColumn.isColorData && (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelColorOptions - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - label: (0, _language.strings).selectDirectColor, - disabled: !colorColumn.stats.hasColorData, - checked: !!(colorColumn.stats.hasColorData && props.directColor), - onChange: (e, checked)=>props.onDirectColorChange(checked) - }), (0, _base.base).react.createElement("div", { - className: "sanddance-explanation", - dangerouslySetInnerHTML: { - __html: (0, _language.strings).labelDataColors - } - }))); + return scale; } - -},{"../base":"9M4eu","../controls/columnMap":"5sGIS","../palettes":"6v3MN","../controls/signal":"847y5","../language":"kzoCJ","../controls/group":"hggjF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6v3MN":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Palette", ()=>Palette); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _categorical = require("./categorical"); -var _cyclical = require("./cyclical"); -var _diverging = require("./diverging"); -var _dropdown = require("../controls/dropdown"); -var _dual = require("./dual"); -var _scheme = require("./scheme"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _sequentialMultiHue = require("./sequentialMultiHue"); -var _sequentialSingleHue = require("./sequentialSingleHue"); -var _language = require("../language"); -const maxDistinctColors = 20; -function Palette(props) { - const { distinctValueCount } = props.colorColumn.stats; - const isDual = distinctValueCount === 2; - const categoricalNumeric = distinctValueCount > 0 && distinctValueCount < maxDistinctColors; - let isQualitative = false; - let isQuantitative = false; - switch(props.colorColumn.type){ - case "boolean": - case "string": - isQualitative = true; - break; - case "number": - isQuantitative = true; - break; - case "date": - case "integer": - isQuantitative = true; - isQualitative = categoricalNumeric; - } - const selected = props.scheme; - const options = []; - function menu(name, opts) { - if (options.length) options.push({ - key: "divider" + options.length, - text: null, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Divider - }); - options.push({ - key: name, - text: name, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header - }); - options.push.apply(options, opts); - } - isQualitative && menu((0, _language.strings).schemeCategorical, (0, _categorical.categorical)(selected)); - isQuantitative && menu((0, _language.strings).schemeSequentialSingleHue, (0, _sequentialSingleHue.sequentialSingleHue)(selected)); - isQuantitative && menu((0, _language.strings).schemeSequentialMultiHue, (0, _sequentialMultiHue.sequentialMultiHue)(selected)); - isQuantitative && menu((0, _language.strings).schemeDiverging, (0, _diverging.diverging)(selected)); - isQuantitative && menu((0, _language.strings).schemeCyclical, (0, _cyclical.cyclical)(selected)); - isDual && menu((0, _language.strings).schemeDual, (0, _dual.dual)(selected)); - return (0, _base.base).react.createElement("div", { - className: "sanddance-palette" - }, (0, _base.base).react.createElement("div", { - className: "sanddance-explanation", - dangerouslySetInnerHTML: { - __html: (0, _language.strings).labelColorFieldInfo(props.colorColumn.name, props.colorColumn.type, categoricalNumeric, distinctValueCount) - } - }), (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - collapseLabel: props.collapseLabel, - disabled: props.disabled, - dropdownWidth: 400, - label: (0, _language.strings).labelColorScheme, - onRenderOption: (option)=>{ - if (option.itemType === (0, _base.base).fluentUI.DropdownMenuItemType.Header) return (0, _base.base).react.createElement("span", null, option.text); - else return (0, _base.base).react.createElement("div", { - className: "sanddance-scheme option" - }, (0, _base.base).react.createElement("span", { - className: "name" - }, option.scheme), option.children); - }, - options: options, - onChange: (e, o)=>{ - props.changeColorScheme(o.scheme); - } - }), (0, _base.base).react.createElement("div", { - className: (0, _sanddanceReact.util).classList("sanddance-scheme", props.disabled && "disabled") - }, props.scheme && (0, _scheme.schemesJSX)[props.scheme])); +function point() { + return pointish(band.apply(null, arguments).paddingInner(1)); } -},{"../base":"9M4eu","./categorical":"aOG9z","./cyclical":"7atYL","./diverging":"g5GrM","../controls/dropdown":"2Udzo","./dual":"5Kxmu","./scheme":"9kwPO","@msrvida/sanddance-react":"73dPQ","./sequentialMultiHue":"gjSUq","./sequentialSingleHue":"dbxad","../language":"kzoCJ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aOG9z":[function(require,module,exports) { +},{"d3-array":"5lCYW","./init.js":"ijd73","./ordinal.js":"cg12q","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5lCYW":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "categorical", ()=>categorical); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _scheme = require("./scheme"); -const p8 = `${12.5}%`; -const p9 = `${100 / 9}%`; -const p10 = `${10}%`; -const p12 = `${100 / 12}%`; -const p20 = `${5}%`; -let loaded = false; -function load() { - (0, _scheme.schemesJSX)["accent"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#7fc97f", - style: { - width: p8, - background: "rgb(127, 201, 127)" - } - }), (0, _base.base).react.createElement("div", { - title: "#beaed4", - style: { - width: p8, - background: "rgb(190, 174, 212)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fdc086", - style: { - width: p8, - background: "rgb(253, 192, 134)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffff99", - style: { - width: p8, - background: "rgb(255, 255, 153)" - } - }), (0, _base.base).react.createElement("div", { - title: "#386cb0", - style: { - width: p8, - background: "rgb(56, 108, 176)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f0027f", - style: { - width: p8, - background: "rgb(240, 2, 127)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bf5b17", - style: { - width: p8, - background: "rgb(191, 91, 23)" - } - }), (0, _base.base).react.createElement("div", { - title: "#666666", - style: { - width: p8, - background: "rgb(102, 102, 102)" - } - })); - (0, _scheme.schemesJSX)["category10"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#1f77b4", - style: { - width: p10, - background: "rgb(31, 119, 180)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ff7f0e", - style: { - width: p10, - background: "rgb(255, 127, 14)" - } - }), (0, _base.base).react.createElement("div", { - title: "#2ca02c", - style: { - width: p10, - background: "rgb(44, 160, 44)" +parcelHelpers.export(exports, "bisect", ()=>(0, _bisectJsDefault.default)); +parcelHelpers.export(exports, "bisectRight", ()=>(0, _bisectJs.bisectRight)); +parcelHelpers.export(exports, "bisectLeft", ()=>(0, _bisectJs.bisectLeft)); +parcelHelpers.export(exports, "bisectCenter", ()=>(0, _bisectJs.bisectCenter)); +parcelHelpers.export(exports, "ascending", ()=>(0, _ascendingJsDefault.default)); +parcelHelpers.export(exports, "bisector", ()=>(0, _bisectorJsDefault.default)); +parcelHelpers.export(exports, "blur", ()=>(0, _blurJs.blur)); +parcelHelpers.export(exports, "blur2", ()=>(0, _blurJs.blur2)); +parcelHelpers.export(exports, "blurImage", ()=>(0, _blurJs.blurImage)); +parcelHelpers.export(exports, "count", ()=>(0, _countJsDefault.default)); +parcelHelpers.export(exports, "cross", ()=>(0, _crossJsDefault.default)); +parcelHelpers.export(exports, "cumsum", ()=>(0, _cumsumJsDefault.default)); +parcelHelpers.export(exports, "descending", ()=>(0, _descendingJsDefault.default)); +parcelHelpers.export(exports, "deviation", ()=>(0, _deviationJsDefault.default)); +parcelHelpers.export(exports, "extent", ()=>(0, _extentJsDefault.default)); +parcelHelpers.export(exports, "Adder", ()=>(0, _fsumJs.Adder)); +parcelHelpers.export(exports, "fsum", ()=>(0, _fsumJs.fsum)); +parcelHelpers.export(exports, "fcumsum", ()=>(0, _fsumJs.fcumsum)); +parcelHelpers.export(exports, "group", ()=>(0, _groupJsDefault.default)); +parcelHelpers.export(exports, "flatGroup", ()=>(0, _groupJs.flatGroup)); +parcelHelpers.export(exports, "flatRollup", ()=>(0, _groupJs.flatRollup)); +parcelHelpers.export(exports, "groups", ()=>(0, _groupJs.groups)); +parcelHelpers.export(exports, "index", ()=>(0, _groupJs.index)); +parcelHelpers.export(exports, "indexes", ()=>(0, _groupJs.indexes)); +parcelHelpers.export(exports, "rollup", ()=>(0, _groupJs.rollup)); +parcelHelpers.export(exports, "rollups", ()=>(0, _groupJs.rollups)); +parcelHelpers.export(exports, "groupSort", ()=>(0, _groupSortJsDefault.default)); +parcelHelpers.export(exports, "bin", ()=>(0, _binJsDefault.default)) // Deprecated; use bin. +; +parcelHelpers.export(exports, "histogram", ()=>(0, _binJsDefault.default)); +parcelHelpers.export(exports, "thresholdFreedmanDiaconis", ()=>(0, _freedmanDiaconisJsDefault.default)); +parcelHelpers.export(exports, "thresholdScott", ()=>(0, _scottJsDefault.default)); +parcelHelpers.export(exports, "thresholdSturges", ()=>(0, _sturgesJsDefault.default)); +parcelHelpers.export(exports, "max", ()=>(0, _maxJsDefault.default)); +parcelHelpers.export(exports, "maxIndex", ()=>(0, _maxIndexJsDefault.default)); +parcelHelpers.export(exports, "mean", ()=>(0, _meanJsDefault.default)); +parcelHelpers.export(exports, "median", ()=>(0, _medianJsDefault.default)); +parcelHelpers.export(exports, "medianIndex", ()=>(0, _medianJs.medianIndex)); +parcelHelpers.export(exports, "merge", ()=>(0, _mergeJsDefault.default)); +parcelHelpers.export(exports, "min", ()=>(0, _minJsDefault.default)); +parcelHelpers.export(exports, "minIndex", ()=>(0, _minIndexJsDefault.default)); +parcelHelpers.export(exports, "mode", ()=>(0, _modeJsDefault.default)); +parcelHelpers.export(exports, "nice", ()=>(0, _niceJsDefault.default)); +parcelHelpers.export(exports, "pairs", ()=>(0, _pairsJsDefault.default)); +parcelHelpers.export(exports, "permute", ()=>(0, _permuteJsDefault.default)); +parcelHelpers.export(exports, "quantile", ()=>(0, _quantileJsDefault.default)); +parcelHelpers.export(exports, "quantileIndex", ()=>(0, _quantileJs.quantileIndex)); +parcelHelpers.export(exports, "quantileSorted", ()=>(0, _quantileJs.quantileSorted)); +parcelHelpers.export(exports, "quickselect", ()=>(0, _quickselectJsDefault.default)); +parcelHelpers.export(exports, "range", ()=>(0, _rangeJsDefault.default)); +parcelHelpers.export(exports, "rank", ()=>(0, _rankJsDefault.default)); +parcelHelpers.export(exports, "least", ()=>(0, _leastJsDefault.default)); +parcelHelpers.export(exports, "leastIndex", ()=>(0, _leastIndexJsDefault.default)); +parcelHelpers.export(exports, "greatest", ()=>(0, _greatestJsDefault.default)); +parcelHelpers.export(exports, "greatestIndex", ()=>(0, _greatestIndexJsDefault.default)); +parcelHelpers.export(exports, "scan", ()=>(0, _scanJsDefault.default)) // Deprecated; use leastIndex. +; +parcelHelpers.export(exports, "shuffle", ()=>(0, _shuffleJsDefault.default)); +parcelHelpers.export(exports, "shuffler", ()=>(0, _shuffleJs.shuffler)); +parcelHelpers.export(exports, "sum", ()=>(0, _sumJsDefault.default)); +parcelHelpers.export(exports, "ticks", ()=>(0, _ticksJsDefault.default)); +parcelHelpers.export(exports, "tickIncrement", ()=>(0, _ticksJs.tickIncrement)); +parcelHelpers.export(exports, "tickStep", ()=>(0, _ticksJs.tickStep)); +parcelHelpers.export(exports, "transpose", ()=>(0, _transposeJsDefault.default)); +parcelHelpers.export(exports, "variance", ()=>(0, _varianceJsDefault.default)); +parcelHelpers.export(exports, "zip", ()=>(0, _zipJsDefault.default)); +parcelHelpers.export(exports, "every", ()=>(0, _everyJsDefault.default)); +parcelHelpers.export(exports, "some", ()=>(0, _someJsDefault.default)); +parcelHelpers.export(exports, "filter", ()=>(0, _filterJsDefault.default)); +parcelHelpers.export(exports, "map", ()=>(0, _mapJsDefault.default)); +parcelHelpers.export(exports, "reduce", ()=>(0, _reduceJsDefault.default)); +parcelHelpers.export(exports, "reverse", ()=>(0, _reverseJsDefault.default)); +parcelHelpers.export(exports, "sort", ()=>(0, _sortJsDefault.default)); +parcelHelpers.export(exports, "difference", ()=>(0, _differenceJsDefault.default)); +parcelHelpers.export(exports, "disjoint", ()=>(0, _disjointJsDefault.default)); +parcelHelpers.export(exports, "intersection", ()=>(0, _intersectionJsDefault.default)); +parcelHelpers.export(exports, "subset", ()=>(0, _subsetJsDefault.default)); +parcelHelpers.export(exports, "superset", ()=>(0, _supersetJsDefault.default)); +parcelHelpers.export(exports, "union", ()=>(0, _unionJsDefault.default)); +parcelHelpers.export(exports, "InternMap", ()=>(0, _internmap.InternMap)); +parcelHelpers.export(exports, "InternSet", ()=>(0, _internmap.InternSet)); +var _bisectJs = require("./bisect.js"); +var _bisectJsDefault = parcelHelpers.interopDefault(_bisectJs); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _bisectorJs = require("./bisector.js"); +var _bisectorJsDefault = parcelHelpers.interopDefault(_bisectorJs); +var _blurJs = require("./blur.js"); +var _countJs = require("./count.js"); +var _countJsDefault = parcelHelpers.interopDefault(_countJs); +var _crossJs = require("./cross.js"); +var _crossJsDefault = parcelHelpers.interopDefault(_crossJs); +var _cumsumJs = require("./cumsum.js"); +var _cumsumJsDefault = parcelHelpers.interopDefault(_cumsumJs); +var _descendingJs = require("./descending.js"); +var _descendingJsDefault = parcelHelpers.interopDefault(_descendingJs); +var _deviationJs = require("./deviation.js"); +var _deviationJsDefault = parcelHelpers.interopDefault(_deviationJs); +var _extentJs = require("./extent.js"); +var _extentJsDefault = parcelHelpers.interopDefault(_extentJs); +var _fsumJs = require("./fsum.js"); +var _groupJs = require("./group.js"); +var _groupJsDefault = parcelHelpers.interopDefault(_groupJs); +var _groupSortJs = require("./groupSort.js"); +var _groupSortJsDefault = parcelHelpers.interopDefault(_groupSortJs); +var _binJs = require("./bin.js"); +var _binJsDefault = parcelHelpers.interopDefault(_binJs); +var _freedmanDiaconisJs = require("./threshold/freedmanDiaconis.js"); +var _freedmanDiaconisJsDefault = parcelHelpers.interopDefault(_freedmanDiaconisJs); +var _scottJs = require("./threshold/scott.js"); +var _scottJsDefault = parcelHelpers.interopDefault(_scottJs); +var _sturgesJs = require("./threshold/sturges.js"); +var _sturgesJsDefault = parcelHelpers.interopDefault(_sturgesJs); +var _maxJs = require("./max.js"); +var _maxJsDefault = parcelHelpers.interopDefault(_maxJs); +var _maxIndexJs = require("./maxIndex.js"); +var _maxIndexJsDefault = parcelHelpers.interopDefault(_maxIndexJs); +var _meanJs = require("./mean.js"); +var _meanJsDefault = parcelHelpers.interopDefault(_meanJs); +var _medianJs = require("./median.js"); +var _medianJsDefault = parcelHelpers.interopDefault(_medianJs); +var _mergeJs = require("./merge.js"); +var _mergeJsDefault = parcelHelpers.interopDefault(_mergeJs); +var _minJs = require("./min.js"); +var _minJsDefault = parcelHelpers.interopDefault(_minJs); +var _minIndexJs = require("./minIndex.js"); +var _minIndexJsDefault = parcelHelpers.interopDefault(_minIndexJs); +var _modeJs = require("./mode.js"); +var _modeJsDefault = parcelHelpers.interopDefault(_modeJs); +var _niceJs = require("./nice.js"); +var _niceJsDefault = parcelHelpers.interopDefault(_niceJs); +var _pairsJs = require("./pairs.js"); +var _pairsJsDefault = parcelHelpers.interopDefault(_pairsJs); +var _permuteJs = require("./permute.js"); +var _permuteJsDefault = parcelHelpers.interopDefault(_permuteJs); +var _quantileJs = require("./quantile.js"); +var _quantileJsDefault = parcelHelpers.interopDefault(_quantileJs); +var _quickselectJs = require("./quickselect.js"); +var _quickselectJsDefault = parcelHelpers.interopDefault(_quickselectJs); +var _rangeJs = require("./range.js"); +var _rangeJsDefault = parcelHelpers.interopDefault(_rangeJs); +var _rankJs = require("./rank.js"); +var _rankJsDefault = parcelHelpers.interopDefault(_rankJs); +var _leastJs = require("./least.js"); +var _leastJsDefault = parcelHelpers.interopDefault(_leastJs); +var _leastIndexJs = require("./leastIndex.js"); +var _leastIndexJsDefault = parcelHelpers.interopDefault(_leastIndexJs); +var _greatestJs = require("./greatest.js"); +var _greatestJsDefault = parcelHelpers.interopDefault(_greatestJs); +var _greatestIndexJs = require("./greatestIndex.js"); +var _greatestIndexJsDefault = parcelHelpers.interopDefault(_greatestIndexJs); +var _scanJs = require("./scan.js"); +var _scanJsDefault = parcelHelpers.interopDefault(_scanJs); +var _shuffleJs = require("./shuffle.js"); +var _shuffleJsDefault = parcelHelpers.interopDefault(_shuffleJs); +var _sumJs = require("./sum.js"); +var _sumJsDefault = parcelHelpers.interopDefault(_sumJs); +var _ticksJs = require("./ticks.js"); +var _ticksJsDefault = parcelHelpers.interopDefault(_ticksJs); +var _transposeJs = require("./transpose.js"); +var _transposeJsDefault = parcelHelpers.interopDefault(_transposeJs); +var _varianceJs = require("./variance.js"); +var _varianceJsDefault = parcelHelpers.interopDefault(_varianceJs); +var _zipJs = require("./zip.js"); +var _zipJsDefault = parcelHelpers.interopDefault(_zipJs); +var _everyJs = require("./every.js"); +var _everyJsDefault = parcelHelpers.interopDefault(_everyJs); +var _someJs = require("./some.js"); +var _someJsDefault = parcelHelpers.interopDefault(_someJs); +var _filterJs = require("./filter.js"); +var _filterJsDefault = parcelHelpers.interopDefault(_filterJs); +var _mapJs = require("./map.js"); +var _mapJsDefault = parcelHelpers.interopDefault(_mapJs); +var _reduceJs = require("./reduce.js"); +var _reduceJsDefault = parcelHelpers.interopDefault(_reduceJs); +var _reverseJs = require("./reverse.js"); +var _reverseJsDefault = parcelHelpers.interopDefault(_reverseJs); +var _sortJs = require("./sort.js"); +var _sortJsDefault = parcelHelpers.interopDefault(_sortJs); +var _differenceJs = require("./difference.js"); +var _differenceJsDefault = parcelHelpers.interopDefault(_differenceJs); +var _disjointJs = require("./disjoint.js"); +var _disjointJsDefault = parcelHelpers.interopDefault(_disjointJs); +var _intersectionJs = require("./intersection.js"); +var _intersectionJsDefault = parcelHelpers.interopDefault(_intersectionJs); +var _subsetJs = require("./subset.js"); +var _subsetJsDefault = parcelHelpers.interopDefault(_subsetJs); +var _supersetJs = require("./superset.js"); +var _supersetJsDefault = parcelHelpers.interopDefault(_supersetJs); +var _unionJs = require("./union.js"); +var _unionJsDefault = parcelHelpers.interopDefault(_unionJs); +var _internmap = require("internmap"); + +},{"./bisect.js":"5mqeI","./ascending.js":"zAyXo","./bisector.js":"49VDk","./blur.js":"jfE0Q","./count.js":"6vIaU","./cross.js":"jUp0X","./cumsum.js":"h3OPK","./descending.js":"fbB9Y","./deviation.js":"6718P","./extent.js":"5JWQp","./fsum.js":"3h28A","./group.js":"kABha","./groupSort.js":"kyLtP","./bin.js":"6hfwu","./threshold/freedmanDiaconis.js":"2dRyq","./threshold/scott.js":"lGg25","./threshold/sturges.js":"1lIJb","./max.js":"8YwYZ","./maxIndex.js":"l9rNy","./mean.js":"fVfCV","./median.js":"awkrD","./merge.js":"liJWL","./min.js":"6iq65","./minIndex.js":"8xCGl","./mode.js":"2Kgrp","./nice.js":"e63B5","./pairs.js":"c2ViX","./permute.js":"eud3x","./quantile.js":"29jB7","./quickselect.js":"pm9zy","./range.js":"7i9on","./rank.js":"kd13S","./least.js":"ceK4t","./leastIndex.js":"dW25b","./greatest.js":"jrFax","./greatestIndex.js":"dL9ui","./scan.js":"bmKwW","./shuffle.js":"3ZIpU","./sum.js":"8SwUe","./ticks.js":"fmECo","./transpose.js":"1Ej71","./variance.js":"881VG","./zip.js":"f7Krc","./every.js":"agCBw","./some.js":"3LqiV","./filter.js":"9mlS9","./map.js":"ePJbS","./reduce.js":"h3fvA","./reverse.js":"lg91e","./sort.js":"93lWn","./difference.js":"jJaFT","./disjoint.js":"ewThO","./intersection.js":"3dVn4","./subset.js":"fO88f","./superset.js":"6zbJQ","./union.js":"loYUW","internmap":"cOuqB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5mqeI":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "bisectRight", ()=>bisectRight); +parcelHelpers.export(exports, "bisectLeft", ()=>bisectLeft); +parcelHelpers.export(exports, "bisectCenter", ()=>bisectCenter); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _bisectorJs = require("./bisector.js"); +var _bisectorJsDefault = parcelHelpers.interopDefault(_bisectorJs); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +const ascendingBisect = (0, _bisectorJsDefault.default)((0, _ascendingJsDefault.default)); +const bisectRight = ascendingBisect.right; +const bisectLeft = ascendingBisect.left; +const bisectCenter = (0, _bisectorJsDefault.default)((0, _numberJsDefault.default)).center; +exports.default = bisectRight; + +},{"./ascending.js":"zAyXo","./bisector.js":"49VDk","./number.js":"gSG0m","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"zAyXo":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>ascending); +function ascending(a, b) { + return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"49VDk":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>bisector); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _descendingJs = require("./descending.js"); +var _descendingJsDefault = parcelHelpers.interopDefault(_descendingJs); +function bisector(f) { + let compare1, compare2, delta; + // If an accessor is specified, promote it to a comparator. In this case we + // can test whether the search value is (self-) comparable. We can’t do this + // for a comparator (except for specific, known comparators) because we can’t + // tell if the comparator is symmetric, and an asymmetric comparator can’t be + // used to test whether a single value is comparable. + if (f.length !== 2) { + compare1 = (0, _ascendingJsDefault.default); + compare2 = (d, x)=>(0, _ascendingJsDefault.default)(f(d), x); + delta = (d, x)=>f(d) - x; + } else { + compare1 = f === (0, _ascendingJsDefault.default) || f === (0, _descendingJsDefault.default) ? f : zero; + compare2 = f; + delta = f; + } + function left(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = lo + hi >>> 1; + if (compare2(a[mid], x) < 0) lo = mid + 1; + else hi = mid; + }while (lo < hi); } - }), (0, _base.base).react.createElement("div", { - title: "#d62728", - style: { - width: p10, - background: "rgb(214, 39, 40)" + return lo; + } + function right(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = lo + hi >>> 1; + if (compare2(a[mid], x) <= 0) lo = mid + 1; + else hi = mid; + }while (lo < hi); } - }), (0, _base.base).react.createElement("div", { - title: "#9467bd", - style: { - width: p10, - background: "rgb(148, 103, 189)" + return lo; + } + function center(a, x, lo = 0, hi = a.length) { + const i = left(a, x, lo, hi - 1); + return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; + } + return { + left, + center, + right + }; +} +function zero() { + return 0; +} + +},{"./ascending.js":"zAyXo","./descending.js":"fbB9Y","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fbB9Y":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>descending); +function descending(a, b) { + return a == null || b == null ? NaN : b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gSG0m":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>number); +parcelHelpers.export(exports, "numbers", ()=>numbers); +function number(x) { + return x === null ? NaN : +x; +} +function* numbers(values, valueof) { + if (valueof === undefined) { + for (let value of values)if (value != null && (value = +value) >= value) yield value; + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) yield value; + } +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jfE0Q":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "blur", ()=>blur); +parcelHelpers.export(exports, "blur2", ()=>blur2); +parcelHelpers.export(exports, "blurImage", ()=>blurImage); +function blur(values, r) { + if (!((r = +r) >= 0)) throw new RangeError("invalid r"); + let length = values.length; + if (!((length = Math.floor(length)) >= 0)) throw new RangeError("invalid length"); + if (!length || !r) return values; + const blur = blurf(r); + const temp = values.slice(); + blur(values, temp, 0, length, 1); + blur(temp, values, 0, length, 1); + blur(values, temp, 0, length, 1); + return values; +} +const blur2 = Blur2(blurf); +const blurImage = Blur2(blurfImage); +function Blur2(blur) { + return function(data, rx, ry = rx) { + if (!((rx = +rx) >= 0)) throw new RangeError("invalid rx"); + if (!((ry = +ry) >= 0)) throw new RangeError("invalid ry"); + let { data: values, width, height } = data; + if (!((width = Math.floor(width)) >= 0)) throw new RangeError("invalid width"); + if (!((height = Math.floor(height !== undefined ? height : values.length / width)) >= 0)) throw new RangeError("invalid height"); + if (!width || !height || !rx && !ry) return data; + const blurx = rx && blur(rx); + const blury = ry && blur(ry); + const temp = values.slice(); + if (blurx && blury) { + blurh(blurx, temp, values, width, height); + blurh(blurx, values, temp, width, height); + blurh(blurx, temp, values, width, height); + blurv(blury, values, temp, width, height); + blurv(blury, temp, values, width, height); + blurv(blury, values, temp, width, height); + } else if (blurx) { + blurh(blurx, values, temp, width, height); + blurh(blurx, temp, values, width, height); + blurh(blurx, values, temp, width, height); + } else if (blury) { + blurv(blury, values, temp, width, height); + blurv(blury, temp, values, width, height); + blurv(blury, values, temp, width, height); + } + return data; + }; +} +function blurh(blur, T, S, w, h) { + for(let y = 0, n = w * h; y < n;)blur(T, S, y, y += w, 1); +} +function blurv(blur, T, S, w, h) { + for(let x = 0, n = w * h; x < w; ++x)blur(T, S, x, x + n, w); +} +function blurfImage(radius) { + const blur = blurf(radius); + return (T, S, start, stop, step)=>{ + start <<= 2, stop <<= 2, step <<= 2; + blur(T, S, start + 0, stop + 0, step); + blur(T, S, start + 1, stop + 1, step); + blur(T, S, start + 2, stop + 2, step); + blur(T, S, start + 3, stop + 3, step); + }; +} +// Given a target array T, a source array S, sets each value T[i] to the average +// of {S[i - r], …, S[i], …, S[i + r]}, where r = ⌊radius⌋, start <= i < stop, +// for each i, i + step, i + 2 * step, etc., and where S[j] is clamped between +// S[start] (inclusive) and S[stop] (exclusive). If the given radius is not an +// integer, S[i - r - 1] and S[i + r + 1] are added to the sum, each weighted +// according to r - ⌊radius⌋. +function blurf(radius) { + const radius0 = Math.floor(radius); + if (radius0 === radius) return bluri(radius); + const t = radius - radius0; + const w = 2 * radius + 1; + return (T, S, start, stop, step)=>{ + if (!((stop -= step) >= start)) return; // inclusive stop + let sum = radius0 * S[start]; + const s0 = step * radius0; + const s1 = s0 + step; + for(let i = start, j = start + s0; i < j; i += step)sum += S[Math.min(stop, i)]; + for(let i = start, j = stop; i <= j; i += step){ + sum += S[Math.min(stop, i + s0)]; + T[i] = (sum + t * (S[Math.max(start, i - s1)] + S[Math.min(stop, i + s1)])) / w; + sum -= S[Math.max(start, i - s0)]; + } + }; +} +// Like blurf, but optimized for integer radius. +function bluri(radius) { + const w = 2 * radius + 1; + return (T, S, start, stop, step)=>{ + if (!((stop -= step) >= start)) return; // inclusive stop + let sum = radius * S[start]; + const s = step * radius; + for(let i = start, j = start + s; i < j; i += step)sum += S[Math.min(stop, i)]; + for(let i = start, j = stop; i <= j; i += step){ + sum += S[Math.min(stop, i + s)]; + T[i] = sum / w; + sum -= S[Math.max(start, i - s)]; + } + }; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6vIaU":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>count); +function count(values, valueof) { + let count = 0; + if (valueof === undefined) { + for (let value of values)if (value != null && (value = +value) >= value) ++count; + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) ++count; + } + return count; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jUp0X":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>cross); +function length(array) { + return array.length | 0; +} +function empty(length) { + return !(length > 0); +} +function arrayify(values) { + return typeof values !== "object" || "length" in values ? values : Array.from(values); +} +function reducer(reduce) { + return (values)=>reduce(...values); +} +function cross(...values) { + const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop()); + values = values.map(arrayify); + const lengths = values.map(length); + const j = values.length - 1; + const index = new Array(j + 1).fill(0); + const product = []; + if (j < 0 || lengths.some(empty)) return product; + while(true){ + product.push(index.map((j, i)=>values[i][j])); + let i = j; + while(++index[i] === lengths[i]){ + if (i === 0) return reduce ? product.map(reduce) : product; + index[i--] = 0; } - }), (0, _base.base).react.createElement("div", { - title: "#8c564b", - style: { - width: p10, - background: "rgb(140, 86, 75)" + } +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h3OPK":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>cumsum); +function cumsum(values, valueof) { + var sum = 0, index = 0; + return Float64Array.from(values, valueof === undefined ? (v)=>sum += +v || 0 : (v)=>sum += +valueof(v, index++, values) || 0); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6718P":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>deviation); +var _varianceJs = require("./variance.js"); +var _varianceJsDefault = parcelHelpers.interopDefault(_varianceJs); +function deviation(values, valueof) { + const v = (0, _varianceJsDefault.default)(values, valueof); + return v ? Math.sqrt(v) : v; +} + +},{"./variance.js":"881VG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"881VG":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>variance); +function variance(values, valueof) { + let count = 0; + let delta; + let mean = 0; + let sum = 0; + if (valueof === undefined) { + for (let value of values)if (value != null && (value = +value) >= value) { + delta = value - mean; + mean += delta / ++count; + sum += delta * (value - mean); } - }), (0, _base.base).react.createElement("div", { - title: "#e377c2", - style: { - width: p10, - background: "rgb(227, 119, 194)" + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) { + delta = value - mean; + mean += delta / ++count; + sum += delta * (value - mean); } - }), (0, _base.base).react.createElement("div", { - title: "#7f7f7f", - style: { - width: p10, - background: "rgb(127, 127, 127)" + } + if (count > 1) return sum / (count - 1); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5JWQp":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>extent); +function extent(values, valueof) { + let min; + let max; + if (valueof === undefined) { + for (const value of values)if (value != null) { + if (min === undefined) { + if (value >= value) min = max = value; + } else { + if (min > value) min = value; + if (max < value) max = value; + } } - }), (0, _base.base).react.createElement("div", { - title: "#bcbd22", - style: { - width: p10, - background: "rgb(188, 189, 34)" + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null) { + if (min === undefined) { + if (value >= value) min = max = value; + } else { + if (min > value) min = value; + if (max < value) max = value; + } } - }), (0, _base.base).react.createElement("div", { - title: "#17becf", - style: { - width: p10, - background: "rgb(23, 190, 207)" + } + return [ + min, + max + ]; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3h28A":[function(require,module,exports,__globalThis) { +// https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Modules/mathmodule.c#L1423 +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "Adder", ()=>Adder); +parcelHelpers.export(exports, "fsum", ()=>fsum); +parcelHelpers.export(exports, "fcumsum", ()=>fcumsum); +class Adder { + constructor(){ + this._partials = new Float64Array(32); + this._n = 0; + } + add(x) { + const p = this._partials; + let i = 0; + for(let j = 0; j < this._n && j < 32; j++){ + const y = p[j], hi = x + y, lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x); + if (lo) p[i++] = lo; + x = hi; } - })); - (0, _scheme.schemesJSX)["category20"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#1f77b4", - style: { - width: p20, - background: "rgb(31, 119, 180)" + p[i] = x; + this._n = i + 1; + return this; + } + valueOf() { + const p = this._partials; + let n = this._n, x, y, lo, hi = 0; + if (n > 0) { + hi = p[--n]; + while(n > 0){ + x = hi; + y = p[--n]; + hi = x + y; + lo = y - (hi - x); + if (lo) break; + } + if (n > 0 && (lo < 0 && p[n - 1] < 0 || lo > 0 && p[n - 1] > 0)) { + y = lo * 2; + x = hi + y; + if (y == x - hi) hi = x; + } } - }), (0, _base.base).react.createElement("div", { - title: "#aec7e8", - style: { - width: p20, - background: "rgb(174, 199, 232)" + return hi; + } +} +function fsum(values, valueof) { + const adder = new Adder(); + if (valueof === undefined) { + for (let value of values)if (value = +value) adder.add(value); + } else { + let index = -1; + for (let value of values)if (value = +valueof(value, ++index, values)) adder.add(value); + } + return +adder; +} +function fcumsum(values, valueof) { + const adder = new Adder(); + let index = -1; + return Float64Array.from(values, valueof === undefined ? (v)=>adder.add(+v || 0) : (v)=>adder.add(+valueof(v, ++index, values) || 0)); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kABha":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>group); +parcelHelpers.export(exports, "groups", ()=>groups); +parcelHelpers.export(exports, "flatGroup", ()=>flatGroup); +parcelHelpers.export(exports, "flatRollup", ()=>flatRollup); +parcelHelpers.export(exports, "rollup", ()=>rollup); +parcelHelpers.export(exports, "rollups", ()=>rollups); +parcelHelpers.export(exports, "index", ()=>index); +parcelHelpers.export(exports, "indexes", ()=>indexes); +var _internmap = require("internmap"); +var _identityJs = require("./identity.js"); +var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); +function group(values, ...keys) { + return nest(values, (0, _identityJsDefault.default), (0, _identityJsDefault.default), keys); +} +function groups(values, ...keys) { + return nest(values, Array.from, (0, _identityJsDefault.default), keys); +} +function flatten(groups, keys) { + for(let i = 1, n = keys.length; i < n; ++i)groups = groups.flatMap((g)=>g.pop().map(([key, value])=>[ + ...g, + key, + value + ])); + return groups; +} +function flatGroup(values, ...keys) { + return flatten(groups(values, ...keys), keys); +} +function flatRollup(values, reduce, ...keys) { + return flatten(rollups(values, reduce, ...keys), keys); +} +function rollup(values, reduce, ...keys) { + return nest(values, (0, _identityJsDefault.default), reduce, keys); +} +function rollups(values, reduce, ...keys) { + return nest(values, Array.from, reduce, keys); +} +function index(values, ...keys) { + return nest(values, (0, _identityJsDefault.default), unique, keys); +} +function indexes(values, ...keys) { + return nest(values, Array.from, unique, keys); +} +function unique(values) { + if (values.length !== 1) throw new Error("duplicate key"); + return values[0]; +} +function nest(values, map, reduce, keys) { + return function regroup(values, i) { + if (i >= keys.length) return reduce(values); + const groups = new (0, _internmap.InternMap)(); + const keyof = keys[i++]; + let index = -1; + for (const value of values){ + const key = keyof(value, ++index, values); + const group = groups.get(key); + if (group) group.push(value); + else groups.set(key, [ + value + ]); } - }), (0, _base.base).react.createElement("div", { - title: "#ff7f0e", - style: { - width: p20, - background: "rgb(255, 127, 14)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffbb78", - style: { - width: p20, - background: "rgb(255, 187, 120)" - } - }), (0, _base.base).react.createElement("div", { - title: "#2ca02c", - style: { - width: p20, - background: "rgb(44, 160, 44)" - } - }), (0, _base.base).react.createElement("div", { - title: "#98df8a", - style: { - width: p20, - background: "rgb(152, 223, 138)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d62728", - style: { - width: p20, - background: "rgb(214, 39, 40)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ff9896", - style: { - width: p20, - background: "rgb(255, 152, 150)" - } - }), (0, _base.base).react.createElement("div", { - title: "#9467bd", - style: { - width: p20, - background: "rgb(148, 103, 189)" - } - }), (0, _base.base).react.createElement("div", { - title: "#c5b0d5", - style: { - width: p20, - background: "rgb(197, 176, 213)" - } - }), (0, _base.base).react.createElement("div", { - title: "#8c564b", - style: { - width: p20, - background: "rgb(140, 86, 75)" - } - }), (0, _base.base).react.createElement("div", { - title: "#c49c94", - style: { - width: p20, - background: "rgb(196, 156, 148)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e377c2", - style: { - width: p20, - background: "rgb(227, 119, 194)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f7b6d2", - style: { - width: p20, - background: "rgb(247, 182, 210)" - } - }), (0, _base.base).react.createElement("div", { - title: "#7f7f7f", - style: { - width: p20, - background: "rgb(127, 127, 127)" - } - }), (0, _base.base).react.createElement("div", { - title: "#c7c7c7", - style: { - width: p20, - background: "rgb(199, 199, 199)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bcbd22", - style: { - width: p20, - background: "rgb(188, 189, 34)" - } - }), (0, _base.base).react.createElement("div", { - title: "#dbdb8d", - style: { - width: p20, - background: "rgb(219, 219, 141)" + for (const [key, values] of groups)groups.set(key, regroup(values, i)); + return map(groups); + }(values, 0); +} + +},{"internmap":"cOuqB","./identity.js":"i6NWs","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cOuqB":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "InternMap", ()=>InternMap); +parcelHelpers.export(exports, "InternSet", ()=>InternSet); +class InternMap extends Map { + constructor(entries, key = keyof){ + super(); + Object.defineProperties(this, { + _intern: { + value: new Map() + }, + _key: { + value: key + } + }); + if (entries != null) for (const [key, value] of entries)this.set(key, value); + } + get(key) { + return super.get(intern_get(this, key)); + } + has(key) { + return super.has(intern_get(this, key)); + } + set(key, value) { + return super.set(intern_set(this, key), value); + } + delete(key) { + return super.delete(intern_delete(this, key)); + } +} +class InternSet extends Set { + constructor(values, key = keyof){ + super(); + Object.defineProperties(this, { + _intern: { + value: new Map() + }, + _key: { + value: key + } + }); + if (values != null) for (const value of values)this.add(value); + } + has(value) { + return super.has(intern_get(this, value)); + } + add(value) { + return super.add(intern_set(this, value)); + } + delete(value) { + return super.delete(intern_delete(this, value)); + } +} +function intern_get({ _intern, _key }, value) { + const key = _key(value); + return _intern.has(key) ? _intern.get(key) : value; +} +function intern_set({ _intern, _key }, value) { + const key = _key(value); + if (_intern.has(key)) return _intern.get(key); + _intern.set(key, value); + return value; +} +function intern_delete({ _intern, _key }, value) { + const key = _key(value); + if (_intern.has(key)) { + value = _intern.get(key); + _intern.delete(key); + } + return value; +} +function keyof(value) { + return value !== null && typeof value === "object" ? value.valueOf() : value; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"i6NWs":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>identity); +function identity(x) { + return x; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kyLtP":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>groupSort); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _groupJs = require("./group.js"); +var _groupJsDefault = parcelHelpers.interopDefault(_groupJs); +var _sortJs = require("./sort.js"); +var _sortJsDefault = parcelHelpers.interopDefault(_sortJs); +function groupSort(values, reduce, key) { + return (reduce.length !== 2 ? (0, _sortJsDefault.default)((0, _groupJs.rollup)(values, reduce, key), ([ak, av], [bk, bv])=>(0, _ascendingJsDefault.default)(av, bv) || (0, _ascendingJsDefault.default)(ak, bk)) : (0, _sortJsDefault.default)((0, _groupJsDefault.default)(values, key), ([ak, av], [bk, bv])=>reduce(av, bv) || (0, _ascendingJsDefault.default)(ak, bk))).map(([key])=>key); +} + +},{"./ascending.js":"zAyXo","./group.js":"kABha","./sort.js":"93lWn","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"93lWn":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>sort); +parcelHelpers.export(exports, "compareDefined", ()=>compareDefined); +parcelHelpers.export(exports, "ascendingDefined", ()=>ascendingDefined); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _permuteJs = require("./permute.js"); +var _permuteJsDefault = parcelHelpers.interopDefault(_permuteJs); +function sort(values, ...F) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + values = Array.from(values); + let [f] = F; + if (f && f.length !== 2 || F.length > 1) { + const index = Uint32Array.from(values, (d, i)=>i); + if (F.length > 1) { + F = F.map((f)=>values.map(f)); + index.sort((i, j)=>{ + for (const f of F){ + const c = ascendingDefined(f[i], f[j]); + if (c) return c; + } + }); + } else { + f = values.map(f); + index.sort((i, j)=>ascendingDefined(f[i], f[j])); } - }), (0, _base.base).react.createElement("div", { - title: "#17becf", - style: { - width: p20, - background: "rgb(23, 190, 207)" + return (0, _permuteJsDefault.default)(values, index); + } + return values.sort(compareDefined(f)); +} +function compareDefined(compare = (0, _ascendingJsDefault.default)) { + if (compare === (0, _ascendingJsDefault.default)) return ascendingDefined; + if (typeof compare !== "function") throw new TypeError("compare is not a function"); + return (a, b)=>{ + const x = compare(a, b); + if (x || x === 0) return x; + return (compare(b, b) === 0) - (compare(a, a) === 0); + }; +} +function ascendingDefined(a, b) { + return (a == null || !(a >= a)) - (b == null || !(b >= b)) || (a < b ? -1 : a > b ? 1 : 0); +} + +},{"./ascending.js":"zAyXo","./permute.js":"eud3x","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eud3x":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>permute); +function permute(source, keys) { + return Array.from(keys, (key)=>source[key]); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6hfwu":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>bin); +var _arrayJs = require("./array.js"); +var _bisectJs = require("./bisect.js"); +var _bisectJsDefault = parcelHelpers.interopDefault(_bisectJs); +var _constantJs = require("./constant.js"); +var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); +var _extentJs = require("./extent.js"); +var _extentJsDefault = parcelHelpers.interopDefault(_extentJs); +var _identityJs = require("./identity.js"); +var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); +var _niceJs = require("./nice.js"); +var _niceJsDefault = parcelHelpers.interopDefault(_niceJs); +var _ticksJs = require("./ticks.js"); +var _ticksJsDefault = parcelHelpers.interopDefault(_ticksJs); +var _sturgesJs = require("./threshold/sturges.js"); +var _sturgesJsDefault = parcelHelpers.interopDefault(_sturgesJs); +function bin() { + var value = (0, _identityJsDefault.default), domain = (0, _extentJsDefault.default), threshold = (0, _sturgesJsDefault.default); + function histogram(data) { + if (!Array.isArray(data)) data = Array.from(data); + var i, n = data.length, x, step, values = new Array(n); + for(i = 0; i < n; ++i)values[i] = value(data[i], i, data); + var xz = domain(values), x0 = xz[0], x1 = xz[1], tz = threshold(values, x0, x1); + // Convert number of thresholds into uniform thresholds, and nice the + // default domain accordingly. + if (!Array.isArray(tz)) { + const max = x1, tn = +tz; + if (domain === (0, _extentJsDefault.default)) [x0, x1] = (0, _niceJsDefault.default)(x0, x1, tn); + tz = (0, _ticksJsDefault.default)(x0, x1, tn); + // If the domain is aligned with the first tick (which it will by + // default), then we can use quantization rather than bisection to bin + // values, which is substantially faster. + if (tz[0] <= x0) step = (0, _ticksJs.tickIncrement)(x0, x1, tn); + // If the last threshold is coincident with the domain’s upper bound, the + // last bin will be zero-width. If the default domain is used, and this + // last threshold is coincident with the maximum input value, we can + // extend the niced upper bound by one tick to ensure uniform bin widths; + // otherwise, we simply remove the last threshold. Note that we don’t + // coerce values or the domain to numbers, and thus must be careful to + // compare order (>=) rather than strict equality (===)! + if (tz[tz.length - 1] >= x1) { + if (max >= x1 && domain === (0, _extentJsDefault.default)) { + const step = (0, _ticksJs.tickIncrement)(x0, x1, tn); + if (isFinite(step)) { + if (step > 0) x1 = (Math.floor(x1 / step) + 1) * step; + else if (step < 0) x1 = (Math.ceil(x1 * -step) + 1) / -step; + } + } else tz.pop(); + } + } + // Remove any thresholds outside the domain. + // Be careful not to mutate an array owned by the user! + var m = tz.length, a = 0, b = m; + while(tz[a] <= x0)++a; + while(tz[b - 1] > x1)--b; + if (a || b < m) tz = tz.slice(a, b), m = b - a; + var bins = new Array(m + 1), bin; + // Initialize bins. + for(i = 0; i <= m; ++i){ + bin = bins[i] = []; + bin.x0 = i > 0 ? tz[i - 1] : x0; + bin.x1 = i < m ? tz[i] : x1; + } + // Assign data to bins by value, ignoring any outside the domain. + if (isFinite(step)) { + if (step > 0) { + for(i = 0; i < n; ++i)if ((x = values[i]) != null && x0 <= x && x <= x1) bins[Math.min(m, Math.floor((x - x0) / step))].push(data[i]); + } else if (step < 0) { + for(i = 0; i < n; ++i)if ((x = values[i]) != null && x0 <= x && x <= x1) { + const j = Math.floor((x0 - x) * step); + bins[Math.min(m, j + (tz[j] <= x))].push(data[i]); // handle off-by-one due to rounding + } + } + } else { + for(i = 0; i < n; ++i)if ((x = values[i]) != null && x0 <= x && x <= x1) bins[(0, _bisectJsDefault.default)(tz, x, 0, m)].push(data[i]); } - }), (0, _base.base).react.createElement("div", { - title: "#9edae5", - style: { - width: p20, - background: "rgb(158, 218, 229)" + return bins; + } + histogram.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : (0, _constantJsDefault.default)(_), histogram) : value; + }; + histogram.domain = function(_) { + return arguments.length ? (domain = typeof _ === "function" ? _ : (0, _constantJsDefault.default)([ + _[0], + _[1] + ]), histogram) : domain; + }; + histogram.thresholds = function(_) { + return arguments.length ? (threshold = typeof _ === "function" ? _ : (0, _constantJsDefault.default)(Array.isArray(_) ? (0, _arrayJs.slice).call(_) : _), histogram) : threshold; + }; + return histogram; +} + +},{"./array.js":"j2SMP","./bisect.js":"5mqeI","./constant.js":"7wJOu","./extent.js":"5JWQp","./identity.js":"i6NWs","./nice.js":"e63B5","./ticks.js":"fmECo","./threshold/sturges.js":"1lIJb","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"j2SMP":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "slice", ()=>slice); +parcelHelpers.export(exports, "map", ()=>map); +var array = Array.prototype; +var slice = array.slice; +var map = array.map; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7wJOu":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>constant); +function constant(x) { + return ()=>x; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e63B5":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>nice); +var _ticksJs = require("./ticks.js"); +function nice(start, stop, count) { + let prestep; + while(true){ + const step = (0, _ticksJs.tickIncrement)(start, stop, count); + if (step === prestep || step === 0 || !isFinite(step)) return [ + start, + stop + ]; + else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; } - })); - (0, _scheme.schemesJSX)["category20b"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#393b79", - style: { - width: p20, - background: "rgb(57, 59, 121)" + prestep = step; + } +} + +},{"./ticks.js":"fmECo","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fmECo":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>ticks); +parcelHelpers.export(exports, "tickIncrement", ()=>tickIncrement); +parcelHelpers.export(exports, "tickStep", ()=>tickStep); +const e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2); +function tickSpec(start, stop, count) { + const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; + let i1, i2, inc; + if (power < 0) { + inc = Math.pow(10, -power) / factor; + i1 = Math.round(start * inc); + i2 = Math.round(stop * inc); + if (i1 / inc < start) ++i1; + if (i2 / inc > stop) --i2; + inc = -inc; + } else { + inc = Math.pow(10, power) * factor; + i1 = Math.round(start / inc); + i2 = Math.round(stop / inc); + if (i1 * inc < start) ++i1; + if (i2 * inc > stop) --i2; + } + if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); + return [ + i1, + i2, + inc + ]; +} +function ticks(start, stop, count) { + stop = +stop, start = +start, count = +count; + if (!(count > 0)) return []; + if (start === stop) return [ + start + ]; + const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count); + if (!(i2 >= i1)) return []; + const n = i2 - i1 + 1, ticks = new Array(n); + if (reverse) { + if (inc < 0) for(let i = 0; i < n; ++i)ticks[i] = (i2 - i) / -inc; + else for(let i = 0; i < n; ++i)ticks[i] = (i2 - i) * inc; + } else { + if (inc < 0) for(let i = 0; i < n; ++i)ticks[i] = (i1 + i) / -inc; + else for(let i = 0; i < n; ++i)ticks[i] = (i1 + i) * inc; + } + return ticks; +} +function tickIncrement(start, stop, count) { + stop = +stop, start = +start, count = +count; + return tickSpec(start, stop, count)[2]; +} +function tickStep(start, stop, count) { + stop = +stop, start = +start, count = +count; + const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count); + return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1lIJb":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>thresholdSturges); +var _countJs = require("../count.js"); +var _countJsDefault = parcelHelpers.interopDefault(_countJs); +function thresholdSturges(values) { + return Math.max(1, Math.ceil(Math.log((0, _countJsDefault.default)(values)) / Math.LN2) + 1); +} + +},{"../count.js":"6vIaU","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2dRyq":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>thresholdFreedmanDiaconis); +var _countJs = require("../count.js"); +var _countJsDefault = parcelHelpers.interopDefault(_countJs); +var _quantileJs = require("../quantile.js"); +var _quantileJsDefault = parcelHelpers.interopDefault(_quantileJs); +function thresholdFreedmanDiaconis(values, min, max) { + const c = (0, _countJsDefault.default)(values), d = (0, _quantileJsDefault.default)(values, 0.75) - (0, _quantileJsDefault.default)(values, 0.25); + return c && d ? Math.ceil((max - min) / (2 * d * Math.pow(c, -1 / 3))) : 1; +} + +},{"../count.js":"6vIaU","../quantile.js":"29jB7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"29jB7":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>quantile); +parcelHelpers.export(exports, "quantileSorted", ()=>quantileSorted); +parcelHelpers.export(exports, "quantileIndex", ()=>quantileIndex); +var _maxJs = require("./max.js"); +var _maxJsDefault = parcelHelpers.interopDefault(_maxJs); +var _maxIndexJs = require("./maxIndex.js"); +var _maxIndexJsDefault = parcelHelpers.interopDefault(_maxIndexJs); +var _minJs = require("./min.js"); +var _minJsDefault = parcelHelpers.interopDefault(_minJs); +var _minIndexJs = require("./minIndex.js"); +var _minIndexJsDefault = parcelHelpers.interopDefault(_minIndexJs); +var _quickselectJs = require("./quickselect.js"); +var _quickselectJsDefault = parcelHelpers.interopDefault(_quickselectJs); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +var _sortJs = require("./sort.js"); +var _greatestJs = require("./greatest.js"); +var _greatestJsDefault = parcelHelpers.interopDefault(_greatestJs); +function quantile(values, p, valueof) { + values = Float64Array.from((0, _numberJs.numbers)(values, valueof)); + if (!(n = values.length) || isNaN(p = +p)) return; + if (p <= 0 || n < 2) return (0, _minJsDefault.default)(values); + if (p >= 1) return (0, _maxJsDefault.default)(values); + var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = (0, _maxJsDefault.default)((0, _quickselectJsDefault.default)(values, i0).subarray(0, i0 + 1)), value1 = (0, _minJsDefault.default)(values.subarray(i0 + 1)); + return value0 + (value1 - value0) * (i - i0); +} +function quantileSorted(values, p, valueof = (0, _numberJsDefault.default)) { + if (!(n = values.length) || isNaN(p = +p)) return; + if (p <= 0 || n < 2) return +valueof(values[0], 0, values); + if (p >= 1) return +valueof(values[n - 1], n - 1, values); + var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = +valueof(values[i0], i0, values), value1 = +valueof(values[i0 + 1], i0 + 1, values); + return value0 + (value1 - value0) * (i - i0); +} +function quantileIndex(values, p, valueof = (0, _numberJsDefault.default)) { + if (isNaN(p = +p)) return; + numbers = Float64Array.from(values, (_, i)=>(0, _numberJsDefault.default)(valueof(values[i], i, values))); + if (p <= 0) return (0, _minIndexJsDefault.default)(numbers); + if (p >= 1) return (0, _maxIndexJsDefault.default)(numbers); + var numbers, index = Uint32Array.from(values, (_, i)=>i), j = numbers.length - 1, i = Math.floor(j * p); + (0, _quickselectJsDefault.default)(index, i, 0, j, (i, j)=>(0, _sortJs.ascendingDefined)(numbers[i], numbers[j])); + i = (0, _greatestJsDefault.default)(index.subarray(0, i + 1), (i)=>numbers[i]); + return i >= 0 ? i : -1; +} + +},{"./max.js":"8YwYZ","./maxIndex.js":"l9rNy","./min.js":"6iq65","./minIndex.js":"8xCGl","./quickselect.js":"pm9zy","./number.js":"gSG0m","./sort.js":"93lWn","./greatest.js":"jrFax","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8YwYZ":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>max); +function max(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values)if (value != null && (max < value || max === undefined && value >= value)) max = value; + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (max < value || max === undefined && value >= value)) max = value; + } + return max; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"l9rNy":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>maxIndex); +function maxIndex(values, valueof) { + let max; + let maxIndex = -1; + let index = -1; + if (valueof === undefined) for (const value of values){ + ++index; + if (value != null && (max < value || max === undefined && value >= value)) max = value, maxIndex = index; + } + else { + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (max < value || max === undefined && value >= value)) max = value, maxIndex = index; + } + return maxIndex; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6iq65":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>min); +function min(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values)if (value != null && (min > value || min === undefined && value >= value)) min = value; + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (min > value || min === undefined && value >= value)) min = value; + } + return min; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8xCGl":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>minIndex); +function minIndex(values, valueof) { + let min; + let minIndex = -1; + let index = -1; + if (valueof === undefined) for (const value of values){ + ++index; + if (value != null && (min > value || min === undefined && value >= value)) min = value, minIndex = index; + } + else { + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (min > value || min === undefined && value >= value)) min = value, minIndex = index; + } + return minIndex; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"pm9zy":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>quickselect); +var _sortJs = require("./sort.js"); +function quickselect(array, k, left = 0, right = Infinity, compare) { + k = Math.floor(k); + left = Math.floor(Math.max(0, left)); + right = Math.floor(Math.min(array.length - 1, right)); + if (!(left <= k && k <= right)) return array; + compare = compare === undefined ? (0, _sortJs.ascendingDefined) : (0, _sortJs.compareDefined)(compare); + while(right > left){ + if (right - left > 600) { + const n = right - left + 1; + const m = k - left + 1; + const z = Math.log(n); + const s = 0.5 * Math.exp(2 * z / 3); + const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + const newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + quickselect(array, k, newLeft, newRight, compare); } - }), (0, _base.base).react.createElement("div", { - title: "#5254a3", - style: { - width: p20, - background: "rgb(82, 84, 163)" + const t = array[k]; + let i = left; + let j = right; + swap(array, left, k); + if (compare(array[right], t) > 0) swap(array, left, right); + while(i < j){ + swap(array, i, j), ++i, --j; + while(compare(array[i], t) < 0)++i; + while(compare(array[j], t) > 0)--j; } - }), (0, _base.base).react.createElement("div", { - title: "#6b6ecf", - style: { - width: p20, - background: "rgb(107, 110, 207)" + if (compare(array[left], t) === 0) swap(array, left, j); + else ++j, swap(array, j, right); + if (j <= k) left = j + 1; + if (k <= j) right = j - 1; + } + return array; +} +function swap(array, i, j) { + const t = array[i]; + array[i] = array[j]; + array[j] = t; +} + +},{"./sort.js":"93lWn","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jrFax":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>greatest); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +function greatest(values, compare = (0, _ascendingJsDefault.default)) { + let max; + let defined = false; + if (compare.length === 1) { + let maxValue; + for (const element of values){ + const value = compare(element); + if (defined ? (0, _ascendingJsDefault.default)(value, maxValue) > 0 : (0, _ascendingJsDefault.default)(value, value) === 0) { + max = element; + maxValue = value; + defined = true; + } } - }), (0, _base.base).react.createElement("div", { - title: "#9c9ede", - style: { - width: p20, - background: "rgb(156, 158, 222)" + } else { + for (const value of values)if (defined ? compare(value, max) > 0 : compare(value, value) === 0) { + max = value; + defined = true; } - }), (0, _base.base).react.createElement("div", { - title: "#637939", - style: { - width: p20, - background: "rgb(99, 121, 57)" - } - }), (0, _base.base).react.createElement("div", { - title: "#8ca252", - style: { - width: p20, - background: "rgb(140, 162, 82)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b5cf6b", - style: { - width: p20, - background: "rgb(181, 207, 107)" - } - }), (0, _base.base).react.createElement("div", { - title: "#cedb9c", - style: { - width: p20, - background: "rgb(206, 219, 156)" - } - }), (0, _base.base).react.createElement("div", { - title: "#8c6d31", - style: { - width: p20, - background: "rgb(140, 109, 49)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bd9e39", - style: { - width: p20, - background: "rgb(189, 158, 57)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e7ba52", - style: { - width: p20, - background: "rgb(231, 186, 82)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e7cb94", - style: { - width: p20, - background: "rgb(231, 203, 148)" - } - }), (0, _base.base).react.createElement("div", { - title: "#843c39", - style: { - width: p20, - background: "rgb(132, 60, 57)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ad494a", - style: { - width: p20, - background: "rgb(173, 73, 74)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d6616b", - style: { - width: p20, - background: "rgb(214, 97, 107)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e7969c", - style: { - width: p20, - background: "rgb(231, 150, 156)" - } - }), (0, _base.base).react.createElement("div", { - title: "#7b4173", - style: { - width: p20, - background: "rgb(123, 65, 115)" - } - }), (0, _base.base).react.createElement("div", { - title: "#a55194", - style: { - width: p20, - background: "rgb(165, 81, 148)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ce6dbd", - style: { - width: p20, - background: "rgb(206, 109, 189)" + } + return max; +} + +},{"./ascending.js":"zAyXo","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lGg25":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>thresholdScott); +var _countJs = require("../count.js"); +var _countJsDefault = parcelHelpers.interopDefault(_countJs); +var _deviationJs = require("../deviation.js"); +var _deviationJsDefault = parcelHelpers.interopDefault(_deviationJs); +function thresholdScott(values, min, max) { + const c = (0, _countJsDefault.default)(values), d = (0, _deviationJsDefault.default)(values); + return c && d ? Math.ceil((max - min) * Math.cbrt(c) / (3.49 * d)) : 1; +} + +},{"../count.js":"6vIaU","../deviation.js":"6718P","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fVfCV":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>mean); +function mean(values, valueof) { + let count = 0; + let sum = 0; + if (valueof === undefined) { + for (let value of values)if (value != null && (value = +value) >= value) ++count, sum += value; + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) ++count, sum += value; + } + if (count) return sum / count; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"awkrD":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>median); +parcelHelpers.export(exports, "medianIndex", ()=>medianIndex); +var _quantileJs = require("./quantile.js"); +var _quantileJsDefault = parcelHelpers.interopDefault(_quantileJs); +function median(values, valueof) { + return (0, _quantileJsDefault.default)(values, 0.5, valueof); +} +function medianIndex(values, valueof) { + return (0, _quantileJs.quantileIndex)(values, 0.5, valueof); +} + +},{"./quantile.js":"29jB7","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"liJWL":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>merge); +function* flatten(arrays) { + for (const array of arrays)yield* array; +} +function merge(arrays) { + return Array.from(flatten(arrays)); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2Kgrp":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>mode); +var _internmap = require("internmap"); +function mode(values, valueof) { + const counts = new (0, _internmap.InternMap)(); + if (valueof === undefined) { + for (let value of values)if (value != null && value >= value) counts.set(value, (counts.get(value) || 0) + 1); + } else { + let index = -1; + for (let value of values)if ((value = valueof(value, ++index, values)) != null && value >= value) counts.set(value, (counts.get(value) || 0) + 1); + } + let modeValue; + let modeCount = 0; + for (const [value, count] of counts)if (count > modeCount) { + modeCount = count; + modeValue = value; + } + return modeValue; +} + +},{"internmap":"cOuqB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"c2ViX":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>pairs); +parcelHelpers.export(exports, "pair", ()=>pair); +function pairs(values, pairof = pair) { + const pairs1 = []; + let previous; + let first = false; + for (const value of values){ + if (first) pairs1.push(pairof(previous, value)); + previous = value; + first = true; + } + return pairs1; +} +function pair(a, b) { + return [ + a, + b + ]; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7i9on":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>range); +function range(start, stop, step) { + start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; + var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range = new Array(n); + while(++i < n)range[i] = start + i * step; + return range; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kd13S":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>rank); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _sortJs = require("./sort.js"); +function rank(values, valueof = (0, _ascendingJsDefault.default)) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + let V = Array.from(values); + const R = new Float64Array(V.length); + if (valueof.length !== 2) V = V.map(valueof), valueof = (0, _ascendingJsDefault.default); + const compareIndex = (i, j)=>valueof(V[i], V[j]); + let k, r; + values = Uint32Array.from(V, (_, i)=>i); + // Risky chaining due to Safari 14 https://github.com/d3/d3-array/issues/123 + values.sort(valueof === (0, _ascendingJsDefault.default) ? (i, j)=>(0, _sortJs.ascendingDefined)(V[i], V[j]) : (0, _sortJs.compareDefined)(compareIndex)); + values.forEach((j, i)=>{ + const c = compareIndex(j, k === undefined ? j : k); + if (c >= 0) { + if (k === undefined || c > 0) k = j, r = i; + R[j] = r; + } else R[j] = NaN; + }); + return R; +} + +},{"./ascending.js":"zAyXo","./sort.js":"93lWn","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ceK4t":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>least); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +function least(values, compare = (0, _ascendingJsDefault.default)) { + let min; + let defined = false; + if (compare.length === 1) { + let minValue; + for (const element of values){ + const value = compare(element); + if (defined ? (0, _ascendingJsDefault.default)(value, minValue) < 0 : (0, _ascendingJsDefault.default)(value, value) === 0) { + min = element; + minValue = value; + defined = true; + } } - }), (0, _base.base).react.createElement("div", { - title: "#de9ed6", - style: { - width: p20, - background: "rgb(222, 158, 214)" + } else { + for (const value of values)if (defined ? compare(value, min) < 0 : compare(value, value) === 0) { + min = value; + defined = true; } - })); - (0, _scheme.schemesJSX)["category20c"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#3182bd", - style: { - width: p20, - background: "rgb(49, 130, 189)" + } + return min; +} + +},{"./ascending.js":"zAyXo","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dW25b":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>leastIndex); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _minIndexJs = require("./minIndex.js"); +var _minIndexJsDefault = parcelHelpers.interopDefault(_minIndexJs); +function leastIndex(values, compare = (0, _ascendingJsDefault.default)) { + if (compare.length === 1) return (0, _minIndexJsDefault.default)(values, compare); + let minValue; + let min = -1; + let index = -1; + for (const value of values){ + ++index; + if (min < 0 ? compare(value, value) === 0 : compare(value, minValue) < 0) { + minValue = value; + min = index; } - }), (0, _base.base).react.createElement("div", { - title: "#6baed6", - style: { - width: p20, - background: "rgb(107, 174, 214)" + } + return min; +} + +},{"./ascending.js":"zAyXo","./minIndex.js":"8xCGl","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dL9ui":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>greatestIndex); +var _ascendingJs = require("./ascending.js"); +var _ascendingJsDefault = parcelHelpers.interopDefault(_ascendingJs); +var _maxIndexJs = require("./maxIndex.js"); +var _maxIndexJsDefault = parcelHelpers.interopDefault(_maxIndexJs); +function greatestIndex(values, compare = (0, _ascendingJsDefault.default)) { + if (compare.length === 1) return (0, _maxIndexJsDefault.default)(values, compare); + let maxValue; + let max = -1; + let index = -1; + for (const value of values){ + ++index; + if (max < 0 ? compare(value, value) === 0 : compare(value, maxValue) > 0) { + maxValue = value; + max = index; } - }), (0, _base.base).react.createElement("div", { - title: "#9ecae1", - style: { - width: p20, - background: "rgb(158, 202, 225)" + } + return max; +} + +},{"./ascending.js":"zAyXo","./maxIndex.js":"l9rNy","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bmKwW":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>scan); +var _leastIndexJs = require("./leastIndex.js"); +var _leastIndexJsDefault = parcelHelpers.interopDefault(_leastIndexJs); +function scan(values, compare) { + const index = (0, _leastIndexJsDefault.default)(values, compare); + return index < 0 ? undefined : index; +} + +},{"./leastIndex.js":"dW25b","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3ZIpU":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "shuffler", ()=>shuffler); +exports.default = shuffler(Math.random); +function shuffler(random) { + return function shuffle(array, i0 = 0, i1 = array.length) { + let m = i1 - (i0 = +i0); + while(m){ + const i = random() * m-- | 0, t = array[m + i0]; + array[m + i0] = array[i + i0]; + array[i + i0] = t; } - }), (0, _base.base).react.createElement("div", { - title: "#c6dbef", - style: { - width: p20, - background: "rgb(198, 219, 239)" + return array; + }; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8SwUe":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>sum); +function sum(values, valueof) { + let sum = 0; + if (valueof === undefined) { + for (let value of values)if (value = +value) sum += value; + } else { + let index = -1; + for (let value of values)if (value = +valueof(value, ++index, values)) sum += value; + } + return sum; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1Ej71":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>transpose); +var _minJs = require("./min.js"); +var _minJsDefault = parcelHelpers.interopDefault(_minJs); +function transpose(matrix) { + if (!(n = matrix.length)) return []; + for(var i = -1, m = (0, _minJsDefault.default)(matrix, length), transpose = new Array(m); ++i < m;)for(var j = -1, n, row = transpose[i] = new Array(n); ++j < n;)row[j] = matrix[j][i]; + return transpose; +} +function length(d) { + return d.length; +} + +},{"./min.js":"6iq65","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"f7Krc":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>zip); +var _transposeJs = require("./transpose.js"); +var _transposeJsDefault = parcelHelpers.interopDefault(_transposeJs); +function zip() { + return (0, _transposeJsDefault.default)(arguments); +} + +},{"./transpose.js":"1Ej71","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"agCBw":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>every); +function every(values, test) { + if (typeof test !== "function") throw new TypeError("test is not a function"); + let index = -1; + for (const value of values){ + if (!test(value, ++index, values)) return false; + } + return true; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3LqiV":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>some); +function some(values, test) { + if (typeof test !== "function") throw new TypeError("test is not a function"); + let index = -1; + for (const value of values){ + if (test(value, ++index, values)) return true; + } + return false; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9mlS9":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>filter); +function filter(values, test) { + if (typeof test !== "function") throw new TypeError("test is not a function"); + const array = []; + let index = -1; + for (const value of values)if (test(value, ++index, values)) array.push(value); + return array; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ePJbS":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>map); +function map(values, mapper) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + if (typeof mapper !== "function") throw new TypeError("mapper is not a function"); + return Array.from(values, (value, index)=>mapper(value, index, values)); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"h3fvA":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>reduce); +function reduce(values, reducer, value) { + if (typeof reducer !== "function") throw new TypeError("reducer is not a function"); + const iterator = values[Symbol.iterator](); + let done, next, index = -1; + if (arguments.length < 3) { + ({ done, value } = iterator.next()); + if (done) return; + ++index; + } + while({ done, value: next } = iterator.next(), !done)value = reducer(value, next, ++index, values); + return value; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lg91e":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>reverse); +function reverse(values) { + if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable"); + return Array.from(values).reverse(); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jJaFT":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>difference); +var _internmap = require("internmap"); +function difference(values, ...others) { + values = new (0, _internmap.InternSet)(values); + for (const other of others)for (const value of other)values.delete(value); + return values; +} + +},{"internmap":"cOuqB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ewThO":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>disjoint); +var _internmap = require("internmap"); +function disjoint(values, other) { + const iterator = other[Symbol.iterator](), set = new (0, _internmap.InternSet)(); + for (const v of values){ + if (set.has(v)) return false; + let value, done; + while({ value, done } = iterator.next()){ + if (done) break; + if (Object.is(v, value)) return false; + set.add(value); } - }), (0, _base.base).react.createElement("div", { - title: "#e6550d", - style: { - width: p20, - background: "rgb(230, 85, 13)" + } + return true; +} + +},{"internmap":"cOuqB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3dVn4":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>intersection); +var _internmap = require("internmap"); +function intersection(values, ...others) { + values = new (0, _internmap.InternSet)(values); + others = others.map(set); + out: for (const value of values){ + for (const other of others)if (!other.has(value)) { + values.delete(value); + continue out; } - }), (0, _base.base).react.createElement("div", { - title: "#fd8d3c", - style: { - width: p20, - background: "rgb(253, 141, 60)" + } + return values; +} +function set(values) { + return values instanceof (0, _internmap.InternSet) ? values : new (0, _internmap.InternSet)(values); +} + +},{"internmap":"cOuqB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fO88f":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>subset); +var _supersetJs = require("./superset.js"); +var _supersetJsDefault = parcelHelpers.interopDefault(_supersetJs); +function subset(values, other) { + return (0, _supersetJsDefault.default)(other, values); +} + +},{"./superset.js":"6zbJQ","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6zbJQ":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>superset); +function superset(values, other) { + const iterator = values[Symbol.iterator](), set = new Set(); + for (const o of other){ + const io = intern(o); + if (set.has(io)) continue; + let value, done; + while({ value, done } = iterator.next()){ + if (done) return false; + const ivalue = intern(value); + set.add(ivalue); + if (Object.is(io, ivalue)) break; } - }), (0, _base.base).react.createElement("div", { - title: "#fdae6b", - style: { - width: p20, - background: "rgb(253, 174, 107)" + } + return true; +} +function intern(value) { + return value !== null && typeof value === "object" ? value.valueOf() : value; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"loYUW":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>union); +var _internmap = require("internmap"); +function union(...others) { + const set = new (0, _internmap.InternSet)(); + for (const other of others)for (const o of other)set.add(o); + return set; +} + +},{"internmap":"cOuqB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ijd73":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "initRange", ()=>initRange); +parcelHelpers.export(exports, "initInterpolator", ()=>initInterpolator); +function initRange(domain, range) { + switch(arguments.length){ + case 0: + break; + case 1: + this.range(domain); + break; + default: + this.range(range).domain(domain); + break; + } + return this; +} +function initInterpolator(domain, interpolator) { + switch(arguments.length){ + case 0: + break; + case 1: + if (typeof domain === "function") this.interpolator(domain); + else this.range(domain); + break; + default: + this.domain(domain); + if (typeof interpolator === "function") this.interpolator(interpolator); + else this.range(interpolator); + break; + } + return this; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cg12q":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "implicit", ()=>implicit); +parcelHelpers.export(exports, "default", ()=>ordinal); +var _d3Array = require("d3-array"); +var _initJs = require("./init.js"); +const implicit = Symbol("implicit"); +function ordinal() { + var index = new (0, _d3Array.InternMap)(), domain = [], range = [], unknown = implicit; + function scale(d) { + let i = index.get(d); + if (i === undefined) { + if (unknown !== implicit) return unknown; + index.set(d, i = domain.push(d) - 1); } - }), (0, _base.base).react.createElement("div", { - title: "#fdd0a2", - style: { - width: p20, - background: "rgb(253, 208, 162)" + return range[i % range.length]; + } + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = [], index = new (0, _d3Array.InternMap)(); + for (const value of _){ + if (index.has(value)) continue; + index.set(value, domain.push(value) - 1); } - }), (0, _base.base).react.createElement("div", { - title: "#31a354", - style: { - width: p20, - background: "rgb(49, 163, 84)" + return scale; + }; + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), scale) : range.slice(); + }; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + scale.copy = function() { + return ordinal(domain, range).unknown(unknown); + }; + (0, _initJs.initRange).apply(scale, arguments); + return scale; +} + +},{"d3-array":"5lCYW","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e07Nz":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>identity); +var _linearJs = require("./linear.js"); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +function identity(domain) { + var unknown; + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : x; + } + scale.invert = scale; + scale.domain = scale.range = function(_) { + return arguments.length ? (domain = Array.from(_, (0, _numberJsDefault.default)), scale) : domain.slice(); + }; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + scale.copy = function() { + return identity(domain).unknown(unknown); + }; + domain = arguments.length ? Array.from(domain, (0, _numberJsDefault.default)) : [ + 0, + 1 + ]; + return (0, _linearJs.linearish)(scale); +} + +},{"./linear.js":"ik2PQ","./number.js":"aUICk","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ik2PQ":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "linearish", ()=>linearish); +parcelHelpers.export(exports, "default", ()=>linear); +var _d3Array = require("d3-array"); +var _continuousJs = require("./continuous.js"); +var _continuousJsDefault = parcelHelpers.interopDefault(_continuousJs); +var _initJs = require("./init.js"); +var _tickFormatJs = require("./tickFormat.js"); +var _tickFormatJsDefault = parcelHelpers.interopDefault(_tickFormatJs); +function linearish(scale) { + var domain = scale.domain; + scale.ticks = function(count) { + var d = domain(); + return (0, _d3Array.ticks)(d[0], d[d.length - 1], count == null ? 10 : count); + }; + scale.tickFormat = function(count, specifier) { + var d = domain(); + return (0, _tickFormatJsDefault.default)(d[0], d[d.length - 1], count == null ? 10 : count, specifier); + }; + scale.nice = function(count) { + if (count == null) count = 10; + var d = domain(); + var i0 = 0; + var i1 = d.length - 1; + var start = d[i0]; + var stop = d[i1]; + var prestep; + var step; + var maxIter = 10; + if (stop < start) { + step = start, start = stop, stop = step; + step = i0, i0 = i1, i1 = step; } - }), (0, _base.base).react.createElement("div", { - title: "#74c476", - style: { - width: p20, - background: "rgb(116, 196, 118)" + while(maxIter-- > 0){ + step = (0, _d3Array.tickIncrement)(start, stop, count); + if (step === prestep) { + d[i0] = start; + d[i1] = stop; + return domain(d); + } else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; + } else break; + prestep = step; } - }), (0, _base.base).react.createElement("div", { - title: "#a1d99b", - style: { - width: p20, - background: "rgb(161, 217, 155)" - } - }), (0, _base.base).react.createElement("div", { - title: "#c7e9c0", - style: { - width: p20, - background: "rgb(199, 233, 192)" - } - }), (0, _base.base).react.createElement("div", { - title: "#756bb1", - style: { - width: p20, - background: "rgb(117, 107, 177)" - } - }), (0, _base.base).react.createElement("div", { - title: "#9e9ac8", - style: { - width: p20, - background: "rgb(158, 154, 200)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bcbddc", - style: { - width: p20, - background: "rgb(188, 189, 220)" - } - }), (0, _base.base).react.createElement("div", { - title: "#dadaeb", - style: { - width: p20, - background: "rgb(218, 218, 235)" - } - }), (0, _base.base).react.createElement("div", { - title: "#636363", - style: { - width: p20, - background: "rgb(99, 99, 99)" - } - }), (0, _base.base).react.createElement("div", { - title: "#969696", - style: { - width: p20, - background: "rgb(150, 150, 150)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bdbdbd", - style: { - width: p20, - background: "rgb(189, 189, 189)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d9d9d9", - style: { - width: p20, - background: "rgb(217, 217, 217)" - } - })); - (0, _scheme.schemesJSX)["dark2"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#1b9e77", - style: { - width: p8, - background: "rgb(27, 158, 119)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d95f02", - style: { - width: p8, - background: "rgb(217, 95, 2)" - } - }), (0, _base.base).react.createElement("div", { - title: "#7570b3", - style: { - width: p8, - background: "rgb(117, 112, 179)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e7298a", - style: { - width: p8, - background: "rgb(231, 41, 138)" - } - }), (0, _base.base).react.createElement("div", { - title: "#66a61e", - style: { - width: p8, - background: "rgb(102, 166, 30)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e6ab02", - style: { - width: p8, - background: "rgb(230, 171, 2)" - } - }), (0, _base.base).react.createElement("div", { - title: "#a6761d", - style: { - width: p8, - background: "rgb(166, 118, 29)" - } - }), (0, _base.base).react.createElement("div", { - title: "#666666", - style: { - width: p8, - background: "rgb(102, 102, 102)" - } - })); - (0, _scheme.schemesJSX)["paired"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#a6cee3", - style: { - width: p12, - background: "rgb(166, 206, 227)" - } - }), (0, _base.base).react.createElement("div", { - title: "#1f78b4", - style: { - width: p12, - background: "rgb(31, 120, 180)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b2df8a", - style: { - width: p12, - background: "rgb(178, 223, 138)" - } - }), (0, _base.base).react.createElement("div", { - title: "#33a02c", - style: { - width: p12, - background: "rgb(51, 160, 44)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fb9a99", - style: { - width: p12, - background: "rgb(251, 154, 153)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e31a1c", - style: { - width: p12, - background: "rgb(227, 26, 28)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fdbf6f", - style: { - width: p12, - background: "rgb(253, 191, 111)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ff7f00", - style: { - width: p12, - background: "rgb(255, 127, 0)" - } - }), (0, _base.base).react.createElement("div", { - title: "#cab2d6", - style: { - width: p12, - background: "rgb(202, 178, 214)" - } - }), (0, _base.base).react.createElement("div", { - title: "#6a3d9a", - style: { - width: p12, - background: "rgb(106, 61, 154)" + return scale; + }; + return scale; +} +function linear() { + var scale = (0, _continuousJsDefault.default)(); + scale.copy = function() { + return (0, _continuousJs.copy)(scale, linear()); + }; + (0, _initJs.initRange).apply(scale, arguments); + return linearish(scale); +} + +},{"d3-array":"5lCYW","./continuous.js":"2SYx4","./init.js":"ijd73","./tickFormat.js":"fHwUM","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2SYx4":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "identity", ()=>identity); +parcelHelpers.export(exports, "copy", ()=>copy); +parcelHelpers.export(exports, "transformer", ()=>transformer); +parcelHelpers.export(exports, "default", ()=>continuous); +var _d3Array = require("d3-array"); +var _d3Interpolate = require("d3-interpolate"); +var _constantJs = require("./constant.js"); +var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +var unit = [ + 0, + 1 +]; +function identity(x) { + return x; +} +function normalize(a, b) { + return (b -= a = +a) ? function(x) { + return (x - a) / b; + } : (0, _constantJsDefault.default)(isNaN(b) ? NaN : 0.5); +} +function clamper(a, b) { + var t; + if (a > b) t = a, a = b, b = t; + return function(x) { + return Math.max(a, Math.min(b, x)); + }; +} +// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. +// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b]. +function bimap(domain, range, interpolate) { + var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; + if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); + else d0 = normalize(d0, d1), r0 = interpolate(r0, r1); + return function(x) { + return r0(d0(x)); + }; +} +function polymap(domain, range, interpolate) { + var j = Math.min(domain.length, range.length) - 1, d = new Array(j), r = new Array(j), i = -1; + // Reverse descending domains. + if (domain[j] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + while(++i < j){ + d[i] = normalize(domain[i], domain[i + 1]); + r[i] = interpolate(range[i], range[i + 1]); + } + return function(x) { + var i = (0, _d3Array.bisect)(domain, x, 1, j) - 1; + return r[i](d[i](x)); + }; +} +function copy(source, target) { + return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown()); +} +function transformer() { + var domain = unit, range = unit, interpolate = (0, _d3Interpolate.interpolate), transform, untransform, unknown, clamp = identity, piecewise, output, input; + function rescale() { + var n = Math.min(domain.length, range.length); + if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]); + piecewise = n > 2 ? polymap : bimap; + output = input = null; + return scale; + } + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x))); + } + scale.invert = function(y) { + return clamp(untransform((input || (input = piecewise(range, domain.map(transform), (0, _d3Interpolate.interpolateNumber))))(y))); + }; + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_, (0, _numberJsDefault.default)), rescale()) : domain.slice(); + }; + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + scale.rangeRound = function(_) { + return range = Array.from(_), interpolate = (0, _d3Interpolate.interpolateRound), rescale(); + }; + scale.clamp = function(_) { + return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity; + }; + scale.interpolate = function(_) { + return arguments.length ? (interpolate = _, rescale()) : interpolate; + }; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + return function(t, u) { + transform = t, untransform = u; + return rescale(); + }; +} +function continuous() { + return transformer()(identity, identity); +} + +},{"d3-array":"5lCYW","d3-interpolate":"hWyQt","./constant.js":"3WTV4","./number.js":"aUICk","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hWyQt":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "interpolate", ()=>(0, _valueJsDefault.default)); +parcelHelpers.export(exports, "interpolateArray", ()=>(0, _arrayJsDefault.default)); +parcelHelpers.export(exports, "interpolateBasis", ()=>(0, _basisJsDefault.default)); +parcelHelpers.export(exports, "interpolateBasisClosed", ()=>(0, _basisClosedJsDefault.default)); +parcelHelpers.export(exports, "interpolateDate", ()=>(0, _dateJsDefault.default)); +parcelHelpers.export(exports, "interpolateDiscrete", ()=>(0, _discreteJsDefault.default)); +parcelHelpers.export(exports, "interpolateHue", ()=>(0, _hueJsDefault.default)); +parcelHelpers.export(exports, "interpolateNumber", ()=>(0, _numberJsDefault.default)); +parcelHelpers.export(exports, "interpolateNumberArray", ()=>(0, _numberArrayJsDefault.default)); +parcelHelpers.export(exports, "interpolateObject", ()=>(0, _objectJsDefault.default)); +parcelHelpers.export(exports, "interpolateRound", ()=>(0, _roundJsDefault.default)); +parcelHelpers.export(exports, "interpolateString", ()=>(0, _stringJsDefault.default)); +parcelHelpers.export(exports, "interpolateTransformCss", ()=>(0, _indexJs.interpolateTransformCss)); +parcelHelpers.export(exports, "interpolateTransformSvg", ()=>(0, _indexJs.interpolateTransformSvg)); +parcelHelpers.export(exports, "interpolateZoom", ()=>(0, _zoomJsDefault.default)); +parcelHelpers.export(exports, "interpolateRgb", ()=>(0, _rgbJsDefault.default)); +parcelHelpers.export(exports, "interpolateRgbBasis", ()=>(0, _rgbJs.rgbBasis)); +parcelHelpers.export(exports, "interpolateRgbBasisClosed", ()=>(0, _rgbJs.rgbBasisClosed)); +parcelHelpers.export(exports, "interpolateHsl", ()=>(0, _hslJsDefault.default)); +parcelHelpers.export(exports, "interpolateHslLong", ()=>(0, _hslJs.hslLong)); +parcelHelpers.export(exports, "interpolateLab", ()=>(0, _labJsDefault.default)); +parcelHelpers.export(exports, "interpolateHcl", ()=>(0, _hclJsDefault.default)); +parcelHelpers.export(exports, "interpolateHclLong", ()=>(0, _hclJs.hclLong)); +parcelHelpers.export(exports, "interpolateCubehelix", ()=>(0, _cubehelixJsDefault.default)); +parcelHelpers.export(exports, "interpolateCubehelixLong", ()=>(0, _cubehelixJs.cubehelixLong)); +parcelHelpers.export(exports, "piecewise", ()=>(0, _piecewiseJsDefault.default)); +parcelHelpers.export(exports, "quantize", ()=>(0, _quantizeJsDefault.default)); +var _valueJs = require("./value.js"); +var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); +var _arrayJs = require("./array.js"); +var _arrayJsDefault = parcelHelpers.interopDefault(_arrayJs); +var _basisJs = require("./basis.js"); +var _basisJsDefault = parcelHelpers.interopDefault(_basisJs); +var _basisClosedJs = require("./basisClosed.js"); +var _basisClosedJsDefault = parcelHelpers.interopDefault(_basisClosedJs); +var _dateJs = require("./date.js"); +var _dateJsDefault = parcelHelpers.interopDefault(_dateJs); +var _discreteJs = require("./discrete.js"); +var _discreteJsDefault = parcelHelpers.interopDefault(_discreteJs); +var _hueJs = require("./hue.js"); +var _hueJsDefault = parcelHelpers.interopDefault(_hueJs); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +var _numberArrayJs = require("./numberArray.js"); +var _numberArrayJsDefault = parcelHelpers.interopDefault(_numberArrayJs); +var _objectJs = require("./object.js"); +var _objectJsDefault = parcelHelpers.interopDefault(_objectJs); +var _roundJs = require("./round.js"); +var _roundJsDefault = parcelHelpers.interopDefault(_roundJs); +var _stringJs = require("./string.js"); +var _stringJsDefault = parcelHelpers.interopDefault(_stringJs); +var _indexJs = require("./transform/index.js"); +var _zoomJs = require("./zoom.js"); +var _zoomJsDefault = parcelHelpers.interopDefault(_zoomJs); +var _rgbJs = require("./rgb.js"); +var _rgbJsDefault = parcelHelpers.interopDefault(_rgbJs); +var _hslJs = require("./hsl.js"); +var _hslJsDefault = parcelHelpers.interopDefault(_hslJs); +var _labJs = require("./lab.js"); +var _labJsDefault = parcelHelpers.interopDefault(_labJs); +var _hclJs = require("./hcl.js"); +var _hclJsDefault = parcelHelpers.interopDefault(_hclJs); +var _cubehelixJs = require("./cubehelix.js"); +var _cubehelixJsDefault = parcelHelpers.interopDefault(_cubehelixJs); +var _piecewiseJs = require("./piecewise.js"); +var _piecewiseJsDefault = parcelHelpers.interopDefault(_piecewiseJs); +var _quantizeJs = require("./quantize.js"); +var _quantizeJsDefault = parcelHelpers.interopDefault(_quantizeJs); + +},{"./value.js":"gfJPE","./array.js":"aHWTr","./basis.js":"88PXq","./basisClosed.js":"k0GEO","./date.js":"7hJMh","./discrete.js":"856yx","./hue.js":"8zvjW","./number.js":"jdEvy","./numberArray.js":"e2unU","./object.js":"bDQsG","./round.js":"8t96L","./string.js":"i8PKu","./transform/index.js":"kov9u","./zoom.js":"fAkJy","./rgb.js":"eqhhf","./hsl.js":"kviB4","./lab.js":"drgXo","./hcl.js":"e1eQm","./cubehelix.js":"fTm9T","./piecewise.js":"3wh8c","./quantize.js":"6KHTv","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gfJPE":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + var t = typeof b, c; + return b == null || t === "boolean" ? (0, _constantJsDefault.default)(b) : (t === "number" ? (0, _numberJsDefault.default) : t === "string" ? (c = (0, _d3Color.color)(b)) ? (b = c, _rgbJsDefault.default) : (0, _stringJsDefault.default) : b instanceof (0, _d3Color.color) ? (0, _rgbJsDefault.default) : b instanceof Date ? (0, _dateJsDefault.default) : (0, _numberArrayJs.isNumberArray)(b) ? (0, _numberArrayJsDefault.default) : Array.isArray(b) ? (0, _arrayJs.genericArray) : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? (0, _objectJsDefault.default) : (0, _numberJsDefault.default))(a, b); + }); +var _d3Color = require("d3-color"); +var _rgbJs = require("./rgb.js"); +var _rgbJsDefault = parcelHelpers.interopDefault(_rgbJs); +var _arrayJs = require("./array.js"); +var _dateJs = require("./date.js"); +var _dateJsDefault = parcelHelpers.interopDefault(_dateJs); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +var _objectJs = require("./object.js"); +var _objectJsDefault = parcelHelpers.interopDefault(_objectJs); +var _stringJs = require("./string.js"); +var _stringJsDefault = parcelHelpers.interopDefault(_stringJs); +var _constantJs = require("./constant.js"); +var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); +var _numberArrayJs = require("./numberArray.js"); +var _numberArrayJsDefault = parcelHelpers.interopDefault(_numberArrayJs); + +},{"d3-color":"37LNF","./rgb.js":"eqhhf","./array.js":"aHWTr","./date.js":"7hJMh","./number.js":"jdEvy","./object.js":"bDQsG","./string.js":"i8PKu","./constant.js":"iuQcB","./numberArray.js":"e2unU","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eqhhf":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "rgbBasis", ()=>rgbBasis); +parcelHelpers.export(exports, "rgbBasisClosed", ()=>rgbBasisClosed); +var _d3Color = require("d3-color"); +var _basisJs = require("./basis.js"); +var _basisJsDefault = parcelHelpers.interopDefault(_basisJs); +var _basisClosedJs = require("./basisClosed.js"); +var _basisClosedJsDefault = parcelHelpers.interopDefault(_basisClosedJs); +var _colorJs = require("./color.js"); +var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); +exports.default = function rgbGamma(y) { + var color = (0, _colorJs.gamma)(y); + function rgb(start, end) { + var r = color((start = (0, _d3Color.rgb)(start)).r, (end = (0, _d3Color.rgb)(end)).r), g = color(start.g, end.g), b = color(start.b, end.b), opacity = (0, _colorJsDefault.default)(start.opacity, end.opacity); + return function(t) { + start.r = r(t); + start.g = g(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; + } + rgb.gamma = rgbGamma; + return rgb; +}(1); +function rgbSpline(spline) { + return function(colors) { + var n = colors.length, r = new Array(n), g = new Array(n), b = new Array(n), i, color; + for(i = 0; i < n; ++i){ + color = (0, _d3Color.rgb)(colors[i]); + r[i] = color.r || 0; + g[i] = color.g || 0; + b[i] = color.b || 0; } - }), (0, _base.base).react.createElement("div", { - title: "#ffff99", - style: { - width: p12, - background: "rgb(255, 255, 153)" + r = spline(r); + g = spline(g); + b = spline(b); + color.opacity = 1; + return function(t) { + color.r = r(t); + color.g = g(t); + color.b = b(t); + return color + ""; + }; + }; +} +var rgbBasis = rgbSpline((0, _basisJsDefault.default)); +var rgbBasisClosed = rgbSpline((0, _basisClosedJsDefault.default)); + +},{"d3-color":"37LNF","./basis.js":"88PXq","./basisClosed.js":"k0GEO","./color.js":"fWpiN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"88PXq":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "basis", ()=>basis); +parcelHelpers.export(exports, "default", ()=>function(values) { + var n = values.length - 1; + return function(t) { + var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), v1 = values[i], v2 = values[i + 1], v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1; + return basis((t - i / n) * n, v0, v1, v2, v3); + }; + }); +function basis(t1, v0, v1, v2, v3) { + var t2 = t1 * t1, t3 = t2 * t1; + return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"k0GEO":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(values) { + var n = values.length; + return function(t) { + var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), v0 = values[(i + n - 1) % n], v1 = values[i % n], v2 = values[(i + 1) % n], v3 = values[(i + 2) % n]; + return (0, _basisJs.basis)((t - i / n) * n, v0, v1, v2, v3); + }; + }); +var _basisJs = require("./basis.js"); + +},{"./basis.js":"88PXq","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fWpiN":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "hue", ()=>hue); +parcelHelpers.export(exports, "gamma", ()=>gamma); +parcelHelpers.export(exports, "default", ()=>nogamma); +var _constantJs = require("./constant.js"); +var _constantJsDefault = parcelHelpers.interopDefault(_constantJs); +function linear(a, d) { + return function(t) { + return a + t * d; + }; +} +function exponential(a, b, y) { + return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { + return Math.pow(a + t * b, y); + }; +} +function hue(a, b) { + var d = b - a; + return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : (0, _constantJsDefault.default)(isNaN(a) ? b : a); +} +function gamma(y) { + return (y = +y) === 1 ? nogamma : function(a, b) { + return b - a ? exponential(a, b, y) : (0, _constantJsDefault.default)(isNaN(a) ? b : a); + }; +} +function nogamma(a, b) { + var d = b - a; + return d ? linear(a, d) : (0, _constantJsDefault.default)(isNaN(a) ? b : a); +} + +},{"./constant.js":"iuQcB","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iuQcB":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +exports.default = (x)=>()=>x; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aHWTr":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + return ((0, _numberArrayJs.isNumberArray)(b) ? (0, _numberArrayJsDefault.default) : genericArray)(a, b); + }); +parcelHelpers.export(exports, "genericArray", ()=>genericArray); +var _valueJs = require("./value.js"); +var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); +var _numberArrayJs = require("./numberArray.js"); +var _numberArrayJsDefault = parcelHelpers.interopDefault(_numberArrayJs); +function genericArray(a, b) { + var nb = b ? b.length : 0, na = a ? Math.min(nb, a.length) : 0, x = new Array(na), c = new Array(nb), i; + for(i = 0; i < na; ++i)x[i] = (0, _valueJsDefault.default)(a[i], b[i]); + for(; i < nb; ++i)c[i] = b[i]; + return function(t) { + for(i = 0; i < na; ++i)c[i] = x[i](t); + return c; + }; +} + +},{"./value.js":"gfJPE","./numberArray.js":"e2unU","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e2unU":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + if (!b) b = []; + var n = a ? Math.min(b.length, a.length) : 0, c = b.slice(), i; + return function(t) { + for(i = 0; i < n; ++i)c[i] = a[i] * (1 - t) + b[i] * t; + return c; + }; + }); +parcelHelpers.export(exports, "isNumberArray", ()=>isNumberArray); +function isNumberArray(x) { + return ArrayBuffer.isView(x) && !(x instanceof DataView); +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7hJMh":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + var d = new Date; + return a = +a, b = +b, function(t) { + return d.setTime(a * (1 - t) + b * t), d; + }; + }); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jdEvy":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + return a = +a, b = +b, function(t) { + return a * (1 - t) + b * t; + }; + }); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bDQsG":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + var i = {}, c = {}, k; + if (a === null || typeof a !== "object") a = {}; + if (b === null || typeof b !== "object") b = {}; + for(k in b)if (k in a) i[k] = (0, _valueJsDefault.default)(a[k], b[k]); + else c[k] = b[k]; + return function(t) { + for(k in i)c[k] = i[k](t); + return c; + }; + }); +var _valueJs = require("./value.js"); +var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); + +},{"./value.js":"gfJPE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"i8PKu":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; // number interpolators + // Coerce inputs to strings. + a = a + "", b = b + ""; + // Interpolate pairs of numbers in a & b. + while((am = reA.exec(a)) && (bm = reB.exec(b))){ + if ((bs = bm.index) > bi) { + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { + if (s[i]) s[i] += bm; // coalesce with previous string + else s[++i] = bm; + } else { + s[++i] = null; + q.push({ + i: i, + x: (0, _numberJsDefault.default)(am, bm) + }); + } + bi = reB.lastIndex; } - }), (0, _base.base).react.createElement("div", { - title: "#b15928", - style: { - width: p12, - background: "rgb(177, 89, 40)" + // Add remains of b. + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; } - })); - (0, _scheme.schemesJSX)["pastel1"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#fbb4ae", - style: { - width: p9, - background: "rgb(251, 180, 174)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b3cde3", - style: { - width: p9, - background: "rgb(179, 205, 227)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ccebc5", - style: { - width: p9, - background: "rgb(204, 235, 197)" - } - }), (0, _base.base).react.createElement("div", { - title: "#decbe4", - style: { - width: p9, - background: "rgb(222, 203, 228)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fed9a6", - style: { - width: p9, - background: "rgb(254, 217, 166)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffffcc", - style: { - width: p9, - background: "rgb(255, 255, 204)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e5d8bd", - style: { - width: p9, - background: "rgb(229, 216, 189)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fddaec", - style: { - width: p9, - background: "rgb(253, 218, 236)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f2f2f2", - style: { - width: p9, - background: "rgb(242, 242, 242)" - } - })); - (0, _scheme.schemesJSX)["pastel2"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#b3e2cd", - style: { - width: p8, - background: "rgb(179, 226, 205)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fdcdac", - style: { - width: p8, - background: "rgb(253, 205, 172)" - } - }), (0, _base.base).react.createElement("div", { - title: "#cbd5e8", - style: { - width: p8, - background: "rgb(203, 213, 232)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f4cae4", - style: { - width: p8, - background: "rgb(244, 202, 228)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e6f5c9", - style: { - width: p8, - background: "rgb(230, 245, 201)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fff2ae", - style: { - width: p8, - background: "rgb(255, 242, 174)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f1e2cc", - style: { - width: p8, - background: "rgb(241, 226, 204)" - } - }), (0, _base.base).react.createElement("div", { - title: "#cccccc", - style: { - width: p8, - background: "rgb(204, 204, 204)" - } - })); - (0, _scheme.schemesJSX)["set1"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#e41a1c", - style: { - width: p9, - background: "rgb(228, 26, 28)" - } - }), (0, _base.base).react.createElement("div", { - title: "#377eb8", - style: { - width: p9, - background: "rgb(55, 126, 184)" - } - }), (0, _base.base).react.createElement("div", { - title: "#4daf4a", - style: { - width: p9, - background: "rgb(77, 175, 74)" - } - }), (0, _base.base).react.createElement("div", { - title: "#984ea3", - style: { - width: p9, - background: "rgb(152, 78, 163)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ff7f00", - style: { - width: p9, - background: "rgb(255, 127, 0)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffff33", - style: { - width: p9, - background: "rgb(255, 255, 51)" - } - }), (0, _base.base).react.createElement("div", { - title: "#a65628", - style: { - width: p9, - background: "rgb(166, 86, 40)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f781bf", - style: { - width: p9, - background: "rgb(247, 129, 191)" - } - }), (0, _base.base).react.createElement("div", { - title: "#999999", - style: { - width: p9, - background: "rgb(153, 153, 153)" - } - })); - (0, _scheme.schemesJSX)["set2"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#66c2a5", - style: { - width: p8, - background: "rgb(102, 194, 165)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fc8d62", - style: { - width: p8, - background: "rgb(252, 141, 98)" - } - }), (0, _base.base).react.createElement("div", { - title: "#8da0cb", - style: { - width: p8, - background: "rgb(141, 160, 203)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e78ac3", - style: { - width: p8, - background: "rgb(231, 138, 195)" - } - }), (0, _base.base).react.createElement("div", { - title: "#a6d854", - style: { - width: p8, - background: "rgb(166, 216, 84)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffd92f", - style: { - width: p8, - background: "rgb(255, 217, 47)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e5c494", - style: { - width: p8, - background: "rgb(229, 196, 148)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b3b3b3", - style: { - width: p8, - background: "rgb(179, 179, 179)" - } - })); - (0, _scheme.schemesJSX)["set3"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#8dd3c7", - style: { - width: p12, - background: "rgb(141, 211, 199)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffffb3", - style: { - width: p12, - background: "rgb(255, 255, 179)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bebada", - style: { - width: p12, - background: "rgb(190, 186, 218)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fb8072", - style: { - width: p12, - background: "rgb(251, 128, 114)" - } - }), (0, _base.base).react.createElement("div", { - title: "#80b1d3", - style: { - width: p12, - background: "rgb(128, 177, 211)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fdb462", - style: { - width: p12, - background: "rgb(253, 180, 98)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b3de69", - style: { - width: p12, - background: "rgb(179, 222, 105)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fccde5", - style: { - width: p12, - background: "rgb(252, 205, 229)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d9d9d9", - style: { - width: p12, - background: "rgb(217, 217, 217)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bc80bd", - style: { - width: p12, - background: "rgb(188, 128, 189)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ccebc5", - style: { - width: p12, - background: "rgb(204, 235, 197)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffed6f", - style: { - width: p12, - background: "rgb(255, 237, 111)" - } - })); - (0, _scheme.schemesJSX)["tableau10"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#4c78a8", - style: { - width: p10, - background: "rgb(76, 120, 168)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f58518", - style: { - width: p10, - background: "rgb(245, 133, 24)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e45756", - style: { - width: p10, - background: "rgb(228, 87, 86)" - } - }), (0, _base.base).react.createElement("div", { - title: "#72b7b2", - style: { - width: p10, - background: "rgb(114, 183, 178)" - } - }), (0, _base.base).react.createElement("div", { - title: "#54a24b", - style: { - width: p10, - background: "rgb(84, 162, 75)" - } - }), (0, _base.base).react.createElement("div", { - title: "#eeca3b", - style: { - width: p10, - background: "rgb(238, 202, 59)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b279a2", - style: { - width: p10, - background: "rgb(178, 121, 162)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ff9da6", - style: { - width: p10, - background: "rgb(255, 157, 166)" - } - }), (0, _base.base).react.createElement("div", { - title: "#9d755d", - style: { - width: p10, - background: "rgb(157, 117, 93)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bab0ac", - style: { - width: p10, - background: "rgb(186, 176, 172)" - } - })); - (0, _scheme.schemesJSX)["tableau20"] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, (0, _base.base).react.createElement("div", { - title: "#4c78a8", - style: { - width: p20, - background: "rgb(76, 120, 168)" - } - }), (0, _base.base).react.createElement("div", { - title: "#9ecae9", - style: { - width: p20, - background: "rgb(158, 202, 233)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f58518", - style: { - width: p20, - background: "rgb(245, 133, 24)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ffbf79", - style: { - width: p20, - background: "rgb(255, 191, 121)" - } - }), (0, _base.base).react.createElement("div", { - title: "#54a24b", - style: { - width: p20, - background: "rgb(84, 162, 75)" - } - }), (0, _base.base).react.createElement("div", { - title: "#88d27a", - style: { - width: p20, - background: "rgb(136, 210, 122)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b79a20", - style: { - width: p20, - background: "rgb(183, 154, 32)" - } - }), (0, _base.base).react.createElement("div", { - title: "#f2cf5b", - style: { - width: p20, - background: "rgb(242, 207, 91)" - } - }), (0, _base.base).react.createElement("div", { - title: "#439894", - style: { - width: p20, - background: "rgb(67, 152, 148)" - } - }), (0, _base.base).react.createElement("div", { - title: "#83bcb6", - style: { - width: p20, - background: "rgb(131, 188, 182)" - } - }), (0, _base.base).react.createElement("div", { - title: "#e45756", - style: { - width: p20, - background: "rgb(228, 87, 86)" - } - }), (0, _base.base).react.createElement("div", { - title: "#ff9d98", - style: { - width: p20, - background: "rgb(255, 157, 152)" - } - }), (0, _base.base).react.createElement("div", { - title: "#79706e", - style: { - width: p20, - background: "rgb(121, 112, 110)" - } - }), (0, _base.base).react.createElement("div", { - title: "#bab0ac", - style: { - width: p20, - background: "rgb(186, 176, 172)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d67195", - style: { - width: p20, - background: "rgb(214, 113, 149)" - } - }), (0, _base.base).react.createElement("div", { - title: "#fcbfd2", - style: { - width: p20, - background: "rgb(252, 191, 210)" - } - }), (0, _base.base).react.createElement("div", { - title: "#b279a2", - style: { - width: p20, - background: "rgb(178, 121, 162)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d6a5c9", - style: { - width: p20, - background: "rgb(214, 165, 201)" - } - }), (0, _base.base).react.createElement("div", { - title: "#9e765f", - style: { - width: p20, - background: "rgb(158, 118, 95)" - } - }), (0, _base.base).react.createElement("div", { - title: "#d8b5a5", - style: { - width: p20, - background: "rgb(216, 181, 165)" - } - })); - loaded = true; + // Special optimization for only a single match. + // Otherwise, interpolate each of the numbers and rejoin the string. + return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function(t) { + for(var i = 0, o; i < b; ++i)s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); + }); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, reB = new RegExp(reA.source, "g"); +function zero(b) { + return function() { + return b; + }; } -function categorical(selected) { - if (!loaded) load(); - return [ - (0, _scheme.schemeOption)(selected, "accent"), - (0, _scheme.schemeOption)(selected, "category10"), - (0, _scheme.schemeOption)(selected, "category20"), - (0, _scheme.schemeOption)(selected, "category20b"), - (0, _scheme.schemeOption)(selected, "category20c"), - (0, _scheme.schemeOption)(selected, "dark2"), - (0, _scheme.schemeOption)(selected, "paired"), - (0, _scheme.schemeOption)(selected, "pastel1"), - (0, _scheme.schemeOption)(selected, "pastel2"), - (0, _scheme.schemeOption)(selected, "set1"), - (0, _scheme.schemeOption)(selected, "set2"), - (0, _scheme.schemeOption)(selected, "set3"), - (0, _scheme.schemeOption)(selected, "tableau10"), - (0, _scheme.schemeOption)(selected, "tableau20"), - ]; +function one(b) { + return function(t) { + return b(t) + ""; + }; } -},{"../base":"9M4eu","./scheme":"9kwPO","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9kwPO":[function(require,module,exports) { +},{"./number.js":"jdEvy","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"856yx":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "schemeOption", ()=>schemeOption); -parcelHelpers.export(exports, "schemeHeader", ()=>schemeHeader); -parcelHelpers.export(exports, "schemesJSX", ()=>schemesJSX); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -function schemeOption(selected, scheme) { - return { - key: scheme, - text: scheme, - selected: selected === scheme, - scheme: scheme, - children: schemesJSX[scheme] - }; -} -function schemeHeader(key, text) { - return { - key, - text, - itemType: (0, _base.base).fluentUI.DropdownMenuItemType.Header - }; -} -const schemesJSX = {}; +parcelHelpers.export(exports, "default", ()=>function(range) { + var n = range.length; + return function(t) { + return range[Math.max(0, Math.min(n - 1, Math.floor(t * n)))]; + }; + }); -},{"../base":"9M4eu","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7atYL":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8zvjW":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "cyclical", ()=>cyclical); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _scheme = require("./scheme"); -let loaded = false; -function load() { - (0, _scheme.schemesJSX)["rainbow"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-rainbow" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#6e40aa" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#bf3caf" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#fe4b83" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#ff7847" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#e2b72f" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#aff05b" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#52f667" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#1ddfa3" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#23abd8" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#4c6edb" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#6e40aa" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-rainbow)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["sinebow"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-sinebow" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#ff4040" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#e78d0b" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#a7d503" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#58fc2a" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#18f472" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#00bfbf" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#1872f4" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#582afc" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#a703d5" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#e70b8d" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ff4040" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-sinebow)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - loaded = true; +parcelHelpers.export(exports, "default", ()=>function(a, b) { + var i = (0, _colorJs.hue)(+a, +b); + return function(t) { + var x = i(t); + return x - 360 * Math.floor(x / 360); + }; + }); +var _colorJs = require("./color.js"); + +},{"./color.js":"fWpiN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"8t96L":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(a, b) { + return a = +a, b = +b, function(t) { + return Math.round(a * (1 - t) + b * t); + }; + }); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kov9u":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "interpolateTransformCss", ()=>interpolateTransformCss); +parcelHelpers.export(exports, "interpolateTransformSvg", ()=>interpolateTransformSvg); +var _numberJs = require("../number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +var _parseJs = require("./parse.js"); +function interpolateTransform(parse, pxComma, pxParen, degParen) { + function pop(s) { + return s.length ? s.pop() + " " : ""; + } + function translate(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push("translate(", null, pxComma, null, pxParen); + q.push({ + i: i - 4, + x: (0, _numberJsDefault.default)(xa, xb) + }, { + i: i - 2, + x: (0, _numberJsDefault.default)(ya, yb) + }); + } else if (xb || yb) s.push("translate(" + xb + pxComma + yb + pxParen); + } + function rotate(a, b, s, q) { + if (a !== b) { + if (a - b > 180) b += 360; + else if (b - a > 180) a += 360; // shortest path + q.push({ + i: s.push(pop(s) + "rotate(", null, degParen) - 2, + x: (0, _numberJsDefault.default)(a, b) + }); + } else if (b) s.push(pop(s) + "rotate(" + b + degParen); + } + function skewX(a, b, s, q) { + if (a !== b) q.push({ + i: s.push(pop(s) + "skewX(", null, degParen) - 2, + x: (0, _numberJsDefault.default)(a, b) + }); + else if (b) s.push(pop(s) + "skewX(" + b + degParen); + } + function scale(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push(pop(s) + "scale(", null, ",", null, ")"); + q.push({ + i: i - 4, + x: (0, _numberJsDefault.default)(xa, xb) + }, { + i: i - 2, + x: (0, _numberJsDefault.default)(ya, yb) + }); + } else if (xb !== 1 || yb !== 1) s.push(pop(s) + "scale(" + xb + "," + yb + ")"); + } + return function(a, b) { + var s = [], q = []; // number interpolators + a = parse(a), b = parse(b); + translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); + rotate(a.rotate, b.rotate, s, q); + skewX(a.skewX, b.skewX, s, q); + scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); + a = b = null; // gc + return function(t) { + var i = -1, n = q.length, o; + while(++i < n)s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + }; } -function cyclical(selected) { - if (!loaded) load(); +var interpolateTransformCss = interpolateTransform((0, _parseJs.parseCss), "px, ", "px)", "deg)"); +var interpolateTransformSvg = interpolateTransform((0, _parseJs.parseSvg), ", ", ")", ")"); + +},{"../number.js":"jdEvy","./parse.js":"1NPFm","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1NPFm":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +/* eslint-disable no-undef */ parcelHelpers.export(exports, "parseCss", ()=>parseCss); +parcelHelpers.export(exports, "parseSvg", ()=>parseSvg); +var _decomposeJs = require("./decompose.js"); +var _decomposeJsDefault = parcelHelpers.interopDefault(_decomposeJs); +var svgNode; +function parseCss(value) { + const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); + return m.isIdentity ? (0, _decomposeJs.identity) : (0, _decomposeJsDefault.default)(m.a, m.b, m.c, m.d, m.e, m.f); +} +function parseSvg(value) { + if (value == null) return 0, _decomposeJs.identity; + if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); + svgNode.setAttribute("transform", value); + if (!(value = svgNode.transform.baseVal.consolidate())) return 0, _decomposeJs.identity; + value = value.matrix; + return (0, _decomposeJsDefault.default)(value.a, value.b, value.c, value.d, value.e, value.f); +} + +},{"./decompose.js":"cQAQq","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cQAQq":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "identity", ()=>identity); +parcelHelpers.export(exports, "default", ()=>function(a, b, c, d, e, f) { + var scaleX, scaleY, skewX; + if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX; + if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX; + if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY; + if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX; + return { + translateX: e, + translateY: f, + rotate: Math.atan2(b, a) * degrees, + skewX: Math.atan(skewX) * degrees, + scaleX: scaleX, + scaleY: scaleY + }; + }); +var degrees = 180 / Math.PI; +var identity = { + translateX: 0, + translateY: 0, + rotate: 0, + skewX: 0, + scaleX: 1, + scaleY: 1 +}; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fAkJy":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +var epsilon2 = 1e-12; +function cosh(x) { + return ((x = Math.exp(x)) + 1 / x) / 2; +} +function sinh(x) { + return ((x = Math.exp(x)) - 1 / x) / 2; +} +function tanh(x) { + return ((x = Math.exp(2 * x)) - 1) / (x + 1); +} +exports.default = function zoomRho(rho, rho2, rho4) { + // p0 = [ux0, uy0, w0] + // p1 = [ux1, uy1, w1] + function zoom(p0, p1) { + var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; + // Special case for u0 ≅ u1. + if (d2 < epsilon2) { + S = Math.log(w1 / w0) / rho; + i = function(t) { + return [ + ux0 + t * dx, + uy0 + t * dy, + w0 * Math.exp(rho * t * S) + ]; + }; + } else { + var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); + S = (r1 - r0) / rho; + i = function(t) { + var s = t * S, coshr0 = cosh(r0), u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0)); + return [ + ux0 + u * dx, + uy0 + u * dy, + w0 * coshr0 / cosh(rho * s + r0) + ]; + }; + } + i.duration = S * 1000 * rho / Math.SQRT2; + return i; + } + zoom.rho = function(_) { + var _1 = Math.max(1e-3, +_), _2 = _1 * _1, _4 = _2 * _2; + return zoomRho(_1, _2, _4); + }; + return zoom; +}(Math.SQRT2, 2, 4); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kviB4":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "hslLong", ()=>hslLong); +var _d3Color = require("d3-color"); +var _colorJs = require("./color.js"); +var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); +function hsl(hue) { + return function(start, end) { + var h = hue((start = (0, _d3Color.hsl)(start)).h, (end = (0, _d3Color.hsl)(end)).h), s = (0, _colorJsDefault.default)(start.s, end.s), l = (0, _colorJsDefault.default)(start.l, end.l), opacity = (0, _colorJsDefault.default)(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.s = s(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + }; +} +exports.default = hsl((0, _colorJs.hue)); +var hslLong = hsl((0, _colorJsDefault.default)); + +},{"d3-color":"37LNF","./color.js":"fWpiN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"drgXo":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>lab); +var _d3Color = require("d3-color"); +var _colorJs = require("./color.js"); +var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); +function lab(start, end) { + var l = (0, _colorJsDefault.default)((start = (0, _d3Color.lab)(start)).l, (end = (0, _d3Color.lab)(end)).l), a = (0, _colorJsDefault.default)(start.a, end.a), b = (0, _colorJsDefault.default)(start.b, end.b), opacity = (0, _colorJsDefault.default)(start.opacity, end.opacity); + return function(t) { + start.l = l(t); + start.a = a(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; +} + +},{"d3-color":"37LNF","./color.js":"fWpiN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e1eQm":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "hclLong", ()=>hclLong); +var _d3Color = require("d3-color"); +var _colorJs = require("./color.js"); +var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); +function hcl(hue) { + return function(start, end) { + var h = hue((start = (0, _d3Color.hcl)(start)).h, (end = (0, _d3Color.hcl)(end)).h), c = (0, _colorJsDefault.default)(start.c, end.c), l = (0, _colorJsDefault.default)(start.l, end.l), opacity = (0, _colorJsDefault.default)(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.c = c(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + }; +} +exports.default = hcl((0, _colorJs.hue)); +var hclLong = hcl((0, _colorJsDefault.default)); + +},{"d3-color":"37LNF","./color.js":"fWpiN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fTm9T":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "cubehelixLong", ()=>cubehelixLong); +var _d3Color = require("d3-color"); +var _colorJs = require("./color.js"); +var _colorJsDefault = parcelHelpers.interopDefault(_colorJs); +function cubehelix(hue) { + return function cubehelixGamma(y) { + y = +y; + function cubehelix(start, end) { + var h = hue((start = (0, _d3Color.cubehelix)(start)).h, (end = (0, _d3Color.cubehelix)(end)).h), s = (0, _colorJsDefault.default)(start.s, end.s), l = (0, _colorJsDefault.default)(start.l, end.l), opacity = (0, _colorJsDefault.default)(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.s = s(t); + start.l = l(Math.pow(t, y)); + start.opacity = opacity(t); + return start + ""; + }; + } + cubehelix.gamma = cubehelixGamma; + return cubehelix; + }(1); +} +exports.default = cubehelix((0, _colorJs.hue)); +var cubehelixLong = cubehelix((0, _colorJsDefault.default)); + +},{"d3-color":"37LNF","./color.js":"fWpiN","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3wh8c":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>piecewise); +var _valueJs = require("./value.js"); +var _valueJsDefault = parcelHelpers.interopDefault(_valueJs); +function piecewise(interpolate, values) { + if (values === undefined) values = interpolate, interpolate = (0, _valueJsDefault.default); + var i = 0, n = values.length - 1, v = values[0], I = new Array(n < 0 ? 0 : n); + while(i < n)I[i] = interpolate(v, v = values[++i]); + return function(t) { + var i = Math.max(0, Math.min(n - 1, Math.floor(t *= n))); + return I[i](t - i); + }; +} + +},{"./value.js":"gfJPE","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6KHTv":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(interpolator, n) { + var samples = new Array(n); + for(var i = 0; i < n; ++i)samples[i] = interpolator(i / (n - 1)); + return samples; + }); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3WTV4":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>constants); +function constants(x) { + return function() { + return x; + }; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aUICk":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>number); +function number(x) { + return +x; +} + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"fHwUM":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>tickFormat); +var _d3Array = require("d3-array"); +var _d3Format = require("d3-format"); +function tickFormat(start, stop, count, specifier) { + var step = (0, _d3Array.tickStep)(start, stop, count), precision; + specifier = (0, _d3Format.formatSpecifier)(specifier == null ? ",f" : specifier); + switch(specifier.type){ + case "s": + var value = Math.max(Math.abs(start), Math.abs(stop)); + if (specifier.precision == null && !isNaN(precision = (0, _d3Format.precisionPrefix)(step, value))) specifier.precision = precision; + return (0, _d3Format.formatPrefix)(specifier, value); + case "": + case "e": + case "g": + case "p": + case "r": + if (specifier.precision == null && !isNaN(precision = (0, _d3Format.precisionRound)(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); + break; + case "f": + case "%": + if (specifier.precision == null && !isNaN(precision = (0, _d3Format.precisionFixed)(step))) specifier.precision = precision - (specifier.type === "%") * 2; + break; + } + return (0, _d3Format.format)(specifier); +} + +},{"d3-array":"5lCYW","d3-format":"4fjQY","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4fjQY":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "formatDefaultLocale", ()=>(0, _defaultLocaleJsDefault.default)); +parcelHelpers.export(exports, "format", ()=>(0, _defaultLocaleJs.format)); +parcelHelpers.export(exports, "formatPrefix", ()=>(0, _defaultLocaleJs.formatPrefix)); +parcelHelpers.export(exports, "formatLocale", ()=>(0, _localeJsDefault.default)); +parcelHelpers.export(exports, "formatSpecifier", ()=>(0, _formatSpecifierJsDefault.default)); +parcelHelpers.export(exports, "FormatSpecifier", ()=>(0, _formatSpecifierJs.FormatSpecifier)); +parcelHelpers.export(exports, "precisionFixed", ()=>(0, _precisionFixedJsDefault.default)); +parcelHelpers.export(exports, "precisionPrefix", ()=>(0, _precisionPrefixJsDefault.default)); +parcelHelpers.export(exports, "precisionRound", ()=>(0, _precisionRoundJsDefault.default)); +var _defaultLocaleJs = require("./defaultLocale.js"); +var _defaultLocaleJsDefault = parcelHelpers.interopDefault(_defaultLocaleJs); +var _localeJs = require("./locale.js"); +var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); +var _formatSpecifierJs = require("./formatSpecifier.js"); +var _formatSpecifierJsDefault = parcelHelpers.interopDefault(_formatSpecifierJs); +var _precisionFixedJs = require("./precisionFixed.js"); +var _precisionFixedJsDefault = parcelHelpers.interopDefault(_precisionFixedJs); +var _precisionPrefixJs = require("./precisionPrefix.js"); +var _precisionPrefixJsDefault = parcelHelpers.interopDefault(_precisionPrefixJs); +var _precisionRoundJs = require("./precisionRound.js"); +var _precisionRoundJsDefault = parcelHelpers.interopDefault(_precisionRoundJs); + +},{"./defaultLocale.js":"jzS6R","./locale.js":"9NtbG","./formatSpecifier.js":"iBXoR","./precisionFixed.js":"kTPBo","./precisionPrefix.js":"cmgfB","./precisionRound.js":"g5X8k","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jzS6R":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "format", ()=>format); +parcelHelpers.export(exports, "formatPrefix", ()=>formatPrefix); +parcelHelpers.export(exports, "default", ()=>defaultLocale); +var _localeJs = require("./locale.js"); +var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); +var locale; +var format; +var formatPrefix; +defaultLocale({ + thousands: ",", + grouping: [ + 3 + ], + currency: [ + "$", + "" + ] +}); +function defaultLocale(definition) { + locale = (0, _localeJsDefault.default)(definition); + format = locale.format; + formatPrefix = locale.formatPrefix; + return locale; +} + +},{"./locale.js":"9NtbG","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9NtbG":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(locale) { + var group = locale.grouping === undefined || locale.thousands === undefined ? (0, _identityJsDefault.default) : (0, _formatGroupJsDefault.default)(map.call(locale.grouping, Number), locale.thousands + ""), currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", decimal = locale.decimal === undefined ? "." : locale.decimal + "", numerals = locale.numerals === undefined ? (0, _identityJsDefault.default) : (0, _formatNumeralsJsDefault.default)(map.call(locale.numerals, String)), percent = locale.percent === undefined ? "%" : locale.percent + "", minus = locale.minus === undefined ? "\u2212" : locale.minus + "", nan = locale.nan === undefined ? "NaN" : locale.nan + ""; + function newFormat(specifier) { + specifier = (0, _formatSpecifierJsDefault.default)(specifier); + var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type; + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + else if (!(0, _formatTypesJsDefault.default)[type]) precision === undefined && (precision = 12), trim = true, type = "g"; + // If zero fill is specified, padding goes after sign and before digits. + if (zero || fill === "0" && align === "=") zero = true, fill = "0", align = "="; + // Compute the prefix and suffix. + // For SI-prefix, the suffix is lazily computed. + var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; + // What format function should we use? + // Is this an integer type? + // Can this type generate exponential notation? + var formatType = (0, _formatTypesJsDefault.default)[type], maybeSuffix = /[defgprs%]/.test(type); + // Set the default precision if not specified, + // or clamp the specified precision to the supported range. + // For significant precision, it must be in [1, 21]. + // For fixed precision, it must be in [0, 20]. + precision = precision === undefined ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); + function format(value) { + var valuePrefix = prefix, valueSuffix = suffix, i, n, c; + if (type === "c") { + valueSuffix = formatType(value) + valueSuffix; + value = ""; + } else { + value = +value; + // Determine the sign. -0 is not less than 0, but 1 / -0 is! + var valueNegative = value < 0 || 1 / value < 0; + // Perform the initial formatting. + value = isNaN(value) ? nan : formatType(Math.abs(value), precision); + // Trim insignificant zeros. + if (trim) value = (0, _formatTrimJsDefault.default)(value); + // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. + if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; + // Compute the prefix and suffix. + valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; + valueSuffix = (type === "s" ? prefixes[8 + (0, _formatPrefixAutoJs.prefixExponent) / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); + // Break the formatted value into the integer “value” part that can be + // grouped, and fractional or exponential “suffix” part that is not. + if (maybeSuffix) { + i = -1, n = value.length; + while(++i < n)if (c = value.charCodeAt(i), 48 > c || c > 57) { + valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; + value = value.slice(0, i); + break; + } + } + } + // If the fill character is not "0", grouping is applied before padding. + if (comma && !zero) value = group(value, Infinity); + // Compute the padding. + var length = valuePrefix.length + value.length + valueSuffix.length, padding = length < width ? new Array(width - length + 1).join(fill) : ""; + // If the fill character is "0", grouping is applied after padding. + if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; + // Reconstruct the final output based on the desired alignment. + switch(align){ + case "<": + value = valuePrefix + value + valueSuffix + padding; + break; + case "=": + value = valuePrefix + padding + value + valueSuffix; + break; + case "^": + value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); + break; + default: + value = padding + valuePrefix + value + valueSuffix; + break; + } + return numerals(value); + } + format.toString = function() { + return specifier + ""; + }; + return format; + } + function formatPrefix(specifier, value) { + var f = newFormat((specifier = (0, _formatSpecifierJsDefault.default)(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor((0, _exponentJsDefault.default)(value) / 3))) * 3, k = Math.pow(10, -e), prefix = prefixes[8 + e / 3]; + return function(value) { + return f(k * value) + prefix; + }; + } + return { + format: newFormat, + formatPrefix: formatPrefix + }; + }); +var _exponentJs = require("./exponent.js"); +var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); +var _formatGroupJs = require("./formatGroup.js"); +var _formatGroupJsDefault = parcelHelpers.interopDefault(_formatGroupJs); +var _formatNumeralsJs = require("./formatNumerals.js"); +var _formatNumeralsJsDefault = parcelHelpers.interopDefault(_formatNumeralsJs); +var _formatSpecifierJs = require("./formatSpecifier.js"); +var _formatSpecifierJsDefault = parcelHelpers.interopDefault(_formatSpecifierJs); +var _formatTrimJs = require("./formatTrim.js"); +var _formatTrimJsDefault = parcelHelpers.interopDefault(_formatTrimJs); +var _formatTypesJs = require("./formatTypes.js"); +var _formatTypesJsDefault = parcelHelpers.interopDefault(_formatTypesJs); +var _formatPrefixAutoJs = require("./formatPrefixAuto.js"); +var _identityJs = require("./identity.js"); +var _identityJsDefault = parcelHelpers.interopDefault(_identityJs); +var map = Array.prototype.map, prefixes = [ + "y", + "z", + "a", + "f", + "p", + "n", + "\xb5", + "m", + "", + "k", + "M", + "G", + "T", + "P", + "E", + "Z", + "Y" +]; + +},{"./exponent.js":"aOeaO","./formatGroup.js":"jZnQc","./formatNumerals.js":"3gAed","./formatSpecifier.js":"iBXoR","./formatTrim.js":"gCu3n","./formatTypes.js":"dfzgV","./formatPrefixAuto.js":"iUhuq","./identity.js":"brXEh","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aOeaO":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(x) { + return x = (0, _formatDecimalJs.formatDecimalParts)(Math.abs(x)), x ? x[1] : NaN; + }); +var _formatDecimalJs = require("./formatDecimal.js"); + +},{"./formatDecimal.js":"hs37D","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hs37D":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>function(x) { + return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10); + }); +// Computes the decimal coefficient and exponent of the specified number x with +// significant digits p, where x is positive and p is in [1, 21] or undefined. +// For example, formatDecimalParts(1.23) returns ["123", 0]. +parcelHelpers.export(exports, "formatDecimalParts", ()=>formatDecimalParts); +function formatDecimalParts(x, p) { + if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity + var i, coefficient = x.slice(0, i); + // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ + // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). return [ - (0, _scheme.schemeOption)(selected, "rainbow"), - (0, _scheme.schemeOption)(selected, "sinebow"), + coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, + +x.slice(i + 1) ]; } -},{"../base":"9M4eu","./scheme":"9kwPO","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"g5GrM":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"jZnQc":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "diverging", ()=>diverging); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _scheme = require("./scheme"); -let loaded = false; -function load() { - (0, _scheme.schemesJSX)["blueorange"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-blueorange" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(5, 48, 97)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(34, 101, 163)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(75, 148, 196)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(143, 194, 221)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(205, 227, 238)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(242, 240, 235)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(253, 221, 179)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(248, 182, 100)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(221, 132, 31)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(178, 90, 9)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(127, 59, 8)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-blueorange)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["brownbluegreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-brownbluegreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(84, 48, 5)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(139, 84, 15)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(188, 132, 53)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(222, 190, 123)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(242, 228, 192)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(238, 241, 234)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(195, 231, 226)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(127, 201, 191)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(57, 152, 143)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(10, 103, 95)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 60, 48)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-brownbluegreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["purplegreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-purplegreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(64, 0, 75)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(115, 47, 128)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(154, 109, 170)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(193, 164, 205)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(228, 210, 230)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(239, 240, 239)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(214, 238, 209)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(162, 215, 158)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(92, 173, 101)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(33, 120, 57)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 68, 27)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-purplegreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["pinkyellowgreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-pinkyellowgreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(142, 1, 82)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(192, 38, 126)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(221, 114, 173)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(240, 179, 214)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(250, 221, 237)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(245, 243, 239)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(225, 242, 202)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(182, 222, 135)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(128, 187, 71)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(79, 145, 37)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(39, 100, 25)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-pinkyellowgreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["purpleorange"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-purpleorange" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(45, 0, 75)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(85, 45, 132)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(129, 112, 172)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(176, 170, 208)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(215, 215, 233)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(243, 238, 234)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(253, 221, 179)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(248, 182, 100)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(221, 132, 31)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(178, 90, 9)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(127, 59, 8)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-purpleorange)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["redblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-redblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(103, 0, 31)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(172, 32, 47)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(213, 96, 80)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(241, 163, 133)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(251, 215, 196)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(242, 239, 238)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(205, 227, 238)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(143, 194, 221)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(75, 148, 196)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(34, 101, 163)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(5, 48, 97)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-redblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["redgrey"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-redgrey" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(103, 0, 31)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(172, 32, 47)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(213, 96, 80)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(241, 163, 133)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(252, 216, 197)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(250, 244, 241)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(223, 223, 223)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(184, 184, 184)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(134, 134, 134)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(78, 78, 78)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(26, 26, 26)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-redgrey)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["redyellowblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-redyellowblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(165, 0, 38)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(212, 50, 44)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(241, 110, 67)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(252, 172, 100)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(254, 221, 144)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(250, 248, 193)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(220, 241, 236)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(171, 214, 232)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(117, 171, 208)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(74, 116, 180)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(49, 54, 149)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-redyellowblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["redyellowgreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-redyellowgreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(165, 0, 38)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(212, 50, 44)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(241, 110, 67)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(252, 172, 99)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(254, 221, 141)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(249, 247, 174)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(215, 238, 142)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(164, 216, 110)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(100, 188, 97)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(34, 150, 79)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 104, 55)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-redyellowgreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["spectral"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-spectral" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(158, 1, 66)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(209, 60, 75)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(240, 112, 74)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(252, 172, 99)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(254, 221, 141)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(251, 248, 176)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(224, 243, 161)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(169, 221, 162)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(105, 189, 169)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(66, 136, 181)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(94, 79, 162)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-spectral)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - loaded = true; -} -function diverging(selected) { - if (!loaded) load(); - return [ - (0, _scheme.schemeOption)(selected, "blueorange"), - (0, _scheme.schemeOption)(selected, "brownbluegreen"), - (0, _scheme.schemeOption)(selected, "purplegreen"), - (0, _scheme.schemeOption)(selected, "pinkyellowgreen"), - (0, _scheme.schemeOption)(selected, "purpleorange"), - (0, _scheme.schemeOption)(selected, "redblue"), - (0, _scheme.schemeOption)(selected, "redgrey"), - (0, _scheme.schemeOption)(selected, "redyellowblue"), - (0, _scheme.schemeOption)(selected, "redyellowgreen"), - (0, _scheme.schemeOption)(selected, "spectral"), - ]; -} +parcelHelpers.export(exports, "default", ()=>function(grouping, thousands) { + return function(value, width) { + var i = value.length, t = [], j = 0, g = grouping[0], length = 0; + while(i > 0 && g > 0){ + if (length + g + 1 > width) g = Math.max(1, width - length); + t.push(value.substring(i -= g, i + g)); + if ((length += g + 1) > width) break; + g = grouping[j = (j + 1) % grouping.length]; + } + return t.reverse().join(thousands); + }; + }); -},{"../base":"9M4eu","./scheme":"9kwPO","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5Kxmu":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"3gAed":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "dual", ()=>dual); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -var _scheme = require("./scheme"); -let loaded = false; -function load() { - (0, _sanddanceReact.SandDance).colorSchemes.filter((cs)=>cs.colors.length === 2).map((binaryScheme, i)=>{ - (0, _scheme.schemesJSX)[binaryScheme.scheme] = (0, _base.base).react.createElement("div", { - className: "swatch" - }, binaryScheme.colors.map((color, j)=>(0, _base.base).react.createElement("div", { - key: j, - title: color, - style: { - width: "50%", - backgroundColor: color - } - }))); +parcelHelpers.export(exports, "default", ()=>function(numerals) { + return function(value) { + return value.replace(/[0-9]/g, function(i) { + return numerals[+i]; + }); + }; + }); + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iBXoR":[function(require,module,exports,__globalThis) { +// [[fill]align][sign][symbol][0][width][,][.precision][~][type] +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>formatSpecifier); +parcelHelpers.export(exports, "FormatSpecifier", ()=>FormatSpecifier); +var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; +function formatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + return new FormatSpecifier({ + fill: match[1], + align: match[2], + sign: match[3], + symbol: match[4], + zero: match[5], + width: match[6], + comma: match[7], + precision: match[8] && match[8].slice(1), + trim: match[9], + type: match[10] }); - loaded = true; } -function dual(selected) { - if (!loaded) load(); - return (0, _sanddanceReact.SandDance).colorSchemes.filter((cs)=>cs.colors.length === 2).map((binaryScheme, i)=>(0, _scheme.schemeOption)(selected, binaryScheme.scheme)); +formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof +function FormatSpecifier(specifier) { + this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; + this.align = specifier.align === undefined ? ">" : specifier.align + ""; + this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; + this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; + this.zero = !!specifier.zero; + this.width = specifier.width === undefined ? undefined : +specifier.width; + this.comma = !!specifier.comma; + this.precision = specifier.precision === undefined ? undefined : +specifier.precision; + this.trim = !!specifier.trim; + this.type = specifier.type === undefined ? "" : specifier.type + ""; } +FormatSpecifier.prototype.toString = function() { + return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type; +}; -},{"../base":"9M4eu","@msrvida/sanddance-react":"73dPQ","./scheme":"9kwPO","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gjSUq":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"gCu3n":[function(require,module,exports,__globalThis) { +// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "sequentialMultiHue", ()=>sequentialMultiHue); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _language = require("../language"); -var _scheme = require("./scheme"); -let loaded = false; -function load() { - (0, _scheme.schemesJSX)["viridis"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-viridis" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#440154" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#482475" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#414487" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#355f8d" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#2a788e" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#21918c" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#22a884" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#44bf70" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#7ad151" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#bddf26" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#fde725" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-viridis)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["inferno"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-inferno" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#000004" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#160b39" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#420a68" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#6a176e" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#932667" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#bc3754" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#dd513a" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#f37819" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#fca50a" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#f6d746" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#fcffa4" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-inferno)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["magma"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-magma" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#000004" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#140e36" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#3b0f70" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#641a80" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#8c2981" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#b73779" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#de4968" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#f7705c" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#fe9f6d" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#fecf92" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#fcfdbf" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-magma)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["plasma"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-plasma" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#0d0887" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#41049d" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#6a00a8" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#8f0da4" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#b12a90" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#cc4778" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#e16462" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#f2844b" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#fca636" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#fcce25" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#f0f921" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-plasma)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["cividis"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-cividis" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#002051" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#0a326a" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#2b446e" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#4d566d" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#696970" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#7f7c75" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#948f78" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#ada476" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#caba6a" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#ead156" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#fdea45" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-cividis)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["turbo"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-turbo" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#23171b" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#4a58dd" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#2f9df5" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#27d7c4" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#4df884" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#95fb51" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#dedd32" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#ffa423" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#f65f18" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#ba2208" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#900c00" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-turbo)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["bluegreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-bluegreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(247, 252, 253)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(232, 246, 249)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(213, 239, 237)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(183, 228, 218)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(143, 211, 193)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(104, 194, 163)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(73, 177, 127)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(47, 153, 89)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(21, 127, 60)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(3, 100, 41)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 68, 27)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-bluegreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["bluepurple"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-bluepurple" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(247, 252, 253)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(228, 238, 245)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(204, 221, 236)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(178, 202, 225)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(156, 179, 213)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(143, 149, 198)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(140, 116, 181)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(137, 82, 165)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(133, 45, 143)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(115, 15, 113)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(77, 0, 75)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-bluepurple)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["goldgreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-goldgreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#f4d166" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#d5ca60" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#b6c35c" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#98bb59" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#7cb257" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#60a656" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#4b9c53" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#3f8f4f" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#33834a" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#257740" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#146c36" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-goldgreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["goldorange"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-goldorange" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#f4d166" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#f8be5c" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#f8aa4c" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#f5983b" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#f3852a" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#ef701b" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#e2621f" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#d65322" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#c54923" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#b14223" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#9e3a26" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-goldorange)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["goldred"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-goldred" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#f4d166" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#f6be59" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#f9aa51" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#fc964e" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#f6834b" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#ee734a" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#e56249" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#db5247" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#cf4244" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#c43141" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#b71d3e" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-goldred)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["greenblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-greenblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(247, 252, 240)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(229, 245, 223)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(211, 238, 206)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(189, 229, 191)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(158, 217, 187)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(123, 203, 196)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(88, 183, 205)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(57, 156, 198)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(29, 126, 183)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(11, 96, 161)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(8, 64, 129)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-greenblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["orangered"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-orangered" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 247, 236)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(254, 235, 207)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(253, 220, 175)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(253, 202, 148)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(253, 176, 122)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(250, 142, 93)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(241, 108, 73)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(224, 69, 48)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(200, 29, 19)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(167, 4, 3)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(127, 0, 0)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-orangered)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["purplebluegreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-purplebluegreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 247, 251)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(239, 231, 242)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(219, 216, 234)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(190, 201, 226)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(152, 185, 217)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(105, 168, 207)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(64, 150, 192)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(25, 135, 159)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(3, 120, 119)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(1, 99, 83)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(1, 70, 54)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-purplebluegreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["purpleblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-purpleblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 247, 251)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(239, 234, 244)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(219, 218, 235)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(191, 201, 226)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(155, 185, 217)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(114, 168, 207)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(67, 148, 195)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(26, 125, 182)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(6, 103, 161)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(4, 82, 129)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(2, 56, 88)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-purpleblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["purplered"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-purplered" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(247, 244, 249)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(234, 227, 240)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(220, 201, 226)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(208, 170, 210)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(208, 138, 194)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(221, 99, 174)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(227, 56, 144)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(215, 28, 108)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(183, 11, 79)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(143, 2, 58)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(103, 0, 31)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-purplered)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["redpurple"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-redpurple" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 247, 243)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(253, 228, 225)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(252, 207, 204)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(251, 181, 188)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(249, 147, 176)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(243, 105, 163)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(224, 62, 152)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(192, 23, 136)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(153, 3, 124)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(112, 1, 116)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(73, 0, 106)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-redpurple)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["yellowgreenblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-yellowgreenblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 255, 217)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(239, 249, 189)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(213, 238, 179)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(169, 221, 183)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(115, 201, 189)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(69, 180, 194)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(40, 151, 191)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(32, 115, 178)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(35, 78, 160)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(28, 49, 133)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(8, 29, 88)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-yellowgreenblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["yellowgreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-yellowgreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 255, 229)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(247, 252, 196)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(228, 244, 172)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(199, 232, 155)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(162, 216, 138)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(120, 197, 120)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(78, 175, 99)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(47, 148, 78)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(21, 121, 63)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(3, 96, 52)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 69, 41)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-yellowgreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["yelloworangebrown"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-yelloworangebrown" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 255, 229)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(255, 248, 196)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(254, 234, 161)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(254, 214, 118)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(254, 186, 74)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(251, 153, 44)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(238, 121, 24)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(216, 91, 10)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(183, 67, 4)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(143, 50, 4)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(102, 37, 6)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-yelloworangebrown)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["yelloworangered"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-yelloworangered" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 255, 204)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(255, 240, 169)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(254, 224, 135)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(254, 201, 101)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(254, 171, 75)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(253, 137, 60)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(250, 92, 46)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(236, 48, 35)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(211, 17, 33)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(175, 2, 37)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(128, 0, 38)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-yelloworangered)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["darkblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-darkblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#323232" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#2e4463" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#1e588a" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#086da7" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#0082b9" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#039ac7" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#12b1d4" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#2bc8e2" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#3ddff0" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#61f4fb" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ffffff" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-darkblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["darkgold"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-darkgold" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#3c3c3c" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#554a38" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#6d5a35" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#846f32" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#a0832d" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#bf9828" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#dbb022" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#f0cb23" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#fae241" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#fff290" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ffffff" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-darkgold)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["darkgreen"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-darkgreen" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#3a3a3a" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#245447" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#076a4c" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#038145" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#2d9642" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#5fa941" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#89bb3f" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#b3cb3b" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#dbdc34" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#ffed39" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ffffaa" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-darkgreen)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["darkmulti"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-darkmulti" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#373737" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#294767" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#1e5b88" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#1a748b" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#1f8e7e" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#29a869" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#6abf50" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#aad332" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#eae30d" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#fff166" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ffffff" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-darkmulti)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["darkred"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-darkred" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#343434" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#643633" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#8c3a36" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#b03e38" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#d14632" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#e75d1e" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#eb7e20" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#ed9c25" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#efb92d" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#f3d431" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ffeb2c" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-darkred)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["lightgreyred"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-lightgreyred" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#efe9e6" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#e2dcd9" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#d7cecb" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#ccc1be" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#c0b4af" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#c4a293" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#d38b66" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#de7336" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#e15917" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#df3a10" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#dc000b" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-lightgreyred)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["lightgreyteal"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-lightgreyteal" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#e4eaea" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#d7ddde" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#cbd1d4" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#bcc6ca" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#adbac0" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#85b2be" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#4aacc1" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#22a1c2" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#2192c0" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#1e84be" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#1876bc" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-lightgreyteal)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["lightmulti"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-lightmulti" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#e0f1f2" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#caebd7" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#b8e2b3" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#bddf93" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#d8e17e" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#f6e072" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#f6c659" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#f4a946" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#f58a3f" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#f56c3f" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#ef4a3c" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-lightmulti)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["lightorange"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-lightorange" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#f2e7da" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#f7d7bd" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#f9c7a0" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#fab78a" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#faa47a" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#f8936d" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#f38264" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#ed725f" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#e6605b" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#dd4f5b" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#d43d5b" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-lightorange)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["lighttealblue"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-lighttealblue" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#e3e9e0" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#c4ddd1" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#a2d1cb" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#84c4c9" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#66b5c3" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#49a7bd" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#3698b4" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#3188a9" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#2d799e" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#276994" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#255988" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-lighttealblue)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - loaded = true; -} -function sequentialMultiHue(selected) { - if (!loaded) load(); - return [ - (0, _scheme.schemeOption)(selected, "viridis"), - (0, _scheme.schemeOption)(selected, "magma"), - (0, _scheme.schemeOption)(selected, "inferno"), - (0, _scheme.schemeOption)(selected, "plasma"), - (0, _scheme.schemeOption)(selected, "cividis"), - (0, _scheme.schemeOption)(selected, "turbo"), - (0, _scheme.schemeOption)(selected, "bluegreen"), - (0, _scheme.schemeOption)(selected, "bluepurple"), - (0, _scheme.schemeOption)(selected, "goldgreen"), - (0, _scheme.schemeOption)(selected, "goldorange"), - (0, _scheme.schemeOption)(selected, "goldred"), - (0, _scheme.schemeOption)(selected, "greenblue"), - (0, _scheme.schemeOption)(selected, "orangered"), - (0, _scheme.schemeOption)(selected, "purplebluegreen"), - (0, _scheme.schemeOption)(selected, "purpleblue"), - (0, _scheme.schemeOption)(selected, "purplered"), - (0, _scheme.schemeOption)(selected, "redpurple"), - (0, _scheme.schemeOption)(selected, "yellowgreenblue"), - (0, _scheme.schemeOption)(selected, "yellowgreen"), - (0, _scheme.schemeOption)(selected, "yelloworangebrown"), - (0, _scheme.schemeOption)(selected, "yelloworangered"), - (0, _scheme.schemeHeader)("schemeSequentialMultiHueDark", (0, _language.strings).schemeSequentialMultiHueDark), - (0, _scheme.schemeOption)(selected, "darkblue"), - (0, _scheme.schemeOption)(selected, "darkgold"), - (0, _scheme.schemeOption)(selected, "darkgreen"), - (0, _scheme.schemeOption)(selected, "darkmulti"), - (0, _scheme.schemeOption)(selected, "darkred"), - (0, _scheme.schemeHeader)("schemeSequentialMultiHueLight", (0, _language.strings).schemeSequentialMultiHueLight), - (0, _scheme.schemeOption)(selected, "lightgreyred"), - (0, _scheme.schemeOption)(selected, "lightgreyteal"), - (0, _scheme.schemeOption)(selected, "lightmulti"), - (0, _scheme.schemeOption)(selected, "lightorange"), - (0, _scheme.schemeOption)(selected, "lighttealblue"), - ]; -} - -},{"../base":"9M4eu","../language":"kzoCJ","./scheme":"9kwPO","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dbxad":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "sequentialSingleHue", ()=>sequentialSingleHue); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _scheme = require("./scheme"); -let loaded = false; -function load() { - (0, _scheme.schemesJSX)["blues"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-blues" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(247, 251, 255)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(227, 238, 249)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(207, 225, 242)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(181, 212, 233)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(147, 195, 223)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(109, 174, 213)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(75, 151, 201)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(47, 126, 188)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(24, 100, 170)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(10, 74, 144)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(8, 48, 107)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-blues)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["tealblues"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-tealblues" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#bce4d8" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#a3d6d2" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#8cc9cd" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#76bdc7" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#5fb0c0" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#45a2b9" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#3993b0" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#3584a6" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#32759b" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#2f6790" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#2c5985" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-tealblues)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["teals"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-teals" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#bbdfdf" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#a2d4d5" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#8ac9c9" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#75bcbb" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#61b0af" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#4da5a4" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#379998" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#2b8b8c" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#1e7f7f" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#127273" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#006667" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-teals)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["greens"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-greens" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(247, 252, 245)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(232, 246, 227)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(211, 238, 205)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(183, 226, 177)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(151, 212, 148)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(115, 195, 120)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(77, 175, 98)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(47, 152, 79)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(21, 127, 59)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(3, 100, 41)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 68, 27)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-greens)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["greys"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-greys" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 255, 255)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(242, 242, 242)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(226, 226, 226)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(206, 206, 206)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(180, 180, 180)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(151, 151, 151)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(122, 122, 122)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(95, 95, 95)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(64, 64, 64)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(30, 30, 30)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(0, 0, 0)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-greys)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["purples"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-purples" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(252, 251, 253)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(241, 239, 246)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(226, 225, 239)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(206, 206, 229)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(182, 181, 216)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(158, 155, 201)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(135, 130, 188)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(115, 99, 172)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(97, 64, 155)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(80, 31, 140)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(63, 0, 125)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-purples)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["browns"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-browns" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#eedbbd" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#ecca96" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#e9b97a" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#e4a865" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#dc9856" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#d18954" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#c7784c" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#c0673f" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#b85536" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#ad4433" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#9f3632" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-browns)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["reds"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-reds" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 245, 240)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(254, 227, 214)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(253, 201, 180)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(252, 170, 142)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(252, 138, 107)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(249, 105, 76)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(239, 69, 51)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(217, 39, 35)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(187, 21, 26)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(151, 11, 19)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(103, 0, 13)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-reds)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["oranges"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-oranges" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "rgb(255, 245, 235)" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "rgb(254, 232, 211)" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "rgb(253, 216, 179)" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "rgb(253, 194, 140)" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "rgb(253, 167, 98)" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "rgb(251, 141, 61)" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "rgb(242, 112, 29)" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "rgb(226, 86, 9)" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "rgb(196, 65, 3)" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "rgb(159, 51, 3)" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "rgb(127, 39, 4)" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-oranges)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - (0, _scheme.schemesJSX)["warmgreys"] = (0, _base.base).react.createElement("svg", { - viewBox: "0,0,1,1", - preserveAspectRatio: "none" - }, (0, _base.base).react.createElement("defs", null, (0, _base.base).react.createElement("linearGradient", { - id: "gradient-warmgreys" - }, (0, _base.base).react.createElement("stop", { - offset: "0%", - stopColor: "#dcd4d0" - }), (0, _base.base).react.createElement("stop", { - offset: "10%", - stopColor: "#cec5c1" - }), (0, _base.base).react.createElement("stop", { - offset: "20%", - stopColor: "#c0b8b4" - }), (0, _base.base).react.createElement("stop", { - offset: "30%", - stopColor: "#b3aaa7" - }), (0, _base.base).react.createElement("stop", { - offset: "40%", - stopColor: "#a59c99" - }), (0, _base.base).react.createElement("stop", { - offset: "50%", - stopColor: "#98908c" - }), (0, _base.base).react.createElement("stop", { - offset: "60%", - stopColor: "#8b827f" - }), (0, _base.base).react.createElement("stop", { - offset: "70%", - stopColor: "#7e7673" - }), (0, _base.base).react.createElement("stop", { - offset: "80%", - stopColor: "#726866" - }), (0, _base.base).react.createElement("stop", { - offset: "90%", - stopColor: "#665c5a" - }), (0, _base.base).react.createElement("stop", { - offset: "100%", - stopColor: "#59504e" - }))), (0, _base.base).react.createElement("rect", { - fill: "url(#gradient-warmgreys)", - x: "0", - y: "0", - width: "1", - height: "1" - })); - loaded = true; -} -function sequentialSingleHue(selected) { - if (!loaded) load(); - return [ - (0, _scheme.schemeOption)(selected, "blues"), - (0, _scheme.schemeOption)(selected, "tealblues"), - (0, _scheme.schemeOption)(selected, "teals"), - (0, _scheme.schemeOption)(selected, "greens"), - (0, _scheme.schemeOption)(selected, "browns"), - (0, _scheme.schemeOption)(selected, "oranges"), - (0, _scheme.schemeOption)(selected, "reds"), - (0, _scheme.schemeOption)(selected, "purples"), - (0, _scheme.schemeOption)(selected, "warmgreys"), - (0, _scheme.schemeOption)(selected, "greys"), - ]; -} - -},{"../base":"9M4eu","./scheme":"9kwPO","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dQuoi":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "dataBrowserZeroMessages", ()=>dataBrowserZeroMessages); -parcelHelpers.export(exports, "dataBrowserNullMessages", ()=>dataBrowserNullMessages); -parcelHelpers.export(exports, "DataBrowser", ()=>DataBrowser); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _dataExporter = require("../controls/dataExporter"); -var _dataItem = require("../controls/dataItem"); -var _dataScope = require("../controls/dataScope"); -var _dropdown = require("../controls/dropdown"); -var _group = require("../controls/group"); -var _iconButton = require("../controls/iconButton"); -var _language = require("../language"); -var _columnTypeChanger = require("../controls/columnTypeChanger"); -const dataBrowserZeroMessages = {}; -dataBrowserZeroMessages[(0, _dataScope.DataScopeId).AllData] = (0, _language.strings).labelZeroAll; -dataBrowserZeroMessages[(0, _dataScope.DataScopeId).FilteredData] = null; //empty array is not used -dataBrowserZeroMessages[(0, _dataScope.DataScopeId).SelectedData] = (0, _language.strings).labelZeroSearchResults; -const dataBrowserNullMessages = {}; -dataBrowserNullMessages[(0, _dataScope.DataScopeId).AllData] = (0, _language.strings).labelDataNullAll; -dataBrowserNullMessages[(0, _dataScope.DataScopeId).FilteredData] = (0, _language.strings).labelDataNullFiltered; -dataBrowserNullMessages[(0, _dataScope.DataScopeId).SelectedData] = (0, _language.strings).labelDataNullSelection; -function DataBrowser(props) { - function activateRecord(newIndex) { - props.onActivate(props.data[newIndex], newIndex); - } - const { index } = props; - const length = props.data && props.data.length || 0; - const dropdownRef = (0, _base.base).react.createRef(); - props.explorer.dialogFocusHandler.focus = ()=>{ - var _a; - return (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.focus(); - }; - return (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelDataBrowser, - className: "sanddance-dataIndex" - }, (0, _base.base).react.createElement((0, _dropdown.Dropdown), { - componentRef: dropdownRef, - label: (0, _language.strings).labelDataScope, - collapseLabel: true, - options: [ - { - key: (0, _dataScope.DataScopeId).AllData, - text: (0, _language.strings).selectDataSpanAll, - isSelected: props.selectedDataScope === (0, _dataScope.DataScopeId).AllData - }, - { - key: (0, _dataScope.DataScopeId).FilteredData, - text: (0, _language.strings).selectDataSpanFilter, - isSelected: props.selectedDataScope === (0, _dataScope.DataScopeId).FilteredData - }, - { - key: (0, _dataScope.DataScopeId).SelectedData, - text: (0, _language.strings).selectDataSpanSelection, - isSelected: props.selectedDataScope === (0, _dataScope.DataScopeId).SelectedData - }, - ], - onChange: (e, o)=>{ - props.onDataScopeClick(o.key); - } - }), !props.data && (0, _base.base).react.createElement("div", { - dangerouslySetInnerHTML: { - __html: props.nullMessage - } - }), props.data && !props.data.length && (0, _base.base).react.createElement("div", null, props.zeroMessage), !!length && (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement("div", { - className: "index" - }, (0, _base.base).react.createElement((0, _iconButton.IconButton), { - themePalette: props.themePalette, - iconName: "ChevronLeftMed", - onClick: (e)=>activateRecord(index <= 0 ? length - 1 : index - 1), - disabled: props.disabled || length === 1, - title: (0, _language.strings).buttonPrevDataItem - }), (0, _base.base).react.createElement("span", null, (0, _language.strings).record(index + 1, length)), (0, _base.base).react.createElement((0, _iconButton.IconButton), { - themePalette: props.themePalette, - iconName: "ChevronRightMed", - onClick: (e)=>activateRecord(index >= length - 1 ? 0 : index + 1), - disabled: props.disabled || length === 1, - title: (0, _language.strings).buttonNextDataItem - })), !props.itemVisible && (0, _base.base).react.createElement("div", { - className: "item-filtered" - }, (0, _language.strings).labelDataItemIsFiltered), (0, _base.base).react.createElement((0, _dataItem.DataItem), { - columns: props.columns, - item: props.data[index], - disabled: props.disabled, - onSearch: props.onSearch, - bingSearchDisabled: props.bingSearchDisabled - })), (0, _base.base).react.createElement((0, _columnTypeChanger.ColumnTypeChanger), { - theme: props.theme, - themePalette: props.themePalette, - initialCategoricalColumns: props.categoricalColumns, - initialQuantitativeColumns: props.quantitativeColumns, - onConfirmUpdate: props.onUpdateColumnTypes - }), props.dataExportHandler && props.data && (0, _base.base).react.createElement((0, _dataExporter.DataExportPicker), { - theme: props.theme, - initializer: { - fileName: `${(0, _dataExporter.removeExtensions)(props.displayName)} (${props.data.length})` - }, - data: props.data, - dataExportHandler: props.dataExportHandler, - disabled: props.disabled - })); -} - -},{"../base":"9M4eu","../controls/dataExporter":"789YP","../controls/dataItem":"gXGP7","../controls/dataScope":"i7FKh","../controls/dropdown":"2Udzo","../controls/group":"hggjF","../controls/iconButton":"6gzbB","../language":"kzoCJ","../controls/columnTypeChanger":"86e3b","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gXGP7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DataItem", ()=>DataItem); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _keycodes = require("../keycodes"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function isNumber(value) { - if (typeof value === "number") return true; - if (!isNaN(value)) return true; - return false; -} -function isBoolean(value) { - if (typeof value === "boolean") return true; - if (typeof value === "string") switch(value.toLowerCase()){ - case "true": - case "false": - return true; - } - return false; -} -function bingSearchLink(column, value) { - if (isNumber(value)) return null; - if (isBoolean(value)) return null; - if (column && column.stats.distinctValueCount === 2) return null; - return (0, _base.base).react.createElement("div", { - className: "bing-search" - }, (0, _base.base).react.createElement("a", { - href: `https://www.bing.com/search?q=${encodeURIComponent(value)}`, - target: "_blank", - title: (0, _language.strings).bingsearchDescription(value), - "aria-label": (0, _language.strings).bingsearchDescription(value) - }, (0, _language.strings).bingsearch)); -} -function displayValue(value) { - switch(value){ - case "": - return { - special: true, - display: (0, _language.strings).labelBlank - }; - case null: - return { - special: true, - display: (0, _language.strings).labelNull - }; - case true: - return { - special: true, - display: (0, _language.strings).labelTrue - }; - case false: - return { - special: true, - display: (0, _language.strings).labelFalse - }; - default: - if (typeof value === "object") { - if (value instanceof Date) { - const d = value; - return displayValue(d.input); - } - return { - special: false, - display: value.toLocaleString() - }; - } - return { - special: false, - display: value - }; - } -} -function displayValueElement(nvp) { - const d = displayValue(nvp.value); - if (d.special) return (0, _base.base).react.createElement("i", null, d.display); - return d.display; -} -function DataItem(props) { - if (!props.item) return null; - const nameValuePairs = []; - for(const columnName in props.item){ - if (columnName === (0, _sanddanceReact.SandDance).constants.GL_ORDINAL && !props.showSystemFields) continue; - if ((0, _sanddanceReact.SandDance).util.isInternalFieldName(columnName)) continue; - const nameValuePair = { - columnName, - value: props.item[columnName] - }; - if (!props.bingSearchDisabled) nameValuePair.bingSearch = bingSearchLink(props.columns.filter((c)=>c.name === columnName)[0], props.item[columnName]); - nameValuePairs.push(nameValuePair); - } - return (0, _base.base).react.createElement("div", { - className: "sanddance-dataItem" - }, nameValuePairs.map((nameValuePair, i)=>{ - const ex = { - key: 0, - name: nameValuePair.columnName, - operator: "==", - value: nameValuePair.value - }; - if (nameValuePair.value === null || nameValuePair.value === "") { - ex.operator = "isnullorEmpty"; - delete ex.value; - } - const searchClick = (e)=>{ - const search = { - key: 0, - expressions: [ - ex - ] - }; - props.onSearch(e, [ - search - ]); - }; - const title = (0, _language.strings).tooltipSearch(nameValuePair.columnName, displayValue(nameValuePair.value).display); - return (0, _base.base).react.createElement("div", { - key: i, - onClick: !props.disabled ? searchClick : null, - title: title, - onKeyUp: (e)=>{ - if (e.keyCode === (0, _keycodes.KeyCodes).ENTER) searchClick(e); - }, - tabIndex: 0, - className: "name-value" - }, (0, _base.base).react.createElement("div", { - className: "column-name" - }, nameValuePair.columnName), (0, _base.base).react.createElement("div", { - className: "column-value" - }, displayValueElement(nameValuePair)), nameValuePair.bingSearch); - })); -} - -},{"../base":"9M4eu","../keycodes":"g0scs","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"g0scs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "KeyCodes", ()=>KeyCodes); -const KeyCodes = { - ENTER: 13 -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1YLAA":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "History", ()=>History); -parcelHelpers.export(exports, "getPureInsight", ()=>getPureInsight); -parcelHelpers.export(exports, "replay", ()=>replay); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _group = require("../controls/group"); -var _keycodes = require("../keycodes"); -var _language = require("../language"); -var _sanddanceReact = require("@msrvida/sanddance-react"); -function History(props) { - return (0, _base.base).react.createElement((0, _group.Group), { - label: (0, _language.strings).labelHistory, - className: "sanddance-history" - }, (0, _base.base).react.createElement("ol", null, props.historyItems.map((hi, i)=>{ - let ref; - if (i === props.historyIndex) { - ref = (0, _base.base).react.createRef(); - props.explorer.dialogFocusHandler.focus = ()=>{ - var _a; - (_a = ref.current) === null || _a === void 0 || _a.focus(); - }; - } - return (0, _base.base).react.createElement("li", { - key: i, - className: (0, _sanddanceReact.util).classList(i === props.historyIndex && "selected"), - onKeyUp: (e)=>{ - if (e.keyCode === (0, _keycodes.KeyCodes).ENTER) props.redo(i); - } - }, (0, _base.base).react.createElement((0, _base.base).fluentUI.DefaultButton, { - className: "sanddance-history-button", - componentRef: ref, - text: hi.label, - onClick: ()=>props.redo(i) - })); - }))); -} -function getPureInsight(historicInsight) { - const { colorBin , columns , directColor , facetStyle , filter , hideAxes , hideLegend , scheme , signalValues , size , totalStyle , transform , chart , view } = historicInsight; - const insight = { - colorBin, - columns, - directColor, - facetStyle, - filter, - hideAxes, - hideLegend, - scheme, - signalValues, - size, - totalStyle, - transform, - chart, - view - }; - return insight; -} -function replay(historyItems, index) { - let filter = null; - let historicInsight = {}; - for(let i = 0; i < index + 1; i++){ - const historyItem = historyItems[i]; - if (historyItem) { - if (historyItem.historicInsight.filter === null) filter = null; - else if (historyItem.historicInsight.rebaseFilter) filter = historyItem.historicInsight.filter; - else if (historyItem.historicInsight.filter) filter = (0, _sanddanceReact.SandDance).searchExpression.narrow(filter, historyItem.historicInsight.filter); - historicInsight = Object.assign(Object.assign({}, historicInsight), historyItem.historicInsight); - } - } - return Object.assign(Object.assign({}, historicInsight), { - filter - }); -} - -},{"../base":"9M4eu","../controls/group":"hggjF","../keycodes":"g0scs","../language":"kzoCJ","@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9fxMb":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getPosition", ()=>getPosition); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ function hasClientXY(e) { - if (e && e.clientX !== undefined && e.clientX !== undefined) return { - top: e.clientY, - left: e.clientX - }; -} -function getPosition(e) { - const xy = hasClientXY(e); - if (xy) return xy; - const te = e; - if (te === null || te === void 0 ? void 0 : te.touches) for(let i = 0; i < te.touches.length; i++){ - const xy1 = hasClientXY(te.touches[i]); - if (xy1) return xy1; - } - const el = e.target; - if (el && el.getClientRects) return el.getClientRects()[0]; -} - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8eFp1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "initPrefs", ()=>initPrefs); -parcelHelpers.export(exports, "saveSignalValuePref", ()=>saveSignalValuePref); -parcelHelpers.export(exports, "copyPrefToNewState", ()=>copyPrefToNewState); -parcelHelpers.export(exports, "savePref", ()=>savePref); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceReact = require("@msrvida/sanddance-react"); -function initPrefs(prefs, partialInsight) { - if (partialInsight) { - const specTypePrefs = prefs[partialInsight.chart] || {}; - prefs[partialInsight.chart] = specTypePrefs; - for(const _role in partialInsight.columns){ - const role = _role; - if (role === "color" || role === "x") { - const rolePrefs = specTypePrefs[role] || {}; - specTypePrefs[role] = rolePrefs; - const column = partialInsight.columns[role]; - const copySignalValue = (signalName)=>{ - if (partialInsight.signalValues && partialInsight.signalValues[signalName] && rolePrefs[column]) { - const signalValues = rolePrefs[column].signalValues || {}; - signalValues[signalName] = partialInsight.signalValues[signalName]; - rolePrefs[column].signalValues = signalValues; - } - }; - switch(role){ - case "color": - rolePrefs[column] = { - scheme: partialInsight.scheme, - colorBin: partialInsight.colorBin - }; - copySignalValue((0, _sanddanceReact.SandDance).constants.SignalNames.ColorBinCount); - break; - case "x": - copySignalValue((0, _sanddanceReact.SandDance).constants.SignalNames.XBins); - break; - } - } - } - } -} -function saveSignalValuePref(prefs, chart, role, column, signalName, signalValue) { - const partialInsight = savePref(prefs, chart, role, column, { - signalValues: {} - }); - partialInsight.signalValues[signalName] = signalValue; -} -function copyPrefToNewState(prefs, chart, role, columnName) { - const specTypePrefs = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge({}, prefs["*"], prefs[chart]); - const rolePrefs = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge({}, specTypePrefs["*"], specTypePrefs[role]); - const partialInsight = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge({}, rolePrefs["*"], rolePrefs[columnName]); - return partialInsight; -} -function savePref(prefs, chart, role, column, partialInsight) { - const SpecTypePrefs = prefs[chart] || {}; - prefs[chart] = SpecTypePrefs; - const rolePrefs = SpecTypePrefs[role] || {}; - SpecTypePrefs[role] = rolePrefs; - rolePrefs[column] = (0, _sanddanceReact.SandDance).VegaMorphCharts.util.deepMerge({}, rolePrefs[column], partialInsight); - return rolePrefs[column]; -} - -},{"@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6id2x":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "compareGroups", ()=>compareGroups); -parcelHelpers.export(exports, "createInputSearch", ()=>createInputSearch); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _sanddanceReact = require("@msrvida/sanddance-react"); -function comparableGroup(group) { - return Object.assign(Object.assign({}, group), { - clause: null - }); -} -function compareGroup(a, b) { - return (0, _sanddanceReact.SandDance).searchExpression.compareGroup(comparableGroup(a), comparableGroup(b)); -} -function compareGroups(haystack, needle) { - const groups = []; - let found = false; - //look for item in all - haystack.forEach((group)=>{ - if (compareGroup(group, needle)) //if it exists, don't add it - found = true; - else groups.push(group); - }); - return { - groups, - found - }; -} -function createInputSearch(search) { - const groups = (0, _sanddanceReact.SandDance).searchExpression.ensureSearchExpressionGroupArray(search); - const dialogSearch = groups.map((group, groupIndex)=>{ - return Object.assign(Object.assign({ - key: groupIndex - }, group), { - expressions: group.expressions.map((ex, i)=>{ - const ex2 = Object.assign({ - key: i - }, ex); - return ex2; - }) - }); - }); - return dialogSearch; -} - -},{"@msrvida/sanddance-react":"73dPQ","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2N3JL":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Renderer", ()=>Renderer); -/*! -* Copyright (c) Microsoft Corporation. -* Licensed under the MIT License. -*/ var _base = require("../base"); -var _language = require("../language"); -var _iconButton = require("./iconButton"); -var _dialog = require("./dialog"); -var _button = require("./button"); -function _Renderer(_props) { - class __Renderer extends (0, _base.base).react.Component { - constructor(props){ - var _a, _b; - super(props); - this.state = this.getInitialState(props); - if (!((_b = (_a = this.state.viewer) === null || _a === void 0 ? void 0 : _a.presenter) === null || _b === void 0 ? void 0 : _b.morphchartsref)) { - const t = setInterval(()=>{ - var _a, _b; - const newState = this.getInitialState(props); - if (this.mounted && ((_b = (_a = newState.viewer) === null || _a === void 0 ? void 0 : _a.presenter) === null || _b === void 0 ? void 0 : _b.morphchartsref)) { - clearInterval(t); - this.setState(newState); - } - }, 10); - } - } - componentDidMount() { - this.mounted = true; - } - componentWillUnmount() { - this.mounted = false; - } - getInitialState(props) { - const { viewer } = props.explorer; - return { - showOptions: false, - viewer - }; - } - setOptions(newOptions) { - const { explorer } = this.props; - const renderer = Object.assign(Object.assign({}, explorer.state.renderer), newOptions); - const { onSetupOptionsChanged } = explorer.props; - if (onSetupOptionsChanged) { - const setup = explorer.getSetup(); - setup.renderer = renderer; - onSetupOptionsChanged(setup); - } - explorer.setState({ - renderer - }); - } - setBasicOptions(newOptions) { - this.setOptions({ - advanced: false, - basicOptions: Object.assign(Object.assign({}, this.props.basicOptions), newOptions) - }); - } - setAdvancedOptions(newOptions) { - this.setOptions({ - advanced: true, - advancedOptions: Object.assign(Object.assign({}, this.props.advancedOptions), newOptions) - }); - } - render() { - var _a, _b; - const { props , state } = this; - const iconButtonStyles = { - menuIcon: { - display: "none" - } - }; - if (!((_b = (_a = state.viewer) === null || _a === void 0 ? void 0 : _a.presenter) === null || _b === void 0 ? void 0 : _b.morphchartsref)) return (0, _base.base).react.createElement((0, _iconButton.IconButton), { - styles: iconButtonStyles, - className: "sanddance-advanced-renderer", - disabled: true, - iconName: "HourGlass", - onClick: undefined, - themePalette: props.themePalette, - title: (0, _language.strings).labelRenderer - }); - else { - const { morphchartsref } = state.viewer.presenter; - const choiceButtonStyle = { - border: "none" - }; - const { advanced , advancedOptions , basicOptions } = props; - return (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _iconButton.IconButton), { - iconName: "PicturePosition", - title: (0, _language.strings).buttonCameraHome, - onClick: props.onHomeClick, - styles: iconButtonStyles, - themePalette: props.themePalette - }), (0, _base.base).react.createElement((0, _iconButton.IconButton), { - styles: iconButtonStyles, - className: "sanddance-advanced-renderer", - iconName: advanced ? "DiamondSolid" : "Diamond", - disabled: !morphchartsref.supportedRenders.advanced, - onClick: undefined, - themePalette: props.themePalette, - title: morphchartsref.supportedRenders.advanced ? (0, _language.strings).labelRenderer : (0, _language.strings).labelRendererAdvancedDisabled, - menuProps: { - items: [ - { - key: "basic", - text: (0, _language.strings).labelRendererBasic, - iconProps: { - iconName: advanced ? null : "RadioBullet" - }, - onClick: ()=>advanced && this.setOptions({ - advanced: false - }) - }, - { - key: "advanced", - text: (0, _language.strings).labelRendererAdvanced, - iconProps: { - iconName: advanced ? "RadioBullet" : null - }, - onClick: ()=>!advanced && this.setOptions({ - advanced: true - }) - }, - { - key: "options", - text: (0, _language.strings).labelRendererOptions, - onClick: (e)=>this.setState({ - showOptions: true - }) - }, - ] - } - }), (0, _base.base).react.createElement((0, _dialog.Dialog), { - hidden: !state.showOptions, - dialogContentProps: { - className: "sanddance-renderer-dialog", - title: (0, _language.strings).labelRendererOptionsDialogTitle - }, - onDismiss: ()=>this.setState({ - showOptions: false - }) - }, (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _button.Button), { - iconName: advanced ? "RadioBtnOff" : "RadioBtnOn", - onClick: ()=>this.setOptions({ - advanced: false - }), - text: (0, _language.strings).labelRendererBasic, - themePalette: props.themePalette, - rootStyle: choiceButtonStyle - }), (0, _base.base).react.createElement("ul", null, (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: basicOptions.antialias, - label: (0, _language.strings).labelRendererOptionsAntialias, - onChange: (e, antialias)=>this.setBasicOptions({ - antialias - }) - })))), (0, _base.base).react.createElement("div", null, (0, _base.base).react.createElement((0, _button.Button), { - iconName: advanced ? "RadioBtnOn" : "RadioBtnOff", - onClick: ()=>this.setOptions({ - advanced: true - }), - text: (0, _language.strings).labelRendererAdvanced, - themePalette: props.themePalette, - rootStyle: choiceButtonStyle - }), (0, _base.base).react.createElement("ul", null, (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: advancedOptions.isShadowEnabled, - label: (0, _language.strings).labelRendererOptionsShadow, - onChange: (e, isShadowEnabled)=>this.setAdvancedOptions({ - isShadowEnabled - }) - })), (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: advancedOptions.isSsaoEnabled, - label: (0, _language.strings).labelRendererOptionsSsao, - onChange: (e, isSsaoEnabled)=>this.setAdvancedOptions({ - isSsaoEnabled - }) - })), (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: advancedOptions.isBloomEnabled, - label: (0, _language.strings).labelRendererOptionsBloom, - onChange: (e, isBloomEnabled)=>this.setAdvancedOptions({ - isBloomEnabled - }) - }), (0, _base.base).react.createElement("ul", null, (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - value: advancedOptions.bloomIntensity, - min: 0.1, - max: 5, - step: 0.01, - label: (0, _language.strings).labelRendererOptionsBloomIntensity, - onChange: (bloomIntensity)=>this.setAdvancedOptions({ - bloomIntensity, - isBloomEnabled: true - }) - })))), (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: advancedOptions.isDofEnabled, - label: (0, _language.strings).labelRendererOptionsDof, - onChange: (e, isDofEnabled)=>this.setAdvancedOptions({ - isDofEnabled - }) - }), (0, _base.base).react.createElement("ul", null, (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Slider, { - value: advancedOptions.dofFocusRange, - min: 0, - max: 2, - step: 0.01, - label: (0, _language.strings).labelRendererOptionsDofRange, - onChange: (dofFocusRange)=>this.setAdvancedOptions({ - dofFocusRange, - isDofEnabled: true - }) - })))), (0, _base.base).react.createElement("li", null, (0, _base.base).react.createElement((0, _base.base).fluentUI.Toggle, { - checked: advancedOptions.isFxaaEnabled, - label: (0, _language.strings).labelRendererOptionsFxaa, - onChange: (e, isFxaaEnabled)=>this.setAdvancedOptions({ - isFxaaEnabled - }) - })))))); - } - } - } - return new __Renderer(_props); -} -const Renderer = _Renderer; - -},{"../base":"9M4eu","../language":"kzoCJ","./iconButton":"6gzbB","./dialog":"ep4zG","./button":"j0llx","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8ePka":[function(require,module,exports) { -module.exports = React; - -},{}],"j73oT":[function(require,module,exports) { -module.exports = ReactDOM; - -},{}],"jSYVB":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "fluentUI", ()=>fluentUI); -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. -var _button = require("@fluentui/react/lib/Button"); -var _choiceGroup = require("@fluentui/react/lib/ChoiceGroup"); -var _comboBox = require("@fluentui/react/lib/ComboBox"); -var _commandBar = require("@fluentui/react/lib/CommandBar"); -var _contextualMenu = require("@fluentui/react/lib/ContextualMenu"); -var _utilities = require("@fluentui/react/lib/Utilities"); -var _dialog = require("@fluentui/react/lib/Dialog"); -var _dropdown = require("@fluentui/react/lib/Dropdown"); -var _styling = require("@fluentui/react/lib/Styling"); -var _icon = require("@fluentui/react/lib/Icon"); -var _icons = require("@fluentui/react/lib/Icons"); -var _label = require("@fluentui/react/lib/Label"); -var _modal = require("@fluentui/react/lib/Modal"); -var _slider = require("@fluentui/react/lib/Slider"); -var _spinner = require("@fluentui/react/lib/Spinner"); -var _textField = require("@fluentui/react/lib/TextField"); -var _toggle = require("@fluentui/react/lib/Toggle"); -(0, _icons.initializeIcons)(); -const fluentUI = { - ActionButton: (0, _button.ActionButton), - ChoiceGroup: (0, _choiceGroup.ChoiceGroup), - ComboBox: (0, _comboBox.ComboBox), - CommandBar: (0, _commandBar.CommandBar), - ContextualMenuItemType: (0, _contextualMenu.ContextualMenuItemType), - Customizer: (0, _utilities.Customizer), - DefaultButton: (0, _button.DefaultButton), - Dialog: (0, _dialog.Dialog), - DialogFooter: (0, _dialog.DialogFooter), - DialogType: (0, _dialog.DialogType), - Dropdown: (0, _dropdown.Dropdown), - DropdownMenuItemType: (0, _dropdown.DropdownMenuItemType), - Icon: (0, _icon.Icon), - IconButton: (0, _button.IconButton), - getFocusStyle: (0, _styling.getFocusStyle), - getTheme: (0, _styling.getTheme), - Label: (0, _label.Label), - loadTheme: (0, _styling.loadTheme), - Modal: (0, _modal.Modal), - PrimaryButton: (0, _button.PrimaryButton), - Slider: (0, _slider.Slider), - Spinner: (0, _spinner.Spinner), - SpinnerSize: (0, _spinner.SpinnerSize), - TextField: (0, _textField.TextField), - Toggle: (0, _toggle.Toggle) -}; - -},{"@fluentui/react/lib/Button":"c7Gp7","@fluentui/react/lib/ChoiceGroup":"dcM7C","@fluentui/react/lib/ComboBox":"aEx6o","@fluentui/react/lib/CommandBar":"cnCTi","@fluentui/react/lib/ContextualMenu":"5W7tr","@fluentui/react/lib/Utilities":"d0PNn","@fluentui/react/lib/Dialog":"lhftW","@fluentui/react/lib/Dropdown":"dEJVZ","@fluentui/react/lib/Styling":"fmg3v","@fluentui/react/lib/Icon":"8rJ2a","@fluentui/react/lib/Icons":"l6hLT","@fluentui/react/lib/Label":"f54uM","@fluentui/react/lib/Modal":"fyJ0D","@fluentui/react/lib/Slider":"brPQz","@fluentui/react/lib/Spinner":"dTo6e","@fluentui/react/lib/TextField":"6eVOz","@fluentui/react/lib/Toggle":"hbvPy","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"c7Gp7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _index = require("./components/Button/index"); -parcelHelpers.exportAll(_index, exports); - -},{"./components/Button/index":"ksWPz","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ksWPz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "ButtonGlobalClassNames", ()=>(0, _baseButtonClassNames.ButtonGlobalClassNames)); -var _baseButton = require("./BaseButton"); -parcelHelpers.exportAll(_baseButton, exports); -var _buttonTypes = require("./Button.types"); -parcelHelpers.exportAll(_buttonTypes, exports); -var _button = require("./Button"); -parcelHelpers.exportAll(_button, exports); -var _actionButton = require("./ActionButton/ActionButton"); -parcelHelpers.exportAll(_actionButton, exports); -var _commandBarButton = require("./CommandBarButton/CommandBarButton"); -parcelHelpers.exportAll(_commandBarButton, exports); -var _commandButton = require("./CommandButton/CommandButton"); -parcelHelpers.exportAll(_commandButton, exports); -var _compoundButton = require("./CompoundButton/CompoundButton"); -parcelHelpers.exportAll(_compoundButton, exports); -var _defaultButton = require("./DefaultButton/DefaultButton"); -parcelHelpers.exportAll(_defaultButton, exports); -var _messageBarButton = require("./MessageBarButton/MessageBarButton"); -parcelHelpers.exportAll(_messageBarButton, exports); -var _primaryButton = require("./PrimaryButton/PrimaryButton"); -parcelHelpers.exportAll(_primaryButton, exports); -var _iconButton = require("./IconButton/IconButton"); -parcelHelpers.exportAll(_iconButton, exports); -var _splitButtonClassNames = require("./SplitButton/SplitButton.classNames"); -parcelHelpers.exportAll(_splitButtonClassNames, exports); -var _baseButtonClassNames = require("./BaseButton.classNames"); - -},{"./BaseButton":"aFQzv","./Button.types":"dS38G","./Button":"cyUjW","./ActionButton/ActionButton":"7NwWQ","./CommandBarButton/CommandBarButton":"9NF4g","./CommandButton/CommandButton":"6Kn9C","./CompoundButton/CompoundButton":"8oyjs","./DefaultButton/DefaultButton":"6ZQzj","./MessageBarButton/MessageBarButton":"ik86k","./PrimaryButton/PrimaryButton":"01TCg","./IconButton/IconButton":"fwEU5","./SplitButton/SplitButton.classNames":"1z3em","./BaseButton.classNames":"h7V1v","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aFQzv":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "BaseButton", ()=>BaseButton); -var _tslib = require("tslib"); -var _react = require("react"); -var _utilities = require("../../Utilities"); -var _icon = require("../../Icon"); -var _directionalHint = require("../../common/DirectionalHint"); -var _contextualMenu = require("../../ContextualMenu"); -var _baseButtonClassNames = require("./BaseButton.classNames"); -var _splitButtonClassNames = require("./SplitButton/SplitButton.classNames"); -var _keytipData = require("../../KeytipData"); -var TouchIdleDelay = 500; /* ms */ -var COMPONENT_NAME = "BaseButton"; -/** - * {@docCategory Button} - */ var BaseButton = /** @class */ function(_super) { - (0, _tslib.__extends)(BaseButton, _super); - function BaseButton(props) { - var _this = _super.call(this, props) || this; - _this._buttonElement = _react.createRef(); - _this._splitButtonContainer = _react.createRef(); - _this._mergedRef = (0, _utilities.createMergedRef)(); - _this._renderedVisibleMenu = false; - _this._getMemoizedMenuButtonKeytipProps = (0, _utilities.memoizeFunction)(function(keytipProps) { - return (0, _tslib.__assign)((0, _tslib.__assign)({}, keytipProps), { - hasMenu: true - }); - }); - _this._onRenderIcon = function(buttonProps, defaultRender) { - var iconProps = _this.props.iconProps; - if (iconProps && (iconProps.iconName !== undefined || iconProps.imageProps)) { - var className = iconProps.className, imageProps = iconProps.imageProps, rest = (0, _tslib.__rest)(iconProps, [ - "className", - "imageProps" - ]); - // If the styles prop is specified as part of iconProps, fall back to regular Icon as FontIcon and ImageIcon - // do not have this prop. - if (iconProps.styles) return _react.createElement((0, _icon.Icon), (0, _tslib.__assign)({ - className: (0, _utilities.css)(_this._classNames.icon, className), - imageProps: imageProps - }, rest)); - if (iconProps.iconName) return _react.createElement((0, _icon.FontIcon), (0, _tslib.__assign)({ - className: (0, _utilities.css)(_this._classNames.icon, className) - }, rest)); - if (imageProps) return _react.createElement((0, _icon.ImageIcon), (0, _tslib.__assign)({ - className: (0, _utilities.css)(_this._classNames.icon, className), - imageProps: imageProps - }, rest)); - } - return null; - }; - _this._onRenderTextContents = function() { - var _a = _this.props, text = _a.text, children = _a.children, // eslint-disable-next-line deprecation/deprecation - _b = _a.secondaryText, // eslint-disable-next-line deprecation/deprecation - secondaryText = _b === void 0 ? _this.props.description : _b, _c = _a.onRenderText, onRenderText = _c === void 0 ? _this._onRenderText : _c, _d = _a.onRenderDescription, onRenderDescription = _d === void 0 ? _this._onRenderDescription : _d; - if (text || typeof children === "string" || secondaryText) return _react.createElement("span", { - className: _this._classNames.textContainer - }, onRenderText(_this.props, _this._onRenderText), onRenderDescription(_this.props, _this._onRenderDescription)); - return [ - onRenderText(_this.props, _this._onRenderText), - onRenderDescription(_this.props, _this._onRenderDescription) - ]; - }; - _this._onRenderText = function() { - var text = _this.props.text; - var children = _this.props.children; - // For backwards compat, we should continue to take in the text content from children. - if (text === undefined && typeof children === "string") text = children; - if (_this._hasText()) return _react.createElement("span", { - key: _this._labelId, - className: _this._classNames.label, - id: _this._labelId - }, text); - return null; - }; - _this._onRenderChildren = function() { - var children = _this.props.children; - // If children is just a string, either it or the text will be rendered via onRenderLabel - // If children is another component, it will be rendered after text - if (typeof children === "string") return null; - return children; - }; - _this._onRenderDescription = function(props) { - // eslint-disable-next-line deprecation/deprecation - var _a = props.secondaryText, secondaryText = _a === void 0 ? _this.props.description : _a; - // ms-Button-description is only shown when the button type is compound. - // In other cases it will not be displayed. - return secondaryText ? _react.createElement("span", { - key: _this._descriptionId, - className: _this._classNames.description, - id: _this._descriptionId - }, secondaryText) : null; - }; - _this._onRenderAriaDescription = function() { - var ariaDescription = _this.props.ariaDescription; - // If ariaDescription is given, descriptionId will be assigned to ariaDescriptionSpan, - // otherwise it will be assigned to descriptionSpan. - return ariaDescription ? _react.createElement("span", { - className: _this._classNames.screenReaderText, - id: _this._ariaDescriptionId - }, ariaDescription) : null; - }; - _this._onRenderMenuIcon = function(props) { - var menuIconProps = _this.props.menuIconProps; - return _react.createElement((0, _icon.FontIcon), (0, _tslib.__assign)({ - iconName: "ChevronDown" - }, menuIconProps, { - className: _this._classNames.menuIcon - })); - }; - _this._onRenderMenu = function(menuProps) { - var MenuType = _this.props.menuAs ? (0, _utilities.composeComponentAs)(_this.props.menuAs, (0, _contextualMenu.ContextualMenu)) : (0, _contextualMenu.ContextualMenu); - return _react.createElement(MenuType, (0, _tslib.__assign)({}, menuProps)); - }; - _this._onDismissMenu = function(ev) { - var menuProps = _this.props.menuProps; - if (menuProps && menuProps.onDismiss) menuProps.onDismiss(ev); - if (!ev || !ev.defaultPrevented) _this._dismissMenu(); - }; - _this._dismissMenu = function() { - _this._menuShouldFocusOnMount = undefined; - _this._menuShouldFocusOnContainer = undefined; - _this.setState({ - menuHidden: true - }); - }; - _this._openMenu = function(shouldFocusOnContainer, shouldFocusOnMount) { - if (shouldFocusOnMount === void 0) shouldFocusOnMount = true; - if (_this.props.menuProps) { - _this._menuShouldFocusOnContainer = shouldFocusOnContainer; - _this._menuShouldFocusOnMount = shouldFocusOnMount; - _this._renderedVisibleMenu = true; - _this.setState({ - menuHidden: false - }); - } - }; - _this._onToggleMenu = function(shouldFocusOnContainer) { - var shouldFocusOnMount = true; - if (_this.props.menuProps && _this.props.menuProps.shouldFocusOnMount === false) shouldFocusOnMount = false; - _this.state.menuHidden ? _this._openMenu(shouldFocusOnContainer, shouldFocusOnMount) : _this._dismissMenu(); - }; - _this._onSplitContainerFocusCapture = function(ev) { - var container = _this._splitButtonContainer.current; - // If the target is coming from the portal we do not need to set focus on the container. - if (!container || ev.target && (0, _utilities.portalContainsElement)(ev.target, container)) return; - // We should never be able to focus the individual buttons in a split button. Focus - // should always remain on the container. - container.focus(); - }; - _this._onSplitButtonPrimaryClick = function(ev) { - if (!_this.state.menuHidden) _this._dismissMenu(); - if (!_this._processingTouch && _this.props.onClick) _this.props.onClick(ev); - else if (_this._processingTouch) _this._onMenuClick(ev); - }; - _this._onKeyDown = function(ev) { - // explicity cancelling event so click won't fire after this - // eslint-disable-next-line deprecation/deprecation - if (_this.props.disabled && (ev.which === (0, _utilities.KeyCodes).enter || ev.which === (0, _utilities.KeyCodes).space)) { - ev.preventDefault(); - ev.stopPropagation(); - } else if (!_this.props.disabled) { - if (_this.props.menuProps) _this._onMenuKeyDown(ev); - else if (_this.props.onKeyDown !== undefined) _this.props.onKeyDown(ev); // not cancelling event because it's not disabled - } - }; - _this._onKeyUp = function(ev) { - if (!_this.props.disabled && _this.props.onKeyUp !== undefined) _this.props.onKeyUp(ev); // not cancelling event because it's not disabled - }; - _this._onKeyPress = function(ev) { - // eslint-disable-next-line deprecation/deprecation - if (!_this.props.disabled && _this.props.onKeyPress !== undefined) // eslint-disable-next-line deprecation/deprecation - _this.props.onKeyPress(ev); // not cancelling event because it's not disabled - }; - _this._onMouseUp = function(ev) { - if (!_this.props.disabled && _this.props.onMouseUp !== undefined) _this.props.onMouseUp(ev); // not cancelling event because it's not disabled - }; - _this._onMouseDown = function(ev) { - if (!_this.props.disabled && _this.props.onMouseDown !== undefined) _this.props.onMouseDown(ev); // not cancelling event because it's not disabled - }; - _this._onClick = function(ev) { - if (!_this.props.disabled) { - if (_this.props.menuProps) _this._onMenuClick(ev); - else if (_this.props.onClick !== undefined) _this.props.onClick(ev); // not cancelling event because it's not disabled - } - }; - _this._onSplitButtonContainerKeyDown = function(ev) { - // eslint-disable-next-line deprecation/deprecation - if (ev.which === (0, _utilities.KeyCodes).enter || ev.which === (0, _utilities.KeyCodes).space) { - if (_this._buttonElement.current) { - _this._buttonElement.current.click(); - ev.preventDefault(); - ev.stopPropagation(); - } - } else _this._onMenuKeyDown(ev); - }; - _this._onMenuKeyDown = function(ev) { - var _a; - if (_this.props.disabled) return; - if (_this.props.onKeyDown) _this.props.onKeyDown(ev); - // eslint-disable-next-line deprecation/deprecation - var isUp = ev.which === (0, _utilities.KeyCodes).up; - // eslint-disable-next-line deprecation/deprecation - var isDown = ev.which === (0, _utilities.KeyCodes).down; - if (!ev.defaultPrevented && _this._isValidMenuOpenKey(ev)) { - var onMenuClick = _this.props.onMenuClick; - if (onMenuClick) onMenuClick(ev, _this.props); - _this._onToggleMenu(false); - ev.preventDefault(); - ev.stopPropagation(); - } - // eslint-disable-next-line deprecation/deprecation - if (ev.which === (0, _utilities.KeyCodes).enter || ev.which === (0, _utilities.KeyCodes).space) // We manually set the focus visibility to true if opening via Enter or Space to account for the scenario where - // a user clicks on the button, closes the menu and then opens it via keyboard. In this scenario our default logic - // for setting focus visibility is not triggered since there is no keyboard navigation present beforehand. - (0, _utilities.setFocusVisibility)(true, ev.target, (_a = _this.context) === null || _a === void 0 ? void 0 : _a.registeredProviders); - if (!(ev.altKey || ev.metaKey) && (isUp || isDown)) // Suppose a menu, with shouldFocusOnMount: false, is open, and user wants to keyboard to the menu items - // We need to re-render the menu with shouldFocusOnMount as true. - { - if (!_this.state.menuHidden && _this.props.menuProps) { - var currentShouldFocusOnMount = _this._menuShouldFocusOnMount !== undefined ? _this._menuShouldFocusOnMount : _this.props.menuProps.shouldFocusOnMount; - if (!currentShouldFocusOnMount) { - ev.preventDefault(); - ev.stopPropagation(); - _this._menuShouldFocusOnMount = true; - _this.forceUpdate(); - } - } - } - }; - _this._onTouchStart = function() { - if (_this._isSplitButton && _this._splitButtonContainer.current && !("onpointerdown" in _this._splitButtonContainer.current)) _this._handleTouchAndPointerEvent(); - }; - _this._onMenuClick = function(ev) { - var _a = _this.props, onMenuClick = _a.onMenuClick, menuProps = _a.menuProps; - if (onMenuClick) onMenuClick(ev, _this.props); - // focus on the container by default when the menu is opened with a click event - // this differentiates from a keyboard interaction triggering the click event - var shouldFocusOnContainer = typeof (menuProps === null || menuProps === void 0 ? void 0 : menuProps.shouldFocusOnContainer) === "boolean" ? menuProps.shouldFocusOnContainer : ev.nativeEvent.pointerType === "mouse"; - if (!ev.defaultPrevented) { - _this._onToggleMenu(shouldFocusOnContainer); - ev.preventDefault(); - ev.stopPropagation(); - } - }; - (0, _utilities.initializeComponentRef)(_this); - _this._async = new (0, _utilities.Async)(_this); - _this._events = new (0, _utilities.EventGroup)(_this); - (0, _utilities.warnConditionallyRequiredProps)(COMPONENT_NAME, props, [ - "menuProps", - "onClick" - ], "split", _this.props.split); - (0, _utilities.warnDeprecations)(COMPONENT_NAME, props, { - rootProps: undefined, - description: "secondaryText", - toggled: "checked" - }); - _this._labelId = (0, _utilities.getId)(); - _this._descriptionId = (0, _utilities.getId)(); - _this._ariaDescriptionId = (0, _utilities.getId)(); - _this.state = { - menuHidden: true - }; - return _this; - } - Object.defineProperty(BaseButton.prototype, "_isSplitButton", { - get: function() { - return !!this.props.menuProps && !!this.props.onClick && this.props.split === true; - }, - enumerable: false, - configurable: true - }); - BaseButton.prototype.render = function() { - var _a; - var _b = this.props, ariaDescription = _b.ariaDescription, ariaLabel = _b.ariaLabel, ariaHidden = _b.ariaHidden, className = _b.className, disabled = _b.disabled, allowDisabledFocus = _b.allowDisabledFocus, primaryDisabled = _b.primaryDisabled, // eslint-disable-next-line deprecation/deprecation - _c = _b.secondaryText, // eslint-disable-next-line deprecation/deprecation - secondaryText = _c === void 0 ? this.props.description : _c, href = _b.href, iconProps = _b.iconProps, menuIconProps = _b.menuIconProps, styles = _b.styles, checked = _b.checked, variantClassName = _b.variantClassName, theme = _b.theme, toggle = _b.toggle, getClassNames = _b.getClassNames, role = _b.role; - var menuHidden = this.state.menuHidden; - // Button is disabled if the whole button (in case of splitButton is disabled) or if the primary action is disabled - var isPrimaryButtonDisabled = disabled || primaryDisabled; - this._classNames = getClassNames ? getClassNames(theme, className, variantClassName, iconProps && iconProps.className, menuIconProps && menuIconProps.className, isPrimaryButtonDisabled, checked, !menuHidden, !!this.props.menuProps, this.props.split, !!allowDisabledFocus) : (0, _baseButtonClassNames.getBaseButtonClassNames)(theme, styles, className, variantClassName, iconProps && iconProps.className, menuIconProps && menuIconProps.className, isPrimaryButtonDisabled, !!this.props.menuProps, checked, !menuHidden, this.props.split); - var _d = this, _ariaDescriptionId = _d._ariaDescriptionId, _labelId = _d._labelId, _descriptionId = _d._descriptionId; - // Anchor tag cannot be disabled hence in disabled state rendering - // anchor button as normal button - var renderAsAnchor = !isPrimaryButtonDisabled && !!href; - var tag = renderAsAnchor ? "a" : "button"; - var nativeProps = (0, _utilities.getNativeProps)(// eslint-disable-next-line deprecation/deprecation - (0, _utilities.assign)(renderAsAnchor ? {} : { - type: "button" - }, this.props.rootProps, this.props), renderAsAnchor ? (0, _utilities.anchorProperties) : (0, _utilities.buttonProperties), [ - "disabled" - ]); - // Check for ariaLabel passed in via Button props, and fall back to aria-label passed in via native props - var resolvedAriaLabel = ariaLabel || nativeProps["aria-label"]; - // Check for ariaDescription, secondaryText or aria-describedby in the native props to determine source of - // aria-describedby. Otherwise default to undefined so property does not appear in output. - var ariaDescribedBy = undefined; - if (ariaDescription) ariaDescribedBy = _ariaDescriptionId; - else if (secondaryText && this.props.onRenderDescription !== (0, _utilities.nullRender)) // for buttons like CompoundButton with a valid onRenderDescription, we need to set an ariaDescribedBy - // for buttons that do not render anything (via nullRender), we should not set an ariaDescribedBy - ariaDescribedBy = _descriptionId; - else if (nativeProps["aria-describedby"]) ariaDescribedBy = nativeProps["aria-describedby"]; - // If an explicit aria-labelledby is given, use that and we're done. - // If any kind of description is given (which will end up as an aria-describedby attribute) - // and no ariaLabel is specified, set the labelledby element. - // Otherwise, the button is labeled implicitly by the descendent text on the button (if it exists). - var ariaLabelledBy = undefined; - if (nativeProps["aria-labelledby"]) ariaLabelledBy = nativeProps["aria-labelledby"]; - else if (ariaDescribedBy && !resolvedAriaLabel) ariaLabelledBy = this._hasText() ? _labelId : undefined; - var dataIsFocusable = this.props["data-is-focusable"] === false || disabled && !allowDisabledFocus || this._isSplitButton ? false : true; - var isCheckboxTypeRole = role === "menuitemcheckbox" || role === "checkbox"; - // if isCheckboxTypeRole, always return a checked value. - // Otherwise only return checked value if toggle is set to true. - // This is because role="checkbox" always needs to have an aria-checked value - // but our checked prop only sets aria-pressed if we mark the button as a toggle="true" - var checkedOrPressedValue = isCheckboxTypeRole ? !!checked : toggle === true ? !!checked : undefined; - var buttonProps = (0, _utilities.assign)(nativeProps, (_a = { - className: this._classNames.root, - // eslint-disable-next-line deprecation/deprecation - ref: this._mergedRef(this.props.elementRef, this._buttonElement), - disabled: isPrimaryButtonDisabled && !allowDisabledFocus, - onKeyDown: this._onKeyDown, - onKeyPress: this._onKeyPress, - onKeyUp: this._onKeyUp, - onMouseDown: this._onMouseDown, - onMouseUp: this._onMouseUp, - onClick: this._onClick, - "aria-label": resolvedAriaLabel, - "aria-labelledby": ariaLabelledBy, - "aria-describedby": ariaDescribedBy, - "aria-disabled": isPrimaryButtonDisabled, - "data-is-focusable": dataIsFocusable - }, // aria-pressed attribute should only be present for toggle buttons - // aria-checked attribute should only be present for toggle buttons with checkbox type role - _a[isCheckboxTypeRole ? "aria-checked" : "aria-pressed"] = checkedOrPressedValue, _a)); - if (ariaHidden) buttonProps["aria-hidden"] = true; - if (this._isSplitButton) return this._onRenderSplitButtonContent(tag, buttonProps); - else if (this.props.menuProps) { - var _e = this.props.menuProps.id, id = _e === void 0 ? "".concat(this._labelId, "-menu") : _e; - (0, _utilities.assign)(buttonProps, { - "aria-expanded": !menuHidden, - "aria-controls": !menuHidden ? id : null, - "aria-haspopup": true - }); - } - return this._onRenderContent(tag, buttonProps); - }; - BaseButton.prototype.componentDidMount = function() { - // For split buttons, touching anywhere in the button should drop the dropdown, which should contain the - // primary action. This gives more hit target space for touch environments. We're setting the onpointerdown here, - // because React does not support Pointer events yet. - if (this._isSplitButton && this._splitButtonContainer.current) { - if ("onpointerdown" in this._splitButtonContainer.current) this._events.on(this._splitButtonContainer.current, "pointerdown", this._onPointerDown, true); - if ("onpointerup" in this._splitButtonContainer.current && this.props.onPointerUp) this._events.on(this._splitButtonContainer.current, "pointerup", this.props.onPointerUp, true); - } - }; - BaseButton.prototype.componentDidUpdate = function(prevProps, prevState) { - // If Button's menu was closed, run onAfterMenuDismiss. - if (this.props.onAfterMenuDismiss && !prevState.menuHidden && this.state.menuHidden) this.props.onAfterMenuDismiss(); - }; - BaseButton.prototype.componentWillUnmount = function() { - this._async.dispose(); - this._events.dispose(); - }; - BaseButton.prototype.focus = function() { - var _a, _b; - if (this._isSplitButton && this._splitButtonContainer.current) { - (0, _utilities.setFocusVisibility)(true, undefined, (_a = this.context) === null || _a === void 0 ? void 0 : _a.registeredProviders); - this._splitButtonContainer.current.focus(); - } else if (this._buttonElement.current) { - (0, _utilities.setFocusVisibility)(true, undefined, (_b = this.context) === null || _b === void 0 ? void 0 : _b.registeredProviders); - this._buttonElement.current.focus(); - } - }; - BaseButton.prototype.dismissMenu = function() { - this._dismissMenu(); - }; - BaseButton.prototype.openMenu = function(shouldFocusOnContainer, shouldFocusOnMount) { - this._openMenu(shouldFocusOnContainer, shouldFocusOnMount); - }; - BaseButton.prototype._onRenderContent = function(tag, buttonProps) { - var _this = this; - var props = this.props; - var Tag = tag; - var menuIconProps = props.menuIconProps, menuProps = props.menuProps, _a = props.onRenderIcon, onRenderIcon = _a === void 0 ? this._onRenderIcon : _a, _b = props.onRenderAriaDescription, onRenderAriaDescription = _b === void 0 ? this._onRenderAriaDescription : _b, _c = props.onRenderChildren, onRenderChildren = _c === void 0 ? this._onRenderChildren : _c, // eslint-disable-next-line deprecation/deprecation - _d = props.onRenderMenu, // eslint-disable-next-line deprecation/deprecation - onRenderMenu = _d === void 0 ? this._onRenderMenu : _d, _e = props.onRenderMenuIcon, onRenderMenuIcon = _e === void 0 ? this._onRenderMenuIcon : _e, disabled = props.disabled; - var keytipProps = props.keytipProps; - if (keytipProps && menuProps) keytipProps = this._getMemoizedMenuButtonKeytipProps(keytipProps); - var Button = function(keytipAttributes) { - return _react.createElement(Tag, (0, _tslib.__assign)({}, buttonProps, keytipAttributes), _react.createElement("span", { - className: _this._classNames.flexContainer, - "data-automationid": "splitbuttonprimary" - }, onRenderIcon(props, _this._onRenderIcon), _this._onRenderTextContents(), onRenderAriaDescription(props, _this._onRenderAriaDescription), onRenderChildren(props, _this._onRenderChildren), !_this._isSplitButton && (menuProps || menuIconProps || _this.props.onRenderMenuIcon) && onRenderMenuIcon(_this.props, _this._onRenderMenuIcon), menuProps && !menuProps.doNotLayer && _this._shouldRenderMenu() && onRenderMenu(_this._getMenuProps(menuProps), _this._onRenderMenu))); - }; - var Content = keytipProps ? // If we're making a split button, we won't put the keytip here - _react.createElement((0, _keytipData.KeytipData), { - keytipProps: !this._isSplitButton ? keytipProps : undefined, - ariaDescribedBy: buttonProps["aria-describedby"], - disabled: disabled - }, function(keytipAttributes) { - return Button(keytipAttributes); - }) : Button(); - if (menuProps && menuProps.doNotLayer) return _react.createElement(_react.Fragment, null, Content, this._shouldRenderMenu() && onRenderMenu(this._getMenuProps(menuProps), this._onRenderMenu)); - return _react.createElement(_react.Fragment, null, Content, _react.createElement((0, _utilities.FocusRects), null)); - }; - /** - * Method to help determine if the menu's component tree should - * be rendered. It takes into account whether the menu is expanded, - * whether it is a persisted menu and whether it has been shown to the user. - */ BaseButton.prototype._shouldRenderMenu = function() { - var menuHidden = this.state.menuHidden; - // eslint-disable-next-line deprecation/deprecation - var _a = this.props, persistMenu = _a.persistMenu, renderPersistedMenuHiddenOnMount = _a.renderPersistedMenuHiddenOnMount; - if (!menuHidden) // Always should render a menu when it is expanded - return true; - else if (persistMenu && (this._renderedVisibleMenu || renderPersistedMenuHiddenOnMount)) // _renderedVisibleMenu ensures that the first rendering of - // the menu happens on-screen, as edge's scrollbar calculations are off if done while hidden. - return true; - return false; - }; - BaseButton.prototype._hasText = function() { - // _onRenderTextContents and _onRenderText do not perform the same checks. Below is parity with what _onRenderText - // used to have before the refactor that introduced this function. _onRenderTextContents does not require props. - // text to be undefined in order for props.children to be used as a fallback. - // Purely a code maintainability/reuse issue, but logged as Issue #4979. - return this.props.text !== null && (this.props.text !== undefined || typeof this.props.children === "string"); - }; - BaseButton.prototype._getMenuProps = function(menuProps) { - var persistMenu = this.props.persistMenu; - var menuHidden = this.state.menuHidden; - // the accessible menu label (accessible name) has a relationship to the button. - // If the menu props do not specify an explicit value for aria-label or aria-labelledBy, - // AND the button has text, we'll set the menu aria-labelledBy to the text element id. - if (!menuProps.ariaLabel && !menuProps.labelElementId && this._hasText()) menuProps = (0, _tslib.__assign)((0, _tslib.__assign)({}, menuProps), { - labelElementId: this._labelId - }); - return (0, _tslib.__assign)((0, _tslib.__assign)({ - id: this._labelId + "-menu", - directionalHint: (0, _directionalHint.DirectionalHint).bottomLeftEdge - }, menuProps), { - shouldFocusOnContainer: this._menuShouldFocusOnContainer, - shouldFocusOnMount: this._menuShouldFocusOnMount, - hidden: persistMenu ? menuHidden : undefined, - className: (0, _utilities.css)("ms-BaseButton-menuhost", menuProps.className), - target: this._isSplitButton ? this._splitButtonContainer.current : this._buttonElement.current, - onDismiss: this._onDismissMenu - }); - }; - BaseButton.prototype._onRenderSplitButtonContent = function(tag, buttonProps) { - var _this = this; - var _a = this.props, _b = _a.styles, styles = _b === void 0 ? {} : _b, disabled = _a.disabled, allowDisabledFocus = _a.allowDisabledFocus, checked = _a.checked, getSplitButtonClassNames = _a.getSplitButtonClassNames, primaryDisabled = _a.primaryDisabled, menuProps = _a.menuProps, toggle = _a.toggle, role = _a.role, primaryActionButtonProps = _a.primaryActionButtonProps; - var keytipProps = this.props.keytipProps; - var menuHidden = this.state.menuHidden; - var classNames = getSplitButtonClassNames ? getSplitButtonClassNames(!!disabled, !menuHidden, !!checked, !!allowDisabledFocus) : styles && (0, _splitButtonClassNames.getSplitButtonClassNames)(styles, !!disabled, !menuHidden, !!checked, !!primaryDisabled); - (0, _utilities.assign)(buttonProps, { - onClick: undefined, - onPointerDown: undefined, - onPointerUp: undefined, - tabIndex: -1, - "data-is-focusable": false - }); - if (keytipProps && menuProps) keytipProps = this._getMemoizedMenuButtonKeytipProps(keytipProps); - var containerProps = (0, _utilities.getNativeProps)(buttonProps, [], [ - "disabled" - ]); - // Add additional props to apply on primary action button - if (primaryActionButtonProps) (0, _utilities.assign)(buttonProps, primaryActionButtonProps); - var SplitButton = function(keytipAttributes) { - return _react.createElement("div", (0, _tslib.__assign)({}, containerProps, { - "data-ktp-target": keytipAttributes ? keytipAttributes["data-ktp-target"] : undefined, - role: role ? role : "button", - "aria-disabled": disabled, - "aria-haspopup": true, - "aria-expanded": !menuHidden, - "aria-pressed": toggle ? !!checked : undefined, - "aria-describedby": (0, _utilities.mergeAriaAttributeValues)(buttonProps["aria-describedby"], keytipAttributes ? keytipAttributes["aria-describedby"] : undefined), - className: classNames && classNames.splitButtonContainer, - onKeyDown: _this._onSplitButtonContainerKeyDown, - onTouchStart: _this._onTouchStart, - ref: _this._splitButtonContainer, - "data-is-focusable": true, - onClick: !disabled && !primaryDisabled ? _this._onSplitButtonPrimaryClick : undefined, - tabIndex: !disabled && !primaryDisabled || allowDisabledFocus ? 0 : undefined, - "aria-roledescription": buttonProps["aria-roledescription"], - onFocusCapture: _this._onSplitContainerFocusCapture - }), _react.createElement("span", { - style: { - display: "flex", - width: "100%" - } - }, _this._onRenderContent(tag, buttonProps), _this._onRenderSplitButtonMenuButton(classNames, keytipAttributes), _this._onRenderSplitButtonDivider(classNames))); - }; - return keytipProps ? _react.createElement((0, _keytipData.KeytipData), { - keytipProps: keytipProps, - disabled: disabled - }, function(keytipAttributes) { - return SplitButton(keytipAttributes); - }) : SplitButton(); - }; - BaseButton.prototype._onRenderSplitButtonDivider = function(classNames) { - if (classNames && classNames.divider) { - var onClick = function(ev) { - ev.stopPropagation(); - }; - return _react.createElement("span", { - className: classNames.divider, - "aria-hidden": true, - onClick: onClick - }); - } - return null; - }; - BaseButton.prototype._onRenderSplitButtonMenuButton = function(classNames, keytipAttributes) { - var _a = this.props, allowDisabledFocus = _a.allowDisabledFocus, checked = _a.checked, disabled = _a.disabled, splitButtonMenuProps = _a.splitButtonMenuProps, splitButtonAriaLabel = _a.splitButtonAriaLabel, primaryDisabled = _a.primaryDisabled; - var menuHidden = this.state.menuHidden; - var menuIconProps = this.props.menuIconProps; - if (menuIconProps === undefined) menuIconProps = { - iconName: "ChevronDown" - }; - var splitButtonProps = (0, _tslib.__assign)((0, _tslib.__assign)({}, splitButtonMenuProps), { - styles: classNames, - checked: checked, - disabled: disabled, - allowDisabledFocus: allowDisabledFocus, - onClick: this._onMenuClick, - menuProps: undefined, - iconProps: (0, _tslib.__assign)((0, _tslib.__assign)({}, menuIconProps), { - className: this._classNames.menuIcon - }), - ariaLabel: splitButtonAriaLabel, - "aria-haspopup": true, - "aria-expanded": !menuHidden, - "data-is-focusable": false - }); - // Add data-ktp-execute-target to the split button if the keytip is defined - return _react.createElement(BaseButton, (0, _tslib.__assign)({}, splitButtonProps, { - "data-ktp-execute-target": keytipAttributes ? keytipAttributes["data-ktp-execute-target"] : keytipAttributes, - onMouseDown: this._onMouseDown, - tabIndex: primaryDisabled && !allowDisabledFocus ? 0 : -1 - })); - }; - BaseButton.prototype._onPointerDown = function(ev) { - var onPointerDown = this.props.onPointerDown; - if (onPointerDown) onPointerDown(ev); - if (ev.pointerType === "touch") { - this._handleTouchAndPointerEvent(); - ev.preventDefault(); - ev.stopImmediatePropagation(); - } - }; - BaseButton.prototype._handleTouchAndPointerEvent = function() { - var _this = this; - // If we already have an existing timeout from a previous touch and pointer event - // cancel that timeout so we can set a new one. - if (this._lastTouchTimeoutId !== undefined) { - this._async.clearTimeout(this._lastTouchTimeoutId); - this._lastTouchTimeoutId = undefined; - } - this._processingTouch = true; - this._lastTouchTimeoutId = this._async.setTimeout(function() { - _this._processingTouch = false; - _this._lastTouchTimeoutId = undefined; - // Touch and pointer events don't focus the button naturally, - // so adding an imperative focus call to guarantee this behavior. - // Only focus the button if a splitbutton menu is not open - if (_this.state.menuHidden) _this.focus(); - }, TouchIdleDelay); - }; - /** - * Returns if the user hits a valid keyboard key to open the menu - * @param ev - the keyboard event - * @returns True if user clicks on custom trigger key if enabled or alt + down arrow if not. False otherwise. - */ BaseButton.prototype._isValidMenuOpenKey = function(ev) { - if (this.props.menuTriggerKeyCode) // eslint-disable-next-line deprecation/deprecation - return ev.which === this.props.menuTriggerKeyCode; - else if (this.props.menuProps) // eslint-disable-next-line deprecation/deprecation - return ev.which === (0, _utilities.KeyCodes).down && (ev.altKey || ev.metaKey); - // Note: When enter is pressed, we will let the event continue to propagate - // to trigger the onClick event on the button - return false; - }; - BaseButton.defaultProps = { - baseClassName: "ms-Button", - styles: {}, - split: false - }; - // needed to access registeredProviders when manually setting focus visibility - BaseButton.contextType = (0, _utilities.FocusRectsContext); - return BaseButton; -}(_react.Component); - -},{"tslib":"01Tx1","react":"8ePka","../../Utilities":"d0PNn","../../Icon":"8rJ2a","../../common/DirectionalHint":"gozug","../../ContextualMenu":"5W7tr","./BaseButton.classNames":"h7V1v","./SplitButton/SplitButton.classNames":"1z3em","../../KeytipData":"glr08","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"01Tx1":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "__extends", ()=>__extends); -parcelHelpers.export(exports, "__assign", ()=>__assign); -parcelHelpers.export(exports, "__rest", ()=>__rest); -parcelHelpers.export(exports, "__decorate", ()=>__decorate); -parcelHelpers.export(exports, "__param", ()=>__param); -parcelHelpers.export(exports, "__esDecorate", ()=>__esDecorate); -parcelHelpers.export(exports, "__runInitializers", ()=>__runInitializers); -parcelHelpers.export(exports, "__propKey", ()=>__propKey); -parcelHelpers.export(exports, "__setFunctionName", ()=>__setFunctionName); -parcelHelpers.export(exports, "__metadata", ()=>__metadata); -parcelHelpers.export(exports, "__awaiter", ()=>__awaiter); -parcelHelpers.export(exports, "__generator", ()=>__generator); -parcelHelpers.export(exports, "__createBinding", ()=>__createBinding); -parcelHelpers.export(exports, "__exportStar", ()=>__exportStar); -parcelHelpers.export(exports, "__values", ()=>__values); -parcelHelpers.export(exports, "__read", ()=>__read); -/** @deprecated */ parcelHelpers.export(exports, "__spread", ()=>__spread); -/** @deprecated */ parcelHelpers.export(exports, "__spreadArrays", ()=>__spreadArrays); -parcelHelpers.export(exports, "__spreadArray", ()=>__spreadArray); -parcelHelpers.export(exports, "__await", ()=>__await); -parcelHelpers.export(exports, "__asyncGenerator", ()=>__asyncGenerator); -parcelHelpers.export(exports, "__asyncDelegator", ()=>__asyncDelegator); -parcelHelpers.export(exports, "__asyncValues", ()=>__asyncValues); -parcelHelpers.export(exports, "__makeTemplateObject", ()=>__makeTemplateObject); -parcelHelpers.export(exports, "__importStar", ()=>__importStar); -parcelHelpers.export(exports, "__importDefault", ()=>__importDefault); -parcelHelpers.export(exports, "__classPrivateFieldGet", ()=>__classPrivateFieldGet); -parcelHelpers.export(exports, "__classPrivateFieldSet", ()=>__classPrivateFieldSet); -parcelHelpers.export(exports, "__classPrivateFieldIn", ()=>__classPrivateFieldIn); -/****************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || ({ - __proto__: [] - }) instanceof Array && function(d, b) { - d.__proto__ = b; - } || function(d, b) { - for(var p in b)if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; - }; - return extendStatics(d, b); -}; -function __extends(d, b) { - if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} -var __assign = function() { - __assign = Object.assign || function __assign(t) { - for(var s, i = 1, n = arguments.length; i < n; i++){ - s = arguments[i]; - for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -function __rest(s, e) { - var t = {}; - for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") { - for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -} -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} -function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} -function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { - function accept(f) { - if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); - return f; - } - var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; - var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; - var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); - var _, done = false; - for(var i = decorators.length - 1; i >= 0; i--){ - var context = {}; - for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p]; - for(var p in contextIn.access)context.access[p] = contextIn.access[p]; - context.addInitializer = function(f) { - if (done) throw new TypeError("Cannot add initializers after decoration has completed"); - extraInitializers.push(accept(f || null)); - }; - var result = (0, decorators[i])(kind === "accessor" ? { - get: descriptor.get, - set: descriptor.set - } : descriptor[key], context); - if (kind === "accessor") { - if (result === void 0) continue; - if (result === null || typeof result !== "object") throw new TypeError("Object expected"); - if (_ = accept(result.get)) descriptor.get = _; - if (_ = accept(result.set)) descriptor.set = _; - if (_ = accept(result.init)) initializers.unshift(_); - } else if (_ = accept(result)) { - if (kind === "field") initializers.unshift(_); - else descriptor[key] = _; - } - } - if (target) Object.defineProperty(target, contextIn.name, descriptor); - done = true; -} -function __runInitializers(thisArg, initializers, value) { - var useValue = arguments.length > 2; - for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); - return useValue ? value : void 0; -} -function __propKey(x) { - return typeof x === "symbol" ? x : "".concat(x); -} -function __setFunctionName(f, name, prefix) { - if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; - return Object.defineProperty(f, "name", { - configurable: true, - value: prefix ? "".concat(prefix, " ", name) : name - }); -} -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} -function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} -function __generator(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, f, y, t, g; - return g = { - next: verb(0), - "throw": verb(1), - "return": verb(2) - }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([ - n, - v - ]); - }; - } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while(g && (g = 0, op[0] && (_ = 0)), _)try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [ - op[0] & 2, - t.value - ]; - switch(op[0]){ - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { - value: op[1], - done: false - }; - case 5: - _.label++; - y = op[1]; - op = [ - 0 - ]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [ - 6, - e - ]; - y = 0; - } finally{ - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { - value: op[0] ? op[1] : void 0, - done: true - }; - } -} -var __createBinding = Object.create ? function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = { - enumerable: true, - get: function() { - return m[k]; - } - }; - Object.defineProperty(o, k2, desc); -} : function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}; -function __exportStar(m, o) { - for(var p in m)if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); -} -function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function() { - if (o && i >= o.length) o = void 0; - return { - value: o && o[i++], - done: !o - }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -} -function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while((n === void 0 || n-- > 0) && !(r = i.next()).done)ar.push(r.value); - } catch (error) { - e = { - error: error - }; - } finally{ - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } finally{ - if (e) throw e.error; - } - } - return ar; -} -function __spread() { - for(var ar = [], i = 0; i < arguments.length; i++)ar = ar.concat(__read(arguments[i])); - return ar; -} -function __spreadArrays() { - for(var s = 0, i = 0, il = arguments.length; i < il; i++)s += arguments[i].length; - for(var r = Array(s), k = 0, i = 0; i < il; i++)for(var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)r[k] = a[j]; - return r; -} -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) { - for(var i = 0, l = from.length, ar; i < l; i++)if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} -function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) i[n] = function(v) { - return new Promise(function(a, b) { - q.push([ - n, - v, - a, - b - ]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); - } -} -function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { - value: __await(o[n](v)), - done: false - } : f ? f(v) : v; - } : f; - } -} -function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v) { - resolve({ - value: v, - done: d - }); - }, reject); - } -} -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) Object.defineProperty(cooked, "raw", { - value: raw - }); - else cooked.raw = raw; - return cooked; -} -var __setModuleDefault = Object.create ? function(o, v) { - Object.defineProperty(o, "default", { - enumerable: true, - value: v - }); -} : function(o, v) { - o["default"] = v; -}; -function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for(var k in mod)if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - } - __setModuleDefault(result, mod); - return result; -} -function __importDefault(mod) { - return mod && mod.__esModule ? mod : { - default: mod - }; -} -function __classPrivateFieldGet(receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -} -function __classPrivateFieldSet(receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; -} -function __classPrivateFieldIn(state, receiver) { - if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object"); - return typeof state === "function" ? receiver === state : state.has(receiver); -} -exports.default = { - __extends, - __assign, - __rest, - __decorate, - __param, - __metadata, - __awaiter, - __generator, - __createBinding, - __exportStar, - __values, - __read, - __spread, - __spreadArrays, - __spreadArray, - __await, - __asyncGenerator, - __asyncDelegator, - __asyncValues, - __makeTemplateObject, - __importStar, - __importDefault, - __classPrivateFieldGet, - __classPrivateFieldSet, - __classPrivateFieldIn -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"d0PNn":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Async", ()=>(0, _utilities.Async)); -parcelHelpers.export(exports, "AutoScroll", ()=>(0, _utilities.AutoScroll)); -parcelHelpers.export(exports, "BaseComponent", ()=>(0, _utilities.BaseComponent)); -parcelHelpers.export(exports, "Customizations", ()=>(0, _utilities.Customizations)); -parcelHelpers.export(exports, "Customizer", ()=>(0, _utilities.Customizer)); -parcelHelpers.export(exports, "CustomizerContext", ()=>(0, _utilities.CustomizerContext)); -parcelHelpers.export(exports, "DATA_IS_SCROLLABLE_ATTRIBUTE", ()=>(0, _utilities.DATA_IS_SCROLLABLE_ATTRIBUTE)); -parcelHelpers.export(exports, "DATA_PORTAL_ATTRIBUTE", ()=>(0, _utilities.DATA_PORTAL_ATTRIBUTE)); -parcelHelpers.export(exports, "DelayedRender", ()=>(0, _utilities.DelayedRender)); -parcelHelpers.export(exports, "EventGroup", ()=>(0, _utilities.EventGroup)); -parcelHelpers.export(exports, "FabricPerformance", ()=>(0, _utilities.FabricPerformance)); -parcelHelpers.export(exports, "FocusRects", ()=>(0, _utilities.FocusRects)); -parcelHelpers.export(exports, "FocusRectsContext", ()=>(0, _utilities.FocusRectsContext)); -parcelHelpers.export(exports, "FocusRectsProvider", ()=>(0, _utilities.FocusRectsProvider)); -parcelHelpers.export(exports, "GlobalSettings", ()=>(0, _utilities.GlobalSettings)); -parcelHelpers.export(exports, "IsFocusVisibleClassName", ()=>(0, _utilities.IsFocusVisibleClassName)); -parcelHelpers.export(exports, "KeyCodes", ()=>(0, _utilities.KeyCodes)); -parcelHelpers.export(exports, "Rectangle", ()=>(0, _utilities.Rectangle)); -parcelHelpers.export(exports, "SELECTION_CHANGE", ()=>(0, _utilities.SELECTION_CHANGE)); -parcelHelpers.export(exports, "Selection", ()=>(0, _utilities.Selection)); -parcelHelpers.export(exports, "SelectionDirection", ()=>(0, _utilities.SelectionDirection)); -parcelHelpers.export(exports, "SelectionMode", ()=>(0, _utilities.SelectionMode)); -parcelHelpers.export(exports, "addDirectionalKeyCode", ()=>(0, _utilities.addDirectionalKeyCode)); -parcelHelpers.export(exports, "addElementAtIndex", ()=>(0, _utilities.addElementAtIndex)); -parcelHelpers.export(exports, "allowOverscrollOnElement", ()=>(0, _utilities.allowOverscrollOnElement)); -parcelHelpers.export(exports, "allowScrollOnElement", ()=>(0, _utilities.allowScrollOnElement)); -parcelHelpers.export(exports, "anchorProperties", ()=>(0, _utilities.anchorProperties)); -parcelHelpers.export(exports, "appendFunction", ()=>(0, _utilities.appendFunction)); -parcelHelpers.export(exports, "arraysEqual", ()=>(0, _utilities.arraysEqual)); -parcelHelpers.export(exports, "asAsync", ()=>(0, _utilities.asAsync)); -parcelHelpers.export(exports, "assertNever", ()=>(0, _utilities.assertNever)); -parcelHelpers.export(exports, "assign", ()=>(0, _utilities.assign)); -parcelHelpers.export(exports, "audioProperties", ()=>(0, _utilities.audioProperties)); -parcelHelpers.export(exports, "baseElementEvents", ()=>(0, _utilities.baseElementEvents)); -parcelHelpers.export(exports, "baseElementProperties", ()=>(0, _utilities.baseElementProperties)); -parcelHelpers.export(exports, "buttonProperties", ()=>(0, _utilities.buttonProperties)); -parcelHelpers.export(exports, "calculatePrecision", ()=>(0, _utilities.calculatePrecision)); -parcelHelpers.export(exports, "canUseDOM", ()=>(0, _utilities.canUseDOM)); -parcelHelpers.export(exports, "classNamesFunction", ()=>(0, _utilities.classNamesFunction)); -parcelHelpers.export(exports, "colGroupProperties", ()=>(0, _utilities.colGroupProperties)); -parcelHelpers.export(exports, "colProperties", ()=>(0, _utilities.colProperties)); -parcelHelpers.export(exports, "composeComponentAs", ()=>(0, _utilities.composeComponentAs)); -parcelHelpers.export(exports, "composeRenderFunction", ()=>(0, _utilities.composeRenderFunction)); -parcelHelpers.export(exports, "createArray", ()=>(0, _utilities.createArray)); -parcelHelpers.export(exports, "createMemoizer", ()=>(0, _utilities.createMemoizer)); -parcelHelpers.export(exports, "createMergedRef", ()=>(0, _utilities.createMergedRef)); -parcelHelpers.export(exports, "css", ()=>(0, _utilities.css)); -parcelHelpers.export(exports, "customizable", ()=>(0, _utilities.customizable)); -parcelHelpers.export(exports, "disableBodyScroll", ()=>(0, _utilities.disableBodyScroll)); -parcelHelpers.export(exports, "divProperties", ()=>(0, _utilities.divProperties)); -parcelHelpers.export(exports, "doesElementContainFocus", ()=>(0, _utilities.doesElementContainFocus)); -parcelHelpers.export(exports, "elementContains", ()=>(0, _utilities.elementContains)); -parcelHelpers.export(exports, "elementContainsAttribute", ()=>(0, _utilities.elementContainsAttribute)); -parcelHelpers.export(exports, "enableBodyScroll", ()=>(0, _utilities.enableBodyScroll)); -parcelHelpers.export(exports, "extendComponent", ()=>(0, _utilities.extendComponent)); -parcelHelpers.export(exports, "filteredAssign", ()=>(0, _utilities.filteredAssign)); -parcelHelpers.export(exports, "find", ()=>(0, _utilities.find)); -parcelHelpers.export(exports, "findElementRecursive", ()=>(0, _utilities.findElementRecursive)); -parcelHelpers.export(exports, "findIndex", ()=>(0, _utilities.findIndex)); -parcelHelpers.export(exports, "findScrollableParent", ()=>(0, _utilities.findScrollableParent)); -parcelHelpers.export(exports, "fitContentToBounds", ()=>(0, _utilities.fitContentToBounds)); -parcelHelpers.export(exports, "flatten", ()=>(0, _utilities.flatten)); -parcelHelpers.export(exports, "focusAsync", ()=>(0, _utilities.focusAsync)); -parcelHelpers.export(exports, "focusFirstChild", ()=>(0, _utilities.focusFirstChild)); -parcelHelpers.export(exports, "formProperties", ()=>(0, _utilities.formProperties)); -parcelHelpers.export(exports, "format", ()=>(0, _utilities.format)); -parcelHelpers.export(exports, "getChildren", ()=>(0, _utilities.getChildren)); -parcelHelpers.export(exports, "getDistanceBetweenPoints", ()=>(0, _utilities.getDistanceBetweenPoints)); -parcelHelpers.export(exports, "getDocument", ()=>(0, _utilities.getDocument)); -parcelHelpers.export(exports, "getElementIndexPath", ()=>(0, _utilities.getElementIndexPath)); -parcelHelpers.export(exports, "getFirstFocusable", ()=>(0, _utilities.getFirstFocusable)); -parcelHelpers.export(exports, "getFirstTabbable", ()=>(0, _utilities.getFirstTabbable)); -parcelHelpers.export(exports, "getFirstVisibleElementFromSelector", ()=>(0, _utilities.getFirstVisibleElementFromSelector)); -parcelHelpers.export(exports, "getFocusableByIndexPath", ()=>(0, _utilities.getFocusableByIndexPath)); -parcelHelpers.export(exports, "getId", ()=>(0, _utilities.getId)); -parcelHelpers.export(exports, "getInitials", ()=>(0, _utilities.getInitials)); -parcelHelpers.export(exports, "getLanguage", ()=>(0, _utilities.getLanguage)); -parcelHelpers.export(exports, "getLastFocusable", ()=>(0, _utilities.getLastFocusable)); -parcelHelpers.export(exports, "getLastTabbable", ()=>(0, _utilities.getLastTabbable)); -parcelHelpers.export(exports, "getNativeElementProps", ()=>(0, _utilities.getNativeElementProps)); -parcelHelpers.export(exports, "getNativeProps", ()=>(0, _utilities.getNativeProps)); -parcelHelpers.export(exports, "getNextElement", ()=>(0, _utilities.getNextElement)); -parcelHelpers.export(exports, "getParent", ()=>(0, _utilities.getParent)); -parcelHelpers.export(exports, "getPreviousElement", ()=>(0, _utilities.getPreviousElement)); -parcelHelpers.export(exports, "getPropsWithDefaults", ()=>(0, _utilities.getPropsWithDefaults)); -parcelHelpers.export(exports, "getRTL", ()=>(0, _utilities.getRTL)); -parcelHelpers.export(exports, "getRTLSafeKeyCode", ()=>(0, _utilities.getRTLSafeKeyCode)); -parcelHelpers.export(exports, "getRect", ()=>(0, _utilities.getRect)); -parcelHelpers.export(exports, "getResourceUrl", ()=>(0, _utilities.getResourceUrl)); -parcelHelpers.export(exports, "getScrollbarWidth", ()=>(0, _utilities.getScrollbarWidth)); -parcelHelpers.export(exports, "getVirtualParent", ()=>(0, _utilities.getVirtualParent)); -parcelHelpers.export(exports, "getWindow", ()=>(0, _utilities.getWindow)); -parcelHelpers.export(exports, "hasHorizontalOverflow", ()=>(0, _utilities.hasHorizontalOverflow)); -parcelHelpers.export(exports, "hasOverflow", ()=>(0, _utilities.hasOverflow)); -parcelHelpers.export(exports, "hasVerticalOverflow", ()=>(0, _utilities.hasVerticalOverflow)); -parcelHelpers.export(exports, "hoistMethods", ()=>(0, _utilities.hoistMethods)); -parcelHelpers.export(exports, "hoistStatics", ()=>(0, _utilities.hoistStatics)); -parcelHelpers.export(exports, "htmlElementProperties", ()=>(0, _utilities.htmlElementProperties)); -parcelHelpers.export(exports, "iframeProperties", ()=>(0, _utilities.iframeProperties)); -parcelHelpers.export(exports, "imageProperties", ()=>(0, _utilities.imageProperties)); -parcelHelpers.export(exports, "imgProperties", ()=>(0, _utilities.imgProperties)); -parcelHelpers.export(exports, "initializeComponentRef", ()=>(0, _utilities.initializeComponentRef)); -parcelHelpers.export(exports, "initializeFocusRects", ()=>(0, _utilities.initializeFocusRects)); -parcelHelpers.export(exports, "inputProperties", ()=>(0, _utilities.inputProperties)); -parcelHelpers.export(exports, "isControlled", ()=>(0, _utilities.isControlled)); -parcelHelpers.export(exports, "isDirectionalKeyCode", ()=>(0, _utilities.isDirectionalKeyCode)); -parcelHelpers.export(exports, "isElementFocusSubZone", ()=>(0, _utilities.isElementFocusSubZone)); -parcelHelpers.export(exports, "isElementFocusZone", ()=>(0, _utilities.isElementFocusZone)); -parcelHelpers.export(exports, "isElementTabbable", ()=>(0, _utilities.isElementTabbable)); -parcelHelpers.export(exports, "isElementVisible", ()=>(0, _utilities.isElementVisible)); -parcelHelpers.export(exports, "isElementVisibleAndNotHidden", ()=>(0, _utilities.isElementVisibleAndNotHidden)); -parcelHelpers.export(exports, "isIE11", ()=>(0, _utilities.isIE11)); -parcelHelpers.export(exports, "isIOS", ()=>(0, _utilities.isIOS)); -parcelHelpers.export(exports, "isMac", ()=>(0, _utilities.isMac)); -parcelHelpers.export(exports, "isVirtualElement", ()=>(0, _utilities.isVirtualElement)); -parcelHelpers.export(exports, "labelProperties", ()=>(0, _utilities.labelProperties)); -parcelHelpers.export(exports, "liProperties", ()=>(0, _utilities.liProperties)); -parcelHelpers.export(exports, "mapEnumByName", ()=>(0, _utilities.mapEnumByName)); -parcelHelpers.export(exports, "memoize", ()=>(0, _utilities.memoize)); -parcelHelpers.export(exports, "memoizeFunction", ()=>(0, _utilities.memoizeFunction)); -parcelHelpers.export(exports, "merge", ()=>(0, _utilities.merge)); -parcelHelpers.export(exports, "mergeAriaAttributeValues", ()=>(0, _utilities.mergeAriaAttributeValues)); -parcelHelpers.export(exports, "mergeCustomizations", ()=>(0, _utilities.mergeCustomizations)); -parcelHelpers.export(exports, "mergeScopedSettings", ()=>(0, _utilities.mergeScopedSettings)); -parcelHelpers.export(exports, "mergeSettings", ()=>(0, _utilities.mergeSettings)); -parcelHelpers.export(exports, "modalize", ()=>(0, _utilities.modalize)); -parcelHelpers.export(exports, "nullRender", ()=>(0, _utilities.nullRender)); -parcelHelpers.export(exports, "olProperties", ()=>(0, _utilities.olProperties)); -parcelHelpers.export(exports, "omit", ()=>(0, _utilities.omit)); -parcelHelpers.export(exports, "on", ()=>(0, _utilities.on)); -parcelHelpers.export(exports, "optionProperties", ()=>(0, _utilities.optionProperties)); -parcelHelpers.export(exports, "portalContainsElement", ()=>(0, _utilities.portalContainsElement)); -parcelHelpers.export(exports, "precisionRound", ()=>(0, _utilities.precisionRound)); -parcelHelpers.export(exports, "raiseClick", ()=>(0, _utilities.raiseClick)); -parcelHelpers.export(exports, "removeDirectionalKeyCode", ()=>(0, _utilities.removeDirectionalKeyCode)); -parcelHelpers.export(exports, "removeIndex", ()=>(0, _utilities.removeIndex)); -parcelHelpers.export(exports, "replaceElement", ()=>(0, _utilities.replaceElement)); -parcelHelpers.export(exports, "resetControlledWarnings", ()=>(0, _utilities.resetControlledWarnings)); -parcelHelpers.export(exports, "resetIds", ()=>(0, _utilities.resetIds)); -parcelHelpers.export(exports, "resetMemoizations", ()=>(0, _utilities.resetMemoizations)); -parcelHelpers.export(exports, "safeRequestAnimationFrame", ()=>(0, _utilities.safeRequestAnimationFrame)); -parcelHelpers.export(exports, "safeSetTimeout", ()=>(0, _utilities.safeSetTimeout)); -parcelHelpers.export(exports, "selectProperties", ()=>(0, _utilities.selectProperties)); -parcelHelpers.export(exports, "setBaseUrl", ()=>(0, _utilities.setBaseUrl)); -parcelHelpers.export(exports, "setFocusVisibility", ()=>(0, _utilities.setFocusVisibility)); -parcelHelpers.export(exports, "setLanguage", ()=>(0, _utilities.setLanguage)); -parcelHelpers.export(exports, "setMemoizeWeakMap", ()=>(0, _utilities.setMemoizeWeakMap)); -parcelHelpers.export(exports, "setPortalAttribute", ()=>(0, _utilities.setPortalAttribute)); -parcelHelpers.export(exports, "setRTL", ()=>(0, _utilities.setRTL)); -parcelHelpers.export(exports, "setSSR", ()=>(0, _utilities.setSSR)); -parcelHelpers.export(exports, "setVirtualParent", ()=>(0, _utilities.setVirtualParent)); -parcelHelpers.export(exports, "setWarningCallback", ()=>(0, _utilities.setWarningCallback)); -parcelHelpers.export(exports, "shallowCompare", ()=>(0, _utilities.shallowCompare)); -parcelHelpers.export(exports, "shouldWrapFocus", ()=>(0, _utilities.shouldWrapFocus)); -parcelHelpers.export(exports, "styled", ()=>(0, _utilities.styled)); -parcelHelpers.export(exports, "tableProperties", ()=>(0, _utilities.tableProperties)); -parcelHelpers.export(exports, "tdProperties", ()=>(0, _utilities.tdProperties)); -parcelHelpers.export(exports, "textAreaProperties", ()=>(0, _utilities.textAreaProperties)); -parcelHelpers.export(exports, "thProperties", ()=>(0, _utilities.thProperties)); -parcelHelpers.export(exports, "toMatrix", ()=>(0, _utilities.toMatrix)); -parcelHelpers.export(exports, "trProperties", ()=>(0, _utilities.trProperties)); -parcelHelpers.export(exports, "unhoistMethods", ()=>(0, _utilities.unhoistMethods)); -parcelHelpers.export(exports, "useCustomizationSettings", ()=>(0, _utilities.useCustomizationSettings)); -parcelHelpers.export(exports, "useFocusRects", ()=>(0, _utilities.useFocusRects)); -parcelHelpers.export(exports, "values", ()=>(0, _utilities.values)); -parcelHelpers.export(exports, "videoProperties", ()=>(0, _utilities.videoProperties)); -parcelHelpers.export(exports, "warn", ()=>(0, _utilities.warn)); -parcelHelpers.export(exports, "warnConditionallyRequiredProps", ()=>(0, _utilities.warnConditionallyRequiredProps)); -parcelHelpers.export(exports, "warnControlledUsage", ()=>(0, _utilities.warnControlledUsage)); -parcelHelpers.export(exports, "warnDeprecations", ()=>(0, _utilities.warnDeprecations)); -parcelHelpers.export(exports, "warnMutuallyExclusive", ()=>(0, _utilities.warnMutuallyExclusive)); -var _version = require("./version"); -var _utilities = require("@fluentui/utilities"); - -},{"./version":"7g0ZP","@fluentui/utilities":"6wnm3","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7g0ZP":[function(require,module,exports) { -// Do not modify this file; it is generated as part of publish. -// The checked in version is a placeholder only and will not be updated. -var _setVersion = require("@fluentui/set-version"); -(0, _setVersion.setVersion)("@fluentui/react", "8.110.3"); - -},{"@fluentui/set-version":"aMFYG"}],"aMFYG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "setVersion", ()=>(0, _setVersion.setVersion)); -var _setVersion = require("./setVersion"); -(0, _setVersion.setVersion)("@fluentui/set-version", "6.0.0"); - -},{"./setVersion":"aEkSq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aEkSq":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "setVersion", ()=>setVersion); -// A packages cache that makes sure that we don't inject the same packageName twice in the same bundle - -// this cache is local to the module closure inside this bundle -var packagesCache = {}; -// Cache access to window to avoid IE11 memory leak. -var _win = undefined; -try { - _win = window; -} catch (e) { -/* no-op */ } -function setVersion(packageName, packageVersion) { - if (typeof _win !== "undefined") { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var packages = _win.__packages__ = _win.__packages__ || {}; - // We allow either the global packages or local packages caches to invalidate so testing can - // just clear the global to set this state - if (!packages[packageName] || !packagesCache[packageName]) { - packagesCache[packageName] = packageVersion; - var versions = packages[packageName] = packages[packageName] || []; - versions.push(packageVersion); +parcelHelpers.export(exports, "default", ()=>function(s) { + out: for(var n = s.length, i = 1, i0 = -1, i1; i < n; ++i)switch(s[i]){ + case ".": + i0 = i1 = i; + break; + case "0": + if (i0 === 0) i0 = i; + i1 = i; + break; + default: + if (!+s[i]) break out; + if (i0 > 0) i0 = 0; + break; } - } -} + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; + }); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6wnm3":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dfzgV":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Async", ()=>(0, _async.Async)); -parcelHelpers.export(exports, "AutoScroll", ()=>(0, _autoScroll.AutoScroll)); -parcelHelpers.export(exports, "BaseComponent", ()=>(0, _baseComponent.BaseComponent)); -parcelHelpers.export(exports, "nullRender", ()=>(0, _baseComponent.nullRender)); -parcelHelpers.export(exports, "DelayedRender", ()=>(0, _delayedRender.DelayedRender)); -parcelHelpers.export(exports, "EventGroup", ()=>(0, _eventGroup.EventGroup)); -parcelHelpers.export(exports, "FabricPerformance", ()=>(0, _fabricPerformance.FabricPerformance)); -parcelHelpers.export(exports, "GlobalSettings", ()=>(0, _globalSettings.GlobalSettings)); -parcelHelpers.export(exports, "KeyCodes", ()=>(0, _keyCodes.KeyCodes)); -parcelHelpers.export(exports, "Rectangle", ()=>(0, _rectangle.Rectangle)); -parcelHelpers.export(exports, "appendFunction", ()=>(0, _appendFunction.appendFunction)); -parcelHelpers.export(exports, "mergeAriaAttributeValues", ()=>(0, _aria.mergeAriaAttributeValues)); -parcelHelpers.export(exports, "addElementAtIndex", ()=>(0, _array.addElementAtIndex)); -parcelHelpers.export(exports, "arraysEqual", ()=>(0, _array.arraysEqual)); -parcelHelpers.export(exports, "createArray", ()=>(0, _array.createArray)); -parcelHelpers.export(exports, "find", ()=>(0, _array.find)); -parcelHelpers.export(exports, "findIndex", ()=>(0, _array.findIndex)); -parcelHelpers.export(exports, "flatten", ()=>(0, _array.flatten)); -parcelHelpers.export(exports, "removeIndex", ()=>(0, _array.removeIndex)); -parcelHelpers.export(exports, "replaceElement", ()=>(0, _array.replaceElement)); -parcelHelpers.export(exports, "toMatrix", ()=>(0, _array.toMatrix)); -parcelHelpers.export(exports, "asAsync", ()=>(0, _asAsync.asAsync)); -parcelHelpers.export(exports, "assertNever", ()=>(0, _assertNever.assertNever)); -parcelHelpers.export(exports, "classNamesFunction", ()=>(0, _classNamesFunction.classNamesFunction)); -parcelHelpers.export(exports, "composeComponentAs", ()=>(0, _composeComponentAs.composeComponentAs)); -parcelHelpers.export(exports, "isControlled", ()=>(0, _controlled.isControlled)); -parcelHelpers.export(exports, "css", ()=>(0, _css.css)); -parcelHelpers.export(exports, "Customizations", ()=>(0, _customizations.Customizations)); -parcelHelpers.export(exports, "Customizer", ()=>(0, _customizer.Customizer)); -parcelHelpers.export(exports, "CustomizerContext", ()=>(0, _customizerContext.CustomizerContext)); -parcelHelpers.export(exports, "customizable", ()=>(0, _customizable.customizable)); -parcelHelpers.export(exports, "useCustomizationSettings", ()=>(0, _useCustomizationSettings.useCustomizationSettings)); -parcelHelpers.export(exports, "mergeCustomizations", ()=>(0, _mergeCustomizations.mergeCustomizations)); -parcelHelpers.export(exports, "mergeScopedSettings", ()=>(0, _mergeSettings.mergeScopedSettings)); -parcelHelpers.export(exports, "mergeSettings", ()=>(0, _mergeSettings.mergeSettings)); -parcelHelpers.export(exports, "DATA_PORTAL_ATTRIBUTE", ()=>(0, _dom.DATA_PORTAL_ATTRIBUTE)); -parcelHelpers.export(exports, "elementContains", ()=>(0, _dom.elementContains)); -parcelHelpers.export(exports, "elementContainsAttribute", ()=>(0, _dom.elementContainsAttribute)); -parcelHelpers.export(exports, "findElementRecursive", ()=>(0, _dom.findElementRecursive)); -parcelHelpers.export(exports, "getChildren", ()=>(0, _dom.getChildren)); -parcelHelpers.export(exports, "getDocument", ()=>(0, _dom.getDocument)); -parcelHelpers.export(exports, "getFirstVisibleElementFromSelector", ()=>(0, _dom.getFirstVisibleElementFromSelector)); -parcelHelpers.export(exports, "getParent", ()=>(0, _dom.getParent)); -parcelHelpers.export(exports, "getRect", ()=>(0, _dom.getRect)); -parcelHelpers.export(exports, "getVirtualParent", ()=>(0, _dom.getVirtualParent)); -parcelHelpers.export(exports, "getWindow", ()=>(0, _dom.getWindow)); -parcelHelpers.export(exports, "isVirtualElement", ()=>(0, _dom.isVirtualElement)); -parcelHelpers.export(exports, "on", ()=>(0, _dom.on)); -parcelHelpers.export(exports, "portalContainsElement", ()=>(0, _dom.portalContainsElement)); -parcelHelpers.export(exports, "raiseClick", ()=>(0, _dom.raiseClick)); -parcelHelpers.export(exports, "setPortalAttribute", ()=>(0, _dom.setPortalAttribute)); -parcelHelpers.export(exports, "setVirtualParent", ()=>(0, _dom.setVirtualParent)); -parcelHelpers.export(exports, "extendComponent", ()=>(0, _extendComponent.extendComponent)); -parcelHelpers.export(exports, "doesElementContainFocus", ()=>(0, _focus.doesElementContainFocus)); -parcelHelpers.export(exports, "focusAsync", ()=>(0, _focus.focusAsync)); -parcelHelpers.export(exports, "focusFirstChild", ()=>(0, _focus.focusFirstChild)); -parcelHelpers.export(exports, "getElementIndexPath", ()=>(0, _focus.getElementIndexPath)); -parcelHelpers.export(exports, "getFirstFocusable", ()=>(0, _focus.getFirstFocusable)); -parcelHelpers.export(exports, "getFirstTabbable", ()=>(0, _focus.getFirstTabbable)); -parcelHelpers.export(exports, "getFocusableByIndexPath", ()=>(0, _focus.getFocusableByIndexPath)); -parcelHelpers.export(exports, "getLastFocusable", ()=>(0, _focus.getLastFocusable)); -parcelHelpers.export(exports, "getLastTabbable", ()=>(0, _focus.getLastTabbable)); -parcelHelpers.export(exports, "getNextElement", ()=>(0, _focus.getNextElement)); -parcelHelpers.export(exports, "getPreviousElement", ()=>(0, _focus.getPreviousElement)); -parcelHelpers.export(exports, "isElementFocusSubZone", ()=>(0, _focus.isElementFocusSubZone)); -parcelHelpers.export(exports, "isElementFocusZone", ()=>(0, _focus.isElementFocusZone)); -parcelHelpers.export(exports, "isElementTabbable", ()=>(0, _focus.isElementTabbable)); -parcelHelpers.export(exports, "isElementVisible", ()=>(0, _focus.isElementVisible)); -parcelHelpers.export(exports, "isElementVisibleAndNotHidden", ()=>(0, _focus.isElementVisibleAndNotHidden)); -parcelHelpers.export(exports, "shouldWrapFocus", ()=>(0, _focus.shouldWrapFocus)); -parcelHelpers.export(exports, "getId", ()=>(0, _getId.getId)); -parcelHelpers.export(exports, "resetIds", ()=>(0, _getId.resetIds)); -parcelHelpers.export(exports, "getNativeElementProps", ()=>(0, _getNativeElementProps.getNativeElementProps)); -parcelHelpers.export(exports, "hoistMethods", ()=>(0, _hoist.hoistMethods)); -parcelHelpers.export(exports, "unhoistMethods", ()=>(0, _hoist.unhoistMethods)); -parcelHelpers.export(exports, "hoistStatics", ()=>(0, _hoistStatics.hoistStatics)); -parcelHelpers.export(exports, "initializeComponentRef", ()=>(0, _initializeComponentRef.initializeComponentRef)); -parcelHelpers.export(exports, "initializeFocusRects", ()=>(0, _initializeFocusRects.initializeFocusRects)); -parcelHelpers.export(exports, "FocusRectsProvider", ()=>(0, _focusRectsProvider.FocusRectsProvider)); -parcelHelpers.export(exports, "FocusRects", ()=>(0, _useFocusRects.FocusRects)); -parcelHelpers.export(exports, "FocusRectsContext", ()=>(0, _useFocusRects.FocusRectsContext)); -parcelHelpers.export(exports, "useFocusRects", ()=>(0, _useFocusRects.useFocusRects)); -parcelHelpers.export(exports, "getInitials", ()=>(0, _initials.getInitials)); -parcelHelpers.export(exports, "addDirectionalKeyCode", ()=>(0, _keyboard.addDirectionalKeyCode)); -parcelHelpers.export(exports, "isDirectionalKeyCode", ()=>(0, _keyboard.isDirectionalKeyCode)); -parcelHelpers.export(exports, "removeDirectionalKeyCode", ()=>(0, _keyboard.removeDirectionalKeyCode)); -parcelHelpers.export(exports, "getLanguage", ()=>(0, _language.getLanguage)); -parcelHelpers.export(exports, "setLanguage", ()=>(0, _language.setLanguage)); -parcelHelpers.export(exports, "calculatePrecision", ()=>(0, _math.calculatePrecision)); -parcelHelpers.export(exports, "fitContentToBounds", ()=>(0, _math.fitContentToBounds)); -parcelHelpers.export(exports, "getDistanceBetweenPoints", ()=>(0, _math.getDistanceBetweenPoints)); -parcelHelpers.export(exports, "precisionRound", ()=>(0, _math.precisionRound)); -parcelHelpers.export(exports, "createMemoizer", ()=>(0, _memoize.createMemoizer)); -parcelHelpers.export(exports, "memoize", ()=>(0, _memoize.memoize)); -parcelHelpers.export(exports, "memoizeFunction", ()=>(0, _memoize.memoizeFunction)); -parcelHelpers.export(exports, "resetMemoizations", ()=>(0, _memoize.resetMemoizations)); -parcelHelpers.export(exports, "setMemoizeWeakMap", ()=>(0, _memoize.setMemoizeWeakMap)); -parcelHelpers.export(exports, "merge", ()=>(0, _merge.merge)); -parcelHelpers.export(exports, "isIOS", ()=>(0, _mobileDetector.isIOS)); -parcelHelpers.export(exports, "modalize", ()=>(0, _modalize.modalize)); -parcelHelpers.export(exports, "assign", ()=>(0, _object.assign)); -parcelHelpers.export(exports, "filteredAssign", ()=>(0, _object.filteredAssign)); -parcelHelpers.export(exports, "mapEnumByName", ()=>(0, _object.mapEnumByName)); -parcelHelpers.export(exports, "shallowCompare", ()=>(0, _object.shallowCompare)); -parcelHelpers.export(exports, "values", ()=>(0, _object.values)); -parcelHelpers.export(exports, "omit", ()=>(0, _object.omit)); -parcelHelpers.export(exports, "isMac", ()=>(0, _osDetector.isMac)); -parcelHelpers.export(exports, "hasHorizontalOverflow", ()=>(0, _overflow.hasHorizontalOverflow)); -parcelHelpers.export(exports, "hasOverflow", ()=>(0, _overflow.hasOverflow)); -parcelHelpers.export(exports, "hasVerticalOverflow", ()=>(0, _overflow.hasVerticalOverflow)); -parcelHelpers.export(exports, "anchorProperties", ()=>(0, _properties.anchorProperties)); -parcelHelpers.export(exports, "audioProperties", ()=>(0, _properties.audioProperties)); -parcelHelpers.export(exports, "baseElementEvents", ()=>(0, _properties.baseElementEvents)); -parcelHelpers.export(exports, "baseElementProperties", ()=>(0, _properties.baseElementProperties)); -parcelHelpers.export(exports, "buttonProperties", ()=>(0, _properties.buttonProperties)); -parcelHelpers.export(exports, "colGroupProperties", ()=>(0, _properties.colGroupProperties)); -parcelHelpers.export(exports, "colProperties", ()=>(0, _properties.colProperties)); -parcelHelpers.export(exports, "divProperties", ()=>(0, _properties.divProperties)); -parcelHelpers.export(exports, "formProperties", ()=>(0, _properties.formProperties)); -parcelHelpers.export(exports, "getNativeProps", ()=>(0, _properties.getNativeProps)); -parcelHelpers.export(exports, "htmlElementProperties", ()=>(0, _properties.htmlElementProperties)); -parcelHelpers.export(exports, "iframeProperties", ()=>(0, _properties.iframeProperties)); -parcelHelpers.export(exports, "imageProperties", ()=>(0, _properties.imageProperties)); -parcelHelpers.export(exports, "imgProperties", ()=>(0, _properties.imgProperties)); -parcelHelpers.export(exports, "inputProperties", ()=>(0, _properties.inputProperties)); -parcelHelpers.export(exports, "labelProperties", ()=>(0, _properties.labelProperties)); -parcelHelpers.export(exports, "liProperties", ()=>(0, _properties.liProperties)); -parcelHelpers.export(exports, "olProperties", ()=>(0, _properties.olProperties)); -parcelHelpers.export(exports, "optionProperties", ()=>(0, _properties.optionProperties)); -parcelHelpers.export(exports, "selectProperties", ()=>(0, _properties.selectProperties)); -parcelHelpers.export(exports, "tableProperties", ()=>(0, _properties.tableProperties)); -parcelHelpers.export(exports, "tdProperties", ()=>(0, _properties.tdProperties)); -parcelHelpers.export(exports, "textAreaProperties", ()=>(0, _properties.textAreaProperties)); -parcelHelpers.export(exports, "thProperties", ()=>(0, _properties.thProperties)); -parcelHelpers.export(exports, "trProperties", ()=>(0, _properties.trProperties)); -parcelHelpers.export(exports, "videoProperties", ()=>(0, _properties.videoProperties)); -parcelHelpers.export(exports, "composeRenderFunction", ()=>(0, _composeRenderFunction.composeRenderFunction)); -parcelHelpers.export(exports, "getResourceUrl", ()=>(0, _resources.getResourceUrl)); -parcelHelpers.export(exports, "setBaseUrl", ()=>(0, _resources.setBaseUrl)); -parcelHelpers.export(exports, "getRTL", ()=>(0, _rtl.getRTL)); -parcelHelpers.export(exports, "getRTLSafeKeyCode", ()=>(0, _rtl.getRTLSafeKeyCode)); -parcelHelpers.export(exports, "setRTL", ()=>(0, _rtl.setRTL)); -parcelHelpers.export(exports, "safeRequestAnimationFrame", ()=>(0, _safeRequestAnimationFrame.safeRequestAnimationFrame)); -parcelHelpers.export(exports, "safeSetTimeout", ()=>(0, _safeSetTimeout.safeSetTimeout)); -parcelHelpers.export(exports, "DATA_IS_SCROLLABLE_ATTRIBUTE", ()=>(0, _scroll.DATA_IS_SCROLLABLE_ATTRIBUTE)); -parcelHelpers.export(exports, "allowOverscrollOnElement", ()=>(0, _scroll.allowOverscrollOnElement)); -parcelHelpers.export(exports, "allowScrollOnElement", ()=>(0, _scroll.allowScrollOnElement)); -parcelHelpers.export(exports, "disableBodyScroll", ()=>(0, _scroll.disableBodyScroll)); -parcelHelpers.export(exports, "enableBodyScroll", ()=>(0, _scroll.enableBodyScroll)); -parcelHelpers.export(exports, "findScrollableParent", ()=>(0, _scroll.findScrollableParent)); -parcelHelpers.export(exports, "getScrollbarWidth", ()=>(0, _scroll.getScrollbarWidth)); -parcelHelpers.export(exports, "SELECTION_CHANGE", ()=>(0, _index.SELECTION_CHANGE)); -parcelHelpers.export(exports, "SELECTION_ITEMS_CHANGE", ()=>(0, _index.SELECTION_ITEMS_CHANGE)); -parcelHelpers.export(exports, "Selection", ()=>(0, _index.Selection)); -parcelHelpers.export(exports, "SelectionDirection", ()=>(0, _index.SelectionDirection)); -parcelHelpers.export(exports, "SelectionMode", ()=>(0, _index.SelectionMode)); -parcelHelpers.export(exports, "format", ()=>(0, _string.format)); -parcelHelpers.export(exports, "styled", ()=>(0, _styled.styled)); -parcelHelpers.export(exports, "resetControlledWarnings", ()=>(0, _warn.resetControlledWarnings)); -parcelHelpers.export(exports, "setWarningCallback", ()=>(0, _warn.setWarningCallback)); -parcelHelpers.export(exports, "warn", ()=>(0, _warn.warn)); -parcelHelpers.export(exports, "warnConditionallyRequiredProps", ()=>(0, _warn.warnConditionallyRequiredProps)); -parcelHelpers.export(exports, "warnControlledUsage", ()=>(0, _warn.warnControlledUsage)); -parcelHelpers.export(exports, "warnDeprecations", ()=>(0, _warn.warnDeprecations)); -parcelHelpers.export(exports, "warnMutuallyExclusive", ()=>(0, _warn.warnMutuallyExclusive)); -parcelHelpers.export(exports, "isIE11", ()=>(0, _ie11Detector.isIE11)); -parcelHelpers.export(exports, "getPropsWithDefaults", ()=>(0, _getPropsWithDefaults.getPropsWithDefaults)); -parcelHelpers.export(exports, "setFocusVisibility", ()=>(0, _setFocusVisibility.setFocusVisibility)); -parcelHelpers.export(exports, "IsFocusVisibleClassName", ()=>(0, _setFocusVisibility.IsFocusVisibleClassName)); -parcelHelpers.export(exports, "canUseDOM", ()=>(0, _canUseDOM.canUseDOM)); -// eslint-disable-next-line deprecation/deprecation -parcelHelpers.export(exports, "setSSR", ()=>(0, _setSSR.setSSR)); -parcelHelpers.export(exports, "createMergedRef", ()=>(0, _createMergedRef.createMergedRef)); -parcelHelpers.export(exports, "useIsomorphicLayoutEffect", ()=>(0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)); -var _version = require("./version"); -var _async = require("./Async"); -var _autoScroll = require("./AutoScroll"); -var _baseComponent = require("./BaseComponent"); -var _delayedRender = require("./DelayedRender"); -var _eventGroup = require("./EventGroup"); -var _fabricPerformance = require("./FabricPerformance"); -var _globalSettings = require("./GlobalSettings"); -var _keyCodes = require("./KeyCodes"); -var _rectangle = require("./Rectangle"); -var _appendFunction = require("./appendFunction"); -var _aria = require("./aria"); -var _array = require("./array"); -var _asAsync = require("./asAsync"); -var _assertNever = require("./assertNever"); -var _classNamesFunction = require("./classNamesFunction"); -var _composeComponentAs = require("./componentAs/composeComponentAs"); -var _controlled = require("./controlled"); -var _css = require("./css"); -var _customizations = require("./customizations/Customizations"); -var _customizer = require("./customizations/Customizer"); -var _customizerContext = require("./customizations/CustomizerContext"); -var _customizable = require("./customizations/customizable"); -var _useCustomizationSettings = require("./customizations/useCustomizationSettings"); -var _mergeCustomizations = require("./customizations/mergeCustomizations"); -var _mergeSettings = require("./customizations/mergeSettings"); -var _dom = require("./dom"); -var _extendComponent = require("./extendComponent"); -var _focus = require("./focus"); -var _getId = require("./getId"); -var _getNativeElementProps = require("./getNativeElementProps"); -var _hoist = require("./hoist"); -var _hoistStatics = require("./hoistStatics"); -var _initializeComponentRef = require("./initializeComponentRef"); -var _initializeFocusRects = require("./initializeFocusRects"); -var _focusRectsProvider = require("./FocusRectsProvider"); -var _useFocusRects = require("./useFocusRects"); -var _initials = require("./initials"); -var _keyboard = require("./keyboard"); -var _language = require("./language"); -var _math = require("./math"); -var _memoize = require("./memoize"); -var _merge = require("./merge"); -var _mobileDetector = require("./mobileDetector"); -var _modalize = require("./modalize"); -var _object = require("./object"); -var _osDetector = require("./osDetector"); -var _overflow = require("./overflow"); -var _properties = require("./properties"); -var _composeRenderFunction = require("./renderFunction/composeRenderFunction"); -var _resources = require("./resources"); -var _rtl = require("./rtl"); -var _safeRequestAnimationFrame = require("./safeRequestAnimationFrame"); -var _safeSetTimeout = require("./safeSetTimeout"); -var _scroll = require("./scroll"); -var _index = require("./selection/index"); -var _string = require("./string"); -var _styled = require("./styled"); -var _warn = require("./warn"); -var _ie11Detector = require("./ie11Detector"); -var _getPropsWithDefaults = require("./getPropsWithDefaults"); -var _setFocusVisibility = require("./setFocusVisibility"); -var _canUseDOM = require("./dom/canUseDOM"); -var _setSSR = require("./dom/setSSR"); -var _createMergedRef = require("./createMergedRef"); -var _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect"); +var _formatDecimalJs = require("./formatDecimal.js"); +var _formatDecimalJsDefault = parcelHelpers.interopDefault(_formatDecimalJs); +var _formatPrefixAutoJs = require("./formatPrefixAuto.js"); +var _formatPrefixAutoJsDefault = parcelHelpers.interopDefault(_formatPrefixAutoJs); +var _formatRoundedJs = require("./formatRounded.js"); +var _formatRoundedJsDefault = parcelHelpers.interopDefault(_formatRoundedJs); +exports.default = { + "%": (x, p)=>(x * 100).toFixed(p), + "b": (x)=>Math.round(x).toString(2), + "c": (x)=>x + "", + "d": (0, _formatDecimalJsDefault.default), + "e": (x, p)=>x.toExponential(p), + "f": (x, p)=>x.toFixed(p), + "g": (x, p)=>x.toPrecision(p), + "o": (x)=>Math.round(x).toString(8), + "p": (x, p)=>(0, _formatRoundedJsDefault.default)(x * 100, p), + "r": (0, _formatRoundedJsDefault.default), + "s": (0, _formatPrefixAutoJsDefault.default), + "X": (x)=>Math.round(x).toString(16).toUpperCase(), + "x": (x)=>Math.round(x).toString(16) +}; -},{"./version":"9PCaM","./Async":"hAQcF","./AutoScroll":"iVvnk","./BaseComponent":"vNedS","./DelayedRender":"kBgki","./EventGroup":"bQDG8","./FabricPerformance":"cJi5t","./GlobalSettings":"hOBvf","./KeyCodes":"aVdtV","./Rectangle":"jqgRr","./appendFunction":"7Twuh","./aria":"4l6c3","./array":"51Jbj","./asAsync":"8GVXW","./assertNever":"7XVG7","./classNamesFunction":"4Iezg","./componentAs/composeComponentAs":"lA2Mh","./controlled":"77Y1K","./css":"j75mX","./customizations/Customizations":"7aH6S","./customizations/Customizer":"83xLA","./customizations/CustomizerContext":"fYZ4d","./customizations/customizable":"bqcZZ","./customizations/useCustomizationSettings":"efO5y","./customizations/mergeCustomizations":"aWBwG","./customizations/mergeSettings":"hfsOs","./dom":"bEiaC","./extendComponent":"i4bE8","./focus":"czIBK","./getId":"kKU74","./getNativeElementProps":"kIq46","./hoist":"a0YrH","./hoistStatics":"kvC3B","./initializeComponentRef":"bP7B7","./initializeFocusRects":"e13M2","./FocusRectsProvider":"itEBl","./useFocusRects":"bttYg","./initials":"5azVr","./keyboard":"gcwLg","./language":"g4Aej","./math":"cvCig","./memoize":"63n82","./merge":"3nXHH","./mobileDetector":"gKqgU","./modalize":"5K7Du","./object":"cCaiB","./osDetector":"iLauf","./overflow":"lLUjc","./properties":"9boev","./renderFunction/composeRenderFunction":"1ASFG","./resources":"6Q55p","./rtl":"6SQS0","./safeRequestAnimationFrame":"2YKAT","./safeSetTimeout":"fHy6l","./scroll":"kGwz1","./selection/index":"9ugij","./string":"bONba","./styled":"h441M","./warn":"jBE7j","./ie11Detector":"g96q9","./getPropsWithDefaults":"9dYTp","./setFocusVisibility":"jrsUT","./dom/canUseDOM":"61CDL","./dom/setSSR":"b63SA","./createMergedRef":"f2qNU","./useIsomorphicLayoutEffect":"abKbf","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"9PCaM":[function(require,module,exports) { -// Do not modify this file; it is generated as part of publish. -// The checked in version is a placeholder only and will not be updated. -var _setVersion = require("@fluentui/set-version"); -(0, _setVersion.setVersion)("@fluentui/utilities", "8.13.16"); +},{"./formatDecimal.js":"hs37D","./formatPrefixAuto.js":"iUhuq","./formatRounded.js":"l08jr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iUhuq":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "prefixExponent", ()=>prefixExponent); +parcelHelpers.export(exports, "default", ()=>function(x, p) { + var d = (0, _formatDecimalJs.formatDecimalParts)(x, p); + if (!d) return x + ""; + var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length; + return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + (0, _formatDecimalJs.formatDecimalParts)(x, Math.max(0, p + i - 1))[0]; // less than 1y! + }); +var _formatDecimalJs = require("./formatDecimal.js"); +var prefixExponent; -},{"@fluentui/set-version":"aMFYG"}],"hAQcF":[function(require,module,exports) { +},{"./formatDecimal.js":"hs37D","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"l08jr":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Async", ()=>Async); -var _getWindow = require("./dom/getWindow"); -/** - * Bugs often appear in async code when stuff gets disposed, but async operations don't get canceled. - * This Async helper class solves these issues by tying async code to the lifetime of a disposable object. - * - * Usage: Anything class extending from BaseModel can access this helper via this.async. Otherwise create a - * new instance of the class and remember to call dispose() during your code's dispose handler. - * - * @public - */ var Async = /** @class */ function() { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - function Async(parent, onError) { - this._timeoutIds = null; - this._immediateIds = null; - this._intervalIds = null; - this._animationFrameIds = null; - this._isDisposed = false; - this._parent = parent || null; - this._onErrorHandler = onError; - this._noop = function() { - /* do nothing */ }; - } - /** - * Dispose function, clears all async operations. - */ Async.prototype.dispose = function() { - var id; - this._isDisposed = true; - this._parent = null; - // Clear timeouts. - if (this._timeoutIds) { - for(id in this._timeoutIds)if (this._timeoutIds.hasOwnProperty(id)) this.clearTimeout(parseInt(id, 10)); - this._timeoutIds = null; - } - // Clear immediates. - if (this._immediateIds) { - for(id in this._immediateIds)if (this._immediateIds.hasOwnProperty(id)) this.clearImmediate(parseInt(id, 10)); - this._immediateIds = null; - } - // Clear intervals. - if (this._intervalIds) { - for(id in this._intervalIds)if (this._intervalIds.hasOwnProperty(id)) this.clearInterval(parseInt(id, 10)); - this._intervalIds = null; - } - // Clear animation frames. - if (this._animationFrameIds) { - for(id in this._animationFrameIds)if (this._animationFrameIds.hasOwnProperty(id)) this.cancelAnimationFrame(parseInt(id, 10)); - this._animationFrameIds = null; - } - }; - /** - * SetTimeout override, which will auto cancel the timeout during dispose. - * @param callback - Callback to execute. - * @param duration - Duration in milliseconds. - * @returns The setTimeout id. - */ Async.prototype.setTimeout = function(callback, duration) { - var _this = this; - var timeoutId = 0; - if (!this._isDisposed) { - if (!this._timeoutIds) this._timeoutIds = {}; - timeoutId = setTimeout(function() { - // Time to execute the timeout, enqueue it as a foreground task to be executed. - try { - // Now delete the record and call the callback. - if (_this._timeoutIds) delete _this._timeoutIds[timeoutId]; - callback.apply(_this._parent); - } catch (e) { - _this._logError(e); - } - }, duration); - this._timeoutIds[timeoutId] = true; - } - return timeoutId; - }; - /** - * Clears the timeout. - * @param id - Id to cancel. - */ Async.prototype.clearTimeout = function(id) { - if (this._timeoutIds && this._timeoutIds[id]) { - clearTimeout(id); - delete this._timeoutIds[id]; - } - }; - /** - * SetImmediate override, which will auto cancel the immediate during dispose. - * @param callback - Callback to execute. - * @param targetElement - Optional target element to use for identifying the correct window. - * @returns The setTimeout id. - */ Async.prototype.setImmediate = function(callback, targetElement) { - var _this = this; - var immediateId = 0; - var win = (0, _getWindow.getWindow)(targetElement); - if (!this._isDisposed) { - if (!this._immediateIds) this._immediateIds = {}; - var setImmediateCallback = function() { - // Time to execute the timeout, enqueue it as a foreground task to be executed. - try { - // Now delete the record and call the callback. - if (_this._immediateIds) delete _this._immediateIds[immediateId]; - callback.apply(_this._parent); - } catch (e) { - _this._logError(e); - } - }; - immediateId = win.setTimeout(setImmediateCallback, 0); - this._immediateIds[immediateId] = true; - } - return immediateId; - }; - /** - * Clears the immediate. - * @param id - Id to cancel. - * @param targetElement - Optional target element to use for identifying the correct window. - */ Async.prototype.clearImmediate = function(id, targetElement) { - var win = (0, _getWindow.getWindow)(targetElement); - if (this._immediateIds && this._immediateIds[id]) { - win.clearTimeout(id); - delete this._immediateIds[id]; - } - }; - /** - * SetInterval override, which will auto cancel the timeout during dispose. - * @param callback - Callback to execute. - * @param duration - Duration in milliseconds. - * @returns The setTimeout id. - */ Async.prototype.setInterval = function(callback, duration) { - var _this = this; - var intervalId = 0; - if (!this._isDisposed) { - if (!this._intervalIds) this._intervalIds = {}; - intervalId = setInterval(function() { - // Time to execute the interval callback, enqueue it as a foreground task to be executed. - try { - callback.apply(_this._parent); - } catch (e) { - _this._logError(e); - } - }, duration); - this._intervalIds[intervalId] = true; - } - return intervalId; - }; - /** - * Clears the interval. - * @param id - Id to cancel. - */ Async.prototype.clearInterval = function(id) { - if (this._intervalIds && this._intervalIds[id]) { - clearInterval(id); - delete this._intervalIds[id]; - } - }; - /** - * Creates a function that, when executed, will only call the func function at most once per - * every wait milliseconds. Provide an options object to indicate that func should be invoked - * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled - * function will return the result of the last func call. - * - * Note: If leading and trailing options are true func will be called on the trailing edge of - * the timeout only if the throttled function is invoked more than once during the wait timeout. - * - * @param func - The function to throttle. - * @param wait - The number of milliseconds to throttle executions to. Defaults to 0. - * @param options - The options object. - * @returns The new throttled function. - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any - Async.prototype.throttle = function(func, wait, options) { - var _this = this; - if (this._isDisposed) return this._noop; - var waitMS = wait || 0; - var leading = true; - var trailing = true; - var lastExecuteTime = 0; - var lastResult; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var lastArgs; - var timeoutId = null; - if (options && typeof options.leading === "boolean") leading = options.leading; - if (options && typeof options.trailing === "boolean") trailing = options.trailing; - var callback = function(userCall) { - var now = Date.now(); - var delta = now - lastExecuteTime; - var waitLength = leading ? waitMS - delta : waitMS; - if (delta >= waitMS && (!userCall || leading)) { - lastExecuteTime = now; - if (timeoutId) { - _this.clearTimeout(timeoutId); - timeoutId = null; - } - lastResult = func.apply(_this._parent, lastArgs); - } else if (timeoutId === null && trailing) timeoutId = _this.setTimeout(callback, waitLength); - return lastResult; - }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var resultFunction = function() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - lastArgs = args; - return callback(true); - }; - return resultFunction; - }; - /** - * Creates a function that will delay the execution of func until after wait milliseconds have - * elapsed since the last time it was invoked. Provide an options object to indicate that func - * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls - * to the debounced function will return the result of the last func call. - * - * Note: If leading and trailing options are true func will be called on the trailing edge of - * the timeout only if the debounced function is invoked more than once during the wait - * timeout. - * - * @param func - The function to debounce. - * @param wait - The number of milliseconds to delay. - * @param options - The options object. - * @returns The new debounced function. - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any - Async.prototype.debounce = function(func, wait, options) { - var _this = this; - if (this._isDisposed) { - var noOpFunction = function() { - /** Do nothing */ }; - noOpFunction.cancel = function() { - return; - }; - noOpFunction.flush = function() { - return null; - }; - noOpFunction.pending = function() { - return false; - }; - return noOpFunction; - } - var waitMS = wait || 0; - var leading = false; - var trailing = true; - var maxWait = null; - var lastCallTime = 0; - var lastExecuteTime = Date.now(); - var lastResult; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var lastArgs; - var timeoutId = null; - if (options && typeof options.leading === "boolean") leading = options.leading; - if (options && typeof options.trailing === "boolean") trailing = options.trailing; - if (options && typeof options.maxWait === "number" && !isNaN(options.maxWait)) maxWait = options.maxWait; - var markExecuted = function(time) { - if (timeoutId) { - _this.clearTimeout(timeoutId); - timeoutId = null; - } - lastExecuteTime = time; - }; - var invokeFunction = function(time) { - markExecuted(time); - lastResult = func.apply(_this._parent, lastArgs); - }; - var callback = function(userCall) { - var now = Date.now(); - var executeImmediately = false; - if (userCall) { - if (leading && now - lastCallTime >= waitMS) executeImmediately = true; - lastCallTime = now; - } - var delta = now - lastCallTime; - var waitLength = waitMS - delta; - var maxWaitDelta = now - lastExecuteTime; - var maxWaitExpired = false; - if (maxWait !== null) { - // maxWait only matters when there is a pending callback - if (maxWaitDelta >= maxWait && timeoutId) maxWaitExpired = true; - else waitLength = Math.min(waitLength, maxWait - maxWaitDelta); - } - if (delta >= waitMS || maxWaitExpired || executeImmediately) invokeFunction(now); - else if ((timeoutId === null || !userCall) && trailing) timeoutId = _this.setTimeout(callback, waitLength); - return lastResult; - }; - var pending = function() { - return !!timeoutId; - }; - var cancel = function() { - if (pending()) // Mark the debounced function as having executed - markExecuted(Date.now()); - }; - var flush = function() { - if (pending()) invokeFunction(Date.now()); - return lastResult; - }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var resultFunction = function() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - lastArgs = args; - return callback(true); - }; - resultFunction.cancel = cancel; - resultFunction.flush = flush; - resultFunction.pending = pending; - return resultFunction; - }; - Async.prototype.requestAnimationFrame = function(callback, targetElement) { - var _this = this; - var animationFrameId = 0; - var win = (0, _getWindow.getWindow)(targetElement); - if (!this._isDisposed) { - if (!this._animationFrameIds) this._animationFrameIds = {}; - var animationFrameCallback = function() { - try { - // Now delete the record and call the callback. - if (_this._animationFrameIds) delete _this._animationFrameIds[animationFrameId]; - callback.apply(_this._parent); - } catch (e) { - _this._logError(e); - } - }; - animationFrameId = win.requestAnimationFrame ? win.requestAnimationFrame(animationFrameCallback) : win.setTimeout(animationFrameCallback, 0); - this._animationFrameIds[animationFrameId] = true; - } - return animationFrameId; - }; - Async.prototype.cancelAnimationFrame = function(id, targetElement) { - var win = (0, _getWindow.getWindow)(targetElement); - if (this._animationFrameIds && this._animationFrameIds[id]) { - win.cancelAnimationFrame ? win.cancelAnimationFrame(id) : win.clearTimeout(id); - delete this._animationFrameIds[id]; - } - }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Async.prototype._logError = function(e) { - if (this._onErrorHandler) this._onErrorHandler(e); - }; - return Async; -}(); +parcelHelpers.export(exports, "default", ()=>function(x, p) { + var d = (0, _formatDecimalJs.formatDecimalParts)(x, p); + if (!d) return x + ""; + var coefficient = d[0], exponent = d[1]; + return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0"); + }); +var _formatDecimalJs = require("./formatDecimal.js"); -},{"./dom/getWindow":"i0Ddq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"i0Ddq":[function(require,module,exports) { +},{"./formatDecimal.js":"hs37D","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"brXEh":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Helper to get the window object. The helper will make sure to use a cached variable - * of "window", to avoid overhead and memory leaks in IE11. Note that in popup scenarios the - * window object won't match the "global" window object, and for these scenarios, you should - * pass in an element hosted within the popup. - * - * @public - */ parcelHelpers.export(exports, "getWindow", ()=>getWindow); -var _canUseDOM = require("./canUseDOM"); -var _window = undefined; -// Note: Accessing "window" in IE11 is somewhat expensive, and calling "typeof window" -// hits a memory leak, whereas aliasing it and calling "typeof _window" does not. -// Caching the window value at the file scope lets us minimize the impact. -try { - _window = window; -} catch (e) { -/* no-op */ } -function getWindow(rootElement) { - if (!(0, _canUseDOM.canUseDOM)() || typeof _window === "undefined") return undefined; - else { - var el = rootElement; - return el && el.ownerDocument && el.ownerDocument.defaultView ? el.ownerDocument.defaultView : _window; - } -} +parcelHelpers.export(exports, "default", ()=>function(x) { + return x; + }); -},{"./canUseDOM":"61CDL","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"61CDL":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"kTPBo":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Verifies if an application can use DOM. - */ parcelHelpers.export(exports, "canUseDOM", ()=>canUseDOM); -function canUseDOM() { - return typeof window !== "undefined" && !!(window.document && // eslint-disable-next-line deprecation/deprecation - window.document.createElement); -} +parcelHelpers.export(exports, "default", ()=>function(step) { + return Math.max(0, -(0, _exponentJsDefault.default)(Math.abs(step))); + }); +var _exponentJs = require("./exponent.js"); +var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"iVvnk":[function(require,module,exports) { +},{"./exponent.js":"aOeaO","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"cmgfB":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "AutoScroll", ()=>AutoScroll); -var _eventGroup = require("./EventGroup"); -var _scroll = require("./scroll"); -var _getRect = require("./dom/getRect"); -var SCROLL_ITERATION_DELAY = 16; -var SCROLL_GUTTER = 100; -var MAX_SCROLL_VELOCITY = 15; -/** - * AutoScroll simply hooks up mouse events given a parent element, and scrolls the container - * up/down depending on how close the mouse is to the top/bottom of the container. - * - * Once you don't want autoscroll any more, just dispose the helper and it will unhook events. - * - * @public - * {@docCategory AutoScroll} - */ var AutoScroll = /** @class */ function() { - function AutoScroll(element) { - this._events = new (0, _eventGroup.EventGroup)(this); - this._scrollableParent = (0, _scroll.findScrollableParent)(element); - this._incrementScroll = this._incrementScroll.bind(this); - this._scrollRect = (0, _getRect.getRect)(this._scrollableParent); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - if (this._scrollableParent === window) this._scrollableParent = document.body; - if (this._scrollableParent) { - this._events.on(window, "mousemove", this._onMouseMove, true); - this._events.on(window, "touchmove", this._onTouchMove, true); - } - } - AutoScroll.prototype.dispose = function() { - this._events.dispose(); - this._stopScroll(); - }; - AutoScroll.prototype._onMouseMove = function(ev) { - this._computeScrollVelocity(ev); - }; - AutoScroll.prototype._onTouchMove = function(ev) { - if (ev.touches.length > 0) this._computeScrollVelocity(ev); - }; - AutoScroll.prototype._computeScrollVelocity = function(ev) { - if (!this._scrollRect) return; - var clientX; - var clientY; - if ("clientX" in ev) { - clientX = ev.clientX; - clientY = ev.clientY; - } else { - clientX = ev.touches[0].clientX; - clientY = ev.touches[0].clientY; - } - var scrollRectTop = this._scrollRect.top; - var scrollRectLeft = this._scrollRect.left; - var scrollClientBottom = scrollRectTop + this._scrollRect.height - SCROLL_GUTTER; - var scrollClientRight = scrollRectLeft + this._scrollRect.width - SCROLL_GUTTER; - // variables to use for alternating scroll direction - var scrollRect; - var clientDirection; - var scrollClient; - // if either of these conditions are met we are scrolling vertically else horizontally - if (clientY < scrollRectTop + SCROLL_GUTTER || clientY > scrollClientBottom) { - clientDirection = clientY; - scrollRect = scrollRectTop; - scrollClient = scrollClientBottom; - this._isVerticalScroll = true; - } else { - clientDirection = clientX; - scrollRect = scrollRectLeft; - scrollClient = scrollClientRight; - this._isVerticalScroll = false; - } - // calculate scroll velocity and direction - if (clientDirection < scrollRect + SCROLL_GUTTER) this._scrollVelocity = Math.max(-MAX_SCROLL_VELOCITY, -MAX_SCROLL_VELOCITY * ((SCROLL_GUTTER - (clientDirection - scrollRect)) / SCROLL_GUTTER)); - else if (clientDirection > scrollClient) this._scrollVelocity = Math.min(MAX_SCROLL_VELOCITY, MAX_SCROLL_VELOCITY * ((clientDirection - scrollClient) / SCROLL_GUTTER)); - else this._scrollVelocity = 0; - if (this._scrollVelocity) this._startScroll(); - else this._stopScroll(); - }; - AutoScroll.prototype._startScroll = function() { - if (!this._timeoutId) this._incrementScroll(); - }; - AutoScroll.prototype._incrementScroll = function() { - if (this._scrollableParent) { - if (this._isVerticalScroll) this._scrollableParent.scrollTop += Math.round(this._scrollVelocity); - else this._scrollableParent.scrollLeft += Math.round(this._scrollVelocity); - } - this._timeoutId = setTimeout(this._incrementScroll, SCROLL_ITERATION_DELAY); - }; - AutoScroll.prototype._stopScroll = function() { - if (this._timeoutId) { - clearTimeout(this._timeoutId); - delete this._timeoutId; - } - }; - return AutoScroll; -}(); +parcelHelpers.export(exports, "default", ()=>function(step, value) { + return Math.max(0, Math.max(-8, Math.min(8, Math.floor((0, _exponentJsDefault.default)(value) / 3))) * 3 - (0, _exponentJsDefault.default)(Math.abs(step))); + }); +var _exponentJs = require("./exponent.js"); +var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); -},{"./EventGroup":"bQDG8","./scroll":"kGwz1","./dom/getRect":"fEGdU","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bQDG8":[function(require,module,exports) { +},{"./exponent.js":"aOeaO","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g5X8k":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "EventGroup", ()=>EventGroup); -var _object = require("./object"); -/** An instance of EventGroup allows anything with a handle to it to trigger events on it. - * If the target is an HTMLElement, the event will be attached to the element and can be - * triggered as usual (like clicking for onClick). - * The event can be triggered by calling EventGroup.raise() here. If the target is an - * HTMLElement, the event gets raised and is handled by the browser. Otherwise, it gets - * handled here in EventGroup, and the handler is called in the context of the parent - * (which is passed in in the constructor). - * - * @public - * {@docCategory EventGroup} - */ var EventGroup = /** @class */ function() { - /** parent: the context in which events attached to non-HTMLElements are called */ function EventGroup(parent) { - this._id = EventGroup._uniqueId++; - this._parent = parent; - this._eventRecords = []; +parcelHelpers.export(exports, "default", ()=>function(step, max) { + step = Math.abs(step), max = Math.abs(max) - step; + return Math.max(0, (0, _exponentJsDefault.default)(max) - (0, _exponentJsDefault.default)(step)) + 1; + }); +var _exponentJs = require("./exponent.js"); +var _exponentJsDefault = parcelHelpers.interopDefault(_exponentJs); + +},{"./exponent.js":"aOeaO","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"5BBe1":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "loggish", ()=>loggish); +parcelHelpers.export(exports, "default", ()=>log); +var _d3Array = require("d3-array"); +var _d3Format = require("d3-format"); +var _niceJs = require("./nice.js"); +var _niceJsDefault = parcelHelpers.interopDefault(_niceJs); +var _continuousJs = require("./continuous.js"); +var _initJs = require("./init.js"); +function transformLog(x) { + return Math.log(x); +} +function transformExp(x) { + return Math.exp(x); +} +function transformLogn(x) { + return -Math.log(-x); +} +function transformExpn(x) { + return -Math.exp(-x); +} +function pow10(x) { + return isFinite(x) ? +("1e" + x) : x < 0 ? 0 : x; +} +function powp(base) { + return base === 10 ? pow10 : base === Math.E ? Math.exp : (x)=>Math.pow(base, x); +} +function logp(base) { + return base === Math.E ? Math.log : base === 10 && Math.log10 || base === 2 && Math.log2 || (base = Math.log(base), (x)=>Math.log(x) / base); +} +function reflect(f) { + return (x, k)=>-f(-x, k); +} +function loggish(transform) { + const scale = transform(transformLog, transformExp); + const domain = scale.domain; + let base = 10; + let logs; + let pows; + function rescale() { + logs = logp(base), pows = powp(base); + if (domain()[0] < 0) { + logs = reflect(logs), pows = reflect(pows); + transform(transformLogn, transformExpn); + } else transform(transformLog, transformExp); + return scale; } - /** For IE8, bubbleEvent is ignored here and must be dealt with by the handler. - * Events raised here by default have bubbling set to false and cancelable set to true. - * This applies also to built-in events being raised manually here on HTMLElements, - * which may lead to unexpected behavior if it differs from the defaults. - * - */ EventGroup.raise = function(target, eventName, eventArgs, bubbleEvent) { - var retVal; - if (EventGroup._isElement(target)) { - if (typeof document !== "undefined" && document.createEvent) { - var ev = document.createEvent("HTMLEvents"); - // eslint-disable-next-line deprecation/deprecation - ev.initEvent(eventName, bubbleEvent || false, true); - (0, _object.assign)(ev, eventArgs); - retVal = target.dispatchEvent(ev); - } else if (typeof document !== "undefined" && document.createEventObject) { - // IE8 - var evObj = document.createEventObject(eventArgs); - // cannot set cancelBubble on evObj, fireEvent will overwrite it - target.fireEvent("on" + eventName, evObj); - } - } else // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore -- FIXME: strictBindCallApply error - https://github.com/microsoft/fluentui/issues/17331 - while(target && retVal !== false){ - var events = target.__events__; - var eventRecords = events ? events[eventName] : null; - if (eventRecords) { - for(var id in eventRecords)if (eventRecords.hasOwnProperty(id)) { - var eventRecordList = eventRecords[id]; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore -- FIXME: strictBindCallApply error - https://github.com/microsoft/fluentui/issues/17331 - for(var listIndex = 0; retVal !== false && listIndex < eventRecordList.length; listIndex++){ - var record = eventRecordList[listIndex]; - if (record.objectCallback) retVal = record.objectCallback.call(record.parent, eventArgs); - } - } - } - // If the target has a parent, bubble the event up. - target = bubbleEvent ? target.parent : null; - } - return retVal; - }; - EventGroup.isObserved = function(target, eventName) { - var events = target && target.__events__; - return !!events && !!events[eventName]; - }; - /** Check to see if the target has declared support of the given event. */ EventGroup.isDeclared = function(target, eventName) { - var declaredEvents = target && target.__declaredEvents; - return !!declaredEvents && !!declaredEvents[eventName]; - }; - EventGroup.stopPropagation = function(event) { - if (event.stopPropagation) event.stopPropagation(); - else // IE8 - event.cancelBubble = true; - }; - EventGroup._isElement = function(target) { - return !!target && (!!target.addEventListener || typeof HTMLElement !== "undefined" && target instanceof HTMLElement); - }; - EventGroup.prototype.dispose = function() { - if (!this._isDisposed) { - this._isDisposed = true; - this.off(); - this._parent = null; - } + scale.base = function(_) { + return arguments.length ? (base = +_, rescale()) : base; }; - /** On the target, attach a set of events, where the events object is a name to function mapping. */ EventGroup.prototype.onAll = function(target, events, useCapture) { - for(var eventName in events)if (events.hasOwnProperty(eventName)) this.on(target, eventName, events[eventName], useCapture); + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); }; - /** - * On the target, attach an event whose handler will be called in the context of the parent - * of this instance of EventGroup. - */ EventGroup.prototype.on = function(target, eventName, callback, options) { - var _this = this; - if (eventName.indexOf(",") > -1) { - var events = eventName.split(/[ ,]+/); - for(var i = 0; i < events.length; i++)this.on(target, events[i], callback, options); - } else { - var parent_1 = this._parent; - var eventRecord = { - target: target, - eventName: eventName, - parent: parent_1, - callback: callback, - options: options - }; - // Initialize and wire up the record on the target, so that it can call the callback if the event fires. - var events = target.__events__ = target.__events__ || {}; - events[eventName] = events[eventName] || { - count: 0 - }; - events[eventName][this._id] = events[eventName][this._id] || []; - events[eventName][this._id].push(eventRecord); - events[eventName].count++; - if (EventGroup._isElement(target)) { - var processElementEvent = function() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - if (_this._isDisposed) return; - var result; - try { - result = callback.apply(parent_1, args); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore -- FIXME: strictBindCallApply error - https://github.com/microsoft/fluentui/issues/17331 - if (result === false && args[0]) { - var e = args[0]; - if (e.preventDefault) e.preventDefault(); - if (e.stopPropagation) e.stopPropagation(); - e.cancelBubble = true; - } - } catch (e1) { - // ignore - } - return result; - }; - eventRecord.elementCallback = processElementEvent; - if (target.addEventListener) target.addEventListener(eventName, processElementEvent, options); - else if (target.attachEvent) // IE8 - target.attachEvent("on" + eventName, processElementEvent); - } else { - var processObjectEvent = function() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - if (_this._isDisposed) return; - return callback.apply(parent_1, args); - }; - eventRecord.objectCallback = processObjectEvent; + scale.ticks = (count)=>{ + const d = domain(); + let u = d[0]; + let v = d[d.length - 1]; + const r = v < u; + if (r) [u, v] = [ + v, + u + ]; + let i = logs(u); + let j = logs(v); + let k; + let t; + const n = count == null ? 10 : +count; + let z = []; + if (!(base % 1) && j - i < n) { + i = Math.floor(i), j = Math.ceil(j); + if (u > 0) for(; i <= j; ++i)for(k = 1; k < base; ++k){ + t = i < 0 ? k / pows(-i) : k * pows(i); + if (t < u) continue; + if (t > v) break; + z.push(t); } - // Remember the record locally, so that it can be removed. - this._eventRecords.push(eventRecord); - } - }; - EventGroup.prototype.off = function(target, eventName, callback, options) { - for(var i = 0; i < this._eventRecords.length; i++){ - var eventRecord = this._eventRecords[i]; - if ((!target || target === eventRecord.target) && (!eventName || eventName === eventRecord.eventName) && (!callback || callback === eventRecord.callback) && (typeof options !== "boolean" || options === eventRecord.options)) { - var events = eventRecord.target.__events__; - var targetArrayLookup = events[eventRecord.eventName]; - var targetArray = targetArrayLookup ? targetArrayLookup[this._id] : null; - // We may have already target's entries, so check for null. - if (targetArray) { - if (targetArray.length === 1 || !callback) { - targetArrayLookup.count -= targetArray.length; - delete events[eventRecord.eventName][this._id]; - } else { - targetArrayLookup.count--; - targetArray.splice(targetArray.indexOf(eventRecord), 1); - } - if (!targetArrayLookup.count) delete events[eventRecord.eventName]; - } - if (eventRecord.elementCallback) { - if (eventRecord.target.removeEventListener) eventRecord.target.removeEventListener(eventRecord.eventName, eventRecord.elementCallback, eventRecord.options); - else if (eventRecord.target.detachEvent) // IE8 - eventRecord.target.detachEvent("on" + eventRecord.eventName, eventRecord.elementCallback); - } - this._eventRecords.splice(i--, 1); + else for(; i <= j; ++i)for(k = base - 1; k >= 1; --k){ + t = i > 0 ? k / pows(-i) : k * pows(i); + if (t < u) continue; + if (t > v) break; + z.push(t); } - } + if (z.length * 2 < n) z = (0, _d3Array.ticks)(u, v, n); + } else z = (0, _d3Array.ticks)(i, j, Math.min(j - i, n)).map(pows); + return r ? z.reverse() : z; }; - /** Trigger the given event in the context of this instance of EventGroup. */ EventGroup.prototype.raise = function(eventName, eventArgs, bubbleEvent) { - return EventGroup.raise(this._parent, eventName, eventArgs, bubbleEvent); + scale.tickFormat = (count, specifier)=>{ + if (count == null) count = 10; + if (specifier == null) specifier = base === 10 ? "s" : ","; + if (typeof specifier !== "function") { + if (!(base % 1) && (specifier = (0, _d3Format.formatSpecifier)(specifier)).precision == null) specifier.trim = true; + specifier = (0, _d3Format.format)(specifier); + } + if (count === Infinity) return specifier; + const k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate? + return (d)=>{ + let i = d / pows(Math.round(logs(d))); + if (i * base < base - 0.5) i *= base; + return i <= k ? specifier(d) : ""; + }; }; - /** Declare an event as being supported by this instance of EventGroup. */ EventGroup.prototype.declare = function(event) { - var declaredEvents = this._parent.__declaredEvents = this._parent.__declaredEvents || {}; - if (typeof event === "string") declaredEvents[event] = true; - else for(var i = 0; i < event.length; i++)declaredEvents[event[i]] = true; + scale.nice = ()=>{ + return domain((0, _niceJsDefault.default)(domain(), { + floor: (x)=>pows(Math.floor(logs(x))), + ceil: (x)=>pows(Math.ceil(logs(x))) + })); }; - EventGroup._uniqueId = 0; - return EventGroup; -}(); + return scale; +} +function log() { + const scale = loggish((0, _continuousJs.transformer)()).domain([ + 1, + 10 + ]); + scale.copy = ()=>(0, _continuousJs.copy)(scale, log()).base(scale.base()); + (0, _initJs.initRange).apply(scale, arguments); + return scale; +} -},{"./object":"cCaiB","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cCaiB":[function(require,module,exports) { +},{"d3-array":"5lCYW","d3-format":"4fjQY","./nice.js":"ig9Ha","./continuous.js":"2SYx4","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ig9Ha":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Compares a to b and b to a. - * - * @public - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -parcelHelpers.export(exports, "shallowCompare", ()=>shallowCompare); -/** - * Makes a resulting merge of a bunch of objects. Pass in the target object followed by 1 or more - * objects as arguments and they will be merged sequentially into the target. Note that this will - * shallow merge; it will not create new cloned values for target members. - * - * @public - * @param target - Target object to merge following object arguments into. - * @param args - One or more objects that will be mixed into the target in the order they are provided. - * @returns Resulting merged target. - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -parcelHelpers.export(exports, "assign", ()=>assign); -/** - * Makes a resulting merge of a bunch of objects, but allows a filter function to be passed in to filter - * the resulting merges. This allows for scenarios where you want to merge "everything except that one thing" - * or "properties that start with data-". Note that this will shallow merge; it will not create new cloned - * values for target members. - * - * @public - * @param isAllowed - Callback to determine if the given propName is allowed in the result. - * @param target - Target object to merge following object arguments into. - * @param args - One or more objects that will be mixed into the target in the order they are provided. - * @returns Resulting merged target. - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -parcelHelpers.export(exports, "filteredAssign", ()=>filteredAssign); -/** - * Takes an enum and iterates over each value of the enum (as a string), running the callback on each, - * returning a mapped array. - * @param theEnum - Enum to iterate over - * @param callback - The first parameter the name of the entry, and the second parameter is the value - * of that entry, which is the value you'd normally use when using the enum (usually a number). - */ parcelHelpers.export(exports, "mapEnumByName", ()=>mapEnumByName); -/** - * Get all values in an object dictionary - * - * @param obj - The dictionary to get values for - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -parcelHelpers.export(exports, "values", ()=>values); -/** - * Tiny helper to do the minimal amount of work in duplicating an object but omitting some - * props. This ends up faster than using object ...rest or reduce to filter. - * - * This behaves very much like filteredAssign, but does not merge many objects together, - * uses an exclusion object map, and avoids spreads all for optimal performance. - * - * See perf test for background: - * https://jsperf.com/omit-vs-rest-vs-reduce/1 - * - * @param obj - The object to clone - * @param exclusions - The array of keys to exclude - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -parcelHelpers.export(exports, "omit", ()=>omit); -function shallowCompare(a, b) { - if (!a || !b) // only return true if both a and b are falsy - return !a && !b; - for(var propName in a)if (a.hasOwnProperty(propName)) { - if (!b.hasOwnProperty(propName) || b[propName] !== a[propName]) return false; - } - for(var propName in b)if (b.hasOwnProperty(propName)) { - if (!a.hasOwnProperty(propName)) return false; - } - return true; -} -function assign(target) { - var args = []; - for(var _i = 1; _i < arguments.length; _i++)args[_i - 1] = arguments[_i]; - return filteredAssign.apply(this, [ - null, - target - ].concat(args)); -} -function filteredAssign(isAllowed, target) { - var args = []; - for(var _i = 2; _i < arguments.length; _i++)args[_i - 2] = arguments[_i]; - target = target || {}; - for(var _a = 0, args_1 = args; _a < args_1.length; _a++){ - var sourceObject = args_1[_a]; - if (sourceObject) { - for(var propName in sourceObject)if (sourceObject.hasOwnProperty(propName) && (!isAllowed || isAllowed(propName))) target[propName] = sourceObject[propName]; - } +parcelHelpers.export(exports, "default", ()=>nice); +function nice(domain, interval) { + domain = domain.slice(); + var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], t; + if (x1 < x0) { + t = i0, i0 = i1, i1 = t; + t = x0, x0 = x1, x1 = t; } - return target; -} -function mapEnumByName(// eslint-disable-next-line @typescript-eslint/no-explicit-any -theEnum, callback) { - // map to satisfy compiler since it doesn't realize we strip out undefineds in the .filter() call - return Object.keys(theEnum).map(function(p) { - // map on each property name as a string - if (String(Number(p)) !== p) // if the property is not just a number (because enums in TypeScript will map both ways) - return callback(p, theEnum[p]); - return undefined; - }).filter(function(v) { - return !!v; - }); // only return elements with values -} -function values(obj) { - return Object.keys(obj).reduce(function(arr, key) { - arr.push(obj[key]); - return arr; - }, []); -} -function omit(obj, exclusions) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var result = {}; - for(var key in obj)if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) result[key] = obj[key]; - return result; + domain[i0] = interval.floor(x0); + domain[i1] = interval.ceil(x1); + return domain; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kGwz1":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"26cMO":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DATA_IS_SCROLLABLE_ATTRIBUTE", ()=>DATA_IS_SCROLLABLE_ATTRIBUTE); -parcelHelpers.export(exports, "allowScrollOnElement", ()=>allowScrollOnElement); -parcelHelpers.export(exports, "allowOverscrollOnElement", ()=>allowOverscrollOnElement); -/** - * Disables the body scrolling. - * - * @public - */ parcelHelpers.export(exports, "disableBodyScroll", ()=>disableBodyScroll); -/** - * Enables the body scrolling. - * - * @public - */ parcelHelpers.export(exports, "enableBodyScroll", ()=>enableBodyScroll); -/** - * Calculates the width of a scrollbar for the browser/os. - * - * @public - */ parcelHelpers.export(exports, "getScrollbarWidth", ()=>getScrollbarWidth); -/** - * Traverses up the DOM for the element with the data-is-scrollable=true attribute, or returns - * document.body. - * - * @public - */ parcelHelpers.export(exports, "findScrollableParent", ()=>findScrollableParent); -var _getDocument = require("./dom/getDocument"); -var _mergeStyles = require("@fluentui/merge-styles"); -var _getWindow = require("./dom/getWindow"); -var _scrollbarWidth; -var _bodyScrollDisabledCount = 0; -var DisabledScrollClassName = (0, _mergeStyles.mergeStyles)({ - overflow: "hidden !important" -}); -var DATA_IS_SCROLLABLE_ATTRIBUTE = "data-is-scrollable"; -var allowScrollOnElement = function(element, events) { - if (!element) return; - var _previousClientY = 0; - var _element = null; - // remember the clientY for future calls of _preventOverscrolling - var _saveClientY = function(event) { - if (event.targetTouches.length === 1) _previousClientY = event.targetTouches[0].clientY; - }; - // prevent the body from scrolling when the user attempts - // to scroll past the top or bottom of the element - var _preventOverscrolling = function(event) { - // only respond to a single-finger touch - if (event.targetTouches.length !== 1) return; - // prevent the body touchmove handler from firing - // so that scrolling is allowed within the element - event.stopPropagation(); - if (!_element) return; - var clientY = event.targetTouches[0].clientY - _previousClientY; - var scrollableParent = findScrollableParent(event.target); - if (scrollableParent) _element = scrollableParent; - // if the element is scrolled to the top, - // prevent the user from scrolling up - if (_element.scrollTop === 0 && clientY > 0) event.preventDefault(); - // if the element is scrolled to the bottom, - // prevent the user from scrolling down - if (_element.scrollHeight - Math.ceil(_element.scrollTop) <= _element.clientHeight && clientY < 0) event.preventDefault(); - }; - events.on(element, "touchstart", _saveClientY, { - passive: false - }); - events.on(element, "touchmove", _preventOverscrolling, { - passive: false - }); - _element = element; -}; -var allowOverscrollOnElement = function(element, events) { - if (!element) return; - var _allowElementScroll = function(event) { - event.stopPropagation(); +parcelHelpers.export(exports, "symlogish", ()=>symlogish); +parcelHelpers.export(exports, "default", ()=>symlog); +var _linearJs = require("./linear.js"); +var _continuousJs = require("./continuous.js"); +var _initJs = require("./init.js"); +function transformSymlog(c) { + return function(x) { + return Math.sign(x) * Math.log1p(Math.abs(x / c)); }; - events.on(element, "touchmove", _allowElementScroll, { - passive: false - }); -}; -var _disableIosBodyScroll = function(event) { - event.preventDefault(); -}; -function disableBodyScroll() { - var doc = (0, _getDocument.getDocument)(); - if (doc && doc.body && !_bodyScrollDisabledCount) { - doc.body.classList.add(DisabledScrollClassName); - doc.body.addEventListener("touchmove", _disableIosBodyScroll, { - passive: false, - capture: false - }); - } - _bodyScrollDisabledCount++; } -function enableBodyScroll() { - if (_bodyScrollDisabledCount > 0) { - var doc = (0, _getDocument.getDocument)(); - if (doc && doc.body && _bodyScrollDisabledCount === 1) { - doc.body.classList.remove(DisabledScrollClassName); - doc.body.removeEventListener("touchmove", _disableIosBodyScroll); - } - _bodyScrollDisabledCount--; - } +function transformSymexp(c) { + return function(x) { + return Math.sign(x) * Math.expm1(Math.abs(x)) * c; + }; } -function getScrollbarWidth() { - if (_scrollbarWidth === undefined) { - var scrollDiv = document.createElement("div"); - scrollDiv.style.setProperty("width", "100px"); - scrollDiv.style.setProperty("height", "100px"); - scrollDiv.style.setProperty("overflow", "scroll"); - scrollDiv.style.setProperty("position", "absolute"); - scrollDiv.style.setProperty("top", "-9999px"); - document.body.appendChild(scrollDiv); - // Get the scrollbar width - _scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; - // Delete the DIV - document.body.removeChild(scrollDiv); - } - return _scrollbarWidth; +function symlogish(transform) { + var c = 1, scale = transform(transformSymlog(c), transformSymexp(c)); + scale.constant = function(_) { + return arguments.length ? transform(transformSymlog(c = +_), transformSymexp(c)) : c; + }; + return (0, _linearJs.linearish)(scale); } -function findScrollableParent(startingElement) { - var el = startingElement; - var doc = (0, _getDocument.getDocument)(startingElement); - // First do a quick scan for the scrollable attribute. - while(el && el !== doc.body){ - if (el.getAttribute(DATA_IS_SCROLLABLE_ATTRIBUTE) === "true") return el; - el = el.parentElement; - } - // If we haven't found it, the use the slower method: compute styles to evaluate if overflow is set. - el = startingElement; - while(el && el !== doc.body){ - if (el.getAttribute(DATA_IS_SCROLLABLE_ATTRIBUTE) !== "false") { - var computedStyles = getComputedStyle(el); - var overflowY = computedStyles ? computedStyles.getPropertyValue("overflow-y") : ""; - if (overflowY && (overflowY === "scroll" || overflowY === "auto")) return el; - } - el = el.parentElement; - } - // Fall back to window scroll. - if (!el || el === doc.body) el = (0, _getWindow.getWindow)(startingElement); - return el; +function symlog() { + var scale = symlogish((0, _continuousJs.transformer)()); + scale.copy = function() { + return (0, _continuousJs.copy)(scale, symlog()).constant(scale.constant()); + }; + return (0, _initJs.initRange).apply(scale, arguments); } -},{"./dom/getDocument":"2lQ30","@fluentui/merge-styles":"ggD5u","./dom/getWindow":"i0Ddq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2lQ30":[function(require,module,exports) { +},{"./linear.js":"ik2PQ","./continuous.js":"2SYx4","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ah9R8":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Helper to get the document object. Note that in popup window cases, document - * might be the wrong document, which is why we look at ownerDocument for the - * truth. - * - * @public - */ parcelHelpers.export(exports, "getDocument", ()=>getDocument); -var _canUseDOM = require("./canUseDOM"); -function getDocument(rootElement) { - if (!(0, _canUseDOM.canUseDOM)() || typeof document === "undefined") return undefined; - else { - var el = rootElement; - return el && el.ownerDocument ? el.ownerDocument : document; +parcelHelpers.export(exports, "powish", ()=>powish); +parcelHelpers.export(exports, "default", ()=>pow); +parcelHelpers.export(exports, "sqrt", ()=>sqrt); +var _linearJs = require("./linear.js"); +var _continuousJs = require("./continuous.js"); +var _initJs = require("./init.js"); +function transformPow(exponent) { + return function(x) { + return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent); + }; +} +function transformSqrt(x) { + return x < 0 ? -Math.sqrt(-x) : Math.sqrt(x); +} +function transformSquare(x) { + return x < 0 ? -x * x : x * x; +} +function powish(transform) { + var scale = transform((0, _continuousJs.identity), (0, _continuousJs.identity)), exponent = 1; + function rescale() { + return exponent === 1 ? transform((0, _continuousJs.identity), (0, _continuousJs.identity)) : exponent === 0.5 ? transform(transformSqrt, transformSquare) : transform(transformPow(exponent), transformPow(1 / exponent)); } + scale.exponent = function(_) { + return arguments.length ? (exponent = +_, rescale()) : exponent; + }; + return (0, _linearJs.linearish)(scale); +} +function pow() { + var scale = powish((0, _continuousJs.transformer)()); + scale.copy = function() { + return (0, _continuousJs.copy)(scale, pow()).exponent(scale.exponent()); + }; + (0, _initJs.initRange).apply(scale, arguments); + return scale; +} +function sqrt() { + return pow.apply(null, arguments).exponent(0.5); } -},{"./canUseDOM":"61CDL","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"ggD5u":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "mergeStyles", ()=>(0, _mergeStyles.mergeStyles)); -parcelHelpers.export(exports, "mergeCss", ()=>(0, _mergeStyles.mergeCss)); -parcelHelpers.export(exports, "mergeStyleSets", ()=>(0, _mergeStyleSets.mergeStyleSets)); -parcelHelpers.export(exports, "mergeCssSets", ()=>(0, _mergeStyleSets.mergeCssSets)); -parcelHelpers.export(exports, "concatStyleSets", ()=>(0, _concatStyleSets.concatStyleSets)); -parcelHelpers.export(exports, "concatStyleSetsWithProps", ()=>(0, _concatStyleSetsWithProps.concatStyleSetsWithProps)); -parcelHelpers.export(exports, "fontFace", ()=>(0, _fontFace.fontFace)); -parcelHelpers.export(exports, "keyframes", ()=>(0, _keyframes.keyframes)); -parcelHelpers.export(exports, "InjectionMode", ()=>(0, _stylesheet.InjectionMode)); -parcelHelpers.export(exports, "Stylesheet", ()=>(0, _stylesheet.Stylesheet)); -parcelHelpers.export(exports, "setRTL", ()=>(0, _styleOptionsState.setRTL)); -var _version = require("./version"); -var _mergeStyles = require("./mergeStyles"); -var _mergeStyleSets = require("./mergeStyleSets"); -var _concatStyleSets = require("./concatStyleSets"); -var _concatStyleSetsWithProps = require("./concatStyleSetsWithProps"); -var _fontFace = require("./fontFace"); -var _keyframes = require("./keyframes"); -var _stylesheet = require("./Stylesheet"); -var _styleOptionsState = require("./StyleOptionsState"); - -},{"./version":"1yLpT","./mergeStyles":"8Z5s2","./mergeStyleSets":"1R7DK","./concatStyleSets":"g4PxR","./concatStyleSetsWithProps":"eTVxs","./fontFace":"011dQ","./keyframes":"dTsCK","./Stylesheet":"5cmuF","./StyleOptionsState":"dTpiY","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1yLpT":[function(require,module,exports) { -// Do not modify this file; it is generated as part of publish. -// The checked in version is a placeholder only and will not be updated. -var _setVersion = require("@fluentui/set-version"); -(0, _setVersion.setVersion)("@fluentui/merge-styles", "8.5.12"); - -},{"@fluentui/set-version":"aMFYG"}],"8Z5s2":[function(require,module,exports) { +},{"./linear.js":"ik2PQ","./continuous.js":"2SYx4","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eL6SH":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Concatenation helper, which can merge class names together. Skips over falsey values. - * - * @public - */ parcelHelpers.export(exports, "mergeStyles", ()=>mergeStyles); -/** - * Concatenation helper, which can merge class names together. Skips over falsey values. - * Accepts a set of options that will be used when calculating styles. - * - * @public - */ parcelHelpers.export(exports, "mergeCss", ()=>mergeCss); -var _extractStyleParts = require("./extractStyleParts"); -var _styleOptionsState = require("./StyleOptionsState"); -var _styleToClassName = require("./styleToClassName"); -function mergeStyles() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - return mergeCss(args, (0, _styleOptionsState.getStyleOptions)()); +parcelHelpers.export(exports, "default", ()=>radial); +var _continuousJs = require("./continuous.js"); +var _continuousJsDefault = parcelHelpers.interopDefault(_continuousJs); +var _initJs = require("./init.js"); +var _linearJs = require("./linear.js"); +var _numberJs = require("./number.js"); +var _numberJsDefault = parcelHelpers.interopDefault(_numberJs); +function square(x) { + return Math.sign(x) * x * x; } -function mergeCss(args, options) { - var styleArgs = args instanceof Array ? args : [ - args - ]; - var _a = (0, _extractStyleParts.extractStyleParts)(styleArgs), classes = _a.classes, objects = _a.objects; - if (objects.length) classes.push((0, _styleToClassName.styleToClassName)(options || {}, objects)); - return classes.join(" "); +function unsquare(x) { + return Math.sign(x) * Math.sqrt(Math.abs(x)); +} +function radial() { + var squared = (0, _continuousJsDefault.default)(), range = [ + 0, + 1 + ], round = false, unknown; + function scale(x) { + var y = unsquare(squared(x)); + return isNaN(y) ? unknown : round ? Math.round(y) : y; + } + scale.invert = function(y) { + return squared.invert(square(y)); + }; + scale.domain = function(_) { + return arguments.length ? (squared.domain(_), scale) : squared.domain(); + }; + scale.range = function(_) { + return arguments.length ? (squared.range((range = Array.from(_, (0, _numberJsDefault.default))).map(square)), scale) : range.slice(); + }; + scale.rangeRound = function(_) { + return scale.range(_).round(true); + }; + scale.round = function(_) { + return arguments.length ? (round = !!_, scale) : round; + }; + scale.clamp = function(_) { + return arguments.length ? (squared.clamp(_), scale) : squared.clamp(); + }; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + scale.copy = function() { + return radial(squared.domain(), range).round(round).clamp(squared.clamp()).unknown(unknown); + }; + (0, _initJs.initRange).apply(scale, arguments); + return (0, _linearJs.linearish)(scale); } -},{"./extractStyleParts":"f7nPn","./StyleOptionsState":"dTpiY","./styleToClassName":"7DnF0","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"f7nPn":[function(require,module,exports) { +},{"./continuous.js":"2SYx4","./init.js":"ijd73","./linear.js":"ik2PQ","./number.js":"aUICk","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ENbdr":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Separates the classes and style objects. Any classes that are pre-registered - * args are auto expanded into objects. - */ parcelHelpers.export(exports, "extractStyleParts", ()=>extractStyleParts); -var _stylesheet = require("./Stylesheet"); -function extractStyleParts() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - var classes = []; - var objects = []; - var stylesheet = (0, _stylesheet.Stylesheet).getInstance(); - function _processArgs(argsList) { - for(var _i = 0, argsList_1 = argsList; _i < argsList_1.length; _i++){ - var arg = argsList_1[_i]; - if (arg) { - if (typeof arg === "string") { - if (arg.indexOf(" ") >= 0) _processArgs(arg.split(" ")); - else { - var translatedArgs = stylesheet.argsFromClassName(arg); - if (translatedArgs) _processArgs(translatedArgs); - else // Avoid adding the same class twice. - if (classes.indexOf(arg) === -1) classes.push(arg); - } - } else if (Array.isArray(arg)) _processArgs(arg); - else if (typeof arg === "object") objects.push(arg); - } - } +parcelHelpers.export(exports, "default", ()=>quantile); +var _d3Array = require("d3-array"); +var _initJs = require("./init.js"); +function quantile() { + var domain = [], range = [], thresholds = [], unknown; + function rescale() { + var i = 0, n = Math.max(1, range.length); + thresholds = new Array(n - 1); + while(++i < n)thresholds[i - 1] = (0, _d3Array.quantileSorted)(domain, i / n); + return scale; } - _processArgs(args); - return { - classes: classes, - objects: objects + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : range[(0, _d3Array.bisect)(thresholds, x)]; + } + scale.invertExtent = function(y) { + var i = range.indexOf(y); + return i < 0 ? [ + NaN, + NaN + ] : [ + i > 0 ? thresholds[i - 1] : domain[0], + i < thresholds.length ? thresholds[i] : domain[domain.length - 1] + ]; + }; + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = []; + for (let d of _)if (d != null && !isNaN(d = +d)) domain.push(d); + domain.sort((0, _d3Array.ascending)); + return rescale(); + }; + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + scale.quantiles = function() { + return thresholds.slice(); + }; + scale.copy = function() { + return quantile().domain(domain).range(range).unknown(unknown); }; + return (0, _initJs.initRange).apply(scale, arguments); } -},{"./Stylesheet":"5cmuF","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5cmuF":[function(require,module,exports) { +},{"d3-array":"5lCYW","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4Cxz6":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "InjectionMode", ()=>InjectionMode); -parcelHelpers.export(exports, "Stylesheet", ()=>Stylesheet); -var _tslib = require("tslib"); -var InjectionMode = { - /** - * Avoids style injection, use getRules() to read the styles. - */ none: 0, - /** - * Inserts rules using the insertRule api. - */ insertNode: 1, - /** - * Appends rules using appendChild. - */ appendChild: 2 -}; -var STYLESHEET_SETTING = "__stylesheet__"; -/** - * MSIE 11 doesn't cascade styles based on DOM ordering, but rather on the order that each style node - * is created. As such, to maintain consistent priority, IE11 should reuse a single style node. - */ var REUSE_STYLE_NODE = typeof navigator !== "undefined" && /rv:11.0/.test(navigator.userAgent); -var _global = {}; -// Grab window. -try { - // Why the cast? - // if compiled/type checked in same program with `@fluentui/font-icons-mdl2` which extends `Window` on global - // ( check packages/font-icons-mdl2/src/index.ts ) the definitions don't match! Thus the need of this extra assertion - _global = window || {}; -} catch (_a) { -/* leave as blank object */ } -var _stylesheet; -/** - * Represents the state of styles registered in the page. Abstracts - * the surface for adding styles to the stylesheet, exposes helpers - * for reading the styles registered in server rendered scenarios. - * - * @public - */ var Stylesheet = /** @class */ function() { - function Stylesheet(config, serializedStylesheet) { - var _a, _b, _c, _d, _e, _f; - this._rules = []; - this._preservedRules = []; - this._counter = 0; - this._keyToClassName = {}; - this._onInsertRuleCallbacks = []; - this._onResetCallbacks = []; - this._classNameToArgs = {}; - this._config = (0, _tslib.__assign)({ - // If there is no document we won't have an element to inject into. - injectionMode: typeof document === "undefined" ? InjectionMode.none : InjectionMode.insertNode, - defaultPrefix: "css", - namespace: undefined, - cspSettings: undefined - }, config); - this._classNameToArgs = (_a = serializedStylesheet === null || serializedStylesheet === void 0 ? void 0 : serializedStylesheet.classNameToArgs) !== null && _a !== void 0 ? _a : this._classNameToArgs; - this._counter = (_b = serializedStylesheet === null || serializedStylesheet === void 0 ? void 0 : serializedStylesheet.counter) !== null && _b !== void 0 ? _b : this._counter; - this._keyToClassName = (_d = (_c = this._config.classNameCache) !== null && _c !== void 0 ? _c : serializedStylesheet === null || serializedStylesheet === void 0 ? void 0 : serializedStylesheet.keyToClassName) !== null && _d !== void 0 ? _d : this._keyToClassName; - this._preservedRules = (_e = serializedStylesheet === null || serializedStylesheet === void 0 ? void 0 : serializedStylesheet.preservedRules) !== null && _e !== void 0 ? _e : this._preservedRules; - this._rules = (_f = serializedStylesheet === null || serializedStylesheet === void 0 ? void 0 : serializedStylesheet.rules) !== null && _f !== void 0 ? _f : this._rules; +parcelHelpers.export(exports, "default", ()=>quantize); +var _d3Array = require("d3-array"); +var _linearJs = require("./linear.js"); +var _initJs = require("./init.js"); +function quantize() { + var x0 = 0, x1 = 1, n = 1, domain = [ + 0.5 + ], range = [ + 0, + 1 + ], unknown; + function scale(x) { + return x != null && x <= x ? range[(0, _d3Array.bisect)(domain, x, 0, n)] : unknown; } - /** - * Gets the singleton instance. - */ Stylesheet.getInstance = function() { - _stylesheet = _global[STYLESHEET_SETTING]; - if (!_stylesheet || _stylesheet._lastStyleElement && _stylesheet._lastStyleElement.ownerDocument !== document) { - var fabricConfig = (_global === null || _global === void 0 ? void 0 : _global.FabricConfig) || {}; - var stylesheet = new Stylesheet(fabricConfig.mergeStyles, fabricConfig.serializedStylesheet); - _stylesheet = stylesheet; - _global[STYLESHEET_SETTING] = stylesheet; - } - return _stylesheet; - }; - /** - * Serializes the Stylesheet instance into a format which allows rehydration on creation. - * @returns string representation of `ISerializedStylesheet` interface. - */ Stylesheet.prototype.serialize = function() { - return JSON.stringify({ - classNameToArgs: this._classNameToArgs, - counter: this._counter, - keyToClassName: this._keyToClassName, - preservedRules: this._preservedRules, - rules: this._rules - }); + function rescale() { + var i = -1; + domain = new Array(n); + while(++i < n)domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1); + return scale; + } + scale.domain = function(_) { + return arguments.length ? ([x0, x1] = _, x0 = +x0, x1 = +x1, rescale()) : [ + x0, + x1 + ]; }; - /** - * Configures the stylesheet. - */ Stylesheet.prototype.setConfig = function(config) { - this._config = (0, _tslib.__assign)((0, _tslib.__assign)({}, this._config), config); + scale.range = function(_) { + return arguments.length ? (n = (range = Array.from(_)).length - 1, rescale()) : range.slice(); }; - /** - * Configures a reset callback. - * - * @param callback - A callback which will be called when the Stylesheet is reset. - * @returns function which when called un-registers provided callback. - */ Stylesheet.prototype.onReset = function(callback) { - var _this = this; - this._onResetCallbacks.push(callback); - return function() { - _this._onResetCallbacks = _this._onResetCallbacks.filter(function(cb) { - return cb !== callback; - }); - }; + scale.invertExtent = function(y) { + var i = range.indexOf(y); + return i < 0 ? [ + NaN, + NaN + ] : i < 1 ? [ + x0, + domain[0] + ] : i >= n ? [ + domain[n - 1], + x1 + ] : [ + domain[i - 1], + domain[i] + ]; }; - /** - * Configures an insert rule callback. - * - * @param callback - A callback which will be called when a rule is inserted. - * @returns function which when called un-registers provided callback. - */ Stylesheet.prototype.onInsertRule = function(callback) { - var _this = this; - this._onInsertRuleCallbacks.push(callback); - return function() { - _this._onInsertRuleCallbacks = _this._onInsertRuleCallbacks.filter(function(cb) { - return cb !== callback; - }); - }; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : scale; }; - /** - * Generates a unique classname. - * - * @param displayName - Optional value to use as a prefix. - */ Stylesheet.prototype.getClassName = function(displayName) { - var namespace = this._config.namespace; - var prefix = displayName || this._config.defaultPrefix; - return "".concat(namespace ? namespace + "-" : "").concat(prefix, "-").concat(this._counter++); + scale.thresholds = function() { + return domain.slice(); }; - /** - * Used internally to cache information about a class which was - * registered with the stylesheet. - */ Stylesheet.prototype.cacheClassName = function(className, key, args, rules) { - this._keyToClassName[key] = className; - this._classNameToArgs[className] = { - args: args, - rules: rules - }; + scale.copy = function() { + return quantize().domain([ + x0, + x1 + ]).range(range).unknown(unknown); }; - /** - * Gets the appropriate classname given a key which was previously - * registered using cacheClassName. - */ Stylesheet.prototype.classNameFromKey = function(key) { - return this._keyToClassName[key]; + return (0, _initJs.initRange).apply((0, _linearJs.linearish)(scale), arguments); +} + +},{"d3-array":"5lCYW","./linear.js":"ik2PQ","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"lQqvO":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>threshold); +var _d3Array = require("d3-array"); +var _initJs = require("./init.js"); +function threshold() { + var domain = [ + 0.5 + ], range = [ + 0, + 1 + ], unknown, n = 1; + function scale(x) { + return x != null && x <= x ? range[(0, _d3Array.bisect)(domain, x, 0, n)] : unknown; + } + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_), n = Math.min(domain.length, range.length - 1), scale) : domain.slice(); }; - /** - * Gets all classnames cache with the stylesheet. - */ Stylesheet.prototype.getClassNameCache = function() { - return this._keyToClassName; + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), n = Math.min(domain.length, range.length - 1), scale) : range.slice(); }; - /** - * Gets the arguments associated with a given classname which was - * previously registered using cacheClassName. - */ Stylesheet.prototype.argsFromClassName = function(className) { - var entry = this._classNameToArgs[className]; - return entry && entry.args; + scale.invertExtent = function(y) { + var i = range.indexOf(y); + return [ + domain[i - 1], + domain[i] + ]; }; - /** - * Gets the rules associated with a given classname which was - * previously registered using cacheClassName. - */ Stylesheet.prototype.insertedRulesFromClassName = function(className) { - var entry = this._classNameToArgs[className]; - return entry && entry.rules; + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; }; - /** - * Inserts a css rule into the stylesheet. - * @param preserve - Preserves the rule beyond a reset boundary. - */ Stylesheet.prototype.insertRule = function(rule, preserve) { - var injectionMode = this._config.injectionMode; - var element = injectionMode !== InjectionMode.none ? this._getStyleElement() : undefined; - if (preserve) this._preservedRules.push(rule); - if (element) switch(injectionMode){ - case InjectionMode.insertNode: - var sheet = element.sheet; - try { - sheet.insertRule(rule, sheet.cssRules.length); - } catch (e) { - // The browser will throw exceptions on unsupported rules (such as a moz prefix in webkit.) - // We need to swallow the exceptions for this scenario, otherwise we'd need to filter - // which could be slower and bulkier. - } - break; - case InjectionMode.appendChild: - element.appendChild(document.createTextNode(rule)); - break; - } - else this._rules.push(rule); - // eslint-disable-next-line deprecation/deprecation - if (this._config.onInsertRule) // eslint-disable-next-line deprecation/deprecation - this._config.onInsertRule(rule); - this._onInsertRuleCallbacks.forEach(function(callback) { - return callback(); - }); + scale.copy = function() { + return threshold().domain(domain).range(range).unknown(unknown); }; - /** - * Gets all rules registered with the stylesheet; only valid when - * using InsertionMode.none. - */ Stylesheet.prototype.getRules = function(includePreservedRules) { - return (includePreservedRules ? this._preservedRules.join("") : "") + this._rules.join(""); + return (0, _initJs.initRange).apply(scale, arguments); +} + +},{"d3-array":"5lCYW","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dtq1F":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "calendar", ()=>calendar); +parcelHelpers.export(exports, "default", ()=>time); +var _d3Time = require("d3-time"); +var _d3TimeFormat = require("d3-time-format"); +var _continuousJs = require("./continuous.js"); +var _continuousJsDefault = parcelHelpers.interopDefault(_continuousJs); +var _initJs = require("./init.js"); +var _niceJs = require("./nice.js"); +var _niceJsDefault = parcelHelpers.interopDefault(_niceJs); +function date(t) { + return new Date(t); +} +function number(t) { + return t instanceof Date ? +t : +new Date(+t); +} +function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) { + var scale = (0, _continuousJsDefault.default)(), invert = scale.invert, domain = scale.domain; + var formatMillisecond = format(".%L"), formatSecond = format(":%S"), formatMinute = format("%I:%M"), formatHour = format("%I %p"), formatDay = format("%a %d"), formatWeek = format("%b %d"), formatMonth = format("%B"), formatYear = format("%Y"); + function tickFormat(date) { + return (second(date) < date ? formatMillisecond : minute(date) < date ? formatSecond : hour(date) < date ? formatMinute : day(date) < date ? formatHour : month(date) < date ? week(date) < date ? formatDay : formatWeek : year(date) < date ? formatMonth : formatYear)(date); + } + scale.invert = function(y) { + return new Date(invert(y)); }; - /** - * Resets the internal state of the stylesheet. Only used in server - * rendered scenarios where we're using InsertionMode.none. - */ Stylesheet.prototype.reset = function() { - this._rules = []; - this._counter = 0; - this._classNameToArgs = {}; - this._keyToClassName = {}; - this._onResetCallbacks.forEach(function(callback) { - return callback(); - }); + scale.domain = function(_) { + return arguments.length ? domain(Array.from(_, number)) : domain().map(date); }; - // Forces the regeneration of incoming styles without totally resetting the stylesheet. - Stylesheet.prototype.resetKeys = function() { - this._keyToClassName = {}; + scale.ticks = function(interval) { + var d = domain(); + return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval); }; - Stylesheet.prototype._getStyleElement = function() { - var _this = this; - if (!this._styleElement && typeof document !== "undefined") { - this._styleElement = this._createStyleElement(); - if (!REUSE_STYLE_NODE) // Reset the style element on the next frame. - window.requestAnimationFrame(function() { - _this._styleElement = undefined; - }); - } - return this._styleElement; + scale.tickFormat = function(count, specifier) { + return specifier == null ? tickFormat : format(specifier); }; - Stylesheet.prototype._createStyleElement = function() { - var head = document.head; - var styleElement = document.createElement("style"); - var nodeToInsertBefore = null; - styleElement.setAttribute("data-merge-styles", "true"); - var cspSettings = this._config.cspSettings; - if (cspSettings) { - if (cspSettings.nonce) styleElement.setAttribute("nonce", cspSettings.nonce); - } - if (this._lastStyleElement) // If the `nextElementSibling` is null, then the insertBefore will act as a regular append. - // https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore#Syntax - nodeToInsertBefore = this._lastStyleElement.nextElementSibling; - else { - var placeholderStyleTag = this._findPlaceholderStyleTag(); - if (placeholderStyleTag) nodeToInsertBefore = placeholderStyleTag.nextElementSibling; - else nodeToInsertBefore = head.childNodes[0]; - } - head.insertBefore(styleElement, head.contains(nodeToInsertBefore) ? nodeToInsertBefore : null); - this._lastStyleElement = styleElement; - return styleElement; + scale.nice = function(interval) { + var d = domain(); + if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval); + return interval ? domain((0, _niceJsDefault.default)(d, interval)) : scale; }; - Stylesheet.prototype._findPlaceholderStyleTag = function() { - var head = document.head; - if (head) return head.querySelector("style[data-merge-styles]"); - return null; + scale.copy = function() { + return (0, _continuousJs.copy)(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format)); }; - return Stylesheet; -}(); + return scale; +} +function time() { + return (0, _initJs.initRange).apply(calendar((0, _d3Time.timeTicks), (0, _d3Time.timeTickInterval), (0, _d3Time.timeYear), (0, _d3Time.timeMonth), (0, _d3Time.timeWeek), (0, _d3Time.timeDay), (0, _d3Time.timeHour), (0, _d3Time.timeMinute), (0, _d3Time.timeSecond), (0, _d3TimeFormat.timeFormat)).domain([ + new Date(2000, 0, 1), + new Date(2000, 0, 2) + ]), arguments); +} -},{"tslib":"01Tx1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dTpiY":[function(require,module,exports) { +},{"d3-time":"6KMda","d3-time-format":"eC6Bi","./continuous.js":"2SYx4","./init.js":"ijd73","./nice.js":"ig9Ha","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6KMda":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Sets the current RTL value. - */ parcelHelpers.export(exports, "setRTL", ()=>setRTL); -/** - * Gets the current RTL value. - */ parcelHelpers.export(exports, "getRTL", ()=>getRTL); -parcelHelpers.export(exports, "getStyleOptions", ()=>getStyleOptions); -function setRTL(isRTL) { - if (_rtl !== isRTL) _rtl = isRTL; -} -function getRTL() { - if (_rtl === undefined) _rtl = typeof document !== "undefined" && !!document.documentElement && document.documentElement.getAttribute("dir") === "rtl"; - return _rtl; -} -// This has been split into 2 lines because it was working in Fabric due to the code being transpiled to es5, so this -// was converted to var while not working in Fluent that uses babel to transpile the code to be es6-like. Splitting the -// logic into two lines, however, allows it to work in both scenarios. -var _rtl; -_rtl = getRTL(); -function getStyleOptions() { - return { - rtl: getRTL() - }; -} +parcelHelpers.export(exports, "timeInterval", ()=>(0, _intervalJs.timeInterval)); +parcelHelpers.export(exports, "utcMillisecond", ()=>(0, _millisecondJs.millisecond)); +parcelHelpers.export(exports, "utcMilliseconds", ()=>(0, _millisecondJs.milliseconds)); +parcelHelpers.export(exports, "timeMillisecond", ()=>(0, _millisecondJs.millisecond)); +parcelHelpers.export(exports, "timeMilliseconds", ()=>(0, _millisecondJs.milliseconds)); +parcelHelpers.export(exports, "utcSecond", ()=>(0, _secondJs.second)); +parcelHelpers.export(exports, "utcSeconds", ()=>(0, _secondJs.seconds)); +parcelHelpers.export(exports, "timeSecond", ()=>(0, _secondJs.second)); +parcelHelpers.export(exports, "timeSeconds", ()=>(0, _secondJs.seconds)); +parcelHelpers.export(exports, "timeMinute", ()=>(0, _minuteJs.timeMinute)); +parcelHelpers.export(exports, "timeMinutes", ()=>(0, _minuteJs.timeMinutes)); +parcelHelpers.export(exports, "utcMinute", ()=>(0, _minuteJs.utcMinute)); +parcelHelpers.export(exports, "utcMinutes", ()=>(0, _minuteJs.utcMinutes)); +parcelHelpers.export(exports, "timeHour", ()=>(0, _hourJs.timeHour)); +parcelHelpers.export(exports, "timeHours", ()=>(0, _hourJs.timeHours)); +parcelHelpers.export(exports, "utcHour", ()=>(0, _hourJs.utcHour)); +parcelHelpers.export(exports, "utcHours", ()=>(0, _hourJs.utcHours)); +parcelHelpers.export(exports, "timeDay", ()=>(0, _dayJs.timeDay)); +parcelHelpers.export(exports, "timeDays", ()=>(0, _dayJs.timeDays)); +parcelHelpers.export(exports, "utcDay", ()=>(0, _dayJs.utcDay)); +parcelHelpers.export(exports, "utcDays", ()=>(0, _dayJs.utcDays)); +parcelHelpers.export(exports, "unixDay", ()=>(0, _dayJs.unixDay)); +parcelHelpers.export(exports, "unixDays", ()=>(0, _dayJs.unixDays)); +parcelHelpers.export(exports, "timeWeek", ()=>(0, _weekJs.timeSunday)); +parcelHelpers.export(exports, "timeWeeks", ()=>(0, _weekJs.timeSundays)); +parcelHelpers.export(exports, "timeSunday", ()=>(0, _weekJs.timeSunday)); +parcelHelpers.export(exports, "timeSundays", ()=>(0, _weekJs.timeSundays)); +parcelHelpers.export(exports, "timeMonday", ()=>(0, _weekJs.timeMonday)); +parcelHelpers.export(exports, "timeMondays", ()=>(0, _weekJs.timeMondays)); +parcelHelpers.export(exports, "timeTuesday", ()=>(0, _weekJs.timeTuesday)); +parcelHelpers.export(exports, "timeTuesdays", ()=>(0, _weekJs.timeTuesdays)); +parcelHelpers.export(exports, "timeWednesday", ()=>(0, _weekJs.timeWednesday)); +parcelHelpers.export(exports, "timeWednesdays", ()=>(0, _weekJs.timeWednesdays)); +parcelHelpers.export(exports, "timeThursday", ()=>(0, _weekJs.timeThursday)); +parcelHelpers.export(exports, "timeThursdays", ()=>(0, _weekJs.timeThursdays)); +parcelHelpers.export(exports, "timeFriday", ()=>(0, _weekJs.timeFriday)); +parcelHelpers.export(exports, "timeFridays", ()=>(0, _weekJs.timeFridays)); +parcelHelpers.export(exports, "timeSaturday", ()=>(0, _weekJs.timeSaturday)); +parcelHelpers.export(exports, "timeSaturdays", ()=>(0, _weekJs.timeSaturdays)); +parcelHelpers.export(exports, "utcWeek", ()=>(0, _weekJs.utcSunday)); +parcelHelpers.export(exports, "utcWeeks", ()=>(0, _weekJs.utcSundays)); +parcelHelpers.export(exports, "utcSunday", ()=>(0, _weekJs.utcSunday)); +parcelHelpers.export(exports, "utcSundays", ()=>(0, _weekJs.utcSundays)); +parcelHelpers.export(exports, "utcMonday", ()=>(0, _weekJs.utcMonday)); +parcelHelpers.export(exports, "utcMondays", ()=>(0, _weekJs.utcMondays)); +parcelHelpers.export(exports, "utcTuesday", ()=>(0, _weekJs.utcTuesday)); +parcelHelpers.export(exports, "utcTuesdays", ()=>(0, _weekJs.utcTuesdays)); +parcelHelpers.export(exports, "utcWednesday", ()=>(0, _weekJs.utcWednesday)); +parcelHelpers.export(exports, "utcWednesdays", ()=>(0, _weekJs.utcWednesdays)); +parcelHelpers.export(exports, "utcThursday", ()=>(0, _weekJs.utcThursday)); +parcelHelpers.export(exports, "utcThursdays", ()=>(0, _weekJs.utcThursdays)); +parcelHelpers.export(exports, "utcFriday", ()=>(0, _weekJs.utcFriday)); +parcelHelpers.export(exports, "utcFridays", ()=>(0, _weekJs.utcFridays)); +parcelHelpers.export(exports, "utcSaturday", ()=>(0, _weekJs.utcSaturday)); +parcelHelpers.export(exports, "utcSaturdays", ()=>(0, _weekJs.utcSaturdays)); +parcelHelpers.export(exports, "timeMonth", ()=>(0, _monthJs.timeMonth)); +parcelHelpers.export(exports, "timeMonths", ()=>(0, _monthJs.timeMonths)); +parcelHelpers.export(exports, "utcMonth", ()=>(0, _monthJs.utcMonth)); +parcelHelpers.export(exports, "utcMonths", ()=>(0, _monthJs.utcMonths)); +parcelHelpers.export(exports, "timeYear", ()=>(0, _yearJs.timeYear)); +parcelHelpers.export(exports, "timeYears", ()=>(0, _yearJs.timeYears)); +parcelHelpers.export(exports, "utcYear", ()=>(0, _yearJs.utcYear)); +parcelHelpers.export(exports, "utcYears", ()=>(0, _yearJs.utcYears)); +parcelHelpers.export(exports, "utcTicks", ()=>(0, _ticksJs.utcTicks)); +parcelHelpers.export(exports, "utcTickInterval", ()=>(0, _ticksJs.utcTickInterval)); +parcelHelpers.export(exports, "timeTicks", ()=>(0, _ticksJs.timeTicks)); +parcelHelpers.export(exports, "timeTickInterval", ()=>(0, _ticksJs.timeTickInterval)); +var _intervalJs = require("./interval.js"); +var _millisecondJs = require("./millisecond.js"); +var _secondJs = require("./second.js"); +var _minuteJs = require("./minute.js"); +var _hourJs = require("./hour.js"); +var _dayJs = require("./day.js"); +var _weekJs = require("./week.js"); +var _monthJs = require("./month.js"); +var _yearJs = require("./year.js"); +var _ticksJs = require("./ticks.js"); -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7DnF0":[function(require,module,exports) { +},{"./interval.js":false,"./millisecond.js":"2UJoZ","./second.js":"bm0xM","./minute.js":"ifdFS","./hour.js":"xWpVx","./day.js":"aXPXh","./week.js":"1cvLV","./month.js":"764Za","./year.js":"4SlFD","./ticks.js":"9x0uu","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9JWhy":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "serializeRuleEntries", ()=>serializeRuleEntries); -parcelHelpers.export(exports, "styleToRegistration", ()=>styleToRegistration); -/** - * Insert style to stylesheet. - * @param registration Style registration. - * @param specificityMultiplier Number of times classname selector is repeated in the css rule. - * This is to increase css specificity in case it's needed. Default to 1. - */ parcelHelpers.export(exports, "applyRegistration", ()=>applyRegistration); -parcelHelpers.export(exports, "styleToClassName", ()=>styleToClassName); -var _tslib = require("tslib"); -var _stylesheet = require("./Stylesheet"); -var _kebabRules = require("./transforms/kebabRules"); -var _prefixRules = require("./transforms/prefixRules"); -var _provideUnits = require("./transforms/provideUnits"); -var _rtlifyRules = require("./transforms/rtlifyRules"); -var _tokenizeWithParentheses = require("./tokenizeWithParentheses"); -var DISPLAY_NAME = "displayName"; -function getDisplayName(rules) { - var rootStyle = rules && rules["&"]; - return rootStyle ? rootStyle.displayName : undefined; -} -var globalSelectorRegExp = /\:global\((.+?)\)/g; -/** - * Finds comma separated selectors in a :global() e.g. ":global(.class1, .class2, .class3)" - * and wraps them each in their own global ":global(.class1), :global(.class2), :global(.class3)" - * - * @param selectorWithGlobals The selector to process - * @returns The updated selector - */ function expandCommaSeparatedGlobals(selectorWithGlobals) { - // We the selector does not have a :global() we can shortcut - if (!globalSelectorRegExp.test(selectorWithGlobals)) return selectorWithGlobals; - var replacementInfo = []; - var findGlobal = /\:global\((.+?)\)/g; - var match = null; - // Create a result list for global selectors so we can replace them. - while(match = findGlobal.exec(selectorWithGlobals))// Only if the found selector is a comma separated list we'll process it. - if (match[1].indexOf(",") > -1) replacementInfo.push([ - match.index, - match.index + match[0].length, - // Wrap each of the found selectors in :global() - match[1].split(",").map(function(v) { - return ":global(".concat(v.trim(), ")"); - }).join(", "), - ]); - // Replace the found selectors with their wrapped variants in reverse order - return replacementInfo.reverse().reduce(function(selector, _a) { - var matchIndex = _a[0], matchEndIndex = _a[1], replacement = _a[2]; - var prefix = selector.slice(0, matchIndex); - var suffix = selector.slice(matchEndIndex); - return prefix + replacement + suffix; - }, selectorWithGlobals); -} -function expandSelector(newSelector, currentSelector) { - if (newSelector.indexOf(":global(") >= 0) return newSelector.replace(globalSelectorRegExp, "$1"); - else if (newSelector.indexOf(":") === 0) return currentSelector + newSelector; - else if (newSelector.indexOf("&") < 0) return currentSelector + " " + newSelector; - return newSelector; -} -function extractSelector(currentSelector, rules, selector, value) { - if (rules === void 0) rules = { - __order: [] +parcelHelpers.export(exports, "timeInterval", ()=>timeInterval); +const t0 = new Date, t1 = new Date; +function timeInterval(floori, offseti, count, field) { + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + interval.floor = (date)=>{ + return floori(date = new Date(+date)), date; }; - if (selector.indexOf("@") === 0) { - selector = selector + "{" + currentSelector; - extractRules([ - value - ], rules, selector); - } else if (selector.indexOf(",") > -1) expandCommaSeparatedGlobals(selector).split(",").map(function(s) { - return s.trim(); - }).forEach(function(separatedSelector) { - return extractRules([ - value - ], rules, expandSelector(separatedSelector, currentSelector)); - }); - else extractRules([ - value - ], rules, expandSelector(selector, currentSelector)); -} -function extractRules(args, rules, currentSelector) { - if (rules === void 0) rules = { - __order: [] + interval.ceil = (date)=>{ + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; }; - if (currentSelector === void 0) currentSelector = "&"; - var stylesheet = (0, _stylesheet.Stylesheet).getInstance(); - var currentRules = rules[currentSelector]; - if (!currentRules) { - currentRules = {}; - rules[currentSelector] = currentRules; - rules.__order.push(currentSelector); - } - for(var _i = 0, args_1 = args; _i < args_1.length; _i++){ - var arg = args_1[_i]; - // If the arg is a string, we need to look up the class map and merge. - if (typeof arg === "string") { - var expandedRules = stylesheet.argsFromClassName(arg); - if (expandedRules) extractRules(expandedRules, rules, currentSelector); - // Else if the arg is an array, we need to recurse in. - } else if (Array.isArray(arg)) extractRules(arg, rules, currentSelector); - else { - for(var prop in arg)if (arg.hasOwnProperty(prop)) { - var propValue = arg[prop]; - if (prop === "selectors") { - // every child is a selector. - var selectors = arg.selectors; - for(var newSelector in selectors)if (selectors.hasOwnProperty(newSelector)) extractSelector(currentSelector, rules, newSelector, selectors[newSelector]); - } else if (typeof propValue === "object") // prop is a selector. - { - if (propValue !== null) extractSelector(currentSelector, rules, prop, propValue); - } else if (propValue !== undefined) { - // Else, add the rule to the currentSelector. - if (prop === "margin" || prop === "padding") expandQuads(currentRules, prop, propValue); - else currentRules[prop] = propValue; + interval.round = (date)=>{ + const d0 = interval(date), d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + interval.offset = (date, step)=>{ + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + interval.range = (start, stop, step)=>{ + const range = []; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + let previous; + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + interval.filter = (test)=>{ + return timeInterval((date)=>{ + if (date >= date) while(floori(date), !test(date))date.setTime(date - 1); + }, (date, step)=>{ + if (date >= date) { + if (step < 0) while(++step <= 0){ + while(offseti(date, -1), !test(date)); // eslint-disable-line no-empty + } + else while(--step >= 0){ + while(offseti(date, 1), !test(date)); // eslint-disable-line no-empty } } - } - } - return rules; -} -function expandQuads(currentRules, name, value) { - var parts = typeof value === "string" ? (0, _tokenizeWithParentheses.tokenizeWithParentheses)(value) : [ - value - ]; - if (parts.length === 0) parts.push(value); - if (parts[parts.length - 1] === "!important") // Remove !important from parts, and append it to each part individually - parts = parts.slice(0, -1).map(function(p) { - return p + " !important"; - }); - currentRules[name + "Top"] = parts[0]; - currentRules[name + "Right"] = parts[1] || parts[0]; - currentRules[name + "Bottom"] = parts[2] || parts[0]; - currentRules[name + "Left"] = parts[3] || parts[1] || parts[0]; -} -function getKeyForRules(options, rules) { - var serialized = [ - options.rtl ? "rtl" : "ltr" - ]; - var hasProps = false; - for(var _i = 0, _a = rules.__order; _i < _a.length; _i++){ - var selector = _a[_i]; - serialized.push(selector); - var rulesForSelector = rules[selector]; - for(var propName in rulesForSelector)if (rulesForSelector.hasOwnProperty(propName) && rulesForSelector[propName] !== undefined) { - hasProps = true; - serialized.push(propName, rulesForSelector[propName]); - } - } - return hasProps ? serialized.join("") : undefined; -} -function repeatString(target, count) { - if (count <= 0) return ""; - if (count === 1) return target; - return target + repeatString(target, count - 1); -} -function serializeRuleEntries(options, ruleEntries) { - if (!ruleEntries) return ""; - var allEntries = []; - for(var entry in ruleEntries)if (ruleEntries.hasOwnProperty(entry) && entry !== DISPLAY_NAME && ruleEntries[entry] !== undefined) allEntries.push(entry, ruleEntries[entry]); - // Apply transforms. - for(var i = 0; i < allEntries.length; i += 2){ - (0, _kebabRules.kebabRules)(allEntries, i); - (0, _provideUnits.provideUnits)(allEntries, i); - (0, _rtlifyRules.rtlifyRules)(options, allEntries, i); - (0, _prefixRules.prefixRules)(allEntries, i); - } - // Apply punctuation. - for(var i = 1; i < allEntries.length; i += 4)allEntries.splice(i, 1, ":", allEntries[i], ";"); - return allEntries.join(""); -} -function styleToRegistration(options) { - var args = []; - for(var _i = 1; _i < arguments.length; _i++)args[_i - 1] = arguments[_i]; - var rules = extractRules(args); - var key = getKeyForRules(options, rules); - if (key) { - var stylesheet = (0, _stylesheet.Stylesheet).getInstance(); - var registration = { - className: stylesheet.classNameFromKey(key), - key: key, - args: args + }); + }; + if (count) { + interval.count = (start, end)=>{ + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + interval.every = (step)=>{ + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null : !(step > 1) ? interval : interval.filter(field ? (d)=>field(d) % step === 0 : (d)=>interval.count(0, d) % step === 0); }; - if (!registration.className) { - registration.className = stylesheet.getClassName(getDisplayName(rules)); - var rulesToInsert = []; - for(var _a = 0, _b = rules.__order; _a < _b.length; _a++){ - var selector = _b[_a]; - rulesToInsert.push(selector, serializeRuleEntries(options, rules[selector])); - } - registration.rulesToInsert = rulesToInsert; - } - return registration; - } - return undefined; -} -function applyRegistration(registration, specificityMultiplier) { - if (specificityMultiplier === void 0) specificityMultiplier = 1; - var stylesheet = (0, _stylesheet.Stylesheet).getInstance(); - var className = registration.className, key = registration.key, args = registration.args, rulesToInsert = registration.rulesToInsert; - if (rulesToInsert) { - // rulesToInsert is an ordered array of selector/rule pairs. - for(var i = 0; i < rulesToInsert.length; i += 2){ - var rules = rulesToInsert[i + 1]; - if (rules) { - var selector = rulesToInsert[i]; - selector = selector.replace(/&/g, repeatString(".".concat(registration.className), specificityMultiplier)); - // Insert. Note if a media query, we must close the query with a final bracket. - var processedRule = "".concat(selector, "{").concat(rules, "}").concat(selector.indexOf("@") === 0 ? "}" : ""); - stylesheet.insertRule(processedRule); - } - } - stylesheet.cacheClassName(className, key, args, rulesToInsert); - } -} -function styleToClassName(options) { - var args = []; - for(var _i = 1; _i < arguments.length; _i++)args[_i - 1] = arguments[_i]; - var registration = styleToRegistration.apply(void 0, (0, _tslib.__spreadArray)([ - options - ], args, false)); - if (registration) { - applyRegistration(registration, options.specificityMultiplier); - return registration.className; } - return ""; + return interval; } -},{"tslib":"01Tx1","./Stylesheet":"5cmuF","./transforms/kebabRules":"dQrbw","./transforms/prefixRules":"5oR6n","./transforms/provideUnits":"7H0pE","./transforms/rtlifyRules":"7R6DA","./tokenizeWithParentheses":"dkCSW","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dQrbw":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2UJoZ":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "kebabRules", ()=>kebabRules); -var rules = {}; -function kebabRules(rulePairs, index) { - var rule = rulePairs[index]; - if (rule.charAt(0) !== "-") rulePairs[index] = rules[rule] = rules[rule] || rule.replace(/([A-Z])/g, "-$1").toLowerCase(); -} +parcelHelpers.export(exports, "millisecond", ()=>millisecond); +parcelHelpers.export(exports, "milliseconds", ()=>milliseconds); +var _intervalJs = require("./interval.js"); +const millisecond = (0, _intervalJs.timeInterval)(()=>{ +// noop +}, (date, step)=>{ + date.setTime(+date + step); +}, (start, end)=>{ + return end - start; +}); +// An optimized implementation for this simple case. +millisecond.every = (k)=>{ + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return (0, _intervalJs.timeInterval)((date)=>{ + date.setTime(Math.floor(date / k) * k); + }, (date, step)=>{ + date.setTime(+date + step * k); + }, (start, end)=>{ + return (end - start) / k; + }); +}; +const milliseconds = millisecond.range; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5oR6n":[function(require,module,exports) { +},{"./interval.js":"9JWhy","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"bm0xM":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "prefixRules", ()=>prefixRules); -var _getVendorSettings = require("../getVendorSettings"); -var autoPrefixNames = { - "user-select": 1 -}; -function prefixRules(rulePairs, index) { - var vendorSettings = (0, _getVendorSettings.getVendorSettings)(); - var name = rulePairs[index]; - if (autoPrefixNames[name]) { - var value = rulePairs[index + 1]; - if (autoPrefixNames[name]) { - if (vendorSettings.isWebkit) rulePairs.push("-webkit-" + name, value); - if (vendorSettings.isMoz) rulePairs.push("-moz-" + name, value); - if (vendorSettings.isMs) rulePairs.push("-ms-" + name, value); - if (vendorSettings.isOpera) rulePairs.push("-o-" + name, value); - } - } -} +parcelHelpers.export(exports, "second", ()=>second); +parcelHelpers.export(exports, "seconds", ()=>seconds); +var _intervalJs = require("./interval.js"); +var _durationJs = require("./duration.js"); +const second = (0, _intervalJs.timeInterval)((date)=>{ + date.setTime(date - date.getMilliseconds()); +}, (date, step)=>{ + date.setTime(+date + step * (0, _durationJs.durationSecond)); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationSecond); +}, (date)=>{ + return date.getUTCSeconds(); +}); +const seconds = second.range; -},{"../getVendorSettings":"cuxGa","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cuxGa":[function(require,module,exports) { +},{"./interval.js":"9JWhy","./duration.js":"eRqDr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eRqDr":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getVendorSettings", ()=>getVendorSettings); -/** - * Sets the vendor settings for prefixing and vendor specific operations. - */ parcelHelpers.export(exports, "setVendorSettings", ()=>setVendorSettings); -var _vendorSettings; -function getVendorSettings() { - var _a; - if (!_vendorSettings) { - var doc = typeof document !== "undefined" ? document : undefined; - var nav = typeof navigator !== "undefined" ? navigator : undefined; - var userAgent = (_a = nav === null || nav === void 0 ? void 0 : nav.userAgent) === null || _a === void 0 ? void 0 : _a.toLowerCase(); - if (!doc) _vendorSettings = { - isWebkit: true, - isMoz: true, - isOpera: true, - isMs: true - }; - else _vendorSettings = { - isWebkit: !!(doc && "WebkitAppearance" in doc.documentElement.style), - isMoz: !!(userAgent && userAgent.indexOf("firefox") > -1), - isOpera: !!(userAgent && userAgent.indexOf("opera") > -1), - isMs: !!(nav && (/rv:11.0/i.test(nav.userAgent) || /Edge\/\d./i.test(navigator.userAgent))) - }; - } - return _vendorSettings; -} -function setVendorSettings(vendorSettings) { - _vendorSettings = vendorSettings; -} +parcelHelpers.export(exports, "durationSecond", ()=>durationSecond); +parcelHelpers.export(exports, "durationMinute", ()=>durationMinute); +parcelHelpers.export(exports, "durationHour", ()=>durationHour); +parcelHelpers.export(exports, "durationDay", ()=>durationDay); +parcelHelpers.export(exports, "durationWeek", ()=>durationWeek); +parcelHelpers.export(exports, "durationMonth", ()=>durationMonth); +parcelHelpers.export(exports, "durationYear", ()=>durationYear); +const durationSecond = 1000; +const durationMinute = durationSecond * 60; +const durationHour = durationMinute * 60; +const durationDay = durationHour * 24; +const durationWeek = durationDay * 7; +const durationMonth = durationDay * 30; +const durationYear = durationDay * 365; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7H0pE":[function(require,module,exports) { +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"ifdFS":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "provideUnits", ()=>provideUnits); -var NON_PIXEL_NUMBER_PROPS = [ - "column-count", - "font-weight", - "flex", - "flex-grow", - "flex-shrink", - "fill-opacity", - "opacity", - "order", - "z-index", - "zoom", -]; -function provideUnits(rulePairs, index) { - var name = rulePairs[index]; - var value = rulePairs[index + 1]; - if (typeof value === "number") { - var isNonPixelProp = NON_PIXEL_NUMBER_PROPS.indexOf(name) > -1; - var isVariableOrPrefixed = name.indexOf("--") > -1; - var unit = isNonPixelProp || isVariableOrPrefixed ? "" : "px"; - rulePairs[index + 1] = "".concat(value).concat(unit); - } -} +parcelHelpers.export(exports, "timeMinute", ()=>timeMinute); +parcelHelpers.export(exports, "timeMinutes", ()=>timeMinutes); +parcelHelpers.export(exports, "utcMinute", ()=>utcMinute); +parcelHelpers.export(exports, "utcMinutes", ()=>utcMinutes); +var _intervalJs = require("./interval.js"); +var _durationJs = require("./duration.js"); +const timeMinute = (0, _intervalJs.timeInterval)((date)=>{ + date.setTime(date - date.getMilliseconds() - date.getSeconds() * (0, _durationJs.durationSecond)); +}, (date, step)=>{ + date.setTime(+date + step * (0, _durationJs.durationMinute)); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationMinute); +}, (date)=>{ + return date.getMinutes(); +}); +const timeMinutes = timeMinute.range; +const utcMinute = (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCSeconds(0, 0); +}, (date, step)=>{ + date.setTime(+date + step * (0, _durationJs.durationMinute)); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationMinute); +}, (date)=>{ + return date.getUTCMinutes(); +}); +const utcMinutes = utcMinute.range; + +},{"./interval.js":"9JWhy","./duration.js":"eRqDr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"xWpVx":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "timeHour", ()=>timeHour); +parcelHelpers.export(exports, "timeHours", ()=>timeHours); +parcelHelpers.export(exports, "utcHour", ()=>utcHour); +parcelHelpers.export(exports, "utcHours", ()=>utcHours); +var _intervalJs = require("./interval.js"); +var _durationJs = require("./duration.js"); +const timeHour = (0, _intervalJs.timeInterval)((date)=>{ + date.setTime(date - date.getMilliseconds() - date.getSeconds() * (0, _durationJs.durationSecond) - date.getMinutes() * (0, _durationJs.durationMinute)); +}, (date, step)=>{ + date.setTime(+date + step * (0, _durationJs.durationHour)); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationHour); +}, (date)=>{ + return date.getHours(); +}); +const timeHours = timeHour.range; +const utcHour = (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCMinutes(0, 0, 0); +}, (date, step)=>{ + date.setTime(+date + step * (0, _durationJs.durationHour)); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationHour); +}, (date)=>{ + return date.getUTCHours(); +}); +const utcHours = utcHour.range; + +},{"./interval.js":"9JWhy","./duration.js":"eRqDr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"aXPXh":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "timeDay", ()=>timeDay); +parcelHelpers.export(exports, "timeDays", ()=>timeDays); +parcelHelpers.export(exports, "utcDay", ()=>utcDay); +parcelHelpers.export(exports, "utcDays", ()=>utcDays); +parcelHelpers.export(exports, "unixDay", ()=>unixDay); +parcelHelpers.export(exports, "unixDays", ()=>unixDays); +var _intervalJs = require("./interval.js"); +var _durationJs = require("./duration.js"); +const timeDay = (0, _intervalJs.timeInterval)((date)=>date.setHours(0, 0, 0, 0), (date, step)=>date.setDate(date.getDate() + step), (start, end)=>(end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * (0, _durationJs.durationMinute)) / (0, _durationJs.durationDay), (date)=>date.getDate() - 1); +const timeDays = timeDay.range; +const utcDay = (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCHours(0, 0, 0, 0); +}, (date, step)=>{ + date.setUTCDate(date.getUTCDate() + step); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationDay); +}, (date)=>{ + return date.getUTCDate() - 1; +}); +const utcDays = utcDay.range; +const unixDay = (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCHours(0, 0, 0, 0); +}, (date, step)=>{ + date.setUTCDate(date.getUTCDate() + step); +}, (start, end)=>{ + return (end - start) / (0, _durationJs.durationDay); +}, (date)=>{ + return Math.floor(date / (0, _durationJs.durationDay)); +}); +const unixDays = unixDay.range; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7R6DA":[function(require,module,exports) { +},{"./interval.js":"9JWhy","./duration.js":"eRqDr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"1cvLV":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * RTLifies the rulePair in the array at the current index. This mutates the array for performance - * reasons. - */ parcelHelpers.export(exports, "rtlifyRules", ()=>rtlifyRules); -var _a; -var LEFT = "left"; -var RIGHT = "right"; -var NO_FLIP = "@noflip"; -var NAME_REPLACEMENTS = (_a = {}, _a[LEFT] = RIGHT, _a[RIGHT] = LEFT, _a); -var VALUE_REPLACEMENTS = { - "w-resize": "e-resize", - "sw-resize": "se-resize", - "nw-resize": "ne-resize" -}; -function rtlifyRules(options, rulePairs, index) { - if (options.rtl) { - var name_1 = rulePairs[index]; - if (!name_1) return; - var value = rulePairs[index + 1]; - if (typeof value === "string" && value.indexOf(NO_FLIP) >= 0) rulePairs[index + 1] = value.replace(/\s*(?:\/\*\s*)?\@noflip\b(?:\s*\*\/)?\s*?/g, ""); - else if (name_1.indexOf(LEFT) >= 0) rulePairs[index] = name_1.replace(LEFT, RIGHT); - else if (name_1.indexOf(RIGHT) >= 0) rulePairs[index] = name_1.replace(RIGHT, LEFT); - else if (String(value).indexOf(LEFT) >= 0) rulePairs[index + 1] = value.replace(LEFT, RIGHT); - else if (String(value).indexOf(RIGHT) >= 0) rulePairs[index + 1] = value.replace(RIGHT, LEFT); - else if (NAME_REPLACEMENTS[name_1]) rulePairs[index] = NAME_REPLACEMENTS[name_1]; - else if (VALUE_REPLACEMENTS[value]) rulePairs[index + 1] = VALUE_REPLACEMENTS[value]; - else switch(name_1){ - case "margin": - case "padding": - rulePairs[index + 1] = flipQuad(value); - break; - case "box-shadow": - rulePairs[index + 1] = negateNum(value, 0); - break; - } - } -} -/** - * Given a string value in a space delimited format (e.g. "1 2 3 4"), negates a particular value. - */ function negateNum(value, partIndex) { - var parts = value.split(" "); - var numberVal = parseInt(parts[partIndex], 10); - parts[0] = parts[0].replace(String(numberVal), String(numberVal * -1)); - return parts.join(" "); +parcelHelpers.export(exports, "timeSunday", ()=>timeSunday); +parcelHelpers.export(exports, "timeMonday", ()=>timeMonday); +parcelHelpers.export(exports, "timeTuesday", ()=>timeTuesday); +parcelHelpers.export(exports, "timeWednesday", ()=>timeWednesday); +parcelHelpers.export(exports, "timeThursday", ()=>timeThursday); +parcelHelpers.export(exports, "timeFriday", ()=>timeFriday); +parcelHelpers.export(exports, "timeSaturday", ()=>timeSaturday); +parcelHelpers.export(exports, "timeSundays", ()=>timeSundays); +parcelHelpers.export(exports, "timeMondays", ()=>timeMondays); +parcelHelpers.export(exports, "timeTuesdays", ()=>timeTuesdays); +parcelHelpers.export(exports, "timeWednesdays", ()=>timeWednesdays); +parcelHelpers.export(exports, "timeThursdays", ()=>timeThursdays); +parcelHelpers.export(exports, "timeFridays", ()=>timeFridays); +parcelHelpers.export(exports, "timeSaturdays", ()=>timeSaturdays); +parcelHelpers.export(exports, "utcSunday", ()=>utcSunday); +parcelHelpers.export(exports, "utcMonday", ()=>utcMonday); +parcelHelpers.export(exports, "utcTuesday", ()=>utcTuesday); +parcelHelpers.export(exports, "utcWednesday", ()=>utcWednesday); +parcelHelpers.export(exports, "utcThursday", ()=>utcThursday); +parcelHelpers.export(exports, "utcFriday", ()=>utcFriday); +parcelHelpers.export(exports, "utcSaturday", ()=>utcSaturday); +parcelHelpers.export(exports, "utcSundays", ()=>utcSundays); +parcelHelpers.export(exports, "utcMondays", ()=>utcMondays); +parcelHelpers.export(exports, "utcTuesdays", ()=>utcTuesdays); +parcelHelpers.export(exports, "utcWednesdays", ()=>utcWednesdays); +parcelHelpers.export(exports, "utcThursdays", ()=>utcThursdays); +parcelHelpers.export(exports, "utcFridays", ()=>utcFridays); +parcelHelpers.export(exports, "utcSaturdays", ()=>utcSaturdays); +var _intervalJs = require("./interval.js"); +var _durationJs = require("./duration.js"); +function timeWeekday(i) { + return (0, _intervalJs.timeInterval)((date)=>{ + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, (date, step)=>{ + date.setDate(date.getDate() + step * 7); + }, (start, end)=>{ + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * (0, _durationJs.durationMinute)) / (0, _durationJs.durationWeek); + }); } -/** - * Given a string quad, flips the left and right values. - */ function flipQuad(value) { - if (typeof value === "string") { - var parts = value.split(" "); - if (parts.length === 4) return "".concat(parts[0], " ").concat(parts[3], " ").concat(parts[2], " ").concat(parts[1]); - } - return value; +const timeSunday = timeWeekday(0); +const timeMonday = timeWeekday(1); +const timeTuesday = timeWeekday(2); +const timeWednesday = timeWeekday(3); +const timeThursday = timeWeekday(4); +const timeFriday = timeWeekday(5); +const timeSaturday = timeWeekday(6); +const timeSundays = timeSunday.range; +const timeMondays = timeMonday.range; +const timeTuesdays = timeTuesday.range; +const timeWednesdays = timeWednesday.range; +const timeThursdays = timeThursday.range; +const timeFridays = timeFriday.range; +const timeSaturdays = timeSaturday.range; +function utcWeekday(i) { + return (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, (date, step)=>{ + date.setUTCDate(date.getUTCDate() + step * 7); + }, (start, end)=>{ + return (end - start) / (0, _durationJs.durationWeek); + }); } +const utcSunday = utcWeekday(0); +const utcMonday = utcWeekday(1); +const utcTuesday = utcWeekday(2); +const utcWednesday = utcWeekday(3); +const utcThursday = utcWeekday(4); +const utcFriday = utcWeekday(5); +const utcSaturday = utcWeekday(6); +const utcSundays = utcSunday.range; +const utcMondays = utcMonday.range; +const utcTuesdays = utcTuesday.range; +const utcWednesdays = utcWednesday.range; +const utcThursdays = utcThursday.range; +const utcFridays = utcFriday.range; +const utcSaturdays = utcSaturday.range; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dkCSW":[function(require,module,exports) { +},{"./interval.js":"9JWhy","./duration.js":"eRqDr","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"764Za":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Split a string into tokens separated by whitespace, except all text within parentheses - * is treated as a single token (whitespace is ignored within parentheses). - * - * Unlike String.split(' '), multiple consecutive space characters are collapsed and - * removed from the returned array (including leading and trailing spaces). - * - * For example: - * `tokenizeWithParentheses("3px calc(var(--x) / 2) 9px 0 ")` - * => `["3px", "calc(var(--x) / 2)", "9px", "0"]` - * - * @returns The array of tokens. Returns an empty array if the string was empty or contained only whitespace. - */ parcelHelpers.export(exports, "tokenizeWithParentheses", ()=>tokenizeWithParentheses); -function tokenizeWithParentheses(value) { - var parts = []; - var partStart = 0; - var parens = 0; - for(var i = 0; i < value.length; i++)switch(value[i]){ - case "(": - parens++; - break; - case ")": - if (parens) parens--; - break; - case " ": - case " ": - if (!parens) { - // Add the new part if it's not an empty string - if (i > partStart) parts.push(value.substring(partStart, i)); - partStart = i + 1; - } - break; - } - // Add the last part - if (partStart < value.length) parts.push(value.substring(partStart)); - return parts; -} +parcelHelpers.export(exports, "timeMonth", ()=>timeMonth); +parcelHelpers.export(exports, "timeMonths", ()=>timeMonths); +parcelHelpers.export(exports, "utcMonth", ()=>utcMonth); +parcelHelpers.export(exports, "utcMonths", ()=>utcMonths); +var _intervalJs = require("./interval.js"); +const timeMonth = (0, _intervalJs.timeInterval)((date)=>{ + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, (date, step)=>{ + date.setMonth(date.getMonth() + step); +}, (start, end)=>{ + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, (date)=>{ + return date.getMonth(); +}); +const timeMonths = timeMonth.range; +const utcMonth = (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step)=>{ + date.setUTCMonth(date.getUTCMonth() + step); +}, (start, end)=>{ + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, (date)=>{ + return date.getUTCMonth(); +}); +const utcMonths = utcMonth.range; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"1R7DK":[function(require,module,exports) { +},{"./interval.js":"9JWhy","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"4SlFD":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Takes in one or more style set objects, each consisting of a set of areas, - * each which will produce a class name. Using this is analogous to calling - * `mergeStyles` for each property in the object, but ensures we maintain the - * set ordering when multiple style sets are merged. - * - * @param styleSets - One or more style sets to be merged. - */ parcelHelpers.export(exports, "mergeStyleSets", ()=>mergeStyleSets); -/** - * Takes in one or more style set objects, each1consisting of a set of areas, - * each which will produce a class name. Using this is analogous to calling - * `mergeCss` for each property in the object, but ensures the - * set ordering when multiple style sets are merged. - * - * @param styleSets - One or more style sets to be merged. - * @param options - (optional) Options to use when creating rules. - */ parcelHelpers.export(exports, "mergeCssSets", ()=>mergeCssSets); -var _concatStyleSets = require("./concatStyleSets"); -var _extractStyleParts = require("./extractStyleParts"); -var _styleOptionsState = require("./StyleOptionsState"); -var _styleToClassName = require("./styleToClassName"); -function mergeStyleSets() { - var styleSets = []; - for(var _i = 0; _i < arguments.length; _i++)styleSets[_i] = arguments[_i]; - return mergeCssSets(styleSets, (0, _styleOptionsState.getStyleOptions)()); -} -function mergeCssSets(styleSets, options) { - var classNameSet = { - subComponentStyles: {} - }; - var styleSet = styleSets[0]; - if (!styleSet && styleSets.length <= 1) return { - subComponentStyles: {} - }; - var concatenatedStyleSet = (0, _concatStyleSets.concatStyleSets).apply(void 0, styleSets); - var registrations = []; - for(var styleSetArea in concatenatedStyleSet)if (concatenatedStyleSet.hasOwnProperty(styleSetArea)) { - if (styleSetArea === "subComponentStyles") { - classNameSet.subComponentStyles = concatenatedStyleSet.subComponentStyles || {}; - continue; - } - var styles = concatenatedStyleSet[styleSetArea]; - var _a = (0, _extractStyleParts.extractStyleParts)(styles), classes = _a.classes, objects = _a.objects; - if (objects === null || objects === void 0 ? void 0 : objects.length) { - var registration = (0, _styleToClassName.styleToRegistration)(options || {}, { - displayName: styleSetArea - }, objects); - if (registration) { - registrations.push(registration); - // FIXME: classNameSet invalid types - exposed in TS 4.5 - cast needed - classNameSet[styleSetArea] = classes.concat([ - registration.className - ]).join(" "); - } - } else // FIXME: classNameSet invalid types - exposed in TS 4.5 - cast needed - classNameSet[styleSetArea] = classes.join(" "); - } - for(var _i = 0, registrations_1 = registrations; _i < registrations_1.length; _i++){ - var registration = registrations_1[_i]; - if (registration) (0, _styleToClassName.applyRegistration)(registration, options === null || options === void 0 ? void 0 : options.specificityMultiplier); - } - return classNameSet; -} +parcelHelpers.export(exports, "timeYear", ()=>timeYear); +parcelHelpers.export(exports, "timeYears", ()=>timeYears); +parcelHelpers.export(exports, "utcYear", ()=>utcYear); +parcelHelpers.export(exports, "utcYears", ()=>utcYears); +var _intervalJs = require("./interval.js"); +const timeYear = (0, _intervalJs.timeInterval)((date)=>{ + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, (date, step)=>{ + date.setFullYear(date.getFullYear() + step); +}, (start, end)=>{ + return end.getFullYear() - start.getFullYear(); +}, (date)=>{ + return date.getFullYear(); +}); +// An optimized implementation for this simple case. +timeYear.every = (k)=>{ + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : (0, _intervalJs.timeInterval)((date)=>{ + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, (date, step)=>{ + date.setFullYear(date.getFullYear() + step * k); + }); +}; +const timeYears = timeYear.range; +const utcYear = (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step)=>{ + date.setUTCFullYear(date.getUTCFullYear() + step); +}, (start, end)=>{ + return end.getUTCFullYear() - start.getUTCFullYear(); +}, (date)=>{ + return date.getUTCFullYear(); +}); +// An optimized implementation for this simple case. +utcYear.every = (k)=>{ + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : (0, _intervalJs.timeInterval)((date)=>{ + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, (date, step)=>{ + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; +const utcYears = utcYear.range; -},{"./concatStyleSets":"g4PxR","./extractStyleParts":"f7nPn","./StyleOptionsState":"dTpiY","./styleToClassName":"7DnF0","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"g4PxR":[function(require,module,exports) { +},{"./interval.js":"9JWhy","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"9x0uu":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Combine a set of styles together (but does not register css classes). - * @param styleSets - One or more stylesets to be merged (each param can also be falsy). - */ parcelHelpers.export(exports, "concatStyleSets", ()=>concatStyleSets); -var _tslib = require("tslib"); -function concatStyleSets() { - var styleSets = []; - for(var _i = 0; _i < arguments.length; _i++)styleSets[_i] = arguments[_i]; - if (styleSets && styleSets.length === 1 && styleSets[0] && !styleSets[0].subComponentStyles) return styleSets[0]; - var mergedSet = {}; - // We process sub component styles in two phases. First we collect them, then we combine them into 1 style function. - var workingSubcomponentStyles = {}; - for(var _a = 0, styleSets_1 = styleSets; _a < styleSets_1.length; _a++){ - var currentSet = styleSets_1[_a]; - if (currentSet) { - for(var prop in currentSet)if (currentSet.hasOwnProperty(prop)) { - if (prop === "subComponentStyles" && currentSet.subComponentStyles !== undefined) { - // subcomponent styles - style functions or objects - var currentComponentStyles = currentSet.subComponentStyles; - for(var subCompProp in currentComponentStyles)if (currentComponentStyles.hasOwnProperty(subCompProp)) { - if (workingSubcomponentStyles.hasOwnProperty(subCompProp)) workingSubcomponentStyles[subCompProp].push(currentComponentStyles[subCompProp]); - else workingSubcomponentStyles[subCompProp] = [ - currentComponentStyles[subCompProp] - ]; - } - continue; - } - // the as any casts below is a workaround for ts 2.8. - // todo: remove cast to any in ts 2.9. - var mergedValue = mergedSet[prop]; - var currentValue = currentSet[prop]; - if (mergedValue === undefined) mergedSet[prop] = currentValue; - else mergedSet[prop] = (0, _tslib.__spreadArray)((0, _tslib.__spreadArray)([], Array.isArray(mergedValue) ? mergedValue : [ - mergedValue - ], true), Array.isArray(currentValue) ? currentValue : [ - currentValue - ], true); - } - } - } - if (Object.keys(workingSubcomponentStyles).length > 0) { - mergedSet.subComponentStyles = {}; - var mergedSubStyles = mergedSet.subComponentStyles; - var _loop_1 = function(subCompProp) { - if (workingSubcomponentStyles.hasOwnProperty(subCompProp)) { - var workingSet_1 = workingSubcomponentStyles[subCompProp]; - mergedSubStyles[subCompProp] = function(styleProps) { - return concatStyleSets.apply(void 0, workingSet_1.map(function(styleFunctionOrObject) { - return typeof styleFunctionOrObject === "function" ? styleFunctionOrObject(styleProps) : styleFunctionOrObject; - })); - }; - } - }; - // now we process the subcomponent styles if there are any - for(var subCompProp in workingSubcomponentStyles)_loop_1(subCompProp); +parcelHelpers.export(exports, "utcTicks", ()=>utcTicks); +parcelHelpers.export(exports, "utcTickInterval", ()=>utcTickInterval); +parcelHelpers.export(exports, "timeTicks", ()=>timeTicks); +parcelHelpers.export(exports, "timeTickInterval", ()=>timeTickInterval); +var _d3Array = require("d3-array"); +var _durationJs = require("./duration.js"); +var _millisecondJs = require("./millisecond.js"); +var _secondJs = require("./second.js"); +var _minuteJs = require("./minute.js"); +var _hourJs = require("./hour.js"); +var _dayJs = require("./day.js"); +var _weekJs = require("./week.js"); +var _monthJs = require("./month.js"); +var _yearJs = require("./year.js"); +function ticker(year, month, week, day, hour, minute) { + const tickIntervals = [ + [ + (0, _secondJs.second), + 1, + (0, _durationJs.durationSecond) + ], + [ + (0, _secondJs.second), + 5, + 5 * (0, _durationJs.durationSecond) + ], + [ + (0, _secondJs.second), + 15, + 15 * (0, _durationJs.durationSecond) + ], + [ + (0, _secondJs.second), + 30, + 30 * (0, _durationJs.durationSecond) + ], + [ + minute, + 1, + (0, _durationJs.durationMinute) + ], + [ + minute, + 5, + 5 * (0, _durationJs.durationMinute) + ], + [ + minute, + 15, + 15 * (0, _durationJs.durationMinute) + ], + [ + minute, + 30, + 30 * (0, _durationJs.durationMinute) + ], + [ + hour, + 1, + (0, _durationJs.durationHour) + ], + [ + hour, + 3, + 3 * (0, _durationJs.durationHour) + ], + [ + hour, + 6, + 6 * (0, _durationJs.durationHour) + ], + [ + hour, + 12, + 12 * (0, _durationJs.durationHour) + ], + [ + day, + 1, + (0, _durationJs.durationDay) + ], + [ + day, + 2, + 2 * (0, _durationJs.durationDay) + ], + [ + week, + 1, + (0, _durationJs.durationWeek) + ], + [ + month, + 1, + (0, _durationJs.durationMonth) + ], + [ + month, + 3, + 3 * (0, _durationJs.durationMonth) + ], + [ + year, + 1, + (0, _durationJs.durationYear) + ] + ]; + function ticks(start, stop, count) { + const reverse = stop < start; + if (reverse) [start, stop] = [ + stop, + start + ]; + const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count); + const ticks = interval ? interval.range(start, +stop + 1) : []; // inclusive stop + return reverse ? ticks.reverse() : ticks; } - return mergedSet; -} - -},{"tslib":"01Tx1","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"eTVxs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Concatenates style sets into one, but resolves functional sets using the given props. - * @param styleProps - Props used to resolve functional sets. - * @param allStyles - Style sets, which can be functions or objects. - */ parcelHelpers.export(exports, "concatStyleSetsWithProps", ()=>concatStyleSetsWithProps); -var _concatStyleSets = require("./concatStyleSets"); -function concatStyleSetsWithProps(styleProps) { - var allStyles = []; - for(var _i = 1; _i < arguments.length; _i++)allStyles[_i - 1] = arguments[_i]; - var result = []; - for(var _a = 0, allStyles_1 = allStyles; _a < allStyles_1.length; _a++){ - var styles = allStyles_1[_a]; - if (styles) result.push(typeof styles === "function" ? styles(styleProps) : styles); + function tickInterval(start, stop, count) { + const target = Math.abs(stop - start) / count; + const i = (0, _d3Array.bisector)(([, , step])=>step).right(tickIntervals, target); + if (i === tickIntervals.length) return year.every((0, _d3Array.tickStep)(start / (0, _durationJs.durationYear), stop / (0, _durationJs.durationYear), count)); + if (i === 0) return (0, _millisecondJs.millisecond).every(Math.max((0, _d3Array.tickStep)(start, stop, count), 1)); + const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; + return t.every(step); } - if (result.length === 1) return result[0]; - else if (result.length) // cliffkoh: I cannot figure out how to avoid the cast to any here. - // It is something to do with the use of Omit in IStyleSet. - // It might not be necessary once Omit becomes part of lib.d.ts (when we remove our own Omit and rely on - // the official version). - return (0, _concatStyleSets.concatStyleSets).apply(void 0, result); - return {}; + return [ + ticks, + tickInterval + ]; } +const [utcTicks, utcTickInterval] = ticker((0, _yearJs.utcYear), (0, _monthJs.utcMonth), (0, _weekJs.utcSunday), (0, _dayJs.unixDay), (0, _hourJs.utcHour), (0, _minuteJs.utcMinute)); +const [timeTicks, timeTickInterval] = ticker((0, _yearJs.timeYear), (0, _monthJs.timeMonth), (0, _weekJs.timeSunday), (0, _dayJs.timeDay), (0, _hourJs.timeHour), (0, _minuteJs.timeMinute)); -},{"./concatStyleSets":"g4PxR","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"011dQ":[function(require,module,exports) { +},{"d3-array":"5lCYW","./duration.js":"eRqDr","./millisecond.js":"2UJoZ","./second.js":"bm0xM","./minute.js":"ifdFS","./hour.js":"xWpVx","./day.js":"aXPXh","./week.js":"1cvLV","./month.js":"764Za","./year.js":"4SlFD","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"eC6Bi":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Registers a font face. - * @public - */ parcelHelpers.export(exports, "fontFace", ()=>fontFace); -var _styleOptionsState = require("./StyleOptionsState"); -var _stylesheet = require("./Stylesheet"); -var _styleToClassName = require("./styleToClassName"); -function fontFace(font) { - var stylesheet = (0, _stylesheet.Stylesheet).getInstance(); - var rule = (0, _styleToClassName.serializeRuleEntries)((0, _styleOptionsState.getStyleOptions)(), font); - var className = stylesheet.classNameFromKey(rule); - if (className) return; - var name = stylesheet.getClassName(); - stylesheet.insertRule("@font-face{".concat(rule, "}"), true); - stylesheet.cacheClassName(name, rule, [], [ - "font-face", - rule - ]); -} +parcelHelpers.export(exports, "timeFormatDefaultLocale", ()=>(0, _defaultLocaleJsDefault.default)); +parcelHelpers.export(exports, "timeFormat", ()=>(0, _defaultLocaleJs.timeFormat)); +parcelHelpers.export(exports, "timeParse", ()=>(0, _defaultLocaleJs.timeParse)); +parcelHelpers.export(exports, "utcFormat", ()=>(0, _defaultLocaleJs.utcFormat)); +parcelHelpers.export(exports, "utcParse", ()=>(0, _defaultLocaleJs.utcParse)); +parcelHelpers.export(exports, "timeFormatLocale", ()=>(0, _localeJsDefault.default)); +parcelHelpers.export(exports, "isoFormat", ()=>(0, _isoFormatJsDefault.default)); +parcelHelpers.export(exports, "isoParse", ()=>(0, _isoParseJsDefault.default)); +var _defaultLocaleJs = require("./defaultLocale.js"); +var _defaultLocaleJsDefault = parcelHelpers.interopDefault(_defaultLocaleJs); +var _localeJs = require("./locale.js"); +var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); +var _isoFormatJs = require("./isoFormat.js"); +var _isoFormatJsDefault = parcelHelpers.interopDefault(_isoFormatJs); +var _isoParseJs = require("./isoParse.js"); +var _isoParseJsDefault = parcelHelpers.interopDefault(_isoParseJs); -},{"./StyleOptionsState":"dTpiY","./Stylesheet":"5cmuF","./styleToClassName":"7DnF0","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"dTsCK":[function(require,module,exports) { +},{"./defaultLocale.js":"dYsS4","./locale.js":"hOUzu","./isoFormat.js":false,"./isoParse.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"dYsS4":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Registers keyframe definitions. - * - * @public - */ parcelHelpers.export(exports, "keyframes", ()=>keyframes); -var _styleOptionsState = require("./StyleOptionsState"); -var _stylesheet = require("./Stylesheet"); -var _styleToClassName = require("./styleToClassName"); -function keyframes(timeline) { - var stylesheet = (0, _stylesheet.Stylesheet).getInstance(); - var rulesArray = []; - for(var prop in timeline)if (timeline.hasOwnProperty(prop)) rulesArray.push(prop, "{", (0, _styleToClassName.serializeRuleEntries)((0, _styleOptionsState.getStyleOptions)(), timeline[prop]), "}"); - var rules = rulesArray.join(""); - var className = stylesheet.classNameFromKey(rules); - if (className) return className; - var name = stylesheet.getClassName(); - stylesheet.insertRule("@keyframes ".concat(name, "{").concat(rules, "}"), true); - stylesheet.cacheClassName(name, rules, [], [ - "keyframes", - rules - ]); - return name; +parcelHelpers.export(exports, "timeFormat", ()=>timeFormat); +parcelHelpers.export(exports, "timeParse", ()=>timeParse); +parcelHelpers.export(exports, "utcFormat", ()=>utcFormat); +parcelHelpers.export(exports, "utcParse", ()=>utcParse); +parcelHelpers.export(exports, "default", ()=>defaultLocale); +var _localeJs = require("./locale.js"); +var _localeJsDefault = parcelHelpers.interopDefault(_localeJs); +var locale; +var timeFormat; +var timeParse; +var utcFormat; +var utcParse; +defaultLocale({ + dateTime: "%x, %X", + date: "%-m/%-d/%Y", + time: "%-I:%M:%S %p", + periods: [ + "AM", + "PM" + ], + days: [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday" + ], + shortDays: [ + "Sun", + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat" + ], + months: [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" + ], + shortMonths: [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" + ] +}); +function defaultLocale(definition) { + locale = (0, _localeJsDefault.default)(definition); + timeFormat = locale.format; + timeParse = locale.parse; + utcFormat = locale.utcFormat; + utcParse = locale.utcParse; + return locale; } -},{"./StyleOptionsState":"dTpiY","./Stylesheet":"5cmuF","./styleToClassName":"7DnF0","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fEGdU":[function(require,module,exports) { +},{"./locale.js":"hOUzu","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hOUzu":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Helper to get bounding client rect. Passing in window will get the window size. - * - * @public - */ parcelHelpers.export(exports, "getRect", ()=>getRect); -function getRect(element) { - var rect; - if (element) { - if (element === window) rect = { - left: 0, - top: 0, - width: window.innerWidth, - height: window.innerHeight, - right: window.innerWidth, - bottom: window.innerHeight - }; - else if (element.getBoundingClientRect) rect = element.getBoundingClientRect(); +parcelHelpers.export(exports, "default", ()=>formatLocale); +var _d3Time = require("d3-time"); +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; } - return rect; + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"vNedS":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "BaseComponent", ()=>BaseComponent); -/** - * Simple constant function for returning null, used to render empty templates in JSX. - * - * @public - */ parcelHelpers.export(exports, "nullRender", ()=>nullRender); -var _tslib = require("tslib"); -var _react = require("react"); -var _async = require("./Async"); -var _eventGroup = require("./EventGroup"); -var _warnConditionallyRequiredProps = require("./warn/warnConditionallyRequiredProps"); -var _warnMutuallyExclusive = require("./warn/warnMutuallyExclusive"); -var _warnDeprecations = require("./warn/warnDeprecations"); -/** - * BaseComponent class, which provides basic helpers for all components. - * - * @public - * {@docCategory BaseComponent} - * - * @deprecated Do not use. We are moving away from class component. - */ var BaseComponent = /** @class */ function(_super) { - (0, _tslib.__extends)(BaseComponent, _super); - /** - * BaseComponent constructor - * @param props - The props for the component. - * @param context - The context for the component. - */ // eslint-disable-next-line @typescript-eslint/no-explicit-any - function BaseComponent(props, context) { - var _this = _super.call(this, props, context) || this; - // eslint-disable-next-line deprecation/deprecation - _makeAllSafe(_this, BaseComponent.prototype, [ - "componentDidMount", - "shouldComponentUpdate", - "getSnapshotBeforeUpdate", - "render", - "componentDidUpdate", - "componentWillUnmount", - ]); - return _this; +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; } - /** - * When the component receives props, make sure the componentRef is updated. - */ BaseComponent.prototype.componentDidUpdate = function(prevProps, prevState) { - this._updateComponentRef(prevProps, this.props); + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} +function newDate(y, m, d) { + return { + y: y, + m: m, + d: d, + H: 0, + M: 0, + S: 0, + L: 0 }; - /** - * When the component has mounted, update the componentRef. - */ BaseComponent.prototype.componentDidMount = function() { - this._setComponentRef(this.props.componentRef, this); +} +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_weekdays = locale.days, locale_shortWeekdays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths; + var periodRe = formatRe(locale_periods), periodLookup = formatLookup(locale_periods), weekdayRe = formatRe(locale_weekdays), weekdayLookup = formatLookup(locale_weekdays), shortWeekdayRe = formatRe(locale_shortWeekdays), shortWeekdayLookup = formatLookup(locale_shortWeekdays), monthRe = formatRe(locale_months), monthLookup = formatLookup(locale_months), shortMonthRe = formatRe(locale_shortMonths), shortMonthLookup = formatLookup(locale_shortMonths); + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "g": formatYearISO, + "G": formatFullYearISO, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent }; - /** - * If we have disposables, dispose them automatically on unmount. - */ BaseComponent.prototype.componentWillUnmount = function() { - this._setComponentRef(this.props.componentRef, null); - if (this.__disposables) { - for(var i = 0, len = this._disposables.length; i < len; i++){ - var disposable = this.__disposables[i]; - if (disposable.dispose) disposable.dispose(); - } - this.__disposables = null; - } + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "g": formatUTCYearISO, + "G": formatUTCFullYearISO, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent }; - Object.defineProperty(BaseComponent.prototype, "className", { - /** - * Gets the object's class name. - */ get: function() { - if (!this.__className) { - var funcNameRegex = /function (.{1,})\(/; - var results = funcNameRegex.exec(this.constructor.toString()); - this.__className = results && results.length > 1 ? results[1] : ""; + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "g": parseYear, + "G": parseFullYear, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + function newFormat(specifier, formats) { + return function(date) { + var string = [], i = -1, j = 0, n = specifier.length, c, pad, format; + if (!(date instanceof Date)) date = new Date(+date); + while(++i < n)if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; } - return this.__className; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseComponent.prototype, "_disposables", { - /** - * Allows subclasses to push things to this._disposables to be auto disposed. - */ get: function() { - if (!this.__disposables) this.__disposables = []; - return this.__disposables; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseComponent.prototype, "_async", { - /** - * Gets the async instance associated with the component, created on demand. The async instance gives - * subclasses a way to execute setTimeout/setInterval async calls safely, where the callbacks - * will be cleared/ignored automatically after unmounting. The helpers within the async object also - * preserve the this pointer so that you don't need to "bind" the callbacks. - */ get: function() { - if (!this.__async) { - this.__async = new (0, _async.Async)(this); - this._disposables.push(this.__async); + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), i = parseSpecifier(d, specifier, string += "", 0), week, day; + if (i != string.length) return null; + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? (0, _d3Time.utcMonday).ceil(week) : (0, _d3Time.utcMonday)(week); + week = (0, _d3Time.utcDay).offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? (0, _d3Time.timeMonday).ceil(week) : (0, _d3Time.timeMonday)(week); + week = (0, _d3Time.timeDay).offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; } - return this.__async; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseComponent.prototype, "_events", { - /** - * Gets the event group instance assocaited with the component, created on demand. The event instance - * provides on/off methods for listening to DOM (or regular javascript object) events. The event callbacks - * will be automatically disconnected after unmounting. The helpers within the events object also - * preserve the this reference so that you don't need to "bind" the callbacks. - */ get: function() { - if (!this.__events) { - this.__events = new (0, _eventGroup.EventGroup)(this); - this._disposables.push(this.__events); + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); } - return this.__events; - }, - enumerable: false, - configurable: true - }); - /** - * Helper to return a memoized ref resolver function. - * @param refName - Name of the member to assign the ref to. - * @returns A function instance keyed from the given refname. - * @deprecated Use `createRef` from React.createRef. - */ BaseComponent.prototype._resolveRef = function(refName) { - var _this = this; - if (!this.__resolves) this.__resolves = {}; - if (!this.__resolves[refName]) this.__resolves[refName] = function(ref) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return _this[refName] = ref; + // Otherwise, all fields are in local time. + return localDate(d); }; - return this.__resolves[refName]; - }; - /** - * Updates the componentRef (by calling it with "this" when necessary.) - */ BaseComponent.prototype._updateComponentRef = function(currentProps, newProps) { - if (newProps === void 0) newProps = {}; - // currentProps *should* always be defined, but verify that just in case a subclass is manually - // calling a lifecycle method with no parameters (which has happened) or other odd usage. - if (currentProps && newProps && currentProps.componentRef !== newProps.componentRef) { - this._setComponentRef(currentProps.componentRef, null); - this._setComponentRef(newProps.componentRef, this); + } + function parseSpecifier(d, specifier, string, j) { + var i = 0, n = specifier.length, m = string.length, c, parse; + while(i < n){ + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || (j = parse(d, string, j)) < 0) return -1; + } else if (c != string.charCodeAt(j++)) return -1; } - }; - /** - * Warns when a deprecated props are being used. - * - * @param deprecationMap - The map of deprecations, where key is the prop name and the value is - * either null or a replacement prop name. - */ BaseComponent.prototype._warnDeprecations = function(deprecationMap) { - (0, _warnDeprecations.warnDeprecations)(this.className, this.props, deprecationMap); - }; - /** - * Warns when props which are mutually exclusive with each other are both used. - * - * @param mutuallyExclusiveMap - The map of mutually exclusive props. - */ BaseComponent.prototype._warnMutuallyExclusive = function(mutuallyExclusiveMap) { - (0, _warnMutuallyExclusive.warnMutuallyExclusive)(this.className, this.props, mutuallyExclusiveMap); - }; - /** - * Warns when props are required if a condition is met. - * - * @param requiredProps - The name of the props that are required when the condition is met. - * @param conditionalPropName - The name of the prop that the condition is based on. - * @param condition - Whether the condition is met. - */ BaseComponent.prototype._warnConditionallyRequiredProps = function(requiredProps, conditionalPropName, condition) { - (0, _warnConditionallyRequiredProps.warnConditionallyRequiredProps)(this.className, this.props, requiredProps, conditionalPropName, condition); - }; - BaseComponent.prototype._setComponentRef = function(ref, value) { - if (!this._skipComponentRefResolution && ref) { - if (typeof ref === "function") ref(value); - if (typeof ref === "object") // eslint-disable-next-line @typescript-eslint/no-explicit-any - ref.current = value; + return j; + } + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { + return specifier; + }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { + return specifier; + }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { + return specifier; + }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { + return specifier; + }; + return p; } }; - return BaseComponent; -}(_react.Component); -/** - * Helper to override a given method with a wrapper method that can try/catch the original, but also - * ensures that the BaseComponent's methods are called before the subclass's. This ensures that - * componentWillUnmount in the base is called and that things in the _disposables array are disposed. - */ // eslint-disable-next-line deprecation/deprecation -function _makeAllSafe(obj, prototype, methodNames) { - for(var i = 0, len = methodNames.length; i < len; i++)_makeSafe(obj, prototype, methodNames[i]); } -// eslint-disable-next-line deprecation/deprecation -function _makeSafe(obj, prototype, methodName) { - /* eslint-disable @typescript-eslint/no-explicit-any */ var classMethod = obj[methodName]; - var prototypeMethod = prototype[methodName]; - if (classMethod || prototypeMethod) obj[methodName] = function() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - /* eslint-enable @typescript-eslint/no-explicit-any */ var retVal; - if (prototypeMethod) retVal = prototypeMethod.apply(this, args); - if (classMethod !== prototypeMethod) retVal = classMethod.apply(this, args); - return retVal; - }; +var pads = { + "-": "", + "_": " ", + "0": "0" +}, numberRe = /^\s*\d+/, percentRe = /^%/, requoteRe = /[\\^$*+?|[\]().{}]/g; +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); } -function nullRender() { - return null; +function requote(s) { + return s.replace(requoteRe, "\\$&"); } - -},{"tslib":"01Tx1","react":"8ePka","./Async":"hAQcF","./EventGroup":"bQDG8","./warn/warnConditionallyRequiredProps":"aqitP","./warn/warnMutuallyExclusive":"kWVSG","./warn/warnDeprecations":"5WdRA","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aqitP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Warns when props are required if a condition is met. - * - * @public - * @param componentName - The name of the component being used. - * @param props - The props passed into the component. - * @param requiredProps - The name of the props that are required when the condition is met. - * @param conditionalPropName - The name of the prop that the condition is based on. - * @param condition - Whether the condition is met. - */ parcelHelpers.export(exports, "warnConditionallyRequiredProps", ()=>warnConditionallyRequiredProps); -var _warn = require("./warn"); -function warnConditionallyRequiredProps(componentName, props, requiredProps, conditionalPropName, condition) { - var _i, requiredProps_1, requiredPropName; +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); } - -},{"./warn":"TxsYr","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"TxsYr":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Sends a warning to console, if the api is present. - * - * @public - * @param message - Warning message. - */ parcelHelpers.export(exports, "warn", ()=>warn); -/** - * Configures the warning callback. Passing in undefined will reset it to use the default - * console.warn function. - * - * @public - * @param warningCallback - Callback to override the generated warnings. - */ parcelHelpers.export(exports, "setWarningCallback", ()=>setWarningCallback); -/* eslint-disable no-console */ var _warningCallback = undefined; -function warn(message) { - if (console && console.warn) console.warn(message); +function formatLookup(names) { + return new Map(names.map((name, i)=>[ + name.toLowerCase(), + i + ])); } -function setWarningCallback(warningCallback) { - _warningCallback = warningCallback; +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kWVSG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Warns when two props which are mutually exclusive are both being used. - * - * @public - * @param componentName - The name of the component being used. - * @param props - The props passed into the component. - * @param exclusiveMap - A map where the key is a parameter, and the value is the other parameter. - */ parcelHelpers.export(exports, "warnMutuallyExclusive", ()=>warnMutuallyExclusive); -var _warn = require("./warn"); -function warnMutuallyExclusive(componentName, props, exclusiveMap) { - var propName, propInExclusiveMapValue; +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; } - -},{"./warn":"TxsYr","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5WdRA":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Warns when a deprecated props are being used. - * - * @public - * @param componentName - The name of the component being used. - * @param props - The props passed into the component. - * @param deprecationMap - The map of deprecations, where key is the prop name and the value is - * either null or a replacement prop name. - */ parcelHelpers.export(exports, "warnDeprecations", ()=>warnDeprecations); -var _warn = require("./warn"); -function warnDeprecations(componentName, props, deprecationMap) { - var propName, deprecationMessage, replacementPropName; +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; } - -},{"./warn":"TxsYr","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kBgki":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DelayedRender", ()=>DelayedRender); -var _tslib = require("tslib"); -var _react = require("react"); -var _getWindow = require("./dom/getWindow"); -/** - * Utility component for delaying the render of a child component after a given delay. This component - * requires a single child component; don't pass in many components. Wrap multiple components in a DIV - * if necessary. - * - * @public - * {@docCategory DelayedRender} - */ var DelayedRender = /** @class */ function(_super) { - (0, _tslib.__extends)(DelayedRender, _super); - function DelayedRender(props) { - var _this = _super.call(this, props) || this; - _this.state = { - isRendered: (0, _getWindow.getWindow)() === undefined - }; - return _this; - } - DelayedRender.prototype.componentDidMount = function() { - var _this = this; - var delay = this.props.delay; - this._timeoutId = window.setTimeout(function() { - _this.setState({ - isRendered: true - }); - }, delay); - }; - DelayedRender.prototype.componentWillUnmount = function() { - if (this._timeoutId) clearTimeout(this._timeoutId); - }; - DelayedRender.prototype.render = function() { - return this.state.isRendered ? _react.Children.only(this.props.children) : null; - }; - DelayedRender.defaultProps = { - delay: 0 - }; - return DelayedRender; -}(_react.Component); - -},{"tslib":"01Tx1","react":"8ePka","./dom/getWindow":"i0Ddq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cJi5t":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "FabricPerformance", ()=>FabricPerformance); -var now = function() { - return typeof performance !== "undefined" && !!performance.now ? performance.now() : Date.now(); -}; -var RESET_INTERVAL = 180000; // auto reset every 3 minutes -/** - * Performance helper class for measuring things. - * - * @public - * {@docCategory FabricPerformance} - */ var FabricPerformance = /** @class */ function() { - function FabricPerformance() {} - /** - * Measures execution time of the given syncronous function. If the same logic is executed multiple times, - * each individual measurement will be collected as well the overall numbers. - * @param name - The name of this measurement - * @param func - The logic to be measured for execution time - */ FabricPerformance.measure = function(name, func) { - if (FabricPerformance._timeoutId) FabricPerformance.setPeriodicReset(); - var start = now(); - func(); - var end = now(); - var measurement = FabricPerformance.summary[name] || { - totalDuration: 0, - count: 0, - all: [] - }; - var duration = end - start; - measurement.totalDuration += duration; - measurement.count++; - measurement.all.push({ - duration: duration, - timeStamp: end - }); - FabricPerformance.summary[name] = measurement; - }; - FabricPerformance.reset = function() { - FabricPerformance.summary = {}; - clearTimeout(FabricPerformance._timeoutId); - FabricPerformance._timeoutId = NaN; - }; - FabricPerformance.setPeriodicReset = function() { - FabricPerformance._timeoutId = setTimeout(function() { - return FabricPerformance.reset(); - }, RESET_INTERVAL); - }; - FabricPerformance.summary = {}; - return FabricPerformance; -}(); - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hOBvf":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "GlobalSettings", ()=>GlobalSettings); -var _getWindow = require("./dom/getWindow"); -/** - * Storing global state in local module variables has issues when more than one copy - * if the module gets loaded on the page (due to a bundling error or simply by consuming - * a prebundled script.) - * - * This file contains helpers to deal with the getting and setting local state, and allows - * callers to get called back when it mutates. - */ var GLOBAL_SETTINGS_PROP_NAME = "__globalSettings__"; -var CALLBACK_STATE_PROP_NAME = "__callbacks__"; -var _counter = 0; -/** - * Global settings helper, which stores settings in the global (window) namespace. - * If window is not provided, it will store settings in module scope. Provides a - * way to observe changes as well when their values change. - * - * @public - * {@docCategory GlobalSettings} - */ var GlobalSettings = /** @class */ function() { - function GlobalSettings() {} - GlobalSettings.getValue = function(key, defaultValue) { - var globalSettings = _getGlobalSettings(); - if (globalSettings[key] === undefined) globalSettings[key] = typeof defaultValue === "function" ? defaultValue() : defaultValue; - return globalSettings[key]; - }; - GlobalSettings.setValue = function(key, value) { - var globalSettings = _getGlobalSettings(); - var callbacks = globalSettings[CALLBACK_STATE_PROP_NAME]; - var oldValue = globalSettings[key]; - if (value !== oldValue) { - globalSettings[key] = value; - var changeDescription = { - oldValue: oldValue, - value: value, - key: key - }; - for(var id in callbacks)if (callbacks.hasOwnProperty(id)) callbacks[id](changeDescription); - } - return value; - }; - GlobalSettings.addChangeListener = function(cb) { - // Note: we use generated ids on the callbacks to create a map of the callbacks, which optimizes removal. - // (It's faster to delete a key than it is to look up the index of an object and splice an array.) - var id = cb.__id__; - var callbacks = _getCallbacks(); - if (!id) id = cb.__id__ = String(_counter++); - callbacks[id] = cb; - }; - GlobalSettings.removeChangeListener = function(cb) { - var callbacks = _getCallbacks(); - delete callbacks[cb.__id__]; - }; - return GlobalSettings; -}(); -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function _getGlobalSettings() { - var _a; - var win = (0, _getWindow.getWindow)(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var globalObj = win || {}; - if (!globalObj[GLOBAL_SETTINGS_PROP_NAME]) globalObj[GLOBAL_SETTINGS_PROP_NAME] = (_a = {}, _a[CALLBACK_STATE_PROP_NAME] = {}, _a); - return globalObj[GLOBAL_SETTINGS_PROP_NAME]; +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; } -function _getCallbacks() { - var globalSettings = _getGlobalSettings(); - return globalSettings[CALLBACK_STATE_PROP_NAME]; +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; } - -},{"./dom/getWindow":"i0Ddq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"aVdtV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "KeyCodes", ()=>KeyCodes); -var KeyCodes = { - backspace: 8, - tab: 9, - enter: 13, - shift: 16, - ctrl: 17, - alt: 18, - pauseBreak: 19, - capslock: 20, - escape: 27, - space: 32, - pageUp: 33, - pageDown: 34, - end: 35, - home: 36, - left: 37, - up: 38, - right: 39, - down: 40, - insert: 45, - del: 46, - zero: 48, - one: 49, - two: 50, - three: 51, - four: 52, - five: 53, - six: 54, - seven: 55, - eight: 56, - nine: 57, - colon: 58, - a: 65, - b: 66, - c: 67, - d: 68, - e: 69, - f: 70, - g: 71, - h: 72, - i: 73, - j: 74, - k: 75, - l: 76, - m: 77, - n: 78, - o: 79, - p: 80, - q: 81, - r: 82, - s: 83, - t: 84, - u: 85, - v: 86, - w: 87, - x: 88, - y: 89, - z: 90, - leftWindow: 91, - rightWindow: 92, - select: 93, - /* eslint-disable @typescript-eslint/naming-convention */ zero_numpad: 96, - one_numpad: 97, - two_numpad: 98, - three_numpad: 99, - four_numpad: 100, - five_numpad: 101, - six_numpad: 102, - seven_numpad: 103, - eight_numpad: 104, - nine_numpad: 105, - /* eslint-enable @typescript-eslint/naming-convention */ multiply: 106, - add: 107, - subtract: 109, - decimalPoint: 110, - divide: 111, - f1: 112, - f2: 113, - f3: 114, - f4: 115, - f5: 116, - f6: 117, - f7: 118, - f8: 119, - f9: 120, - f10: 121, - f11: 122, - f12: 123, - numlock: 144, - scrollLock: 145, - semicolon: 186, - equalSign: 187, - comma: 188, - dash: 189, - period: 190, - forwardSlash: 191, - graveAccent: 192, - openBracket: 219, - backSlash: 220, - closeBracket: 221, - singleQuote: 222 -}; - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"jqgRr":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Rectangle", ()=>Rectangle); -/** - * Rectangle helper class. - * - * @public - * {@docCategory Rectangle} - */ var Rectangle = /** @class */ function() { - function Rectangle(left, right, top, bottom) { - if (left === void 0) left = 0; - if (right === void 0) right = 0; - if (top === void 0) top = 0; - if (bottom === void 0) bottom = 0; - this.top = top; - this.bottom = bottom; - this.left = left; - this.right = right; - } - Object.defineProperty(Rectangle.prototype, "width", { - /** - * Calculated automatically by subtracting the right from left - */ get: function() { - return this.right - this.left; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "height", { - /** - * Calculated automatically by subtracting the bottom from top. - */ get: function() { - return this.bottom - this.top; - }, - enumerable: false, - configurable: true - }); - /** - * Tests if another rect is approximately equal to this rect (within 4 decimal places.) - */ Rectangle.prototype.equals = function(rect) { - // Fixing to 4 decimal places because it allows enough precision and will handle cases when something - // should be rounded, like .999999 should round to 1. - return parseFloat(this.top.toFixed(4)) === parseFloat(rect.top.toFixed(4)) && parseFloat(this.bottom.toFixed(4)) === parseFloat(rect.bottom.toFixed(4)) && parseFloat(this.left.toFixed(4)) === parseFloat(rect.left.toFixed(4)) && parseFloat(this.right.toFixed(4)) === parseFloat(rect.right.toFixed(4)); - }; - return Rectangle; -}(); - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7Twuh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/* eslint-disable @typescript-eslint/no-explicit-any */ /** - * Returns a single function which will call each of the given functions in the context of the - * parent. - */ parcelHelpers.export(exports, "appendFunction", ()=>appendFunction); -function appendFunction(parent) { - var functions = []; - for(var _i = 1; _i < arguments.length; _i++)functions[_i - 1] = arguments[_i]; - if (functions.length < 2) return functions[0]; - return function() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - functions.forEach(function(f) { - return f && f.apply(parent, args); - }); - }; +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4l6c3":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * ARIA helper to concatenate attributes, returning undefined if all attributes - * are undefined. (Empty strings are not a valid ARIA attribute value.) - * - * @param ariaAttributes - ARIA attributes to merge - */ parcelHelpers.export(exports, "mergeAriaAttributeValues", ()=>mergeAriaAttributeValues); -function mergeAriaAttributeValues() { - var ariaAttributes = []; - for(var _i = 0; _i < arguments.length; _i++)ariaAttributes[_i] = arguments[_i]; - var mergedAttribute = ariaAttributes.filter(function(arg) { - return arg; - }).join(" ").trim(); - return mergedAttribute === "" ? undefined : mergedAttribute; +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"51Jbj":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Helper to find the index of an item within an array, using a callback to - * determine the match. - * - * @public - * @param array - Array to search. - * @param cb - Callback which returns true on matches. - * @param fromIndex - Optional index to start from (defaults to 0) - */ parcelHelpers.export(exports, "findIndex", ()=>findIndex); -/** - * Helper to find the first item within an array that satisfies the callback. - * @param array - Array to search - * @param cb - Callback which returns true on matches - */ parcelHelpers.export(exports, "find", ()=>find); -/** - * Creates an array of a given size and helper method to populate. - * - * @public - * @param size - Size of array. - * @param getItem - Callback to populate given cell index. - */ parcelHelpers.export(exports, "createArray", ()=>createArray); -/** - * Convert the given array to a matrix with columnCount number - * of columns. - * - * @public - * @param items - The array to convert - * @param columnCount - The number of columns for the resulting matrix - * @returns A matrix of items - */ parcelHelpers.export(exports, "toMatrix", ()=>toMatrix); -/** - * Given an array, it returns a new array that does not contain the item at the given index. - * @param array - The array to operate on - * @param index - The index of the element to remove - */ parcelHelpers.export(exports, "removeIndex", ()=>removeIndex); -/** - * Given an array, this function returns a new array where the element at a given index has been replaced. - * @param array - The array to operate on - * @param newElement - The element that will be placed in the new array - * @param index - The index of the element that should be replaced - */ parcelHelpers.export(exports, "replaceElement", ()=>replaceElement); -/** - * Given an array, this function returns a new array where an element has been inserted at the given index. - * @param array - The array to operate on - * @param index - The index where an element should be inserted - * @param itemToAdd - The element to insert - */ parcelHelpers.export(exports, "addElementAtIndex", ()=>addElementAtIndex); -/** - * Given an array where each element is of type T or T[], flatten it into an array of T - * @param array - The array where each element can optionally also be an array - */ parcelHelpers.export(exports, "flatten", ()=>flatten); -/** - * Returns a boolean indicating if the two given arrays are equal in length and values. - * - * @param array1 - First array to compare - * @param array2 - Second array to compare - * @returns True if the arrays are the same length and have the same values in the same positions, false otherwise. - */ parcelHelpers.export(exports, "arraysEqual", ()=>arraysEqual); -function findIndex(array, cb, fromIndex) { - if (fromIndex === void 0) fromIndex = 0; - var index = -1; - for(var i = fromIndex; array && i < array.length; i++)if (cb(array[i], i)) { - index = i; - break; - } - return index; +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; } -function find(array, cb) { - var index = findIndex(array, cb); - if (index < 0) return undefined; - return array[index]; +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; } -function createArray(size, getItem) { - var array = []; - for(var i = 0; i < size; i++)array.push(getItem(i)); - return array; +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; } -function toMatrix(items, columnCount) { - return items.reduce(function(rows, currentValue, index) { - if (index % columnCount === 0) rows.push([ - currentValue - ]); - else rows[rows.length - 1].push(currentValue); - return rows; - }, []); +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; } -function removeIndex(array, index) { - return array.filter(function(_, i) { - return index !== i; - }); +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; } -function replaceElement(array, newElement, index) { - var copy = array.slice(); - copy[index] = newElement; - return copy; +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; } -function addElementAtIndex(array, index, itemToAdd) { - var copy = array.slice(); - copy.splice(index, 0, itemToAdd); - return copy; +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; } -function flatten(array) { - var result = []; - array.forEach(function(item) { - return result = result.concat(item); - }); - return result; +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; } -function arraysEqual(array1, array2) { - if (array1.length !== array2.length) return false; - for(var i = 0; i < array1.length; i++){ - if (array1[i] !== array2[i]) return false; - } - return true; +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8GVXW":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Produces a component which internally loads the target component before first mount. - * The component passes all props through to the loaded component. - * - * This overload accepts a module with a default export for the component. - */ parcelHelpers.export(exports, "asAsync", ()=>asAsync); -/** - * asAsync - a HOC for async loading components. - * - * Usage: - * - * const AsyncDialog = asAsync({ - * load: () => import('Dialog').then(result => result.default), - * }); - * - * React.render(domElement, } { ...dialogProps } />); - * - * Note the `asyncPlaceholder` prop will be respected when rendering the async component and it hasn't - * been loaded yet. - */ var _tslib = require("tslib"); -var _react = require("react"); -/** - * If possible, use a WeakMap to maintain a cache of loaded components. - * This can be used to synchronously render components that have already been loaded, - * rather than having to wait for at least one async tick. - */ var _syncModuleCache = typeof WeakMap !== "undefined" ? new WeakMap() : undefined; -function asAsync(options) { - var Async = /** @class */ function(_super) { - (0, _tslib.__extends)(Async, _super); - function Async() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.state = { - Component: _syncModuleCache ? _syncModuleCache.get(options.load) : undefined - }; - return _this; - } - Async.prototype.render = function() { - // Typescript issue: the rest can't be pulled without the any cast, as TypeScript fails with rest on generics. - // eslint-disable-next-line @typescript-eslint/no-explicit-any - var _a = this.props, forwardedRef = _a.forwardedRef, Placeholder = _a.asyncPlaceholder, rest = (0, _tslib.__rest)(_a, [ - "forwardedRef", - "asyncPlaceholder" - ]); - var Component = this.state.Component; - return Component ? _react.createElement(Component, (0, _tslib.__assign)((0, _tslib.__assign)({}, rest), { - ref: forwardedRef - })) : Placeholder ? _react.createElement(Placeholder, null) : null; - }; - Async.prototype.componentDidMount = function() { - var _this = this; - var Component = this.state.Component; - if (!Component) options.load().then(function(LoadedComponent) { - if (LoadedComponent) { - // Cache component for future reference. - _syncModuleCache && _syncModuleCache.set(options.load, LoadedComponent); - // Set state. - _this.setState({ - Component: LoadedComponent - }, options.onLoad); - } - }).catch(options.onError); - }; - return Async; - }(_react.Component); - return _react.forwardRef(function(props, ref) { - return _react.createElement(Async, (0, _tslib.__assign)({}, props, { - forwardedRef: ref - })); - }); +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; } - -},{"tslib":"01Tx1","react":"8ePka","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7XVG7":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * AssertNever is a utility function that can be used for exhaustiveness checks in switch statements. - * - * @public - */ parcelHelpers.export(exports, "assertNever", ()=>assertNever); -function assertNever(x) { - throw new Error("Unexpected object: " + x); +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4Iezg":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Creates a getClassNames function which calls getStyles given the props, and injects them - * into mergeStyleSets. - * - * Note that the props you pass in on every render should be in the same order and - * immutable (numbers, strings, and booleans). This will allow the results to be memoized. Violating - * these will cause extra recalcs to occur. - */ parcelHelpers.export(exports, "classNamesFunction", ()=>classNamesFunction); -var _mergeStyles = require("@fluentui/merge-styles"); -var _rtl = require("./rtl"); -var _dom = require("./dom"); -var MAX_CACHE_COUNT = 50; -var DEFAULT_SPECIFICITY_MULTIPLIER = 5; -var _memoizedClassNames = 0; -var stylesheet = (0, _mergeStyles.Stylesheet).getInstance(); -if (stylesheet && stylesheet.onReset) stylesheet.onReset(function() { - return _memoizedClassNames++; -}); -// Note that because of the caching nature within the classNames memoization, -// I've disabled this rule to simply be able to work with any types. -/* eslint-disable @typescript-eslint/no-explicit-any */ // This represents a prop we attach to each Map to indicate the cached return value -// associated with the graph node. -var retVal = "__retval__"; -function classNamesFunction(options) { - // We build a trie where each node is a Map. The map entry key represents an argument - // value, and the entry value is another node (Map). Each node has a `__retval__` - // property which is used to hold the cached response. - if (options === void 0) options = {}; - // To derive the response, we can simply ensure the arguments are added or already - // exist in the trie. At the last node, if there is a `__retval__` we return that. Otherwise - // we call the `getStyles` api to evaluate, cache on the property, and return that. - var map = new Map(); - var styleCalcCount = 0; - var getClassNamesCount = 0; - var currentMemoizedClassNames = _memoizedClassNames; - var getClassNames = function(styleFunctionOrObject, styleProps) { - var _a; - if (styleProps === void 0) styleProps = {}; - // If useStaticStyles is true, styleFunctionOrObject returns slot to classname mappings. - // If there is also no style overrides, we can skip merge styles completely and - // simply return the result from the style funcion. - if (options.useStaticStyles && typeof styleFunctionOrObject === "function" && styleFunctionOrObject.__noStyleOverride__) return styleFunctionOrObject(styleProps); - getClassNamesCount++; - var current = map; - var theme = styleProps.theme; - var rtl = theme && theme.rtl !== undefined ? theme.rtl : (0, _rtl.getRTL)(); - var disableCaching = options.disableCaching; - // On reset of our stylesheet, reset memoized cache. - if (currentMemoizedClassNames !== _memoizedClassNames) { - currentMemoizedClassNames = _memoizedClassNames; - map = new Map(); - styleCalcCount = 0; - } - if (!options.disableCaching) { - current = _traverseMap(map, styleFunctionOrObject); - current = _traverseMap(current, styleProps); - } - if (disableCaching || !current[retVal]) { - if (styleFunctionOrObject === undefined) current[retVal] = {}; - else current[retVal] = (0, _mergeStyles.mergeCssSets)([ - typeof styleFunctionOrObject === "function" ? styleFunctionOrObject(styleProps) : styleFunctionOrObject, - ], { - rtl: !!rtl, - specificityMultiplier: options.useStaticStyles ? DEFAULT_SPECIFICITY_MULTIPLIER : undefined - }); - if (!disableCaching) styleCalcCount++; - } - if (styleCalcCount > (options.cacheSize || MAX_CACHE_COUNT)) { - var win = (0, _dom.getWindow)(); - if ((_a = win === null || win === void 0 ? void 0 : win.FabricConfig) === null || _a === void 0 ? void 0 : _a.enableClassNameCacheFullWarning) { - // eslint-disable-next-line no-console - console.warn("Styles are being recalculated too frequently. Cache miss rate is ".concat(styleCalcCount, "/").concat(getClassNamesCount, ".")); - // eslint-disable-next-line no-console - console.trace(); - } - map.clear(); - styleCalcCount = 0; - // Mutate the options passed in, that's all we can do. - options.disableCaching = true; - } - // Note: the retVal is an attached property on the Map; not a key in the Map. We use this attached property to - // cache the return value for this branch of the graph. - return current[retVal]; - }; - return getClassNames; +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; } -function _traverseEdge(current, value) { - value = _normalizeValue(value); - if (!current.has(value)) current.set(value, new Map()); - return current.get(value); +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); } -function _traverseMap(current, inputs) { - if (typeof inputs === "function") { - var cachedInputsFromStyled = inputs.__cachedInputs__; - if (cachedInputsFromStyled) // The styled helper will generate the styles function and will attach the cached - // inputs (consisting of the default styles, customzied styles, and user provided styles.) - // These should be used as cache keys for deriving the memoized value. - for(var _i = 0, _a = inputs.__cachedInputs__; _i < _a.length; _i++){ - var input = _a[_i]; - current = _traverseEdge(current, input); - } - else current = _traverseEdge(current, inputs); - } else if (typeof inputs === "object") { - for(var propName in inputs)if (inputs.hasOwnProperty(propName)) current = _traverseEdge(current, inputs[propName]); - } - return current; +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); } -function _normalizeValue(value) { - switch(value){ - case undefined: - return "__undefined__"; - case null: - return "__null__"; - default: - return value; - } +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); } - -},{"@fluentui/merge-styles":"ggD5u","./rtl":"6SQS0","./dom":"bEiaC","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6SQS0":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Gets the rtl state of the page (returns true if in rtl.) - */ parcelHelpers.export(exports, "getRTL", ()=>getRTL); -/** - * Sets the rtl state of the page (by adjusting the dir attribute of the html element.) - */ parcelHelpers.export(exports, "setRTL", ()=>setRTL); -/** - * Returns the given key, but flips right/left arrows if necessary. - */ parcelHelpers.export(exports, "getRTLSafeKeyCode", ()=>getRTLSafeKeyCode); -var _keyCodes = require("./KeyCodes"); -var _getDocument = require("./dom/getDocument"); -var _sessionStorage = require("./sessionStorage"); -var _mergeStyles = require("@fluentui/merge-styles"); -var RTL_LOCAL_STORAGE_KEY = "isRTL"; -// Default to undefined so that we initialize on first read. -var _isRTL; -function getRTL(theme) { - if (theme === void 0) theme = {}; - if (theme.rtl !== undefined) return theme.rtl; - if (_isRTL === undefined) { - // Fabric supports persisting the RTL setting between page refreshes via session storage - var savedRTL = (0, _sessionStorage.getItem)(RTL_LOCAL_STORAGE_KEY); - if (savedRTL !== null) { - _isRTL = savedRTL === "1"; - setRTL(_isRTL); - } - var doc = (0, _getDocument.getDocument)(); - if (_isRTL === undefined && doc) { - _isRTL = (doc.body && doc.body.getAttribute("dir") || doc.documentElement.getAttribute("dir")) === "rtl"; - (0, _mergeStyles.setRTL)(_isRTL); - } - } - return !!_isRTL; +function formatDayOfYear(d, p) { + return pad(1 + (0, _d3Time.timeDay).count((0, _d3Time.timeYear)(d), d), p, 3); } -function setRTL(isRTL, persistSetting) { - if (persistSetting === void 0) persistSetting = false; - var doc = (0, _getDocument.getDocument)(); - if (doc) doc.documentElement.setAttribute("dir", isRTL ? "rtl" : "ltr"); - if (persistSetting) (0, _sessionStorage.setItem)(RTL_LOCAL_STORAGE_KEY, isRTL ? "1" : "0"); - _isRTL = isRTL; - (0, _mergeStyles.setRTL)(_isRTL); +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); } -function getRTLSafeKeyCode(key, theme) { - if (theme === void 0) theme = {}; - if (getRTL(theme)) { - if (key === (0, _keyCodes.KeyCodes).left) key = (0, _keyCodes.KeyCodes).right; - else if (key === (0, _keyCodes.KeyCodes).right) key = (0, _keyCodes.KeyCodes).left; - } - return key; +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; } - -},{"./KeyCodes":"aVdtV","./dom/getDocument":"2lQ30","./sessionStorage":"gH0YF","@fluentui/merge-styles":"ggD5u","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gH0YF":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Fetches an item from session storage without throwing an exception - * @param key The key of the item to fetch from session storage - */ parcelHelpers.export(exports, "getItem", ()=>getItem); -/** - * Inserts an item into session storage without throwing an exception - * @param key The key of the item to add to session storage - * @param data The data to put into session storage - */ parcelHelpers.export(exports, "setItem", ()=>setItem); -var _getWindow = require("./dom/getWindow"); -function getItem(key) { - var result = null; - try { - var win = (0, _getWindow.getWindow)(); - result = win ? win.sessionStorage.getItem(key) : null; - } catch (e) { - /* Eat the exception */ } - return result; +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); } -function setItem(key, data) { - var _a; - try { - (_a = (0, _getWindow.getWindow)()) === null || _a === void 0 || _a.sessionStorage.setItem(key, data); - } catch (e) { - /* Eat the exception */ } +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); } - -},{"./dom/getWindow":"i0Ddq","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bEiaC":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "elementContains", ()=>(0, _elementContains.elementContains)); -parcelHelpers.export(exports, "elementContainsAttribute", ()=>(0, _elementContainsAttribute.elementContainsAttribute)); -parcelHelpers.export(exports, "findElementRecursive", ()=>(0, _findElementRecursive.findElementRecursive)); -parcelHelpers.export(exports, "getChildren", ()=>(0, _getChildren.getChildren)); -parcelHelpers.export(exports, "getDocument", ()=>(0, _getDocument.getDocument)); -parcelHelpers.export(exports, "getFirstVisibleElementFromSelector", ()=>(0, _getFirstVisibleElementFromSelector.getFirstVisibleElementFromSelector)); -parcelHelpers.export(exports, "getParent", ()=>(0, _getParent.getParent)); -parcelHelpers.export(exports, "getRect", ()=>(0, _getRect.getRect)); -parcelHelpers.export(exports, "getVirtualParent", ()=>(0, _getVirtualParent.getVirtualParent)); -parcelHelpers.export(exports, "getWindow", ()=>(0, _getWindow.getWindow)); -parcelHelpers.export(exports, "isVirtualElement", ()=>(0, _isVirtualElement.isVirtualElement)); -parcelHelpers.export(exports, "on", ()=>(0, _on.on)); -parcelHelpers.export(exports, "portalContainsElement", ()=>(0, _portalContainsElement.portalContainsElement)); -parcelHelpers.export(exports, "raiseClick", ()=>(0, _raiseClick.raiseClick)); -parcelHelpers.export(exports, "DATA_PORTAL_ATTRIBUTE", ()=>(0, _setPortalAttribute.DATA_PORTAL_ATTRIBUTE)); -parcelHelpers.export(exports, "setPortalAttribute", ()=>(0, _setPortalAttribute.setPortalAttribute)); -parcelHelpers.export(exports, "setVirtualParent", ()=>(0, _setVirtualParent.setVirtualParent)); -var _elementContains = require("./dom/elementContains"); -var _elementContainsAttribute = require("./dom/elementContainsAttribute"); -var _findElementRecursive = require("./dom/findElementRecursive"); -var _getChildren = require("./dom/getChildren"); -var _getDocument = require("./dom/getDocument"); -var _getFirstVisibleElementFromSelector = require("./dom/getFirstVisibleElementFromSelector"); -var _getParent = require("./dom/getParent"); -var _getRect = require("./dom/getRect"); -var _getVirtualParent = require("./dom/getVirtualParent"); -var _getWindow = require("./dom/getWindow"); -var _isVirtualElement = require("./dom/isVirtualElement"); -var _on = require("./dom/on"); -var _portalContainsElement = require("./dom/portalContainsElement"); -var _raiseClick = require("./dom/raiseClick"); -var _setPortalAttribute = require("./dom/setPortalAttribute"); -var _setVirtualParent = require("./dom/setVirtualParent"); - -},{"./dom/elementContains":"kDzok","./dom/elementContainsAttribute":"bualD","./dom/findElementRecursive":"2mH6l","./dom/getChildren":"f419h","./dom/getDocument":"2lQ30","./dom/getFirstVisibleElementFromSelector":"gK3FW","./dom/getParent":"f9MJY","./dom/getRect":"fEGdU","./dom/getVirtualParent":"6J1c5","./dom/getWindow":"i0Ddq","./dom/isVirtualElement":"2P1wP","./dom/on":"6DXHh","./dom/portalContainsElement":"gr6BD","./dom/raiseClick":"2oRwz","./dom/setPortalAttribute":"8RVUD","./dom/setVirtualParent":"cDXbV","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kDzok":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "elementContains", ()=>(0, _domUtilities.elementContains)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2DoJo":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -var _version = require("./version"); -var _ivirtualElement = require("./IVirtualElement"); -parcelHelpers.exportAll(_ivirtualElement, exports); -var _elementContains = require("./elementContains"); -parcelHelpers.exportAll(_elementContains, exports); -var _elementContainsAttribute = require("./elementContainsAttribute"); -parcelHelpers.exportAll(_elementContainsAttribute, exports); -var _findElementRecursive = require("./findElementRecursive"); -parcelHelpers.exportAll(_findElementRecursive, exports); -var _getChildren = require("./getChildren"); -parcelHelpers.exportAll(_getChildren, exports); -var _getParent = require("./getParent"); -parcelHelpers.exportAll(_getParent, exports); -var _getVirtualParent = require("./getVirtualParent"); -parcelHelpers.exportAll(_getVirtualParent, exports); -var _isVirtualElement = require("./isVirtualElement"); -parcelHelpers.exportAll(_isVirtualElement, exports); -var _portalContainsElement = require("./portalContainsElement"); -parcelHelpers.exportAll(_portalContainsElement, exports); -var _setPortalAttribute = require("./setPortalAttribute"); -parcelHelpers.exportAll(_setPortalAttribute, exports); -var _setVirtualParent = require("./setVirtualParent"); -parcelHelpers.exportAll(_setVirtualParent, exports); - -},{"./version":"kS9to","./IVirtualElement":"b0FZf","./elementContains":"5hgAs","./elementContainsAttribute":"lQXtt","./findElementRecursive":"38a7I","./getChildren":"6Mnks","./getParent":"gp02N","./getVirtualParent":"hctgE","./isVirtualElement":"c1KhA","./portalContainsElement":"fbRSG","./setPortalAttribute":"2QF9q","./setVirtualParent":"4Zyj6","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"kS9to":[function(require,module,exports) { -// Do not modify this file; it is generated as part of publish. -// The checked in version is a placeholder only and will not be updated. -var _setVersion = require("@fluentui/set-version"); -(0, _setVersion.setVersion)("@fluentui/dom-utilities", "2.2.11"); - -},{"@fluentui/set-version":"aMFYG"}],"b0FZf":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"5hgAs":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Determines whether or not a parent element contains a given child element. - * If `allowVirtualParents` is true, this method may return `true` if the child - * has the parent in its virtual element hierarchy. - * - * @public - */ parcelHelpers.export(exports, "elementContains", ()=>elementContains); -var _getParent = require("./getParent"); -function elementContains(parent, child, allowVirtualParents) { - if (allowVirtualParents === void 0) allowVirtualParents = true; - var isContained = false; - if (parent && child) { - if (allowVirtualParents) { - if (parent === child) isContained = true; - else { - isContained = false; - while(child){ - var nextParent = (0, _getParent.getParent)(child); - if (nextParent === parent) { - isContained = true; - break; - } - child = nextParent; - } - } - } else if (parent.contains) isContained = parent.contains(child); - } - return isContained; +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; } - -},{"./getParent":"gp02N","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gp02N":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Gets the element which is the parent of a given element. - * If `allowVirtuaParents` is `true`, this method prefers the virtual parent over - * real DOM parent when present. - * - * @public - */ parcelHelpers.export(exports, "getParent", ()=>getParent); -var _getVirtualParent = require("./getVirtualParent"); -function getParent(child, allowVirtualParents) { - if (allowVirtualParents === void 0) allowVirtualParents = true; - return child && (allowVirtualParents && (0, _getVirtualParent.getVirtualParent)(child) || child.parentNode && child.parentNode); +function formatWeekNumberSunday(d, p) { + return pad((0, _d3Time.timeSunday).count((0, _d3Time.timeYear)(d) - 1, d), p, 2); } - -},{"./getVirtualParent":"hctgE","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"hctgE":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Gets the virtual parent given the child element, if it exists. - * - * @public - */ parcelHelpers.export(exports, "getVirtualParent", ()=>getVirtualParent); -var _isVirtualElement = require("./isVirtualElement"); -function getVirtualParent(child) { - var parent; - if (child && (0, _isVirtualElement.isVirtualElement)(child)) parent = child._virtual.parent; - return parent; +function dISO(d) { + var day = d.getDay(); + return day >= 4 || day === 0 ? (0, _d3Time.timeThursday)(d) : (0, _d3Time.timeThursday).ceil(d); } - -},{"./isVirtualElement":"c1KhA","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"c1KhA":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Determines whether or not an element has the virtual hierarchy extension. - * - * @public - */ parcelHelpers.export(exports, "isVirtualElement", ()=>isVirtualElement); -function isVirtualElement(element) { - return element && !!element._virtual; +function formatWeekNumberISO(d, p) { + d = dISO(d); + return pad((0, _d3Time.timeThursday).count((0, _d3Time.timeYear)(d), d) + ((0, _d3Time.timeYear)(d).getDay() === 4), p, 2); } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lQXtt":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Determines if an element, or any of its ancestors, contain the given attribute - * @param element - element to start searching at - * @param attribute - the attribute to search for - * @returns the value of the first instance found - */ parcelHelpers.export(exports, "elementContainsAttribute", ()=>elementContainsAttribute); -var _findElementRecursive = require("./findElementRecursive"); -function elementContainsAttribute(element, attribute) { - var elementMatch = (0, _findElementRecursive.findElementRecursive)(element, function(testElement) { - return testElement.hasAttribute(attribute); - }); - return elementMatch && elementMatch.getAttribute(attribute); +function formatWeekdayNumberSunday(d) { + return d.getDay(); } - -},{"./findElementRecursive":"38a7I","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"38a7I":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Finds the first parent element where the matchFunction returns true - * @param element - element to start searching at - * @param matchFunction - the function that determines if the element is a match - * @returns the matched element or null no match was found - */ parcelHelpers.export(exports, "findElementRecursive", ()=>findElementRecursive); -var _getParent = require("./getParent"); -function findElementRecursive(element, matchFunction) { - if (!element || element === document.body) return null; - return matchFunction(element) ? element : findElementRecursive((0, _getParent.getParent)(element), matchFunction); +function formatWeekNumberMonday(d, p) { + return pad((0, _d3Time.timeMonday).count((0, _d3Time.timeYear)(d) - 1, d), p, 2); } - -},{"./getParent":"gp02N","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6Mnks":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Gets the elements which are child elements of the given element. - * If `allowVirtualChildren` is `true`, this method enumerates virtual child elements - * after the original children. - * @param parent - The element to get the children of. - * @param allowVirtualChildren - true if the method should enumerate virtual child elements. - */ parcelHelpers.export(exports, "getChildren", ()=>getChildren); -var _isVirtualElement = require("./isVirtualElement"); -function getChildren(parent, allowVirtualChildren) { - if (allowVirtualChildren === void 0) allowVirtualChildren = true; - var children = []; - if (parent) { - for(var i = 0; i < parent.children.length; i++)children.push(parent.children.item(i)); - if (allowVirtualChildren && (0, _isVirtualElement.isVirtualElement)(parent)) children.push.apply(children, parent._virtual.children); - } - return children; +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); } - -},{"./isVirtualElement":"c1KhA","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fbRSG":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Determine whether a target is within a portal from perspective of root or optional parent. - * This function only works against portal components that use the setPortalAttribute function. - * If both parent and child are within the same portal this function will return false. - * @param target - Element to query portal containment status of. - * @param parent - Optional parent perspective. Search for containing portal stops at parent - * (or root if parent is undefined or invalid.) - */ parcelHelpers.export(exports, "portalContainsElement", ()=>portalContainsElement); -var _findElementRecursive = require("./findElementRecursive"); -var _setPortalAttribute = require("./setPortalAttribute"); -function portalContainsElement(target, parent) { - var elementMatch = (0, _findElementRecursive.findElementRecursive)(target, function(testElement) { - return parent === testElement || testElement.hasAttribute((0, _setPortalAttribute.DATA_PORTAL_ATTRIBUTE)); - }); - return elementMatch !== null && elementMatch.hasAttribute((0, _setPortalAttribute.DATA_PORTAL_ATTRIBUTE)); +function formatYearISO(d, p) { + d = dISO(d); + return pad(d.getFullYear() % 100, p, 2); } - -},{"./findElementRecursive":"38a7I","./setPortalAttribute":"2QF9q","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2QF9q":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DATA_PORTAL_ATTRIBUTE", ()=>DATA_PORTAL_ATTRIBUTE); -/** - * Identify element as a portal by setting an attribute. - * @param element - Element to mark as a portal. - */ parcelHelpers.export(exports, "setPortalAttribute", ()=>setPortalAttribute); -var DATA_PORTAL_ATTRIBUTE = "data-portal-element"; -function setPortalAttribute(element) { - element.setAttribute(DATA_PORTAL_ATTRIBUTE, "true"); +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"4Zyj6":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Sets the virtual parent of an element. - * Pass `undefined` as the `parent` to clear the virtual parent. - * - * @public - */ parcelHelpers.export(exports, "setVirtualParent", ()=>setVirtualParent); -function setVirtualParent(child, parent) { - var virtualChild = child; - var virtualParent = parent; - if (!virtualChild._virtual) virtualChild._virtual = { - children: [] - }; - var oldParent = virtualChild._virtual.parent; - if (oldParent && oldParent !== parent) { - // Remove the child from its old parent. - var index = oldParent._virtual.children.indexOf(virtualChild); - if (index > -1) oldParent._virtual.children.splice(index, 1); - } - virtualChild._virtual.parent = virtualParent || undefined; - if (virtualParent) { - if (!virtualParent._virtual) virtualParent._virtual = { - children: [] - }; - virtualParent._virtual.children.push(virtualChild); - } +function formatFullYearISO(d, p) { + var day = d.getDay(); + d = day >= 4 || day === 0 ? (0, _d3Time.timeThursday)(d) : (0, _d3Time.timeThursday).ceil(d); + return pad(d.getFullYear() % 10000, p, 4); } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"bualD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "elementContainsAttribute", ()=>(0, _domUtilities.elementContainsAttribute)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2mH6l":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "findElementRecursive", ()=>(0, _domUtilities.findElementRecursive)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"f419h":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getChildren", ()=>(0, _domUtilities.getChildren)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gK3FW":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Gets the first visible element that matches the given selector - * @param selector - The selector to use to find potential visible elements - * @returns The first visible element that matches the selector, otherwise undefined - * - * @public - */ parcelHelpers.export(exports, "getFirstVisibleElementFromSelector", ()=>getFirstVisibleElementFromSelector); -var _focus = require("../focus"); -var _getDocument = require("./getDocument"); -function getFirstVisibleElementFromSelector(selector) { - var elements = (0, _getDocument.getDocument)().querySelectorAll(selector); - // Iterate across the elements that match the selector and return the first visible/non-hidden element - return Array.from(elements).find(function(element) { - return (0, _focus.isElementVisibleAndNotHidden)(element); - }); +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + pad(z / 60 | 0, "0", 2) + pad(z % 60, "0", 2); } - -},{"../focus":"czIBK","./getDocument":"2lQ30","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"czIBK":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Gets the first focusable element. - * - * @public - */ parcelHelpers.export(exports, "getFirstFocusable", ()=>getFirstFocusable); -/** - * Gets the last focusable element. - * - * @public - */ parcelHelpers.export(exports, "getLastFocusable", ()=>getLastFocusable); -/** - * Gets the first tabbable element. (The difference between focusable and tabbable is that tabbable elements are - * focusable elements that also have tabIndex != -1.) - * @param rootElement - The parent element to search beneath. - * @param currentElement - The descendant of rootElement to start the search at. This element is the first one checked, - * and iteration continues forward. Typical use passes rootElement.firstChild. - * @param includeElementsInFocusZones - true if traversal should go into FocusZone descendants. - * @param checkNode - Include currentElement in search when true. Defaults to true. - * @public - */ parcelHelpers.export(exports, "getFirstTabbable", ()=>getFirstTabbable); -/** - * Gets the last tabbable element. (The difference between focusable and tabbable is that tabbable elements are - * focusable elements that also have tabIndex != -1.) - * @param rootElement - The parent element to search beneath. - * @param currentElement - The descendant of rootElement to start the search at. This element is the first one checked, - * and iteration continues in reverse. Typical use passes rootElement.lastChild. - * @param includeElementsInFocusZones - true if traversal should go into FocusZone descendants. - * @param checkNode - Include currentElement in search when true. Defaults to true. - * @public - */ parcelHelpers.export(exports, "getLastTabbable", ()=>getLastTabbable); -/** - * Attempts to focus the first focusable element that is a child or child's child of the rootElement. - * - * @public - * @param rootElement - Element to start the search for a focusable child. - * @param bypassHiddenElements - If true, focus will be not be set on hidden elements. - * @returns True if focus was set, false if it was not. - */ parcelHelpers.export(exports, "focusFirstChild", ()=>focusFirstChild); -/** - * Traverse to find the previous element. - * If tabbable is true, the element must have tabIndex != -1. - * - * @public - */ parcelHelpers.export(exports, "getPreviousElement", ()=>getPreviousElement); -/** - * Traverse to find the next focusable element. - * If tabbable is true, the element must have tabIndex != -1. - * - * @public - * @param checkNode - Include currentElement in search when true. - */ parcelHelpers.export(exports, "getNextElement", ()=>getNextElement); -/** - * Determines if an element is visible. - * - * @public - */ parcelHelpers.export(exports, "isElementVisible", ()=>isElementVisible); -/** - * Determines if an element is visible and not hidden - * @param element - Element to check - * @returns Returns true if the given element is visible and not hidden - * - * @public - */ parcelHelpers.export(exports, "isElementVisibleAndNotHidden", ()=>isElementVisibleAndNotHidden); -/** - * Determines if an element can receive focus programmatically or via a mouse click. - * If checkTabIndex is true, additionally checks to ensure the element can be focused with the tab key, - * meaning tabIndex != -1. - * - * @public - */ parcelHelpers.export(exports, "isElementTabbable", ()=>isElementTabbable); -/** - * Determines if a given element is a focus zone. - * - * @public - */ parcelHelpers.export(exports, "isElementFocusZone", ()=>isElementFocusZone); -/** - * Determines if a given element is a focus sub zone. - * - * @public - */ parcelHelpers.export(exports, "isElementFocusSubZone", ()=>isElementFocusSubZone); -/** - * Determines if an element, or any of its children, contain focus. - * - * @public - */ parcelHelpers.export(exports, "doesElementContainFocus", ()=>doesElementContainFocus); -/** - * Determines if an, or any of its ancestors, sepcificies that it doesn't want focus to wrap - * @param element - element to start searching from - * @param noWrapDataAttribute - the no wrap data attribute to match (either) - * @returns true if focus should wrap, false otherwise - */ parcelHelpers.export(exports, "shouldWrapFocus", ()=>shouldWrapFocus); -/** - * Sets focus to an element asynchronously. The focus will be set at the next browser repaint, - * meaning it won't cause any extra recalculations. If more than one focusAsync is called during one frame, - * only the latest called focusAsync element will actually be focused - * @param element - The element to focus - */ parcelHelpers.export(exports, "focusAsync", ()=>focusAsync); -/** - * Finds the closest focusable element via an index path from a parent. See - * `getElementIndexPath` for getting an index path from an element to a child. - */ parcelHelpers.export(exports, "getFocusableByIndexPath", ()=>getFocusableByIndexPath); -/** - * Finds the element index path from a parent element to a child element. - * - * If you had this node structure: "A has children [B, C] and C has child D", - * the index path from A to D would be [1, 0], or `parent.chidren[1].children[0]`. - */ parcelHelpers.export(exports, "getElementIndexPath", ()=>getElementIndexPath); -var _elementContainsAttribute = require("./dom/elementContainsAttribute"); -var _elementContains = require("./dom/elementContains"); -var _getParent = require("./dom/getParent"); -var _getWindow = require("./dom/getWindow"); -var _getDocument = require("./dom/getDocument"); -var IS_FOCUSABLE_ATTRIBUTE = "data-is-focusable"; -var IS_VISIBLE_ATTRIBUTE = "data-is-visible"; -var FOCUSZONE_ID_ATTRIBUTE = "data-focuszone-id"; -var FOCUSZONE_SUB_ATTRIBUTE = "data-is-sub-focuszone"; -function getFirstFocusable(rootElement, currentElement, includeElementsInFocusZones) { - return getNextElement(rootElement, currentElement, true, false, false, includeElementsInFocusZones); +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); } -function getLastFocusable(rootElement, currentElement, includeElementsInFocusZones) { - return getPreviousElement(rootElement, currentElement, true, false, true, includeElementsInFocusZones); +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); } -function getFirstTabbable(rootElement, currentElement, includeElementsInFocusZones, checkNode) { - if (checkNode === void 0) checkNode = true; - return getNextElement(rootElement, currentElement, checkNode, false, false, includeElementsInFocusZones, false, true); +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); } -function getLastTabbable(rootElement, currentElement, includeElementsInFocusZones, checkNode) { - if (checkNode === void 0) checkNode = true; - return getPreviousElement(rootElement, currentElement, checkNode, false, true, includeElementsInFocusZones, false, true); +function formatUTCDayOfYear(d, p) { + return pad(1 + (0, _d3Time.utcDay).count((0, _d3Time.utcYear)(d), d), p, 3); } -function focusFirstChild(rootElement, bypassHiddenElements) { - var element = getNextElement(rootElement, rootElement, true, false, false, true, undefined, undefined, bypassHiddenElements); - if (element) { - focusAsync(element); - return true; - } - return false; +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); } -function getPreviousElement(rootElement, currentElement, checkNode, suppressParentTraversal, traverseChildren, includeElementsInFocusZones, allowFocusRoot, tabbable) { - if (!currentElement || !allowFocusRoot && currentElement === rootElement) return null; - var isCurrentElementVisible = isElementVisible(currentElement); - // Check its children. - if (traverseChildren && isCurrentElementVisible && (includeElementsInFocusZones || !(isElementFocusZone(currentElement) || isElementFocusSubZone(currentElement)))) { - var childMatch = getPreviousElement(rootElement, currentElement.lastElementChild, true, true, true, includeElementsInFocusZones, allowFocusRoot, tabbable); - if (childMatch) { - if (tabbable && isElementTabbable(childMatch, true) || !tabbable) return childMatch; - var childMatchSiblingMatch = getPreviousElement(rootElement, childMatch.previousElementSibling, true, true, true, includeElementsInFocusZones, allowFocusRoot, tabbable); - if (childMatchSiblingMatch) return childMatchSiblingMatch; - var childMatchParent = childMatch.parentElement; - // At this point if we have not found any potential matches - // start looking at the rest of the subtree under the currentParent. - // NOTE: We do not want to recurse here because doing so could - // cause elements to get skipped. - while(childMatchParent && childMatchParent !== currentElement){ - var childMatchParentMatch = getPreviousElement(rootElement, childMatchParent.previousElementSibling, true, true, true, includeElementsInFocusZones, allowFocusRoot, tabbable); - if (childMatchParentMatch) return childMatchParentMatch; - childMatchParent = childMatchParent.parentElement; - } - } - } - // Check the current node, if it's not the first traversal. - if (checkNode && isCurrentElementVisible && isElementTabbable(currentElement, tabbable)) return currentElement; - // Check its previous sibling. - var siblingMatch = getPreviousElement(rootElement, currentElement.previousElementSibling, true, true, true, includeElementsInFocusZones, allowFocusRoot, tabbable); - if (siblingMatch) return siblingMatch; - // Check its parent. - if (!suppressParentTraversal) return getPreviousElement(rootElement, currentElement.parentElement, true, false, false, includeElementsInFocusZones, allowFocusRoot, tabbable); - return null; +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; } -function getNextElement(rootElement, currentElement, checkNode, suppressParentTraversal, suppressChildTraversal, includeElementsInFocusZones, allowFocusRoot, tabbable, bypassHiddenElements) { - if (!currentElement || currentElement === rootElement && suppressChildTraversal && !allowFocusRoot) return null; - var checkElementVisibility = bypassHiddenElements ? isElementVisibleAndNotHidden : isElementVisible; - var isCurrentElementVisible = checkElementVisibility(currentElement); - // Check the current node, if it's not the first traversal. - if (checkNode && isCurrentElementVisible && isElementTabbable(currentElement, tabbable)) return currentElement; - // Check its children. - if (!suppressChildTraversal && isCurrentElementVisible && (includeElementsInFocusZones || !(isElementFocusZone(currentElement) || isElementFocusSubZone(currentElement)))) { - var childMatch = getNextElement(rootElement, currentElement.firstElementChild, true, true, false, includeElementsInFocusZones, allowFocusRoot, tabbable, bypassHiddenElements); - if (childMatch) return childMatch; - } - if (currentElement === rootElement) return null; - // Check its sibling. - var siblingMatch = getNextElement(rootElement, currentElement.nextElementSibling, true, true, false, includeElementsInFocusZones, allowFocusRoot, tabbable, bypassHiddenElements); - if (siblingMatch) return siblingMatch; - if (!suppressParentTraversal) return getNextElement(rootElement, currentElement.parentElement, false, false, true, includeElementsInFocusZones, allowFocusRoot, tabbable, bypassHiddenElements); - return null; +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); } -function isElementVisible(element) { - // If the element is not valid, return false. - if (!element || !element.getAttribute) return false; - var visibilityAttribute = element.getAttribute(IS_VISIBLE_ATTRIBUTE); - // If the element is explicitly marked with the visibility attribute, return that value as boolean. - if (visibilityAttribute !== null && visibilityAttribute !== undefined) return visibilityAttribute === "true"; - // Fallback to other methods of determining actual visibility. - return element.offsetHeight !== 0 || element.offsetParent !== null || // eslint-disable-next-line @typescript-eslint/no-explicit-any - element.isVisible === true; // used as a workaround for testing. +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); } -function isElementVisibleAndNotHidden(element) { - return !!element && isElementVisible(element) && !element.hidden && window.getComputedStyle(element).visibility !== "hidden"; +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); } -function isElementTabbable(element, checkTabIndex) { - // If this element is null or is disabled, it is not considered tabbable. - if (!element || element.disabled) return false; - var tabIndex = 0; - var tabIndexAttributeValue = null; - if (element && element.getAttribute) { - tabIndexAttributeValue = element.getAttribute("tabIndex"); - if (tabIndexAttributeValue) tabIndex = parseInt(tabIndexAttributeValue, 10); - } - var isFocusableAttribute = element.getAttribute ? element.getAttribute(IS_FOCUSABLE_ATTRIBUTE) : null; - var isTabIndexSet = tabIndexAttributeValue !== null && tabIndex >= 0; - var result = !!element && isFocusableAttribute !== "false" && (element.tagName === "A" || element.tagName === "BUTTON" || element.tagName === "INPUT" || element.tagName === "TEXTAREA" || element.tagName === "SELECT" || isFocusableAttribute === "true" || isTabIndexSet); - return checkTabIndex ? tabIndex !== -1 && result : result; +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; } -function isElementFocusZone(element) { - return !!(element && element.getAttribute && !!element.getAttribute(FOCUSZONE_ID_ATTRIBUTE)); +function formatUTCWeekNumberSunday(d, p) { + return pad((0, _d3Time.utcSunday).count((0, _d3Time.utcYear)(d) - 1, d), p, 2); } -function isElementFocusSubZone(element) { - return !!(element && element.getAttribute && element.getAttribute(FOCUSZONE_SUB_ATTRIBUTE) === "true"); +function UTCdISO(d) { + var day = d.getUTCDay(); + return day >= 4 || day === 0 ? (0, _d3Time.utcThursday)(d) : (0, _d3Time.utcThursday).ceil(d); } -function doesElementContainFocus(element) { - var document = (0, _getDocument.getDocument)(element); - var currentActiveElement = document && document.activeElement; - if (currentActiveElement && (0, _elementContains.elementContains)(element, currentActiveElement)) return true; - return false; +function formatUTCWeekNumberISO(d, p) { + d = UTCdISO(d); + return pad((0, _d3Time.utcThursday).count((0, _d3Time.utcYear)(d), d) + ((0, _d3Time.utcYear)(d).getUTCDay() === 4), p, 2); } -function shouldWrapFocus(element, noWrapDataAttribute) { - return (0, _elementContainsAttribute.elementContainsAttribute)(element, noWrapDataAttribute) === "true" ? false : true; +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); } -var targetToFocusOnNextRepaint = undefined; -function focusAsync(element) { - if (element) { - // An element was already queued to be focused, so replace that one with the new element - if (targetToFocusOnNextRepaint) { - targetToFocusOnNextRepaint = element; - return; - } - targetToFocusOnNextRepaint = element; - var win = (0, _getWindow.getWindow)(element); - if (win) // element.focus() is a no-op if the element is no longer in the DOM, meaning this is always safe - win.requestAnimationFrame(function() { - targetToFocusOnNextRepaint && targetToFocusOnNextRepaint.focus(); - // We are done focusing for this frame, so reset the queued focus element - targetToFocusOnNextRepaint = undefined; - }); - } +function formatUTCWeekNumberMonday(d, p) { + return pad((0, _d3Time.utcMonday).count((0, _d3Time.utcYear)(d) - 1, d), p, 2); } -function getFocusableByIndexPath(parent, path) { - var element = parent; - for(var _i = 0, path_1 = path; _i < path_1.length; _i++){ - var index = path_1[_i]; - var nextChild = element.children[Math.min(index, element.children.length - 1)]; - if (!nextChild) break; - element = nextChild; +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} +function formatUTCYearISO(d, p) { + d = UTCdISO(d); + return pad(d.getUTCFullYear() % 100, p, 2); +} +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} +function formatUTCFullYearISO(d, p) { + var day = d.getUTCDay(); + d = day >= 4 || day === 0 ? (0, _d3Time.utcThursday)(d) : (0, _d3Time.utcThursday).ceil(d); + return pad(d.getUTCFullYear() % 10000, p, 4); +} +function formatUTCZone() { + return "+0000"; +} +function formatLiteralPercent() { + return "%"; +} +function formatUnixTimestamp(d) { + return +d; +} +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +},{"d3-time":"6KMda","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"iLPRP":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "default", ()=>utcTime); +var _d3Time = require("d3-time"); +var _d3TimeFormat = require("d3-time-format"); +var _timeJs = require("./time.js"); +var _initJs = require("./init.js"); +function utcTime() { + return (0, _initJs.initRange).apply((0, _timeJs.calendar)((0, _d3Time.utcTicks), (0, _d3Time.utcTickInterval), (0, _d3Time.utcYear), (0, _d3Time.utcMonth), (0, _d3Time.utcWeek), (0, _d3Time.utcDay), (0, _d3Time.utcHour), (0, _d3Time.utcMinute), (0, _d3Time.utcSecond), (0, _d3TimeFormat.utcFormat)).domain([ + Date.UTC(2000, 0, 1), + Date.UTC(2000, 0, 2) + ]), arguments); +} + +},{"d3-time":"6KMda","d3-time-format":"eC6Bi","./time.js":"dtq1F","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e0eA3":[function(require,module,exports,__globalThis) { +var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "copy", ()=>copy); +parcelHelpers.export(exports, "default", ()=>sequential); +parcelHelpers.export(exports, "sequentialLog", ()=>sequentialLog); +parcelHelpers.export(exports, "sequentialSymlog", ()=>sequentialSymlog); +parcelHelpers.export(exports, "sequentialPow", ()=>sequentialPow); +parcelHelpers.export(exports, "sequentialSqrt", ()=>sequentialSqrt); +var _d3Interpolate = require("d3-interpolate"); +var _continuousJs = require("./continuous.js"); +var _initJs = require("./init.js"); +var _linearJs = require("./linear.js"); +var _logJs = require("./log.js"); +var _symlogJs = require("./symlog.js"); +var _powJs = require("./pow.js"); +function transformer() { + var x0 = 0, x1 = 1, t0, t1, k10, transform, interpolator = (0, _continuousJs.identity), clamp = false, unknown; + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x)); } - element = isElementTabbable(element) && isElementVisible(element) ? element : getNextElement(parent, element, true) || getPreviousElement(parent, element); - return element; + scale.domain = function(_) { + return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [ + x0, + x1 + ]; + }; + scale.clamp = function(_) { + return arguments.length ? (clamp = !!_, scale) : clamp; + }; + scale.interpolator = function(_) { + return arguments.length ? (interpolator = _, scale) : interpolator; + }; + function range(interpolate) { + return function(_) { + var r0, r1; + return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [ + interpolator(0), + interpolator(1) + ]; + }; + } + scale.range = range((0, _d3Interpolate.interpolate)); + scale.rangeRound = range((0, _d3Interpolate.interpolateRound)); + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + return function(t) { + transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0); + return scale; + }; +} +function copy(source, target) { + return target.domain(source.domain()).interpolator(source.interpolator()).clamp(source.clamp()).unknown(source.unknown()); +} +function sequential() { + var scale = (0, _linearJs.linearish)(transformer()((0, _continuousJs.identity))); + scale.copy = function() { + return copy(scale, sequential()); + }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } -function getElementIndexPath(fromElement, toElement) { - var path = []; - while(toElement && fromElement && toElement !== fromElement){ - var parent_1 = (0, _getParent.getParent)(toElement, true); - if (parent_1 === null) return []; - path.unshift(Array.prototype.indexOf.call(parent_1.children, toElement)); - toElement = parent_1; - } - return path; +function sequentialLog() { + var scale = (0, _logJs.loggish)(transformer()).domain([ + 1, + 10 + ]); + scale.copy = function() { + return copy(scale, sequentialLog()).base(scale.base()); + }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } - -},{"./dom/elementContainsAttribute":"bualD","./dom/elementContains":"kDzok","./dom/getParent":"f9MJY","./dom/getWindow":"i0Ddq","./dom/getDocument":"2lQ30","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"f9MJY":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getParent", ()=>(0, _domUtilities.getParent)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6J1c5":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "getVirtualParent", ()=>(0, _domUtilities.getVirtualParent)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2P1wP":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "isVirtualElement", ()=>(0, _domUtilities.isVirtualElement)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"6DXHh":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "on", ()=>on); -function on(element, eventName, callback, options) { - element.addEventListener(eventName, callback, options); - return function() { - return element.removeEventListener(eventName, callback, options); +function sequentialSymlog() { + var scale = (0, _symlogJs.symlogish)(transformer()); + scale.copy = function() { + return copy(scale, sequentialSymlog()).constant(scale.constant()); }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } - -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"gr6BD":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "portalContainsElement", ()=>(0, _domUtilities.portalContainsElement)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"2oRwz":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** Raises a click event. - * @deprecated Moved to `FocusZone` component since it was the only place internally using this function. - */ parcelHelpers.export(exports, "raiseClick", ()=>raiseClick); -function raiseClick(target) { - var event = createNewEvent("MouseEvents"); - // eslint-disable-next-line deprecation/deprecation - event.initEvent("click", true, true); - target.dispatchEvent(event); +function sequentialPow() { + var scale = (0, _powJs.powish)(transformer()); + scale.copy = function() { + return copy(scale, sequentialPow()).exponent(scale.exponent()); + }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } -function createNewEvent(eventName) { - var event; - if (typeof Event === "function") // Chrome, Opera, Firefox - event = new Event(eventName); - else { - // IE - event = document.createEvent("Event"); - // eslint-disable-next-line deprecation/deprecation - event.initEvent(eventName, true, true); - } - return event; +function sequentialSqrt() { + return sequentialPow.apply(null, arguments).exponent(0.5); } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"8RVUD":[function(require,module,exports) { +},{"d3-interpolate":"hWyQt","./continuous.js":"2SYx4","./init.js":"ijd73","./linear.js":"ik2PQ","./log.js":"5BBe1","./symlog.js":"26cMO","./pow.js":"ah9R8","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"i0IcB":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "DATA_PORTAL_ATTRIBUTE", ()=>(0, _domUtilities.DATA_PORTAL_ATTRIBUTE)); -parcelHelpers.export(exports, "setPortalAttribute", ()=>(0, _domUtilities.setPortalAttribute)); -var _domUtilities = require("@fluentui/dom-utilities"); - -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"cDXbV":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "setVirtualParent", ()=>(0, _domUtilities.setVirtualParent)); -var _domUtilities = require("@fluentui/dom-utilities"); +parcelHelpers.export(exports, "default", ()=>sequentialQuantile); +var _d3Array = require("d3-array"); +var _continuousJs = require("./continuous.js"); +var _initJs = require("./init.js"); +function sequentialQuantile() { + var domain = [], interpolator = (0, _continuousJs.identity); + function scale(x) { + if (x != null && !isNaN(x = +x)) return interpolator(((0, _d3Array.bisect)(domain, x, 1) - 1) / (domain.length - 1)); + } + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = []; + for (let d of _)if (d != null && !isNaN(d = +d)) domain.push(d); + domain.sort((0, _d3Array.ascending)); + return scale; + }; + scale.interpolator = function(_) { + return arguments.length ? (interpolator = _, scale) : interpolator; + }; + scale.range = function() { + return domain.map((d, i)=>interpolator(i / (domain.length - 1))); + }; + scale.quantiles = function(n) { + return Array.from({ + length: n + 1 + }, (_, i)=>(0, _d3Array.quantile)(domain, i / n)); + }; + scale.copy = function() { + return sequentialQuantile(interpolator).domain(domain); + }; + return (0, _initJs.initInterpolator).apply(scale, arguments); +} -},{"@fluentui/dom-utilities":"2DoJo","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"lA2Mh":[function(require,module,exports) { +},{"d3-array":"5lCYW","./continuous.js":"2SYx4","./init.js":"ijd73","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"6Pqcc":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Composes two components which conform to the `IComponentAs` specification; that is, two - * components which accept a `defaultRender` prop, which is a 'default' implementation of - * a component which accepts the same overall props. - * - * @public - */ parcelHelpers.export(exports, "composeComponentAs", ()=>composeComponentAs); -var _tslib = require("tslib"); -var _react = require("react"); -var _memoize = require("../memoize"); -function createComposedComponent(outer) { - var Outer = outer; - var outerMemoizer = (0, _memoize.createMemoizer)(function(inner) { - if (outer === inner) throw new Error("Attempted to compose a component with itself."); - var Inner = inner; - var innerMemoizer = (0, _memoize.createMemoizer)(function(defaultRender) { - var InnerWithDefaultRender = function(innerProps) { - return _react.createElement(Inner, (0, _tslib.__assign)({}, innerProps, { - defaultRender: defaultRender - })); - }; - return InnerWithDefaultRender; - }); - var OuterWithDefaultRender = function(outerProps) { - var defaultRender = outerProps.defaultRender; - return _react.createElement(Outer, (0, _tslib.__assign)({}, outerProps, { - defaultRender: defaultRender ? innerMemoizer(defaultRender) : Inner - })); +parcelHelpers.export(exports, "default", ()=>diverging); +parcelHelpers.export(exports, "divergingLog", ()=>divergingLog); +parcelHelpers.export(exports, "divergingSymlog", ()=>divergingSymlog); +parcelHelpers.export(exports, "divergingPow", ()=>divergingPow); +parcelHelpers.export(exports, "divergingSqrt", ()=>divergingSqrt); +var _d3Interpolate = require("d3-interpolate"); +var _continuousJs = require("./continuous.js"); +var _initJs = require("./init.js"); +var _linearJs = require("./linear.js"); +var _logJs = require("./log.js"); +var _sequentialJs = require("./sequential.js"); +var _symlogJs = require("./symlog.js"); +var _powJs = require("./pow.js"); +function transformer() { + var x0 = 0, x1 = 0.5, x2 = 1, s = 1, t0, t1, t2, k10, k21, interpolator = (0, _continuousJs.identity), transform, clamp = false, unknown; + function scale(x) { + return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (s * x < s * t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x)); + } + scale.domain = function(_) { + return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1, scale) : [ + x0, + x1, + x2 + ]; + }; + scale.clamp = function(_) { + return arguments.length ? (clamp = !!_, scale) : clamp; + }; + scale.interpolator = function(_) { + return arguments.length ? (interpolator = _, scale) : interpolator; + }; + function range(interpolate) { + return function(_) { + var r0, r1, r2; + return arguments.length ? ([r0, r1, r2] = _, interpolator = (0, _d3Interpolate.piecewise)(interpolate, [ + r0, + r1, + r2 + ]), scale) : [ + interpolator(0), + interpolator(0.5), + interpolator(1) + ]; }; - return OuterWithDefaultRender; - }); - return outerMemoizer; -} -var componentAsMemoizer = (0, _memoize.createMemoizer)(createComposedComponent); -function composeComponentAs(outer, inner) { - return componentAsMemoizer(outer)(inner); + } + scale.range = range((0, _d3Interpolate.interpolate)); + scale.rangeRound = range((0, _d3Interpolate.interpolateRound)); + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + return function(t) { + transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1; + return scale; + }; } - -},{"tslib":"01Tx1","react":"8ePka","../memoize":"63n82","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"63n82":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); -parcelHelpers.defineInteropFlag(exports); -/** - * Test utility for providing a custom weakmap. - * - * @internal - * */ parcelHelpers.export(exports, "setMemoizeWeakMap", ()=>setMemoizeWeakMap); -/** - * Reset memoizations. - */ parcelHelpers.export(exports, "resetMemoizations", ()=>resetMemoizations); -/** - * Memoize decorator to be used on class methods. WARNING: the `this` reference - * will be inaccessible within a memoized method, given that a cached method's `this` - * would not be instance-specific. - * - * @public - */ parcelHelpers.export(exports, "memoize", ()=>memoize); -/** - * Memoizes a function; when you pass in the same parameters multiple times, it returns a cached result. - * Be careful when passing in objects, you need to pass in the same INSTANCE for caching to work. Otherwise - * it will grow the cache unnecessarily. Also avoid using default values that evaluate functions; passing in - * undefined for a value and relying on a default function will execute it the first time, but will not - * re-evaluate subsequent times which may have been unexpected. - * - * By default, the cache will reset after 100 permutations, to avoid abuse cases where the function is - * unintendedly called with unique objects. Without a reset, the cache could grow infinitely, so we safeguard - * by resetting. To override this behavior, pass a value of 0 to the maxCacheSize parameter. - * - * @public - * @param cb - The function to memoize. - * @param maxCacheSize - Max results to cache. If the cache exceeds this value, it will reset on the next call. - * @param ignoreNullOrUndefinedResult - Flag to decide whether to cache callback result if it is undefined/null. - * If the flag is set to true, the callback result is recomputed every time till the callback result is - * not undefined/null for the first time, and then the non-undefined/null version gets cached. - * @returns A memoized version of the function. - */ parcelHelpers.export(exports, "memoizeFunction", ()=>memoizeFunction); -/** - * Creates a memoizer for a single-value function, backed by a WeakMap. - * With a WeakMap, the memoized values are only kept as long as the source objects, - * ensuring that there is no memory leak. - * - * This function assumes that the input values passed to the wrapped function will be - * `function` or `object` types. To memoize functions which accept other inputs, use - * `memoizeFunction`, which memoizes against arbitrary inputs using a lookup cache. - * - * @public - */ parcelHelpers.export(exports, "createMemoizer", ()=>createMemoizer); -var _mergeStyles = require("@fluentui/merge-styles"); -var _initializedStylesheetResets = false; -var _resetCounter = 0; -var _emptyObject = { - empty: true -}; -var _dictionary = {}; -var _weakMap = typeof WeakMap === "undefined" ? null : WeakMap; -function setMemoizeWeakMap(weakMap) { - _weakMap = weakMap; +function diverging() { + var scale = (0, _linearJs.linearish)(transformer()((0, _continuousJs.identity))); + scale.copy = function() { + return (0, _sequentialJs.copy)(scale, diverging()); + }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } -function resetMemoizations() { - _resetCounter++; +function divergingLog() { + var scale = (0, _logJs.loggish)(transformer()).domain([ + 0.1, + 1, + 10 + ]); + scale.copy = function() { + return (0, _sequentialJs.copy)(scale, divergingLog()).base(scale.base()); + }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } -function memoize(_target, _key, descriptor) { - // We bind to "null" to prevent people from inadvertently pulling values from "this", - // rather than passing them in as input values which can be memoized. - var fn = memoizeFunction(descriptor.value && descriptor.value.bind(null)); - return { - configurable: true, - get: function() { - return fn; - } +function divergingSymlog() { + var scale = (0, _symlogJs.symlogish)(transformer()); + scale.copy = function() { + return (0, _sequentialJs.copy)(scale, divergingSymlog()).constant(scale.constant()); }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } -function memoizeFunction(cb, maxCacheSize, ignoreNullOrUndefinedResult) { - if (maxCacheSize === void 0) maxCacheSize = 100; - if (ignoreNullOrUndefinedResult === void 0) ignoreNullOrUndefinedResult = false; - // Avoid breaking scenarios which don't have weak map. - if (!_weakMap) return cb; - if (!_initializedStylesheetResets) { - var stylesheet = (0, _mergeStyles.Stylesheet).getInstance(); - if (stylesheet && stylesheet.onReset) (0, _mergeStyles.Stylesheet).getInstance().onReset(resetMemoizations); - _initializedStylesheetResets = true; - } - var rootNode; - var cacheSize = 0; - var localResetCounter = _resetCounter; - return function memoizedFunction() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - var currentNode = rootNode; - if (rootNode === undefined || localResetCounter !== _resetCounter || maxCacheSize > 0 && cacheSize > maxCacheSize) { - rootNode = _createNode(); - cacheSize = 0; - localResetCounter = _resetCounter; - } - currentNode = rootNode; - // Traverse the tree until we find the match. - for(var i = 0; i < args.length; i++){ - var arg = _normalizeArg(args[i]); - if (!currentNode.map.has(arg)) currentNode.map.set(arg, _createNode()); - currentNode = currentNode.map.get(arg); - } - if (!currentNode.hasOwnProperty("value")) { - currentNode.value = cb.apply(void 0, args); - cacheSize++; - } - if (ignoreNullOrUndefinedResult && (currentNode.value === null || currentNode.value === undefined)) currentNode.value = cb.apply(void 0, args); - return currentNode.value; +function divergingPow() { + var scale = (0, _powJs.powish)(transformer()); + scale.copy = function() { + return (0, _sequentialJs.copy)(scale, divergingPow()).exponent(scale.exponent()); }; + return (0, _initJs.initInterpolator).apply(scale, arguments); } -function createMemoizer(getValue) { - if (!_weakMap) // Without a `WeakMap` implementation, memoization is not possible. - return getValue; - var cache = new _weakMap(); - function memoizedGetValue(input) { - if (!input || typeof input !== "function" && typeof input !== "object") // A WeakMap can only be used to test against reference values, i.e. 'function' and 'object'. - // All other inputs cannot be memoized against in this manner. - return getValue(input); - if (cache.has(input)) return cache.get(input); - var value = getValue(input); - cache.set(input, value); - return value; - } - return memoizedGetValue; +function divergingSqrt() { + return divergingPow.apply(null, arguments).exponent(0.5); } -function _normalizeArg(val) { - if (!val) return _emptyObject; - else if (typeof val === "object" || typeof val === "function") return val; - else if (!_dictionary[val]) _dictionary[val] = { - val: val - }; - return _dictionary[val]; + +},{"d3-interpolate":"hWyQt","./continuous.js":"2SYx4","./init.js":"ijd73","./linear.js":"ik2PQ","./log.js":"5BBe1","./sequential.js":"e0eA3","./symlog.js":"26cMO","./pow.js":"ah9R8","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"7m9yM":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "version", ()=>version); +const version = '4.0.6'; + +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"71zHd":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +parcelHelpers.defineInteropFlag(exports); +parcelHelpers.export(exports, "classList", ()=>classList); +parcelHelpers.export(exports, "deepCompare", ()=>deepCompare); +parcelHelpers.export(exports, "compareInsight", ()=>compareInsight); +var _justCompare = require("just-compare"); +const classList = (...args)=>{ + return args.filter(Boolean).join(' '); +}; +const deepCompare = _justCompare.default || _justCompare; +function addNullable(insight, signalValues) { + const withNulls = Object.assign(Object.assign({ + view: null, + filter: null + }, insight), { + signalValues + }); + return withNulls; } -function _createNode() { +function compareInsight(viewer, insight) { + const currentInsight = viewer.getInsight(); + const a = addNullable(currentInsight, Object.assign(Object.assign({}, viewer.insight.signalValues), currentInsight.signalValues)); + const b = addNullable(insight, Object.assign(Object.assign({}, a.signalValues), insight.signalValues)); + const compare = deepCompare(a, b); return { - map: _weakMap ? new _weakMap() : null + a, + b, + compare }; } -},{"@fluentui/merge-styles":"ggD5u","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"77Y1K":[function(require,module,exports) { +},{"just-compare":"hL7vS","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"hL7vS":[function(require,module,exports,__globalThis) { var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Determines whether a component is controlled. - * @param props - Component props - * @param valueProp - Prop containing the controlled value - * @returns true if controlled, false if uncontrolled - */ parcelHelpers.export(exports, "isControlled", ()=>isControlled); -function isControlled(props, valueProp) { - // React's built-in considers a prop to be provided if its value is non-null/undefined. - // Mirror that behavior here (rather than checking for just undefined). - return props[valueProp] !== undefined && props[valueProp] !== null; +parcelHelpers.export(exports, "default", ()=>collectionCompare); +var collectionCompare = compare; +/* + primitives: value1 === value2 + functions: value1.toString == value2.toString + arrays: if length, sequence and values of properties are identical + objects: if length, names and values of properties are identical + compare([[1, [2, 3]], [[1, [2, 3]]); // true + compare([[1, [2, 3], 4], [[1, [2, 3]]); // false + compare({a: 2, b: 3}, {a: 2, b: 3}); // true + compare({a: 2, b: 3}, {b: 3, a: 2}); // true + compare({a: 2, b: 3, c: 4}, {a: 2, b: 3}); // false + compare({a: 2, b: 3}, {a: 2, b: 3, c: 4}); // false + compare([[1, [2, {a: 4}], 4], [[1, [2, {a: 4}]]); // true +*/ function compare(value1, value2) { + if (value1 === value2) return true; + /* eslint-disable no-self-compare */ // if both values are NaNs return true + if (value1 !== value1 && value2 !== value2) return true; + if (({}).toString.call(value1) != ({}).toString.call(value2)) return false; + if (value1 !== Object(value1)) // non equal primitives + return false; + if (!value1) return false; + if (Array.isArray(value1)) return compareArrays(value1, value2); + if (({}).toString.call(value1) == '[object Set]') return compareArrays(Array.from(value1), Array.from(value2)); + if (({}).toString.call(value1) == '[object Object]') return compareObjects(value1, value2); + else return compareNativeSubtypes(value1, value2); +} +function compareNativeSubtypes(value1, value2) { + // e.g. Function, RegExp, Date + return value1.toString() === value2.toString(); +} +function compareArrays(value1, value2) { + var len = value1.length; + if (len != value2.length) return false; + var alike = true; + for(var i = 0; i < len; i++)if (!compare(value1[i], value2[i])) { + alike = false; + break; + } + return alike; +} +function compareObjects(value1, value2) { + var keys1 = Object.keys(value1).sort(); + var keys2 = Object.keys(value2).sort(); + var len = keys1.length; + if (len != keys2.length) return false; + for(var i = 0; i < len; i++){ + var key1 = keys1[i]; + var key2 = keys2[i]; + if (!(key1 == key2 && compare(value1[key1], value2[key2]))) return false; + } + return true; } -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"j75mX":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"2yfj3":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -/** - * Concatination helper, which can merge class names together. Skips over falsey values. - * - * @public - */ parcelHelpers.export(exports, "css", ()=>css); -function css() { - var args = []; - for(var _i = 0; _i < arguments.length; _i++)args[_i] = arguments[_i]; - var classes = []; - for(var _a = 0, args_1 = args; _a < args_1.length; _a++){ - var arg = args_1[_a]; - if (arg) { - if (typeof arg === "string") classes.push(arg); - else if (arg.hasOwnProperty("toString") && typeof arg.toString === "function") classes.push(arg.toString()); - else { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - for(var key in arg)// eslint-disable-next-line @typescript-eslint/no-explicit-any - if (arg[key]) classes.push(key); +parcelHelpers.export(exports, "Viewer", ()=>Viewer); +var _base = require("./base"); +var _util = require("./util"); +var _sanddance = require("@msrvida/sanddance"); +function _Viewer(_props) { + class __Viewer extends (0, _base.base).react.Component { + layout() { + const { props } = this; + this.lastData = props.data; + this.viewer.render({ + insight: props.insight, + setup: props.setup + }, props.data, props.renderOptions).then((renderResult)=>{ + //TODO: show errors if any + //console.log('viewer render'); + props.onView && props.onView(renderResult); + }).catch((e)=>{ + //console.log('viewer error'); + props.onError && props.onError(e); + }); + } + view() { + var _a, _b, _c, _d, _e; + const { props } = this; + let didLayout = false; + if (props.insight && props.data) { + const c = (0, _util.compareInsight)(this.viewer, props.insight); + const sameDataRef = props.data === this.lastData; + if (!c.compare || !sameDataRef) { + this.layout(); + didLayout = true; + } + } + if (!didLayout && props.setup) { + const { camera } = props.setup; + //compare setup, move camera + if (camera !== 'hold') { + if (!(0, _util.deepCompare)(this.viewer.setup.camera, camera)) { + //camera is different + if (!camera) (_b = (_a = this.viewer) === null || _a === void 0 ? void 0 : _a.presenter) === null || _b === void 0 || _b.homeCamera(); + else this.viewer.setCamera(camera); + //save this for next comparison + const setup = (0, _sanddance.VegaMorphCharts).util.clone(this.viewer.setup); + setup.camera = camera; + this.viewer.setup = setup; + } + } + if (props.setup.renderer) (_e = (_d = (_c = this.viewer) === null || _c === void 0 ? void 0 : _c.presenter) === null || _d === void 0 ? void 0 : _d.morphchartsref) === null || _e === void 0 || _e.setMorphChartsRendererOptions(props.setup.renderer); } } + componentDidMount() { + const { props } = this; + const element = (0, _base.base).reactDOM.findDOMNode(this.viewerDiv); + this.viewer = new (0, _sanddance.Viewer)(element, props.viewerOptions); + if (props.onMount) { + if (props.onMount(this.viewer.presenter.getElement((0, _sanddance.VegaMorphCharts).PresenterElement.gl))) this.view(); + } else this.view(); + } + componentDidUpdate() { + const { props } = this; + this.viewer.options = (0, _sanddance.VegaMorphCharts).util.deepMerge(this.viewer.options, props.viewerOptions); + this.view(); + } + componentWillUnmount() { + this.viewer.finalize(); + } + render() { + return (0, _base.base).react.createElement("div", { + className: "sanddance-ReactViewer", + ref: (div)=>this.viewerDiv = div + }); + } } - return classes.join(" "); + return new __Viewer(_props); } +const Viewer = _Viewer; -},{"@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"7aH6S":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./base":"e2btd","./util":"71zHd","@msrvida/sanddance":"ganM8","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"e2btd":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Customizations", ()=>Customizations); -var _tslib = require("tslib"); -var _globalSettings = require("../GlobalSettings"); -var CustomizationsGlobalKey = "customizations"; -var NO_CUSTOMIZATIONS = { - settings: {}, - scopedSettings: {}, - inCustomizerContext: false +parcelHelpers.export(exports, "base", ()=>base); +/** + * Specify the dependency libraries to use for rendering. + * @param react React library. + * @param vega Vega library. + * @param deck @deck.gl/core library. + * @param layers @deck.gl/layers library. + * @param luma @luma.gl/core library. + */ parcelHelpers.export(exports, "use", ()=>use); +var _viewer = require("./viewer"); +var _sanddance = require("@msrvida/sanddance"); +const base = { + react: null, + reactDOM: null }; -var _allSettings = (0, _globalSettings.GlobalSettings).getValue(CustomizationsGlobalKey, { - settings: {}, - scopedSettings: {}, - inCustomizerContext: false -}); -var _events = []; -var Customizations = /** @class */ function() { - function Customizations() {} - Customizations.reset = function() { - _allSettings.settings = {}; - _allSettings.scopedSettings = {}; - }; - /** Apply global Customization settings. - * @example Customizations.applySettings(\{ theme: \{...\} \}); - */ Customizations.applySettings = function(settings) { - _allSettings.settings = (0, _tslib.__assign)((0, _tslib.__assign)({}, _allSettings.settings), settings); - Customizations._raiseChange(); - }; - /** Apply Customizations to a particular named scope, like a component. - * @example Customizations.applyScopedSettings('Nav', \{ styles: () =\> \{\} \}); - */ Customizations.applyScopedSettings = function(scopeName, settings) { - _allSettings.scopedSettings[scopeName] = (0, _tslib.__assign)((0, _tslib.__assign)({}, _allSettings.scopedSettings[scopeName]), settings); - Customizations._raiseChange(); - }; - Customizations.getSettings = function(properties, scopeName, localSettings) { - if (localSettings === void 0) localSettings = NO_CUSTOMIZATIONS; - var settings = {}; - var localScopedSettings = scopeName && localSettings.scopedSettings[scopeName] || {}; - var globalScopedSettings = scopeName && _allSettings.scopedSettings[scopeName] || {}; - for(var _i = 0, properties_1 = properties; _i < properties_1.length; _i++){ - var property = properties_1[_i]; - settings[property] = localScopedSettings[property] || localSettings.settings[property] || globalScopedSettings[property] || _allSettings.settings[property]; - } - return settings; - }; - /** Used to run some code that sets Customizations without triggering an update until the end. - * Useful for applying Customizations that don't affect anything currently rendered, or for - * applying many customizations at once. - * @param suppressUpdate - Do not raise the change event at the end, preventing all updates - */ Customizations.applyBatchedUpdates = function(code, suppressUpdate) { - Customizations._suppressUpdates = true; - try { - code(); - } catch (_a) { - /* do nothing */ } - Customizations._suppressUpdates = false; - if (!suppressUpdate) Customizations._raiseChange(); - }; - Customizations.observe = function(onChange) { - _events.push(onChange); - }; - Customizations.unobserve = function(onChange) { - _events = _events.filter(function(cb) { - return cb !== onChange; - }); - }; - Customizations._raiseChange = function() { - if (!Customizations._suppressUpdates) _events.forEach(function(cb) { - return cb(); - }); - }; - return Customizations; -}(); +function use(react, reactDOM, vega) { + _sanddance.VegaMorphCharts.use(vega); + base.react = react; + base.reactDOM = reactDOM; + //inform React that we are using a dynamic base class + (0, _viewer.Viewer).prototype = react.Component.prototype; +} -},{"tslib":"01Tx1","../GlobalSettings":"hOBvf","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"83xLA":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"./viewer":"2yfj3","@msrvida/sanddance":"ganM8","@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"g42QN":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "Customizer", ()=>Customizer); -var _tslib = require("tslib"); -var _react = require("react"); -var _customizations = require("./Customizations"); -var _customizerContext = require("./CustomizerContext"); -var _mergeCustomizations = require("./mergeCustomizations"); -/** - * The Customizer component allows for default props to be mixed into components which - * are decorated with the customizable() decorator, or use the styled HOC. This enables - * injection scenarios like: - * - * 1. render svg icons instead of the icon font within all buttons - * 2. inject a custom theme object into a component - * - * Props are provided via the settings prop which should be one of the following: - * - A json map which contains 1 or more name/value pairs representing injectable props. - * - A function that receives the current settings and returns the new ones that apply to the scope - * - * @public - * - * @deprecated This component is deprecated for purpose of applying theme to components - * as of `@fluentui/react` version 8. Use `ThemeProvider` for applying theme instead. - */ var Customizer = /** @class */ function(_super) { - (0, _tslib.__extends)(Customizer, _super); - function Customizer() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._onCustomizationChange = function() { - return _this.forceUpdate(); - }; - return _this; - } - Customizer.prototype.componentDidMount = function() { - (0, _customizations.Customizations).observe(this._onCustomizationChange); - }; - Customizer.prototype.componentWillUnmount = function() { - (0, _customizations.Customizations).unobserve(this._onCustomizationChange); - }; - Customizer.prototype.render = function() { - var _this = this; - var contextTransform = this.props.contextTransform; - return _react.createElement((0, _customizerContext.CustomizerContext).Consumer, null, function(parentContext) { - var newContext = (0, _mergeCustomizations.mergeCustomizations)(_this.props, parentContext); - if (contextTransform) newContext = contextTransform(newContext); - return _react.createElement((0, _customizerContext.CustomizerContext).Provider, { - value: newContext - }, _this.props.children); - }); - }; - return Customizer; -}(_react.Component); +parcelHelpers.export(exports, "version", ()=>version); +const version = '4.0.2'; -},{"tslib":"01Tx1","react":"8ePka","./Customizations":"7aH6S","./CustomizerContext":"fYZ4d","./mergeCustomizations":"aWBwG","@parcel/transformer-js/src/esmodule-helpers.js":"dWZT9"}],"fYZ4d":[function(require,module,exports) { -var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); +},{"@parcel/transformer-js/src/esmodule-helpers.js":"j7FRh"}],"67xOI":[function(require,module,exports,__globalThis) { +/*! +* Copyright (c) Microsoft Corporation. +* Licensed under the MIT License. +*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); parcelHelpers.defineInteropFlag(exports); -parcelHelpers.export(exports, "CustomizerContext", ()=>CustomizerContext); -var _react = require("react"); -var CustomizerContext = _react.createContext({ - customizations: { - inCustomizerContext: false, - settings: {}, - scopedSettings: {} - } -}); +parcelHelpers.export(exports, "strings", ()=>strings); +const strings = { + appName: 'SandDance', + bingsearch: 'Bing', + bingsearchDescription: (term)=>`Search Bing for "${term}"`, + buttonClose: 'Close', + buttonSelect: 'Search & Select', + buttonColorSchemeMap: 'Map color scheme to filtered data', + buttonColorSchemeRemap: 'Remap color to filtered data', + buttonColorSchemeKeep: 'Keep same color scheme', + buttonCopyToClipboard: 'Copy to clipboard', + buttonExclude: 'Exclude', + buttonExport: 'Export', + buttonExportCount: (total)=>total == 1 ? 'Export 1 row...' : `Export ${total} rows...`, + buttonIsolate: 'Isolate', + buttonReset: 'Stop filtering', + buttonDeselect: 'Clear selection', + buttonToolbarFloat: 'Float toolbar', + buttonToolbarDock: 'Dock toolbar', + buttonToolbarHide: 'Hide toolbar', + buttonToolbarShow: 'Show toolbar', + buttonNextDataItem: 'Next data item', + buttonPrevDataItem: 'Previous data item', + buttonCreateSnapshot: 'Create snapshot', + buttonNextSnapshot: 'Next snapshot', + buttonPrevSnapshot: 'Previous snapshot', + buttonUpdateSnapshot: 'Update snapshot', + buttonAddExpression: 'Add expression', + buttonAddExpressionGroup: 'Add group', + buttonDeleteExpression: 'Delete', + buttonDeleteExpressionGroup: 'Delete group', + buttonClearSnapshots: 'Clear snapshots', + buttonDeleteSnapshot: 'Delete snapshot', + buttonEditSnapshot: 'Edit snapshot', + buttonMoveUp: 'Move up', + buttonMoveDown: 'Move down', + buttonShowVegaSpec: 'Show Vega spec', + buttonLaunchVegaEditor: 'Open Vega Editor', + buttonCameraHome: 'Center chart in window', + buttonTooltipMapping: 'Tooltip columns...', + buttonBackgroundImage: 'Background image...', + buttonTransitionReverse: 'Play Reverse', + buttonTransitionPause: 'Pause', + buttonTransitionPlay: 'Play', + buttonUndo: 'Undo', + buttonRedo: 'Redo', + buttonColumnTypes: 'Column types...', + buttonApply: 'Apply', + buttonRemove: 'Remove', + buttonResetToDefault: 'Reset to default', + chartTypeBarChartH: 'Bar', + chartTypeBarChartV: 'Column', + chartTypeDensity: 'Density', + chartTypeGrid: 'Grid', + chartTypeScatterPlot: 'Scatter', + chartTypeStacks: 'Stacks', + chartTypeStrips: 'Strips', + chartTypeTreeMap: 'Treemap', + defaultFileName: 'sanddance-data', + errorExportFilenameEmpty: 'Filename cannot be blank', + errorExportFilenameCharacters: (characters)=>`A filename cannot contain any of the following characters: ${characters}`, + errorColumnMustBeNumeric: 'Numeric column required for this chart type.', + errorNumericValue: 'Value must be numeric', + errorImageFormat: 'File is not an image', + labelBackgroundImageDialogTitle: 'Background image', + labelBackgroundImageSubtext: 'Background image can only be shown on Scatterplot, Density, and Stacks charts. Columns must be numeric type.', + labelBackgroundLeft: 'Left extent', + labelBackgroundRight: 'Right extent', + labelBackgroundBottom: 'Bottom extent', + labelBackgroundTop: 'Top extent', + labelBlank: 'blank', + labelNull: 'null', + labelTrue: 'true', + labelFalse: 'false', + labelSystemInfo: 'System info', + labelChangeColumnType: 'Change column type', + labelChartSettings: 'Chart settings', + labelEditColumn: 'Edit', + labelColumnName: 'Column name', + labelColumnType: 'Column type', + labelColumnDistinct: 'Distinct values', + labelColumnHasColorData: 'Has color data', + labelColumnIsColorData: 'Is color data', + labelColumnQuantitativeMin: 'Min', + labelColumnQuantitativeMax: 'Max', + labelColumnQuantitativeMean: 'Mean', + labelDataBrowser: 'Data browser', + labelDataScope: 'Scope', + labelExport: 'Export Data', + labelExportFormat: 'File format', + labelExportCSV: '.CSV - Comma separated values', + labelExportHTML: '.HTML - A SandDance html page embedding this data', + labelExportJSON: '.JSON - JavaScript object notation', + labelExportTSV: '.TSV - Tab separated values', + labelHistory: 'History', + labelHistoryWarning: 'This will erase your current history.', + labelTools: 'Tools', + labelHoldCamera: 'Keep previous camera position', + labelVegaSpec: 'Vega specification', + labelColor: 'Chart color', + labelError: 'Error', + labelExportFileName: 'File name', + labelSnapshots: 'Snapshots', + labelSnapshotSettingThumbnailWidth: 'Thumbnail image width', + labelSearch: 'Select by search', + labelSearchClause: 'Clause', + labelSearchColumn: 'Field', + labelSearchOperator: 'Operator', + labelSearchValue: 'Value', + labelSearchValuePlaceholder: 'Value to search for', + labelChart: 'Chart', + labelChartCanvas: 'Chart canvas', + labelColumnMapping: 'Column Mapping', + labelChartTypeOptions: 'Chart options', + labelColorBin: 'Color binning', + labelColorOptions: 'Color options', + labelColorBinExplanation: 'For numeric columns', + labelColorFieldInfo: (colorColumnName, colorColumnType, categoricalNumeric, distinctValueCount)=>`Field ${colorColumnName} is of type ${colorColumnType}${categoricalNumeric ? ` and has ${distinctValueCount} distinct values` : ''}.`, + labelColorFieldIsColorData: (colorColumnName)=>`Field ${colorColumnName} contains direct color data.`, + labelColorBinNone: 'None (continuous)', + labelColorBinQuantize: 'Quantize', + labelColorBinQuantile: 'Quantile', + labelColorFilter: 'Note: Colors will be re-mapped to the filter when viewing this snapshot.', + labelColorScheme: 'Scheme', + labelTotal: 'Total by', + labelTotalByCountSquare: 'Count (Grid layout)', + labelTotalByCountStrip: 'Count (Strip layout)', + labelTotalBySumStrip: 'Sum (Strip layout)', + labelTotalBySumTreemap: 'Sum (Treemap layout)', + labelTotalBySumStripPercent: 'Sum as percentage (Strip layout)', + labelColumnColor: 'Color by', + labelColumnFacet: 'Facet by', + labelFacetLayout: 'Facet layout', + labelFacetLayoutWrap: 'Wrap', + // labelFacetLayoutHorizontal: 'Horizontal', + // labelFacetLayoutVertical: 'Vertical', + labelFacetLayoutCross: "\u229E", + labelColumnFacetV: 'Cross facet by', + labelColumnSort: 'Sort by', + labelColumnX: 'X Axis', + labelColumnY: 'Y Axis', + labelColumnZ: 'Z Axis', + labelColumnSize: 'Size by', + labelColumnGroup: 'Group by', + labelAliasColor: 'Color', + labelAliasFacet: 'Facet', + labelAliasFacetV: 'Vertical facet', + labelAliasSort: 'Sort', + labelAliasX: 'X Axis', + labelAliasY: 'Y Axis', + labelAliasZ: 'Z Axis', + labelAliasSize: 'Size', + labelAliasGroup: 'Group', + labelDataItemIsFiltered: 'Item is filtered from view', + labelHistoryInit: 'Initial view', + labelHistoryFilterClear: 'Clear filter', + labelHistoryFilterIExclude: 'Exclude filter', + labelHistoryFilterIsolate: 'Isolate filter', + labelHistoryChangeChartType: (chart)=>`Change chart type to ${chart}`, + labelHistoryMapColumn: (column)=>`Map ${column} role`, + labelHistoryUnMapColumn: (column)=>`Unmap ${column} role`, + labelHistoryReviveSnapshot: 'Revive snapshot', + labelHistoryColorBin: 'Change color binning', + labelHistoryDirectColor: 'Change direct color', + labelRenderer: 'Renderer quality', + labelRendererAdvancedDisabled: 'Renderer quality (Enhanced 3D mode not supported on this device)', + labelRendererBasic: 'Standard mode', + labelRendererAdvanced: 'Enhanced 3D mode', + labelRendererOptions: 'Renderer options ...', + labelRendererOptionsDialogTitle: 'Renderer options', + labelRendererOptionsAntialias: 'Antialias', + labelRendererOptionsBloom: 'Bloom highlighting (for selections)', + labelRendererOptionsBloomIntensity: 'Intensity', + labelRendererOptionsDof: 'Depth of Field', + labelRendererOptionsDofRange: 'Focus Range', + labelRendererOptionsFxaa: 'Antialias', + labelRendererOptionsShadow: 'Shadows', + labelRendererOptionsSsao: 'Screen Space Ambient Occlusion', + labelShowLegend: 'Show legend', + labelShowAxes: 'Show axes', + labelSnapshotTitle: 'Title', + labelSnapshotDescription: 'Note (optional)', + labelTooltipMapping: 'Tooltip columns', + labelTransition: 'Transition', + labelTransitionOptions: 'Transition options', + labelTransitionScrubber: 'Scrub transition', + labelTransitionStaggerBy: 'Stagger by', + labelTransitionStaggerByOrdinal: 'Data order', + labelTransitionStaggerByColumn: 'Column', + labelTransitionStaggerByPosition: 'Axis position', + labelTransitionStaggerOptions: 'Stagger options', + labelTransitionStaggerReverse: 'Reverse', + labelTransitionDurations: 'Transition durations', + labelTransitionCamera: '2D / 3D view', + labelTransitionDuration: 'Duration', + labelTransitionStagger: 'Stagger', + labelVegaSpecData: 'Data reference', + labelVegaSpecNotes: 'Note: You may need to change the color scheme to make this visible in Vega.', + labelYes: 'Yes', + labelNo: 'No', + labelConfirmation: 'Are you sure?', + labelColumnTypes: 'Column types', + loading: 'Loading...', + schemeCategorical: 'Categorical', + schemeCyclical: 'Cyclical', + schemeDiverging: 'Diverging', + schemeDual: 'Dual', + schemeSequentialMultiHue: 'Sequential Multi Hue', + schemeSequentialMultiHueDark: 'For dark backgrounds', + schemeSequentialMultiHueLight: 'For light backgrounds', + schemeSequentialSingleHue: 'Sequential Single Hue', + selectDataSpanAll: 'All rows', + selectDataSpanFilter: 'Filtered', + selectDataSpanSelection: 'Selected', + selectVegaSpecDataNone: 'None', + selectVegaSpecDataInline: 'Inline - WARNING this may use substantial browser/clipboard memory for large data sets.', + selectVegaSpecDataUrl: 'URL', + record: (current, total)=>`${current} of ${total}`, + searchEQ: '=', + searchNEQ: '<>', + searchGT: '>', + searchGTE: '>=', + searchLT: '<', + searchLTE: '<=', + searchNULL: 'is null or empty', + searchIN: 'contains', + searchSW: 'starts with', + searchWHERE: 'Where', + searchAND: 'and', + searchOR: 'or', + selectAny: '-- any --', + selectNone: '-- none --', + selectNumeric: 'Numeric', + selectNonNumeric: 'Categorical', + selectDirectColor: 'Direct color', + selectReference: 'Column mappings', + tooltipSearch: (column, value)=>`Click to search in '${column}' for "${value}"`, + labelRequired: 'required', + labelSystem: 'System', + labelViewType2d: 'View in 2D', + labelViewType3d: 'View in 3D', + labelDataColors: 'Enabled if this data column contains any CSS color values.', + labelDataNullAll: 'Loading data...', + labelDataNullFiltered: 'You can filter by first making a selection, then choosing Isolate or Exclude in the top bar.', + labelDataNullSelection: 'You can select by: