diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..e4fc7fe
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,7 @@
+test/js
+test/mocha.js
+/webgl-lint.js
+dist
+examples/3rdParty
+out
+examples/**/*.js
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
new file mode 100644
index 0000000..c3b9a4f
--- /dev/null
+++ b/.eslintrc.cjs
@@ -0,0 +1,109 @@
+/* global module */
+
+module.exports = {
+ parser: '@typescript-eslint/parser',
+ env: {
+ es2022: true,
+ browser: true,
+ },
+ parserOptions: {
+ sourceType: 'module',
+ ecmaVersion: 'latest',
+ tsconfigRootDir: __dirname,
+ project: ['./tsconfig.json'],
+ },
+ root: true,
+
+ plugins: [
+ '@typescript-eslint',
+ 'eslint-plugin-html',
+ 'eslint-plugin-optional-comma-spacing',
+ 'eslint-plugin-require-trailing-comma',
+ ],
+ extends: [
+ 'eslint:recommended',
+ 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
+ ],
+ rules: {
+ 'brace-style': [2, '1tbs', { allowSingleLine: false }],
+ camelcase: [0],
+ 'comma-dangle': 0,
+ 'comma-spacing': 0,
+ 'comma-style': [2, 'last'],
+ 'consistent-return': 2,
+ curly: [2, 'all'],
+ 'dot-notation': 0,
+ 'eol-last': [0],
+ eqeqeq: 2,
+ 'global-strict': [0],
+ 'key-spacing': [0],
+ 'keyword-spacing': [1, { before: true, after: true, overrides: {} }],
+ 'new-cap': 2,
+ 'new-parens': 2,
+ 'no-alert': 2,
+ 'no-array-constructor': 2,
+ 'no-caller': 2,
+ 'no-catch-shadow': 2,
+ 'no-comma-dangle': [0],
+ 'no-const-assign': 2,
+ 'no-eval': 2,
+ 'no-extend-native': 2,
+ 'no-extra-bind': 2,
+ 'no-extra-parens': [2, 'functions'],
+ 'no-implied-eval': 2,
+ 'no-irregular-whitespace': 2,
+ 'no-iterator': 2,
+ 'no-label-var': 2,
+ 'no-labels': 2,
+ 'no-lone-blocks': 2,
+ 'no-loop-func': 2,
+ 'no-multi-spaces': [0],
+ 'no-multi-str': 2,
+ 'no-native-reassign': 2,
+ 'no-new-func': 2,
+ 'no-new-object': 2,
+ 'no-new-wrappers': 2,
+ 'no-new': 2,
+ 'no-obj-calls': 2,
+ 'no-octal-escape': 2,
+ 'no-process-exit': 2,
+ 'no-proto': 2,
+ 'no-return-assign': 2,
+ 'no-script-url': 2,
+ 'no-sequences': 2,
+ 'no-shadow-restricted-names': 2,
+ 'no-shadow': [0],
+ 'no-spaced-func': 2,
+ 'no-trailing-spaces': 2,
+ 'no-undef-init': 2,
+ //'no-undef': 2, // ts recommends this be off: https://typescript-eslint.io/linting/troubleshooting
+ 'no-underscore-dangle': 2,
+ 'no-unreachable': 2,
+ 'no-unused-expressions': 2,
+ 'no-use-before-define': 0,
+ 'no-var': 2,
+ 'no-with': 2,
+ 'one-var': ["error", "never"],
+ 'optional-comma-spacing/optional-comma-spacing': [2, { after: true }],
+ 'prefer-const': 2,
+ 'require-trailing-comma/require-trailing-comma': [2],
+ 'semi-spacing': [2, { before: false, after: true }],
+ semi: [2, 'always'],
+ 'space-before-function-paren': [
+ 2,
+ {
+ anonymous: 'always',
+ named: 'never',
+ asyncArrow: 'always',
+ },
+ ],
+ 'space-infix-ops': 2,
+ 'space-unary-ops': [2, { words: true, nonwords: false }],
+ strict: [2, 'function'],
+ yoda: [2, 'never'],
+ '@typescript-eslint/no-empty-function': 'off',
+ '@typescript-eslint/no-explicit-any': 'off', // TODO: Reenable this and figure out how to fix code.
+ '@typescript-eslint/no-non-null-assertion': 'off',
+ '@typescript-eslint/no-unused-vars': 2,
+ },
+};
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5aab17e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+
+
+*.pyc
+.DS_Store
+node_modules
+out
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..230241b
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,9 @@
+{
+ "cSpell.words": [
+ "Accum",
+ "elems",
+ "muigui",
+ "stepify",
+ "treeshake"
+ ]
+}
\ No newline at end of file
diff --git a/CNAME b/CNAME
new file mode 100644
index 0000000..4eef503
--- /dev/null
+++ b/CNAME
@@ -0,0 +1 @@
+muigui.org
\ No newline at end of file
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..36cc8c1
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2022 Gregg Tavares
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a70362c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,94 @@
+# muigui
+
+# NOT READY for USE
+
+
+
+## License
+
+[MIT](https://github.com/greggman/muigui/blob/main/LICENSE.md)
diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..b1e1ff1
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,181 @@
+# To Do
+
+- [ ] Tests
+- [ ] DirectionView to use converters
+- [ ] Color RGB, HSL, LAB, Alpha? (just input=color for now?)
+ - [x] red, green, blue color formats
+ - [x] #RGB
+ - [x] RGB
+ - [x] #RRGGBB
+ - [x] RRGGBB
+ - [x] 0xRRGGBB
+ - [x] [255, 255, 255]
+ - [x] [1, 1, 1]
+ - [ ] red, green, blue, alpha color formats
+
+ note: the default color editor doesn't have alpha so this is a big ask.
+ I think this is best as an extra add on since it requires a non-small
+ amount of code to build a color editor? (actually, maybe I don't care about size)
+
+ note: kind of leading toward not carrying about size and also
+ making own color editor as the default one, at least in Chrome,
+ kinda sucks.
+
+ - [ ] 0xRRGGBBAA
+ - [ ] #RRGGBBAA
+ - [ ] [255, 255, 255, 255]
+ - [ ] [1, 1, 1, 1]
+
+ - [ ] hdr colors (this is really just not limited them to 1.0 on float colors, and/or CSS strings)
+- [x] (no for now) wrapping slider? (0-360)
+- [x] (no for now) Direction? (an arrow, low-pri)
+- [x] onChange
+- [x] name
+- [x] listen
+- [x] update
+- [x] disable
+- [x] remove
+- [x] hide
+- [x] fix 'period'. It's stepping by 0.1 and only going to 3.1
+- [ ] camelCase to Camel Case?
+- [x] get rid of min/max/step etc... as setters and add setOptions
+- [ ] interval
+- [ ] radio
+- [x] scroll wheel (not sure, opt in?)
+- [ ] make direction roll with min/max?
+- [ ] add ticks like volume control to direction (rename knob)
+- [x] text red if invalid?
+- [ ] fix editing text (forgot where it's failing)
+- [ ] what should 0x123 do for hex colors because we want it to be 0x000123. I guess it just works.
+- [ ] angle (circle with arrow) - both display, and editor
+- [ ] slider with ticks and number
+- [ ] circle input (circle with 2 arrows) - both display and editor
+- [ ] add keyboard controls to direction
+- [ ] add keyboard controls to vec2
+- [ ] add keyboard controls to color picker
+- [x] Label (not interactive)
+- [x] Label multi line (use as log)
+- [x] ask for file? (nah, drag and drop is better)
+- [ ] styles (form)
+- [x] deg to rad
+- [x] fix step with conversions
+- [x] format slider number?
+- [ ] TextArea (edit larger text)
+ - [ ] pop-out text (or expand in place?)
+- [ ] submenus
+- [x] menu open/close
+- [x] scroll on long (css)
+- [ ] x, y, z
+- [x] copy paste all (no, what would that even look like? right click? Shift-Ctrl-C?)
+- [x] single line text
+- [x] splitter
+- [x] functions to query colors?
+- [x] (doesn't work) maybe just add color-scheme to CSS
+- [ ] make svg ids start with muigui
+- [ ] on enter in text field we need to invalidate value cache
+- [ ] add all
+ - [ ] add with filter? (pass in filter so you can make positive or negative)
+ - [ ] add with list of fields?
+ - [ ] list of options by field name
+ - [ ] recursive (max depth?)
+ - [ ] match by instanceof ?
+ - [ ] let user provide matcher?
+- [x] add hover for long name
+- [ ] try making custom controllers. In particular a list editor like unity
+- [x] fix "RGB"
+- [x] fix first column when changing width
+- [x] do autoplace test
+- [ ] Create layout units? Instead of using CSS directly on types maybe make
+ components that do nothing but layout?
+ `Column`, `Row`, etc. Then for layout it becomes
+
+ Column[
+ title,
+ Column[
+ Row[
+ Column[label, Color, Text],
+ ],
+ Row[
+ Column[label, Slider, Number],
+ ]
+ Row[
+ Button,
+ ]
+ ],
+ ]
+
+ No idea if that makes sense
+
+- [ ] try to refactor Text, Number, Slider, Color, Checkbox, etc, into more reusable components
+ so you can combine them into a new component. Like ideally an X,Y,Z might be
+ 3 sliders. So maybe instead of Checkbox extends ValueComponent it should just
+ `ValueComponent.add(new Checkbox())` or something to that effect. Same with ValueComponent
+ vs Component. Maybe it's `Component.add(new ValueComponent())`
+
+ Can we separate text and number and reuse them?
+
+- [x] auto step (not going to do this for now)
+- [x] fix can't enter trailing '.' on input number (FF only?) (maybe don't set text when value from text)
+- [x] consider more explicit layout
+ - [x] (1 part, 2 parts, 3 parts) or (1 part, 2 parts where 3 is [[1][2[1][2]]])
+- [ ] Docs
+- [ ] API docs (jsdoc)
+- [ ] TypeScript
+- [x] add folder.onChange/onFinishChange
+- [x] Fix Safari Style
+- [x] Fix Safari overflow on long names
+- [x] Change menu to button or at least make it so you can focus
+- [x] add focus to color
+- [x] fix disabled so it disables all inputs (otherwise focus goes there)
+
+---
+
+- [ ] look into add without object. eg
+
+ ```js
+ gui.addButton(title, fn);
+ gui.addSlider(title, get, set, min, max, step);
+ gui.addNumber(title, get, set, converter, step);
+ gui.addText(title, get, set);
+ gui.addCheckbox(title, get, set);
+ gui.addColor(title, get, set, format);
+ ```
+
+ or
+
+ ```js
+ gui.addController(new Button(title, fn));
+ gui.addController(new Slider(title, get, set, min, max, step));
+ gui.addController(new Number(title, get, set, converter, step));
+ gui.addController(new Text(title, get, set));
+ gui.addController(new Checkbox(title, get, set));
+ gui.addController(new Color(title, get, set, format));
+ ```
+
+ It's kind of gross but given this is probably a not a common desire, if you really want to mod a
+ local variable you can do this
+
+ ```js
+ let temperature = 72.0;
+
+ const helper = {
+ get v() { return temperature; }
+ set v(newV) { temperature = newV; }
+ };
+
+ gui.add(helper, 'v').name('temperature');
+ ```
+
+
+ The second is arguably better than the first? The first is cluttered API, having to add every widget.
+ Sadly the `addColor` and `addFolder` are already the expected API 😭
+
+- [ ] Decide what to do about to/from
+
+ DirectionView: pass in what you want
+ NumberView: pass in what you want
+ what if I want hex? (use text view?)
+ SliderView: pass in what you want
+ TextView: ???
+ ColorView: ???
+ Vec2View: pass in what you want
\ No newline at end of file
diff --git a/build/prep-for-deploy.js b/build/prep-for-deploy.js
new file mode 100644
index 0000000..e87158a
--- /dev/null
+++ b/build/prep-for-deploy.js
@@ -0,0 +1,9 @@
+import fs from 'fs';
+import path from 'path';
+import * as url from 'url';
+const dirname = url.fileURLToPath(new URL('.', import.meta.url));
+
+const ignoreFilename = path.join(dirname, '..', '.gitignore');
+const ignore = fs.readFileSync(ignoreFilename, {encoding: 'utf8'});
+const newIgnore = ignore.replace(/# -- clip-for-deploy-start --[\s\S]*?# -- clip-for-deploy-end --/, '');
+fs.writeFileSync(ignoreFilename, newIgnore);
diff --git a/build/serve.js b/build/serve.js
new file mode 100644
index 0000000..a373cb6
--- /dev/null
+++ b/build/serve.js
@@ -0,0 +1,62 @@
+import path from 'path';
+import fsPromise from 'fs/promises';
+import {spawn} from 'child_process';
+import chokidar from 'chokidar';
+
+spawn('./node_modules/.bin/tsc', [
+ '--watch',
+], {
+ stdio: 'inherit',
+});
+
+spawn('./node_modules/.bin/servez', [
+ 'out',
+], {
+ shell: true,
+ stdio: 'inherit',
+});
+
+const ignoreFns = [
+ fn => fn.startsWith('.git'),
+ fn => fn.startsWith('node_modules'),
+ fn => fn.startsWith('build'),
+ fn => fn.startsWith('out'),
+ fn => fn.startsWith('src'),
+ fn => fn.startsWith('dist'),
+ fn => fn.startsWith('.'),
+];
+
+function ignore(fn) {
+ for (const ignoreFn of ignoreFns) {
+ if (ignoreFn(fn)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+const outDir = 'out';
+
+async function copyFile(srcFilename) {
+ const dstFilename = path.join(outDir, srcFilename);
+ const dirname = path.dirname(dstFilename);
+ try {
+ await fsPromise.stat(dirname);
+ } catch {
+ await fsPromise.mkdir(dirname, { recursive: true });
+ }
+ console.log('copy', srcFilename, '->', dstFilename);
+ await fsPromise.copyFile(srcFilename, dstFilename);
+}
+
+chokidar.watch('.').on('all', (event, path) => {
+ switch (event) {
+ case 'add':
+ case 'change':
+ if (ignore(path)) {
+ return;
+ }
+ copyFile(path);
+ break;
+ }
+});
diff --git a/build/tsconfig-serve.json b/build/tsconfig-serve.json
new file mode 100644
index 0000000..76f2768
--- /dev/null
+++ b/build/tsconfig-serve.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "out/src"
+ }
+}
diff --git a/dist/0.x/controllers/Button.d.ts b/dist/0.x/controllers/Button.d.ts
new file mode 100644
index 0000000..50f0953
--- /dev/null
+++ b/dist/0.x/controllers/Button.d.ts
@@ -0,0 +1,6 @@
+export default class Button extends Controller {
+ constructor(object: any, property: any, options?: {});
+ setOptions(options: any): void;
+ #private;
+}
+import Controller from './Controller.js';
diff --git a/dist/0.x/controllers/Canvas.d.ts b/dist/0.x/controllers/Canvas.d.ts
new file mode 100644
index 0000000..bbdc33f
--- /dev/null
+++ b/dist/0.x/controllers/Canvas.d.ts
@@ -0,0 +1,6 @@
+export default class Canvas extends LabelController {
+ constructor();
+ get canvas(): HTMLElement;
+ #private;
+}
+import LabelController from './LabelController.js';
diff --git a/dist/0.x/controllers/Checkbox.d.ts b/dist/0.x/controllers/Checkbox.d.ts
new file mode 100644
index 0000000..6dd8ce1
--- /dev/null
+++ b/dist/0.x/controllers/Checkbox.d.ts
@@ -0,0 +1,4 @@
+export default class Checkbox extends ValueController {
+ constructor(object: any, property: any);
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/Color.d.ts b/dist/0.x/controllers/Color.d.ts
new file mode 100644
index 0000000..7406fa1
--- /dev/null
+++ b/dist/0.x/controllers/Color.d.ts
@@ -0,0 +1,6 @@
+export default class Color extends ValueController {
+ constructor(object: any, property: any, options?: {});
+ setOptions(options: any): this;
+ #private;
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/ColorChooser.d.ts b/dist/0.x/controllers/ColorChooser.d.ts
new file mode 100644
index 0000000..ebbfe71
--- /dev/null
+++ b/dist/0.x/controllers/ColorChooser.d.ts
@@ -0,0 +1,5 @@
+export default class ColorChooser extends PopDownController {
+ setOptions(options: any): this;
+ #private;
+}
+import PopDownController from './PopDownController.js';
diff --git a/dist/0.x/controllers/Container.d.ts b/dist/0.x/controllers/Container.d.ts
new file mode 100644
index 0000000..3dafbde
--- /dev/null
+++ b/dist/0.x/controllers/Container.d.ts
@@ -0,0 +1,13 @@
+export default class Container extends Controller {
+ get children(): any[];
+ get controllers(): any[];
+ get folders(): any[];
+ reset(recursive?: boolean): this;
+ updateDisplay(): this;
+ remove(controller: any): this;
+ addController(controller: any): any;
+ pushContainer(container: any): any;
+ popContainer(): this;
+ #private;
+}
+import Controller from './Controller.js';
diff --git a/dist/0.x/controllers/Controller.d.ts b/dist/0.x/controllers/Controller.d.ts
new file mode 100644
index 0000000..8f4b8c9
--- /dev/null
+++ b/dist/0.x/controllers/Controller.d.ts
@@ -0,0 +1,20 @@
+export default class Controller extends View {
+ constructor(className: any);
+ get parent(): any;
+ setParent(parent: any): void;
+ show(show?: boolean): this;
+ hide(): this;
+ disabled(): boolean;
+ enable(enable?: boolean): this;
+ disable(disable?: boolean): this;
+ onChange(fn: any): this;
+ removeChange(fn: any): this;
+ onFinishChange(fn: any): this;
+ removeFinishChange(fn: any): this;
+ emitChange(value: any, object: any, property: any): void;
+ emitFinalChange(value: any, object: any, property: any): void;
+ updateDisplay(): void;
+ getColors(): any;
+ #private;
+}
+import View from '../views/View.js';
diff --git a/dist/0.x/controllers/Direction.d.ts b/dist/0.x/controllers/Direction.d.ts
new file mode 100644
index 0000000..288814b
--- /dev/null
+++ b/dist/0.x/controllers/Direction.d.ts
@@ -0,0 +1,5 @@
+export default class Direction extends PopDownController {
+ constructor(object: any, property: any, options: any);
+ #private;
+}
+import PopDownController from './PopDownController.js';
diff --git a/dist/0.x/controllers/Divider.d.ts b/dist/0.x/controllers/Divider.d.ts
new file mode 100644
index 0000000..11fff60
--- /dev/null
+++ b/dist/0.x/controllers/Divider.d.ts
@@ -0,0 +1,4 @@
+export default class Divider extends Controller {
+ constructor();
+}
+import Controller from './Controller.js';
diff --git a/dist/0.x/controllers/Folder.d.ts b/dist/0.x/controllers/Folder.d.ts
new file mode 100644
index 0000000..54f372c
--- /dev/null
+++ b/dist/0.x/controllers/Folder.d.ts
@@ -0,0 +1,10 @@
+export default class Folder extends Container {
+ constructor(name?: string, className?: string);
+ open(open?: boolean): this;
+ close(): this;
+ name(name: any): this;
+ title(title: any): this;
+ toggleOpen(): this;
+ #private;
+}
+import Container from './Container.js';
diff --git a/dist/0.x/controllers/Label.d.ts b/dist/0.x/controllers/Label.d.ts
new file mode 100644
index 0000000..b717340
--- /dev/null
+++ b/dist/0.x/controllers/Label.d.ts
@@ -0,0 +1,4 @@
+export default class Label extends Controller {
+ text(text: any): this;
+}
+import Controller from './Controller.js';
diff --git a/dist/0.x/controllers/LabelController.d.ts b/dist/0.x/controllers/LabelController.d.ts
new file mode 100644
index 0000000..6ddcfa1
--- /dev/null
+++ b/dist/0.x/controllers/LabelController.d.ts
@@ -0,0 +1,8 @@
+export default class LabelController extends Controller {
+ constructor(className?: string, name?: string);
+ get id(): string;
+ name(name: any): this;
+ tooltip(tip: any): void;
+ #private;
+}
+import Controller from './Controller.js';
diff --git a/dist/0.x/controllers/PopDownController.d.ts b/dist/0.x/controllers/PopDownController.d.ts
new file mode 100644
index 0000000..97d01cf
--- /dev/null
+++ b/dist/0.x/controllers/PopDownController.d.ts
@@ -0,0 +1,10 @@
+export default class PopDownController extends ValueController {
+ constructor(object: any, property: any, options?: {});
+ setKnobColor(bgCssColor: any): void;
+ updateDisplay(): void;
+ setOptions(options: any): void;
+ addTop(view: any): any;
+ addBottom(view: any): any;
+ #private;
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/RadioGrid.d.ts b/dist/0.x/controllers/RadioGrid.d.ts
new file mode 100644
index 0000000..2c193fb
--- /dev/null
+++ b/dist/0.x/controllers/RadioGrid.d.ts
@@ -0,0 +1,4 @@
+export default class RadioGrid extends ValueController {
+ constructor(object: any, property: any, options: any);
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/Range.d.ts b/dist/0.x/controllers/Range.d.ts
new file mode 100644
index 0000000..a1fac1f
--- /dev/null
+++ b/dist/0.x/controllers/Range.d.ts
@@ -0,0 +1,4 @@
+export default class Range extends ValueController {
+ constructor(object: any, property: any, options: any);
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/Select.d.ts b/dist/0.x/controllers/Select.d.ts
new file mode 100644
index 0000000..1387f97
--- /dev/null
+++ b/dist/0.x/controllers/Select.d.ts
@@ -0,0 +1,4 @@
+export default class Select extends ValueController {
+ constructor(object: any, property: any, options: any);
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/Slider.d.ts b/dist/0.x/controllers/Slider.d.ts
new file mode 100644
index 0000000..0597f38
--- /dev/null
+++ b/dist/0.x/controllers/Slider.d.ts
@@ -0,0 +1,4 @@
+export default class Slider extends ValueController {
+ constructor(object: any, property: any, options?: {});
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/Text.d.ts b/dist/0.x/controllers/Text.d.ts
new file mode 100644
index 0000000..6955d07
--- /dev/null
+++ b/dist/0.x/controllers/Text.d.ts
@@ -0,0 +1,4 @@
+export default class Text extends ValueController {
+ constructor(object: any, property: any);
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/TextNumber.d.ts b/dist/0.x/controllers/TextNumber.d.ts
new file mode 100644
index 0000000..3b96e2e
--- /dev/null
+++ b/dist/0.x/controllers/TextNumber.d.ts
@@ -0,0 +1,5 @@
+export default class TextNumber extends ValueController {
+ constructor(object: any, property: any, options?: {});
+ #private;
+}
+import ValueController from './ValueController.js';
diff --git a/dist/0.x/controllers/ValueController.d.ts b/dist/0.x/controllers/ValueController.d.ts
new file mode 100644
index 0000000..c75abe5
--- /dev/null
+++ b/dist/0.x/controllers/ValueController.d.ts
@@ -0,0 +1,17 @@
+export default class ValueController extends LabelController {
+ constructor(object: any, property: any, className?: string);
+ get initialValue(): any;
+ get object(): any;
+ get property(): any;
+ add(view: any): any;
+ setValue(v: any): void;
+ setFinalValue(v: any): this;
+ updateDisplay(ignoreCache: any): this;
+ setOptions(options: any): this;
+ getValue(): any;
+ value(v: any): this;
+ reset(): this;
+ listen(listen?: boolean): this;
+ #private;
+}
+import LabelController from './LabelController.js';
diff --git a/dist/0.x/controllers/Vec2.d.ts b/dist/0.x/controllers/Vec2.d.ts
new file mode 100644
index 0000000..72df7b8
--- /dev/null
+++ b/dist/0.x/controllers/Vec2.d.ts
@@ -0,0 +1,4 @@
+export default class Vec2 extends PopDownController {
+ constructor(object: any, property: any);
+}
+import PopDownController from './PopDownController.js';
diff --git a/dist/0.x/controllers/create-controller.d.ts b/dist/0.x/controllers/create-controller.d.ts
new file mode 100644
index 0000000..ca37c40
--- /dev/null
+++ b/dist/0.x/controllers/create-controller.d.ts
@@ -0,0 +1,13 @@
+/**
+ * possible inputs
+ * add(o, p, min: number, max: number)
+ * add(o, p, min: number, max: number, step: number)
+ * add(o, p, array: [value])
+ * add(o, p, array: [[key, value]])
+ *
+ * @param {*} object
+ * @param {string} property
+ * @param {...any} args
+ * @returns {Controller}
+ */
+export function createController(object: any, property: string, ...args: any[]): Controller;
diff --git a/dist/0.x/esm.d.ts b/dist/0.x/esm.d.ts
new file mode 100644
index 0000000..0f10034
--- /dev/null
+++ b/dist/0.x/esm.d.ts
@@ -0,0 +1,10 @@
+import GUI from './muigui.js';
+export { default as ColorChooser } from './controllers/ColorChooser.js';
+export { default as Direction } from './controllers/Direction.js';
+export { default as RadioGrid } from './controllers/RadioGrid.js';
+export { default as Range } from './controllers/Range.js';
+export { default as Select } from './controllers/Select.js';
+export { default as Slider } from './controllers/Slider.js';
+export { default as TextNumber } from './controllers/TextNumber.js';
+export { default as Vec2 } from './controllers/Vec2.js';
+export default GUI;
diff --git a/dist/0.x/layout/Column.d.ts b/dist/0.x/layout/Column.d.ts
new file mode 100644
index 0000000..332e883
--- /dev/null
+++ b/dist/0.x/layout/Column.d.ts
@@ -0,0 +1,4 @@
+export default class Column extends Layout {
+ constructor();
+}
+import Layout from './Layout.js';
diff --git a/dist/0.x/layout/Frame.d.ts b/dist/0.x/layout/Frame.d.ts
new file mode 100644
index 0000000..e2c4f7c
--- /dev/null
+++ b/dist/0.x/layout/Frame.d.ts
@@ -0,0 +1,5 @@
+export default class Frame extends Layout {
+ static get foo(): string;
+ constructor();
+}
+import Layout from './Layout.js';
diff --git a/dist/0.x/layout/Grid.d.ts b/dist/0.x/layout/Grid.d.ts
new file mode 100644
index 0000000..a7d1d8c
--- /dev/null
+++ b/dist/0.x/layout/Grid.d.ts
@@ -0,0 +1,4 @@
+export default class Grid extends Layout {
+ constructor();
+}
+import Layout from './Layout.js';
diff --git a/dist/0.x/layout/Layout.d.ts b/dist/0.x/layout/Layout.d.ts
new file mode 100644
index 0000000..89655d9
--- /dev/null
+++ b/dist/0.x/layout/Layout.d.ts
@@ -0,0 +1,5 @@
+export default class Layout extends View {
+ static css: string;
+ constructor(tag: any, className: any);
+}
+import View from '../views/View.js';
diff --git a/dist/0.x/layout/Row.d.ts b/dist/0.x/layout/Row.d.ts
new file mode 100644
index 0000000..b608884
--- /dev/null
+++ b/dist/0.x/layout/Row.d.ts
@@ -0,0 +1,4 @@
+export default class Row extends Layout {
+ constructor();
+}
+import Layout from './Layout.js';
diff --git a/dist/0.x/libs/assert.d.ts b/dist/0.x/libs/assert.d.ts
new file mode 100644
index 0000000..84e0f59
--- /dev/null
+++ b/dist/0.x/libs/assert.d.ts
@@ -0,0 +1 @@
+export function assert(truthy: any, msg?: string): void;
diff --git a/dist/0.x/libs/color-utils.d.ts b/dist/0.x/libs/color-utils.d.ts
new file mode 100644
index 0000000..d145154
--- /dev/null
+++ b/dist/0.x/libs/color-utils.d.ts
@@ -0,0 +1,215 @@
+export function hslToRgbUint8([h, s, l]: [any, any, any]): number[];
+export function hslaToRgbaUint8([h, s, l, a]: [any, any, any, any]): number[];
+export function rgbFloatToHsl01([r, g, b]: [any, any, any]): number[];
+export function rgbaFloatToHsla01([r, g, b, a]: [any, any, any, any]): any[];
+export function hsv01ToRGBFloat([hue, sat, val]: [any, any, any]): number[];
+export function hsva01ToRGBAFloat([hue, sat, val, alpha]: [any, any, any, any]): any[];
+export function rgbFloatToHSV01([r, g, b]: [any, any, any]): number[];
+export function rgbaFloatToHSVA01([r, g, b, a]: [any, any, any, any]): any[];
+export function guessFormat(v: any): string;
+export function hexToUint8RGB(v: any): number[];
+export function uint8RGBToHex(v: any): string;
+export function hexToUint8RGBA(v: any): number[];
+export function uint8RGBAToHex(v: any): string;
+export function hexToFloatRGB(v: any): number[];
+export function floatRGBToHex(v: any): string;
+export function hexToFloatRGBA(v: any): number[];
+export function floatRGBAToHex(v: any): string;
+export function rgbUint8ToHsl(rgb: any): number[];
+export function rgbaUint8ToHsla(rgba: any): any[];
+export function hasAlpha(format: any): any;
+export const colorFormatConverters: {
+ hex6: {
+ color: {
+ from: (v: any) => any[];
+ to: typeof fixHex6;
+ };
+ text: {
+ from: (v: any) => any[];
+ to: (v: any) => any;
+ };
+ };
+ hex8: {
+ color: {
+ from: (v: any) => any[];
+ to: typeof fixHex8;
+ };
+ text: {
+ from: (v: any) => any[];
+ to: (v: any) => any;
+ };
+ };
+ hex3: {
+ color: {
+ from: (v: any) => any[];
+ to: typeof hex3ToHex6;
+ };
+ text: {
+ from: (v: any) => any[];
+ to: (v: any) => any;
+ };
+ };
+ 'hex6-no-hash': {
+ color: {
+ from: (v: any) => any[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (v: any) => any[];
+ to: (v: any) => any;
+ };
+ };
+ 'hex8-no-hash': {
+ color: {
+ from: (v: any) => any[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (v: any) => any[];
+ to: (v: any) => any;
+ };
+ };
+ 'hex3-no-hash': {
+ color: {
+ from: (v: any) => any[];
+ to: typeof hex3ToHex6;
+ };
+ text: {
+ from: (v: any) => any[];
+ to: (v: any) => any;
+ };
+ };
+ 'uint32-rgb': {
+ color: {
+ from: (v: any) => (number | boolean)[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (v: any) => (number | boolean)[];
+ to: (v: any) => string;
+ };
+ };
+ 'uint32-rgba': {
+ color: {
+ from: (v: any) => (number | boolean)[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (v: any) => (number | boolean)[];
+ to: (v: any) => string;
+ };
+ };
+ 'uint8-rgb': {
+ color: {
+ from: (v: any) => (boolean | number[])[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => (boolean | number[])[];
+ to: (v: any) => any;
+ };
+ };
+ 'uint8-rgba': {
+ color: {
+ from: (v: any) => (boolean | number[])[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => (boolean | number[])[];
+ to: (v: any) => any;
+ };
+ };
+ 'float-rgb': {
+ color: {
+ from: (v: any) => (boolean | number[])[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => any[];
+ to: (v: any) => string;
+ };
+ };
+ 'float-rgba': {
+ color: {
+ from: (v: any) => (boolean | number[])[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => any[];
+ to: (v: any) => string;
+ };
+ };
+ 'object-rgb': {
+ color: {
+ from: (v: any) => (boolean | {
+ r: number;
+ g: number;
+ b: number;
+ })[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => any[];
+ to: (rgb: any) => string;
+ };
+ };
+ 'object-rgba': {
+ color: {
+ from: (v: any) => (boolean | {
+ r: number;
+ g: number;
+ b: number;
+ a: number;
+ })[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => any[];
+ to: (rgba: any) => string;
+ };
+ };
+ 'css-rgb': {
+ color: {
+ from: (v: any) => (string | boolean)[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => (string | boolean)[];
+ to: (v: any) => string | boolean;
+ };
+ };
+ 'css-rgba': {
+ color: {
+ from: (v: any) => (string | boolean)[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => (string | boolean)[];
+ to: (v: any) => string | boolean;
+ };
+ };
+ 'css-hsl': {
+ color: {
+ from: (v: any) => (string | boolean)[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => (string | boolean)[];
+ to: (v: any) => string | boolean;
+ };
+ };
+ 'css-hsla': {
+ color: {
+ from: (v: any) => (string | boolean)[];
+ to: (v: any) => string;
+ };
+ text: {
+ from: (s: any) => (string | boolean)[];
+ to: (v: any) => string | boolean;
+ };
+ };
+};
+declare function fixHex6(v: any): any;
+declare function fixHex8(v: any): any;
+declare function hex3ToHex6(hex3: any): any;
+export {};
diff --git a/dist/0.x/libs/conversions.d.ts b/dist/0.x/libs/conversions.d.ts
new file mode 100644
index 0000000..25f18df
--- /dev/null
+++ b/dist/0.x/libs/conversions.d.ts
@@ -0,0 +1,16 @@
+export namespace identity {
+ function to(v: any): any;
+ function from(v: any): any[];
+}
+export namespace strToNumber {
+ export function to_1(v: any): any;
+ export { to_1 as to };
+ export function from_1(v: any): (number | boolean)[];
+ export { from_1 as from };
+}
+export namespace converters {
+ let radToDeg: {
+ to: (v: any) => any;
+ from: (v: any) => any[];
+ };
+}
diff --git a/dist/0.x/libs/elem.d.ts b/dist/0.x/libs/elem.d.ts
new file mode 100644
index 0000000..720af8a
--- /dev/null
+++ b/dist/0.x/libs/elem.d.ts
@@ -0,0 +1,4 @@
+export function setElemProps(elem: any, attrs: any, children: any): any;
+export function createElem(tag: any, attrs?: {}, children?: any[]): any;
+export function addElem(tag: any, parent: any, attrs?: {}, children?: any[]): any;
+export function getNewId(): string;
diff --git a/dist/0.x/libs/ids.d.ts b/dist/0.x/libs/ids.d.ts
new file mode 100644
index 0000000..196073a
--- /dev/null
+++ b/dist/0.x/libs/ids.d.ts
@@ -0,0 +1 @@
+export function makeId(): string;
diff --git a/dist/0.x/libs/key-values.d.ts b/dist/0.x/libs/key-values.d.ts
new file mode 100644
index 0000000..f151c67
--- /dev/null
+++ b/dist/0.x/libs/key-values.d.ts
@@ -0,0 +1 @@
+export function convertToKeyValues(keyValues: any, valueIsNumber: any): any[];
diff --git a/dist/0.x/libs/keyboard.d.ts b/dist/0.x/libs/keyboard.d.ts
new file mode 100644
index 0000000..8a1a626
--- /dev/null
+++ b/dist/0.x/libs/keyboard.d.ts
@@ -0,0 +1,6 @@
+export function addKeyboardEvents(elem: any, { onDown, onUp }: {
+ onDown?: typeof noop | undefined;
+ onUp?: typeof noop | undefined;
+}): () => void;
+declare function noop(): void;
+export {};
diff --git a/dist/0.x/libs/resize-helpers.d.ts b/dist/0.x/libs/resize-helpers.d.ts
new file mode 100644
index 0000000..d63d278
--- /dev/null
+++ b/dist/0.x/libs/resize-helpers.d.ts
@@ -0,0 +1,3 @@
+export function onResize(elem: any, callback: any): void;
+export function onResizeSVGNoScale(elem: any, hAnchor: any, vAnchor: any, callback: any): void;
+export function onResizeCanvas(elem: any, callback: any): void;
diff --git a/dist/0.x/libs/svg.d.ts b/dist/0.x/libs/svg.d.ts
new file mode 100644
index 0000000..84873ee
--- /dev/null
+++ b/dist/0.x/libs/svg.d.ts
@@ -0,0 +1 @@
+export function arc(cx: any, cy: any, r: any, start: any, end: any): string;
diff --git a/dist/0.x/libs/taskrunner.d.ts b/dist/0.x/libs/taskrunner.d.ts
new file mode 100644
index 0000000..2f6058a
--- /dev/null
+++ b/dist/0.x/libs/taskrunner.d.ts
@@ -0,0 +1,2 @@
+export function addTask(fn: any): void;
+export function removeTask(fn: any): void;
diff --git a/dist/0.x/libs/touch.d.ts b/dist/0.x/libs/touch.d.ts
new file mode 100644
index 0000000..267eb9f
--- /dev/null
+++ b/dist/0.x/libs/touch.d.ts
@@ -0,0 +1,17 @@
+export function computeRelativePosition(elem: any, event: any, start: any): {
+ x: number;
+ y: number;
+ nx: number;
+ ny: number;
+ dx: number;
+ dy: number;
+ ndx: number;
+ ndy: number;
+};
+export function addTouchEvents(elem: any, { onDown, onMove, onUp }: {
+ onDown?: typeof noop | undefined;
+ onMove?: typeof noop | undefined;
+ onUp?: typeof noop | undefined;
+}): () => void;
+declare function noop(): void;
+export {};
diff --git a/dist/0.x/libs/utils.d.ts b/dist/0.x/libs/utils.d.ts
new file mode 100644
index 0000000..422cfad
--- /dev/null
+++ b/dist/0.x/libs/utils.d.ts
@@ -0,0 +1,27 @@
+export function removeArrayElem(array: any, value: any): any;
+export function idToLabel(id: any): any;
+export function clamp(v: any, min: any, max: any): number;
+export function copyExistingProperties(dst: any, src: any): any;
+export function makeMinMaxPair(gui: any, properties: any, minPropName: any, maxPropName: any, options: any): any[];
+export function isTypedArray(a: any): any;
+export function isArrayOrTypedArray(v: any): any;
+export function stepify(v: any, from: any, step: any): number;
+export function euclideanModulo(v: any, n: any): number;
+export function lerp(a: any, b: any, t: any): any;
+export function mapRange(v: any, inMin: any, inMax: any, outMin: any, outMax: any): any;
+export function makeRangeConverters({ from, to }: {
+ from: any;
+ to: any;
+}): {
+ to: (v: any) => any;
+ from: (v: any) => any[];
+};
+export function makeRangeOptions({ from, to, step }: {
+ from: any;
+ to: any;
+ step: any;
+}): any;
+export namespace identity {
+ function to(v: any): any;
+ function from(v: any): any[];
+}
diff --git a/dist/0.x/libs/wheel.d.ts b/dist/0.x/libs/wheel.d.ts
new file mode 100644
index 0000000..61823b9
--- /dev/null
+++ b/dist/0.x/libs/wheel.d.ts
@@ -0,0 +1 @@
+export function createWheelHelper(): (e: any, step: any, wheelScale?: number) => number;
diff --git a/dist/0.x/muigui.d.ts b/dist/0.x/muigui.d.ts
new file mode 100644
index 0000000..985e780
--- /dev/null
+++ b/dist/0.x/muigui.d.ts
@@ -0,0 +1,46 @@
+export class GUIFolder extends Folder {
+ add(object: any, property: any, ...args: any[]): any;
+ addCanvas(name: any): any;
+ addColor(object: any, property: any, options?: {}): any;
+ addDivider(): any;
+ addFolder(name: any): any;
+ addLabel(text: any): any;
+}
+export class GUI extends GUIFolder {
+ static converters: {
+ radToDeg: {
+ to: (v: any) => any;
+ from: (v: any) => any[];
+ };
+ };
+ static mapRange: (v: any, inMin: any, inMax: any, outMin: any, outMax: any) => any;
+ static makeRangeConverters: ({ from, to }: {
+ from: any;
+ to: any;
+ }) => {
+ to: (v: any) => any;
+ from: (v: any) => any[];
+ };
+ static makeRangeOptions: ({ from, to, step }: {
+ from: any;
+ to: any;
+ step: any;
+ }) => any;
+ static makeMinMaxPair: typeof makeMinMaxPair;
+ static setBaseStyles(css: any): void;
+ static getBaseStyleSheet(): CSSStyleSheet;
+ static setUserStyles(css: any): void;
+ static getUserStyleSheet(): CSSStyleSheet;
+ static setTheme(name: any): void;
+ constructor(options?: {});
+ setStyle(css: any): void;
+ #private;
+}
+export default GUI;
+import Column from './layout/Column.js';
+import Frame from './layout/Frame.js';
+import Grid from './layout/Grid.js';
+import Row from './layout/Row.js';
+import Folder from './controllers/Folder.js';
+import { makeMinMaxPair } from './libs/utils.js';
+export { Column, Frame, Grid, Row };
diff --git a/dist/0.x/muigui.js b/dist/0.x/muigui.js
new file mode 100644
index 0000000..ce955f2
--- /dev/null
+++ b/dist/0.x/muigui.js
@@ -0,0 +1,3835 @@
+/* muigui@0.0.12, license MIT */
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.GUI = factory());
+})(this, (function () { 'use strict';
+
+ var css = {
+ default: `
+.muigui {
+ --bg-color: #ddd;
+ --color: #222;
+ --contrast-color: #eee;
+ --value-color: #145 ;
+ --value-bg-color: #eeee;
+ --disabled-color: #999;
+ --menu-bg-color: #f8f8f8;
+ --menu-sep-color: #bbb;
+ --hover-bg-color: #999;
+ --focus-color: #68C;
+ --range-color: #888888;
+ --invalid-color: #FF0000;
+ --selected-color: rgb(255, 255, 255, 0.9);
+
+ --button-bg-color: var(--value-bg-color);
+
+ --range-left-color: var(--value-color);
+ --range-right-color: var(--value-bg-color);
+ --range-right-hover-color: var(--hover-bg-color);
+
+ color: var(--color);
+ background-color: var(--bg-color);
+}
+
+@media (prefers-color-scheme: dark) {
+ .muigui {
+ --bg-color: #222222;
+ --color: #dddddd;
+ --contrast-color: #000;
+ --value-color: #43e5f7;
+ --value-bg-color: #444444;
+ --disabled-color: #666666;
+ --menu-bg-color: #080808;
+ --menu-sep-color: #444444;
+ --hover-bg-color: #666666;
+ --focus-color: #88AAFF;
+ --range-color: #888888;
+ --invalid-color: #FF6666;
+ --selected-color: rgba(255, 255, 255, 0.3);
+
+ --button-bg-color: var(--value-bg-color);
+
+ --range-left-color: var(--value-color);
+ --range-right-color: var(--value-bg-color);
+ --range-right-hover-color: var(--hover-bg-color);
+
+ color: var(--color);
+ background-color: var(--bg-color);
+ }
+}
+
+.muigui {
+ --width: 250px;
+ --label-width: 45%;
+ --number-width: 40%;
+
+
+ --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
+ --font-size: 11px;
+ --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
+ --font-size-mono: 11px;
+
+ --line-height: 1.7em;
+ --border-radius: 0px;
+
+ width: var(--width);
+ font-family: var(--font-family);
+ font-size: var(--font-size);
+ box-sizing: border-box;
+ line-height: 100%;
+}
+.muigui * {
+ box-sizing: inherit;
+}
+
+.muigui-no-scroll {
+ touch-action: none;
+}
+.muigui-no-h-scroll {
+ touch-action: pan-y;
+}
+.muigui-no-v-scroll {
+ touch-action: pan-x;
+}
+
+.muigui-invalid-value {
+ background-color: red !important;
+ color: white !important;
+}
+
+.muigui-grid {
+ display: grid;
+}
+.muigui-rows {
+ display: flex;
+ flex-direction: column;
+
+ min-height: 20px;
+ border: 2px solid red;
+}
+.muigui-columns {
+ display: flex;
+ flex-direction: row;
+
+ height: 20px;
+ border: 2px solid green;
+}
+.muigui-rows>*,
+.muigui-columns>* {
+ flex: 1 1 auto;
+ align-items: stretch;
+ min-height: 0;
+ min-width: 0;
+}
+
+.muigui-row {
+ border: 2px solid yellow;
+ min-height: 10px
+}
+.muigui-column {
+ border: 2px solid lightgreen;
+}
+
+/* -------- */
+
+.muigui-show { /* */ }
+.muigui-hide {
+ display: none !important;
+}
+.muigui-disabled {
+ pointer-events: none;
+ --color: var(--disabled-color) !important;
+ --value-color: var(--disabled-color) !important;
+ --range-left-color: var(--disabled-color) !important;
+}
+
+.muigui canvas,
+.muigui svg {
+ display: block;
+ border-radius: var(--border-radius);
+}
+.muigui canvas {
+ background-color: var(--value-bg-color);
+}
+
+.muigui-controller {
+ min-width: 0;
+ min-height: var(--line-height);
+}
+.muigui-root,
+.muigui-menu {
+ display: flex;
+ flex-direction: column;
+ position: relative;
+ user-select: none;
+ height: fit-content;
+ margin: 0;
+ padding-bottom: 0.1em;
+ border-radius: var(--border-radius);
+}
+.muigui-menu {
+ border-bottom: 1px solid var(--menu-sep-color);
+}
+
+.muigui-root>button:nth-child(1),
+.muigui-menu>button:nth-child(1) {
+ border-top: 1px solid var(--menu-sep-color);
+ border-bottom: 1px solid var(--menu-sep-color);
+ position: relative;
+ text-align: left;
+ color: var(--color);
+ background-color: var(--menu-bg-color);
+ min-height: var(--line-height);
+ padding-top: 0.2em;
+ padding-bottom: 0.2em;
+ cursor: pointer;
+ border-radius: var(--border-radius);
+}
+.muigui-root>div:nth-child(2),
+.muigui-menu>div:nth-child(2) {
+ flex: 1 1 auto;
+}
+
+.muigui-controller {
+ margin-left: 0.2em;
+ margin-right: 0.2em;
+}
+.muigui-root.muigui-controller,
+.muigui-menu.muigui-controller {
+ margin-left: 0;
+ margin-right: 0;
+}
+.muigui-controller>*:nth-child(1) {
+ flex: 1 0 var(--label-width);
+ min-width: 0;
+ white-space: pre;
+}
+.muigui-controller>label:nth-child(1) {
+ place-content: center start;
+ display: inline-grid;
+ overflow: hidden;
+}
+.muigui-controller>*:nth-child(2) {
+ flex: 1 1 75%;
+ min-width: 0;
+}
+
+/* -----------------------------------------
+ a label controller is [[label][value]]
+*/
+
+.muigui-label-controller {
+ display: flex;
+ margin: 0.4em 0 0.4em 0;
+ word-wrap: initial;
+ align-items: stretch;
+}
+
+.muigui-value {
+ display: flex;
+ align-items: stretch;
+}
+.muigui-value>* {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+.muigui-value>*:nth-child(1) {
+ flex: 1 1 calc(100% - var(--number-width));
+}
+.muigui-value>*:nth-child(2) {
+ flex: 1 1 var(--number-width);
+ margin-left: 0.2em;
+}
+
+/* fix! */
+.muigui-open>button>label::before,
+.muigui-closed>button>label::before {
+ width: 1.25em;
+ height: var(--line-height);
+ display: inline-grid;
+ place-content: center start;
+ pointer-events: none;
+}
+.muigui-open>button>label::before {
+ content: "ⓧ"; /*"▼";*/
+}
+.muigui-closed>button>label::before {
+ content: "⨁"; /*"▶";*/
+}
+.muigui-open>*:nth-child(2) {
+ transition: max-height 0.2s ease-out,
+ opacity 0.5s ease-out;
+ max-height: 100vh;
+ overflow: auto;
+ opacity: 1;
+}
+
+.muigui-closed>*:nth-child(2) {
+ transition: max-height 0.2s ease-out,
+ opacity 1s;
+ max-height: 0;
+ opacity: 0;
+ overflow: hidden;
+}
+
+/* ---- popdown ---- */
+
+.muigui-pop-down-top {
+ display: flex;
+}
+/* fix? */
+.muigui-value>*:nth-child(1).muigui-pop-down-top {
+ flex: 0;
+}
+.muigui-pop-down-bottom {
+
+}
+
+.muigui-pop-down-values {
+ min-width: 0;
+ display: flex;
+}
+.muigui-pop-down-values>* {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+
+.muigui-value.muigui-pop-down-controller {
+ flex-direction: column;
+}
+
+.muigui-pop-down-top input[type=checkbox] {
+ -webkit-appearance: none;
+ appearance: none;
+ width: auto;
+ color: var(--value-color);
+ background-color: var(--value-bg-color);
+ cursor: pointer;
+
+ display: grid;
+ place-content: center;
+ margin: 0;
+ font: inherit;
+ color: currentColor;
+ width: 1.7em;
+ height: 1.7em;
+ transform: translateY(-0.075em);
+}
+
+.muigui-pop-down-top input[type=checkbox]::before {
+ content: "+";
+ display: grid;
+ place-content: center;
+ border-radius: calc(var(--border-radius) + 2px);
+ border-left: 1px solid rgba(255,255,255,0.3);
+ border-top: 1px solid rgba(255,255,255,0.3);
+ border-bottom: 1px solid rgba(0,0,0,0.2);
+ border-right: 1px solid rgba(0,0,0,0.2);
+ background-color: var(--range-color);
+ color: var(--value-bg-color);
+ width: calc(var(--line-height) - 4px);
+ height: calc(var(--line-height) - 4px);
+}
+
+.muigui-pop-down-top input[type=checkbox]:checked::before {
+ content: "X";
+}
+
+
+/* ---- select ---- */
+
+.muigui select,
+.muigui option,
+.muigui input,
+.muigui button {
+ color: var(--value-color);
+ background-color: var(--value-bg-color);
+ font-family: var(--font-family);
+ font-size: var(--font-size);
+ border: none;
+ margin: 0;
+ border-radius: var(--border-radius);
+}
+.muigui select {
+ appearance: none;
+ margin: 0;
+ margin-left: 0; /*?*/
+ overflow: hidden; /* Safari */
+}
+
+.muigui select:focus,
+.muigui input:focus,
+.muigui button:focus {
+ outline: 1px solid var(--focus-color);
+}
+
+.muigui select:hover,
+.muigui option:hover,
+.muigui input:hover,
+.muigui button:hover {
+ background-color: var(--hover-bg-color);
+}
+
+/* ------ [ label ] ------ */
+
+.muigui-label {
+ border-top: 1px solid var(--menu-sep-color);
+ border-bottom: 1px solid var(--menu-sep-color);
+ padding-top: 0.4em;
+ padding-bottom: 0.3em;
+ place-content: center start;
+ background-color: var(--menu-bg-color);
+ white-space: pre;
+ border-radius: var(--border-radius);
+}
+
+/* ------ [ divider] ------ */
+
+.muigui-divider {
+ min-height: 6px;
+ border-top: 2px solid var(--menu-sep-color);
+ margin-top: 6px;
+}
+
+/* ------ [ button ] ------ */
+
+.muigui-button {
+ display: grid;
+
+}
+.muigui-button button {
+ border: none;
+ color: var(--value-color);
+ background-color: var(--button-bg-color);
+ cursor: pointer;
+ place-content: center center;
+}
+
+/* ------ [ color ] ------ */
+
+.muigui-color>div {
+ overflow: hidden;
+ position: relative;
+ margin-left: 0;
+ margin-right: 0; /* why? */
+ max-width: var(--line-height);
+ border-radius: var(--border-radius);
+}
+
+.muigui-color>div:focus-within {
+ outline: 1px solid var(--focus-color);
+}
+
+.muigui-color input[type=color] {
+ border: none;
+ padding: 0;
+ background: inherit;
+ cursor: pointer;
+ position: absolute;
+ width: 200%;
+ left: -10px;
+ top: -10px;
+ height: 200%;
+}
+.muigui-disabled canvas,
+.muigui-disabled svg,
+.muigui-disabled img,
+.muigui-disabled .muigui-color input[type=color] {
+ opacity: 0.2;
+}
+
+/* ------ [ checkbox ] ------ */
+
+.muigui-checkbox>label:nth-child(2) {
+ display: grid;
+ place-content: center start;
+ margin: 0;
+}
+
+.muigui-checkbox input[type=checkbox] {
+ -webkit-appearance: none;
+ appearance: none;
+ width: auto;
+ color: var(--value-color);
+ background-color: var(--value-bg-color);
+ cursor: pointer;
+
+ display: grid;
+ place-content: center;
+ margin: 0;
+ font: inherit;
+ color: currentColor;
+ width: 1.7em;
+ height: 1.7em;
+ transform: translateY(-0.075em);
+}
+
+.muigui-checkbox input[type=checkbox]::before {
+ content: "";
+ color: var(--value-color);
+ display: grid;
+ place-content: center;
+}
+
+.muigui-checkbox input[type=checkbox]:checked::before {
+ content: "✔";
+}
+
+.muigui input[type=number]::-webkit-inner-spin-button,
+.muigui input[type=number]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ appearance: none;
+ margin: 0;
+}
+.muigui input[type=number] {
+ -moz-appearance: textfield;
+}
+
+/* ------ [ radio grid ] ------ */
+
+.muigui-radio-grid>div {
+ display: grid;
+ gap: 2px;
+}
+
+.muigui-radio-grid input {
+ appearance: none;
+ display: none;
+}
+
+.muigui-radio-grid button {
+ color: var(--color);
+ width: 100%;
+ text-align: left;
+}
+
+.muigui-radio-grid input:checked + button {
+ color: var(--value-color);
+ background-color: var(--selected-color);
+}
+
+/* ------ [ color-chooser ] ------ */
+
+.muigui-color-chooser-cursor {
+ stroke-width: 1px;
+ stroke: white;
+ fill: none;
+}
+.muigui-color-chooser-circle {
+ stroke-width: 1px;
+ stroke: white;
+ fill: none;
+}
+
+
+/* ------ [ vec2 ] ------ */
+
+.muigui-vec2 svg {
+ background-color: var(--value-bg-color);
+}
+
+.muigui-vec2-axis {
+ stroke: 1px;
+ stroke: var(--focus-color);
+}
+
+.muigui-vec2-line {
+ stroke-width: 1px;
+ stroke: var(--value-color);
+ fill: var(--value-color);
+}
+
+/* ------ [ direction ] ------ */
+
+.muigui-direction svg {
+ background-color: rgba(0,0,0,0.2);
+}
+
+.muigui-direction:focus-within svg {
+ outline: none;
+}
+.muigui-direction-range {
+ fill: var(--value-bg-color);
+}
+.muigui-direction svg:focus {
+ outline: none;
+}
+.muigui-direction svg:focus .muigui-direction-range {
+ stroke-width: 0.5px;
+ stroke: var(--focus-color);
+}
+
+.muigui-direction-arrow {
+ fill: var(--value-color);
+}
+
+/* ------ [ slider ] ------ */
+
+.muigui-slider>div {
+ display: flex;
+ align-items: stretch;
+ height: var(--line-height);
+}
+.muigui-slider svg {
+ flex: 1 1 auto;
+}
+.muigui-slider .muigui-slider-up #muigui-orientation {
+ transform: scale(1, -1) translateY(-100%);
+}
+
+.muigui-slider .muigui-slider-up #muigui-number-orientation {
+ transform: scale(1,-1);
+}
+
+.muigui-ticks {
+ stroke: var(--range-color);
+}
+.muigui-thicks {
+ stroke: var(--color);
+ stroke-width: 2px;
+}
+.muigui-svg-text {
+ fill: var(--color);
+ font-size: 7px;
+}
+.muigui-mark {
+ fill: var(--value-color);
+}
+
+/* ------ [ range ] ------ */
+
+
+.muigui-range input[type=range] {
+ -webkit-appearance: none;
+ appearance: none;
+ background-color: transparent;
+}
+
+.muigui-range input[type=range]::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ appearance: none;
+ border-radius: calc(var(--border-radius) + 2px);
+ border-left: 1px solid rgba(255,255,255,0.3);
+ border-top: 1px solid rgba(255,255,255,0.3);
+ border-bottom: 1px solid rgba(0,0,0,0.2);
+ border-right: 1px solid rgba(0,0,0,0.2);
+ background-color: var(--range-color);
+ margin-top: calc((var(--line-height) - 2px) / -2);
+ width: calc(var(--line-height) - 2px);
+ height: calc(var(--line-height) - 2px);
+}
+
+.muigui-range input[type=range]::-webkit-slider-runnable-track {
+ -webkit-appearance: none;
+ appearance: none;
+ border: 1px solid var(--menu-sep-color);
+ height: 2px;
+}
+
+
+/* dat.gui style - doesn't work on Safari iOS */
+
+/*
+.muigui-range input[type=range] {
+ cursor: ew-resize;
+ overflow: hidden;
+}
+
+.muigui-range input[type=range] {
+ -webkit-appearance: none;
+ appearance: none;
+ background-color: var(--range-right-color);
+ margin: 0;
+}
+.muigui-range input[type=range]:hover {
+ background-color: var(--range-right-hover-color);
+}
+
+.muigui-range input[type=range]::-webkit-slider-runnable-track {
+ -webkit-appearance: none;
+ appearance: none;
+ height: max-content;
+ color: var(--range-left-color);
+ margin-top: -1px;
+}
+
+.muigui-range input[type=range]::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ appearance: none;
+ width: 0px;
+ height: max-content;
+ box-shadow: -1000px 0 0 1000px var(--range-left-color);
+}
+*/
+
+/* FF */
+/*
+.muigui-range input[type=range]::-moz-slider-progress {
+ background-color: var(--range-left-color);
+}
+.muigui-range input[type=range]::-moz-slider-thumb {
+ height: max-content;
+ width: 0;
+ border: none;
+ box-shadow: -1000px 0 0 1000px var(--range-left-color);
+ box-sizing: border-box;
+}
+*/
+
+.muigui-checkered-background {
+ background-color: #404040;
+ background-image:
+ linear-gradient(45deg, #808080 25%, transparent 25%),
+ linear-gradient(-45deg, #808080 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, #808080 75%),
+ linear-gradient(-45deg, transparent 75%, #808080 75%);
+ background-size: 16px 16px;
+ background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
+}
+
+/* ---------------------------------------------------------- */
+
+/* needs to be at bottom to take precedence */
+.muigui-auto-place {
+ max-height: 100%;
+ position: fixed;
+ top: 0;
+ right: 15px;
+ z-index: 100001;
+}
+
+`,
+ themes: {
+ default: '',
+ float: `
+ :root {
+ color-scheme: light dark,
+ }
+
+ .muigui {
+ --width: 400px;
+ --bg-color: initial;
+ --label-width: 25%;
+ --number-width: 20%;
+ }
+
+ input,
+ .muigui-label-controller>label {
+ text-shadow:
+ -1px -1px 0 var(--contrast-color),
+ 1px -1px 0 var(--contrast-color),
+ -1px 1px 0 var(--contrast-color),
+ 1px 1px 0 var(--contrast-color);
+ }
+
+ .muigui-controller > label:nth-child(1) {
+ place-content: center end;
+ margin-right: 1em;
+ }
+
+ .muigui-value > :nth-child(2) {
+ margin-left: 1em;
+ }
+
+ .muigui-root>*:nth-child(1) {
+ display: none;
+ }
+
+ .muigui-range input[type=range]::-webkit-slider-thumb {
+ border-radius: 1em;
+ }
+
+ .muigui-range input[type=range]::-webkit-slider-runnable-track {
+ -webkit-appearance: initial;
+ appearance: none;
+ border: 1px solid rgba(0, 0, 0, 0.25);
+ height: 2px;
+ }
+
+ .muigui-colors {
+ --value-color: var(--color );
+ --value-bg-color: rgba(0, 0, 0, 0.1);
+ --disabled-color: #cccccc;
+ --menu-bg-color: rgba(0, 0, 0, 0.1);
+ --menu-sep-color: #bbbbbb;
+ --hover-bg-color: rgba(0, 0, 0, 0);
+ --invalid-color: #FF0000;
+ --selected-color: rgba(0, 0, 0, 0.3);
+ --range-color: rgba(0, 0, 0, 0.125);
+ }
+`,
+ },
+ };
+
+ function setElemProps(elem, attrs, children) {
+ for (const [key, value] of Object.entries(attrs)) {
+ if (typeof value === 'function' && key.startsWith('on')) {
+ const eventName = key.substring(2).toLowerCase();
+ elem.addEventListener(eventName, value, {passive: false});
+ } else if (typeof value === 'object') {
+ for (const [k, v] of Object.entries(value)) {
+ elem[key][k] = v;
+ }
+ } else if (elem[key] === undefined) {
+ elem.setAttribute(key, value);
+ } else {
+ elem[key] = value;
+ }
+ }
+ for (const child of children) {
+ elem.appendChild(child);
+ }
+ return elem;
+ }
+
+ function createElem(tag, attrs = {}, children = []) {
+ const elem = document.createElement(tag);
+ setElemProps(elem, attrs, children);
+ return elem;
+ }
+
+ function addElem(tag, parent, attrs = {}, children = []) {
+ const elem = createElem(tag, attrs, children);
+ parent.appendChild(elem);
+ return elem;
+ }
+
+ let nextId = 0;
+ function getNewId() {
+ return `muigui-id-${nextId++}`;
+ }
+
+ function removeArrayElem(array, value) {
+ const ndx = array.indexOf(value);
+ if (ndx) {
+ array.splice(ndx, 1);
+ }
+ return array;
+ }
+
+ /**
+ * Converts an camelCase or snake_case id to "camel case" or "snake case"
+ * @param {string} id
+ */
+ const underscoreRE = /_/g;
+ const upperLowerRE = /([A-Z])([a-z])/g;
+ function idToLabel(id) {
+ return id.replace(underscoreRE, ' ')
+ .replace(upperLowerRE, (m, m1, m2) => `${m1.toLowerCase()} ${m2}`);
+ }
+
+ function clamp$1(v, min, max) {
+ return Math.max(min, Math.min(max, v));
+ }
+
+ const isTypedArray = typeof SharedArrayBuffer !== 'undefined'
+ ? function isArrayBufferOrSharedArrayBuffer(a) {
+ return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);
+ }
+ : function isArrayBuffer(a) {
+ return a && a.buffer && a.buffer instanceof ArrayBuffer;
+ };
+
+ const isArrayOrTypedArray = v => Array.isArray(v) || isTypedArray(v);
+
+ // Yea, I know this should be `Math.round(v / step) * step
+ // but try step = 0.1, newV = 19.95
+ //
+ // I get
+ // Math.round(19.95 / 0.1) * 0.1
+ // 19.900000000000002
+ // vs
+ // Math.round(19.95 / 0.1) / (1 / 0.1)
+ // 19.9
+ //
+ const stepify = (v, from, step) => Math.round(from(v) / step) / (1 / step);
+
+ const euclideanModulo$1 = (v, n) => ((v % n) + n) % n;
+ const lerp$1 = (a, b, t) => a + (b - a) * t;
+ function copyExistingProperties(dst, src) {
+ for (const key in src) {
+ if (key in dst) {
+ dst[key] = src[key];
+ }
+ }
+ return dst;
+ }
+
+ const mapRange = (v, inMin, inMax, outMin, outMax) => (v - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
+
+ const makeRangeConverters = ({from, to}) => {
+ return {
+ to: v => mapRange(v, ...from, ...to),
+ from: v => [true, mapRange(v, ...to, ...from)],
+ };
+ };
+
+ const makeRangeOptions = ({from, to, step}) => {
+ return {
+ min: to[0],
+ max: to[1],
+ ...(step && {step}),
+ converters: makeRangeConverters({from, to}),
+ };
+ };
+
+ // TODO: remove an use one in conversions. Move makeRangeConverters there?
+ const identity$1 = {
+ to: v => v,
+ from: v => [true, v],
+ };
+ function makeMinMaxPair(gui, properties, minPropName, maxPropName, options) {
+ const { converters: { from } = identity$1 } = options;
+ const { min, max } = options;
+ const guiMinRange = options.minRange || 0;
+ const valueMinRange = from(guiMinRange)[1];
+ const minGui = gui
+ .add(properties, minPropName, {
+ ...options,
+ min,
+ max: max - guiMinRange,
+ })
+ .onChange(v => {
+ maxGui.setValue(Math.min(max, Math.max(v + valueMinRange, properties[maxPropName])));
+ });
+ const maxGui = gui
+ .add(properties, maxPropName, {
+ ...options,
+ min: min + guiMinRange,
+ max,
+ })
+ .onChange(v => {
+ minGui.setValue(Math.max(min, Math.min(v - valueMinRange, properties[minPropName])));
+ });
+ return [ minGui, maxGui ];
+ }
+
+ class View {
+ domElement;
+ #childDestElem;
+ #views = [];
+ constructor(elem) {
+ this.domElement = elem;
+ this.#childDestElem = elem;
+ }
+ addElem(elem) {
+ this.#childDestElem.appendChild(elem);
+ return elem;
+ }
+ removeElem(elem) {
+ this.#childDestElem.removeChild(elem);
+ return elem;
+ }
+ pushSubElem(elem) {
+ this.#childDestElem.appendChild(elem);
+ this.#childDestElem = elem;
+ }
+ popSubElem() {
+ this.#childDestElem = this.#childDestElem.parentElement;
+ }
+ add(view) {
+ this.#views.push(view);
+ this.addElem(view.domElement);
+ return view;
+ }
+ remove(view) {
+ this.removeElem(view.domElement);
+ removeArrayElem(this.#views, view);
+ return view;
+ }
+ pushSubView(view) {
+ this.pushSubElem(view.domElement);
+ }
+ popSubView() {
+ this.popSubElem();
+ }
+ setOptions(options) {
+ for (const view of this.#views) {
+ view.setOptions(options);
+ }
+ }
+ updateDisplayIfNeeded(newV, ignoreCache) {
+ for (const view of this.#views) {
+ view.updateDisplayIfNeeded(newV, ignoreCache);
+ }
+ return this;
+ }
+ $(selector) {
+ return this.domElement.querySelector(selector);
+ }
+ }
+
+ class Controller extends View {
+ #changeFns;
+ #finishChangeFns;
+ #parent;
+
+ constructor(className) {
+ super(createElem('div', {className: 'muigui-controller'}));
+ this.#changeFns = [];
+ this.#finishChangeFns = [];
+ // we need the specialization to come last so it takes precedence.
+ if (className) {
+ this.domElement.classList.add(className);
+ }
+ }
+ get parent() {
+ return this.#parent;
+ }
+ setParent(parent) {
+ this.#parent = parent;
+ this.enable(!this.disabled());
+ }
+ show(show = true) {
+ this.domElement.classList.toggle('muigui-hide', !show);
+ this.domElement.classList.toggle('muigui-show', show);
+ return this;
+ }
+ hide() {
+ return this.show(false);
+ }
+ disabled() {
+ return !!this.domElement.closest('.muigui-disabled');
+ }
+
+ enable(enable = true) {
+ this.domElement.classList.toggle('muigui-disabled', !enable);
+
+ // If disabled we need to set the attribute 'disabled=true' to all
+ // input/select/button/textarea's below
+ //
+ // If enabled we need to set the attribute 'disabled=false' to all below
+ // until we hit a disabled controller.
+ //
+ // ATM the problem is we can find the input/select/button/textarea elements
+ // but we can't easily find which controller they belong do.
+ // But we don't need to? We can just check up if it or parent has
+ // '.muigui-disabled'
+ ['input', 'button', 'select', 'textarea'].forEach(tag => {
+ this.domElement.querySelectorAll(tag).forEach(elem => {
+ const disabled = !!elem.closest('.muigui-disabled');
+ elem.disabled = disabled;
+ });
+ });
+
+ return this;
+ }
+ disable(disable = true) {
+ return this.enable(!disable);
+ }
+ onChange(fn) {
+ this.removeChange(fn);
+ this.#changeFns.push(fn);
+ return this;
+ }
+ removeChange(fn) {
+ removeArrayElem(this.#changeFns, fn);
+ return this;
+ }
+ onFinishChange(fn) {
+ this.removeFinishChange(fn);
+ this.#finishChangeFns.push(fn);
+ return this;
+ }
+ removeFinishChange(fn) {
+ removeArrayElem(this.#finishChangeFns, fn);
+ return this;
+ }
+ #callListeners(fns, newV) {
+ for (const fn of fns) {
+ fn.call(this, newV);
+ }
+ }
+ emitChange(value, object, property) {
+ this.#callListeners(this.#changeFns, value);
+ if (this.#parent) {
+ if (object === undefined) {
+ this.#parent.emitChange(value);
+ } else {
+ this.#parent.emitChange({
+ object,
+ property,
+ value,
+ controller: this,
+ });
+ }
+ }
+ }
+ emitFinalChange(value, object, property) {
+ this.#callListeners(this.#finishChangeFns, value);
+ if (this.#parent) {
+ if (object === undefined) {
+ this.#parent.emitChange(value);
+ } else {
+ this.#parent.emitFinalChange({
+ object,
+ property,
+ value,
+ controller: this,
+ });
+ }
+ }
+ }
+ updateDisplay() {
+ // placeholder. override
+ }
+ getColors() {
+ const toCamelCase = s => s.replace(/-([a-z])/g, (m, m1) => m1.toUpperCase());
+ const keys = [
+ 'color',
+ 'bg-color',
+ 'value-color',
+ 'value-bg-color',
+ 'hover-bg-color',
+ 'menu-bg-color',
+ 'menu-sep-color',
+ 'disabled-color',
+ ];
+ const div = createElem('div');
+ this.domElement.appendChild(div);
+ const colors = Object.fromEntries(keys.map(key => {
+ div.style.color = `var(--${key})`;
+ const s = getComputedStyle(div);
+ return [toCamelCase(key), s.color];
+ }));
+ div.remove();
+ return colors;
+ }
+ }
+
+ class Button extends Controller {
+ #object;
+ #property;
+ #buttonElem;
+ #options = {
+ name: '',
+ };
+
+ constructor(object, property, options = {}) {
+ super('muigui-button', '');
+ this.#object = object;
+ this.#property = property;
+
+ this.#buttonElem = this.addElem(
+ createElem('button', {
+ type: 'button',
+ onClick: () => {
+ this.#object[this.#property](this);
+ },
+ }));
+ this.setOptions({name: property, ...options});
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {name} = this.#options;
+ this.#buttonElem.textContent = name;
+ }
+ }
+
+ function arraysEqual(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;
+ }
+
+ function copyArrayElementsFromTo(src, dst) {
+ dst.length = src.length;
+ for (let i = 0; i < src.length; ++i) {
+ dst[i] = src[i];
+ }
+ }
+
+ class EditView extends View {
+ #oldV;
+ #updateCheck;
+
+ #checkArrayNeedsUpdate(newV) {
+ // It's an array, we need to compare all elements
+ // Example, vec2, [r,g,b], ...
+ const needUpdate = !arraysEqual(newV, this.#oldV);
+ if (needUpdate) {
+ copyArrayElementsFromTo(newV, this.#oldV);
+ }
+ return needUpdate;
+ }
+
+ #checkTypedArrayNeedsUpdate() {
+ let once = true;
+ return function checkTypedArrayNeedsUpdateImpl(newV) {
+ // It's a typedarray, we need to compare all elements
+ // Example: Float32Array([r, g, b])
+ let needUpdate = once;
+ once = false;
+ if (!needUpdate) {
+ needUpdate = !arraysEqual(newV, this.#oldV);
+ }
+ return needUpdate;
+ };
+ }
+
+ #checkObjectNeedsUpdate(newV) {
+ let needUpdate = false;
+ for (const key in newV) {
+ if (newV[key] !== this.#oldV[key]) {
+ needUpdate = true;
+ this.#oldV[key] = newV[key];
+ }
+ }
+ return needUpdate;
+ }
+
+ #checkValueNeedsUpdate(newV) {
+ const needUpdate = newV !== this.#oldV;
+ this.#oldV = newV;
+ return needUpdate;
+ }
+
+ #getUpdateCheckForType(newV) {
+ if (Array.isArray(newV)) {
+ this.#oldV = [];
+ return this.#checkArrayNeedsUpdate.bind(this);
+ } else if (isTypedArray(newV)) {
+ this.#oldV = new newV.constructor(newV);
+ return this.#checkTypedArrayNeedsUpdate(this);
+ } else if (typeof newV === 'object') {
+ this.#oldV = {};
+ return this.#checkObjectNeedsUpdate.bind(this);
+ } else {
+ return this.#checkValueNeedsUpdate.bind(this);
+ }
+ }
+
+ // The point of this is updating DOM elements
+ // is slow but if we've called `listen` then
+ // every frame we're going to try to update
+ // things with the current value so if nothing
+ // has changed then skip it.
+ updateDisplayIfNeeded(newV, ignoreCache) {
+ this.#updateCheck = this.#updateCheck || this.#getUpdateCheckForType(newV);
+ // Note: We call #updateCheck first because it updates
+ // the cache
+ if (this.#updateCheck(newV) || ignoreCache) {
+ this.updateDisplay(newV);
+ }
+ }
+ setOptions(/*options*/) {
+ // override this
+ return this;
+ }
+ }
+
+ class CheckboxView extends EditView {
+ #checkboxElem;
+ constructor(setter, id) {
+ const checkboxElem = createElem('input', {
+ type: 'checkbox',
+ id,
+ onInput: () => {
+ setter.setValue(checkboxElem.checked);
+ },
+ onChange: () => {
+ setter.setFinalValue(checkboxElem.checked);
+ },
+ });
+ super(createElem('label', {}, [checkboxElem]));
+ this.#checkboxElem = checkboxElem;
+ }
+ updateDisplay(v) {
+ this.#checkboxElem.checked = v;
+ }
+ }
+
+ const tasks = [];
+ const tasksToRemove = new Set();
+
+ let requestId;
+ let processing;
+
+ function removeTasks() {
+ if (!tasksToRemove.size) {
+ return;
+ }
+
+ if (processing) {
+ queueProcessing();
+ return;
+ }
+
+ tasksToRemove.forEach(task => {
+ removeArrayElem(tasks, task);
+ });
+ tasksToRemove.clear();
+ }
+
+ function processTasks() {
+ requestId = undefined;
+ processing = true;
+ for (const task of tasks) {
+ if (!tasksToRemove.has(task)) {
+ task();
+ }
+ }
+ processing = false;
+ removeTasks();
+ queueProcessing();
+ }
+
+ function queueProcessing() {
+ if (!requestId && tasks.length) {
+ requestId = requestAnimationFrame(processTasks);
+ }
+ }
+
+ function addTask(fn) {
+ tasks.push(fn);
+ queueProcessing();
+ }
+
+ function removeTask(fn) {
+ tasksToRemove.set(fn);
+
+ const ndx = tasks.indexOf(fn);
+ if (ndx >= 0) {
+ tasks.splice(ndx, 1);
+ }
+ }
+
+ let id = 0;
+
+ function makeId() {
+ return `muigui-${++id}`;
+ }
+
+ class ValueView extends View {
+ constructor(className = '') {
+ super(createElem('div', {className: 'muigui-value'}));
+ if (className) {
+ this.domElement.classList.add(className);
+ }
+ }
+ }
+
+ class LabelController extends Controller {
+ #id;
+ #nameElem;
+
+ constructor(className = '', name = '') {
+ super('muigui-label-controller');
+ this.#id = makeId();
+ this.#nameElem = createElem('label', {for: this.#id});
+ this.domElement.appendChild(this.#nameElem);
+ this.pushSubView(new ValueView(className));
+ this.name(name);
+ }
+ get id() {
+ return this.#id;
+ }
+ name(name) {
+ if (this.#nameElem.title === this.#nameElem.textContent) {
+ this.#nameElem.title = name;
+ }
+ this.#nameElem.textContent = name;
+ return this;
+ }
+ tooltip(tip) {
+ this.#nameElem.title = tip;
+ }
+ }
+
+ class ValueController extends LabelController {
+ #object;
+ #property;
+ #initialValue;
+ #listening;
+ #views;
+ #updateFn;
+
+ constructor(object, property, className = '') {
+ super(className, property);
+ this.#object = object;
+ this.#property = property;
+ this.#initialValue = this.getValue();
+ this.#listening = false;
+ this.#views = [];
+ }
+ get initialValue() {
+ return this.#initialValue;
+ }
+ get object() {
+ return this.#object;
+ }
+ get property() {
+ return this.#property;
+ }
+ add(view) {
+ this.#views.push(view);
+ super.add(view);
+ this.updateDisplay();
+ return view;
+ }
+ #setValueImpl(v, ignoreCache) {
+ let isDifferent = false;
+ if (typeof v === 'object') {
+ const dst = this.#object[this.#property];
+ // don't replace objects, just their values.
+ if (Array.isArray(v) || isTypedArray(v)) {
+ for (let i = 0; i < v.length; ++i) {
+ isDifferent ||= dst[i] !== v[i];
+ dst[i] = v[i];
+ }
+ } else {
+ for (const key of Object.keys(v)) {
+ isDifferent ||= dst[key] !== v[key];
+ }
+ Object.assign(dst, v);
+ }
+ } else {
+ isDifferent = this.#object[this.#property] !== v;
+ this.#object[this.#property] = v;
+ }
+ this.updateDisplay(ignoreCache);
+ if (isDifferent) {
+ this.emitChange(this.getValue(), this.#object, this.#property);
+ }
+ return isDifferent;
+ }
+ setValue(v) {
+ this.#setValueImpl(v);
+ }
+ setFinalValue(v) {
+ const isDifferent = this.#setValueImpl(v, true);
+ if (isDifferent) {
+ this.emitFinalChange(this.getValue(), this.#object, this.#property);
+ }
+ return this;
+ }
+ updateDisplay(ignoreCache) {
+ const newV = this.getValue();
+ for (const view of this.#views) {
+ view.updateDisplayIfNeeded(newV, ignoreCache);
+ }
+ return this;
+ }
+ setOptions(options) {
+ for (const view of this.#views) {
+ view.setOptions(options);
+ }
+ this.updateDisplay();
+ return this;
+ }
+ getValue() {
+ return this.#object[this.#property];
+ }
+ value(v) {
+ this.setValue(v);
+ return this;
+ }
+ reset() {
+ this.setValue(this.#initialValue);
+ return this;
+ }
+ listen(listen = true) {
+ if (!this.#updateFn) {
+ this.#updateFn = this.updateDisplay.bind(this);
+ }
+ if (listen) {
+ if (!this.#listening) {
+ this.#listening = true;
+ addTask(this.#updateFn);
+ }
+ } else {
+ if (this.#listening) {
+ this.#listening = false;
+ removeTask(this.#updateFn);
+ }
+ }
+ return this;
+ }
+ }
+
+ class Checkbox extends ValueController {
+ constructor(object, property) {
+ super(object, property, 'muigui-checkbox');
+ const id = this.id;
+ this.add(new CheckboxView(this, id));
+ this.updateDisplay();
+ }
+ }
+
+ const identity = {
+ to: v => v,
+ from: v => [true, v],
+ };
+
+ // from: from string to value
+ // to: from value to string
+ const strToNumber = {
+ to: v => v.toString(),
+ from: v => {
+ const newV = parseFloat(v);
+ return [!Number.isNaN(newV), newV];
+ },
+ };
+
+ const converters = {
+ radToDeg: makeRangeConverters({to: [0, 180], from: [0, Math.PI]}),
+ };
+
+ function createWheelHelper() {
+ let wheelAccum = 0;
+ return function (e, step, wheelScale = 5) {
+ wheelAccum -= e.deltaY * step / wheelScale;
+ const wheelSteps = Math.floor(Math.abs(wheelAccum) / step) * Math.sign(wheelAccum);
+ const delta = wheelSteps * step;
+ wheelAccum -= delta;
+ return delta;
+ };
+ }
+
+ class NumberView extends EditView {
+ #to;
+ #from;
+ #step;
+ #skipUpdate;
+ #options = {
+ step: 0.01,
+ converters: strToNumber,
+ min: Number.NEGATIVE_INFINITY,
+ max: Number.POSITIVE_INFINITY,
+ };
+
+ constructor(setter, options) {
+ const setValue = setter.setValue.bind(setter);
+ const setFinalValue = setter.setFinalValue.bind(setter);
+ const wheelHelper = createWheelHelper();
+ super(createElem('input', {
+ type: 'number',
+ onInput: () => this.#handleInput(setValue, true),
+ onChange: () => this.#handleInput(setFinalValue, false),
+ onWheel: e => {
+ e.preventDefault();
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ const v = parseFloat(this.domElement.value);
+ const newV = clamp$1(stepify(v + delta, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ this.setOptions(options);
+ }
+ #handleInput(setFn, skipUpdate) {
+ const v = parseFloat(this.domElement.value);
+ const [valid, newV] = this.#from(v);
+ let inRange;
+ if (valid && !Number.isNaN(v)) {
+ const {min, max} = this.#options;
+ inRange = newV >= min && newV <= max;
+ this.#skipUpdate = skipUpdate;
+ setFn(clamp$1(newV, min, max));
+ }
+ this.domElement.classList.toggle('muigui-invalid-value', !valid || !inRange);
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.domElement.value = stepify(v, this.#to, this.#step);
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {
+ step,
+ converters: {to, from},
+ } = this.#options;
+ this.#to = to;
+ this.#from = from;
+ this.#step = step;
+ return this;
+ }
+ }
+
+ // Wanted to name this `Number` but it conflicts with
+ // JavaScript `Number`. It most likely wouldn't be
+ // an issue? But users might `import {Number} ...` and
+ // things would break.
+ class TextNumber extends ValueController {
+ #textView;
+ #step;
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-checkbox');
+ this.#textView = this.add(new NumberView(this, options));
+ this.updateDisplay();
+ }
+ }
+
+ class SelectView extends EditView {
+ #values;
+
+ constructor(setter, keyValues) {
+ const values = [];
+ super(createElem('select', {
+ onChange: () => {
+ setter.setFinalValue(this.#values[this.domElement.selectedIndex]);
+ },
+ }, keyValues.map(([key, value]) => {
+ values.push(value);
+ return createElem('option', {textContent: key});
+ })));
+ this.#values = values;
+ }
+ updateDisplay(v) {
+ const ndx = this.#values.indexOf(v);
+ this.domElement.selectedIndex = ndx;
+ }
+ }
+
+ // 4 cases
+ // (a) keyValues is array of arrays, each sub array is key value
+ // (b) keyValues is array and value is number then keys = array contents, value = index
+ // (c) keyValues is array and value is not number, key = array contents, value = array contents
+ // (d) keyValues is object then key->value
+ function convertToKeyValues(keyValues, valueIsNumber) {
+ if (Array.isArray(keyValues)) {
+ if (Array.isArray(keyValues[0])) {
+ // (a) keyValues is array of arrays, each sub array is key value
+ return keyValues;
+ } else {
+ if (valueIsNumber) {
+ // (b) keyValues is array and value is number then keys = array contents, value = index
+ return keyValues.map((v, ndx) => [v, ndx]);
+ } else {
+ // (c) keyValues is array and value is not number, key = array contents, value = array contents
+ return keyValues.map(v => [v, v]);
+ }
+ }
+ } else {
+ // (d)
+ return [...Object.entries(keyValues)];
+ }
+ }
+
+ class Select extends ValueController {
+ constructor(object, property, options) {
+ super(object, property, 'muigui-select');
+ const valueIsNumber = typeof this.getValue() === 'number';
+ const {keyValues: keyValuesInput} = options;
+ const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);
+ this.add(new SelectView(this, keyValues));
+ this.updateDisplay();
+ }
+ }
+
+ class RangeView extends EditView {
+ #to;
+ #from;
+ #step;
+ #skipUpdate;
+ #options = {
+ step: 0.01,
+ min: 0,
+ max: 1,
+ converters: identity,
+ };
+
+ constructor(setter, options) {
+ const wheelHelper = createWheelHelper();
+ super(createElem('input', {
+ type: 'range',
+ onInput: () => {
+ this.#skipUpdate = true;
+ const {min, max, step} = this.#options;
+ const v = parseFloat(this.domElement.value);
+ const newV = clamp$1(stepify(v, v => v, step), min, max);
+ const [valid, validV] = this.#from(newV);
+ if (valid) {
+ setter.setValue(validV);
+ }
+ },
+ onChange: () => {
+ this.#skipUpdate = true;
+ const {min, max, step} = this.#options;
+ const v = parseFloat(this.domElement.value);
+ const newV = clamp$1(stepify(v, v => v, step), min, max);
+ const [valid, validV] = this.#from(newV);
+ if (valid) {
+ setter.setFinalValue(validV);
+ }
+ },
+ onWheel: e => {
+ e.preventDefault();
+ const [valid, v] = this.#from(parseFloat(this.domElement.value));
+ if (!valid) {
+ return;
+ }
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ const newV = clamp$1(stepify(v + delta, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ this.setOptions(options);
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.domElement.value = stepify(v, this.#to, this.#step);
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {
+ step,
+ min,
+ max,
+ converters: {to, from},
+ } = this.#options;
+ this.#to = to;
+ this.#from = from;
+ this.#step = step;
+ this.domElement.step = step;
+ this.domElement.min = min;
+ this.domElement.max = max;
+ return this;
+ }
+ }
+
+ class Range extends ValueController {
+ constructor(object, property, options) {
+ super(object, property, 'muigui-range');
+ this.add(new RangeView(this, options));
+ this.add(new NumberView(this, options));
+ }
+ }
+
+ class TextView extends EditView {
+ #to;
+ #from;
+ #skipUpdate;
+ #options = {
+ converters: identity,
+ };
+
+ constructor(setter, options) {
+ const setValue = setter.setValue.bind(setter);
+ const setFinalValue = setter.setFinalValue.bind(setter);
+ super(createElem('input', {
+ type: 'text',
+ onInput: () => this.#handleInput(setValue, true),
+ onChange: () => this.#handleInput(setFinalValue, false),
+ }));
+ this.setOptions(options);
+ }
+ #handleInput(setFn, skipUpdate) {
+ const [valid, newV] = this.#from(this.domElement.value);
+ if (valid) {
+ this.#skipUpdate = skipUpdate;
+ setFn(newV);
+ }
+ this.domElement.style.color = valid ? '' : 'var(--invalid-color)';
+
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.domElement.value = this.#to(v);
+ this.domElement.style.color = '';
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {
+ converters: {to, from},
+ } = this.#options;
+ this.#to = to;
+ this.#from = from;
+ return this;
+ }
+ }
+
+ class Text extends ValueController {
+ constructor(object, property) {
+ super(object, property, 'muigui-checkbox');
+ this.add(new TextView(this));
+ this.updateDisplay();
+ }
+ }
+
+ // const isConversion = o => typeof o.to === 'function' && typeof o.from === 'function';
+
+ /**
+ * possible inputs
+ * add(o, p, min: number, max: number)
+ * add(o, p, min: number, max: number, step: number)
+ * add(o, p, array: [value])
+ * add(o, p, array: [[key, value]])
+ *
+ * @param {*} object
+ * @param {string} property
+ * @param {...any} args
+ * @returns {Controller}
+ */
+ function createController(object, property, ...args) {
+ const [arg1] = args;
+ if (Array.isArray(arg1)) {
+ return new Select(object, property, {keyValues: arg1});
+ }
+
+ const t = typeof object[property];
+ switch (t) {
+ case 'number':
+ if (typeof args[0] === 'number' && typeof args[1] === 'number') {
+ const min = args[0];
+ const max = args[1];
+ const step = args[2];
+ return new Range(object, property, {min, max, ...(step && {step})});
+ }
+ return args.length === 0
+ ? new TextNumber(object, property, ...args)
+ : new Range(object, property, ...args);
+ case 'boolean':
+ return new Checkbox(object, property, ...args);
+ case 'function':
+ return new Button(object, property, ...args);
+ case 'string':
+ return new Text(object, property, ...args);
+ case 'undefined':
+ throw new Error(`no property named ${property}`);
+ default:
+ throw new Error(`unhandled type ${t} for property ${property}`);
+ }
+ }
+
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
+ const lerp = (a, b, t) => a + (b - a) * t;
+ const fract = v => v >= 0 ? v % 1 : 1 - (v % 1);
+
+ const f0 = v => +v.toFixed(0); // converts to string (eg 1.2 => "1"), then converts back to number (eg, "1.200" => 1.2)
+ const f3 = v => +v.toFixed(3); // converts to string (eg 1.2 => "1.200"), then converts back to number (eg, "1.200" => 1.2)
+
+ const hexToUint32RGB = v => (parseInt(v.substring(1, 3), 16) << 16) |
+ (parseInt(v.substring(3, 5), 16) << 8 ) |
+ (parseInt(v.substring(5, 7), 16) );
+ const uint32RGBToHex = v => `#${(Math.round(v)).toString(16).padStart(6, '0')}`;
+ const hexToUint32RGBA = v => (parseInt(v.substring(1, 3), 16) * 2 ** 24) +
+ (parseInt(v.substring(3, 5), 16) * 2 ** 16) +
+ (parseInt(v.substring(5, 7), 16) * 2 ** 8) +
+ (parseInt(v.substring(7, 9), 16) );
+ const uint32RGBAToHex = v => `#${(Math.round(v)).toString(16).padStart(8, '0')}`;
+
+ const hexToUint8RGB = v => [
+ parseInt(v.substring(1, 3), 16),
+ parseInt(v.substring(3, 5), 16),
+ parseInt(v.substring(5, 7), 16),
+ ];
+ const uint8RGBToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;
+
+ const hexToUint8RGBA = v => [
+ parseInt(v.substring(1, 3), 16),
+ parseInt(v.substring(3, 5), 16),
+ parseInt(v.substring(5, 7), 16),
+ parseInt(v.substring(7, 9), 16),
+ ];
+ const uint8RGBAToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;
+
+ const hexToFloatRGB = v => hexToUint8RGB(v).map(v => f3(v / 255));
+ const floatRGBToHex = v => uint8RGBToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));
+
+ const hexToFloatRGBA = v => hexToUint8RGBA(v).map(v => f3(v / 255));
+ const floatRGBAToHex = v => uint8RGBAToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));
+
+ const scaleAndClamp = v => clamp(Math.round(v * 255), 0, 255).toString(16).padStart(2, '0');
+
+ const hexToObjectRGB = v => ({
+ r: parseInt(v.substring(1, 3), 16) / 255,
+ g: parseInt(v.substring(3, 5), 16) / 255,
+ b: parseInt(v.substring(5, 7), 16) / 255,
+ });
+ const objectRGBToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}`;
+ const hexToObjectRGBA = v => ({
+ r: parseInt(v.substring(1, 3), 16) / 255,
+ g: parseInt(v.substring(3, 5), 16) / 255,
+ b: parseInt(v.substring(5, 7), 16) / 255,
+ a: parseInt(v.substring(7, 9), 16) / 255,
+ });
+ const objectRGBAToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}${scaleAndClamp(v.a)}`;
+
+ const hexToCssRGB = v => `rgb(${hexToUint8RGB(v).join(', ')})`;
+ const cssRGBRegex = /^\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/;
+ const cssRGBToHex = v => {
+ const m = cssRGBRegex.exec(v);
+ return uint8RGBToHex([m[1], m[2], m[3]].map(v => parseInt(v)));
+ };
+ const hexToCssRGBA = v => `rgba(${hexToUint8RGBA(v).map((v, i) => i === 3 ? v / 255 : v).join(', ')})`;
+ const cssRGBARegex = /^\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+\.\d+|\d+)\s*\)\s*$/;
+ const cssRGBAToHex = v => {
+ const m = cssRGBARegex.exec(v);
+ return uint8RGBAToHex([m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? (parseFloat(v) * 255 | 0) : parseInt(v)));
+ };
+
+ const hexToCssHSL = v => {
+ const hsl = rgbUint8ToHsl(hexToUint8RGB(v)).map(v => f0(v));
+ return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`;
+ };
+ const hexToCssHSLA = v => {
+ const hsla = rgbaUint8ToHsla(hexToUint8RGBA(v)).map((v, i) => i === 3 ? f3(v) : f0(v));
+ return `hsl(${hsla[0]} ${hsla[1]}% ${hsla[2]}% / ${hsla[3]})`;
+ };
+ const cssHSLRegex = /^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\)\s*$/;
+ const cssHSLARegex = /^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\/\s*(\d+\.\d+|\d+)\s*\)\s*$/;
+
+ const hex3DigitTo6Digit = v => `${v[0]}${v[0]}${v[1]}${v[1]}${v[2]}${v[2]}`;
+ const cssHSLToHex = v => {
+ const m = cssHSLRegex.exec(v);
+ const rgb = hslToRgbUint8([m[1], m[2], m[3]].map(v => parseFloat(v)));
+ return uint8RGBToHex(rgb);
+ };
+ const cssHSLAToHex = v => {
+ const m = cssHSLARegex.exec(v);
+ const rgba = hslaToRgbaUint8([m[1], m[2], m[3], m[4]].map(v => parseFloat(v)));
+ return uint8RGBAToHex(rgba);
+ };
+
+ const euclideanModulo = (v, n) => ((v % n) + n) % n;
+
+ function hslToRgbUint8([h, s, l]) {
+ h = euclideanModulo(h, 360);
+ s = clamp(s / 100, 0, 1);
+ l = clamp(l / 100, 0, 1);
+
+ const a = s * Math.min(l, 1 - l);
+
+ function f(n) {
+ const k = (n + h / 30) % 12;
+ return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
+ }
+
+ return [f(0), f(8), f(4)].map(v => Math.round(v * 255));
+ }
+
+ function hslaToRgbaUint8([h, s, l, a]) {
+ const rgb = hslToRgbUint8([h, s, l]);
+ return [...rgb, a * 255 | 0];
+ }
+
+ function rgbFloatToHsl01([r, g, b]) {
+ const max = Math.max(r, g, b);
+ const min = Math.min(r, g, b);
+ const l = (min + max) * 0.5;
+ const d = max - min;
+ let h = 0;
+ let s = 0;
+
+ if (d !== 0) {
+ s = (l === 0 || l === 1)
+ ? 0
+ : (max - l) / Math.min(l, 1 - l);
+
+ switch (max) {
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
+ case g: h = (b - r) / d + 2; break;
+ case b: h = (r - g) / d + 4;
+ }
+ }
+
+ return [h / 6, s, l];
+ }
+
+ function rgbaFloatToHsla01([r, g, b, a]) {
+ const hsl = rgbFloatToHsl01([r, g, b]);
+ return [...hsl, a];
+ }
+
+ const rgbUint8ToHsl = (rgb) => {
+ const [h, s, l] = rgbFloatToHsl01(rgb.map(v => v / 255));
+ return [h * 360, s * 100, l * 100];
+ };
+
+ const rgbaUint8ToHsla = (rgba) => {
+ const [h, s, l, a] = rgbaFloatToHsla01(rgba.map(v => v / 255));
+ return [h * 360, s * 100, l * 100, a];
+ };
+
+ function hsv01ToRGBFloat([hue, sat, val]) {
+ sat = clamp(sat, 0, 1);
+ val = clamp(val, 0, 1);
+ return [hue, hue + 2 / 3, hue + 1 / 3].map(
+ v => lerp(1, clamp(Math.abs(fract(v) * 6 - 3.0) - 1, 0, 1), sat) * val
+ );
+ }
+
+ function hsva01ToRGBAFloat([hue, sat, val, alpha]) {
+ const rgb = hsv01ToRGBFloat([hue, sat, val]);
+ return [...rgb, alpha];
+ }
+
+ const round3 = v => Math.round(v * 1000) / 1000;
+
+ function rgbFloatToHSV01([r, g, b]) {
+ const p = b > g
+ ? [b, g, -1, 2 / 3]
+ : [g, b, 0, -1 / 3];
+ const q = p[0] > r
+ ? [p[0], p[1], p[3], r]
+ : [r, p[1], p[2], p[0]];
+ const d = q[0] - Math.min(q[3], q[1]);
+ return [
+ Math.abs(q[2] + (q[3] - q[1]) / (6 * d + Number.EPSILON)),
+ d / (q[0] + Number.EPSILON),
+ q[0],
+ ].map(round3);
+ }
+
+ function rgbaFloatToHSVA01([r, g, b, a]) {
+ const hsv = rgbFloatToHSV01([r, g, b]);
+ return [...hsv, a];
+ }
+
+ // window.hsv01ToRGBFloat = hsv01ToRGBFloat;
+ // window.rgbFloatToHSV01 = rgbFloatToHSV01;
+
+ // Yea, meh!
+ const hasAlpha = format => format.endsWith('a') || format.startsWith('hex8');
+
+ const cssStringFormats = [
+ { re: /^#(?:[0-9a-f]){6}$/i, format: 'hex6' },
+ { re: /^(?:[0-9a-f]){6}$/i, format: 'hex6-no-hash' },
+ { re: /^#(?:[0-9a-f]){8}$/i, format: 'hex8' },
+ { re: /^(?:[0-9a-f]){8}$/i, format: 'hex8-no-hash' },
+ { re: /^#(?:[0-9a-f]){3}$/i, format: 'hex3' },
+ { re: /^(?:[0-9a-f]){3}$/i, format: 'hex3-no-hash' },
+ { re: cssRGBRegex, format: 'css-rgb' },
+ { re: cssHSLRegex, format: 'css-hsl' },
+ { re: cssRGBARegex, format: 'css-rgba' },
+ { re: cssHSLARegex, format: 'css-hsla' },
+ ];
+
+ function guessStringColorFormat(v) {
+ for (const formatInfo of cssStringFormats) {
+ if (formatInfo.re.test(v)) {
+ return formatInfo;
+ }
+ }
+ return undefined;
+ }
+
+ function guessFormat(v) {
+ switch (typeof v) {
+ case 'number':
+ console.warn('can not reliably guess format based on a number. You should pass in a format like {format: "uint32-rgb"} or {format: "uint32-rgb"}');
+ return v <= 0xFFFFFF ? 'uint32-rgb' : 'uint32-rgba';
+ case 'string': {
+ const formatInfo = guessStringColorFormat(v.trim());
+ if (formatInfo) {
+ return formatInfo.format;
+ }
+ break;
+ }
+ case 'object':
+ if (v instanceof Uint8Array || v instanceof Uint8ClampedArray) {
+ if (v.length === 3) {
+ return 'uint8-rgb';
+ } else if (v.length === 4) {
+ return 'uint8-rgba';
+ }
+ } else if (v instanceof Float32Array) {
+ if (v.length === 3) {
+ return 'float-rgb';
+ } else if (v.length === 4) {
+ return 'float-rgba';
+ }
+ } else if (Array.isArray(v)) {
+ if (v.length === 3) {
+ return 'float-rgb';
+ } else if (v.length === 4) {
+ return 'float-rgba';
+ }
+ } else {
+ if ('r' in v && 'g' in v && 'b' in v) {
+ if ('a' in v) {
+ return 'object-rgba';
+ } else {
+ return 'object-rgb';
+ }
+ }
+ }
+ }
+ throw new Error(`unknown color format: ${v}`);
+ }
+
+ function fixHex6(v) {
+ return v.trim(v);
+ //const formatInfo = guessStringColorFormat(v.trim());
+ //const fix = formatInfo ? formatInfo.fix : v => v;
+ //return fix(v.trim());
+ }
+
+ function fixHex8(v) {
+ return v.trim(v);
+ //const formatInfo = guessStringColorFormat(v.trim());
+ //const fix = formatInfo ? formatInfo.fix : v => v;
+ //return fix(v.trim());
+ }
+
+ function hex6ToHex3(hex6) {
+ return (hex6[1] === hex6[2] &&
+ hex6[3] === hex6[4] &&
+ hex6[5] === hex6[6])
+ ? `#${hex6[1]}${hex6[3]}${hex6[5]}`
+ : hex6;
+ }
+
+ const hex3RE = /^(#|)([0-9a-f]{3})$/i;
+ function hex3ToHex6(hex3) {
+ const m = hex3RE.exec(hex3);
+ if (m) {
+ const [, , m2] = m;
+ return `#${hex3DigitTo6Digit(m2)}`;
+ }
+ return hex3;
+ }
+
+ function fixHex3(v) {
+ return hex6ToHex3(fixHex6(v));
+ }
+
+ const strToRGBObject = (s) => {
+ try {
+ const json = s.replace(/([a-z])/g, '"$1"');
+ const rgb = JSON.parse(json);
+ if (Number.isNaN(rgb.r) || Number.isNaN(rgb.g) || Number.isNaN(rgb.b)) {
+ throw new Error('not {r, g, b}');
+ }
+ return [true, rgb];
+ } catch (e) {
+ return [false];
+ }
+ };
+
+ const strToRGBAObject = (s) => {
+ try {
+ const json = s.replace(/([a-z])/g, '"$1"');
+ const rgba = JSON.parse(json);
+ if (Number.isNaN(rgba.r) || Number.isNaN(rgba.g) || Number.isNaN(rgba.b) || Number.isNaN(rgba.a)) {
+ throw new Error('not {r, g, b, a}');
+ }
+ return [true, rgba];
+ } catch (e) {
+ return [false];
+ }
+ };
+
+ const strToCssRGB = s => {
+ const m = cssRGBRegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3]].map(v => parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, `rgb(${v.join(', ')})`];
+ };
+
+ const strToCssRGBA = s => {
+ const m = cssRGBARegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? parseFloat(v) : parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, `rgba(${v.join(', ')})`];
+ };
+
+ const strToCssHSL = s => {
+ const m = cssHSLRegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3]].map(v => parseFloat(v));
+ const outOfRange = v.find(v => Number.isNaN(v));
+ return [!outOfRange, `hsl(${v[0]}, ${v[1]}%, ${v[2]}%)`];
+ };
+
+ const strToCssHSLA = s => {
+ const m = cssHSLARegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3], m[4]].map(v => parseFloat(v));
+ const outOfRange = v.find(v => Number.isNaN(v));
+ return [!outOfRange, `hsl(${v[0]} ${v[1]}% ${v[2]}% / ${v[3]})`];
+ };
+
+ const rgbObjectToStr = rgb => {
+ return `{r:${f3(rgb.r)}, g:${f3(rgb.g)}, b:${f3(rgb.b)}}`;
+ };
+ const rgbaObjectToStr = rgba => {
+ return `{r:${f3(rgba.r)}, g:${f3(rgba.g)}, b:${f3(rgba.b)}}, a:${f3(rgba.a)}}`;
+ };
+
+ const strTo3IntsRE = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/;
+ const strTo3Ints = s => {
+ const m = strTo3IntsRE.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3]].map(v => parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, v];
+ };
+
+ const strTo4IntsRE = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/;
+ const strTo4Ints = s => {
+ const m = strTo4IntsRE.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3], m[4]].map(v => parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, v];
+ };
+
+ const strTo3Floats = s => {
+ const numbers = s.split(',').map(s => s.trim());
+ const v = numbers.map(v => parseFloat(v));
+ if (v.length !== 3) {
+ return [false];
+ }
+ // Note: using isNaN not Number.isNaN
+ const badNdx = numbers.findIndex(v => isNaN(v));
+ return [badNdx < 0, v.map(v => f3(v))];
+ };
+
+ const strTo4Floats = s => {
+ const numbers = s.split(',').map(s => s.trim());
+ const v = numbers.map(v => parseFloat(v));
+ if (v.length !== 4) {
+ return [false];
+ }
+ // Note: using isNaN not Number.isNaN
+ const badNdx = numbers.findIndex(v => isNaN(v));
+ return [badNdx < 0, v.map(v => f3(v))];
+ };
+
+ const strToUint32RGBRegex = /^\s*(?:0x){0,1}([0-9a-z]{1,6})\s*$/i;
+ const strToUint32RGB = s => {
+ const m = strToUint32RGBRegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ return [true, parseInt(m[1], 16)];
+ };
+
+ const strToUint32RGBARegex = /^\s*(?:0x){0,1}([0-9a-z]{1,8})\s*$/i;
+ const strToUint32RGBA = s => {
+ const m = strToUint32RGBARegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ return [true, parseInt(m[1], 16)];
+ };
+
+ const hex6RE = /^\s*#[a-f0-9]{6}\s*$|^\s*#[a-f0-9]{3}\s*$/i;
+ const hexNoHash6RE = /^\s*[a-f0-9]{6}\s*$/i;
+ const hex8RE = /^\s*#[a-f0-9]{8}\s*$/i;
+ const hexNoHash8RE = /^\s*[a-f0-9]{8}\s*$/i;
+
+ // For each format converter
+ //
+ // fromHex/toHex convert from/to '#RRGGBB'
+ //
+ // fromHex converts from the string '#RRBBGG' to the format
+ // (eg: for uint32-rgb, '#123456' becomes 0x123456)
+ //
+ // toHex converts from the format to '#RRGGBB'
+ // (eg: for uint8-rgb, [16, 33, 50] becomes '#102132')
+ //
+ //
+ // fromStr/toStr convert from/to what's in the input[type=text] element
+ //
+ // toStr converts from the format to its string representation
+ // (eg, for object-rgb, {r: 1, g: 0.5, b:0} becomes "{r: 1, g: 0.5, b:0}")
+ // ^object ^string
+ //
+ // fromStr converts its string representation to its format
+ // (eg, for object-rgb) "{r: 1, g: 0.5, b:0}" becomes {r: 1, g: 0.5, b:0})
+ // ^string ^object
+ // fromString returns an array which is [valid, v]
+ // where valid is true if the string was a valid and v is the converted
+ // format if v is true.
+ //
+ // Note: toStr should convert to "ideal" form (whatever that is).
+ // (eg, for css-rgb
+ // "{ r: 0.10000, g: 001, b: 0}" becomes "{r: 0.1, g: 1, b: 0}"
+ // notice that css-rgb is a string to a string
+ // )
+ const colorFormatConverters = {
+ 'hex6': {
+ color: {
+ from: v => [true, v],
+ to: fixHex6,
+ },
+ text: {
+ from: v => [hex6RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex8': {
+ color: {
+ from: v => [true, v],
+ to: fixHex8,
+ },
+ text: {
+ from: v => [hex8RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex3': {
+ color: {
+ from: v => [true, fixHex3(v)],
+ to: hex3ToHex6,
+ },
+ text: {
+ from: v => [hex6RE.test(v), hex6ToHex3(v.trim())],
+ to: v => v,
+ },
+ },
+ 'hex6-no-hash': {
+ color: {
+ from: v => [true, v.substring(1)],
+ to: v => `#${fixHex6(v)}`,
+ },
+ text: {
+ from: v => [hexNoHash6RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex8-no-hash': {
+ color: {
+ from: v => [true, v.substring(1)],
+ to: v => `#${fixHex8(v)}`,
+ },
+ text: {
+ from: v => [hexNoHash8RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex3-no-hash': {
+ color: {
+ from: v => [true, fixHex3(v).substring(1)],
+ to: hex3ToHex6,
+ },
+ text: {
+ from: v => [hexNoHash6RE.test(v), hex6ToHex3(v.trim())],
+ to: v => v,
+ },
+ },
+ 'uint32-rgb': {
+ color: {
+ from: v => [true, hexToUint32RGB(v)],
+ to: uint32RGBToHex,
+ },
+ text: {
+ from: v => strToUint32RGB(v),
+ to: v => `0x${v.toString(16).padStart(6, '0')}`,
+ },
+ },
+ 'uint32-rgba': {
+ color: {
+ from: v => [true, hexToUint32RGBA(v)],
+ to: uint32RGBAToHex,
+ },
+ text: {
+ from: v => strToUint32RGBA(v),
+ to: v => `0x${v.toString(16).padStart(8, '0')}`,
+ },
+ },
+ 'uint8-rgb': {
+ color: {
+ from: v => [true, hexToUint8RGB(v)],
+ to: uint8RGBToHex,
+ },
+ text: {
+ from: strTo3Ints,
+ to: v => v.join(', '),
+ },
+ },
+ 'uint8-rgba': {
+ color: {
+ from: v => [true, hexToUint8RGBA(v)],
+ to: uint8RGBAToHex,
+ },
+ text: {
+ from: strTo4Ints,
+ to: v => v.join(', '),
+ },
+ },
+ 'float-rgb': {
+ color: {
+ from: v => [true, hexToFloatRGB(v)],
+ to: floatRGBToHex,
+ },
+ text: {
+ from: strTo3Floats,
+ // need Array.from because map of Float32Array makes a Float32Array
+ to: v => Array.from(v).map(v => f3(v)).join(', '),
+ },
+ },
+ 'float-rgba': {
+ color: {
+ from: v => [true, hexToFloatRGBA(v)],
+ to: floatRGBAToHex,
+ },
+ text: {
+ from: strTo4Floats,
+ // need Array.from because map of Float32Array makes a Float32Array
+ to: v => Array.from(v).map(v => f3(v)).join(', '),
+ },
+ },
+ 'object-rgb': {
+ color: {
+ from: v => [true, hexToObjectRGB(v)],
+ to: objectRGBToHex,
+ },
+ text: {
+ from: strToRGBObject,
+ to: rgbObjectToStr,
+ },
+ },
+ 'object-rgba': {
+ color: {
+ from: v => [true, hexToObjectRGBA(v)],
+ to: objectRGBAToHex,
+ },
+ text: {
+ from: strToRGBAObject,
+ to: rgbaObjectToStr,
+ },
+ },
+ 'css-rgb': {
+ color: {
+ from: v => [true, hexToCssRGB(v)],
+ to: cssRGBToHex,
+ },
+ text: {
+ from: strToCssRGB,
+ to: v => strToCssRGB(v)[1],
+ },
+ },
+ 'css-rgba': {
+ color: {
+ from: v => [true, hexToCssRGBA(v)],
+ to: cssRGBAToHex,
+ },
+ text: {
+ from: strToCssRGBA,
+ to: v => strToCssRGBA(v)[1],
+ },
+ },
+ 'css-hsl': {
+ color: {
+ from: v => [true, hexToCssHSL(v)],
+ to: cssHSLToHex,
+ },
+ text: {
+ from: strToCssHSL,
+ to: v => strToCssHSL(v)[1],
+ },
+ },
+ 'css-hsla': {
+ color: {
+ from: v => [true, hexToCssHSLA(v)],
+ to: cssHSLAToHex,
+ },
+ text: {
+ from: strToCssHSLA,
+ to: v => strToCssHSLA(v)[1],
+ },
+ },
+ };
+
+ class ElementView extends View {
+ constructor(tag, className) {
+ super(createElem(tag, {className}));
+ }
+ }
+
+ // TODO: remove this? Should just be user side
+ class Canvas extends LabelController {
+ #canvasElem;
+
+ constructor() {
+ super('muigui-canvas');
+ this.#canvasElem = this.add(
+ new ElementView('canvas', 'muigui-canvas'),
+ ).domElement;
+ }
+ get canvas() {
+ return this.#canvasElem;
+ }
+ }
+
+ class ColorView extends EditView {
+ #to;
+ #from;
+ #colorElem;
+ #skipUpdate;
+ #options = {
+ converters: identity,
+ };
+
+ constructor(setter, options) {
+ const colorElem = createElem('input', {
+ type: 'color',
+ onInput: () => {
+ const [valid, newV] = this.#from(colorElem.value);
+ if (valid) {
+ this.#skipUpdate = true;
+ setter.setValue(newV);
+ }
+ },
+ onChange: () => {
+ const [valid, newV] = this.#from(colorElem.value);
+ if (valid) {
+ this.#skipUpdate = true;
+ setter.setFinalValue(newV);
+ }
+ },
+ });
+ super(createElem('div', {}, [colorElem]));
+ this.setOptions(options);
+ this.#colorElem = colorElem;
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.#colorElem.value = this.#to(v);
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {converters: {to, from}} = this.#options;
+ this.#to = to;
+ this.#from = from;
+ return this;
+ }
+ }
+
+ class Color extends ValueController {
+ #colorView;
+ #textView;
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-color');
+ const format = options.format || guessFormat(this.getValue());
+ const {color, text} = colorFormatConverters[format];
+ this.#colorView = this.add(new ColorView(this, {converters: color}));
+ this.#textView = this.add(new TextView(this, {converters: text}));
+ this.updateDisplay();
+ }
+ setOptions(options) {
+ const {format} = options;
+ if (format) {
+ const {color, text} = colorFormatConverters[format];
+ this.#colorView.setOptions({converters: color});
+ this.#textView.setOptions({converters: text});
+ }
+ super.setOptions(options);
+ return this;
+ }
+ }
+
+ // This feels like it should be something else like
+ // gui.addController({className: 'muigui-divider')};
+ class Divider extends Controller {
+ constructor() {
+ super('muigui-divider');
+ }
+ }
+
+ class Container extends Controller {
+ #controllers;
+ #childDestController;
+
+ constructor(className) {
+ super(className);
+ this.#controllers = [];
+ this.#childDestController = this;
+ }
+ get children() {
+ return this.#controllers; // should we return a copy?
+ }
+ get controllers() {
+ return this.#controllers.filter(c => !(c instanceof Container));
+ }
+ get folders() {
+ return this.#controllers.filter(c => c instanceof Container);
+ }
+ reset(recursive = true) {
+ for (const controller of this.#controllers) {
+ if (!(controller instanceof Container) || recursive) {
+ controller.reset(recursive);
+ }
+ }
+ return this;
+ }
+ updateDisplay() {
+ for (const controller of this.#controllers) {
+ controller.updateDisplay();
+ }
+ return this;
+ }
+ remove(controller) {
+ const ndx = this.#controllers.indexOf(controller);
+ if (ndx >= 0) {
+ const c = this.#controllers.splice(ndx, 1);
+ const c0 = c[0];
+ const elem = c0.domElement;
+ elem.remove();
+ c0.setParent(null);
+ }
+ return this;
+ }
+ #addControllerImpl(controller) {
+ this.domElement.appendChild(controller.domElement);
+ this.#controllers.push(controller);
+ controller.setParent(this);
+ return controller;
+ }
+ addController(controller) {
+ return this.#childDestController.#addControllerImpl(controller);
+ }
+ pushContainer(container) {
+ this.addController(container);
+ this.#childDestController = container;
+ return container;
+ }
+ popContainer() {
+ this.#childDestController = this.#childDestController.parent;
+ return this;
+ }
+ }
+
+ class Folder extends Container {
+ #labelElem;
+
+ constructor(name = 'Controls', className = 'muigui-menu') {
+ super(className);
+ this.#labelElem = createElem('label');
+ this.addElem(createElem('button', {
+ type: 'button',
+ onClick: () => this.toggleOpen(),
+ }, [this.#labelElem]));
+ this.pushContainer(new Container());
+ this.name(name);
+ this.open();
+ }
+ open(open = true) {
+ this.domElement.classList.toggle('muigui-closed', !open);
+ this.domElement.classList.toggle('muigui-open', open);
+ return this;
+ }
+ close() {
+ return this.open(false);
+ }
+ name(name) {
+ this.#labelElem.textContent = name;
+ return this;
+ }
+ title(title) {
+ return this.name(title);
+ }
+ toggleOpen() {
+ this.open(!this.domElement.classList.contains('muigui-open'));
+ return this;
+ }
+ }
+
+ // This feels like it should be something else like
+ // gui.addDividing = new Controller()
+ class Label extends Controller {
+ constructor(text) {
+ super('muigui-label');
+ this.text(text);
+ }
+ text(text) {
+ this.domElement.textContent = text;
+ return this;
+ }
+ }
+
+ function noop$1() {
+ }
+
+ function computeRelativePosition(elem, event, start) {
+ const rect = elem.getBoundingClientRect();
+ const x = event.clientX - rect.left;
+ const y = event.clientY - rect.top;
+ const nx = x / rect.width;
+ const ny = y / rect.height;
+ start = start || [x, y];
+ const dx = x - start[0];
+ const dy = y - start[1];
+ const ndx = dx / rect.width;
+ const ndy = dy / rect.width;
+ return {x, y, nx, ny, dx, dy, ndx, ndy};
+ }
+
+ function addTouchEvents(elem, {onDown = noop$1, onMove = noop$1, onUp = noop$1}) {
+ let start;
+ const pointerMove = function (event) {
+ const e = {
+ type: 'move',
+ ...computeRelativePosition(elem, event, start),
+ };
+ onMove(e);
+ };
+
+ const pointerUp = function (event) {
+ elem.releasePointerCapture(event.pointerId);
+ elem.removeEventListener('pointermove', pointerMove);
+ elem.removeEventListener('pointerup', pointerUp);
+
+ document.body.style.backgroundColor = '';
+
+ onUp('up');
+ };
+
+ const pointerDown = function (event) {
+ elem.addEventListener('pointermove', pointerMove);
+ elem.addEventListener('pointerup', pointerUp);
+ elem.setPointerCapture(event.pointerId);
+
+ const rel = computeRelativePosition(elem, event);
+ start = [rel.x, rel.y];
+ onDown({
+ type: 'down',
+ ...rel,
+ });
+ };
+
+ elem.addEventListener('pointerdown', pointerDown);
+
+ return function () {
+ elem.removeEventListener('pointerdown', pointerDown);
+ };
+ }
+
+ const svg$3 = `
+
+
+
+`;
+
+ function connectFillTargets(elem) {
+ elem.querySelectorAll('[data-src]').forEach(srcElem => {
+ const id = getNewId();
+ srcElem.id = id;
+ elem.querySelectorAll(`[data-target=${srcElem.dataset.src}]`).forEach(targetElem => {
+ targetElem.setAttribute('fill', `url(#${id})`);
+ });
+ });
+ return elem;
+ }
+
+ // Was originally going to make alpha an option. Issue is
+ // hard coded conversions?
+ class ColorChooserView extends EditView {
+ #to;
+ #from;
+ #satLevelElem;
+ #circleElem;
+ #hueUIElem;
+ #hueElem;
+ #hueCursorElem;
+ #alphaUIElem;
+ #alphaElem;
+ #alphaCursorElem;
+ #hsva;
+ #skipHueUpdate;
+ #skipSatLevelUpdate;
+ #skipAlphaUpdate;
+ #options = {
+ converters: identity,
+ alpha: false,
+ };
+ #convertInternalToHex;
+ #convertHexToInternal;
+
+ constructor(setter, options) {
+ super(createElem('div', {
+ innerHTML: svg$3,
+ className: 'muigui-no-scroll',
+ }));
+ this.#satLevelElem = this.domElement.children[0];
+ this.#hueUIElem = this.domElement.children[1];
+ this.#alphaUIElem = this.domElement.children[2];
+ connectFillTargets(this.#satLevelElem);
+ connectFillTargets(this.#hueUIElem);
+ connectFillTargets(this.#alphaUIElem);
+ this.#circleElem = this.$('.muigui-color-chooser-circle');
+ this.#hueElem = this.$('[data-src=muigui-color-chooser-hue]');
+ this.#hueCursorElem = this.$('.muigui-color-chooser-hue-cursor');
+ this.#alphaElem = this.$('[data-src=muigui-color-chooser-alpha]');
+ this.#alphaCursorElem = this.$('.muigui-color-chooser-alpha-cursor');
+
+ const handleSatLevelChange = (e) => {
+ const s = clamp$1(e.nx, 0, 1);
+ const v = clamp$1(e.ny, 0, 1);
+ this.#hsva[1] = s;
+ this.#hsva[2] = (1 - v);
+ this.#skipHueUpdate = true;
+ this.#skipAlphaUpdate = true;
+ const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));
+ if (valid) {
+ setter.setValue(newV);
+ }
+ };
+
+ const handleHueChange = (e) => {
+ const h = clamp$1(e.nx, 0, 1);
+ this.#hsva[0] = h;
+ this.#skipSatLevelUpdate = true;
+ this.#skipAlphaUpdate = true;
+ const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));
+ if (valid) {
+ setter.setValue(newV);
+ }
+ };
+
+ const handleAlphaChange = (e) => {
+ const a = clamp$1(e.nx, 0, 1);
+ this.#hsva[3] = a;
+ this.#skipHueUpdate = true;
+ this.#skipSatLevelUpdate = true;
+ const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));
+ if (valid) {
+ setter.setValue(newV);
+ }
+ };
+
+ addTouchEvents(this.#satLevelElem, {
+ onDown: handleSatLevelChange,
+ onMove: handleSatLevelChange,
+ });
+ addTouchEvents(this.#hueUIElem, {
+ onDown: handleHueChange,
+ onMove: handleHueChange,
+ });
+ addTouchEvents(this.#alphaUIElem, {
+ onDown: handleAlphaChange,
+ onMove: handleAlphaChange,
+ });
+ this.setOptions(options);
+ }
+ updateDisplay(newV) {
+ if (!this.#hsva) {
+ this.#hsva = this.#convertHexToInternal(this.#to(newV));
+ }
+ {
+ const [h, s, v, a = 1] = this.#convertHexToInternal(this.#to(newV));
+ // Don't copy the hue if it was un-computable.
+ if (!this.#skipHueUpdate) {
+ this.#hsva[0] = s > 0.001 && v > 0.001 ? h : this.#hsva[0];
+ }
+ if (!this.#skipSatLevelUpdate) {
+ this.#hsva[1] = s;
+ this.#hsva[2] = v;
+ }
+ if (!this.#skipAlphaUpdate) {
+ this.#hsva[3] = a;
+ }
+ }
+ {
+ const [h, s, v, a] = this.#hsva;
+ const [hue, sat, lum] = rgbaFloatToHsla01(hsva01ToRGBAFloat(this.#hsva));
+
+ if (!this.#skipHueUpdate) {
+ this.#hueCursorElem.setAttribute('transform', `translate(${h * 64}, 0)`);
+ }
+ this.#hueElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} 0% 100% / ${a})`);
+ this.#hueElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} 100% 50% / ${a})`);
+ if (!this.#skipAlphaUpdate) {
+ this.#alphaCursorElem.setAttribute('transform', `translate(${a * 64}, 0)`);
+ }
+ this.#alphaElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 0)`);
+ this.#alphaElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 1)`);
+
+ if (!this.#skipSatLevelUpdate) {
+ this.#circleElem.setAttribute('cx', `${s * 64}`);
+ this.#circleElem.setAttribute('cy', `${(1 - v) * 48}`);
+ }
+ }
+ this.#skipHueUpdate = false;
+ this.#skipSatLevelUpdate = false;
+ this.#skipAlphaUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {converters: {to, from}, alpha} = this.#options;
+ this.#alphaUIElem.style.display = alpha ? '' : 'none';
+ this.#convertInternalToHex = alpha
+ ? v => floatRGBAToHex(hsva01ToRGBAFloat(v))
+ : v => floatRGBToHex(hsv01ToRGBFloat(v));
+ this.#convertHexToInternal = alpha
+ ? v => rgbaFloatToHSVA01(hexToFloatRGBA(v))
+ : v => rgbFloatToHSV01(hexToFloatRGB(v));
+ this.#to = to;
+ this.#from = from;
+ return this;
+ }
+ }
+
+ /*
+
+ holder = new TabHolder
+ tab = holder.add(new Tab("name"))
+ tab.add(...)
+
+
+ pc = new PopdownController
+ top = pc.add(new Row())
+ top.add(new Button());
+ values = topRow.add(new Div())
+ bottom = pc.add(new Row());
+
+
+
+ pc = new PopdownController
+ pc.addTop
+ pc.addTop
+
+ pc.addBottom
+
+
+ */
+
+ class PopDownController extends ValueController {
+ #top;
+ #valuesView;
+ #checkboxElem;
+ #bottom;
+ #options = {
+ open: false,
+ };
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-pop-down-controller');
+ /*
+ [ValueView
+ [[B][values]] upper row
+ [[ visual ]] lower row
+ ]
+ */
+ this.#top = this.add(new ElementView('div', 'muigui-pop-down-top'));
+ // this.#top.add(new CheckboxView(makeSetter(this.#options, 'open')));
+ const checkboxElem = this.#top.addElem(createElem('input', {
+ type: 'checkbox',
+ onChange: () => {
+ this.#options.open = checkboxElem.checked;
+ this.updateDisplay();
+ },
+ }));
+ this.#checkboxElem = checkboxElem;
+ this.#valuesView = this.#top.add(new ElementView('div', 'muigui-pop-down-values'));
+ this.#bottom = this.add(new ElementView('div', 'muigui-pop-down-bottom'));
+ this.setOptions(options);
+ }
+ setKnobColor(bgCssColor/*, fgCssColor*/) {
+ if (this.#checkboxElem) {
+ this.#checkboxElem.style = `
+ --range-color: ${bgCssColor};
+ --value-bg-color: ${bgCssColor};
+ `;
+ }
+ }
+ updateDisplay() {
+ super.updateDisplay();
+ const {open} = this.#options;
+ this.domElement.children[1].classList.toggle('muigui-open', open);
+ this.domElement.children[1].classList.toggle('muigui-closed', !open);
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ super.setOptions(options);
+ this.updateDisplay();
+ }
+ addTop(view) {
+ return this.#valuesView.add(view);
+ }
+ addBottom(view) {
+ return this.#bottom.add(view);
+ }
+ }
+
+ /* eslint-disable no-underscore-dangle */
+
+ class ColorChooser extends PopDownController {
+ #colorView;
+ #textView;
+ #to;
+ #setKnobHelper;
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-color-chooser');
+ const format = options.format || guessFormat(this.getValue());
+ const {color, text} = colorFormatConverters[format];
+ this.#to = color.to;
+ this.#textView = new TextView(this, {converters: text, alpha: hasAlpha(format)});
+ this.#colorView = new ColorChooserView(this, {converters: color, alpha: hasAlpha(format)});
+ this.addTop(this.#textView);
+ this.addBottom(this.#colorView);
+ // WTF! FIX!
+ this.#setKnobHelper = () => {
+ if (this.#to) {
+ const hex6Or8 = this.#to(this.getValue());
+ const hsl = rgbUint8ToHsl(hexToUint8RGB(hex6Or8));
+ hsl[2] = (hsl[2] + 50) % 100;
+ const hex = uint8RGBToHex(hslToRgbUint8(hsl));
+ this.setKnobColor(`${hex6Or8.substring(0, 7)}FF`, hex);
+ }
+ };
+ this.updateDisplay();
+ }
+ updateDisplay() {
+ super.updateDisplay();
+ if (this.#setKnobHelper) {
+ this.#setKnobHelper();
+ }
+ }
+ setOptions(options) {
+ super.setOptions(options);
+ return this;
+ }
+ }
+
+ function showCSS(ob) {
+ if (ob.prototype.css) {
+ showCSS(ob.prototype);
+ }
+ }
+
+ class Layout extends View {
+ static css = 'bar';
+ constructor(tag, className) {
+ super(createElem(tag, {className}));
+
+ showCSS(this);
+ }
+ }
+
+ /*
+ class ValueController ?? {
+ const row = this.add(new Row());
+ const label = row.add(new Label());
+ const div = row.add(new Div());
+ const row = div.add(new Row());
+ }
+ */
+
+ /*
+ class MyCustomThing extends ValueController {
+ constructor(object, property, options) {
+ const topRow = this.add(new Row());
+ const bottomRow = this.add(new Row());
+ topRow.add(new NumberView());
+ topRow.add(new NumberView());
+ topRow.add(new NumberView());
+ topRow.add(new NumberView());
+ bottomRow.add(new DirectionView());
+ bottomRow.add(new DirectionView());
+ bottomRow.add(new DirectionView());
+ bottomRow.add(new DirectionView());
+ }
+ }
+ new Grid([
+ [new
+ ]
+ */
+
+ class Column extends Layout {
+ constructor() {
+ super('div', 'muigui-row');
+ }
+ }
+
+ class Frame extends Layout {
+ static css = 'foo';
+ constructor() {
+ super('div', 'muigui-frame');
+ }
+ static get foo() {
+ return 'boo';
+ }
+ }
+
+ class Grid extends Layout {
+ constructor() {
+ super('div', 'muigui-grid');
+ }
+ }
+
+ class Row extends Layout {
+ constructor() {
+ super('div', 'muigui-row');
+ }
+ }
+
+ class GUIFolder extends Folder {
+ add(object, property, ...args) {
+ const controller = object instanceof Controller
+ ? object
+ : createController(object, property, ...args);
+ return this.addController(controller);
+ }
+ addCanvas(name) {
+ return this.addController(new Canvas(name));
+ }
+ addColor(object, property, options = {}) {
+ const value = object[property];
+ if (hasAlpha(options.format || guessFormat(value))) {
+ return this.addController(new ColorChooser(object, property, options));
+ } else {
+ return this.addController(new Color(object, property, options));
+ }
+ }
+ addDivider() {
+ return this.addController(new Divider());
+ }
+ addFolder(name) {
+ return this.addController(new GUIFolder(name));
+ }
+ addLabel(text) {
+ return this.addController(new Label(text));
+ }
+ }
+
+ class MuiguiElement extends HTMLElement {
+ constructor() {
+ super();
+ this.shadow = this.attachShadow({mode: 'open'});
+ }
+ }
+
+ customElements.define('muigui-element', MuiguiElement);
+
+ const baseStyleSheet = new CSSStyleSheet();
+ baseStyleSheet.replaceSync(css.default);
+ const userStyleSheet = new CSSStyleSheet();
+
+ function makeStyleSheetUpdater(styleSheet) {
+ let newCss;
+ let newCssPromise;
+
+ function updateStyle() {
+ if (newCss && !newCssPromise) {
+ const s = newCss;
+ newCss = undefined;
+ newCssPromise = styleSheet.replace(s).then(() => {
+ newCssPromise = undefined;
+ updateStyle();
+ });
+ }
+ }
+
+ return function updateStyleSheet(css) {
+ newCss = css;
+ updateStyle();
+ };
+ }
+
+ const updateBaseStyle = makeStyleSheetUpdater(baseStyleSheet);
+ const updateUserStyle = makeStyleSheetUpdater(userStyleSheet);
+
+ class GUI extends GUIFolder {
+ static converters = converters;
+ static mapRange = mapRange;
+ static makeRangeConverters = makeRangeConverters;
+ static makeRangeOptions = makeRangeOptions;
+ static makeMinMaxPair = makeMinMaxPair;
+ #localStyleSheet = new CSSStyleSheet();
+
+ constructor(options = {}) {
+ super('Controls', 'muigui-root');
+ if (options instanceof HTMLElement) {
+ options = {parent: options};
+ }
+ const {
+ autoPlace = true,
+ width,
+ title = 'Controls',
+ } = options;
+ let {
+ parent,
+ } = options;
+
+ if (width) {
+ this.domElement.style.width = /^\d+$/.test(width) ? `${width}px` : width;
+ }
+ if (parent === undefined && autoPlace) {
+ parent = document.body;
+ this.domElement.classList.add('muigui-auto-place');
+ }
+ if (parent) {
+ const muiguiElement = createElem('muigui-element');
+ muiguiElement.shadowRoot.adoptedStyleSheets = [baseStyleSheet, userStyleSheet, this.#localStyleSheet];
+ muiguiElement.shadow.appendChild(this.domElement);
+ parent.appendChild(muiguiElement);
+ }
+ if (title) {
+ this.title(title);
+ }
+ this.domElement.classList.add('muigui', 'muigui-colors');
+ }
+ setStyle(css) {
+ this.#localStyleSheet.replace(css);
+ }
+ static setBaseStyles(css) {
+ updateBaseStyle(css);
+ }
+ static getBaseStyleSheet() {
+ return baseStyleSheet;
+ }
+ static setUserStyles(css) {
+ updateUserStyle(css);
+ }
+ static getUserStyleSheet() {
+ return userStyleSheet;
+ }
+ static setTheme(name) {
+ GUI.setBaseStyles(`${css.default}\n${css.themes[name] || ''}`);
+ }
+ }
+
+ function noop() {
+ }
+
+ const keyDirections = {
+ ArrowLeft: [-1, 0],
+ ArrowRight: [1, 0],
+ ArrowUp: [0, -1],
+ ArrowDown: [0, 1],
+ };
+
+ // This probably needs to be global
+ function addKeyboardEvents(elem, {onDown = noop, onUp = noop}) {
+ const keyDown = function (event) {
+ const mult = event.shiftKey ? 10 : 1;
+ const [dx, dy] = (keyDirections[event.key] || [0, 0]).map(v => v * mult);
+ const fn = event.type === 'keydown' ? onDown : onUp;
+ fn({
+ type: event.type.substring(3),
+ dx,
+ dy,
+ event,
+ });
+ };
+
+ elem.addEventListener('keydown', keyDown);
+ elem.addEventListener('keyup', keyDown);
+
+ return function () {
+ elem.removeEventListener('keydown', keyDown);
+ elem.removeEventListener('keyup', keyDown);
+ };
+ }
+
+ function assert(truthy, msg = '') {
+ if (!truthy) {
+ throw new Error(msg);
+ }
+ }
+
+ function getEllipsePointForAngle(cx, cy, rx, ry, phi, theta) {
+ const m = Math.abs(rx) * Math.cos(theta);
+ const n = Math.abs(ry) * Math.sin(theta);
+
+ return [
+ cx + Math.cos(phi) * m - Math.sin(phi) * n,
+ cy + Math.sin(phi) * m + Math.cos(phi) * n,
+ ];
+ }
+
+ function getEndpointParameters(cx, cy, rx, ry, phi, theta, dTheta) {
+ const [x1, y1] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta);
+ const [x2, y2] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta + dTheta);
+
+ const fa = Math.abs(dTheta) > Math.PI ? 1 : 0;
+ const fs = dTheta > 0 ? 1 : 0;
+
+ return { x1, y1, x2, y2, fa, fs };
+ }
+
+ function arc(cx, cy, r, start, end) {
+ assert(Math.abs(start - end) <= Math.PI * 2);
+ assert(start >= -Math.PI && start <= Math.PI * 2);
+ assert(start <= end);
+ assert(end >= -Math.PI && end <= Math.PI * 4);
+
+ const { x1, y1, x2, y2, fa, fs } = getEndpointParameters(cx, cy, r, r, 0, start, end - start);
+ return Math.abs(Math.abs(start - end) - Math.PI * 2) > Number.EPSILON
+ ? `M${cx} ${cy} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2} L${cx} ${cy}`
+ : `M${x1} ${y1} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2}`;
+ }
+
+ const svg$2 = `
+
+`;
+
+ const twoPiMod = v => euclideanModulo$1(v + Math.PI, Math.PI * 2) - Math.PI;
+
+ class DirectionView extends EditView {
+ #arrowElem;
+ #rangeElem;
+ #lastV;
+ #wrap;
+ #options = {
+ step: 1,
+ min: -180,
+ max: 180,
+
+ /*
+ --------
+ / -π/2 \
+ / | \
+ |<- -π * |
+ | * 0 ->| zero is down the positive X axis
+ |<- +π * |
+ \ | /
+ \ π/2 /
+ --------
+ */
+ dirMin: -Math.PI,
+ dirMax: Math.PI,
+ //dirMin: Math.PI * 0.5,
+ //dirMax: Math.PI * 2.5,
+ //dirMin: -Math.PI * 0.75, // test 10:30 to 7:30
+ //dirMax: Math.PI * 0.75,
+ //dirMin: Math.PI * 0.75, // test 7:30 to 10:30
+ //dirMax: -Math.PI * 0.75,
+ //dirMin: -Math.PI * 0.75, // test 10:30 to 1:30
+ //dirMax: -Math.PI * 0.25,
+ //dirMin: Math.PI * 0.25, // test 4:30 to 7:30
+ //dirMax: Math.PI * 0.75,
+ //dirMin: Math.PI * 0.75, // test 4:30 to 7:30
+ //dirMax: Math.PI * 0.25,
+ wrap: undefined,
+ converters: identity,
+ };
+
+ constructor(setter, options = {}) {
+ const wheelHelper = createWheelHelper();
+ super(createElem('div', {
+ className: 'muigui-direction muigui-no-scroll',
+ innerHTML: svg$2,
+ onWheel: e => {
+ e.preventDefault();
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ let tempV = this.#lastV + delta;
+ if (this.#wrap) {
+ tempV = euclideanModulo$1(tempV - min, max - min) + min;
+ }
+ const newV = clamp$1(stepify(tempV, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ const handleTouch = (e) => {
+ const {min, max, step, dirMin, dirMax} = this.#options;
+ const nx = e.nx * 2 - 1;
+ const ny = e.ny * 2 - 1;
+ const a = Math.atan2(ny, nx);
+
+ const center = (dirMin + dirMax) / 2;
+
+ const centeredAngle = twoPiMod(a - center);
+ const centeredStart = twoPiMod(dirMin - center);
+ const diff = dirMax - dirMin;
+
+ const n = clamp$1((centeredAngle - centeredStart) / (diff), 0, 1);
+ const newV = stepify(min + (max - min) * n, v => v, step);
+ setter.setValue(newV);
+ };
+ addTouchEvents(this.domElement, {
+ onDown: handleTouch,
+ onMove: handleTouch,
+ });
+ addKeyboardEvents(this.domElement, {
+ onDown: (e) => {
+ const {min, max, step} = this.#options;
+ const newV = clamp$1(stepify(this.#lastV + e.dx * step, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ });
+ this.#arrowElem = this.$('#muigui-arrow');
+ this.#rangeElem = this.$('#muigui-range');
+ this.setOptions(options);
+ }
+ updateDisplay(v) {
+ this.#lastV = v;
+ const {min, max} = this.#options;
+ const n = (v - min) / (max - min);
+ const angle = lerp$1(this.#options.dirMin, this.#options.dirMax, n);
+ this.#arrowElem.style.transform = `rotate(${angle}rad)`;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {dirMin, dirMax, wrap} = this.#options;
+ this.#wrap = wrap !== undefined
+ ? wrap
+ : Math.abs(dirMin - dirMax) >= Math.PI * 2 - Number.EPSILON;
+ const [min, max] = dirMin < dirMax ? [dirMin, dirMax] : [dirMax , dirMin];
+ this.#rangeElem.setAttribute('d', arc(0, 0, 28.87, min, max));
+ }
+ }
+
+ // deg2rad
+ // where is 0
+ // range (0, 360), (-180, +180), (0,0) Really this is a range
+
+ class Direction extends PopDownController {
+ #options;
+ constructor(object, property, options) {
+ super(object, property, 'muigui-direction');
+ this.#options = options; // FIX
+ this.addTop(new NumberView(this,
+ identity));
+ this.addBottom(new DirectionView(this, options));
+ this.updateDisplay();
+ }
+ }
+
+ class RadioGridView extends EditView {
+ #values;
+
+ constructor(setter, keyValues, cols = 3) {
+ const values = [];
+ const name = makeId();
+ super(createElem('div', {}, keyValues.map(([key, value], ndx) => {
+ values.push(value);
+ return createElem('label', {}, [
+ createElem('input', {
+ type: 'radio',
+ name,
+ value: ndx,
+ onChange: function () {
+ if (this.checked) {
+ setter.setFinalValue(that.#values[this.value]);
+ }
+ },
+ }),
+ createElem('button', {
+ type: 'button',
+ textContent: key,
+ onClick: function () {
+ this.previousElementSibling.click();
+ },
+ }),
+ ]);
+ })));
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ const that = this;
+ this.#values = values;
+ this.cols(cols);
+ }
+ updateDisplay(v) {
+ const ndx = this.#values.indexOf(v);
+ for (let i = 0; i < this.domElement.children.length; ++i) {
+ this.domElement.children[i].children[0].checked = i === ndx;
+ }
+ }
+ cols(cols) {
+ this.domElement.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
+ }
+ }
+
+ class RadioGrid extends ValueController {
+ constructor(object, property, options) {
+ super(object, property, 'muigui-radio-grid');
+ const valueIsNumber = typeof this.getValue() === 'number';
+ const {
+ keyValues: keyValuesInput,
+ cols = 3,
+ } = options;
+ const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);
+ this.add(new RadioGridView(this, keyValues, cols));
+ this.updateDisplay();
+ }
+ }
+
+ function onResize(elem, callback) {
+ new ResizeObserver(() => {
+ callback({rect: elem.getBoundingClientRect(), elem});
+ }).observe(elem);
+ }
+
+ function onResizeSVGNoScale(elem, hAnchor, vAnchor, callback) {
+ onResize(elem, ({rect}) => {
+ const {width, height} = rect;
+ elem.setAttribute('viewBox', `-${width * hAnchor} -${height * vAnchor} ${width} ${height}`);
+ callback({elem, rect});
+ });
+ }
+
+ function onResizeCanvas(elem, callback) {
+ onResize(elem, ({rect}) => {
+ const {width, height} = rect;
+ elem.width = width;
+ elem.height = height;
+ callback({elem, rect});
+ });
+ }
+
+ const svg$1 = `
+
+`;
+
+ function createSVGTicks(start, end, step, min, max, height) {
+ const p = [];
+ if (start < min) {
+ start += stepify(min - start, v => v, step);
+ }
+ end = Math.min(end, max);
+ for (let i = start; i <= end; i += step) {
+ p.push(`M${i} 0 l0 ${height}`);
+ }
+ return p.join(' ');
+ }
+
+ function createSVGNumbers(start, end, unitSize, unit, minusSize, min, max, labelFn) {
+ const texts = [];
+ if (start < min) {
+ start += stepify(min - start, v => v, unitSize);
+ }
+ end = Math.min(end, max);
+ const digits = Math.max(0, -Math.log10(unit));
+ const f = v => labelFn(v.toFixed(digits));
+ for (let i = start; i <= end; i += unitSize) {
+ texts.push(`${f(i / unitSize * unit)}`);
+ }
+ return texts.join('\n');
+ }
+
+ function computeSizeOfMinus(elem) {
+ const oldHTML = elem.innerHTML;
+ elem.innerHTML = '- ';
+ const text = elem.querySelector('text');
+ const size = text.getComputedTextLength();
+ elem.innerHTML = oldHTML;
+ return size;
+ }
+
+ class SliderView extends EditView {
+ #svgElem;
+ #originElem;
+ #ticksElem;
+ #thicksElem;
+ #numbersElem;
+ #leftGradElem;
+ #rightGradElem;
+ #width;
+ #height;
+ #lastV;
+ #minusSize;
+ #options = {
+ min: -100,
+ max: 100,
+ step: 1,
+ unit: 10,
+ unitSize: 10,
+ ticksPerUnit: 5,
+ labelFn: v => v,
+ tickHeight: 1,
+ limits: true,
+ thicksColor: undefined,
+ orientation: undefined,
+ };
+
+ constructor(setter, options) {
+ const wheelHelper = createWheelHelper();
+ super(createElem('div', {
+ innerHTML: svg$1,
+ className: 'muigui-no-v-scroll',
+ onWheel: e => {
+ e.preventDefault();
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ const newV = clamp$1(stepify(this.#lastV + delta, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ this.#svgElem = this.$('svg');
+ this.#originElem = this.$('#muigui-origin');
+ this.#ticksElem = this.$('#muigui-ticks');
+ this.#thicksElem = this.$('#muigui-thicks');
+ this.#numbersElem = this.$('#muigui-numbers');
+ this.#leftGradElem = this.$('#muigui-left-grad');
+ this.#rightGradElem = this.$('#muigui-right-grad');
+ this.setOptions(options);
+ let startV;
+ addTouchEvents(this.domElement, {
+ onDown: () => {
+ startV = this.#lastV;
+ },
+ onMove: (e) => {
+ const {min, max, unitSize, unit, step} = this.#options;
+ const newV = clamp$1(stepify(startV - e.dx / unitSize * unit, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ });
+ addKeyboardEvents(this.domElement, {
+ onDown: (e) => {
+ const {min, max, step} = this.#options;
+ const newV = clamp$1(stepify(this.#lastV + e.dx * step, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ });
+ onResizeSVGNoScale(this.#svgElem, 0.5, 0, ({rect: {width}}) => {
+ this.#leftGradElem.setAttribute('x', -width / 2);
+ this.#rightGradElem.setAttribute('x', width / 2 - 20);
+ this.#minusSize = computeSizeOfMinus(this.#numbersElem);
+ this.#width = width;
+ this.#updateSlider();
+ });
+ }
+ // |--------V--------|
+ // . . | . . . | . . . |
+ //
+ #updateSlider() {
+ // There's no size if ResizeObserver has not fired yet.
+ if (!this.#width || this.#lastV === undefined) {
+ return;
+ }
+ const {
+ labelFn,
+ limits,
+ min,
+ max,
+ orientation,
+ tickHeight,
+ ticksPerUnit,
+ unit,
+ unitSize,
+ thicksColor,
+ } = this.#options;
+ const unitsAcross = Math.ceil(this.#width / unitSize);
+ const center = this.#lastV;
+ const centerUnitSpace = center / unit;
+ const startUnitSpace = Math.round(centerUnitSpace - unitsAcross);
+ const endUnitSpace = startUnitSpace + unitsAcross * 2;
+ const start = startUnitSpace * unitSize;
+ const end = endUnitSpace * unitSize;
+ const minUnitSpace = limits ? min * unitSize / unit : start;
+ const maxUnitSpace = limits ? max * unitSize / unit : end;
+ const height = labelFn(1) === '' ? 10 : 5;
+ if (ticksPerUnit > 1) {
+ this.#ticksElem.setAttribute('d', createSVGTicks(start, end, unitSize / ticksPerUnit, minUnitSpace, maxUnitSpace, height * tickHeight));
+ }
+ this.#thicksElem.style.stroke = thicksColor; //setAttribute('stroke', thicksColor);
+ this.#thicksElem.setAttribute('d', createSVGTicks(start, end, unitSize, minUnitSpace, maxUnitSpace, height));
+ this.#numbersElem.innerHTML = createSVGNumbers(start, end, unitSize, unit, this.#minusSize, minUnitSpace, maxUnitSpace, labelFn);
+ this.#originElem.setAttribute('transform', `translate(${-this.#lastV * unitSize / unit} 0)`);
+ this.#svgElem.classList.toggle('muigui-slider-up', orientation === 'up');
+ }
+ updateDisplay(v) {
+ this.#lastV = v;
+ this.#updateSlider();
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ return this;
+ }
+ }
+
+ class Slider extends ValueController {
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-slider');
+ this.add(new SliderView(this, options));
+ this.add(new NumberView(this, options));
+ this.updateDisplay();
+ }
+ }
+
+ const svg = `
+
+`;
+
+ class Vec2View extends EditView {
+ #svgElem;
+ #arrowElem;
+ #circleElem;
+ #lastV = [];
+
+ constructor(setter) {
+ super(createElem('div', {
+ innerHTML: svg,
+ className: 'muigui-no-scroll',
+ }));
+ const onTouch = (e) => {
+ const {width, height} = this.#svgElem.getBoundingClientRect();
+ const nx = e.nx * 2 - 1;
+ const ny = e.ny * 2 - 1;
+ setter.setValue([nx * width * 0.5, ny * height * 0.5]);
+ };
+ addTouchEvents(this.domElement, {
+ onDown: onTouch,
+ onMove: onTouch,
+ });
+ this.#svgElem = this.$('svg');
+ this.#arrowElem = this.$('#muigui-arrow');
+ this.#circleElem = this.$('#muigui-circle');
+ onResizeSVGNoScale(this.#svgElem, 0.5, 0.5, () => this.#updateDisplayImpl);
+ }
+ #updateDisplayImpl() {
+ const [x, y] = this.#lastV;
+ this.#arrowElem.setAttribute('d', `M0,0L${x},${y}`);
+ this.#circleElem.setAttribute('transform', `translate(${x}, ${y})`);
+ }
+ updateDisplay(v) {
+ this.#lastV[0] = v[0];
+ this.#lastV[1] = v[1];
+ this.#updateDisplayImpl();
+ }
+ }
+
+ // TODO: zoom with wheel and pinch?
+ // TODO: grid?
+ // // options
+ // scale:
+ // range: number (both x and y + /)
+ // range: array (min, max)
+ // xRange:
+ // deg/rad/turn
+
+ class Vec2 extends PopDownController {
+ constructor(object, property) {
+ super(object, property, 'muigui-vec2');
+
+ const makeSetter = (ndx) => {
+ return {
+ setValue: (v) => {
+ const newV = this.getValue();
+ newV[ndx] = v;
+ this.setValue(newV);
+ },
+ setFinalValue: (v) => {
+ const newV = this.getValue();
+ newV[ndx] = v;
+ this.setFinalValue(newV);
+ },
+ };
+ };
+
+ this.addTop(new NumberView(makeSetter(0), {
+ converters: {
+ to: v => v[0],
+ from: strToNumber.from,
+ },
+ }));
+ this.addTop(new NumberView(makeSetter(1), {
+ converters: {
+ to: v => v[1],
+ from: strToNumber.from,
+ },
+ }));
+ this.addBottom(new Vec2View(this));
+ this.updateDisplay();
+ }
+ }
+
+ GUI.ColorChooser = ColorChooser;
+ GUI.Direction = Direction;
+ GUI.RadioGrid = RadioGrid;
+ GUI.Range = Range;
+ GUI.Select = Select;
+ GUI.Slider = Slider;
+ GUI.TextNumber = TextNumber;
+ GUI.Vec2 = Vec2;
+
+ return GUI;
+
+}));
+//# sourceMappingURL=muigui.js.map
diff --git a/dist/0.x/muigui.js.map b/dist/0.x/muigui.js.map
new file mode 100644
index 0000000..c0fb460
--- /dev/null
+++ b/dist/0.x/muigui.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"muigui.js","sources":["../../src/styles/muigui.css.js","../../src/libs/elem.js","../../src/libs/utils.js","../../../src/views/View.ts","../../src/controllers/Controller.js","../../src/controllers/Button.js","../../src/views/EditView.js","../../src/views/CheckboxView.js","../../src/libs/taskrunner.js","../../src/libs/ids.js","../../src/views/ValueView.js","../../src/controllers/LabelController.js","../../src/controllers/ValueController.js","../../src/controllers/Checkbox.js","../../src/libs/conversions.js","../../src/libs/wheel.js","../../src/views/NumberView.js","../../src/controllers/TextNumber.js","../../src/views/SelectView.js","../../src/libs/key-values.js","../../src/controllers/Select.js","../../src/views/RangeView.js","../../src/controllers/Range.js","../../src/views/TextView.js","../../src/controllers/Text.js","../../src/controllers/create-controller.js","../../src/libs/color-utils.js","../../src/views/ElementView.js","../../src/controllers/Canvas.js","../../src/views/ColorView.js","../../src/controllers/Color.js","../../src/controllers/Divider.js","../../src/controllers/Container.js","../../src/controllers/Folder.js","../../src/controllers/Label.js","../../src/libs/touch.js","../../src/views/ColorChooserView.js","../../src/controllers/PopDownController.js","../../src/controllers/ColorChooser.js","../../src/layout/Layout.js","../../src/layout/Column.js","../../src/layout/Frame.js","../../src/layout/Grid.js","../../src/layout/Row.js","../../src/muigui.js","../../src/libs/keyboard.js","../../src/libs/assert.js","../../src/libs/svg.js","../../src/views/DirectionView.js","../../src/controllers/Direction.js","../../src/views/RadioGridView.js","../../src/controllers/RadioGrid.js","../../src/libs/resize-helpers.js","../../src/views/SliderView.js","../../src/controllers/Slider.js","../../src/views/Vec2View.js","../../src/controllers/Vec2.js","../../src/umd.js"],"sourcesContent":["export default {\n default: `\n.muigui {\n --bg-color: #ddd;\n --color: #222;\n --contrast-color: #eee;\n --value-color: #145 ;\n --value-bg-color: #eeee;\n --disabled-color: #999;\n --menu-bg-color: #f8f8f8;\n --menu-sep-color: #bbb;\n --hover-bg-color: #999;\n --focus-color: #68C;\n --range-color: #888888;\n --invalid-color: #FF0000;\n --selected-color: rgb(255, 255, 255, 0.9);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n}\n\n@media (prefers-color-scheme: dark) {\n .muigui {\n --bg-color: #222222;\n --color: #dddddd;\n --contrast-color: #000;\n --value-color: #43e5f7;\n --value-bg-color: #444444;\n --disabled-color: #666666;\n --menu-bg-color: #080808;\n --menu-sep-color: #444444;\n --hover-bg-color: #666666;\n --focus-color: #88AAFF;\n --range-color: #888888;\n --invalid-color: #FF6666;\n --selected-color: rgba(255, 255, 255, 0.3);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n }\n}\n\n.muigui {\n --width: 250px;\n --label-width: 45%;\n --number-width: 40%;\n\n\n --font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Arial, sans-serif;\n --font-size: 11px;\n --font-family-mono: Menlo, Monaco, Consolas, \"Droid Sans Mono\", monospace;\n --font-size-mono: 11px;\n\n --line-height: 1.7em;\n --border-radius: 0px;\n\n width: var(--width);\n font-family: var(--font-family);\n font-size: var(--font-size);\n box-sizing: border-box;\n line-height: 100%;\n}\n.muigui * {\n box-sizing: inherit;\n}\n\n.muigui-no-scroll {\n touch-action: none;\n}\n.muigui-no-h-scroll {\n touch-action: pan-y;\n}\n.muigui-no-v-scroll {\n touch-action: pan-x;\n}\n\n.muigui-invalid-value {\n background-color: red !important;\n color: white !important;\n}\n\n.muigui-grid {\n display: grid;\n}\n.muigui-rows {\n display: flex;\n flex-direction: column;\n\n min-height: 20px;\n border: 2px solid red;\n}\n.muigui-columns {\n display: flex;\n flex-direction: row;\n\n height: 20px;\n border: 2px solid green;\n}\n.muigui-rows>*,\n.muigui-columns>* {\n flex: 1 1 auto;\n align-items: stretch;\n min-height: 0;\n min-width: 0;\n}\n\n.muigui-row {\n border: 2px solid yellow;\n min-height: 10px\n}\n.muigui-column {\n border: 2px solid lightgreen;\n}\n\n/* -------- */\n\n.muigui-show { /* */ }\n.muigui-hide { \n display: none !important;\n}\n.muigui-disabled {\n pointer-events: none;\n --color: var(--disabled-color) !important;\n --value-color: var(--disabled-color) !important;\n --range-left-color: var(--disabled-color) !important;\n}\n\n.muigui canvas,\n.muigui svg {\n display: block;\n border-radius: var(--border-radius);\n}\n.muigui canvas {\n background-color: var(--value-bg-color);\n}\n\n.muigui-controller {\n min-width: 0;\n min-height: var(--line-height);\n}\n.muigui-root,\n.muigui-menu {\n display: flex;\n flex-direction: column;\n position: relative;\n user-select: none;\n height: fit-content;\n margin: 0;\n padding-bottom: 0.1em;\n border-radius: var(--border-radius);\n}\n.muigui-menu {\n border-bottom: 1px solid var(--menu-sep-color);\n}\n\n.muigui-root>button:nth-child(1),\n.muigui-menu>button:nth-child(1) {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n position: relative;\n text-align: left;\n color: var(--color);\n background-color: var(--menu-bg-color);\n min-height: var(--line-height);\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n cursor: pointer;\n border-radius: var(--border-radius);\n}\n.muigui-root>div:nth-child(2),\n.muigui-menu>div:nth-child(2) {\n flex: 1 1 auto;\n}\n\n.muigui-controller {\n margin-left: 0.2em;\n margin-right: 0.2em;\n}\n.muigui-root.muigui-controller,\n.muigui-menu.muigui-controller {\n margin-left: 0;\n margin-right: 0;\n}\n.muigui-controller>*:nth-child(1) {\n flex: 1 0 var(--label-width);\n min-width: 0;\n white-space: pre;\n}\n.muigui-controller>label:nth-child(1) {\n place-content: center start;\n display: inline-grid;\n overflow: hidden;\n}\n.muigui-controller>*:nth-child(2) {\n flex: 1 1 75%;\n min-width: 0;\n}\n\n/* -----------------------------------------\n a label controller is [[label][value]]\n*/\n\n.muigui-label-controller {\n display: flex;\n margin: 0.4em 0 0.4em 0;\n word-wrap: initial;\n align-items: stretch;\n}\n\n.muigui-value {\n display: flex;\n align-items: stretch;\n}\n.muigui-value>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n.muigui-value>*:nth-child(1) {\n flex: 1 1 calc(100% - var(--number-width));\n}\n.muigui-value>*:nth-child(2) {\n flex: 1 1 var(--number-width);\n margin-left: 0.2em;\n}\n\n/* fix! */\n.muigui-open>button>label::before,\n.muigui-closed>button>label::before {\n width: 1.25em;\n height: var(--line-height);\n display: inline-grid;\n place-content: center start;\n pointer-events: none;\n}\n.muigui-open>button>label::before {\n content: \"ⓧ\"; /*\"▼\";*/\n}\n.muigui-closed>button>label::before {\n content: \"⨁\"; /*\"▶\";*/\n}\n.muigui-open>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 0.5s ease-out;\n max-height: 100vh;\n overflow: auto;\n opacity: 1;\n}\n\n.muigui-closed>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 1s;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n}\n\n/* ---- popdown ---- */\n\n.muigui-pop-down-top {\n display: flex;\n}\n/* fix? */\n.muigui-value>*:nth-child(1).muigui-pop-down-top {\n flex: 0;\n}\n.muigui-pop-down-bottom {\n\n}\n\n.muigui-pop-down-values {\n min-width: 0;\n display: flex;\n}\n.muigui-pop-down-values>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.muigui-value.muigui-pop-down-controller {\n flex-direction: column;\n}\n\n.muigui-pop-down-top input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-pop-down-top input[type=checkbox]::before {\n content: \"+\";\n display: grid;\n place-content: center;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n color: var(--value-bg-color);\n width: calc(var(--line-height) - 4px);\n height: calc(var(--line-height) - 4px);\n}\n\n.muigui-pop-down-top input[type=checkbox]:checked::before {\n content: \"X\";\n}\n\n\n/* ---- select ---- */\n\n.muigui select,\n.muigui option,\n.muigui input,\n.muigui button {\n color: var(--value-color);\n background-color: var(--value-bg-color);\n font-family: var(--font-family);\n font-size: var(--font-size);\n border: none;\n margin: 0;\n border-radius: var(--border-radius);\n}\n.muigui select {\n appearance: none;\n margin: 0;\n margin-left: 0; /*?*/\n overflow: hidden; /* Safari */\n}\n\n.muigui select:focus,\n.muigui input:focus,\n.muigui button:focus {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui select:hover,\n.muigui option:hover,\n.muigui input:hover,\n.muigui button:hover {\n background-color: var(--hover-bg-color); \n}\n\n/* ------ [ label ] ------ */\n\n.muigui-label {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n padding-top: 0.4em;\n padding-bottom: 0.3em;\n place-content: center start;\n background-color: var(--menu-bg-color);\n white-space: pre;\n border-radius: var(--border-radius);\n}\n\n/* ------ [ divider] ------ */\n\n.muigui-divider {\n min-height: 6px;\n border-top: 2px solid var(--menu-sep-color);\n margin-top: 6px;\n}\n\n/* ------ [ button ] ------ */\n\n.muigui-button {\n display: grid;\n\n}\n.muigui-button button {\n border: none;\n color: var(--value-color);\n background-color: var(--button-bg-color);\n cursor: pointer;\n place-content: center center;\n}\n\n/* ------ [ color ] ------ */\n\n.muigui-color>div {\n overflow: hidden;\n position: relative;\n margin-left: 0;\n margin-right: 0; /* why? */\n max-width: var(--line-height);\n border-radius: var(--border-radius);\n}\n\n.muigui-color>div:focus-within {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui-color input[type=color] {\n border: none;\n padding: 0;\n background: inherit;\n cursor: pointer;\n position: absolute;\n width: 200%;\n left: -10px;\n top: -10px;\n height: 200%;\n}\n.muigui-disabled canvas,\n.muigui-disabled svg,\n.muigui-disabled img,\n.muigui-disabled .muigui-color input[type=color] {\n opacity: 0.2;\n}\n\n/* ------ [ checkbox ] ------ */\n\n.muigui-checkbox>label:nth-child(2) {\n display: grid;\n place-content: center start;\n margin: 0;\n}\n\n.muigui-checkbox input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-checkbox input[type=checkbox]::before {\n content: \"\";\n color: var(--value-color);\n display: grid;\n place-content: center;\n}\n\n.muigui-checkbox input[type=checkbox]:checked::before {\n content: \"✔\";\n}\n\n.muigui input[type=number]::-webkit-inner-spin-button, \n.muigui input[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none;\n appearance: none;\n margin: 0; \n}\n.muigui input[type=number] {\n -moz-appearance: textfield;\n}\n\n/* ------ [ radio grid ] ------ */\n\n.muigui-radio-grid>div {\n display: grid;\n gap: 2px;\n}\n\n.muigui-radio-grid input {\n appearance: none;\n display: none;\n}\n\n.muigui-radio-grid button {\n color: var(--color);\n width: 100%;\n text-align: left;\n}\n\n.muigui-radio-grid input:checked + button {\n color: var(--value-color);\n background-color: var(--selected-color);\n}\n\n/* ------ [ color-chooser ] ------ */\n\n.muigui-color-chooser-cursor {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n.muigui-color-chooser-circle {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n\n\n/* ------ [ vec2 ] ------ */\n\n.muigui-vec2 svg {\n background-color: var(--value-bg-color);\n}\n\n.muigui-vec2-axis {\n stroke: 1px;\n stroke: var(--focus-color);\n}\n\n.muigui-vec2-line {\n stroke-width: 1px;\n stroke: var(--value-color);\n fill: var(--value-color);\n}\n\n/* ------ [ direction ] ------ */\n\n.muigui-direction svg {\n background-color: rgba(0,0,0,0.2);\n}\n\n.muigui-direction:focus-within svg {\n outline: none;\n}\n.muigui-direction-range {\n fill: var(--value-bg-color);\n}\n.muigui-direction svg:focus {\n outline: none;\n}\n.muigui-direction svg:focus .muigui-direction-range {\n stroke-width: 0.5px;\n stroke: var(--focus-color);\n}\n\n.muigui-direction-arrow {\n fill: var(--value-color);\n}\n\n/* ------ [ slider ] ------ */\n\n.muigui-slider>div {\n display: flex;\n align-items: stretch;\n height: var(--line-height);\n}\n.muigui-slider svg {\n flex: 1 1 auto;\n}\n.muigui-slider .muigui-slider-up #muigui-orientation {\n transform: scale(1, -1) translateY(-100%);\n}\n\n.muigui-slider .muigui-slider-up #muigui-number-orientation {\n transform: scale(1,-1);\n}\n\n.muigui-ticks {\n stroke: var(--range-color);\n}\n.muigui-thicks {\n stroke: var(--color);\n stroke-width: 2px;\n}\n.muigui-svg-text {\n fill: var(--color);\n font-size: 7px;\n}\n.muigui-mark {\n fill: var(--value-color);\n}\n\n/* ------ [ range ] ------ */\n\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: transparent;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n margin-top: calc((var(--line-height) - 2px) / -2);\n width: calc(var(--line-height) - 2px);\n height: calc(var(--line-height) - 2px);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n border: 1px solid var(--menu-sep-color);\n height: 2px;\n}\n\n\n/* dat.gui style - doesn't work on Safari iOS */\n\n/*\n.muigui-range input[type=range] {\n cursor: ew-resize;\n overflow: hidden;\n}\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: var(--range-right-color);\n margin: 0;\n}\n.muigui-range input[type=range]:hover {\n background-color: var(--range-right-hover-color);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n height: max-content;\n color: var(--range-left-color);\n margin-top: -1px;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0px;\n height: max-content;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n}\n*/\n\n/* FF */\n/*\n.muigui-range input[type=range]::-moz-slider-progress {\n background-color: var(--range-left-color); \n}\n.muigui-range input[type=range]::-moz-slider-thumb {\n height: max-content;\n width: 0;\n border: none;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n box-sizing: border-box;\n}\n*/\n\n.muigui-checkered-background {\n background-color: #404040;\n background-image:\n linear-gradient(45deg, #808080 25%, transparent 25%),\n linear-gradient(-45deg, #808080 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #808080 75%),\n linear-gradient(-45deg, transparent 75%, #808080 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0px;\n}\n\n/* ---------------------------------------------------------- */\n\n/* needs to be at bottom to take precedence */\n.muigui-auto-place {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 100001;\n}\n\n`,\nthemes: {\n default: '',\n float: `\n :root {\n color-scheme: light dark,\n }\n\n .muigui {\n --width: 400px;\n --bg-color: initial;\n --label-width: 25%;\n --number-width: 20%;\n }\n\n input,\n .muigui-label-controller>label {\n text-shadow:\n -1px -1px 0 var(--contrast-color),\n 1px -1px 0 var(--contrast-color),\n -1px 1px 0 var(--contrast-color),\n 1px 1px 0 var(--contrast-color);\n }\n\n .muigui-controller > label:nth-child(1) {\n place-content: center end;\n margin-right: 1em;\n }\n\n .muigui-value > :nth-child(2) {\n margin-left: 1em;\n }\n\n .muigui-root>*:nth-child(1) {\n display: none;\n }\n\n .muigui-range input[type=range]::-webkit-slider-thumb {\n border-radius: 1em;\n }\n\n .muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: initial;\n appearance: none;\n border: 1px solid rgba(0, 0, 0, 0.25);\n height: 2px;\n }\n\n .muigui-colors {\n --value-color: var(--color );\n --value-bg-color: rgba(0, 0, 0, 0.1);\n --disabled-color: #cccccc;\n --menu-bg-color: rgba(0, 0, 0, 0.1);\n --menu-sep-color: #bbbbbb;\n --hover-bg-color: rgba(0, 0, 0, 0);\n --invalid-color: #FF0000;\n --selected-color: rgba(0, 0, 0, 0.3);\n --range-color: rgba(0, 0, 0, 0.125);\n }\n`,\n},\n};\n","export function setElemProps(elem, attrs, children) {\n for (const [key, value] of Object.entries(attrs)) {\n if (typeof value === 'function' && key.startsWith('on')) {\n const eventName = key.substring(2).toLowerCase();\n elem.addEventListener(eventName, value, {passive: false});\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n elem[key][k] = v;\n }\n } else if (elem[key] === undefined) {\n elem.setAttribute(key, value);\n } else {\n elem[key] = value;\n }\n }\n for (const child of children) {\n elem.appendChild(child);\n }\n return elem;\n}\n\nexport function createElem(tag, attrs = {}, children = []) {\n const elem = document.createElement(tag);\n setElemProps(elem, attrs, children);\n return elem;\n}\n\nexport function addElem(tag, parent, attrs = {}, children = []) {\n const elem = createElem(tag, attrs, children);\n parent.appendChild(elem);\n return elem;\n}\n\nlet nextId = 0;\nexport function getNewId() {\n return `muigui-id-${nextId++}`;\n}\n","export function removeArrayElem(array, value) {\n const ndx = array.indexOf(value);\n if (ndx) {\n array.splice(ndx, 1);\n }\n return array;\n}\n\n/**\n * Converts an camelCase or snake_case id to \"camel case\" or \"snake case\"\n * @param {string} id\n */\nconst underscoreRE = /_/g;\nconst upperLowerRE = /([A-Z])([a-z])/g;\nexport function idToLabel(id) {\n return id.replace(underscoreRE, ' ')\n .replace(upperLowerRE, (m, m1, m2) => `${m1.toLowerCase()} ${m2}`);\n}\n\nexport function clamp(v, min, max) {\n return Math.max(min, Math.min(max, v));\n}\n\nexport const isTypedArray = typeof SharedArrayBuffer !== 'undefined'\n ? function isArrayBufferOrSharedArrayBuffer(a) {\n return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);\n }\n : function isArrayBuffer(a) {\n return a && a.buffer && a.buffer instanceof ArrayBuffer;\n };\n\nexport const isArrayOrTypedArray = v => Array.isArray(v) || isTypedArray(v);\n\n// Yea, I know this should be `Math.round(v / step) * step\n// but try step = 0.1, newV = 19.95\n//\n// I get\n// Math.round(19.95 / 0.1) * 0.1\n// 19.900000000000002\n// vs\n// Math.round(19.95 / 0.1) / (1 / 0.1)\n// 19.9\n//\nexport const stepify = (v, from, step) => Math.round(from(v) / step) / (1 / step);\n\nexport const euclideanModulo = (v, n) => ((v % n) + n) % n;\nexport const lerp = (a, b, t) => a + (b - a) * t;\nexport function copyExistingProperties(dst, src) {\n for (const key in src) {\n if (key in dst) {\n dst[key] = src[key];\n }\n }\n return dst;\n}\n\nexport const mapRange = (v, inMin, inMax, outMin, outMax) => (v - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;\n\nexport const makeRangeConverters = ({from, to}) => {\n return {\n to: v => mapRange(v, ...from, ...to),\n from: v => [true, mapRange(v, ...to, ...from)],\n };\n};\n\nexport const makeRangeOptions = ({from, to, step}) => {\n return {\n min: to[0],\n max: to[1],\n ...(step && {step}),\n converters: makeRangeConverters({from, to}),\n };\n};\n\n// TODO: remove an use one in conversions. Move makeRangeConverters there?\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\nexport function makeMinMaxPair(gui, properties, minPropName, maxPropName, options) {\n const { converters: { from } = identity } = options;\n const { min, max } = options;\n const guiMinRange = options.minRange || 0;\n const valueMinRange = from(guiMinRange)[1];\n const minGui = gui\n .add(properties, minPropName, {\n ...options,\n min,\n max: max - guiMinRange,\n })\n .onChange(v => {\n maxGui.setValue(Math.min(max, Math.max(v + valueMinRange, properties[maxPropName])));\n });\n const maxGui = gui\n .add(properties, maxPropName, {\n ...options,\n min: min + guiMinRange,\n max,\n })\n .onChange(v => {\n minGui.setValue(Math.max(min, Math.min(v - valueMinRange, properties[minPropName])));\n });\n return [ minGui, maxGui ];\n}\n\n","import { removeArrayElem } from '../libs/utils.js';\n\nexport default class View {\n domElement: HTMLElement;\n\n #childDestElem: HTMLElement;\n #views: View[] = [];\n\n constructor(elem: HTMLElement) {\n this.domElement = elem;\n this.#childDestElem = elem;\n }\n addElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n return elem;\n }\n removeElem(elem: HTMLElement) {\n this.#childDestElem.removeChild(elem);\n return elem;\n }\n pushSubElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n this.#childDestElem = elem;\n }\n popSubElem() {\n this.#childDestElem = this.#childDestElem.parentElement!;\n }\n add(view: View) {\n this.#views.push(view);\n this.addElem(view.domElement);\n return view;\n }\n remove(view: View) {\n this.removeElem(view.domElement);\n removeArrayElem(this.#views, view);\n return view;\n }\n pushSubView(view: View) {\n this.pushSubElem(view.domElement);\n }\n popSubView() {\n this.popSubElem();\n }\n setOptions(options: any) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n }\n updateDisplayIfNeeded(newV: any, ignoreCache?: boolean) {\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n $(selector: string) {\n return this.domElement.querySelector(selector);\n }\n}","import { createElem } from '../libs/elem.js';\nimport { removeArrayElem } from '../libs/utils.js';\nimport View from '../views/View.js';\n\nexport default class Controller extends View {\n #changeFns;\n #finishChangeFns;\n #parent;\n\n constructor(className) {\n super(createElem('div', {className: 'muigui-controller'}));\n this.#changeFns = [];\n this.#finishChangeFns = [];\n // we need the specialization to come last so it takes precedence.\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n get parent() {\n return this.#parent;\n }\n setParent(parent) {\n this.#parent = parent;\n this.enable(!this.disabled());\n }\n show(show = true) {\n this.domElement.classList.toggle('muigui-hide', !show);\n this.domElement.classList.toggle('muigui-show', show);\n return this;\n }\n hide() {\n return this.show(false);\n }\n disabled() {\n return !!this.domElement.closest('.muigui-disabled');\n }\n\n enable(enable = true) {\n this.domElement.classList.toggle('muigui-disabled', !enable);\n\n // If disabled we need to set the attribute 'disabled=true' to all\n // input/select/button/textarea's below\n //\n // If enabled we need to set the attribute 'disabled=false' to all below\n // until we hit a disabled controller.\n //\n // ATM the problem is we can find the input/select/button/textarea elements\n // but we can't easily find which controller they belong do.\n // But we don't need to? We can just check up if it or parent has\n // '.muigui-disabled'\n ['input', 'button', 'select', 'textarea'].forEach(tag => {\n this.domElement.querySelectorAll(tag).forEach(elem => {\n const disabled = !!elem.closest('.muigui-disabled');\n elem.disabled = disabled;\n });\n });\n\n return this;\n }\n disable(disable = true) {\n return this.enable(!disable);\n }\n onChange(fn) {\n this.removeChange(fn);\n this.#changeFns.push(fn);\n return this;\n }\n removeChange(fn) {\n removeArrayElem(this.#changeFns, fn);\n return this;\n }\n onFinishChange(fn) {\n this.removeFinishChange(fn);\n this.#finishChangeFns.push(fn);\n return this;\n }\n removeFinishChange(fn) {\n removeArrayElem(this.#finishChangeFns, fn);\n return this;\n }\n #callListeners(fns, newV) {\n for (const fn of fns) {\n fn.call(this, newV);\n }\n }\n emitChange(value, object, property) {\n this.#callListeners(this.#changeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n emitFinalChange(value, object, property) {\n this.#callListeners(this.#finishChangeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitFinalChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n updateDisplay() {\n // placeholder. override\n }\n getColors() {\n const toCamelCase = s => s.replace(/-([a-z])/g, (m, m1) => m1.toUpperCase());\n const keys = [\n 'color',\n 'bg-color',\n 'value-color',\n 'value-bg-color',\n 'hover-bg-color',\n 'menu-bg-color',\n 'menu-sep-color',\n 'disabled-color',\n ];\n const div = createElem('div');\n this.domElement.appendChild(div);\n const colors = Object.fromEntries(keys.map(key => {\n div.style.color = `var(--${key})`;\n const s = getComputedStyle(div);\n return [toCamelCase(key), s.color];\n }));\n div.remove();\n return colors;\n }\n}\n","import {\n createElem,\n} from '../libs/elem.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport Controller from './Controller.js';\n\nexport default class Button extends Controller {\n #object;\n #property;\n #buttonElem;\n #options = {\n name: '',\n };\n\n constructor(object, property, options = {}) {\n super('muigui-button', '');\n this.#object = object;\n this.#property = property;\n\n this.#buttonElem = this.addElem(\n createElem('button', {\n type: 'button',\n onClick: () => {\n this.#object[this.#property](this);\n },\n }));\n this.setOptions({name: property, ...options});\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {name} = this.#options;\n this.#buttonElem.textContent = name;\n }\n}","import { isTypedArray } from '../libs/utils.js';\nimport View from './View.js';\n\nfunction arraysEqual(a, b) {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; ++i) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction copyArrayElementsFromTo(src, dst) {\n dst.length = src.length;\n for (let i = 0; i < src.length; ++i) {\n dst[i] = src[i];\n }\n}\n\nexport default class EditView extends View {\n #oldV;\n #updateCheck;\n\n #checkArrayNeedsUpdate(newV) {\n // It's an array, we need to compare all elements\n // Example, vec2, [r,g,b], ...\n const needUpdate = !arraysEqual(newV, this.#oldV);\n if (needUpdate) {\n copyArrayElementsFromTo(newV, this.#oldV);\n }\n return needUpdate;\n }\n\n #checkTypedArrayNeedsUpdate() {\n let once = true;\n return function checkTypedArrayNeedsUpdateImpl(newV) {\n // It's a typedarray, we need to compare all elements\n // Example: Float32Array([r, g, b])\n let needUpdate = once;\n once = false;\n if (!needUpdate) {\n needUpdate = !arraysEqual(newV, this.#oldV);\n }\n return needUpdate;\n };\n }\n\n #checkObjectNeedsUpdate(newV) {\n let needUpdate = false;\n for (const key in newV) {\n if (newV[key] !== this.#oldV[key]) {\n needUpdate = true;\n this.#oldV[key] = newV[key];\n }\n }\n return needUpdate;\n }\n\n #checkValueNeedsUpdate(newV) {\n const needUpdate = newV !== this.#oldV;\n this.#oldV = newV;\n return needUpdate;\n }\n\n #getUpdateCheckForType(newV) {\n if (Array.isArray(newV)) {\n this.#oldV = [];\n return this.#checkArrayNeedsUpdate.bind(this);\n } else if (isTypedArray(newV)) {\n this.#oldV = new newV.constructor(newV);\n return this.#checkTypedArrayNeedsUpdate(this);\n } else if (typeof newV === 'object') {\n this.#oldV = {};\n return this.#checkObjectNeedsUpdate.bind(this);\n } else {\n return this.#checkValueNeedsUpdate.bind(this);\n }\n }\n\n // The point of this is updating DOM elements\n // is slow but if we've called `listen` then\n // every frame we're going to try to update\n // things with the current value so if nothing\n // has changed then skip it.\n updateDisplayIfNeeded(newV, ignoreCache) {\n this.#updateCheck = this.#updateCheck || this.#getUpdateCheckForType(newV);\n // Note: We call #updateCheck first because it updates\n // the cache\n if (this.#updateCheck(newV) || ignoreCache) {\n this.updateDisplay(newV);\n }\n }\n setOptions(/*options*/) {\n // override this\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class CheckboxView extends EditView {\n #checkboxElem;\n constructor(setter, id) {\n const checkboxElem = createElem('input', {\n type: 'checkbox',\n id,\n onInput: () => {\n setter.setValue(checkboxElem.checked);\n },\n onChange: () => {\n setter.setFinalValue(checkboxElem.checked);\n },\n });\n super(createElem('label', {}, [checkboxElem]));\n this.#checkboxElem = checkboxElem;\n }\n updateDisplay(v) {\n this.#checkboxElem.checked = v;\n }\n}\n","import { removeArrayElem } from './utils.js';\n\nconst tasks = [];\nconst tasksToRemove = new Set();\n\nlet requestId;\nlet processing;\n\nfunction removeTasks() {\n if (!tasksToRemove.size) {\n return;\n }\n\n if (processing) {\n queueProcessing();\n return;\n }\n\n tasksToRemove.forEach(task => {\n removeArrayElem(tasks, task);\n });\n tasksToRemove.clear();\n}\n\nfunction processTasks() {\n requestId = undefined;\n processing = true;\n for (const task of tasks) {\n if (!tasksToRemove.has(task)) {\n task();\n }\n }\n processing = false;\n removeTasks();\n queueProcessing();\n}\n\nfunction queueProcessing() {\n if (!requestId && tasks.length) {\n requestId = requestAnimationFrame(processTasks);\n }\n}\n\nexport function addTask(fn) {\n tasks.push(fn);\n queueProcessing();\n}\n\nexport function removeTask(fn) {\n tasksToRemove.set(fn);\n\n const ndx = tasks.indexOf(fn);\n if (ndx >= 0) {\n tasks.splice(ndx, 1);\n }\n}","let id = 0;\n\nexport function makeId() {\n return `muigui-${++id}`;\n}\n","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ValueView extends View {\n constructor(className = '') {\n super(createElem('div', {className: 'muigui-value'}));\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n}","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport ValueView from '../views/ValueView.js';\nimport Controller from './Controller.js';\n\nexport default class LabelController extends Controller {\n #id;\n #nameElem;\n\n constructor(className = '', name = '') {\n super('muigui-label-controller');\n this.#id = makeId();\n this.#nameElem = createElem('label', {for: this.#id});\n this.domElement.appendChild(this.#nameElem);\n this.pushSubView(new ValueView(className));\n this.name(name);\n }\n get id() {\n return this.#id;\n }\n name(name) {\n if (this.#nameElem.title === this.#nameElem.textContent) {\n this.#nameElem.title = name;\n }\n this.#nameElem.textContent = name;\n return this;\n }\n tooltip(tip) {\n this.#nameElem.title = tip;\n }\n}\n\n","import {addTask, removeTask} from '../libs/taskrunner.js';\nimport { isTypedArray } from '../libs/utils.js';\nimport LabelController from './LabelController.js';\n\nexport default class ValueController extends LabelController {\n #object;\n #property;\n #initialValue;\n #listening;\n #views;\n #updateFn;\n\n constructor(object, property, className = '') {\n super(className, property);\n this.#object = object;\n this.#property = property;\n this.#initialValue = this.getValue();\n this.#listening = false;\n this.#views = [];\n }\n get initialValue() {\n return this.#initialValue;\n }\n get object() {\n return this.#object;\n }\n get property() {\n return this.#property;\n }\n add(view) {\n this.#views.push(view);\n super.add(view);\n this.updateDisplay();\n return view;\n }\n #setValueImpl(v, ignoreCache) {\n let isDifferent = false;\n if (typeof v === 'object') {\n const dst = this.#object[this.#property];\n // don't replace objects, just their values.\n if (Array.isArray(v) || isTypedArray(v)) {\n for (let i = 0; i < v.length; ++i) {\n isDifferent ||= dst[i] !== v[i];\n dst[i] = v[i];\n }\n } else {\n for (const key of Object.keys(v)) {\n isDifferent ||= dst[key] !== v[key];\n }\n Object.assign(dst, v);\n }\n } else {\n isDifferent = this.#object[this.#property] !== v;\n this.#object[this.#property] = v;\n }\n this.updateDisplay(ignoreCache);\n if (isDifferent) {\n this.emitChange(this.getValue(), this.#object, this.#property);\n }\n return isDifferent;\n }\n setValue(v) {\n this.#setValueImpl(v);\n }\n setFinalValue(v) {\n const isDifferent = this.#setValueImpl(v, true);\n if (isDifferent) {\n this.emitFinalChange(this.getValue(), this.#object, this.#property);\n }\n return this;\n }\n updateDisplay(ignoreCache) {\n const newV = this.getValue();\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n setOptions(options) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n this.updateDisplay();\n return this;\n }\n getValue() {\n return this.#object[this.#property];\n }\n value(v) {\n this.setValue(v);\n return this;\n }\n reset() {\n this.setValue(this.#initialValue);\n return this;\n }\n listen(listen = true) {\n if (!this.#updateFn) {\n this.#updateFn = this.updateDisplay.bind(this);\n }\n if (listen) {\n if (!this.#listening) {\n this.#listening = true;\n addTask(this.#updateFn);\n }\n } else {\n if (this.#listening) {\n this.#listening = false;\n removeTask(this.#updateFn);\n }\n }\n return this;\n }\n}\n\n","import CheckboxView from '../views/CheckboxView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Checkbox extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n const id = this.id;\n this.add(new CheckboxView(this, id));\n this.updateDisplay();\n }\n}","import {\n makeRangeConverters,\n} from './utils.js';\n\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\n\n// from: from string to value\n// to: from value to string\nexport const strToNumber = {\n to: v => v.toString(),\n from: v => {\n const newV = parseFloat(v);\n return [!Number.isNaN(newV), newV];\n },\n};\n\nexport const converters = {\n radToDeg: makeRangeConverters({to: [0, 180], from: [0, Math.PI]}),\n};\n","export function createWheelHelper() {\n let wheelAccum = 0;\n return function (e, step, wheelScale = 5) {\n wheelAccum -= e.deltaY * step / wheelScale;\n const wheelSteps = Math.floor(Math.abs(wheelAccum) / step) * Math.sign(wheelAccum);\n const delta = wheelSteps * step;\n wheelAccum -= delta;\n return delta;\n };\n}\n","import { createElem } from '../libs/elem.js';\nimport { strToNumber } from '../libs/conversions.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nexport default class NumberView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n converters: strToNumber,\n min: Number.NEGATIVE_INFINITY,\n max: Number.POSITIVE_INFINITY,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'number',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const v = parseFloat(this.domElement.value);\n const [valid, newV] = this.#from(v);\n let inRange;\n if (valid && !Number.isNaN(v)) {\n const {min, max} = this.#options;\n inRange = newV >= min && newV <= max;\n this.#skipUpdate = skipUpdate;\n setFn(clamp(newV, min, max));\n }\n this.domElement.classList.toggle('muigui-invalid-value', !valid || !inRange);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n return this;\n }\n}\n","\nimport NumberView from '../views/NumberView.js';\nimport ValueController from './ValueController.js';\n\n// Wanted to name this `Number` but it conflicts with\n// JavaScript `Number`. It most likely wouldn't be\n// an issue? But users might `import {Number} ...` and\n// things would break.\nexport default class TextNumber extends ValueController {\n #textView;\n #step;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-checkbox');\n this.#textView = this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class SelectView extends EditView {\n #values;\n\n constructor(setter, keyValues) {\n const values = [];\n super(createElem('select', {\n onChange: () => {\n setter.setFinalValue(this.#values[this.domElement.selectedIndex]);\n },\n }, keyValues.map(([key, value]) => {\n values.push(value);\n return createElem('option', {textContent: key});\n })));\n this.#values = values;\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n this.domElement.selectedIndex = ndx;\n }\n}\n","\n// 4 cases\n// (a) keyValues is array of arrays, each sub array is key value\n// (b) keyValues is array and value is number then keys = array contents, value = index\n// (c) keyValues is array and value is not number, key = array contents, value = array contents\n// (d) keyValues is object then key->value\nexport function convertToKeyValues(keyValues, valueIsNumber) {\n if (Array.isArray(keyValues)) {\n if (Array.isArray(keyValues[0])) {\n // (a) keyValues is array of arrays, each sub array is key value\n return keyValues;\n } else {\n if (valueIsNumber) {\n // (b) keyValues is array and value is number then keys = array contents, value = index\n return keyValues.map((v, ndx) => [v, ndx]);\n } else {\n // (c) keyValues is array and value is not number, key = array contents, value = array contents\n return keyValues.map(v => [v, v]);\n }\n }\n } else {\n // (d)\n return [...Object.entries(keyValues)];\n }\n}\n","import SelectView from '../views/SelectView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class Select extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-select');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {keyValues: keyValuesInput} = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new SelectView(this, keyValues));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport EditView from './EditView.js';\n\nexport default class RangeView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n min: 0,\n max: 1,\n converters: identity,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'range',\n onInput: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setValue(validV);\n }\n },\n onChange: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setFinalValue(validV);\n }\n },\n onWheel: e => {\n e.preventDefault();\n const [valid, v] = this.#from(parseFloat(this.domElement.value));\n if (!valid) {\n return;\n }\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n min,\n max,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n this.domElement.step = step;\n this.domElement.min = min;\n this.domElement.max = max;\n return this;\n }\n}","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport RangeView from '../views/RangeView.js';\n\nexport default class Range extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-range');\n this.add(new RangeView(this, options));\n this.add(new NumberView(this, options));\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class TextView extends EditView {\n #to;\n #from;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n super(createElem('input', {\n type: 'text',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const [valid, newV] = this.#from(this.domElement.value);\n if (valid) {\n this.#skipUpdate = skipUpdate;\n setFn(newV);\n }\n this.domElement.style.color = valid ? '' : 'var(--invalid-color)';\n\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = this.#to(v);\n this.domElement.style.color = '';\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import TextView from '../views/TextView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Text extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n this.add(new TextView(this));\n this.updateDisplay();\n }\n}","import Button from './Button.js';\nimport Checkbox from './Checkbox.js';\nimport TextNumber from './TextNumber.js';\nimport Select from './Select.js';\nimport Range from './Range.js';\nimport Text from './Text.js';\n\n// const isConversion = o => typeof o.to === 'function' && typeof o.from === 'function';\n\n/**\n * possible inputs\n * add(o, p, min: number, max: number)\n * add(o, p, min: number, max: number, step: number)\n * add(o, p, array: [value])\n * add(o, p, array: [[key, value]])\n *\n * @param {*} object\n * @param {string} property\n * @param {...any} args\n * @returns {Controller}\n */\nexport function createController(object, property, ...args) {\n const [arg1] = args;\n if (Array.isArray(arg1)) {\n return new Select(object, property, {keyValues: arg1});\n }\n\n const t = typeof object[property];\n switch (t) {\n case 'number':\n if (typeof args[0] === 'number' && typeof args[1] === 'number') {\n const min = args[0];\n const max = args[1];\n const step = args[2];\n return new Range(object, property, {min, max, ...(step && {step})});\n }\n return args.length === 0\n ? new TextNumber(object, property, ...args)\n : new Range(object, property, ...args);\n case 'boolean':\n return new Checkbox(object, property, ...args);\n case 'function':\n return new Button(object, property, ...args);\n case 'string':\n return new Text(object, property, ...args);\n case 'undefined':\n throw new Error(`no property named ${property}`);\n default:\n throw new Error(`unhandled type ${t} for property ${property}`);\n }\n}","const clamp = (v, min, max) => Math.max(min, Math.min(max, v));\nconst lerp = (a, b, t) => a + (b - a) * t;\nconst fract = v => v >= 0 ? v % 1 : 1 - (v % 1);\n\nconst f0 = v => +v.toFixed(0); // converts to string (eg 1.2 => \"1\"), then converts back to number (eg, \"1.200\" => 1.2)\nconst f3 = v => +v.toFixed(3); // converts to string (eg 1.2 => \"1.200\"), then converts back to number (eg, \"1.200\" => 1.2)\n\nconst hexToUint32RGB = v => (parseInt(v.substring(1, 3), 16) << 16) |\n (parseInt(v.substring(3, 5), 16) << 8 ) |\n (parseInt(v.substring(5, 7), 16) );\nconst uint32RGBToHex = v => `#${(Math.round(v)).toString(16).padStart(6, '0')}`;\nconst hexToUint32RGBA = v => (parseInt(v.substring(1, 3), 16) * 2 ** 24) +\n (parseInt(v.substring(3, 5), 16) * 2 ** 16) +\n (parseInt(v.substring(5, 7), 16) * 2 ** 8) +\n (parseInt(v.substring(7, 9), 16) );\nconst uint32RGBAToHex = v => `#${(Math.round(v)).toString(16).padStart(8, '0')}`;\n\nexport const hexToUint8RGB = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n];\nexport const uint8RGBToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToUint8RGBA = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n parseInt(v.substring(7, 9), 16),\n];\nexport const uint8RGBAToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToFloatRGB = v => hexToUint8RGB(v).map(v => f3(v / 255));\nexport const floatRGBToHex = v => uint8RGBToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nexport const hexToFloatRGBA = v => hexToUint8RGBA(v).map(v => f3(v / 255));\nexport const floatRGBAToHex = v => uint8RGBAToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nconst scaleAndClamp = v => clamp(Math.round(v * 255), 0, 255).toString(16).padStart(2, '0');\n\nconst hexToObjectRGB = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n});\nconst objectRGBToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}`;\nconst hexToObjectRGBA = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n a: parseInt(v.substring(7, 9), 16) / 255,\n});\nconst objectRGBAToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}${scaleAndClamp(v.a)}`;\n\nconst hexToCssRGB = v => `rgb(${hexToUint8RGB(v).join(', ')})`;\nconst cssRGBRegex = /^\\s*rgb\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\s*$/;\nconst cssRGBToHex = v => {\n const m = cssRGBRegex.exec(v);\n return uint8RGBToHex([m[1], m[2], m[3]].map(v => parseInt(v)));\n};\nconst hexToCssRGBA = v => `rgba(${hexToUint8RGBA(v).map((v, i) => i === 3 ? v / 255 : v).join(', ')})`;\nconst cssRGBARegex = /^\\s*rgba\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\nconst cssRGBAToHex = v => {\n const m = cssRGBARegex.exec(v);\n return uint8RGBAToHex([m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? (parseFloat(v) * 255 | 0) : parseInt(v)));\n};\n\nconst hexToCssHSL = v => {\n const hsl = rgbUint8ToHsl(hexToUint8RGB(v)).map(v => f0(v));\n return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`;\n};\nconst hexToCssHSLA = v => {\n const hsla = rgbaUint8ToHsla(hexToUint8RGBA(v)).map((v, i) => i === 3 ? f3(v) : f0(v));\n return `hsl(${hsla[0]} ${hsla[1]}% ${hsla[2]}% / ${hsla[3]})`;\n};\nconst cssHSLRegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\)\\s*$/;\nconst cssHSLARegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\/\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\n\nconst hex3DigitTo6Digit = v => `${v[0]}${v[0]}${v[1]}${v[1]}${v[2]}${v[2]}`;\nconst cssHSLToHex = v => {\n const m = cssHSLRegex.exec(v);\n const rgb = hslToRgbUint8([m[1], m[2], m[3]].map(v => parseFloat(v)));\n return uint8RGBToHex(rgb);\n};\nconst cssHSLAToHex = v => {\n const m = cssHSLARegex.exec(v);\n const rgba = hslaToRgbaUint8([m[1], m[2], m[3], m[4]].map(v => parseFloat(v)));\n return uint8RGBAToHex(rgba);\n};\n\nconst euclideanModulo = (v, n) => ((v % n) + n) % n;\n\nexport function hslToRgbUint8([h, s, l]) {\n h = euclideanModulo(h, 360);\n s = clamp(s / 100, 0, 1);\n l = clamp(l / 100, 0, 1);\n\n const a = s * Math.min(l, 1 - l);\n\n function f(n) {\n const k = (n + h / 30) % 12;\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n\n return [f(0), f(8), f(4)].map(v => Math.round(v * 255));\n}\n\nexport function hslaToRgbaUint8([h, s, l, a]) {\n const rgb = hslToRgbUint8([h, s, l]);\n return [...rgb, a * 255 | 0];\n}\n\nexport function rgbFloatToHsl01([r, g, b]) {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (min + max) * 0.5;\n const d = max - min;\n let h = 0;\n let s = 0;\n\n if (d !== 0) {\n s = (l === 0 || l === 1)\n ? 0\n : (max - l) / Math.min(l, 1 - l);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4;\n }\n }\n\n return [h / 6, s, l];\n}\n\nexport function rgbaFloatToHsla01([r, g, b, a]) {\n const hsl = rgbFloatToHsl01([r, g, b]);\n return [...hsl, a];\n}\n\nexport const rgbUint8ToHsl = (rgb) => {\n const [h, s, l] = rgbFloatToHsl01(rgb.map(v => v / 255));\n return [h * 360, s * 100, l * 100];\n};\n\nexport const rgbaUint8ToHsla = (rgba) => {\n const [h, s, l, a] = rgbaFloatToHsla01(rgba.map(v => v / 255));\n return [h * 360, s * 100, l * 100, a];\n};\n\nexport function hsv01ToRGBFloat([hue, sat, val]) {\n sat = clamp(sat, 0, 1);\n val = clamp(val, 0, 1);\n return [hue, hue + 2 / 3, hue + 1 / 3].map(\n v => lerp(1, clamp(Math.abs(fract(v) * 6 - 3.0) - 1, 0, 1), sat) * val\n );\n}\n\nexport function hsva01ToRGBAFloat([hue, sat, val, alpha]) {\n const rgb = hsv01ToRGBFloat([hue, sat, val]);\n return [...rgb, alpha];\n}\n\nconst round3 = v => Math.round(v * 1000) / 1000;\n\nexport function rgbFloatToHSV01([r, g, b]) {\n const p = b > g\n ? [b, g, -1, 2 / 3]\n : [g, b, 0, -1 / 3];\n const q = p[0] > r\n ? [p[0], p[1], p[3], r]\n : [r, p[1], p[2], p[0]];\n const d = q[0] - Math.min(q[3], q[1]);\n return [\n Math.abs(q[2] + (q[3] - q[1]) / (6 * d + Number.EPSILON)),\n d / (q[0] + Number.EPSILON),\n q[0],\n ].map(round3);\n}\n\nexport function rgbaFloatToHSVA01([r, g, b, a]) {\n const hsv = rgbFloatToHSV01([r, g, b]);\n return [...hsv, a];\n}\n\n// window.hsv01ToRGBFloat = hsv01ToRGBFloat;\n// window.rgbFloatToHSV01 = rgbFloatToHSV01;\n\n// Yea, meh!\nexport const hasAlpha = format => format.endsWith('a') || format.startsWith('hex8');\n\nconst cssStringFormats = [\n { re: /^#(?:[0-9a-f]){6}$/i, format: 'hex6' },\n { re: /^(?:[0-9a-f]){6}$/i, format: 'hex6-no-hash' },\n { re: /^#(?:[0-9a-f]){8}$/i, format: 'hex8' },\n { re: /^(?:[0-9a-f]){8}$/i, format: 'hex8-no-hash' },\n { re: /^#(?:[0-9a-f]){3}$/i, format: 'hex3' },\n { re: /^(?:[0-9a-f]){3}$/i, format: 'hex3-no-hash' },\n { re: cssRGBRegex, format: 'css-rgb' },\n { re: cssHSLRegex, format: 'css-hsl' },\n { re: cssRGBARegex, format: 'css-rgba' },\n { re: cssHSLARegex, format: 'css-hsla' },\n];\n\nfunction guessStringColorFormat(v) {\n for (const formatInfo of cssStringFormats) {\n if (formatInfo.re.test(v)) {\n return formatInfo;\n }\n }\n return undefined;\n}\n\nexport function guessFormat(v) {\n switch (typeof v) {\n case 'number':\n console.warn('can not reliably guess format based on a number. You should pass in a format like {format: \"uint32-rgb\"} or {format: \"uint32-rgb\"}');\n return v <= 0xFFFFFF ? 'uint32-rgb' : 'uint32-rgba';\n case 'string': {\n const formatInfo = guessStringColorFormat(v.trim());\n if (formatInfo) {\n return formatInfo.format;\n }\n break;\n }\n case 'object':\n if (v instanceof Uint8Array || v instanceof Uint8ClampedArray) {\n if (v.length === 3) {\n return 'uint8-rgb';\n } else if (v.length === 4) {\n return 'uint8-rgba';\n }\n } else if (v instanceof Float32Array) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else if (Array.isArray(v)) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else {\n if ('r' in v && 'g' in v && 'b' in v) {\n if ('a' in v) {\n return 'object-rgba';\n } else {\n return 'object-rgb';\n }\n }\n }\n }\n throw new Error(`unknown color format: ${v}`);\n}\n\nfunction fixHex6(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction fixHex8(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction hex6ToHex3(hex6) {\n return (hex6[1] === hex6[2] &&\n hex6[3] === hex6[4] &&\n hex6[5] === hex6[6])\n ? `#${hex6[1]}${hex6[3]}${hex6[5]}`\n : hex6;\n}\n\nconst hex3RE = /^(#|)([0-9a-f]{3})$/i;\nfunction hex3ToHex6(hex3) {\n const m = hex3RE.exec(hex3);\n if (m) {\n const [, , m2] = m;\n return `#${hex3DigitTo6Digit(m2)}`;\n }\n return hex3;\n}\n\nfunction fixHex3(v) {\n return hex6ToHex3(fixHex6(v));\n}\n\nconst strToRGBObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgb = JSON.parse(json);\n if (Number.isNaN(rgb.r) || Number.isNaN(rgb.g) || Number.isNaN(rgb.b)) {\n throw new Error('not {r, g, b}');\n }\n return [true, rgb];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToRGBAObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgba = JSON.parse(json);\n if (Number.isNaN(rgba.r) || Number.isNaN(rgba.g) || Number.isNaN(rgba.b) || Number.isNaN(rgba.a)) {\n throw new Error('not {r, g, b, a}');\n }\n return [true, rgba];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToCssRGB = s => {\n const m = cssRGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgb(${v.join(', ')})`];\n};\n\nconst strToCssRGBA = s => {\n const m = cssRGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? parseFloat(v) : parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgba(${v.join(', ')})`];\n};\n\nconst strToCssHSL = s => {\n const m = cssHSLRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]}, ${v[1]}%, ${v[2]}%)`];\n};\n\nconst strToCssHSLA = s => {\n const m = cssHSLARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]} ${v[1]}% ${v[2]}% / ${v[3]})`];\n};\n\nconst rgbObjectToStr = rgb => {\n return `{r:${f3(rgb.r)}, g:${f3(rgb.g)}, b:${f3(rgb.b)}}`;\n};\nconst rgbaObjectToStr = rgba => {\n return `{r:${f3(rgba.r)}, g:${f3(rgba.g)}, b:${f3(rgba.b)}}, a:${f3(rgba.a)}}`;\n};\n\nconst strTo3IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo3Ints = s => {\n const m = strTo3IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo4IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo4Ints = s => {\n const m = strTo4IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo3Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 3) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strTo4Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 4) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strToUint32RGBRegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,6})\\s*$/i;\nconst strToUint32RGB = s => {\n const m = strToUint32RGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst strToUint32RGBARegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,8})\\s*$/i;\nconst strToUint32RGBA = s => {\n const m = strToUint32RGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst hex6RE = /^\\s*#[a-f0-9]{6}\\s*$|^\\s*#[a-f0-9]{3}\\s*$/i;\nconst hexNoHash6RE = /^\\s*[a-f0-9]{6}\\s*$/i;\nconst hex8RE = /^\\s*#[a-f0-9]{8}\\s*$/i;\nconst hexNoHash8RE = /^\\s*[a-f0-9]{8}\\s*$/i;\n\n// For each format converter\n//\n// fromHex/toHex convert from/to '#RRGGBB'\n//\n// fromHex converts from the string '#RRBBGG' to the format\n// (eg: for uint32-rgb, '#123456' becomes 0x123456)\n//\n// toHex converts from the format to '#RRGGBB'\n// (eg: for uint8-rgb, [16, 33, 50] becomes '#102132')\n//\n//\n// fromStr/toStr convert from/to what's in the input[type=text] element\n//\n// toStr converts from the format to its string representation\n// (eg, for object-rgb, {r: 1, g: 0.5, b:0} becomes \"{r: 1, g: 0.5, b:0}\")\n// ^object ^string\n//\n// fromStr converts its string representation to its format\n// (eg, for object-rgb) \"{r: 1, g: 0.5, b:0}\" becomes {r: 1, g: 0.5, b:0})\n// ^string ^object\n// fromString returns an array which is [valid, v]\n// where valid is true if the string was a valid and v is the converted\n// format if v is true.\n//\n// Note: toStr should convert to \"ideal\" form (whatever that is).\n// (eg, for css-rgb\n// \"{ r: 0.10000, g: 001, b: 0}\" becomes \"{r: 0.1, g: 1, b: 0}\"\n// notice that css-rgb is a string to a string\n// )\nexport const colorFormatConverters = {\n 'hex6': {\n color: {\n from: v => [true, v],\n to: fixHex6,\n },\n text: {\n from: v => [hex6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8': {\n color: {\n from: v => [true, v],\n to: fixHex8,\n },\n text: {\n from: v => [hex8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3': {\n color: {\n from: v => [true, fixHex3(v)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hex6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'hex6-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex6(v)}`,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex8(v)}`,\n },\n text: {\n from: v => [hexNoHash8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3-no-hash': {\n color: {\n from: v => [true, fixHex3(v).substring(1)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'uint32-rgb': {\n color: {\n from: v => [true, hexToUint32RGB(v)],\n to: uint32RGBToHex,\n },\n text: {\n from: v => strToUint32RGB(v),\n to: v => `0x${v.toString(16).padStart(6, '0')}`,\n },\n },\n 'uint32-rgba': {\n color: {\n from: v => [true, hexToUint32RGBA(v)],\n to: uint32RGBAToHex,\n },\n text: {\n from: v => strToUint32RGBA(v),\n to: v => `0x${v.toString(16).padStart(8, '0')}`,\n },\n },\n 'uint8-rgb': {\n color: {\n from: v => [true, hexToUint8RGB(v)],\n to: uint8RGBToHex,\n },\n text: {\n from: strTo3Ints,\n to: v => v.join(', '),\n },\n },\n 'uint8-rgba': {\n color: {\n from: v => [true, hexToUint8RGBA(v)],\n to: uint8RGBAToHex,\n },\n text: {\n from: strTo4Ints,\n to: v => v.join(', '),\n },\n },\n 'float-rgb': {\n color: {\n from: v => [true, hexToFloatRGB(v)],\n to: floatRGBToHex,\n },\n text: {\n from: strTo3Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'float-rgba': {\n color: {\n from: v => [true, hexToFloatRGBA(v)],\n to: floatRGBAToHex,\n },\n text: {\n from: strTo4Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'object-rgb': {\n color: {\n from: v => [true, hexToObjectRGB(v)],\n to: objectRGBToHex,\n },\n text: {\n from: strToRGBObject,\n to: rgbObjectToStr,\n },\n },\n 'object-rgba': {\n color: {\n from: v => [true, hexToObjectRGBA(v)],\n to: objectRGBAToHex,\n },\n text: {\n from: strToRGBAObject,\n to: rgbaObjectToStr,\n },\n },\n 'css-rgb': {\n color: {\n from: v => [true, hexToCssRGB(v)],\n to: cssRGBToHex,\n },\n text: {\n from: strToCssRGB,\n to: v => strToCssRGB(v)[1],\n },\n },\n 'css-rgba': {\n color: {\n from: v => [true, hexToCssRGBA(v)],\n to: cssRGBAToHex,\n },\n text: {\n from: strToCssRGBA,\n to: v => strToCssRGBA(v)[1],\n },\n },\n 'css-hsl': {\n color: {\n from: v => [true, hexToCssHSL(v)],\n to: cssHSLToHex,\n },\n text: {\n from: strToCssHSL,\n to: v => strToCssHSL(v)[1],\n },\n },\n 'css-hsla': {\n color: {\n from: v => [true, hexToCssHSLA(v)],\n to: cssHSLAToHex,\n },\n text: {\n from: strToCssHSLA,\n to: v => strToCssHSLA(v)[1],\n },\n },\n};","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ElementView extends View {\n constructor(tag, className) {\n super(createElem(tag, {className}));\n }\n}","import ElementView from '../views/ElementView.js';\nimport LabelController from './LabelController.js';\n\n// TODO: remove this? Should just be user side\nexport default class Canvas extends LabelController {\n #canvasElem;\n\n constructor() {\n super('muigui-canvas');\n this.#canvasElem = this.add(\n new ElementView('canvas', 'muigui-canvas'),\n ).domElement;\n }\n get canvas() {\n return this.#canvasElem;\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class ColorView extends EditView {\n #to;\n #from;\n #colorElem;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const colorElem = createElem('input', {\n type: 'color',\n onInput: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setValue(newV);\n }\n },\n onChange: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setFinalValue(newV);\n }\n },\n });\n super(createElem('div', {}, [colorElem]));\n this.setOptions(options);\n this.#colorElem = colorElem;\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.#colorElem.value = this.#to(v);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}} = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import {\n colorFormatConverters,\n guessFormat,\n} from '../libs/color-utils.js';\nimport ValueController from './ValueController.js';\nimport TextView from '../views/TextView.js';\nimport ColorView from '../views/ColorView.js';\n\nexport default class Color extends ValueController {\n #colorView;\n #textView;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#colorView = this.add(new ColorView(this, {converters: color}));\n this.#textView = this.add(new TextView(this, {converters: text}));\n this.updateDisplay();\n }\n setOptions(options) {\n const {format} = options;\n if (format) {\n const {color, text} = colorFormatConverters[format];\n this.#colorView.setOptions({converters: color});\n this.#textView.setOptions({converters: text});\n }\n super.setOptions(options);\n return this;\n }\n}","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addController({className: 'muigui-divider')};\nexport default class Divider extends Controller {\n constructor() {\n super('muigui-divider');\n }\n}","import Controller from './Controller.js';\n\nexport default class Container extends Controller {\n #controllers;\n #childDestController;\n\n constructor(className) {\n super(className);\n this.#controllers = [];\n this.#childDestController = this;\n }\n get children() {\n return this.#controllers; // should we return a copy?\n }\n get controllers() {\n return this.#controllers.filter(c => !(c instanceof Container));\n }\n get folders() {\n return this.#controllers.filter(c => c instanceof Container);\n }\n reset(recursive = true) {\n for (const controller of this.#controllers) {\n if (!(controller instanceof Container) || recursive) {\n controller.reset(recursive);\n }\n }\n return this;\n }\n updateDisplay() {\n for (const controller of this.#controllers) {\n controller.updateDisplay();\n }\n return this;\n }\n remove(controller) {\n const ndx = this.#controllers.indexOf(controller);\n if (ndx >= 0) {\n const c = this.#controllers.splice(ndx, 1);\n const c0 = c[0];\n const elem = c0.domElement;\n elem.remove();\n c0.setParent(null);\n }\n return this;\n }\n #addControllerImpl(controller) {\n this.domElement.appendChild(controller.domElement);\n this.#controllers.push(controller);\n controller.setParent(this);\n return controller;\n }\n addController(controller) {\n return this.#childDestController.#addControllerImpl(controller);\n }\n pushContainer(container) {\n this.addController(container);\n this.#childDestController = container;\n return container;\n }\n popContainer() {\n this.#childDestController = this.#childDestController.parent;\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport Container from './Container.js';\n\nexport default class Folder extends Container {\n #labelElem;\n\n constructor(name = 'Controls', className = 'muigui-menu') {\n super(className);\n this.#labelElem = createElem('label');\n this.addElem(createElem('button', {\n type: 'button',\n onClick: () => this.toggleOpen(),\n }, [this.#labelElem]));\n this.pushContainer(new Container());\n this.name(name);\n this.open();\n }\n open(open = true) {\n this.domElement.classList.toggle('muigui-closed', !open);\n this.domElement.classList.toggle('muigui-open', open);\n return this;\n }\n close() {\n return this.open(false);\n }\n name(name) {\n this.#labelElem.textContent = name;\n return this;\n }\n title(title) {\n return this.name(title);\n }\n toggleOpen() {\n this.open(!this.domElement.classList.contains('muigui-open'));\n return this;\n }\n}\n","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addDividing = new Controller()\nexport default class Label extends Controller {\n constructor(text) {\n super('muigui-label');\n this.text(text);\n }\n text(text) {\n this.domElement.textContent = text;\n return this;\n }\n}","function noop() {\n}\n\nexport function computeRelativePosition(elem, event, start) {\n const rect = elem.getBoundingClientRect();\n const x = event.clientX - rect.left;\n const y = event.clientY - rect.top;\n const nx = x / rect.width;\n const ny = y / rect.height;\n start = start || [x, y];\n const dx = x - start[0];\n const dy = y - start[1];\n const ndx = dx / rect.width;\n const ndy = dy / rect.width;\n return {x, y, nx, ny, dx, dy, ndx, ndy};\n}\n\nexport function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}) {\n let start;\n const pointerMove = function (event) {\n const e = {\n type: 'move',\n ...computeRelativePosition(elem, event, start),\n };\n onMove(e);\n };\n\n const pointerUp = function (event) {\n elem.releasePointerCapture(event.pointerId);\n elem.removeEventListener('pointermove', pointerMove);\n elem.removeEventListener('pointerup', pointerUp);\n\n document.body.style.backgroundColor = '';\n\n onUp('up');\n };\n\n const pointerDown = function (event) {\n elem.addEventListener('pointermove', pointerMove);\n elem.addEventListener('pointerup', pointerUp);\n elem.setPointerCapture(event.pointerId);\n\n const rel = computeRelativePosition(elem, event);\n start = [rel.x, rel.y];\n onDown({\n type: 'down',\n ...rel,\n });\n };\n\n elem.addEventListener('pointerdown', pointerDown);\n\n return function () {\n elem.removeEventListener('pointerdown', pointerDown);\n };\n}","import { createElem, getNewId } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp } from '../libs/utils.js';\nimport EditView from './EditView.js';\nimport {\n hexToFloatRGB,\n hexToFloatRGBA,\n hsv01ToRGBFloat,\n hsva01ToRGBAFloat,\n rgbFloatToHSV01,\n rgbaFloatToHSVA01,\n floatRGBToHex,\n floatRGBAToHex,\n rgbaFloatToHsla01,\n} from '../libs/color-utils.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nconst svg = `\n\n\n\n`;\n\nfunction connectFillTargets(elem) {\n elem.querySelectorAll('[data-src]').forEach(srcElem => {\n const id = getNewId();\n srcElem.id = id;\n elem.querySelectorAll(`[data-target=${srcElem.dataset.src}]`).forEach(targetElem => {\n targetElem.setAttribute('fill', `url(#${id})`);\n });\n });\n return elem;\n}\n\n// Was originally going to make alpha an option. Issue is\n// hard coded conversions?\nexport default class ColorChooserView extends EditView {\n #to;\n #from;\n #satLevelElem;\n #circleElem;\n #hueUIElem;\n #hueElem;\n #hueCursorElem;\n #alphaUIElem;\n #alphaElem;\n #alphaCursorElem;\n #hsva;\n #skipHueUpdate;\n #skipSatLevelUpdate;\n #skipAlphaUpdate;\n #options = {\n converters: identity,\n alpha: false,\n };\n #convertInternalToHex;\n #convertHexToInternal;\n\n constructor(setter, options) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n this.#satLevelElem = this.domElement.children[0];\n this.#hueUIElem = this.domElement.children[1];\n this.#alphaUIElem = this.domElement.children[2];\n connectFillTargets(this.#satLevelElem);\n connectFillTargets(this.#hueUIElem);\n connectFillTargets(this.#alphaUIElem);\n this.#circleElem = this.$('.muigui-color-chooser-circle');\n this.#hueElem = this.$('[data-src=muigui-color-chooser-hue]');\n this.#hueCursorElem = this.$('.muigui-color-chooser-hue-cursor');\n this.#alphaElem = this.$('[data-src=muigui-color-chooser-alpha]');\n this.#alphaCursorElem = this.$('.muigui-color-chooser-alpha-cursor');\n\n const handleSatLevelChange = (e) => {\n const s = clamp(e.nx, 0, 1);\n const v = clamp(e.ny, 0, 1);\n this.#hsva[1] = s;\n this.#hsva[2] = (1 - v);\n this.#skipHueUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleHueChange = (e) => {\n const h = clamp(e.nx, 0, 1);\n this.#hsva[0] = h;\n this.#skipSatLevelUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleAlphaChange = (e) => {\n const a = clamp(e.nx, 0, 1);\n this.#hsva[3] = a;\n this.#skipHueUpdate = true;\n this.#skipSatLevelUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n addTouchEvents(this.#satLevelElem, {\n onDown: handleSatLevelChange,\n onMove: handleSatLevelChange,\n });\n addTouchEvents(this.#hueUIElem, {\n onDown: handleHueChange,\n onMove: handleHueChange,\n });\n addTouchEvents(this.#alphaUIElem, {\n onDown: handleAlphaChange,\n onMove: handleAlphaChange,\n });\n this.setOptions(options);\n }\n updateDisplay(newV) {\n if (!this.#hsva) {\n this.#hsva = this.#convertHexToInternal(this.#to(newV));\n }\n {\n const [h, s, v, a = 1] = this.#convertHexToInternal(this.#to(newV));\n // Don't copy the hue if it was un-computable.\n if (!this.#skipHueUpdate) {\n this.#hsva[0] = s > 0.001 && v > 0.001 ? h : this.#hsva[0];\n }\n if (!this.#skipSatLevelUpdate) {\n this.#hsva[1] = s;\n this.#hsva[2] = v;\n }\n if (!this.#skipAlphaUpdate) {\n this.#hsva[3] = a;\n }\n }\n {\n const [h, s, v, a] = this.#hsva;\n const [hue, sat, lum] = rgbaFloatToHsla01(hsva01ToRGBAFloat(this.#hsva));\n\n if (!this.#skipHueUpdate) {\n this.#hueCursorElem.setAttribute('transform', `translate(${h * 64}, 0)`);\n }\n this.#hueElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} 0% 100% / ${a})`);\n this.#hueElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} 100% 50% / ${a})`);\n if (!this.#skipAlphaUpdate) {\n this.#alphaCursorElem.setAttribute('transform', `translate(${a * 64}, 0)`);\n }\n this.#alphaElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 0)`);\n this.#alphaElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 1)`);\n\n if (!this.#skipSatLevelUpdate) {\n this.#circleElem.setAttribute('cx', `${s * 64}`);\n this.#circleElem.setAttribute('cy', `${(1 - v) * 48}`);\n }\n }\n this.#skipHueUpdate = false;\n this.#skipSatLevelUpdate = false;\n this.#skipAlphaUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}, alpha} = this.#options;\n this.#alphaUIElem.style.display = alpha ? '' : 'none';\n this.#convertInternalToHex = alpha\n ? v => floatRGBAToHex(hsva01ToRGBAFloat(v))\n : v => floatRGBToHex(hsv01ToRGBFloat(v));\n this.#convertHexToInternal = alpha\n ? v => rgbaFloatToHSVA01(hexToFloatRGBA(v))\n : v => rgbFloatToHSV01(hexToFloatRGB(v));\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import ElementView from '../views/ElementView.js';\nimport ValueController from './ValueController.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport { createElem } from '../libs/elem.js';\n/*\n\nholder = new TabHolder\ntab = holder.add(new Tab(\"name\"))\ntab.add(...)\n\n\npc = new PopdownController\ntop = pc.add(new Row())\ntop.add(new Button());\nvalues = topRow.add(new Div())\nbottom = pc.add(new Row());\n\n\n\npc = new PopdownController\npc.addTop\npc.addTop\n\npc.addBottom\n\n\n*/\n\nexport default class PopDownController extends ValueController {\n #top;\n #valuesView;\n #checkboxElem;\n #bottom;\n #options = {\n open: false,\n };\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-pop-down-controller');\n /*\n [ValueView\n [[B][values]] upper row\n [[ visual ]] lower row\n ]\n */\n this.#top = this.add(new ElementView('div', 'muigui-pop-down-top'));\n// this.#top.add(new CheckboxView(makeSetter(this.#options, 'open')));\n const checkboxElem = this.#top.addElem(createElem('input', {\n type: 'checkbox',\n onChange: () => {\n this.#options.open = checkboxElem.checked;\n this.updateDisplay();\n },\n }));\n this.#checkboxElem = checkboxElem;\n this.#valuesView = this.#top.add(new ElementView('div', 'muigui-pop-down-values'));\n this.#bottom = this.add(new ElementView('div', 'muigui-pop-down-bottom'));\n this.setOptions(options);\n }\n setKnobColor(bgCssColor/*, fgCssColor*/) {\n if (this.#checkboxElem) {\n this.#checkboxElem.style = `\n --range-color: ${bgCssColor};\n --value-bg-color: ${bgCssColor};\n `;\n }\n }\n updateDisplay() {\n super.updateDisplay();\n const {open} = this.#options;\n this.domElement.children[1].classList.toggle('muigui-open', open);\n this.domElement.children[1].classList.toggle('muigui-closed', !open);\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n super.setOptions(options);\n this.updateDisplay();\n }\n addTop(view) {\n return this.#valuesView.add(view);\n }\n addBottom(view) {\n return this.#bottom.add(view);\n }\n}","/* eslint-disable no-underscore-dangle */\nimport {\n colorFormatConverters,\n guessFormat,\n hasAlpha,\n hexToUint8RGB,\n hslToRgbUint8,\n rgbUint8ToHsl,\n uint8RGBToHex,\n} from '../libs/color-utils.js';\nimport ColorChooserView from '../views/ColorChooserView.js';\nimport TextView from '../views/TextView.js';\nimport PopDownController from './PopDownController.js';\n\nexport default class ColorChooser extends PopDownController {\n #colorView;\n #textView;\n #to;\n #setKnobHelper;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color-chooser');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#to = color.to;\n this.#textView = new TextView(this, {converters: text, alpha: hasAlpha(format)});\n this.#colorView = new ColorChooserView(this, {converters: color, alpha: hasAlpha(format)});\n this.addTop(this.#textView);\n this.addBottom(this.#colorView);\n // WTF! FIX!\n this.#setKnobHelper = () => {\n if (this.#to) {\n const hex6Or8 = this.#to(this.getValue());\n const hsl = rgbUint8ToHsl(hexToUint8RGB(hex6Or8));\n hsl[2] = (hsl[2] + 50) % 100;\n const hex = uint8RGBToHex(hslToRgbUint8(hsl));\n this.setKnobColor(`${hex6Or8.substring(0, 7)}FF`, hex);\n }\n };\n this.updateDisplay();\n }\n updateDisplay() {\n super.updateDisplay();\n if (this.#setKnobHelper) {\n this.#setKnobHelper();\n }\n }\n setOptions(options) {\n super.setOptions(options);\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport View from '../views/View.js';\n\nfunction showCSS(ob) {\n if (ob.prototype.css) {\n showCSS(ob.prototype);\n }\n}\n\nexport default class Layout extends View {\n static css = 'bar';\n constructor(tag, className) {\n super(createElem(tag, {className}));\n\n showCSS(this);\n }\n}\n\n/*\nclass ValueController ?? {\n const row = this.add(new Row());\n const label = row.add(new Label());\n const div = row.add(new Div());\n const row = div.add(new Row());\n}\n*/\n\n/*\nclass MyCustomThing extends ValueController {\n constructor(object, property, options) {\n const topRow = this.add(new Row());\n const bottomRow = this.add(new Row());\n topRow.add(new NumberView());\n topRow.add(new NumberView());\n topRow.add(new NumberView());\n topRow.add(new NumberView());\n bottomRow.add(new DirectionView());\n bottomRow.add(new DirectionView());\n bottomRow.add(new DirectionView());\n bottomRow.add(new DirectionView());\n }\n}\n new Grid([\n [new\n ]\n */","import Layout from './Layout.js';\n\nexport default class Column extends Layout {\n constructor() {\n super('div', 'muigui-row');\n }\n}\n","import Layout from './Layout.js';\n\nexport default class Frame extends Layout {\n static css = 'foo';\n constructor() {\n super('div', 'muigui-frame');\n }\n static get foo() {\n return 'boo';\n }\n}\n","import Layout from './Layout.js';\n\nexport default class Grid extends Layout {\n constructor() {\n super('div', 'muigui-grid');\n }\n}\n","import Layout from './Layout.js';\n\nexport default class Row extends Layout {\n constructor() {\n super('div', 'muigui-row');\n }\n}\n","import css from './styles/muigui.css.js';\nimport {createElem} from './libs/elem.js';\nimport {createController} from './controllers/create-controller.js';\nimport {\n mapRange,\n makeRangeConverters,\n makeRangeOptions,\n makeMinMaxPair,\n} from './libs/utils.js';\nimport {\n converters\n} from './libs/conversions.js';\nimport {\n hasAlpha,\n guessFormat,\n} from './libs/color-utils.js';\nimport Canvas from './controllers/Canvas.js';\nimport Color from './controllers/Color.js';\nimport Divider from './controllers/Divider.js';\nimport Folder from './controllers/Folder.js';\nimport Label from './controllers/Label.js';\nimport Controller from './controllers/Controller.js';\nimport ColorChooser from './controllers/ColorChooser.js';\n\nimport Column from './layout/Column.js';\nimport Frame from './layout/Frame.js';\nimport Grid from './layout/Grid.js';\nimport Row from './layout/Row.js';\n\nexport {\n Column,\n Frame,\n Grid,\n Row,\n};\n\nexport class GUIFolder extends Folder {\n add(object, property, ...args) {\n const controller = object instanceof Controller\n ? object\n : createController(object, property, ...args);\n return this.addController(controller);\n }\n addCanvas(name) {\n return this.addController(new Canvas(name));\n }\n addColor(object, property, options = {}) {\n const value = object[property];\n if (hasAlpha(options.format || guessFormat(value))) {\n return this.addController(new ColorChooser(object, property, options));\n } else {\n return this.addController(new Color(object, property, options));\n }\n }\n addDivider() {\n return this.addController(new Divider());\n }\n addFolder(name) {\n return this.addController(new GUIFolder(name));\n }\n addLabel(text) {\n return this.addController(new Label(text));\n }\n}\n\nclass MuiguiElement extends HTMLElement {\n constructor() {\n super();\n this.shadow = this.attachShadow({mode: 'open'});\n }\n}\n\ncustomElements.define('muigui-element', MuiguiElement);\n\nconst baseStyleSheet = new CSSStyleSheet();\nbaseStyleSheet.replaceSync(css.default);\nconst userStyleSheet = new CSSStyleSheet();\n\nfunction makeStyleSheetUpdater(styleSheet) {\n let newCss;\n let newCssPromise;\n\n function updateStyle() {\n if (newCss && !newCssPromise) {\n const s = newCss;\n newCss = undefined;\n newCssPromise = styleSheet.replace(s).then(() => {\n newCssPromise = undefined;\n updateStyle();\n });\n }\n }\n\n return function updateStyleSheet(css) {\n newCss = css;\n updateStyle();\n };\n}\n\nconst updateBaseStyle = makeStyleSheetUpdater(baseStyleSheet);\nconst updateUserStyle = makeStyleSheetUpdater(userStyleSheet);\n\nexport class GUI extends GUIFolder {\n static converters = converters;\n static mapRange = mapRange;\n static makeRangeConverters = makeRangeConverters;\n static makeRangeOptions = makeRangeOptions;\n static makeMinMaxPair = makeMinMaxPair;\n #localStyleSheet = new CSSStyleSheet();\n\n constructor(options = {}) {\n super('Controls', 'muigui-root');\n if (options instanceof HTMLElement) {\n options = {parent: options};\n }\n const {\n autoPlace = true,\n width,\n title = 'Controls',\n } = options;\n let {\n parent,\n } = options;\n\n if (width) {\n this.domElement.style.width = /^\\d+$/.test(width) ? `${width}px` : width;\n }\n if (parent === undefined && autoPlace) {\n parent = document.body;\n this.domElement.classList.add('muigui-auto-place');\n }\n if (parent) {\n const muiguiElement = createElem('muigui-element');\n muiguiElement.shadowRoot.adoptedStyleSheets = [baseStyleSheet, userStyleSheet, this.#localStyleSheet];\n muiguiElement.shadow.appendChild(this.domElement);\n parent.appendChild(muiguiElement);\n }\n if (title) {\n this.title(title);\n }\n this.domElement.classList.add('muigui', 'muigui-colors');\n }\n setStyle(css) {\n this.#localStyleSheet.replace(css);\n }\n static setBaseStyles(css) {\n updateBaseStyle(css);\n }\n static getBaseStyleSheet() {\n return baseStyleSheet;\n }\n static setUserStyles(css) {\n updateUserStyle(css);\n }\n static getUserStyleSheet() {\n return userStyleSheet;\n }\n static setTheme(name) {\n GUI.setBaseStyles(`${css.default}\\n${css.themes[name] || ''}`);\n }\n}\n\nexport default GUI;\n","function noop() {\n}\n\nconst keyDirections = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n\n// This probably needs to be global\nexport function addKeyboardEvents(elem, {onDown = noop, onUp = noop}) {\n const keyDown = function (event) {\n const mult = event.shiftKey ? 10 : 1;\n const [dx, dy] = (keyDirections[event.key] || [0, 0]).map(v => v * mult);\n const fn = event.type === 'keydown' ? onDown : onUp;\n fn({\n type: event.type.substring(3),\n dx,\n dy,\n event,\n });\n };\n\n elem.addEventListener('keydown', keyDown);\n elem.addEventListener('keyup', keyDown);\n\n return function () {\n elem.removeEventListener('keydown', keyDown);\n elem.removeEventListener('keyup', keyDown);\n };\n}","export function assert(truthy, msg = '') {\n if (!truthy) {\n throw new Error(msg);\n }\n}","import { assert } from '../libs/assert.js';\n\nfunction getEllipsePointForAngle(cx, cy, rx, ry, phi, theta) {\n const m = Math.abs(rx) * Math.cos(theta);\n const n = Math.abs(ry) * Math.sin(theta);\n\n return [\n cx + Math.cos(phi) * m - Math.sin(phi) * n,\n cy + Math.sin(phi) * m + Math.cos(phi) * n,\n ];\n}\n\nfunction getEndpointParameters(cx, cy, rx, ry, phi, theta, dTheta) {\n const [x1, y1] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta);\n const [x2, y2] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta + dTheta);\n\n const fa = Math.abs(dTheta) > Math.PI ? 1 : 0;\n const fs = dTheta > 0 ? 1 : 0;\n\n return { x1, y1, x2, y2, fa, fs };\n}\n\nexport function arc(cx, cy, r, start, end) {\n assert(Math.abs(start - end) <= Math.PI * 2);\n assert(start >= -Math.PI && start <= Math.PI * 2);\n assert(start <= end);\n assert(end >= -Math.PI && end <= Math.PI * 4);\n\n const { x1, y1, x2, y2, fa, fs } = getEndpointParameters(cx, cy, r, r, 0, start, end - start);\n return Math.abs(Math.abs(start - end) - Math.PI * 2) > Number.EPSILON\n ? `M${cx} ${cy} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2} L${cx} ${cy}`\n : `M${x1} ${y1} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2}`;\n}\n","import { identity } from '../libs/conversions.js';\nimport { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { arc } from '../libs/svg.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, euclideanModulo, lerp, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nconst twoPiMod = v => euclideanModulo(v + Math.PI, Math.PI * 2) - Math.PI;\n\nexport default class DirectionView extends EditView {\n #arrowElem;\n #rangeElem;\n #lastV;\n #wrap;\n #options = {\n step: 1,\n min: -180,\n max: 180,\n\n /*\n --------\n / -π/2 \\\n / | \\\n |<- -π * |\n | * 0 ->| zero is down the positive X axis\n |<- +π * |\n \\ | /\n \\ π/2 /\n --------\n */\n dirMin: -Math.PI,\n dirMax: Math.PI,\n //dirMin: Math.PI * 0.5,\n //dirMax: Math.PI * 2.5,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 7:30 to 10:30\n //dirMax: -Math.PI * 0.75,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 1:30\n //dirMax: -Math.PI * 0.25,\n //dirMin: Math.PI * 0.25, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.25,\n wrap: undefined,\n converters: identity,\n };\n\n constructor(setter, options = {}) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n className: 'muigui-direction muigui-no-scroll',\n innerHTML: svg,\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n let tempV = this.#lastV + delta;\n if (this.#wrap) {\n tempV = euclideanModulo(tempV - min, max - min) + min;\n }\n const newV = clamp(stepify(tempV, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n const handleTouch = (e) => {\n const {min, max, step, dirMin, dirMax} = this.#options;\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n const a = Math.atan2(ny, nx);\n\n const center = (dirMin + dirMax) / 2;\n\n const centeredAngle = twoPiMod(a - center);\n const centeredStart = twoPiMod(dirMin - center);\n const diff = dirMax - dirMin;\n\n const n = clamp((centeredAngle - centeredStart) / (diff), 0, 1);\n const newV = stepify(min + (max - min) * n, v => v, step);\n setter.setValue(newV);\n };\n addTouchEvents(this.domElement, {\n onDown: handleTouch,\n onMove: handleTouch,\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n this.#arrowElem = this.$('#muigui-arrow');\n this.#rangeElem = this.$('#muigui-range');\n this.setOptions(options);\n }\n updateDisplay(v) {\n this.#lastV = v;\n const {min, max} = this.#options;\n const n = (v - min) / (max - min);\n const angle = lerp(this.#options.dirMin, this.#options.dirMax, n);\n this.#arrowElem.style.transform = `rotate(${angle}rad)`;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {dirMin, dirMax, wrap} = this.#options;\n this.#wrap = wrap !== undefined\n ? wrap\n : Math.abs(dirMin - dirMax) >= Math.PI * 2 - Number.EPSILON;\n const [min, max] = dirMin < dirMax ? [dirMin, dirMax] : [dirMax , dirMin];\n this.#rangeElem.setAttribute('d', arc(0, 0, 28.87, min, max));\n }\n}\n","import { identity } from '../libs/conversions.js';\nimport DirectionView from '../views/DirectionView.js';\nimport NumberView from '../views/NumberView.js';\n// import ValueController from './ValueController.js';\nimport PopDownController from './PopDownController.js';\n\n\n// deg2rad\n// where is 0\n// range (0, 360), (-180, +180), (0,0) Really this is a range\n\nexport default class Direction extends PopDownController {\n #options;\n constructor(object, property, options) {\n super(object, property, 'muigui-direction');\nthis.#options = options; // FIX\n this.addTop(new NumberView(this,\nidentity));\n this.addBottom(new DirectionView(this, options));\n this.updateDisplay();\n }\n}\n\n","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport EditView from './EditView.js';\n\nexport default class RadioGridView extends EditView {\n #values;\n\n constructor(setter, keyValues, cols = 3) {\n const values = [];\n const name = makeId();\n super(createElem('div', {}, keyValues.map(([key, value], ndx) => {\n values.push(value);\n return createElem('label', {}, [\n createElem('input', {\n type: 'radio',\n name,\n value: ndx,\n onChange: function () {\n if (this.checked) {\n setter.setFinalValue(that.#values[this.value]);\n }\n },\n }),\n createElem('button', {\n type: 'button',\n textContent: key,\n onClick: function () {\n this.previousElementSibling.click();\n },\n }),\n ]);\n })));\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.#values = values;\n this.cols(cols);\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n for (let i = 0; i < this.domElement.children.length; ++i) {\n this.domElement.children[i].children[0].checked = i === ndx;\n }\n }\n cols(cols) {\n this.domElement.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;\n }\n}\n","import RadioGridView from '../views/RadioGridView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class RadioGrid extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-radio-grid');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {\n keyValues: keyValuesInput,\n cols = 3,\n } = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new RadioGridView(this, keyValues, cols));\n this.updateDisplay();\n }\n}","export function onResize(elem, callback) {\n new ResizeObserver(() => {\n callback({rect: elem.getBoundingClientRect(), elem});\n }).observe(elem);\n}\n\nexport function onResizeSVGNoScale(elem, hAnchor, vAnchor, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.setAttribute('viewBox', `-${width * hAnchor} -${height * vAnchor} ${width} ${height}`);\n callback({elem, rect});\n });\n}\n\nexport function onResizeCanvas(elem, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.width = width;\n elem.height = height;\n callback({elem, rect});\n });\n}\n","import { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nfunction createSVGTicks(start, end, step, min, max, height) {\n const p = [];\n if (start < min) {\n start += stepify(min - start, v => v, step);\n }\n end = Math.min(end, max);\n for (let i = start; i <= end; i += step) {\n p.push(`M${i} 0 l0 ${height}`);\n }\n return p.join(' ');\n}\n\nfunction createSVGNumbers(start, end, unitSize, unit, minusSize, min, max, labelFn) {\n const texts = [];\n if (start < min) {\n start += stepify(min - start, v => v, unitSize);\n }\n end = Math.min(end, max);\n const digits = Math.max(0, -Math.log10(unit));\n const f = v => labelFn(v.toFixed(digits));\n for (let i = start; i <= end; i += unitSize) {\n texts.push(`= 0 ? i : (i - minusSize / 2) }\" y=\"0\">${f(i / unitSize * unit)}`);\n }\n return texts.join('\\n');\n}\n\nfunction computeSizeOfMinus(elem) {\n const oldHTML = elem.innerHTML;\n elem.innerHTML = '- ';\n const text = elem.querySelector('text');\n const size = text.getComputedTextLength();\n elem.innerHTML = oldHTML;\n return size;\n}\n\nexport default class SliderView extends EditView {\n #svgElem;\n #originElem;\n #ticksElem;\n #thicksElem;\n #numbersElem;\n #leftGradElem;\n #rightGradElem;\n #width;\n #height;\n #lastV;\n #minusSize;\n #options = {\n min: -100,\n max: 100,\n step: 1,\n unit: 10,\n unitSize: 10,\n ticksPerUnit: 5,\n labelFn: v => v,\n tickHeight: 1,\n limits: true,\n thicksColor: undefined,\n orientation: undefined,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-v-scroll',\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(this.#lastV + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.#svgElem = this.$('svg');\n this.#originElem = this.$('#muigui-origin');\n this.#ticksElem = this.$('#muigui-ticks');\n this.#thicksElem = this.$('#muigui-thicks');\n this.#numbersElem = this.$('#muigui-numbers');\n this.#leftGradElem = this.$('#muigui-left-grad');\n this.#rightGradElem = this.$('#muigui-right-grad');\n this.setOptions(options);\n let startV;\n addTouchEvents(this.domElement, {\n onDown: () => {\n startV = this.#lastV;\n },\n onMove: (e) => {\n const {min, max, unitSize, unit, step} = this.#options;\n const newV = clamp(stepify(startV - e.dx / unitSize * unit, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n onResizeSVGNoScale(this.#svgElem, 0.5, 0, ({rect: {width}}) => {\n this.#leftGradElem.setAttribute('x', -width / 2);\n this.#rightGradElem.setAttribute('x', width / 2 - 20);\n this.#minusSize = computeSizeOfMinus(this.#numbersElem);\n this.#width = width;\n this.#updateSlider();\n });\n }\n // |--------V--------|\n // . . | . . . | . . . |\n //\n #updateSlider() {\n // There's no size if ResizeObserver has not fired yet.\n if (!this.#width || this.#lastV === undefined) {\n return;\n }\n const {\n labelFn,\n limits,\n min,\n max,\n orientation,\n tickHeight,\n ticksPerUnit,\n unit,\n unitSize,\n thicksColor,\n } = this.#options;\n const unitsAcross = Math.ceil(this.#width / unitSize);\n const center = this.#lastV;\n const centerUnitSpace = center / unit;\n const startUnitSpace = Math.round(centerUnitSpace - unitsAcross);\n const endUnitSpace = startUnitSpace + unitsAcross * 2;\n const start = startUnitSpace * unitSize;\n const end = endUnitSpace * unitSize;\n const minUnitSpace = limits ? min * unitSize / unit : start;\n const maxUnitSpace = limits ? max * unitSize / unit : end;\n const height = labelFn(1) === '' ? 10 : 5;\n if (ticksPerUnit > 1) {\n this.#ticksElem.setAttribute('d', createSVGTicks(start, end, unitSize / ticksPerUnit, minUnitSpace, maxUnitSpace, height * tickHeight));\n }\n this.#thicksElem.style.stroke = thicksColor; //setAttribute('stroke', thicksColor);\n this.#thicksElem.setAttribute('d', createSVGTicks(start, end, unitSize, minUnitSpace, maxUnitSpace, height));\n this.#numbersElem.innerHTML = createSVGNumbers(start, end, unitSize, unit, this.#minusSize, minUnitSpace, maxUnitSpace, labelFn);\n this.#originElem.setAttribute('transform', `translate(${-this.#lastV * unitSize / unit} 0)`);\n this.#svgElem.classList.toggle('muigui-slider-up', orientation === 'up');\n }\n updateDisplay(v) {\n this.#lastV = v;\n this.#updateSlider();\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n return this;\n }\n}\n","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport SliderView from '../views/SliderView.js';\n\nexport default class Slider extends ValueController {\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-slider');\n this.add(new SliderView(this, options));\n this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nexport default class Vec2View extends EditView {\n #svgElem;\n #arrowElem;\n #circleElem;\n #lastV = [];\n\n constructor(setter) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n const onTouch = (e) => {\n const {width, height} = this.#svgElem.getBoundingClientRect();\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n setter.setValue([nx * width * 0.5, ny * height * 0.5]);\n };\n addTouchEvents(this.domElement, {\n onDown: onTouch,\n onMove: onTouch,\n });\n this.#svgElem = this.$('svg');\n this.#arrowElem = this.$('#muigui-arrow');\n this.#circleElem = this.$('#muigui-circle');\n onResizeSVGNoScale(this.#svgElem, 0.5, 0.5, () => this.#updateDisplayImpl);\n }\n #updateDisplayImpl() {\n const [x, y] = this.#lastV;\n this.#arrowElem.setAttribute('d', `M0,0L${x},${y}`);\n this.#circleElem.setAttribute('transform', `translate(${x}, ${y})`);\n }\n updateDisplay(v) {\n this.#lastV[0] = v[0];\n this.#lastV[1] = v[1];\n this.#updateDisplayImpl();\n }\n}\n","import NumberView from '../views/NumberView.js';\nimport Vec2View from '../views/Vec2View.js';\nimport PopDownController from './PopDownController.js';\nimport { strToNumber } from '../libs/conversions.js';\n\n// TODO: zoom with wheel and pinch?\n// TODO: grid?\n// // options\n// scale:\n// range: number (both x and y + /)\n// range: array (min, max)\n// xRange:\n// deg/rad/turn\n\nexport default class Vec2 extends PopDownController {\n constructor(object, property) {\n super(object, property, 'muigui-vec2');\n\n const makeSetter = (ndx) => {\n return {\n setValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setValue(newV);\n },\n setFinalValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setFinalValue(newV);\n },\n };\n };\n\n this.addTop(new NumberView(makeSetter(0), {\n converters: {\n to: v => v[0],\n from: strToNumber.from,\n },\n }));\n this.addTop(new NumberView(makeSetter(1), {\n converters: {\n to: v => v[1],\n from: strToNumber.from,\n },\n }));\n this.addBottom(new Vec2View(this));\n this.updateDisplay();\n }\n}\n","import GUI from './muigui.js';\n\nimport ColorChooser from './controllers/ColorChooser.js';\nimport Direction from './controllers/Direction.js';\nimport RadioGrid from './controllers/RadioGrid.js';\nimport Range from './controllers/Range.js';\nimport Select from './controllers/Select.js';\nimport Slider from './controllers/Slider.js';\nimport TextNumber from './controllers/TextNumber.js';\nimport Vec2 from './controllers/Vec2.js';\n\nGUI.ColorChooser = ColorChooser;\nGUI.Direction = Direction;\nGUI.RadioGrid = RadioGrid;\nGUI.Range = Range;\nGUI.Select = Select;\nGUI.Slider = Slider;\nGUI.TextNumber = TextNumber;\nGUI.Vec2 = Vec2;\n\nexport default GUI;"],"names":["clamp","euclideanModulo","lerp","identity","noop","svg"],"mappings":";;;;;;;AAAA,YAAe;EACf,EAAE,OAAO,EAAE,CAAC;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;EACD,MAAM,EAAE;EACR,EAAE,OAAO,EAAE,EAAE;EACb,EAAE,KAAK,EAAE,CAAC;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;EACD,CAAC;EACD,CAAC;;ECnvBM,SAAS,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE;EACpD,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;EACpD,IAAI,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;EAC7D,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;EACvD,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;EAChE,KAAK,MAAM,IAAI,OAAO,KAAK,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/0.x/muigui.min.js b/dist/0.x/muigui.min.js
new file mode 100644
index 0000000..4d5665f
--- /dev/null
+++ b/dist/0.x/muigui.min.js
@@ -0,0 +1,2 @@
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).GUI=e()}(this,(function(){"use strict";var t={default:'\n.muigui {\n --bg-color: #ddd;\n --color: #222;\n --contrast-color: #eee;\n --value-color: #145 ;\n --value-bg-color: #eeee;\n --disabled-color: #999;\n --menu-bg-color: #f8f8f8;\n --menu-sep-color: #bbb;\n --hover-bg-color: #999;\n --focus-color: #68C;\n --range-color: #888888;\n --invalid-color: #FF0000;\n --selected-color: rgb(255, 255, 255, 0.9);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n}\n\n@media (prefers-color-scheme: dark) {\n .muigui {\n --bg-color: #222222;\n --color: #dddddd;\n --contrast-color: #000;\n --value-color: #43e5f7;\n --value-bg-color: #444444;\n --disabled-color: #666666;\n --menu-bg-color: #080808;\n --menu-sep-color: #444444;\n --hover-bg-color: #666666;\n --focus-color: #88AAFF;\n --range-color: #888888;\n --invalid-color: #FF6666;\n --selected-color: rgba(255, 255, 255, 0.3);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n }\n}\n\n.muigui {\n --width: 250px;\n --label-width: 45%;\n --number-width: 40%;\n\n\n --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;\n --font-size: 11px;\n --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;\n --font-size-mono: 11px;\n\n --line-height: 1.7em;\n --border-radius: 0px;\n\n width: var(--width);\n font-family: var(--font-family);\n font-size: var(--font-size);\n box-sizing: border-box;\n line-height: 100%;\n}\n.muigui * {\n box-sizing: inherit;\n}\n\n.muigui-no-scroll {\n touch-action: none;\n}\n.muigui-no-h-scroll {\n touch-action: pan-y;\n}\n.muigui-no-v-scroll {\n touch-action: pan-x;\n}\n\n.muigui-invalid-value {\n background-color: red !important;\n color: white !important;\n}\n\n.muigui-grid {\n display: grid;\n}\n.muigui-rows {\n display: flex;\n flex-direction: column;\n\n min-height: 20px;\n border: 2px solid red;\n}\n.muigui-columns {\n display: flex;\n flex-direction: row;\n\n height: 20px;\n border: 2px solid green;\n}\n.muigui-rows>*,\n.muigui-columns>* {\n flex: 1 1 auto;\n align-items: stretch;\n min-height: 0;\n min-width: 0;\n}\n\n.muigui-row {\n border: 2px solid yellow;\n min-height: 10px\n}\n.muigui-column {\n border: 2px solid lightgreen;\n}\n\n/* -------- */\n\n.muigui-show { /* */ }\n.muigui-hide { \n display: none !important;\n}\n.muigui-disabled {\n pointer-events: none;\n --color: var(--disabled-color) !important;\n --value-color: var(--disabled-color) !important;\n --range-left-color: var(--disabled-color) !important;\n}\n\n.muigui canvas,\n.muigui svg {\n display: block;\n border-radius: var(--border-radius);\n}\n.muigui canvas {\n background-color: var(--value-bg-color);\n}\n\n.muigui-controller {\n min-width: 0;\n min-height: var(--line-height);\n}\n.muigui-root,\n.muigui-menu {\n display: flex;\n flex-direction: column;\n position: relative;\n user-select: none;\n height: fit-content;\n margin: 0;\n padding-bottom: 0.1em;\n border-radius: var(--border-radius);\n}\n.muigui-menu {\n border-bottom: 1px solid var(--menu-sep-color);\n}\n\n.muigui-root>button:nth-child(1),\n.muigui-menu>button:nth-child(1) {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n position: relative;\n text-align: left;\n color: var(--color);\n background-color: var(--menu-bg-color);\n min-height: var(--line-height);\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n cursor: pointer;\n border-radius: var(--border-radius);\n}\n.muigui-root>div:nth-child(2),\n.muigui-menu>div:nth-child(2) {\n flex: 1 1 auto;\n}\n\n.muigui-controller {\n margin-left: 0.2em;\n margin-right: 0.2em;\n}\n.muigui-root.muigui-controller,\n.muigui-menu.muigui-controller {\n margin-left: 0;\n margin-right: 0;\n}\n.muigui-controller>*:nth-child(1) {\n flex: 1 0 var(--label-width);\n min-width: 0;\n white-space: pre;\n}\n.muigui-controller>label:nth-child(1) {\n place-content: center start;\n display: inline-grid;\n overflow: hidden;\n}\n.muigui-controller>*:nth-child(2) {\n flex: 1 1 75%;\n min-width: 0;\n}\n\n/* -----------------------------------------\n a label controller is [[label][value]]\n*/\n\n.muigui-label-controller {\n display: flex;\n margin: 0.4em 0 0.4em 0;\n word-wrap: initial;\n align-items: stretch;\n}\n\n.muigui-value {\n display: flex;\n align-items: stretch;\n}\n.muigui-value>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n.muigui-value>*:nth-child(1) {\n flex: 1 1 calc(100% - var(--number-width));\n}\n.muigui-value>*:nth-child(2) {\n flex: 1 1 var(--number-width);\n margin-left: 0.2em;\n}\n\n/* fix! */\n.muigui-open>button>label::before,\n.muigui-closed>button>label::before {\n width: 1.25em;\n height: var(--line-height);\n display: inline-grid;\n place-content: center start;\n pointer-events: none;\n}\n.muigui-open>button>label::before {\n content: "ⓧ"; /*"▼";*/\n}\n.muigui-closed>button>label::before {\n content: "⨁"; /*"▶";*/\n}\n.muigui-open>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 0.5s ease-out;\n max-height: 100vh;\n overflow: auto;\n opacity: 1;\n}\n\n.muigui-closed>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 1s;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n}\n\n/* ---- popdown ---- */\n\n.muigui-pop-down-top {\n display: flex;\n}\n/* fix? */\n.muigui-value>*:nth-child(1).muigui-pop-down-top {\n flex: 0;\n}\n.muigui-pop-down-bottom {\n\n}\n\n.muigui-pop-down-values {\n min-width: 0;\n display: flex;\n}\n.muigui-pop-down-values>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.muigui-value.muigui-pop-down-controller {\n flex-direction: column;\n}\n\n.muigui-pop-down-top input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-pop-down-top input[type=checkbox]::before {\n content: "+";\n display: grid;\n place-content: center;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n color: var(--value-bg-color);\n width: calc(var(--line-height) - 4px);\n height: calc(var(--line-height) - 4px);\n}\n\n.muigui-pop-down-top input[type=checkbox]:checked::before {\n content: "X";\n}\n\n\n/* ---- select ---- */\n\n.muigui select,\n.muigui option,\n.muigui input,\n.muigui button {\n color: var(--value-color);\n background-color: var(--value-bg-color);\n font-family: var(--font-family);\n font-size: var(--font-size);\n border: none;\n margin: 0;\n border-radius: var(--border-radius);\n}\n.muigui select {\n appearance: none;\n margin: 0;\n margin-left: 0; /*?*/\n overflow: hidden; /* Safari */\n}\n\n.muigui select:focus,\n.muigui input:focus,\n.muigui button:focus {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui select:hover,\n.muigui option:hover,\n.muigui input:hover,\n.muigui button:hover {\n background-color: var(--hover-bg-color); \n}\n\n/* ------ [ label ] ------ */\n\n.muigui-label {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n padding-top: 0.4em;\n padding-bottom: 0.3em;\n place-content: center start;\n background-color: var(--menu-bg-color);\n white-space: pre;\n border-radius: var(--border-radius);\n}\n\n/* ------ [ divider] ------ */\n\n.muigui-divider {\n min-height: 6px;\n border-top: 2px solid var(--menu-sep-color);\n margin-top: 6px;\n}\n\n/* ------ [ button ] ------ */\n\n.muigui-button {\n display: grid;\n\n}\n.muigui-button button {\n border: none;\n color: var(--value-color);\n background-color: var(--button-bg-color);\n cursor: pointer;\n place-content: center center;\n}\n\n/* ------ [ color ] ------ */\n\n.muigui-color>div {\n overflow: hidden;\n position: relative;\n margin-left: 0;\n margin-right: 0; /* why? */\n max-width: var(--line-height);\n border-radius: var(--border-radius);\n}\n\n.muigui-color>div:focus-within {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui-color input[type=color] {\n border: none;\n padding: 0;\n background: inherit;\n cursor: pointer;\n position: absolute;\n width: 200%;\n left: -10px;\n top: -10px;\n height: 200%;\n}\n.muigui-disabled canvas,\n.muigui-disabled svg,\n.muigui-disabled img,\n.muigui-disabled .muigui-color input[type=color] {\n opacity: 0.2;\n}\n\n/* ------ [ checkbox ] ------ */\n\n.muigui-checkbox>label:nth-child(2) {\n display: grid;\n place-content: center start;\n margin: 0;\n}\n\n.muigui-checkbox input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-checkbox input[type=checkbox]::before {\n content: "";\n color: var(--value-color);\n display: grid;\n place-content: center;\n}\n\n.muigui-checkbox input[type=checkbox]:checked::before {\n content: "✔";\n}\n\n.muigui input[type=number]::-webkit-inner-spin-button, \n.muigui input[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none;\n appearance: none;\n margin: 0; \n}\n.muigui input[type=number] {\n -moz-appearance: textfield;\n}\n\n/* ------ [ radio grid ] ------ */\n\n.muigui-radio-grid>div {\n display: grid;\n gap: 2px;\n}\n\n.muigui-radio-grid input {\n appearance: none;\n display: none;\n}\n\n.muigui-radio-grid button {\n color: var(--color);\n width: 100%;\n text-align: left;\n}\n\n.muigui-radio-grid input:checked + button {\n color: var(--value-color);\n background-color: var(--selected-color);\n}\n\n/* ------ [ color-chooser ] ------ */\n\n.muigui-color-chooser-cursor {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n.muigui-color-chooser-circle {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n\n\n/* ------ [ vec2 ] ------ */\n\n.muigui-vec2 svg {\n background-color: var(--value-bg-color);\n}\n\n.muigui-vec2-axis {\n stroke: 1px;\n stroke: var(--focus-color);\n}\n\n.muigui-vec2-line {\n stroke-width: 1px;\n stroke: var(--value-color);\n fill: var(--value-color);\n}\n\n/* ------ [ direction ] ------ */\n\n.muigui-direction svg {\n background-color: rgba(0,0,0,0.2);\n}\n\n.muigui-direction:focus-within svg {\n outline: none;\n}\n.muigui-direction-range {\n fill: var(--value-bg-color);\n}\n.muigui-direction svg:focus {\n outline: none;\n}\n.muigui-direction svg:focus .muigui-direction-range {\n stroke-width: 0.5px;\n stroke: var(--focus-color);\n}\n\n.muigui-direction-arrow {\n fill: var(--value-color);\n}\n\n/* ------ [ slider ] ------ */\n\n.muigui-slider>div {\n display: flex;\n align-items: stretch;\n height: var(--line-height);\n}\n.muigui-slider svg {\n flex: 1 1 auto;\n}\n.muigui-slider .muigui-slider-up #muigui-orientation {\n transform: scale(1, -1) translateY(-100%);\n}\n\n.muigui-slider .muigui-slider-up #muigui-number-orientation {\n transform: scale(1,-1);\n}\n\n.muigui-ticks {\n stroke: var(--range-color);\n}\n.muigui-thicks {\n stroke: var(--color);\n stroke-width: 2px;\n}\n.muigui-svg-text {\n fill: var(--color);\n font-size: 7px;\n}\n.muigui-mark {\n fill: var(--value-color);\n}\n\n/* ------ [ range ] ------ */\n\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: transparent;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n margin-top: calc((var(--line-height) - 2px) / -2);\n width: calc(var(--line-height) - 2px);\n height: calc(var(--line-height) - 2px);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n border: 1px solid var(--menu-sep-color);\n height: 2px;\n}\n\n\n/* dat.gui style - doesn\'t work on Safari iOS */\n\n/*\n.muigui-range input[type=range] {\n cursor: ew-resize;\n overflow: hidden;\n}\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: var(--range-right-color);\n margin: 0;\n}\n.muigui-range input[type=range]:hover {\n background-color: var(--range-right-hover-color);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n height: max-content;\n color: var(--range-left-color);\n margin-top: -1px;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0px;\n height: max-content;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n}\n*/\n\n/* FF */\n/*\n.muigui-range input[type=range]::-moz-slider-progress {\n background-color: var(--range-left-color); \n}\n.muigui-range input[type=range]::-moz-slider-thumb {\n height: max-content;\n width: 0;\n border: none;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n box-sizing: border-box;\n}\n*/\n\n.muigui-checkered-background {\n background-color: #404040;\n background-image:\n linear-gradient(45deg, #808080 25%, transparent 25%),\n linear-gradient(-45deg, #808080 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #808080 75%),\n linear-gradient(-45deg, transparent 75%, #808080 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0px;\n}\n\n/* ---------------------------------------------------------- */\n\n/* needs to be at bottom to take precedence */\n.muigui-auto-place {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 100001;\n}\n\n',themes:{default:"",float:"\n :root {\n color-scheme: light dark,\n }\n\n .muigui {\n --width: 400px;\n --bg-color: initial;\n --label-width: 25%;\n --number-width: 20%;\n }\n\n input,\n .muigui-label-controller>label {\n text-shadow:\n -1px -1px 0 var(--contrast-color),\n 1px -1px 0 var(--contrast-color),\n -1px 1px 0 var(--contrast-color),\n 1px 1px 0 var(--contrast-color);\n }\n\n .muigui-controller > label:nth-child(1) {\n place-content: center end;\n margin-right: 1em;\n }\n\n .muigui-value > :nth-child(2) {\n margin-left: 1em;\n }\n\n .muigui-root>*:nth-child(1) {\n display: none;\n }\n\n .muigui-range input[type=range]::-webkit-slider-thumb {\n border-radius: 1em;\n }\n\n .muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: initial;\n appearance: none;\n border: 1px solid rgba(0, 0, 0, 0.25);\n height: 2px;\n }\n\n .muigui-colors {\n --value-color: var(--color );\n --value-bg-color: rgba(0, 0, 0, 0.1);\n --disabled-color: #cccccc;\n --menu-bg-color: rgba(0, 0, 0, 0.1);\n --menu-sep-color: #bbbbbb;\n --hover-bg-color: rgba(0, 0, 0, 0);\n --invalid-color: #FF0000;\n --selected-color: rgba(0, 0, 0, 0.3);\n --range-color: rgba(0, 0, 0, 0.125);\n }\n"}};function e(t,e={},n=[]){const i=document.createElement(t);return function(t,e,n){for(const[n,i]of Object.entries(e))if("function"==typeof i&&n.startsWith("on")){const e=n.substring(2).toLowerCase();t.addEventListener(e,i,{passive:!1})}else if("object"==typeof i)for(const[e,o]of Object.entries(i))t[n][e]=o;else void 0===t[n]?t.setAttribute(n,i):t[n]=i;for(const e of n)t.appendChild(e)}(i,e,n),i}let n=0;function i(t,e){const n=t.indexOf(e);return n&&t.splice(n,1),t}function o(t,e,n){return Math.max(e,Math.min(n,t))}const r="undefined"!=typeof SharedArrayBuffer?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer},s=(t,e,n)=>Math.round(e(t)/n)/(1/n),a=(t,e)=>(t%e+e)%e;function l(t,e){for(const n in e)n in t&&(t[n]=e[n]);return t}const u=(t,e,n,i,o)=>(t-e)*(o-i)/(n-e)+i,c=({from:t,to:e})=>({to:n=>u(n,...t,...e),from:n=>[!0,u(n,...e,...t)]}),h=({from:t,to:e,step:n})=>({min:e[0],max:e[1],...n&&{step:n},converters:c({from:t,to:e})}),d={to:t=>t,from:t=>[!0,t]};function p(t,e,n,i,o){const{converters:{from:r}=d}=o,{min:s,max:a}=o,l=o.minRange||0,u=r(l)[1],c=t.add(e,n,{...o,min:s,max:a-l}).onChange((t=>{h.setValue(Math.min(a,Math.max(t+u,e[i])))})),h=t.add(e,i,{...o,min:s+l,max:a}).onChange((t=>{c.setValue(Math.max(s,Math.min(t-u,e[n])))}));return[c,h]}class m{domElement;#t;#e=[];constructor(t){this.domElement=t,this.#t=t}addElem(t){return this.#t.appendChild(t),t}removeElem(t){return this.#t.removeChild(t),t}pushSubElem(t){this.#t.appendChild(t),this.#t=t}popSubElem(){this.#t=this.#t.parentElement}add(t){return this.#e.push(t),this.addElem(t.domElement),t}remove(t){return this.removeElem(t.domElement),i(this.#e,t),t}pushSubView(t){this.pushSubElem(t.domElement)}popSubView(){this.popSubElem()}setOptions(t){for(const e of this.#e)e.setOptions(t)}updateDisplayIfNeeded(t,e){for(const n of this.#e)n.updateDisplayIfNeeded(t,e);return this}$(t){return this.domElement.querySelector(t)}}class g extends m{#n;#i;#o;constructor(t){super(e("div",{className:"muigui-controller"})),this.#n=[],this.#i=[],t&&this.domElement.classList.add(t)}get parent(){return this.#o}setParent(t){this.#o=t,this.enable(!this.disabled())}show(t=!0){return this.domElement.classList.toggle("muigui-hide",!t),this.domElement.classList.toggle("muigui-show",t),this}hide(){return this.show(!1)}disabled(){return!!this.domElement.closest(".muigui-disabled")}enable(t=!0){return this.domElement.classList.toggle("muigui-disabled",!t),["input","button","select","textarea"].forEach((t=>{this.domElement.querySelectorAll(t).forEach((t=>{const e=!!t.closest(".muigui-disabled");t.disabled=e}))})),this}disable(t=!0){return this.enable(!t)}onChange(t){return this.removeChange(t),this.#n.push(t),this}removeChange(t){return i(this.#n,t),this}onFinishChange(t){return this.removeFinishChange(t),this.#i.push(t),this}removeFinishChange(t){return i(this.#i,t),this}#r(t,e){for(const n of t)n.call(this,e)}emitChange(t,e,n){this.#r(this.#n,t),this.#o&&(void 0===e?this.#o.emitChange(t):this.#o.emitChange({object:e,property:n,value:t,controller:this}))}emitFinalChange(t,e,n){this.#r(this.#i,t),this.#o&&(void 0===e?this.#o.emitChange(t):this.#o.emitFinalChange({object:e,property:n,value:t,controller:this}))}updateDisplay(){}getColors(){const t=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase())),n=e("div");this.domElement.appendChild(n);const i=Object.fromEntries(["color","bg-color","value-color","value-bg-color","hover-bg-color","menu-bg-color","menu-sep-color","disabled-color"].map((e=>{n.style.color=`var(--${e})`;const i=getComputedStyle(n);return[t(e),i.color]})));return n.remove(),i}}class f extends g{#s;#a;#l;#u={name:""};constructor(t,n,i={}){super("muigui-button",""),this.#s=t,this.#a=n,this.#l=this.addElem(e("button",{type:"button",onClick:()=>{this.#s[this.#a](this)}})),this.setOptions({name:n,...i})}setOptions(t){l(this.#u,t);const{name:e}=this.#u;this.#l.textContent=e}}function b(t,e){if(t.length!==e.length)return!1;for(let n=0;n{t.setValue(i.checked)},onChange:()=>{t.setFinalValue(i.checked)}});super(e("label",{},[i])),this.#b=i}updateDisplay(t){this.#b.checked=t}}const w=[],y=new Set;let k,E;function $(){k=void 0,E=!0;for(const t of w)y.has(t)||t();E=!1,y.size&&(E?C():(y.forEach((t=>{i(w,t)})),y.clear())),C()}function C(){!k&&w.length&&(k=requestAnimationFrame($))}let V=0;function I(){return"muigui-"+ ++V}class M extends m{constructor(t=""){super(e("div",{className:"muigui-value"})),t&&this.domElement.classList.add(t)}}class S extends g{#v;#x;constructor(t="",n=""){super("muigui-label-controller"),this.#v=I(),this.#x=e("label",{for:this.#v}),this.domElement.appendChild(this.#x),this.pushSubView(new M(t)),this.name(n)}get id(){return this.#v}name(t){return this.#x.title===this.#x.textContent&&(this.#x.title=t),this.#x.textContent=t,this}tooltip(t){this.#x.title=t}}class D extends S{#s;#a;#w;#y;#e;#k;constructor(t,e,n=""){super(n,e),this.#s=t,this.#a=e,this.#w=this.getValue(),this.#y=!1,this.#e=[]}get initialValue(){return this.#w}get object(){return this.#s}get property(){return this.#a}add(t){return this.#e.push(t),super.add(t),this.updateDisplay(),t}#E(t,e){let n=!1;if("object"==typeof t){const e=this.#s[this.#a];if(Array.isArray(t)||r(t))for(let i=0;i=0&&w.splice(e,1)}(this.#k)),this}}class N extends D{constructor(t,e){super(t,e,"muigui-checkbox");const n=this.id;this.add(new x(this,n)),this.updateDisplay()}}const F={to:t=>t,from:t=>[!0,t]},A={to:t=>t.toString(),from:t=>{const e=parseFloat(t);return[!Number.isNaN(e),e]}},U={radToDeg:c({to:[0,180],from:[0,Math.PI]})};function L(){let t=0;return function(e,n,i=5){t-=e.deltaY*n/i;const o=Math.floor(Math.abs(t)/n)*Math.sign(t)*n;return t-=o,o}}class O extends v{#$;#C;#V;#I;#u={step:.01,converters:A,min:Number.NEGATIVE_INFINITY,max:Number.POSITIVE_INFINITY};constructor(t,n){const i=t.setValue.bind(t),r=t.setFinalValue.bind(t),a=L();super(e("input",{type:"number",onInput:()=>this.#M(i,!0),onChange:()=>this.#M(r,!1),onWheel:e=>{e.preventDefault();const{min:n,max:i,step:r}=this.#u,l=a(e,r),u=parseFloat(this.domElement.value),c=o(s(u+l,(t=>t),r),n,i);t.setValue(c)}})),this.setOptions(n)}#M(t,e){const n=parseFloat(this.domElement.value),[i,r]=this.#C(n);let s;if(i&&!Number.isNaN(n)){const{min:n,max:i}=this.#u;s=r>=n&&r<=i,this.#I=e,t(o(r,n,i))}this.domElement.classList.toggle("muigui-invalid-value",!i||!s)}updateDisplay(t){this.#I||(this.domElement.value=s(t,this.#$,this.#V)),this.#I=!1}setOptions(t){l(this.#u,t);const{step:e,converters:{to:n,from:i}}=this.#u;return this.#$=n,this.#C=i,this.#V=e,this}}class j extends D{#S;#V;constructor(t,e,n={}){super(t,e,"muigui-checkbox"),this.#S=this.add(new O(this,n)),this.updateDisplay()}}class T extends v{#D;constructor(t,n){const i=[];super(e("select",{onChange:()=>{t.setFinalValue(this.#D[this.domElement.selectedIndex])}},n.map((([t,n])=>(i.push(n),e("option",{textContent:t})))))),this.#D=i}updateDisplay(t){const e=this.#D.indexOf(t);this.domElement.selectedIndex=e}}function H(t,e){return Array.isArray(t)?Array.isArray(t[0])?t:e?t.map(((t,e)=>[t,e])):t.map((t=>[t,t])):[...Object.entries(t)]}class z extends D{constructor(t,e,n){super(t,e,"muigui-select");const i="number"==typeof this.getValue(),{keyValues:o}=n,r=H(o,i);this.add(new T(this,r)),this.updateDisplay()}}class P extends v{#$;#C;#V;#I;#u={step:.01,min:0,max:1,converters:F};constructor(t,n){const i=L();super(e("input",{type:"range",onInput:()=>{this.#I=!0;const{min:e,max:n,step:i}=this.#u,r=parseFloat(this.domElement.value),a=o(s(r,(t=>t),i),e,n),[l,u]=this.#C(a);l&&t.setValue(u)},onChange:()=>{this.#I=!0;const{min:e,max:n,step:i}=this.#u,r=parseFloat(this.domElement.value),a=o(s(r,(t=>t),i),e,n),[l,u]=this.#C(a);l&&t.setFinalValue(u)},onWheel:e=>{e.preventDefault();const[n,r]=this.#C(parseFloat(this.domElement.value));if(!n)return;const{min:a,max:l,step:u}=this.#u,c=i(e,u),h=o(s(r+c,(t=>t),u),a,l);t.setValue(h)}})),this.setOptions(n)}updateDisplay(t){this.#I||(this.domElement.value=s(t,this.#$,this.#V)),this.#I=!1}setOptions(t){l(this.#u,t);const{step:e,min:n,max:i,converters:{to:o,from:r}}=this.#u;return this.#$=o,this.#C=r,this.#V=e,this.domElement.step=e,this.domElement.min=n,this.domElement.max=i,this}}class B extends D{constructor(t,e,n){super(t,e,"muigui-range"),this.add(new P(this,n)),this.add(new O(this,n))}}class G extends v{#$;#C;#I;#u={converters:F};constructor(t,n){const i=t.setValue.bind(t),o=t.setFinalValue.bind(t);super(e("input",{type:"text",onInput:()=>this.#M(i,!0),onChange:()=>this.#M(o,!1)})),this.setOptions(n)}#M(t,e){const[n,i]=this.#C(this.domElement.value);n&&(this.#I=e,t(i)),this.domElement.style.color=n?"":"var(--invalid-color)"}updateDisplay(t){this.#I||(this.domElement.value=this.#$(t),this.domElement.style.color=""),this.#I=!1}setOptions(t){l(this.#u,t);const{converters:{to:e,from:n}}=this.#u;return this.#$=e,this.#C=n,this}}class R extends D{constructor(t,e){super(t,e,"muigui-checkbox"),this.add(new G(this)),this.updateDisplay()}}const Y=(t,e,n)=>Math.max(e,Math.min(n,t)),K=(t,e,n)=>t+(e-t)*n,W=t=>t>=0?t%1:1-t%1,q=t=>+t.toFixed(0),J=t=>+t.toFixed(3),_=t=>parseInt(t.substring(1,3),16)<<16|parseInt(t.substring(3,5),16)<<8|parseInt(t.substring(5,7),16),X=t=>parseInt(t.substring(1,3),16)*2**24+65536*parseInt(t.substring(3,5),16)+256*parseInt(t.substring(5,7),16)+parseInt(t.substring(7,9),16),Z=t=>[parseInt(t.substring(1,3),16),parseInt(t.substring(3,5),16),parseInt(t.substring(5,7),16)],Q=t=>`#${Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}`,tt=t=>[parseInt(t.substring(1,3),16),parseInt(t.substring(3,5),16),parseInt(t.substring(5,7),16),parseInt(t.substring(7,9),16)],et=t=>`#${Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}`,nt=t=>Z(t).map((t=>J(t/255))),it=t=>Q(Array.from(t).map((t=>Math.round(Y(255*t,0,255))))),ot=t=>tt(t).map((t=>J(t/255))),rt=t=>et(Array.from(t).map((t=>Math.round(Y(255*t,0,255))))),st=t=>Y(Math.round(255*t),0,255).toString(16).padStart(2,"0"),at=t=>({r:parseInt(t.substring(1,3),16)/255,g:parseInt(t.substring(3,5),16)/255,b:parseInt(t.substring(5,7),16)/255}),lt=t=>({r:parseInt(t.substring(1,3),16)/255,g:parseInt(t.substring(3,5),16)/255,b:parseInt(t.substring(5,7),16)/255,a:parseInt(t.substring(7,9),16)/255}),ut=t=>`rgb(${Z(t).join(", ")})`,ct=/^\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/,ht=t=>`rgba(${tt(t).map(((t,e)=>3===e?t/255:t)).join(", ")})`,dt=/^\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+\.\d+|\d+)\s*\)\s*$/,pt=t=>{const e=yt(Z(t)).map((t=>q(t)));return`hsl(${e[0]}, ${e[1]}%, ${e[2]}%)`},mt=t=>{const e=kt(tt(t)).map(((t,e)=>3===e?J(t):q(t)));return`hsl(${e[0]} ${e[1]}% ${e[2]}% / ${e[3]})`},gt=/^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\)\s*$/,ft=/^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\/\s*(\d+\.\d+|\d+)\s*\)\s*$/,bt=(t,e)=>(t%e+e)%e;function vt([t,e,n]){t=bt(t,360),e=Y(e/100,0,1),n=Y(n/100,0,1);const i=e*Math.min(n,1-n);function o(e){const o=(e+t/30)%12;return n-i*Math.max(-1,Math.min(o-3,9-o,1))}return[o(0),o(8),o(4)].map((t=>Math.round(255*t)))}function xt([t,e,n]){const i=Math.max(t,e,n),o=Math.min(t,e,n),r=.5*(o+i),s=i-o;let a=0,l=0;if(0!==s)switch(l=0===r||1===r?0:(i-r)/Math.min(r,1-r),i){case t:a=(e-n)/s+(e{const[e,n,i]=xt(t.map((t=>t/255)));return[360*e,100*n,100*i]},kt=t=>{const[e,n,i,o]=wt(t.map((t=>t/255)));return[360*e,100*n,100*i,o]};function Et([t,e,n]){return e=Y(e,0,1),n=Y(n,0,1),[t,t+2/3,t+1/3].map((t=>K(1,Y(Math.abs(6*W(t)-3)-1,0,1),e)*n))}function $t([t,e,n,i]){return[...Et([t,e,n]),i]}const Ct=t=>Math.round(1e3*t)/1e3;function Vt([t,e,n]){const i=n>e?[n,e,-1,2/3]:[e,n,0,-1/3],o=i[0]>t?[i[0],i[1],i[3],t]:[t,i[1],i[2],i[0]],r=o[0]-Math.min(o[3],o[1]);return[Math.abs(o[2]+(o[3]-o[1])/(6*r+Number.EPSILON)),r/(o[0]+Number.EPSILON),o[0]].map(Ct)}const It=t=>t.endsWith("a")||t.startsWith("hex8"),Mt=[{re:/^#(?:[0-9a-f]){6}$/i,format:"hex6"},{re:/^(?:[0-9a-f]){6}$/i,format:"hex6-no-hash"},{re:/^#(?:[0-9a-f]){8}$/i,format:"hex8"},{re:/^(?:[0-9a-f]){8}$/i,format:"hex8-no-hash"},{re:/^#(?:[0-9a-f]){3}$/i,format:"hex3"},{re:/^(?:[0-9a-f]){3}$/i,format:"hex3-no-hash"},{re:ct,format:"css-rgb"},{re:gt,format:"css-hsl"},{re:dt,format:"css-rgba"},{re:ft,format:"css-hsla"}];function St(t){switch(typeof t){case"number":return console.warn('can not reliably guess format based on a number. You should pass in a format like {format: "uint32-rgb"} or {format: "uint32-rgb"}'),t<=16777215?"uint32-rgb":"uint32-rgba";case"string":{const e=function(t){for(const e of Mt)if(e.re.test(t))return e}(t.trim());if(e)return e.format;break}case"object":if(t instanceof Uint8Array||t instanceof Uint8ClampedArray){if(3===t.length)return"uint8-rgb";if(4===t.length)return"uint8-rgba"}else if(t instanceof Float32Array){if(3===t.length)return"float-rgb";if(4===t.length)return"float-rgba"}else if(Array.isArray(t)){if(3===t.length)return"float-rgb";if(4===t.length)return"float-rgba"}else if("r"in t&&"g"in t&&"b"in t)return"a"in t?"object-rgba":"object-rgb"}throw new Error(`unknown color format: ${t}`)}function Dt(t){return t.trim(t)}function Nt(t){return t.trim(t)}function Ft(t){return t[1]===t[2]&&t[3]===t[4]&&t[5]===t[6]?`#${t[1]}${t[3]}${t[5]}`:t}const At=/^(#|)([0-9a-f]{3})$/i;function Ut(t){const e=At.exec(t);if(e){const[,,t]=e;return"#"+`${(n=t)[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`}var n;return t}function Lt(t){return Ft(Dt(t))}const Ot=t=>{const e=ct.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3]].map((t=>parseInt(t)));return[!n.find((t=>t>255)),`rgb(${n.join(", ")})`]},jt=t=>{const e=dt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3],e[4]].map(((t,e)=>3===e?parseFloat(t):parseInt(t)));return[!n.find((t=>t>255)),`rgba(${n.join(", ")})`]},Tt=t=>{const e=gt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3]].map((t=>parseFloat(t)));return[!n.find((t=>Number.isNaN(t))),`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`]},Ht=t=>{const e=ft.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3],e[4]].map((t=>parseFloat(t)));return[!n.find((t=>Number.isNaN(t))),`hsl(${n[0]} ${n[1]}% ${n[2]}% / ${n[3]})`]},zt=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/,Pt=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/,Bt=/^\s*(?:0x){0,1}([0-9a-z]{1,6})\s*$/i,Gt=/^\s*(?:0x){0,1}([0-9a-z]{1,8})\s*$/i,Rt=/^\s*#[a-f0-9]{6}\s*$|^\s*#[a-f0-9]{3}\s*$/i,Yt=/^\s*[a-f0-9]{6}\s*$/i,Kt=/^\s*#[a-f0-9]{8}\s*$/i,Wt=/^\s*[a-f0-9]{8}\s*$/i,qt={hex6:{color:{from:t=>[!0,t],to:Dt},text:{from:t=>[Rt.test(t),t.trim()],to:t=>t}},hex8:{color:{from:t=>[!0,t],to:Nt},text:{from:t=>[Kt.test(t),t.trim()],to:t=>t}},hex3:{color:{from:t=>[!0,Lt(t)],to:Ut},text:{from:t=>[Rt.test(t),Ft(t.trim())],to:t=>t}},"hex6-no-hash":{color:{from:t=>[!0,t.substring(1)],to:t=>`#${Dt(t)}`},text:{from:t=>[Yt.test(t),t.trim()],to:t=>t}},"hex8-no-hash":{color:{from:t=>[!0,t.substring(1)],to:t=>`#${Nt(t)}`},text:{from:t=>[Wt.test(t),t.trim()],to:t=>t}},"hex3-no-hash":{color:{from:t=>[!0,Lt(t).substring(1)],to:Ut},text:{from:t=>[Yt.test(t),Ft(t.trim())],to:t=>t}},"uint32-rgb":{color:{from:t=>[!0,_(t)],to:t=>`#${Math.round(t).toString(16).padStart(6,"0")}`},text:{from:t=>(t=>{const e=Bt.exec(t);return e?[!0,parseInt(e[1],16)]:[!1]})(t),to:t=>`0x${t.toString(16).padStart(6,"0")}`}},"uint32-rgba":{color:{from:t=>[!0,X(t)],to:t=>`#${Math.round(t).toString(16).padStart(8,"0")}`},text:{from:t=>(t=>{const e=Gt.exec(t);return e?[!0,parseInt(e[1],16)]:[!1]})(t),to:t=>`0x${t.toString(16).padStart(8,"0")}`}},"uint8-rgb":{color:{from:t=>[!0,Z(t)],to:Q},text:{from:t=>{const e=zt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3]].map((t=>parseInt(t)));return[!n.find((t=>t>255)),n]},to:t=>t.join(", ")}},"uint8-rgba":{color:{from:t=>[!0,tt(t)],to:et},text:{from:t=>{const e=Pt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3],e[4]].map((t=>parseInt(t)));return[!n.find((t=>t>255)),n]},to:t=>t.join(", ")}},"float-rgb":{color:{from:t=>[!0,nt(t)],to:it},text:{from:t=>{const e=t.split(",").map((t=>t.trim())),n=e.map((t=>parseFloat(t)));if(3!==n.length)return[!1];const i=e.findIndex((t=>isNaN(t)));return[i<0,n.map((t=>J(t)))]},to:t=>Array.from(t).map((t=>J(t))).join(", ")}},"float-rgba":{color:{from:t=>[!0,ot(t)],to:rt},text:{from:t=>{const e=t.split(",").map((t=>t.trim())),n=e.map((t=>parseFloat(t)));if(4!==n.length)return[!1];const i=e.findIndex((t=>isNaN(t)));return[i<0,n.map((t=>J(t)))]},to:t=>Array.from(t).map((t=>J(t))).join(", ")}},"object-rgb":{color:{from:t=>[!0,at(t)],to:t=>`#${st(t.r)}${st(t.g)}${st(t.b)}`},text:{from:t=>{try{const e=t.replace(/([a-z])/g,'"$1"'),n=JSON.parse(e);if(Number.isNaN(n.r)||Number.isNaN(n.g)||Number.isNaN(n.b))throw new Error("not {r, g, b}");return[!0,n]}catch(t){return[!1]}},to:t=>`{r:${J(t.r)}, g:${J(t.g)}, b:${J(t.b)}}`}},"object-rgba":{color:{from:t=>[!0,lt(t)],to:t=>`#${st(t.r)}${st(t.g)}${st(t.b)}${st(t.a)}`},text:{from:t=>{try{const e=t.replace(/([a-z])/g,'"$1"'),n=JSON.parse(e);if(Number.isNaN(n.r)||Number.isNaN(n.g)||Number.isNaN(n.b)||Number.isNaN(n.a))throw new Error("not {r, g, b, a}");return[!0,n]}catch(t){return[!1]}},to:t=>`{r:${J(t.r)}, g:${J(t.g)}, b:${J(t.b)}}, a:${J(t.a)}}`}},"css-rgb":{color:{from:t=>[!0,ut(t)],to:t=>{const e=ct.exec(t);return Q([e[1],e[2],e[3]].map((t=>parseInt(t))))}},text:{from:Ot,to:t=>Ot(t)[1]}},"css-rgba":{color:{from:t=>[!0,ht(t)],to:t=>{const e=dt.exec(t);return et([e[1],e[2],e[3],e[4]].map(((t,e)=>3===e?255*parseFloat(t)|0:parseInt(t))))}},text:{from:jt,to:t=>jt(t)[1]}},"css-hsl":{color:{from:t=>[!0,pt(t)],to:t=>{const e=gt.exec(t),n=vt([e[1],e[2],e[3]].map((t=>parseFloat(t))));return Q(n)}},text:{from:Tt,to:t=>Tt(t)[1]}},"css-hsla":{color:{from:t=>[!0,mt(t)],to:t=>{const e=ft.exec(t),n=function([t,e,n,i]){return[...vt([t,e,n]),255*i|0]}([e[1],e[2],e[3],e[4]].map((t=>parseFloat(t))));return et(n)}},text:{from:Ht,to:t=>Ht(t)[1]}}};class Jt extends m{constructor(t,n){super(e(t,{className:n}))}}class _t extends S{#N;constructor(){super("muigui-canvas"),this.#N=this.add(new Jt("canvas","muigui-canvas")).domElement}get canvas(){return this.#N}}class Xt extends v{#$;#C;#F;#I;#u={converters:F};constructor(t,n){const i=e("input",{type:"color",onInput:()=>{const[e,n]=this.#C(i.value);e&&(this.#I=!0,t.setValue(n))},onChange:()=>{const[e,n]=this.#C(i.value);e&&(this.#I=!0,t.setFinalValue(n))}});super(e("div",{},[i])),this.setOptions(n),this.#F=i}updateDisplay(t){this.#I||(this.#F.value=this.#$(t)),this.#I=!1}setOptions(t){l(this.#u,t);const{converters:{to:e,from:n}}=this.#u;return this.#$=e,this.#C=n,this}}class Zt extends D{#A;#S;constructor(t,e,n={}){super(t,e,"muigui-color");const i=n.format||St(this.getValue()),{color:o,text:r}=qt[i];this.#A=this.add(new Xt(this,{converters:o})),this.#S=this.add(new G(this,{converters:r})),this.updateDisplay()}setOptions(t){const{format:e}=t;if(e){const{color:t,text:n}=qt[e];this.#A.setOptions({converters:t}),this.#S.setOptions({converters:n})}return super.setOptions(t),this}}class Qt extends g{constructor(){super("muigui-divider")}}class te extends g{#U;#L;constructor(t){super(t),this.#U=[],this.#L=this}get children(){return this.#U}get controllers(){return this.#U.filter((t=>!(t instanceof te)))}get folders(){return this.#U.filter((t=>t instanceof te))}reset(t=!0){for(const e of this.#U)e instanceof te&&!t||e.reset(t);return this}updateDisplay(){for(const t of this.#U)t.updateDisplay();return this}remove(t){const e=this.#U.indexOf(t);if(e>=0){const t=this.#U.splice(e,1)[0];t.domElement.remove(),t.setParent(null)}return this}#O(t){return this.domElement.appendChild(t.domElement),this.#U.push(t),t.setParent(this),t}addController(t){return this.#L.#O(t)}pushContainer(t){return this.addController(t),this.#L=t,t}popContainer(){return this.#L=this.#L.parent,this}}class ee extends te{#j;constructor(t="Controls",n="muigui-menu"){super(n),this.#j=e("label"),this.addElem(e("button",{type:"button",onClick:()=>this.toggleOpen()},[this.#j])),this.pushContainer(new te),this.name(t),this.open()}open(t=!0){return this.domElement.classList.toggle("muigui-closed",!t),this.domElement.classList.toggle("muigui-open",t),this}close(){return this.open(!1)}name(t){return this.#j.textContent=t,this}title(t){return this.name(t)}toggleOpen(){return this.open(!this.domElement.classList.contains("muigui-open")),this}}class ne extends g{constructor(t){super("muigui-label"),this.text(t)}text(t){return this.domElement.textContent=t,this}}function ie(){}function oe(t,e,n){const i=t.getBoundingClientRect(),o=e.clientX-i.left,r=e.clientY-i.top,s=o/i.width,a=r/i.height,l=o-(n=n||[o,r])[0],u=r-n[1];return{x:o,y:r,nx:s,ny:a,dx:l,dy:u,ndx:l/i.width,ndy:u/i.width}}function re(t,{onDown:e=ie,onMove:n=ie,onUp:i=ie}){let o;const r=function(e){const i={type:"move",...oe(t,e,o)};n(i)},s=function(e){t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",s),document.body.style.backgroundColor="",i("up")},a=function(n){t.addEventListener("pointermove",r),t.addEventListener("pointerup",s),t.setPointerCapture(n.pointerId);const i=oe(t,n);o=[i.x,i.y],e({type:"down",...i})};return t.addEventListener("pointerdown",a),function(){t.removeEventListener("pointerdown",a)}}function se(t){return t.querySelectorAll("[data-src]").forEach((e=>{const i="muigui-id-"+n++;e.id=i,t.querySelectorAll(`[data-target=${e.dataset.src}]`).forEach((t=>{t.setAttribute("fill",`url(#${i})`)}))})),t}class ae extends v{#$;#C;#T;#H;#z;#P;#B;#G;#R;#Y;#K;#W;#q;#J;#u={converters:F,alpha:!1};#_;#X;constructor(t,n){super(e("div",{innerHTML:'\n\n\n\n',className:"muigui-no-scroll"})),this.#T=this.domElement.children[0],this.#z=this.domElement.children[1],this.#G=this.domElement.children[2],se(this.#T),se(this.#z),se(this.#G),this.#H=this.$(".muigui-color-chooser-circle"),this.#P=this.$("[data-src=muigui-color-chooser-hue]"),this.#B=this.$(".muigui-color-chooser-hue-cursor"),this.#R=this.$("[data-src=muigui-color-chooser-alpha]"),this.#Y=this.$(".muigui-color-chooser-alpha-cursor");const i=e=>{const n=o(e.nx,0,1),i=o(e.ny,0,1);this.#K[1]=n,this.#K[2]=1-i,this.#W=!0,this.#J=!0;const[r,s]=this.#C(this.#_(this.#K));r&&t.setValue(s)},r=e=>{const n=o(e.nx,0,1);this.#K[0]=n,this.#q=!0,this.#J=!0;const[i,r]=this.#C(this.#_(this.#K));i&&t.setValue(r)},s=e=>{const n=o(e.nx,0,1);this.#K[3]=n,this.#W=!0,this.#q=!0;const[i,r]=this.#C(this.#_(this.#K));i&&t.setValue(r)};re(this.#T,{onDown:i,onMove:i}),re(this.#z,{onDown:r,onMove:r}),re(this.#G,{onDown:s,onMove:s}),this.setOptions(n)}updateDisplay(t){this.#K||(this.#K=this.#X(this.#$(t)));{const[e,n,i,o=1]=this.#X(this.#$(t));this.#W||(this.#K[0]=n>.001&&i>.001?e:this.#K[0]),this.#q||(this.#K[1]=n,this.#K[2]=i),this.#J||(this.#K[3]=o)}{const[t,e,n,i]=this.#K,[o,r,s]=wt($t(this.#K));this.#W||this.#B.setAttribute("transform",`translate(${64*t}, 0)`),this.#P.children[0].setAttribute("stop-color",`hsl(${360*o} 0% 100% / ${i})`),this.#P.children[1].setAttribute("stop-color",`hsl(${360*o} 100% 50% / ${i})`),this.#J||this.#Y.setAttribute("transform",`translate(${64*i}, 0)`),this.#R.children[0].setAttribute("stop-color",`hsl(${360*o} ${100*r}% ${100*s}% / 0)`),this.#R.children[1].setAttribute("stop-color",`hsl(${360*o} ${100*r}% ${100*s}% / 1)`),this.#q||(this.#H.setAttribute("cx",""+64*e),this.#H.setAttribute("cy",""+48*(1-n)))}this.#W=!1,this.#q=!1,this.#J=!1}setOptions(t){l(this.#u,t);const{converters:{to:e,from:n},alpha:i}=this.#u;return this.#G.style.display=i?"":"none",this.#_=i?t=>rt($t(t)):t=>it(Et(t)),this.#X=i?t=>function([t,e,n,i]){return[...Vt([t,e,n]),i]}(ot(t)):t=>Vt(nt(t)),this.#$=e,this.#C=n,this}}class le extends D{#Z;#Q;#b;#tt;#u={open:!1};constructor(t,n,i={}){super(t,n,"muigui-pop-down-controller"),this.#Z=this.add(new Jt("div","muigui-pop-down-top"));const o=this.#Z.addElem(e("input",{type:"checkbox",onChange:()=>{this.#u.open=o.checked,this.updateDisplay()}}));this.#b=o,this.#Q=this.#Z.add(new Jt("div","muigui-pop-down-values")),this.#tt=this.add(new Jt("div","muigui-pop-down-bottom")),this.setOptions(i)}setKnobColor(t){this.#b&&(this.#b.style=`\n --range-color: ${t};\n --value-bg-color: ${t};\n `)}updateDisplay(){super.updateDisplay();const{open:t}=this.#u;this.domElement.children[1].classList.toggle("muigui-open",t),this.domElement.children[1].classList.toggle("muigui-closed",!t)}setOptions(t){l(this.#u,t),super.setOptions(t),this.updateDisplay()}addTop(t){return this.#Q.add(t)}addBottom(t){return this.#tt.add(t)}}class ue extends le{#A;#S;#$;#et;constructor(t,e,n={}){super(t,e,"muigui-color-chooser");const i=n.format||St(this.getValue()),{color:o,text:r}=qt[i];this.#$=o.to,this.#S=new G(this,{converters:r,alpha:It(i)}),this.#A=new ae(this,{converters:o,alpha:It(i)}),this.addTop(this.#S),this.addBottom(this.#A),this.#et=()=>{if(this.#$){const t=this.#$(this.getValue()),e=yt(Z(t));e[2]=(e[2]+50)%100;const n=Q(vt(e));this.setKnobColor(`${t.substring(0,7)}FF`,n)}},this.updateDisplay()}updateDisplay(){super.updateDisplay(),this.#et&&this.#et()}setOptions(t){return super.setOptions(t),this}}class ce extends ee{add(t,e,...n){const i=t instanceof g?t:function(t,e,...n){const[i]=n;if(Array.isArray(i))return new z(t,e,{keyValues:i});const o=typeof t[e];switch(o){case"number":if("number"==typeof n[0]&&"number"==typeof n[1]){const i=n[0],o=n[1],r=n[2];return new B(t,e,{min:i,max:o,...r&&{step:r}})}return 0===n.length?new j(t,e,...n):new B(t,e,...n);case"boolean":return new N(t,e,...n);case"function":return new f(t,e,...n);case"string":return new R(t,e,...n);case"undefined":throw new Error(`no property named ${e}`);default:throw new Error(`unhandled type ${o} for property ${e}`)}}(t,e,...n);return this.addController(i)}addCanvas(t){return this.addController(new _t(t))}addColor(t,e,n={}){const i=t[e];return It(n.format||St(i))?this.addController(new ue(t,e,n)):this.addController(new Zt(t,e,n))}addDivider(){return this.addController(new Qt)}addFolder(t){return this.addController(new ce(t))}addLabel(t){return this.addController(new ne(t))}}class he extends HTMLElement{constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}}customElements.define("muigui-element",he);const de=new CSSStyleSheet;de.replaceSync(t.default);const pe=new CSSStyleSheet;function me(t){let e,n;function i(){if(e&&!n){const o=e;e=void 0,n=t.replace(o).then((()=>{n=void 0,i()}))}}return function(t){e=t,i()}}const ge=me(de),fe=me(pe);class be extends ce{static converters=U;static mapRange=u;static makeRangeConverters=c;static makeRangeOptions=h;static makeMinMaxPair=p;#nt=new CSSStyleSheet;constructor(t={}){super("Controls","muigui-root"),t instanceof HTMLElement&&(t={parent:t});const{autoPlace:n=!0,width:i,title:o="Controls"}=t;let{parent:r}=t;if(i&&(this.domElement.style.width=/^\d+$/.test(i)?`${i}px`:i),void 0===r&&n&&(r=document.body,this.domElement.classList.add("muigui-auto-place")),r){const t=e("muigui-element");t.shadowRoot.adoptedStyleSheets=[de,pe,this.#nt],t.shadow.appendChild(this.domElement),r.appendChild(t)}o&&this.title(o),this.domElement.classList.add("muigui","muigui-colors")}setStyle(t){this.#nt.replace(t)}static setBaseStyles(t){ge(t)}static getBaseStyleSheet(){return de}static setUserStyles(t){fe(t)}static getUserStyleSheet(){return pe}static setTheme(e){be.setBaseStyles(`${t.default}\n${t.themes[e]||""}`)}}function ve(){}const xe={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function we(t,{onDown:e=ve,onUp:n=ve}){const i=function(t){const i=t.shiftKey?10:1,[o,r]=(xe[t.key]||[0,0]).map((t=>t*i));("keydown"===t.type?e:n)({type:t.type.substring(3),dx:o,dy:r,event:t})};return t.addEventListener("keydown",i),t.addEventListener("keyup",i),function(){t.removeEventListener("keydown",i),t.removeEventListener("keyup",i)}}function ye(t,e=""){if(!t)throw new Error(e)}function ke(t,e,n,i,o,r){const s=Math.abs(n)*Math.cos(r),a=Math.abs(i)*Math.sin(r);return[t+Math.cos(o)*s-Math.sin(o)*a,e+Math.sin(o)*s+Math.cos(o)*a]}function Ee(t,e,n,i,o){ye(Math.abs(i-o)<=2*Math.PI),ye(i>=-Math.PI&&i<=2*Math.PI),ye(i<=o),ye(o>=-Math.PI&&o<=4*Math.PI);const{x1:r,y1:s,x2:a,y2:l,fa:u,fs:c}=function(t,e,n,i,o,r,s){const[a,l]=ke(t,e,n,i,o,r),[u,c]=ke(t,e,n,i,o,r+s);return{x1:a,y1:l,x2:u,y2:c,fa:Math.abs(s)>Math.PI?1:0,fs:s>0?1:0}}(t,e,n,n,0,i,o-i);return Math.abs(Math.abs(i-o)-2*Math.PI)>Number.EPSILON?`M${t} ${e} L${r} ${s} A ${n} ${n} 0 ${u} ${c} ${a} ${l} L${t} ${e}`:`M${r} ${s} L${r} ${s} A ${n} ${n} 0 ${u} ${c} ${a} ${l}`}const $e=t=>a(t+Math.PI,2*Math.PI)-Math.PI;class Ce extends v{#it;#ot;#rt;#st;#u={step:1,min:-180,max:180,dirMin:-Math.PI,dirMax:Math.PI,wrap:void 0,converters:F};constructor(t,n={}){const i=L();super(e("div",{className:"muigui-direction muigui-no-scroll",innerHTML:'\n\n',onWheel:e=>{e.preventDefault();const{min:n,max:r,step:l}=this.#u,u=i(e,l);let c=this.#rt+u;this.#st&&(c=a(c-n,r-n)+n);const h=o(s(c,(t=>t),l),n,r);t.setValue(h)}}));const r=e=>{const{min:n,max:i,step:r,dirMin:a,dirMax:l}=this.#u,u=2*e.nx-1,c=2*e.ny-1,h=Math.atan2(c,u),d=(a+l)/2,p=o(($e(h-d)-$e(a-d))/(l-a),0,1),m=s(n+(i-n)*p,(t=>t),r);t.setValue(m)};re(this.domElement,{onDown:r,onMove:r}),we(this.domElement,{onDown:e=>{const{min:n,max:i,step:r}=this.#u,a=o(s(this.#rt+e.dx*r,(t=>t),r),n,i);t.setValue(a)}}),this.#it=this.$("#muigui-arrow"),this.#ot=this.$("#muigui-range"),this.setOptions(n)}updateDisplay(t){this.#rt=t;const{min:e,max:n}=this.#u,i=(t-e)/(n-e),o=(r=this.#u.dirMin,s=this.#u.dirMax,r+(s-r)*i);var r,s;this.#it.style.transform=`rotate(${o}rad)`}setOptions(t){l(this.#u,t);const{dirMin:e,dirMax:n,wrap:i}=this.#u;this.#st=void 0!==i?i:Math.abs(e-n)>=2*Math.PI-Number.EPSILON;const[o,r]=e(o.push(i),e("label",{},[e("input",{type:"radio",name:r,value:a,onChange:function(){this.checked&&t.setFinalValue(s.#D[this.value])}}),e("button",{type:"button",textContent:n,onClick:function(){this.previousElementSibling.click()}})]))))));const s=this;this.#D=o,this.cols(i)}updateDisplay(t){const e=this.#D.indexOf(t);for(let t=0;t{e({rect:t.getBoundingClientRect(),elem:t})})).observe(t)}function Me(t,e,n,i){Ie(t,(({rect:o})=>{const{width:r,height:s}=o;t.setAttribute("viewBox",`-${r*e} -${s*n} ${r} ${s}`),i({elem:t,rect:o})}))}function Se(t,e,n,i,o,r){const a=[];tt),n)),e=Math.min(e,o);for(let i=t;i<=e;i+=n)a.push(`M${i} 0 l0 ${r}`);return a.join(" ")}class De extends v{#at;#lt;#ut;#ct;#ht;#dt;#pt;#mt;#gt;#rt;#ft;#u={min:-100,max:100,step:1,unit:10,unitSize:10,ticksPerUnit:5,labelFn:t=>t,tickHeight:1,limits:!0,thicksColor:void 0,orientation:void 0};constructor(t,n){const i=L();let r;super(e("div",{innerHTML:'\n\n',className:"muigui-no-v-scroll",onWheel:e=>{e.preventDefault();const{min:n,max:r,step:a}=this.#u,l=i(e,a),u=o(s(this.#rt+l,(t=>t),a),n,r);t.setValue(u)}})),this.#at=this.$("svg"),this.#lt=this.$("#muigui-origin"),this.#ut=this.$("#muigui-ticks"),this.#ct=this.$("#muigui-thicks"),this.#ht=this.$("#muigui-numbers"),this.#dt=this.$("#muigui-left-grad"),this.#pt=this.$("#muigui-right-grad"),this.setOptions(n),re(this.domElement,{onDown:()=>{r=this.#rt},onMove:e=>{const{min:n,max:i,unitSize:a,unit:l,step:u}=this.#u,c=o(s(r-e.dx/a*l,(t=>t),u),n,i);t.setValue(c)}}),we(this.domElement,{onDown:e=>{const{min:n,max:i,step:r}=this.#u,a=o(s(this.#rt+e.dx*r,(t=>t),r),n,i);t.setValue(a)}}),Me(this.#at,.5,0,(({rect:{width:t}})=>{this.#dt.setAttribute("x",-t/2),this.#pt.setAttribute("x",t/2-20),this.#ft=function(t){const e=t.innerHTML;t.innerHTML="- ";const n=t.querySelector("text").getComputedTextLength();return t.innerHTML=e,n}(this.#ht),this.#mt=t,this.#bt()}))}#bt(){if(!this.#mt||void 0===this.#rt)return;const{labelFn:t,limits:e,min:n,max:i,orientation:o,tickHeight:r,ticksPerUnit:a,unit:l,unitSize:u,thicksColor:c}=this.#u,h=Math.ceil(this.#mt/u),d=this.#rt/l,p=Math.round(d-h),m=p*u,g=(p+2*h)*u,f=e?n*u/l:m,b=e?i*u/l:g,v=""===t(1)?10:5;a>1&&this.#ut.setAttribute("d",Se(m,g,u/a,f,b,v*r)),this.#ct.style.stroke=c,this.#ct.setAttribute("d",Se(m,g,u,f,b,v)),this.#ht.innerHTML=function(t,e,n,i,o,r,a,l){const u=[];tt),n)),e=Math.min(e,a);const c=Math.max(0,-Math.log10(i));for(let r=t;r<=e;r+=n)u.push(`${h=r/n*i,l(h.toFixed(c))}`);var h;return u.join("\n")}(m,g,u,l,this.#ft,f,b,t),this.#lt.setAttribute("transform",`translate(${-this.#rt*u/l} 0)`),this.#at.classList.toggle("muigui-slider-up","up"===o)}updateDisplay(t){this.#rt=t,this.#bt()}setOptions(t){return l(this.#u,t),this}}class Ne extends v{#at;#it;#H;#rt=[];constructor(t){super(e("div",{innerHTML:'\n\n',className:"muigui-no-scroll"}));const n=e=>{const{width:n,height:i}=this.#at.getBoundingClientRect(),o=2*e.nx-1,r=2*e.ny-1;t.setValue([o*n*.5,r*i*.5])};re(this.domElement,{onDown:n,onMove:n}),this.#at=this.$("svg"),this.#it=this.$("#muigui-arrow"),this.#H=this.$("#muigui-circle"),Me(this.#at,.5,.5,(()=>this.#vt))}#vt(){const[t,e]=this.#rt;this.#it.setAttribute("d",`M0,0L${t},${e}`),this.#H.setAttribute("transform",`translate(${t}, ${e})`)}updateDisplay(t){this.#rt[0]=t[0],this.#rt[1]=t[1],this.#vt()}}return be.ColorChooser=ue,be.Direction=class extends le{#u;constructor(t,e,n){super(t,e,"muigui-direction"),this.#u=n,this.addTop(new O(this,F)),this.addBottom(new Ce(this,n)),this.updateDisplay()}},be.RadioGrid=class extends D{constructor(t,e,n){super(t,e,"muigui-radio-grid");const i="number"==typeof this.getValue(),{keyValues:o,cols:r=3}=n,s=H(o,i);this.add(new Ve(this,s,r)),this.updateDisplay()}},be.Range=B,be.Select=z,be.Slider=class extends D{constructor(t,e,n={}){super(t,e,"muigui-slider"),this.add(new De(this,n)),this.add(new O(this,n)),this.updateDisplay()}},be.TextNumber=j,be.Vec2=class extends le{constructor(t,e){super(t,e,"muigui-vec2");const n=t=>({setValue:e=>{const n=this.getValue();n[t]=e,this.setValue(n)},setFinalValue:e=>{const n=this.getValue();n[t]=e,this.setFinalValue(n)}});this.addTop(new O(n(0),{converters:{to:t=>t[0],from:A.from}})),this.addTop(new O(n(1),{converters:{to:t=>t[1],from:A.from}})),this.addBottom(new Ne(this)),this.updateDisplay()}},be}));
+//# sourceMappingURL=muigui.min.js.map
diff --git a/dist/0.x/muigui.min.js.map b/dist/0.x/muigui.min.js.map
new file mode 100644
index 0000000..37cc366
--- /dev/null
+++ b/dist/0.x/muigui.min.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"muigui.min.js","sources":["../../src/styles/muigui.css.js","../../src/libs/elem.js","../../src/libs/utils.js","../../../src/views/View.ts","../../src/controllers/Controller.js","../../src/controllers/Button.js","../../src/views/EditView.js","../../src/views/CheckboxView.js","../../src/libs/taskrunner.js","../../src/libs/ids.js","../../src/views/ValueView.js","../../src/controllers/LabelController.js","../../src/controllers/ValueController.js","../../src/controllers/Checkbox.js","../../src/libs/conversions.js","../../src/libs/wheel.js","../../src/views/NumberView.js","../../src/controllers/TextNumber.js","../../src/views/SelectView.js","../../src/libs/key-values.js","../../src/controllers/Select.js","../../src/views/RangeView.js","../../src/controllers/Range.js","../../src/views/TextView.js","../../src/controllers/Text.js","../../src/libs/color-utils.js","../../src/views/ElementView.js","../../src/controllers/Canvas.js","../../src/views/ColorView.js","../../src/controllers/Color.js","../../src/controllers/Divider.js","../../src/controllers/Container.js","../../src/controllers/Folder.js","../../src/controllers/Label.js","../../src/libs/touch.js","../../src/views/ColorChooserView.js","../../src/controllers/PopDownController.js","../../src/controllers/ColorChooser.js","../../src/muigui.js","../../src/controllers/create-controller.js","../../src/libs/keyboard.js","../../src/libs/assert.js","../../src/libs/svg.js","../../src/views/DirectionView.js","../../src/views/RadioGridView.js","../../src/libs/resize-helpers.js","../../src/views/SliderView.js","../../src/views/Vec2View.js","../../src/umd.js","../../src/controllers/Direction.js","../../src/controllers/RadioGrid.js","../../src/controllers/Slider.js","../../src/controllers/Vec2.js"],"sourcesContent":["export default {\n default: `\n.muigui {\n --bg-color: #ddd;\n --color: #222;\n --contrast-color: #eee;\n --value-color: #145 ;\n --value-bg-color: #eeee;\n --disabled-color: #999;\n --menu-bg-color: #f8f8f8;\n --menu-sep-color: #bbb;\n --hover-bg-color: #999;\n --focus-color: #68C;\n --range-color: #888888;\n --invalid-color: #FF0000;\n --selected-color: rgb(255, 255, 255, 0.9);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n}\n\n@media (prefers-color-scheme: dark) {\n .muigui {\n --bg-color: #222222;\n --color: #dddddd;\n --contrast-color: #000;\n --value-color: #43e5f7;\n --value-bg-color: #444444;\n --disabled-color: #666666;\n --menu-bg-color: #080808;\n --menu-sep-color: #444444;\n --hover-bg-color: #666666;\n --focus-color: #88AAFF;\n --range-color: #888888;\n --invalid-color: #FF6666;\n --selected-color: rgba(255, 255, 255, 0.3);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n }\n}\n\n.muigui {\n --width: 250px;\n --label-width: 45%;\n --number-width: 40%;\n\n\n --font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Arial, sans-serif;\n --font-size: 11px;\n --font-family-mono: Menlo, Monaco, Consolas, \"Droid Sans Mono\", monospace;\n --font-size-mono: 11px;\n\n --line-height: 1.7em;\n --border-radius: 0px;\n\n width: var(--width);\n font-family: var(--font-family);\n font-size: var(--font-size);\n box-sizing: border-box;\n line-height: 100%;\n}\n.muigui * {\n box-sizing: inherit;\n}\n\n.muigui-no-scroll {\n touch-action: none;\n}\n.muigui-no-h-scroll {\n touch-action: pan-y;\n}\n.muigui-no-v-scroll {\n touch-action: pan-x;\n}\n\n.muigui-invalid-value {\n background-color: red !important;\n color: white !important;\n}\n\n.muigui-grid {\n display: grid;\n}\n.muigui-rows {\n display: flex;\n flex-direction: column;\n\n min-height: 20px;\n border: 2px solid red;\n}\n.muigui-columns {\n display: flex;\n flex-direction: row;\n\n height: 20px;\n border: 2px solid green;\n}\n.muigui-rows>*,\n.muigui-columns>* {\n flex: 1 1 auto;\n align-items: stretch;\n min-height: 0;\n min-width: 0;\n}\n\n.muigui-row {\n border: 2px solid yellow;\n min-height: 10px\n}\n.muigui-column {\n border: 2px solid lightgreen;\n}\n\n/* -------- */\n\n.muigui-show { /* */ }\n.muigui-hide { \n display: none !important;\n}\n.muigui-disabled {\n pointer-events: none;\n --color: var(--disabled-color) !important;\n --value-color: var(--disabled-color) !important;\n --range-left-color: var(--disabled-color) !important;\n}\n\n.muigui canvas,\n.muigui svg {\n display: block;\n border-radius: var(--border-radius);\n}\n.muigui canvas {\n background-color: var(--value-bg-color);\n}\n\n.muigui-controller {\n min-width: 0;\n min-height: var(--line-height);\n}\n.muigui-root,\n.muigui-menu {\n display: flex;\n flex-direction: column;\n position: relative;\n user-select: none;\n height: fit-content;\n margin: 0;\n padding-bottom: 0.1em;\n border-radius: var(--border-radius);\n}\n.muigui-menu {\n border-bottom: 1px solid var(--menu-sep-color);\n}\n\n.muigui-root>button:nth-child(1),\n.muigui-menu>button:nth-child(1) {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n position: relative;\n text-align: left;\n color: var(--color);\n background-color: var(--menu-bg-color);\n min-height: var(--line-height);\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n cursor: pointer;\n border-radius: var(--border-radius);\n}\n.muigui-root>div:nth-child(2),\n.muigui-menu>div:nth-child(2) {\n flex: 1 1 auto;\n}\n\n.muigui-controller {\n margin-left: 0.2em;\n margin-right: 0.2em;\n}\n.muigui-root.muigui-controller,\n.muigui-menu.muigui-controller {\n margin-left: 0;\n margin-right: 0;\n}\n.muigui-controller>*:nth-child(1) {\n flex: 1 0 var(--label-width);\n min-width: 0;\n white-space: pre;\n}\n.muigui-controller>label:nth-child(1) {\n place-content: center start;\n display: inline-grid;\n overflow: hidden;\n}\n.muigui-controller>*:nth-child(2) {\n flex: 1 1 75%;\n min-width: 0;\n}\n\n/* -----------------------------------------\n a label controller is [[label][value]]\n*/\n\n.muigui-label-controller {\n display: flex;\n margin: 0.4em 0 0.4em 0;\n word-wrap: initial;\n align-items: stretch;\n}\n\n.muigui-value {\n display: flex;\n align-items: stretch;\n}\n.muigui-value>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n.muigui-value>*:nth-child(1) {\n flex: 1 1 calc(100% - var(--number-width));\n}\n.muigui-value>*:nth-child(2) {\n flex: 1 1 var(--number-width);\n margin-left: 0.2em;\n}\n\n/* fix! */\n.muigui-open>button>label::before,\n.muigui-closed>button>label::before {\n width: 1.25em;\n height: var(--line-height);\n display: inline-grid;\n place-content: center start;\n pointer-events: none;\n}\n.muigui-open>button>label::before {\n content: \"ⓧ\"; /*\"▼\";*/\n}\n.muigui-closed>button>label::before {\n content: \"⨁\"; /*\"▶\";*/\n}\n.muigui-open>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 0.5s ease-out;\n max-height: 100vh;\n overflow: auto;\n opacity: 1;\n}\n\n.muigui-closed>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 1s;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n}\n\n/* ---- popdown ---- */\n\n.muigui-pop-down-top {\n display: flex;\n}\n/* fix? */\n.muigui-value>*:nth-child(1).muigui-pop-down-top {\n flex: 0;\n}\n.muigui-pop-down-bottom {\n\n}\n\n.muigui-pop-down-values {\n min-width: 0;\n display: flex;\n}\n.muigui-pop-down-values>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.muigui-value.muigui-pop-down-controller {\n flex-direction: column;\n}\n\n.muigui-pop-down-top input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-pop-down-top input[type=checkbox]::before {\n content: \"+\";\n display: grid;\n place-content: center;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n color: var(--value-bg-color);\n width: calc(var(--line-height) - 4px);\n height: calc(var(--line-height) - 4px);\n}\n\n.muigui-pop-down-top input[type=checkbox]:checked::before {\n content: \"X\";\n}\n\n\n/* ---- select ---- */\n\n.muigui select,\n.muigui option,\n.muigui input,\n.muigui button {\n color: var(--value-color);\n background-color: var(--value-bg-color);\n font-family: var(--font-family);\n font-size: var(--font-size);\n border: none;\n margin: 0;\n border-radius: var(--border-radius);\n}\n.muigui select {\n appearance: none;\n margin: 0;\n margin-left: 0; /*?*/\n overflow: hidden; /* Safari */\n}\n\n.muigui select:focus,\n.muigui input:focus,\n.muigui button:focus {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui select:hover,\n.muigui option:hover,\n.muigui input:hover,\n.muigui button:hover {\n background-color: var(--hover-bg-color); \n}\n\n/* ------ [ label ] ------ */\n\n.muigui-label {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n padding-top: 0.4em;\n padding-bottom: 0.3em;\n place-content: center start;\n background-color: var(--menu-bg-color);\n white-space: pre;\n border-radius: var(--border-radius);\n}\n\n/* ------ [ divider] ------ */\n\n.muigui-divider {\n min-height: 6px;\n border-top: 2px solid var(--menu-sep-color);\n margin-top: 6px;\n}\n\n/* ------ [ button ] ------ */\n\n.muigui-button {\n display: grid;\n\n}\n.muigui-button button {\n border: none;\n color: var(--value-color);\n background-color: var(--button-bg-color);\n cursor: pointer;\n place-content: center center;\n}\n\n/* ------ [ color ] ------ */\n\n.muigui-color>div {\n overflow: hidden;\n position: relative;\n margin-left: 0;\n margin-right: 0; /* why? */\n max-width: var(--line-height);\n border-radius: var(--border-radius);\n}\n\n.muigui-color>div:focus-within {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui-color input[type=color] {\n border: none;\n padding: 0;\n background: inherit;\n cursor: pointer;\n position: absolute;\n width: 200%;\n left: -10px;\n top: -10px;\n height: 200%;\n}\n.muigui-disabled canvas,\n.muigui-disabled svg,\n.muigui-disabled img,\n.muigui-disabled .muigui-color input[type=color] {\n opacity: 0.2;\n}\n\n/* ------ [ checkbox ] ------ */\n\n.muigui-checkbox>label:nth-child(2) {\n display: grid;\n place-content: center start;\n margin: 0;\n}\n\n.muigui-checkbox input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-checkbox input[type=checkbox]::before {\n content: \"\";\n color: var(--value-color);\n display: grid;\n place-content: center;\n}\n\n.muigui-checkbox input[type=checkbox]:checked::before {\n content: \"✔\";\n}\n\n.muigui input[type=number]::-webkit-inner-spin-button, \n.muigui input[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none;\n appearance: none;\n margin: 0; \n}\n.muigui input[type=number] {\n -moz-appearance: textfield;\n}\n\n/* ------ [ radio grid ] ------ */\n\n.muigui-radio-grid>div {\n display: grid;\n gap: 2px;\n}\n\n.muigui-radio-grid input {\n appearance: none;\n display: none;\n}\n\n.muigui-radio-grid button {\n color: var(--color);\n width: 100%;\n text-align: left;\n}\n\n.muigui-radio-grid input:checked + button {\n color: var(--value-color);\n background-color: var(--selected-color);\n}\n\n/* ------ [ color-chooser ] ------ */\n\n.muigui-color-chooser-cursor {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n.muigui-color-chooser-circle {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n\n\n/* ------ [ vec2 ] ------ */\n\n.muigui-vec2 svg {\n background-color: var(--value-bg-color);\n}\n\n.muigui-vec2-axis {\n stroke: 1px;\n stroke: var(--focus-color);\n}\n\n.muigui-vec2-line {\n stroke-width: 1px;\n stroke: var(--value-color);\n fill: var(--value-color);\n}\n\n/* ------ [ direction ] ------ */\n\n.muigui-direction svg {\n background-color: rgba(0,0,0,0.2);\n}\n\n.muigui-direction:focus-within svg {\n outline: none;\n}\n.muigui-direction-range {\n fill: var(--value-bg-color);\n}\n.muigui-direction svg:focus {\n outline: none;\n}\n.muigui-direction svg:focus .muigui-direction-range {\n stroke-width: 0.5px;\n stroke: var(--focus-color);\n}\n\n.muigui-direction-arrow {\n fill: var(--value-color);\n}\n\n/* ------ [ slider ] ------ */\n\n.muigui-slider>div {\n display: flex;\n align-items: stretch;\n height: var(--line-height);\n}\n.muigui-slider svg {\n flex: 1 1 auto;\n}\n.muigui-slider .muigui-slider-up #muigui-orientation {\n transform: scale(1, -1) translateY(-100%);\n}\n\n.muigui-slider .muigui-slider-up #muigui-number-orientation {\n transform: scale(1,-1);\n}\n\n.muigui-ticks {\n stroke: var(--range-color);\n}\n.muigui-thicks {\n stroke: var(--color);\n stroke-width: 2px;\n}\n.muigui-svg-text {\n fill: var(--color);\n font-size: 7px;\n}\n.muigui-mark {\n fill: var(--value-color);\n}\n\n/* ------ [ range ] ------ */\n\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: transparent;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n margin-top: calc((var(--line-height) - 2px) / -2);\n width: calc(var(--line-height) - 2px);\n height: calc(var(--line-height) - 2px);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n border: 1px solid var(--menu-sep-color);\n height: 2px;\n}\n\n\n/* dat.gui style - doesn't work on Safari iOS */\n\n/*\n.muigui-range input[type=range] {\n cursor: ew-resize;\n overflow: hidden;\n}\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: var(--range-right-color);\n margin: 0;\n}\n.muigui-range input[type=range]:hover {\n background-color: var(--range-right-hover-color);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n height: max-content;\n color: var(--range-left-color);\n margin-top: -1px;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0px;\n height: max-content;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n}\n*/\n\n/* FF */\n/*\n.muigui-range input[type=range]::-moz-slider-progress {\n background-color: var(--range-left-color); \n}\n.muigui-range input[type=range]::-moz-slider-thumb {\n height: max-content;\n width: 0;\n border: none;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n box-sizing: border-box;\n}\n*/\n\n.muigui-checkered-background {\n background-color: #404040;\n background-image:\n linear-gradient(45deg, #808080 25%, transparent 25%),\n linear-gradient(-45deg, #808080 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #808080 75%),\n linear-gradient(-45deg, transparent 75%, #808080 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0px;\n}\n\n/* ---------------------------------------------------------- */\n\n/* needs to be at bottom to take precedence */\n.muigui-auto-place {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 100001;\n}\n\n`,\nthemes: {\n default: '',\n float: `\n :root {\n color-scheme: light dark,\n }\n\n .muigui {\n --width: 400px;\n --bg-color: initial;\n --label-width: 25%;\n --number-width: 20%;\n }\n\n input,\n .muigui-label-controller>label {\n text-shadow:\n -1px -1px 0 var(--contrast-color),\n 1px -1px 0 var(--contrast-color),\n -1px 1px 0 var(--contrast-color),\n 1px 1px 0 var(--contrast-color);\n }\n\n .muigui-controller > label:nth-child(1) {\n place-content: center end;\n margin-right: 1em;\n }\n\n .muigui-value > :nth-child(2) {\n margin-left: 1em;\n }\n\n .muigui-root>*:nth-child(1) {\n display: none;\n }\n\n .muigui-range input[type=range]::-webkit-slider-thumb {\n border-radius: 1em;\n }\n\n .muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: initial;\n appearance: none;\n border: 1px solid rgba(0, 0, 0, 0.25);\n height: 2px;\n }\n\n .muigui-colors {\n --value-color: var(--color );\n --value-bg-color: rgba(0, 0, 0, 0.1);\n --disabled-color: #cccccc;\n --menu-bg-color: rgba(0, 0, 0, 0.1);\n --menu-sep-color: #bbbbbb;\n --hover-bg-color: rgba(0, 0, 0, 0);\n --invalid-color: #FF0000;\n --selected-color: rgba(0, 0, 0, 0.3);\n --range-color: rgba(0, 0, 0, 0.125);\n }\n`,\n},\n};\n","export function setElemProps(elem, attrs, children) {\n for (const [key, value] of Object.entries(attrs)) {\n if (typeof value === 'function' && key.startsWith('on')) {\n const eventName = key.substring(2).toLowerCase();\n elem.addEventListener(eventName, value, {passive: false});\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n elem[key][k] = v;\n }\n } else if (elem[key] === undefined) {\n elem.setAttribute(key, value);\n } else {\n elem[key] = value;\n }\n }\n for (const child of children) {\n elem.appendChild(child);\n }\n return elem;\n}\n\nexport function createElem(tag, attrs = {}, children = []) {\n const elem = document.createElement(tag);\n setElemProps(elem, attrs, children);\n return elem;\n}\n\nexport function addElem(tag, parent, attrs = {}, children = []) {\n const elem = createElem(tag, attrs, children);\n parent.appendChild(elem);\n return elem;\n}\n\nlet nextId = 0;\nexport function getNewId() {\n return `muigui-id-${nextId++}`;\n}\n","export function removeArrayElem(array, value) {\n const ndx = array.indexOf(value);\n if (ndx) {\n array.splice(ndx, 1);\n }\n return array;\n}\n\n/**\n * Converts an camelCase or snake_case id to \"camel case\" or \"snake case\"\n * @param {string} id\n */\nconst underscoreRE = /_/g;\nconst upperLowerRE = /([A-Z])([a-z])/g;\nexport function idToLabel(id) {\n return id.replace(underscoreRE, ' ')\n .replace(upperLowerRE, (m, m1, m2) => `${m1.toLowerCase()} ${m2}`);\n}\n\nexport function clamp(v, min, max) {\n return Math.max(min, Math.min(max, v));\n}\n\nexport const isTypedArray = typeof SharedArrayBuffer !== 'undefined'\n ? function isArrayBufferOrSharedArrayBuffer(a) {\n return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);\n }\n : function isArrayBuffer(a) {\n return a && a.buffer && a.buffer instanceof ArrayBuffer;\n };\n\nexport const isArrayOrTypedArray = v => Array.isArray(v) || isTypedArray(v);\n\n// Yea, I know this should be `Math.round(v / step) * step\n// but try step = 0.1, newV = 19.95\n//\n// I get\n// Math.round(19.95 / 0.1) * 0.1\n// 19.900000000000002\n// vs\n// Math.round(19.95 / 0.1) / (1 / 0.1)\n// 19.9\n//\nexport const stepify = (v, from, step) => Math.round(from(v) / step) / (1 / step);\n\nexport const euclideanModulo = (v, n) => ((v % n) + n) % n;\nexport const lerp = (a, b, t) => a + (b - a) * t;\nexport function copyExistingProperties(dst, src) {\n for (const key in src) {\n if (key in dst) {\n dst[key] = src[key];\n }\n }\n return dst;\n}\n\nexport const mapRange = (v, inMin, inMax, outMin, outMax) => (v - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;\n\nexport const makeRangeConverters = ({from, to}) => {\n return {\n to: v => mapRange(v, ...from, ...to),\n from: v => [true, mapRange(v, ...to, ...from)],\n };\n};\n\nexport const makeRangeOptions = ({from, to, step}) => {\n return {\n min: to[0],\n max: to[1],\n ...(step && {step}),\n converters: makeRangeConverters({from, to}),\n };\n};\n\n// TODO: remove an use one in conversions. Move makeRangeConverters there?\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\nexport function makeMinMaxPair(gui, properties, minPropName, maxPropName, options) {\n const { converters: { from } = identity } = options;\n const { min, max } = options;\n const guiMinRange = options.minRange || 0;\n const valueMinRange = from(guiMinRange)[1];\n const minGui = gui\n .add(properties, minPropName, {\n ...options,\n min,\n max: max - guiMinRange,\n })\n .onChange(v => {\n maxGui.setValue(Math.min(max, Math.max(v + valueMinRange, properties[maxPropName])));\n });\n const maxGui = gui\n .add(properties, maxPropName, {\n ...options,\n min: min + guiMinRange,\n max,\n })\n .onChange(v => {\n minGui.setValue(Math.max(min, Math.min(v - valueMinRange, properties[minPropName])));\n });\n return [ minGui, maxGui ];\n}\n\n","import { removeArrayElem } from '../libs/utils.js';\n\nexport default class View {\n domElement: HTMLElement;\n\n #childDestElem: HTMLElement;\n #views: View[] = [];\n\n constructor(elem: HTMLElement) {\n this.domElement = elem;\n this.#childDestElem = elem;\n }\n addElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n return elem;\n }\n removeElem(elem: HTMLElement) {\n this.#childDestElem.removeChild(elem);\n return elem;\n }\n pushSubElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n this.#childDestElem = elem;\n }\n popSubElem() {\n this.#childDestElem = this.#childDestElem.parentElement!;\n }\n add(view: View) {\n this.#views.push(view);\n this.addElem(view.domElement);\n return view;\n }\n remove(view: View) {\n this.removeElem(view.domElement);\n removeArrayElem(this.#views, view);\n return view;\n }\n pushSubView(view: View) {\n this.pushSubElem(view.domElement);\n }\n popSubView() {\n this.popSubElem();\n }\n setOptions(options: any) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n }\n updateDisplayIfNeeded(newV: any, ignoreCache?: boolean) {\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n $(selector: string) {\n return this.domElement.querySelector(selector);\n }\n}","import { createElem } from '../libs/elem.js';\nimport { removeArrayElem } from '../libs/utils.js';\nimport View from '../views/View.js';\n\nexport default class Controller extends View {\n #changeFns;\n #finishChangeFns;\n #parent;\n\n constructor(className) {\n super(createElem('div', {className: 'muigui-controller'}));\n this.#changeFns = [];\n this.#finishChangeFns = [];\n // we need the specialization to come last so it takes precedence.\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n get parent() {\n return this.#parent;\n }\n setParent(parent) {\n this.#parent = parent;\n this.enable(!this.disabled());\n }\n show(show = true) {\n this.domElement.classList.toggle('muigui-hide', !show);\n this.domElement.classList.toggle('muigui-show', show);\n return this;\n }\n hide() {\n return this.show(false);\n }\n disabled() {\n return !!this.domElement.closest('.muigui-disabled');\n }\n\n enable(enable = true) {\n this.domElement.classList.toggle('muigui-disabled', !enable);\n\n // If disabled we need to set the attribute 'disabled=true' to all\n // input/select/button/textarea's below\n //\n // If enabled we need to set the attribute 'disabled=false' to all below\n // until we hit a disabled controller.\n //\n // ATM the problem is we can find the input/select/button/textarea elements\n // but we can't easily find which controller they belong do.\n // But we don't need to? We can just check up if it or parent has\n // '.muigui-disabled'\n ['input', 'button', 'select', 'textarea'].forEach(tag => {\n this.domElement.querySelectorAll(tag).forEach(elem => {\n const disabled = !!elem.closest('.muigui-disabled');\n elem.disabled = disabled;\n });\n });\n\n return this;\n }\n disable(disable = true) {\n return this.enable(!disable);\n }\n onChange(fn) {\n this.removeChange(fn);\n this.#changeFns.push(fn);\n return this;\n }\n removeChange(fn) {\n removeArrayElem(this.#changeFns, fn);\n return this;\n }\n onFinishChange(fn) {\n this.removeFinishChange(fn);\n this.#finishChangeFns.push(fn);\n return this;\n }\n removeFinishChange(fn) {\n removeArrayElem(this.#finishChangeFns, fn);\n return this;\n }\n #callListeners(fns, newV) {\n for (const fn of fns) {\n fn.call(this, newV);\n }\n }\n emitChange(value, object, property) {\n this.#callListeners(this.#changeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n emitFinalChange(value, object, property) {\n this.#callListeners(this.#finishChangeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitFinalChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n updateDisplay() {\n // placeholder. override\n }\n getColors() {\n const toCamelCase = s => s.replace(/-([a-z])/g, (m, m1) => m1.toUpperCase());\n const keys = [\n 'color',\n 'bg-color',\n 'value-color',\n 'value-bg-color',\n 'hover-bg-color',\n 'menu-bg-color',\n 'menu-sep-color',\n 'disabled-color',\n ];\n const div = createElem('div');\n this.domElement.appendChild(div);\n const colors = Object.fromEntries(keys.map(key => {\n div.style.color = `var(--${key})`;\n const s = getComputedStyle(div);\n return [toCamelCase(key), s.color];\n }));\n div.remove();\n return colors;\n }\n}\n","import {\n createElem,\n} from '../libs/elem.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport Controller from './Controller.js';\n\nexport default class Button extends Controller {\n #object;\n #property;\n #buttonElem;\n #options = {\n name: '',\n };\n\n constructor(object, property, options = {}) {\n super('muigui-button', '');\n this.#object = object;\n this.#property = property;\n\n this.#buttonElem = this.addElem(\n createElem('button', {\n type: 'button',\n onClick: () => {\n this.#object[this.#property](this);\n },\n }));\n this.setOptions({name: property, ...options});\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {name} = this.#options;\n this.#buttonElem.textContent = name;\n }\n}","import { isTypedArray } from '../libs/utils.js';\nimport View from './View.js';\n\nfunction arraysEqual(a, b) {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; ++i) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction copyArrayElementsFromTo(src, dst) {\n dst.length = src.length;\n for (let i = 0; i < src.length; ++i) {\n dst[i] = src[i];\n }\n}\n\nexport default class EditView extends View {\n #oldV;\n #updateCheck;\n\n #checkArrayNeedsUpdate(newV) {\n // It's an array, we need to compare all elements\n // Example, vec2, [r,g,b], ...\n const needUpdate = !arraysEqual(newV, this.#oldV);\n if (needUpdate) {\n copyArrayElementsFromTo(newV, this.#oldV);\n }\n return needUpdate;\n }\n\n #checkTypedArrayNeedsUpdate() {\n let once = true;\n return function checkTypedArrayNeedsUpdateImpl(newV) {\n // It's a typedarray, we need to compare all elements\n // Example: Float32Array([r, g, b])\n let needUpdate = once;\n once = false;\n if (!needUpdate) {\n needUpdate = !arraysEqual(newV, this.#oldV);\n }\n return needUpdate;\n };\n }\n\n #checkObjectNeedsUpdate(newV) {\n let needUpdate = false;\n for (const key in newV) {\n if (newV[key] !== this.#oldV[key]) {\n needUpdate = true;\n this.#oldV[key] = newV[key];\n }\n }\n return needUpdate;\n }\n\n #checkValueNeedsUpdate(newV) {\n const needUpdate = newV !== this.#oldV;\n this.#oldV = newV;\n return needUpdate;\n }\n\n #getUpdateCheckForType(newV) {\n if (Array.isArray(newV)) {\n this.#oldV = [];\n return this.#checkArrayNeedsUpdate.bind(this);\n } else if (isTypedArray(newV)) {\n this.#oldV = new newV.constructor(newV);\n return this.#checkTypedArrayNeedsUpdate(this);\n } else if (typeof newV === 'object') {\n this.#oldV = {};\n return this.#checkObjectNeedsUpdate.bind(this);\n } else {\n return this.#checkValueNeedsUpdate.bind(this);\n }\n }\n\n // The point of this is updating DOM elements\n // is slow but if we've called `listen` then\n // every frame we're going to try to update\n // things with the current value so if nothing\n // has changed then skip it.\n updateDisplayIfNeeded(newV, ignoreCache) {\n this.#updateCheck = this.#updateCheck || this.#getUpdateCheckForType(newV);\n // Note: We call #updateCheck first because it updates\n // the cache\n if (this.#updateCheck(newV) || ignoreCache) {\n this.updateDisplay(newV);\n }\n }\n setOptions(/*options*/) {\n // override this\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class CheckboxView extends EditView {\n #checkboxElem;\n constructor(setter, id) {\n const checkboxElem = createElem('input', {\n type: 'checkbox',\n id,\n onInput: () => {\n setter.setValue(checkboxElem.checked);\n },\n onChange: () => {\n setter.setFinalValue(checkboxElem.checked);\n },\n });\n super(createElem('label', {}, [checkboxElem]));\n this.#checkboxElem = checkboxElem;\n }\n updateDisplay(v) {\n this.#checkboxElem.checked = v;\n }\n}\n","import { removeArrayElem } from './utils.js';\n\nconst tasks = [];\nconst tasksToRemove = new Set();\n\nlet requestId;\nlet processing;\n\nfunction removeTasks() {\n if (!tasksToRemove.size) {\n return;\n }\n\n if (processing) {\n queueProcessing();\n return;\n }\n\n tasksToRemove.forEach(task => {\n removeArrayElem(tasks, task);\n });\n tasksToRemove.clear();\n}\n\nfunction processTasks() {\n requestId = undefined;\n processing = true;\n for (const task of tasks) {\n if (!tasksToRemove.has(task)) {\n task();\n }\n }\n processing = false;\n removeTasks();\n queueProcessing();\n}\n\nfunction queueProcessing() {\n if (!requestId && tasks.length) {\n requestId = requestAnimationFrame(processTasks);\n }\n}\n\nexport function addTask(fn) {\n tasks.push(fn);\n queueProcessing();\n}\n\nexport function removeTask(fn) {\n tasksToRemove.set(fn);\n\n const ndx = tasks.indexOf(fn);\n if (ndx >= 0) {\n tasks.splice(ndx, 1);\n }\n}","let id = 0;\n\nexport function makeId() {\n return `muigui-${++id}`;\n}\n","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ValueView extends View {\n constructor(className = '') {\n super(createElem('div', {className: 'muigui-value'}));\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n}","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport ValueView from '../views/ValueView.js';\nimport Controller from './Controller.js';\n\nexport default class LabelController extends Controller {\n #id;\n #nameElem;\n\n constructor(className = '', name = '') {\n super('muigui-label-controller');\n this.#id = makeId();\n this.#nameElem = createElem('label', {for: this.#id});\n this.domElement.appendChild(this.#nameElem);\n this.pushSubView(new ValueView(className));\n this.name(name);\n }\n get id() {\n return this.#id;\n }\n name(name) {\n if (this.#nameElem.title === this.#nameElem.textContent) {\n this.#nameElem.title = name;\n }\n this.#nameElem.textContent = name;\n return this;\n }\n tooltip(tip) {\n this.#nameElem.title = tip;\n }\n}\n\n","import {addTask, removeTask} from '../libs/taskrunner.js';\nimport { isTypedArray } from '../libs/utils.js';\nimport LabelController from './LabelController.js';\n\nexport default class ValueController extends LabelController {\n #object;\n #property;\n #initialValue;\n #listening;\n #views;\n #updateFn;\n\n constructor(object, property, className = '') {\n super(className, property);\n this.#object = object;\n this.#property = property;\n this.#initialValue = this.getValue();\n this.#listening = false;\n this.#views = [];\n }\n get initialValue() {\n return this.#initialValue;\n }\n get object() {\n return this.#object;\n }\n get property() {\n return this.#property;\n }\n add(view) {\n this.#views.push(view);\n super.add(view);\n this.updateDisplay();\n return view;\n }\n #setValueImpl(v, ignoreCache) {\n let isDifferent = false;\n if (typeof v === 'object') {\n const dst = this.#object[this.#property];\n // don't replace objects, just their values.\n if (Array.isArray(v) || isTypedArray(v)) {\n for (let i = 0; i < v.length; ++i) {\n isDifferent ||= dst[i] !== v[i];\n dst[i] = v[i];\n }\n } else {\n for (const key of Object.keys(v)) {\n isDifferent ||= dst[key] !== v[key];\n }\n Object.assign(dst, v);\n }\n } else {\n isDifferent = this.#object[this.#property] !== v;\n this.#object[this.#property] = v;\n }\n this.updateDisplay(ignoreCache);\n if (isDifferent) {\n this.emitChange(this.getValue(), this.#object, this.#property);\n }\n return isDifferent;\n }\n setValue(v) {\n this.#setValueImpl(v);\n }\n setFinalValue(v) {\n const isDifferent = this.#setValueImpl(v, true);\n if (isDifferent) {\n this.emitFinalChange(this.getValue(), this.#object, this.#property);\n }\n return this;\n }\n updateDisplay(ignoreCache) {\n const newV = this.getValue();\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n setOptions(options) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n this.updateDisplay();\n return this;\n }\n getValue() {\n return this.#object[this.#property];\n }\n value(v) {\n this.setValue(v);\n return this;\n }\n reset() {\n this.setValue(this.#initialValue);\n return this;\n }\n listen(listen = true) {\n if (!this.#updateFn) {\n this.#updateFn = this.updateDisplay.bind(this);\n }\n if (listen) {\n if (!this.#listening) {\n this.#listening = true;\n addTask(this.#updateFn);\n }\n } else {\n if (this.#listening) {\n this.#listening = false;\n removeTask(this.#updateFn);\n }\n }\n return this;\n }\n}\n\n","import CheckboxView from '../views/CheckboxView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Checkbox extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n const id = this.id;\n this.add(new CheckboxView(this, id));\n this.updateDisplay();\n }\n}","import {\n makeRangeConverters,\n} from './utils.js';\n\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\n\n// from: from string to value\n// to: from value to string\nexport const strToNumber = {\n to: v => v.toString(),\n from: v => {\n const newV = parseFloat(v);\n return [!Number.isNaN(newV), newV];\n },\n};\n\nexport const converters = {\n radToDeg: makeRangeConverters({to: [0, 180], from: [0, Math.PI]}),\n};\n","export function createWheelHelper() {\n let wheelAccum = 0;\n return function (e, step, wheelScale = 5) {\n wheelAccum -= e.deltaY * step / wheelScale;\n const wheelSteps = Math.floor(Math.abs(wheelAccum) / step) * Math.sign(wheelAccum);\n const delta = wheelSteps * step;\n wheelAccum -= delta;\n return delta;\n };\n}\n","import { createElem } from '../libs/elem.js';\nimport { strToNumber } from '../libs/conversions.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nexport default class NumberView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n converters: strToNumber,\n min: Number.NEGATIVE_INFINITY,\n max: Number.POSITIVE_INFINITY,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'number',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const v = parseFloat(this.domElement.value);\n const [valid, newV] = this.#from(v);\n let inRange;\n if (valid && !Number.isNaN(v)) {\n const {min, max} = this.#options;\n inRange = newV >= min && newV <= max;\n this.#skipUpdate = skipUpdate;\n setFn(clamp(newV, min, max));\n }\n this.domElement.classList.toggle('muigui-invalid-value', !valid || !inRange);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n return this;\n }\n}\n","\nimport NumberView from '../views/NumberView.js';\nimport ValueController from './ValueController.js';\n\n// Wanted to name this `Number` but it conflicts with\n// JavaScript `Number`. It most likely wouldn't be\n// an issue? But users might `import {Number} ...` and\n// things would break.\nexport default class TextNumber extends ValueController {\n #textView;\n #step;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-checkbox');\n this.#textView = this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class SelectView extends EditView {\n #values;\n\n constructor(setter, keyValues) {\n const values = [];\n super(createElem('select', {\n onChange: () => {\n setter.setFinalValue(this.#values[this.domElement.selectedIndex]);\n },\n }, keyValues.map(([key, value]) => {\n values.push(value);\n return createElem('option', {textContent: key});\n })));\n this.#values = values;\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n this.domElement.selectedIndex = ndx;\n }\n}\n","\n// 4 cases\n// (a) keyValues is array of arrays, each sub array is key value\n// (b) keyValues is array and value is number then keys = array contents, value = index\n// (c) keyValues is array and value is not number, key = array contents, value = array contents\n// (d) keyValues is object then key->value\nexport function convertToKeyValues(keyValues, valueIsNumber) {\n if (Array.isArray(keyValues)) {\n if (Array.isArray(keyValues[0])) {\n // (a) keyValues is array of arrays, each sub array is key value\n return keyValues;\n } else {\n if (valueIsNumber) {\n // (b) keyValues is array and value is number then keys = array contents, value = index\n return keyValues.map((v, ndx) => [v, ndx]);\n } else {\n // (c) keyValues is array and value is not number, key = array contents, value = array contents\n return keyValues.map(v => [v, v]);\n }\n }\n } else {\n // (d)\n return [...Object.entries(keyValues)];\n }\n}\n","import SelectView from '../views/SelectView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class Select extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-select');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {keyValues: keyValuesInput} = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new SelectView(this, keyValues));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport EditView from './EditView.js';\n\nexport default class RangeView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n min: 0,\n max: 1,\n converters: identity,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'range',\n onInput: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setValue(validV);\n }\n },\n onChange: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setFinalValue(validV);\n }\n },\n onWheel: e => {\n e.preventDefault();\n const [valid, v] = this.#from(parseFloat(this.domElement.value));\n if (!valid) {\n return;\n }\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n min,\n max,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n this.domElement.step = step;\n this.domElement.min = min;\n this.domElement.max = max;\n return this;\n }\n}","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport RangeView from '../views/RangeView.js';\n\nexport default class Range extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-range');\n this.add(new RangeView(this, options));\n this.add(new NumberView(this, options));\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class TextView extends EditView {\n #to;\n #from;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n super(createElem('input', {\n type: 'text',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const [valid, newV] = this.#from(this.domElement.value);\n if (valid) {\n this.#skipUpdate = skipUpdate;\n setFn(newV);\n }\n this.domElement.style.color = valid ? '' : 'var(--invalid-color)';\n\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = this.#to(v);\n this.domElement.style.color = '';\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import TextView from '../views/TextView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Text extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n this.add(new TextView(this));\n this.updateDisplay();\n }\n}","const clamp = (v, min, max) => Math.max(min, Math.min(max, v));\nconst lerp = (a, b, t) => a + (b - a) * t;\nconst fract = v => v >= 0 ? v % 1 : 1 - (v % 1);\n\nconst f0 = v => +v.toFixed(0); // converts to string (eg 1.2 => \"1\"), then converts back to number (eg, \"1.200\" => 1.2)\nconst f3 = v => +v.toFixed(3); // converts to string (eg 1.2 => \"1.200\"), then converts back to number (eg, \"1.200\" => 1.2)\n\nconst hexToUint32RGB = v => (parseInt(v.substring(1, 3), 16) << 16) |\n (parseInt(v.substring(3, 5), 16) << 8 ) |\n (parseInt(v.substring(5, 7), 16) );\nconst uint32RGBToHex = v => `#${(Math.round(v)).toString(16).padStart(6, '0')}`;\nconst hexToUint32RGBA = v => (parseInt(v.substring(1, 3), 16) * 2 ** 24) +\n (parseInt(v.substring(3, 5), 16) * 2 ** 16) +\n (parseInt(v.substring(5, 7), 16) * 2 ** 8) +\n (parseInt(v.substring(7, 9), 16) );\nconst uint32RGBAToHex = v => `#${(Math.round(v)).toString(16).padStart(8, '0')}`;\n\nexport const hexToUint8RGB = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n];\nexport const uint8RGBToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToUint8RGBA = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n parseInt(v.substring(7, 9), 16),\n];\nexport const uint8RGBAToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToFloatRGB = v => hexToUint8RGB(v).map(v => f3(v / 255));\nexport const floatRGBToHex = v => uint8RGBToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nexport const hexToFloatRGBA = v => hexToUint8RGBA(v).map(v => f3(v / 255));\nexport const floatRGBAToHex = v => uint8RGBAToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nconst scaleAndClamp = v => clamp(Math.round(v * 255), 0, 255).toString(16).padStart(2, '0');\n\nconst hexToObjectRGB = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n});\nconst objectRGBToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}`;\nconst hexToObjectRGBA = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n a: parseInt(v.substring(7, 9), 16) / 255,\n});\nconst objectRGBAToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}${scaleAndClamp(v.a)}`;\n\nconst hexToCssRGB = v => `rgb(${hexToUint8RGB(v).join(', ')})`;\nconst cssRGBRegex = /^\\s*rgb\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\s*$/;\nconst cssRGBToHex = v => {\n const m = cssRGBRegex.exec(v);\n return uint8RGBToHex([m[1], m[2], m[3]].map(v => parseInt(v)));\n};\nconst hexToCssRGBA = v => `rgba(${hexToUint8RGBA(v).map((v, i) => i === 3 ? v / 255 : v).join(', ')})`;\nconst cssRGBARegex = /^\\s*rgba\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\nconst cssRGBAToHex = v => {\n const m = cssRGBARegex.exec(v);\n return uint8RGBAToHex([m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? (parseFloat(v) * 255 | 0) : parseInt(v)));\n};\n\nconst hexToCssHSL = v => {\n const hsl = rgbUint8ToHsl(hexToUint8RGB(v)).map(v => f0(v));\n return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`;\n};\nconst hexToCssHSLA = v => {\n const hsla = rgbaUint8ToHsla(hexToUint8RGBA(v)).map((v, i) => i === 3 ? f3(v) : f0(v));\n return `hsl(${hsla[0]} ${hsla[1]}% ${hsla[2]}% / ${hsla[3]})`;\n};\nconst cssHSLRegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\)\\s*$/;\nconst cssHSLARegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\/\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\n\nconst hex3DigitTo6Digit = v => `${v[0]}${v[0]}${v[1]}${v[1]}${v[2]}${v[2]}`;\nconst cssHSLToHex = v => {\n const m = cssHSLRegex.exec(v);\n const rgb = hslToRgbUint8([m[1], m[2], m[3]].map(v => parseFloat(v)));\n return uint8RGBToHex(rgb);\n};\nconst cssHSLAToHex = v => {\n const m = cssHSLARegex.exec(v);\n const rgba = hslaToRgbaUint8([m[1], m[2], m[3], m[4]].map(v => parseFloat(v)));\n return uint8RGBAToHex(rgba);\n};\n\nconst euclideanModulo = (v, n) => ((v % n) + n) % n;\n\nexport function hslToRgbUint8([h, s, l]) {\n h = euclideanModulo(h, 360);\n s = clamp(s / 100, 0, 1);\n l = clamp(l / 100, 0, 1);\n\n const a = s * Math.min(l, 1 - l);\n\n function f(n) {\n const k = (n + h / 30) % 12;\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n\n return [f(0), f(8), f(4)].map(v => Math.round(v * 255));\n}\n\nexport function hslaToRgbaUint8([h, s, l, a]) {\n const rgb = hslToRgbUint8([h, s, l]);\n return [...rgb, a * 255 | 0];\n}\n\nexport function rgbFloatToHsl01([r, g, b]) {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (min + max) * 0.5;\n const d = max - min;\n let h = 0;\n let s = 0;\n\n if (d !== 0) {\n s = (l === 0 || l === 1)\n ? 0\n : (max - l) / Math.min(l, 1 - l);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4;\n }\n }\n\n return [h / 6, s, l];\n}\n\nexport function rgbaFloatToHsla01([r, g, b, a]) {\n const hsl = rgbFloatToHsl01([r, g, b]);\n return [...hsl, a];\n}\n\nexport const rgbUint8ToHsl = (rgb) => {\n const [h, s, l] = rgbFloatToHsl01(rgb.map(v => v / 255));\n return [h * 360, s * 100, l * 100];\n};\n\nexport const rgbaUint8ToHsla = (rgba) => {\n const [h, s, l, a] = rgbaFloatToHsla01(rgba.map(v => v / 255));\n return [h * 360, s * 100, l * 100, a];\n};\n\nexport function hsv01ToRGBFloat([hue, sat, val]) {\n sat = clamp(sat, 0, 1);\n val = clamp(val, 0, 1);\n return [hue, hue + 2 / 3, hue + 1 / 3].map(\n v => lerp(1, clamp(Math.abs(fract(v) * 6 - 3.0) - 1, 0, 1), sat) * val\n );\n}\n\nexport function hsva01ToRGBAFloat([hue, sat, val, alpha]) {\n const rgb = hsv01ToRGBFloat([hue, sat, val]);\n return [...rgb, alpha];\n}\n\nconst round3 = v => Math.round(v * 1000) / 1000;\n\nexport function rgbFloatToHSV01([r, g, b]) {\n const p = b > g\n ? [b, g, -1, 2 / 3]\n : [g, b, 0, -1 / 3];\n const q = p[0] > r\n ? [p[0], p[1], p[3], r]\n : [r, p[1], p[2], p[0]];\n const d = q[0] - Math.min(q[3], q[1]);\n return [\n Math.abs(q[2] + (q[3] - q[1]) / (6 * d + Number.EPSILON)),\n d / (q[0] + Number.EPSILON),\n q[0],\n ].map(round3);\n}\n\nexport function rgbaFloatToHSVA01([r, g, b, a]) {\n const hsv = rgbFloatToHSV01([r, g, b]);\n return [...hsv, a];\n}\n\n// window.hsv01ToRGBFloat = hsv01ToRGBFloat;\n// window.rgbFloatToHSV01 = rgbFloatToHSV01;\n\n// Yea, meh!\nexport const hasAlpha = format => format.endsWith('a') || format.startsWith('hex8');\n\nconst cssStringFormats = [\n { re: /^#(?:[0-9a-f]){6}$/i, format: 'hex6' },\n { re: /^(?:[0-9a-f]){6}$/i, format: 'hex6-no-hash' },\n { re: /^#(?:[0-9a-f]){8}$/i, format: 'hex8' },\n { re: /^(?:[0-9a-f]){8}$/i, format: 'hex8-no-hash' },\n { re: /^#(?:[0-9a-f]){3}$/i, format: 'hex3' },\n { re: /^(?:[0-9a-f]){3}$/i, format: 'hex3-no-hash' },\n { re: cssRGBRegex, format: 'css-rgb' },\n { re: cssHSLRegex, format: 'css-hsl' },\n { re: cssRGBARegex, format: 'css-rgba' },\n { re: cssHSLARegex, format: 'css-hsla' },\n];\n\nfunction guessStringColorFormat(v) {\n for (const formatInfo of cssStringFormats) {\n if (formatInfo.re.test(v)) {\n return formatInfo;\n }\n }\n return undefined;\n}\n\nexport function guessFormat(v) {\n switch (typeof v) {\n case 'number':\n console.warn('can not reliably guess format based on a number. You should pass in a format like {format: \"uint32-rgb\"} or {format: \"uint32-rgb\"}');\n return v <= 0xFFFFFF ? 'uint32-rgb' : 'uint32-rgba';\n case 'string': {\n const formatInfo = guessStringColorFormat(v.trim());\n if (formatInfo) {\n return formatInfo.format;\n }\n break;\n }\n case 'object':\n if (v instanceof Uint8Array || v instanceof Uint8ClampedArray) {\n if (v.length === 3) {\n return 'uint8-rgb';\n } else if (v.length === 4) {\n return 'uint8-rgba';\n }\n } else if (v instanceof Float32Array) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else if (Array.isArray(v)) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else {\n if ('r' in v && 'g' in v && 'b' in v) {\n if ('a' in v) {\n return 'object-rgba';\n } else {\n return 'object-rgb';\n }\n }\n }\n }\n throw new Error(`unknown color format: ${v}`);\n}\n\nfunction fixHex6(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction fixHex8(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction hex6ToHex3(hex6) {\n return (hex6[1] === hex6[2] &&\n hex6[3] === hex6[4] &&\n hex6[5] === hex6[6])\n ? `#${hex6[1]}${hex6[3]}${hex6[5]}`\n : hex6;\n}\n\nconst hex3RE = /^(#|)([0-9a-f]{3})$/i;\nfunction hex3ToHex6(hex3) {\n const m = hex3RE.exec(hex3);\n if (m) {\n const [, , m2] = m;\n return `#${hex3DigitTo6Digit(m2)}`;\n }\n return hex3;\n}\n\nfunction fixHex3(v) {\n return hex6ToHex3(fixHex6(v));\n}\n\nconst strToRGBObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgb = JSON.parse(json);\n if (Number.isNaN(rgb.r) || Number.isNaN(rgb.g) || Number.isNaN(rgb.b)) {\n throw new Error('not {r, g, b}');\n }\n return [true, rgb];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToRGBAObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgba = JSON.parse(json);\n if (Number.isNaN(rgba.r) || Number.isNaN(rgba.g) || Number.isNaN(rgba.b) || Number.isNaN(rgba.a)) {\n throw new Error('not {r, g, b, a}');\n }\n return [true, rgba];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToCssRGB = s => {\n const m = cssRGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgb(${v.join(', ')})`];\n};\n\nconst strToCssRGBA = s => {\n const m = cssRGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? parseFloat(v) : parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgba(${v.join(', ')})`];\n};\n\nconst strToCssHSL = s => {\n const m = cssHSLRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]}, ${v[1]}%, ${v[2]}%)`];\n};\n\nconst strToCssHSLA = s => {\n const m = cssHSLARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]} ${v[1]}% ${v[2]}% / ${v[3]})`];\n};\n\nconst rgbObjectToStr = rgb => {\n return `{r:${f3(rgb.r)}, g:${f3(rgb.g)}, b:${f3(rgb.b)}}`;\n};\nconst rgbaObjectToStr = rgba => {\n return `{r:${f3(rgba.r)}, g:${f3(rgba.g)}, b:${f3(rgba.b)}}, a:${f3(rgba.a)}}`;\n};\n\nconst strTo3IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo3Ints = s => {\n const m = strTo3IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo4IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo4Ints = s => {\n const m = strTo4IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo3Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 3) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strTo4Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 4) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strToUint32RGBRegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,6})\\s*$/i;\nconst strToUint32RGB = s => {\n const m = strToUint32RGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst strToUint32RGBARegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,8})\\s*$/i;\nconst strToUint32RGBA = s => {\n const m = strToUint32RGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst hex6RE = /^\\s*#[a-f0-9]{6}\\s*$|^\\s*#[a-f0-9]{3}\\s*$/i;\nconst hexNoHash6RE = /^\\s*[a-f0-9]{6}\\s*$/i;\nconst hex8RE = /^\\s*#[a-f0-9]{8}\\s*$/i;\nconst hexNoHash8RE = /^\\s*[a-f0-9]{8}\\s*$/i;\n\n// For each format converter\n//\n// fromHex/toHex convert from/to '#RRGGBB'\n//\n// fromHex converts from the string '#RRBBGG' to the format\n// (eg: for uint32-rgb, '#123456' becomes 0x123456)\n//\n// toHex converts from the format to '#RRGGBB'\n// (eg: for uint8-rgb, [16, 33, 50] becomes '#102132')\n//\n//\n// fromStr/toStr convert from/to what's in the input[type=text] element\n//\n// toStr converts from the format to its string representation\n// (eg, for object-rgb, {r: 1, g: 0.5, b:0} becomes \"{r: 1, g: 0.5, b:0}\")\n// ^object ^string\n//\n// fromStr converts its string representation to its format\n// (eg, for object-rgb) \"{r: 1, g: 0.5, b:0}\" becomes {r: 1, g: 0.5, b:0})\n// ^string ^object\n// fromString returns an array which is [valid, v]\n// where valid is true if the string was a valid and v is the converted\n// format if v is true.\n//\n// Note: toStr should convert to \"ideal\" form (whatever that is).\n// (eg, for css-rgb\n// \"{ r: 0.10000, g: 001, b: 0}\" becomes \"{r: 0.1, g: 1, b: 0}\"\n// notice that css-rgb is a string to a string\n// )\nexport const colorFormatConverters = {\n 'hex6': {\n color: {\n from: v => [true, v],\n to: fixHex6,\n },\n text: {\n from: v => [hex6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8': {\n color: {\n from: v => [true, v],\n to: fixHex8,\n },\n text: {\n from: v => [hex8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3': {\n color: {\n from: v => [true, fixHex3(v)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hex6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'hex6-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex6(v)}`,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex8(v)}`,\n },\n text: {\n from: v => [hexNoHash8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3-no-hash': {\n color: {\n from: v => [true, fixHex3(v).substring(1)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'uint32-rgb': {\n color: {\n from: v => [true, hexToUint32RGB(v)],\n to: uint32RGBToHex,\n },\n text: {\n from: v => strToUint32RGB(v),\n to: v => `0x${v.toString(16).padStart(6, '0')}`,\n },\n },\n 'uint32-rgba': {\n color: {\n from: v => [true, hexToUint32RGBA(v)],\n to: uint32RGBAToHex,\n },\n text: {\n from: v => strToUint32RGBA(v),\n to: v => `0x${v.toString(16).padStart(8, '0')}`,\n },\n },\n 'uint8-rgb': {\n color: {\n from: v => [true, hexToUint8RGB(v)],\n to: uint8RGBToHex,\n },\n text: {\n from: strTo3Ints,\n to: v => v.join(', '),\n },\n },\n 'uint8-rgba': {\n color: {\n from: v => [true, hexToUint8RGBA(v)],\n to: uint8RGBAToHex,\n },\n text: {\n from: strTo4Ints,\n to: v => v.join(', '),\n },\n },\n 'float-rgb': {\n color: {\n from: v => [true, hexToFloatRGB(v)],\n to: floatRGBToHex,\n },\n text: {\n from: strTo3Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'float-rgba': {\n color: {\n from: v => [true, hexToFloatRGBA(v)],\n to: floatRGBAToHex,\n },\n text: {\n from: strTo4Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'object-rgb': {\n color: {\n from: v => [true, hexToObjectRGB(v)],\n to: objectRGBToHex,\n },\n text: {\n from: strToRGBObject,\n to: rgbObjectToStr,\n },\n },\n 'object-rgba': {\n color: {\n from: v => [true, hexToObjectRGBA(v)],\n to: objectRGBAToHex,\n },\n text: {\n from: strToRGBAObject,\n to: rgbaObjectToStr,\n },\n },\n 'css-rgb': {\n color: {\n from: v => [true, hexToCssRGB(v)],\n to: cssRGBToHex,\n },\n text: {\n from: strToCssRGB,\n to: v => strToCssRGB(v)[1],\n },\n },\n 'css-rgba': {\n color: {\n from: v => [true, hexToCssRGBA(v)],\n to: cssRGBAToHex,\n },\n text: {\n from: strToCssRGBA,\n to: v => strToCssRGBA(v)[1],\n },\n },\n 'css-hsl': {\n color: {\n from: v => [true, hexToCssHSL(v)],\n to: cssHSLToHex,\n },\n text: {\n from: strToCssHSL,\n to: v => strToCssHSL(v)[1],\n },\n },\n 'css-hsla': {\n color: {\n from: v => [true, hexToCssHSLA(v)],\n to: cssHSLAToHex,\n },\n text: {\n from: strToCssHSLA,\n to: v => strToCssHSLA(v)[1],\n },\n },\n};","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ElementView extends View {\n constructor(tag, className) {\n super(createElem(tag, {className}));\n }\n}","import ElementView from '../views/ElementView.js';\nimport LabelController from './LabelController.js';\n\n// TODO: remove this? Should just be user side\nexport default class Canvas extends LabelController {\n #canvasElem;\n\n constructor() {\n super('muigui-canvas');\n this.#canvasElem = this.add(\n new ElementView('canvas', 'muigui-canvas'),\n ).domElement;\n }\n get canvas() {\n return this.#canvasElem;\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class ColorView extends EditView {\n #to;\n #from;\n #colorElem;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const colorElem = createElem('input', {\n type: 'color',\n onInput: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setValue(newV);\n }\n },\n onChange: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setFinalValue(newV);\n }\n },\n });\n super(createElem('div', {}, [colorElem]));\n this.setOptions(options);\n this.#colorElem = colorElem;\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.#colorElem.value = this.#to(v);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}} = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import {\n colorFormatConverters,\n guessFormat,\n} from '../libs/color-utils.js';\nimport ValueController from './ValueController.js';\nimport TextView from '../views/TextView.js';\nimport ColorView from '../views/ColorView.js';\n\nexport default class Color extends ValueController {\n #colorView;\n #textView;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#colorView = this.add(new ColorView(this, {converters: color}));\n this.#textView = this.add(new TextView(this, {converters: text}));\n this.updateDisplay();\n }\n setOptions(options) {\n const {format} = options;\n if (format) {\n const {color, text} = colorFormatConverters[format];\n this.#colorView.setOptions({converters: color});\n this.#textView.setOptions({converters: text});\n }\n super.setOptions(options);\n return this;\n }\n}","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addController({className: 'muigui-divider')};\nexport default class Divider extends Controller {\n constructor() {\n super('muigui-divider');\n }\n}","import Controller from './Controller.js';\n\nexport default class Container extends Controller {\n #controllers;\n #childDestController;\n\n constructor(className) {\n super(className);\n this.#controllers = [];\n this.#childDestController = this;\n }\n get children() {\n return this.#controllers; // should we return a copy?\n }\n get controllers() {\n return this.#controllers.filter(c => !(c instanceof Container));\n }\n get folders() {\n return this.#controllers.filter(c => c instanceof Container);\n }\n reset(recursive = true) {\n for (const controller of this.#controllers) {\n if (!(controller instanceof Container) || recursive) {\n controller.reset(recursive);\n }\n }\n return this;\n }\n updateDisplay() {\n for (const controller of this.#controllers) {\n controller.updateDisplay();\n }\n return this;\n }\n remove(controller) {\n const ndx = this.#controllers.indexOf(controller);\n if (ndx >= 0) {\n const c = this.#controllers.splice(ndx, 1);\n const c0 = c[0];\n const elem = c0.domElement;\n elem.remove();\n c0.setParent(null);\n }\n return this;\n }\n #addControllerImpl(controller) {\n this.domElement.appendChild(controller.domElement);\n this.#controllers.push(controller);\n controller.setParent(this);\n return controller;\n }\n addController(controller) {\n return this.#childDestController.#addControllerImpl(controller);\n }\n pushContainer(container) {\n this.addController(container);\n this.#childDestController = container;\n return container;\n }\n popContainer() {\n this.#childDestController = this.#childDestController.parent;\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport Container from './Container.js';\n\nexport default class Folder extends Container {\n #labelElem;\n\n constructor(name = 'Controls', className = 'muigui-menu') {\n super(className);\n this.#labelElem = createElem('label');\n this.addElem(createElem('button', {\n type: 'button',\n onClick: () => this.toggleOpen(),\n }, [this.#labelElem]));\n this.pushContainer(new Container());\n this.name(name);\n this.open();\n }\n open(open = true) {\n this.domElement.classList.toggle('muigui-closed', !open);\n this.domElement.classList.toggle('muigui-open', open);\n return this;\n }\n close() {\n return this.open(false);\n }\n name(name) {\n this.#labelElem.textContent = name;\n return this;\n }\n title(title) {\n return this.name(title);\n }\n toggleOpen() {\n this.open(!this.domElement.classList.contains('muigui-open'));\n return this;\n }\n}\n","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addDividing = new Controller()\nexport default class Label extends Controller {\n constructor(text) {\n super('muigui-label');\n this.text(text);\n }\n text(text) {\n this.domElement.textContent = text;\n return this;\n }\n}","function noop() {\n}\n\nexport function computeRelativePosition(elem, event, start) {\n const rect = elem.getBoundingClientRect();\n const x = event.clientX - rect.left;\n const y = event.clientY - rect.top;\n const nx = x / rect.width;\n const ny = y / rect.height;\n start = start || [x, y];\n const dx = x - start[0];\n const dy = y - start[1];\n const ndx = dx / rect.width;\n const ndy = dy / rect.width;\n return {x, y, nx, ny, dx, dy, ndx, ndy};\n}\n\nexport function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}) {\n let start;\n const pointerMove = function (event) {\n const e = {\n type: 'move',\n ...computeRelativePosition(elem, event, start),\n };\n onMove(e);\n };\n\n const pointerUp = function (event) {\n elem.releasePointerCapture(event.pointerId);\n elem.removeEventListener('pointermove', pointerMove);\n elem.removeEventListener('pointerup', pointerUp);\n\n document.body.style.backgroundColor = '';\n\n onUp('up');\n };\n\n const pointerDown = function (event) {\n elem.addEventListener('pointermove', pointerMove);\n elem.addEventListener('pointerup', pointerUp);\n elem.setPointerCapture(event.pointerId);\n\n const rel = computeRelativePosition(elem, event);\n start = [rel.x, rel.y];\n onDown({\n type: 'down',\n ...rel,\n });\n };\n\n elem.addEventListener('pointerdown', pointerDown);\n\n return function () {\n elem.removeEventListener('pointerdown', pointerDown);\n };\n}","import { createElem, getNewId } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp } from '../libs/utils.js';\nimport EditView from './EditView.js';\nimport {\n hexToFloatRGB,\n hexToFloatRGBA,\n hsv01ToRGBFloat,\n hsva01ToRGBAFloat,\n rgbFloatToHSV01,\n rgbaFloatToHSVA01,\n floatRGBToHex,\n floatRGBAToHex,\n rgbaFloatToHsla01,\n} from '../libs/color-utils.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nconst svg = `\n\n\n\n`;\n\nfunction connectFillTargets(elem) {\n elem.querySelectorAll('[data-src]').forEach(srcElem => {\n const id = getNewId();\n srcElem.id = id;\n elem.querySelectorAll(`[data-target=${srcElem.dataset.src}]`).forEach(targetElem => {\n targetElem.setAttribute('fill', `url(#${id})`);\n });\n });\n return elem;\n}\n\n// Was originally going to make alpha an option. Issue is\n// hard coded conversions?\nexport default class ColorChooserView extends EditView {\n #to;\n #from;\n #satLevelElem;\n #circleElem;\n #hueUIElem;\n #hueElem;\n #hueCursorElem;\n #alphaUIElem;\n #alphaElem;\n #alphaCursorElem;\n #hsva;\n #skipHueUpdate;\n #skipSatLevelUpdate;\n #skipAlphaUpdate;\n #options = {\n converters: identity,\n alpha: false,\n };\n #convertInternalToHex;\n #convertHexToInternal;\n\n constructor(setter, options) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n this.#satLevelElem = this.domElement.children[0];\n this.#hueUIElem = this.domElement.children[1];\n this.#alphaUIElem = this.domElement.children[2];\n connectFillTargets(this.#satLevelElem);\n connectFillTargets(this.#hueUIElem);\n connectFillTargets(this.#alphaUIElem);\n this.#circleElem = this.$('.muigui-color-chooser-circle');\n this.#hueElem = this.$('[data-src=muigui-color-chooser-hue]');\n this.#hueCursorElem = this.$('.muigui-color-chooser-hue-cursor');\n this.#alphaElem = this.$('[data-src=muigui-color-chooser-alpha]');\n this.#alphaCursorElem = this.$('.muigui-color-chooser-alpha-cursor');\n\n const handleSatLevelChange = (e) => {\n const s = clamp(e.nx, 0, 1);\n const v = clamp(e.ny, 0, 1);\n this.#hsva[1] = s;\n this.#hsva[2] = (1 - v);\n this.#skipHueUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleHueChange = (e) => {\n const h = clamp(e.nx, 0, 1);\n this.#hsva[0] = h;\n this.#skipSatLevelUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleAlphaChange = (e) => {\n const a = clamp(e.nx, 0, 1);\n this.#hsva[3] = a;\n this.#skipHueUpdate = true;\n this.#skipSatLevelUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n addTouchEvents(this.#satLevelElem, {\n onDown: handleSatLevelChange,\n onMove: handleSatLevelChange,\n });\n addTouchEvents(this.#hueUIElem, {\n onDown: handleHueChange,\n onMove: handleHueChange,\n });\n addTouchEvents(this.#alphaUIElem, {\n onDown: handleAlphaChange,\n onMove: handleAlphaChange,\n });\n this.setOptions(options);\n }\n updateDisplay(newV) {\n if (!this.#hsva) {\n this.#hsva = this.#convertHexToInternal(this.#to(newV));\n }\n {\n const [h, s, v, a = 1] = this.#convertHexToInternal(this.#to(newV));\n // Don't copy the hue if it was un-computable.\n if (!this.#skipHueUpdate) {\n this.#hsva[0] = s > 0.001 && v > 0.001 ? h : this.#hsva[0];\n }\n if (!this.#skipSatLevelUpdate) {\n this.#hsva[1] = s;\n this.#hsva[2] = v;\n }\n if (!this.#skipAlphaUpdate) {\n this.#hsva[3] = a;\n }\n }\n {\n const [h, s, v, a] = this.#hsva;\n const [hue, sat, lum] = rgbaFloatToHsla01(hsva01ToRGBAFloat(this.#hsva));\n\n if (!this.#skipHueUpdate) {\n this.#hueCursorElem.setAttribute('transform', `translate(${h * 64}, 0)`);\n }\n this.#hueElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} 0% 100% / ${a})`);\n this.#hueElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} 100% 50% / ${a})`);\n if (!this.#skipAlphaUpdate) {\n this.#alphaCursorElem.setAttribute('transform', `translate(${a * 64}, 0)`);\n }\n this.#alphaElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 0)`);\n this.#alphaElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 1)`);\n\n if (!this.#skipSatLevelUpdate) {\n this.#circleElem.setAttribute('cx', `${s * 64}`);\n this.#circleElem.setAttribute('cy', `${(1 - v) * 48}`);\n }\n }\n this.#skipHueUpdate = false;\n this.#skipSatLevelUpdate = false;\n this.#skipAlphaUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}, alpha} = this.#options;\n this.#alphaUIElem.style.display = alpha ? '' : 'none';\n this.#convertInternalToHex = alpha\n ? v => floatRGBAToHex(hsva01ToRGBAFloat(v))\n : v => floatRGBToHex(hsv01ToRGBFloat(v));\n this.#convertHexToInternal = alpha\n ? v => rgbaFloatToHSVA01(hexToFloatRGBA(v))\n : v => rgbFloatToHSV01(hexToFloatRGB(v));\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import ElementView from '../views/ElementView.js';\nimport ValueController from './ValueController.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport { createElem } from '../libs/elem.js';\n/*\n\nholder = new TabHolder\ntab = holder.add(new Tab(\"name\"))\ntab.add(...)\n\n\npc = new PopdownController\ntop = pc.add(new Row())\ntop.add(new Button());\nvalues = topRow.add(new Div())\nbottom = pc.add(new Row());\n\n\n\npc = new PopdownController\npc.addTop\npc.addTop\n\npc.addBottom\n\n\n*/\n\nexport default class PopDownController extends ValueController {\n #top;\n #valuesView;\n #checkboxElem;\n #bottom;\n #options = {\n open: false,\n };\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-pop-down-controller');\n /*\n [ValueView\n [[B][values]] upper row\n [[ visual ]] lower row\n ]\n */\n this.#top = this.add(new ElementView('div', 'muigui-pop-down-top'));\n// this.#top.add(new CheckboxView(makeSetter(this.#options, 'open')));\n const checkboxElem = this.#top.addElem(createElem('input', {\n type: 'checkbox',\n onChange: () => {\n this.#options.open = checkboxElem.checked;\n this.updateDisplay();\n },\n }));\n this.#checkboxElem = checkboxElem;\n this.#valuesView = this.#top.add(new ElementView('div', 'muigui-pop-down-values'));\n this.#bottom = this.add(new ElementView('div', 'muigui-pop-down-bottom'));\n this.setOptions(options);\n }\n setKnobColor(bgCssColor/*, fgCssColor*/) {\n if (this.#checkboxElem) {\n this.#checkboxElem.style = `\n --range-color: ${bgCssColor};\n --value-bg-color: ${bgCssColor};\n `;\n }\n }\n updateDisplay() {\n super.updateDisplay();\n const {open} = this.#options;\n this.domElement.children[1].classList.toggle('muigui-open', open);\n this.domElement.children[1].classList.toggle('muigui-closed', !open);\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n super.setOptions(options);\n this.updateDisplay();\n }\n addTop(view) {\n return this.#valuesView.add(view);\n }\n addBottom(view) {\n return this.#bottom.add(view);\n }\n}","/* eslint-disable no-underscore-dangle */\nimport {\n colorFormatConverters,\n guessFormat,\n hasAlpha,\n hexToUint8RGB,\n hslToRgbUint8,\n rgbUint8ToHsl,\n uint8RGBToHex,\n} from '../libs/color-utils.js';\nimport ColorChooserView from '../views/ColorChooserView.js';\nimport TextView from '../views/TextView.js';\nimport PopDownController from './PopDownController.js';\n\nexport default class ColorChooser extends PopDownController {\n #colorView;\n #textView;\n #to;\n #setKnobHelper;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color-chooser');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#to = color.to;\n this.#textView = new TextView(this, {converters: text, alpha: hasAlpha(format)});\n this.#colorView = new ColorChooserView(this, {converters: color, alpha: hasAlpha(format)});\n this.addTop(this.#textView);\n this.addBottom(this.#colorView);\n // WTF! FIX!\n this.#setKnobHelper = () => {\n if (this.#to) {\n const hex6Or8 = this.#to(this.getValue());\n const hsl = rgbUint8ToHsl(hexToUint8RGB(hex6Or8));\n hsl[2] = (hsl[2] + 50) % 100;\n const hex = uint8RGBToHex(hslToRgbUint8(hsl));\n this.setKnobColor(`${hex6Or8.substring(0, 7)}FF`, hex);\n }\n };\n this.updateDisplay();\n }\n updateDisplay() {\n super.updateDisplay();\n if (this.#setKnobHelper) {\n this.#setKnobHelper();\n }\n }\n setOptions(options) {\n super.setOptions(options);\n return this;\n }\n}\n","import css from './styles/muigui.css.js';\nimport {createElem} from './libs/elem.js';\nimport {createController} from './controllers/create-controller.js';\nimport {\n mapRange,\n makeRangeConverters,\n makeRangeOptions,\n makeMinMaxPair,\n} from './libs/utils.js';\nimport {\n converters\n} from './libs/conversions.js';\nimport {\n hasAlpha,\n guessFormat,\n} from './libs/color-utils.js';\nimport Canvas from './controllers/Canvas.js';\nimport Color from './controllers/Color.js';\nimport Divider from './controllers/Divider.js';\nimport Folder from './controllers/Folder.js';\nimport Label from './controllers/Label.js';\nimport Controller from './controllers/Controller.js';\nimport ColorChooser from './controllers/ColorChooser.js';\n\nimport Column from './layout/Column.js';\nimport Frame from './layout/Frame.js';\nimport Grid from './layout/Grid.js';\nimport Row from './layout/Row.js';\n\nexport {\n Column,\n Frame,\n Grid,\n Row,\n};\n\nexport class GUIFolder extends Folder {\n add(object, property, ...args) {\n const controller = object instanceof Controller\n ? object\n : createController(object, property, ...args);\n return this.addController(controller);\n }\n addCanvas(name) {\n return this.addController(new Canvas(name));\n }\n addColor(object, property, options = {}) {\n const value = object[property];\n if (hasAlpha(options.format || guessFormat(value))) {\n return this.addController(new ColorChooser(object, property, options));\n } else {\n return this.addController(new Color(object, property, options));\n }\n }\n addDivider() {\n return this.addController(new Divider());\n }\n addFolder(name) {\n return this.addController(new GUIFolder(name));\n }\n addLabel(text) {\n return this.addController(new Label(text));\n }\n}\n\nclass MuiguiElement extends HTMLElement {\n constructor() {\n super();\n this.shadow = this.attachShadow({mode: 'open'});\n }\n}\n\ncustomElements.define('muigui-element', MuiguiElement);\n\nconst baseStyleSheet = new CSSStyleSheet();\nbaseStyleSheet.replaceSync(css.default);\nconst userStyleSheet = new CSSStyleSheet();\n\nfunction makeStyleSheetUpdater(styleSheet) {\n let newCss;\n let newCssPromise;\n\n function updateStyle() {\n if (newCss && !newCssPromise) {\n const s = newCss;\n newCss = undefined;\n newCssPromise = styleSheet.replace(s).then(() => {\n newCssPromise = undefined;\n updateStyle();\n });\n }\n }\n\n return function updateStyleSheet(css) {\n newCss = css;\n updateStyle();\n };\n}\n\nconst updateBaseStyle = makeStyleSheetUpdater(baseStyleSheet);\nconst updateUserStyle = makeStyleSheetUpdater(userStyleSheet);\n\nexport class GUI extends GUIFolder {\n static converters = converters;\n static mapRange = mapRange;\n static makeRangeConverters = makeRangeConverters;\n static makeRangeOptions = makeRangeOptions;\n static makeMinMaxPair = makeMinMaxPair;\n #localStyleSheet = new CSSStyleSheet();\n\n constructor(options = {}) {\n super('Controls', 'muigui-root');\n if (options instanceof HTMLElement) {\n options = {parent: options};\n }\n const {\n autoPlace = true,\n width,\n title = 'Controls',\n } = options;\n let {\n parent,\n } = options;\n\n if (width) {\n this.domElement.style.width = /^\\d+$/.test(width) ? `${width}px` : width;\n }\n if (parent === undefined && autoPlace) {\n parent = document.body;\n this.domElement.classList.add('muigui-auto-place');\n }\n if (parent) {\n const muiguiElement = createElem('muigui-element');\n muiguiElement.shadowRoot.adoptedStyleSheets = [baseStyleSheet, userStyleSheet, this.#localStyleSheet];\n muiguiElement.shadow.appendChild(this.domElement);\n parent.appendChild(muiguiElement);\n }\n if (title) {\n this.title(title);\n }\n this.domElement.classList.add('muigui', 'muigui-colors');\n }\n setStyle(css) {\n this.#localStyleSheet.replace(css);\n }\n static setBaseStyles(css) {\n updateBaseStyle(css);\n }\n static getBaseStyleSheet() {\n return baseStyleSheet;\n }\n static setUserStyles(css) {\n updateUserStyle(css);\n }\n static getUserStyleSheet() {\n return userStyleSheet;\n }\n static setTheme(name) {\n GUI.setBaseStyles(`${css.default}\\n${css.themes[name] || ''}`);\n }\n}\n\nexport default GUI;\n","import Button from './Button.js';\nimport Checkbox from './Checkbox.js';\nimport TextNumber from './TextNumber.js';\nimport Select from './Select.js';\nimport Range from './Range.js';\nimport Text from './Text.js';\n\n// const isConversion = o => typeof o.to === 'function' && typeof o.from === 'function';\n\n/**\n * possible inputs\n * add(o, p, min: number, max: number)\n * add(o, p, min: number, max: number, step: number)\n * add(o, p, array: [value])\n * add(o, p, array: [[key, value]])\n *\n * @param {*} object\n * @param {string} property\n * @param {...any} args\n * @returns {Controller}\n */\nexport function createController(object, property, ...args) {\n const [arg1] = args;\n if (Array.isArray(arg1)) {\n return new Select(object, property, {keyValues: arg1});\n }\n\n const t = typeof object[property];\n switch (t) {\n case 'number':\n if (typeof args[0] === 'number' && typeof args[1] === 'number') {\n const min = args[0];\n const max = args[1];\n const step = args[2];\n return new Range(object, property, {min, max, ...(step && {step})});\n }\n return args.length === 0\n ? new TextNumber(object, property, ...args)\n : new Range(object, property, ...args);\n case 'boolean':\n return new Checkbox(object, property, ...args);\n case 'function':\n return new Button(object, property, ...args);\n case 'string':\n return new Text(object, property, ...args);\n case 'undefined':\n throw new Error(`no property named ${property}`);\n default:\n throw new Error(`unhandled type ${t} for property ${property}`);\n }\n}","function noop() {\n}\n\nconst keyDirections = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n\n// This probably needs to be global\nexport function addKeyboardEvents(elem, {onDown = noop, onUp = noop}) {\n const keyDown = function (event) {\n const mult = event.shiftKey ? 10 : 1;\n const [dx, dy] = (keyDirections[event.key] || [0, 0]).map(v => v * mult);\n const fn = event.type === 'keydown' ? onDown : onUp;\n fn({\n type: event.type.substring(3),\n dx,\n dy,\n event,\n });\n };\n\n elem.addEventListener('keydown', keyDown);\n elem.addEventListener('keyup', keyDown);\n\n return function () {\n elem.removeEventListener('keydown', keyDown);\n elem.removeEventListener('keyup', keyDown);\n };\n}","export function assert(truthy, msg = '') {\n if (!truthy) {\n throw new Error(msg);\n }\n}","import { assert } from '../libs/assert.js';\n\nfunction getEllipsePointForAngle(cx, cy, rx, ry, phi, theta) {\n const m = Math.abs(rx) * Math.cos(theta);\n const n = Math.abs(ry) * Math.sin(theta);\n\n return [\n cx + Math.cos(phi) * m - Math.sin(phi) * n,\n cy + Math.sin(phi) * m + Math.cos(phi) * n,\n ];\n}\n\nfunction getEndpointParameters(cx, cy, rx, ry, phi, theta, dTheta) {\n const [x1, y1] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta);\n const [x2, y2] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta + dTheta);\n\n const fa = Math.abs(dTheta) > Math.PI ? 1 : 0;\n const fs = dTheta > 0 ? 1 : 0;\n\n return { x1, y1, x2, y2, fa, fs };\n}\n\nexport function arc(cx, cy, r, start, end) {\n assert(Math.abs(start - end) <= Math.PI * 2);\n assert(start >= -Math.PI && start <= Math.PI * 2);\n assert(start <= end);\n assert(end >= -Math.PI && end <= Math.PI * 4);\n\n const { x1, y1, x2, y2, fa, fs } = getEndpointParameters(cx, cy, r, r, 0, start, end - start);\n return Math.abs(Math.abs(start - end) - Math.PI * 2) > Number.EPSILON\n ? `M${cx} ${cy} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2} L${cx} ${cy}`\n : `M${x1} ${y1} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2}`;\n}\n","import { identity } from '../libs/conversions.js';\nimport { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { arc } from '../libs/svg.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, euclideanModulo, lerp, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nconst twoPiMod = v => euclideanModulo(v + Math.PI, Math.PI * 2) - Math.PI;\n\nexport default class DirectionView extends EditView {\n #arrowElem;\n #rangeElem;\n #lastV;\n #wrap;\n #options = {\n step: 1,\n min: -180,\n max: 180,\n\n /*\n --------\n / -π/2 \\\n / | \\\n |<- -π * |\n | * 0 ->| zero is down the positive X axis\n |<- +π * |\n \\ | /\n \\ π/2 /\n --------\n */\n dirMin: -Math.PI,\n dirMax: Math.PI,\n //dirMin: Math.PI * 0.5,\n //dirMax: Math.PI * 2.5,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 7:30 to 10:30\n //dirMax: -Math.PI * 0.75,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 1:30\n //dirMax: -Math.PI * 0.25,\n //dirMin: Math.PI * 0.25, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.25,\n wrap: undefined,\n converters: identity,\n };\n\n constructor(setter, options = {}) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n className: 'muigui-direction muigui-no-scroll',\n innerHTML: svg,\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n let tempV = this.#lastV + delta;\n if (this.#wrap) {\n tempV = euclideanModulo(tempV - min, max - min) + min;\n }\n const newV = clamp(stepify(tempV, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n const handleTouch = (e) => {\n const {min, max, step, dirMin, dirMax} = this.#options;\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n const a = Math.atan2(ny, nx);\n\n const center = (dirMin + dirMax) / 2;\n\n const centeredAngle = twoPiMod(a - center);\n const centeredStart = twoPiMod(dirMin - center);\n const diff = dirMax - dirMin;\n\n const n = clamp((centeredAngle - centeredStart) / (diff), 0, 1);\n const newV = stepify(min + (max - min) * n, v => v, step);\n setter.setValue(newV);\n };\n addTouchEvents(this.domElement, {\n onDown: handleTouch,\n onMove: handleTouch,\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n this.#arrowElem = this.$('#muigui-arrow');\n this.#rangeElem = this.$('#muigui-range');\n this.setOptions(options);\n }\n updateDisplay(v) {\n this.#lastV = v;\n const {min, max} = this.#options;\n const n = (v - min) / (max - min);\n const angle = lerp(this.#options.dirMin, this.#options.dirMax, n);\n this.#arrowElem.style.transform = `rotate(${angle}rad)`;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {dirMin, dirMax, wrap} = this.#options;\n this.#wrap = wrap !== undefined\n ? wrap\n : Math.abs(dirMin - dirMax) >= Math.PI * 2 - Number.EPSILON;\n const [min, max] = dirMin < dirMax ? [dirMin, dirMax] : [dirMax , dirMin];\n this.#rangeElem.setAttribute('d', arc(0, 0, 28.87, min, max));\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport EditView from './EditView.js';\n\nexport default class RadioGridView extends EditView {\n #values;\n\n constructor(setter, keyValues, cols = 3) {\n const values = [];\n const name = makeId();\n super(createElem('div', {}, keyValues.map(([key, value], ndx) => {\n values.push(value);\n return createElem('label', {}, [\n createElem('input', {\n type: 'radio',\n name,\n value: ndx,\n onChange: function () {\n if (this.checked) {\n setter.setFinalValue(that.#values[this.value]);\n }\n },\n }),\n createElem('button', {\n type: 'button',\n textContent: key,\n onClick: function () {\n this.previousElementSibling.click();\n },\n }),\n ]);\n })));\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.#values = values;\n this.cols(cols);\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n for (let i = 0; i < this.domElement.children.length; ++i) {\n this.domElement.children[i].children[0].checked = i === ndx;\n }\n }\n cols(cols) {\n this.domElement.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;\n }\n}\n","export function onResize(elem, callback) {\n new ResizeObserver(() => {\n callback({rect: elem.getBoundingClientRect(), elem});\n }).observe(elem);\n}\n\nexport function onResizeSVGNoScale(elem, hAnchor, vAnchor, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.setAttribute('viewBox', `-${width * hAnchor} -${height * vAnchor} ${width} ${height}`);\n callback({elem, rect});\n });\n}\n\nexport function onResizeCanvas(elem, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.width = width;\n elem.height = height;\n callback({elem, rect});\n });\n}\n","import { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nfunction createSVGTicks(start, end, step, min, max, height) {\n const p = [];\n if (start < min) {\n start += stepify(min - start, v => v, step);\n }\n end = Math.min(end, max);\n for (let i = start; i <= end; i += step) {\n p.push(`M${i} 0 l0 ${height}`);\n }\n return p.join(' ');\n}\n\nfunction createSVGNumbers(start, end, unitSize, unit, minusSize, min, max, labelFn) {\n const texts = [];\n if (start < min) {\n start += stepify(min - start, v => v, unitSize);\n }\n end = Math.min(end, max);\n const digits = Math.max(0, -Math.log10(unit));\n const f = v => labelFn(v.toFixed(digits));\n for (let i = start; i <= end; i += unitSize) {\n texts.push(`= 0 ? i : (i - minusSize / 2) }\" y=\"0\">${f(i / unitSize * unit)}`);\n }\n return texts.join('\\n');\n}\n\nfunction computeSizeOfMinus(elem) {\n const oldHTML = elem.innerHTML;\n elem.innerHTML = '- ';\n const text = elem.querySelector('text');\n const size = text.getComputedTextLength();\n elem.innerHTML = oldHTML;\n return size;\n}\n\nexport default class SliderView extends EditView {\n #svgElem;\n #originElem;\n #ticksElem;\n #thicksElem;\n #numbersElem;\n #leftGradElem;\n #rightGradElem;\n #width;\n #height;\n #lastV;\n #minusSize;\n #options = {\n min: -100,\n max: 100,\n step: 1,\n unit: 10,\n unitSize: 10,\n ticksPerUnit: 5,\n labelFn: v => v,\n tickHeight: 1,\n limits: true,\n thicksColor: undefined,\n orientation: undefined,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-v-scroll',\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(this.#lastV + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.#svgElem = this.$('svg');\n this.#originElem = this.$('#muigui-origin');\n this.#ticksElem = this.$('#muigui-ticks');\n this.#thicksElem = this.$('#muigui-thicks');\n this.#numbersElem = this.$('#muigui-numbers');\n this.#leftGradElem = this.$('#muigui-left-grad');\n this.#rightGradElem = this.$('#muigui-right-grad');\n this.setOptions(options);\n let startV;\n addTouchEvents(this.domElement, {\n onDown: () => {\n startV = this.#lastV;\n },\n onMove: (e) => {\n const {min, max, unitSize, unit, step} = this.#options;\n const newV = clamp(stepify(startV - e.dx / unitSize * unit, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n onResizeSVGNoScale(this.#svgElem, 0.5, 0, ({rect: {width}}) => {\n this.#leftGradElem.setAttribute('x', -width / 2);\n this.#rightGradElem.setAttribute('x', width / 2 - 20);\n this.#minusSize = computeSizeOfMinus(this.#numbersElem);\n this.#width = width;\n this.#updateSlider();\n });\n }\n // |--------V--------|\n // . . | . . . | . . . |\n //\n #updateSlider() {\n // There's no size if ResizeObserver has not fired yet.\n if (!this.#width || this.#lastV === undefined) {\n return;\n }\n const {\n labelFn,\n limits,\n min,\n max,\n orientation,\n tickHeight,\n ticksPerUnit,\n unit,\n unitSize,\n thicksColor,\n } = this.#options;\n const unitsAcross = Math.ceil(this.#width / unitSize);\n const center = this.#lastV;\n const centerUnitSpace = center / unit;\n const startUnitSpace = Math.round(centerUnitSpace - unitsAcross);\n const endUnitSpace = startUnitSpace + unitsAcross * 2;\n const start = startUnitSpace * unitSize;\n const end = endUnitSpace * unitSize;\n const minUnitSpace = limits ? min * unitSize / unit : start;\n const maxUnitSpace = limits ? max * unitSize / unit : end;\n const height = labelFn(1) === '' ? 10 : 5;\n if (ticksPerUnit > 1) {\n this.#ticksElem.setAttribute('d', createSVGTicks(start, end, unitSize / ticksPerUnit, minUnitSpace, maxUnitSpace, height * tickHeight));\n }\n this.#thicksElem.style.stroke = thicksColor; //setAttribute('stroke', thicksColor);\n this.#thicksElem.setAttribute('d', createSVGTicks(start, end, unitSize, minUnitSpace, maxUnitSpace, height));\n this.#numbersElem.innerHTML = createSVGNumbers(start, end, unitSize, unit, this.#minusSize, minUnitSpace, maxUnitSpace, labelFn);\n this.#originElem.setAttribute('transform', `translate(${-this.#lastV * unitSize / unit} 0)`);\n this.#svgElem.classList.toggle('muigui-slider-up', orientation === 'up');\n }\n updateDisplay(v) {\n this.#lastV = v;\n this.#updateSlider();\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nexport default class Vec2View extends EditView {\n #svgElem;\n #arrowElem;\n #circleElem;\n #lastV = [];\n\n constructor(setter) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n const onTouch = (e) => {\n const {width, height} = this.#svgElem.getBoundingClientRect();\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n setter.setValue([nx * width * 0.5, ny * height * 0.5]);\n };\n addTouchEvents(this.domElement, {\n onDown: onTouch,\n onMove: onTouch,\n });\n this.#svgElem = this.$('svg');\n this.#arrowElem = this.$('#muigui-arrow');\n this.#circleElem = this.$('#muigui-circle');\n onResizeSVGNoScale(this.#svgElem, 0.5, 0.5, () => this.#updateDisplayImpl);\n }\n #updateDisplayImpl() {\n const [x, y] = this.#lastV;\n this.#arrowElem.setAttribute('d', `M0,0L${x},${y}`);\n this.#circleElem.setAttribute('transform', `translate(${x}, ${y})`);\n }\n updateDisplay(v) {\n this.#lastV[0] = v[0];\n this.#lastV[1] = v[1];\n this.#updateDisplayImpl();\n }\n}\n","import GUI from './muigui.js';\n\nimport ColorChooser from './controllers/ColorChooser.js';\nimport Direction from './controllers/Direction.js';\nimport RadioGrid from './controllers/RadioGrid.js';\nimport Range from './controllers/Range.js';\nimport Select from './controllers/Select.js';\nimport Slider from './controllers/Slider.js';\nimport TextNumber from './controllers/TextNumber.js';\nimport Vec2 from './controllers/Vec2.js';\n\nGUI.ColorChooser = ColorChooser;\nGUI.Direction = Direction;\nGUI.RadioGrid = RadioGrid;\nGUI.Range = Range;\nGUI.Select = Select;\nGUI.Slider = Slider;\nGUI.TextNumber = TextNumber;\nGUI.Vec2 = Vec2;\n\nexport default GUI;","import { identity } from '../libs/conversions.js';\nimport DirectionView from '../views/DirectionView.js';\nimport NumberView from '../views/NumberView.js';\n// import ValueController from './ValueController.js';\nimport PopDownController from './PopDownController.js';\n\n\n// deg2rad\n// where is 0\n// range (0, 360), (-180, +180), (0,0) Really this is a range\n\nexport default class Direction extends PopDownController {\n #options;\n constructor(object, property, options) {\n super(object, property, 'muigui-direction');\nthis.#options = options; // FIX\n this.addTop(new NumberView(this,\nidentity));\n this.addBottom(new DirectionView(this, options));\n this.updateDisplay();\n }\n}\n\n","import RadioGridView from '../views/RadioGridView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class RadioGrid extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-radio-grid');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {\n keyValues: keyValuesInput,\n cols = 3,\n } = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new RadioGridView(this, keyValues, cols));\n this.updateDisplay();\n }\n}","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport SliderView from '../views/SliderView.js';\n\nexport default class Slider extends ValueController {\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-slider');\n this.add(new SliderView(this, options));\n this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}\n","import NumberView from '../views/NumberView.js';\nimport Vec2View from '../views/Vec2View.js';\nimport PopDownController from './PopDownController.js';\nimport { strToNumber } from '../libs/conversions.js';\n\n// TODO: zoom with wheel and pinch?\n// TODO: grid?\n// // options\n// scale:\n// range: number (both x and y + /)\n// range: array (min, max)\n// xRange:\n// deg/rad/turn\n\nexport default class Vec2 extends PopDownController {\n constructor(object, property) {\n super(object, property, 'muigui-vec2');\n\n const makeSetter = (ndx) => {\n return {\n setValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setValue(newV);\n },\n setFinalValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setFinalValue(newV);\n },\n };\n };\n\n this.addTop(new NumberView(makeSetter(0), {\n converters: {\n to: v => v[0],\n from: strToNumber.from,\n },\n }));\n this.addTop(new NumberView(makeSetter(1), {\n converters: {\n to: v => v[1],\n from: strToNumber.from,\n },\n }));\n this.addBottom(new Vec2View(this));\n this.updateDisplay();\n }\n}\n"],"names":["css","default","themes","float","createElem","tag","attrs","children","elem","document","createElement","key","value","Object","entries","startsWith","eventName","substring","toLowerCase","addEventListener","passive","k","v","undefined","setAttribute","child","appendChild","setElemProps","nextId","removeArrayElem","array","ndx","indexOf","splice","clamp","min","max","Math","isTypedArray","SharedArrayBuffer","a","buffer","ArrayBuffer","stepify","from","step","round","euclideanModulo","n","copyExistingProperties","dst","src","mapRange","inMin","inMax","outMin","outMax","makeRangeConverters","to","makeRangeOptions","converters","identity","makeMinMaxPair","gui","properties","minPropName","maxPropName","options","guiMinRange","minRange","valueMinRange","minGui","add","onChange","maxGui","setValue","View","domElement","childDestElem","views","constructor","this","addElem","removeElem","removeChild","pushSubElem","popSubElem","parentElement","view","push","remove","pushSubView","popSubView","setOptions","updateDisplayIfNeeded","newV","ignoreCache","$","selector","querySelector","Controller","changeFns","finishChangeFns","parent","className","super","classList","setParent","enable","disabled","show","toggle","hide","closest","forEach","querySelectorAll","disable","fn","removeChange","onFinishChange","removeFinishChange","callListeners","fns","call","emitChange","object","property","controller","emitFinalChange","updateDisplay","getColors","toCamelCase","s","replace","m","m1","toUpperCase","div","colors","fromEntries","map","style","color","getComputedStyle","Button","buttonElem","name","type","onClick","textContent","arraysEqual","b","length","i","EditView","oldV","updateCheck","checkArrayNeedsUpdate","needUpdate","copyArrayElementsFromTo","checkTypedArrayNeedsUpdate","once","checkObjectNeedsUpdate","checkValueNeedsUpdate","getUpdateCheckForType","Array","isArray","bind","CheckboxView","checkboxElem","setter","id","onInput","checked","setFinalValue","tasks","tasksToRemove","Set","requestId","processing","processTasks","task","has","size","queueProcessing","clear","requestAnimationFrame","makeId","ValueView","LabelController","nameElem","for","title","tooltip","tip","ValueController","initialValue","listening","updateFn","getValue","setValueImpl","isDifferent","keys","assign","reset","listen","set","removeTask","Checkbox","strToNumber","toString","parseFloat","Number","isNaN","radToDeg","PI","createWheelHelper","wheelAccum","e","wheelScale","deltaY","delta","floor","abs","sign","NumberView","skipUpdate","NEGATIVE_INFINITY","POSITIVE_INFINITY","wheelHelper","handleInput","onWheel","preventDefault","setFn","valid","inRange","TextNumber","textView","SelectView","values","keyValues","selectedIndex","convertToKeyValues","valueIsNumber","Select","keyValuesInput","RangeView","validV","Range","TextView","Text","lerp","t","fract","f0","toFixed","f3","hexToUint32RGB","parseInt","hexToUint32RGBA","hexToUint8RGB","uint8RGBToHex","padStart","join","hexToUint8RGBA","uint8RGBAToHex","hexToFloatRGB","floatRGBToHex","hexToFloatRGBA","floatRGBAToHex","scaleAndClamp","hexToObjectRGB","r","g","hexToObjectRGBA","hexToCssRGB","cssRGBRegex","hexToCssRGBA","cssRGBARegex","hexToCssHSL","hsl","rgbUint8ToHsl","hexToCssHSLA","hsla","rgbaUint8ToHsla","cssHSLRegex","cssHSLARegex","hslToRgbUint8","h","l","f","rgbFloatToHsl01","d","rgbaFloatToHsla01","rgb","rgba","hsv01ToRGBFloat","hue","sat","val","hsva01ToRGBAFloat","alpha","round3","rgbFloatToHSV01","p","q","EPSILON","hasAlpha","format","endsWith","cssStringFormats","re","guessFormat","console","warn","formatInfo","test","guessStringColorFormat","trim","Uint8Array","Uint8ClampedArray","Float32Array","Error","fixHex6","fixHex8","hex6ToHex3","hex6","hex3RE","hex3ToHex6","hex3","exec","m2","fixHex3","strToCssRGB","find","strToCssRGBA","strToCssHSL","strToCssHSLA","strTo3IntsRE","strTo4IntsRE","strToUint32RGBRegex","strToUint32RGBARegex","hex6RE","hexNoHash6RE","hex8RE","hexNoHash8RE","colorFormatConverters","text","hex8","strToUint32RGB","strToUint32RGBA","numbers","split","badNdx","findIndex","json","JSON","parse","hslaToRgbaUint8","ElementView","Canvas","canvasElem","canvas","ColorView","colorElem","Color","colorView","Divider","Container","controllers","childDestController","filter","c","folders","recursive","c0","addControllerImpl","addController","pushContainer","container","popContainer","Folder","labelElem","toggleOpen","open","close","contains","Label","noop","computeRelativePosition","event","start","rect","getBoundingClientRect","x","clientX","left","y","clientY","top","nx","width","ny","height","dx","dy","ndy","addTouchEvents","onDown","onMove","onUp","pointerMove","pointerUp","releasePointerCapture","pointerId","removeEventListener","body","backgroundColor","pointerDown","setPointerCapture","rel","connectFillTargets","srcElem","dataset","targetElem","ColorChooserView","satLevelElem","circleElem","hueUIElem","hueElem","hueCursorElem","alphaUIElem","alphaElem","alphaCursorElem","hsva","skipHueUpdate","skipSatLevelUpdate","skipAlphaUpdate","convertInternalToHex","convertHexToInternal","innerHTML","handleSatLevelChange","handleHueChange","handleAlphaChange","lum","display","rgbaFloatToHSVA01","PopDownController","valuesView","bottom","setKnobColor","bgCssColor","addTop","addBottom","ColorChooser","setKnobHelper","hex6Or8","hex","GUIFolder","args","arg1","createController","addCanvas","addColor","addDivider","addFolder","addLabel","MuiguiElement","HTMLElement","shadow","attachShadow","mode","customElements","define","baseStyleSheet","CSSStyleSheet","replaceSync","userStyleSheet","makeStyleSheetUpdater","styleSheet","newCss","newCssPromise","updateStyle","then","updateBaseStyle","updateUserStyle","GUI","static","localStyleSheet","autoPlace","muiguiElement","shadowRoot","adoptedStyleSheets","setStyle","setBaseStyles","keyDirections","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","addKeyboardEvents","keyDown","mult","shiftKey","assert","truthy","msg","getEllipsePointForAngle","cx","cy","rx","ry","phi","theta","cos","sin","arc","end","x1","y1","x2","y2","fa","fs","dTheta","getEndpointParameters","twoPiMod","DirectionView","arrowElem","rangeElem","lastV","wrap","dirMin","dirMax","tempV","handleTouch","atan2","center","angle","transform","RadioGridView","cols","that","previousElementSibling","click","gridTemplateColumns","onResize","callback","ResizeObserver","observe","onResizeSVGNoScale","hAnchor","vAnchor","createSVGTicks","SliderView","svgElem","originElem","ticksElem","thicksElem","numbersElem","leftGradElem","rightGradElem","minusSize","unit","unitSize","ticksPerUnit","labelFn","tickHeight","limits","thicksColor","orientation","startV","oldHTML","getComputedTextLength","computeSizeOfMinus","updateSlider","unitsAcross","ceil","centerUnitSpace","startUnitSpace","minUnitSpace","maxUnitSpace","stroke","texts","digits","log10","createSVGNumbers","Vec2View","onTouch","updateDisplayImpl","Direction","RadioGrid","Slider","Vec2","makeSetter"],"mappings":"oOAAe,IAAAA,EAAA,CACbC,QAAS,s7cAsrBXC,OAAQ,CACND,QAAS,GACTE,MAAO,gyCCpqBF,SAASC,EAAWC,EAAKC,EAAQ,CAAA,EAAIC,EAAW,IACrD,MAAMC,EAAOC,SAASC,cAAcL,GAEpC,OAxBK,SAAsBG,EAAMF,EAAOC,GACxC,IAAK,MAAOI,EAAKC,KAAUC,OAAOC,QAAQR,GACxC,GAAqB,mBAAVM,GAAwBD,EAAII,WAAW,MAAO,CACvD,MAAMC,EAAYL,EA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WhJ,KAAMd,IAC9Bc,KAAKgD,eACN,GHOHqW,GAAI1P,WAAaA,EACjB0P,GAAI2G,KIJW,cAAmBlJ,GAChC/W,YAAY6C,EAAQC,GAClBrB,MAAMoB,EAAQC,EAAU,eAExB,MAAMod,EAAcnjB,IACX,CACL4C,SAAWrD,IACT,MAAMyE,EAAOd,KAAKsH,WAClBxG,EAAKhE,GAAOT,EACZ2D,KAAKN,SAASoB,EAAK,EAErB+E,cAAgBxJ,IACd,MAAMyE,EAAOd,KAAKsH,WAClBxG,EAAKhE,GAAOT,EACZ2D,KAAK6F,cAAc/E,EAAK,IAK9Bd,KAAKmX,OAAO,IAAInO,EAAWiX,EAAW,GAAI,CACxCthB,WAAY,CACVF,GAAIpC,GAAKA,EAAE,GACXsB,KAAMqK,EAAYrK,SAGtBqC,KAAKmX,OAAO,IAAInO,EAAWiX,EAAW,GAAI,CACxCthB,WAAY,CACVF,GAAIpC,GAAKA,EAAE,GACXsB,KAAMqK,EAAYrK,SAGtBqC,KAAKoX,UAAU,IAAIsI,GAAS1f,OAC5BA,KAAKgD,eACN"}
\ No newline at end of file
diff --git a/dist/0.x/muigui.module.js b/dist/0.x/muigui.module.js
new file mode 100644
index 0000000..db65852
--- /dev/null
+++ b/dist/0.x/muigui.module.js
@@ -0,0 +1,3818 @@
+/* muigui@0.0.12, license MIT */
+var css = {
+ default: `
+.muigui {
+ --bg-color: #ddd;
+ --color: #222;
+ --contrast-color: #eee;
+ --value-color: #145 ;
+ --value-bg-color: #eeee;
+ --disabled-color: #999;
+ --menu-bg-color: #f8f8f8;
+ --menu-sep-color: #bbb;
+ --hover-bg-color: #999;
+ --focus-color: #68C;
+ --range-color: #888888;
+ --invalid-color: #FF0000;
+ --selected-color: rgb(255, 255, 255, 0.9);
+
+ --button-bg-color: var(--value-bg-color);
+
+ --range-left-color: var(--value-color);
+ --range-right-color: var(--value-bg-color);
+ --range-right-hover-color: var(--hover-bg-color);
+
+ color: var(--color);
+ background-color: var(--bg-color);
+}
+
+@media (prefers-color-scheme: dark) {
+ .muigui {
+ --bg-color: #222222;
+ --color: #dddddd;
+ --contrast-color: #000;
+ --value-color: #43e5f7;
+ --value-bg-color: #444444;
+ --disabled-color: #666666;
+ --menu-bg-color: #080808;
+ --menu-sep-color: #444444;
+ --hover-bg-color: #666666;
+ --focus-color: #88AAFF;
+ --range-color: #888888;
+ --invalid-color: #FF6666;
+ --selected-color: rgba(255, 255, 255, 0.3);
+
+ --button-bg-color: var(--value-bg-color);
+
+ --range-left-color: var(--value-color);
+ --range-right-color: var(--value-bg-color);
+ --range-right-hover-color: var(--hover-bg-color);
+
+ color: var(--color);
+ background-color: var(--bg-color);
+ }
+}
+
+.muigui {
+ --width: 250px;
+ --label-width: 45%;
+ --number-width: 40%;
+
+
+ --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
+ --font-size: 11px;
+ --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
+ --font-size-mono: 11px;
+
+ --line-height: 1.7em;
+ --border-radius: 0px;
+
+ width: var(--width);
+ font-family: var(--font-family);
+ font-size: var(--font-size);
+ box-sizing: border-box;
+ line-height: 100%;
+}
+.muigui * {
+ box-sizing: inherit;
+}
+
+.muigui-no-scroll {
+ touch-action: none;
+}
+.muigui-no-h-scroll {
+ touch-action: pan-y;
+}
+.muigui-no-v-scroll {
+ touch-action: pan-x;
+}
+
+.muigui-invalid-value {
+ background-color: red !important;
+ color: white !important;
+}
+
+.muigui-grid {
+ display: grid;
+}
+.muigui-rows {
+ display: flex;
+ flex-direction: column;
+
+ min-height: 20px;
+ border: 2px solid red;
+}
+.muigui-columns {
+ display: flex;
+ flex-direction: row;
+
+ height: 20px;
+ border: 2px solid green;
+}
+.muigui-rows>*,
+.muigui-columns>* {
+ flex: 1 1 auto;
+ align-items: stretch;
+ min-height: 0;
+ min-width: 0;
+}
+
+.muigui-row {
+ border: 2px solid yellow;
+ min-height: 10px
+}
+.muigui-column {
+ border: 2px solid lightgreen;
+}
+
+/* -------- */
+
+.muigui-show { /* */ }
+.muigui-hide {
+ display: none !important;
+}
+.muigui-disabled {
+ pointer-events: none;
+ --color: var(--disabled-color) !important;
+ --value-color: var(--disabled-color) !important;
+ --range-left-color: var(--disabled-color) !important;
+}
+
+.muigui canvas,
+.muigui svg {
+ display: block;
+ border-radius: var(--border-radius);
+}
+.muigui canvas {
+ background-color: var(--value-bg-color);
+}
+
+.muigui-controller {
+ min-width: 0;
+ min-height: var(--line-height);
+}
+.muigui-root,
+.muigui-menu {
+ display: flex;
+ flex-direction: column;
+ position: relative;
+ user-select: none;
+ height: fit-content;
+ margin: 0;
+ padding-bottom: 0.1em;
+ border-radius: var(--border-radius);
+}
+.muigui-menu {
+ border-bottom: 1px solid var(--menu-sep-color);
+}
+
+.muigui-root>button:nth-child(1),
+.muigui-menu>button:nth-child(1) {
+ border-top: 1px solid var(--menu-sep-color);
+ border-bottom: 1px solid var(--menu-sep-color);
+ position: relative;
+ text-align: left;
+ color: var(--color);
+ background-color: var(--menu-bg-color);
+ min-height: var(--line-height);
+ padding-top: 0.2em;
+ padding-bottom: 0.2em;
+ cursor: pointer;
+ border-radius: var(--border-radius);
+}
+.muigui-root>div:nth-child(2),
+.muigui-menu>div:nth-child(2) {
+ flex: 1 1 auto;
+}
+
+.muigui-controller {
+ margin-left: 0.2em;
+ margin-right: 0.2em;
+}
+.muigui-root.muigui-controller,
+.muigui-menu.muigui-controller {
+ margin-left: 0;
+ margin-right: 0;
+}
+.muigui-controller>*:nth-child(1) {
+ flex: 1 0 var(--label-width);
+ min-width: 0;
+ white-space: pre;
+}
+.muigui-controller>label:nth-child(1) {
+ place-content: center start;
+ display: inline-grid;
+ overflow: hidden;
+}
+.muigui-controller>*:nth-child(2) {
+ flex: 1 1 75%;
+ min-width: 0;
+}
+
+/* -----------------------------------------
+ a label controller is [[label][value]]
+*/
+
+.muigui-label-controller {
+ display: flex;
+ margin: 0.4em 0 0.4em 0;
+ word-wrap: initial;
+ align-items: stretch;
+}
+
+.muigui-value {
+ display: flex;
+ align-items: stretch;
+}
+.muigui-value>* {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+.muigui-value>*:nth-child(1) {
+ flex: 1 1 calc(100% - var(--number-width));
+}
+.muigui-value>*:nth-child(2) {
+ flex: 1 1 var(--number-width);
+ margin-left: 0.2em;
+}
+
+/* fix! */
+.muigui-open>button>label::before,
+.muigui-closed>button>label::before {
+ width: 1.25em;
+ height: var(--line-height);
+ display: inline-grid;
+ place-content: center start;
+ pointer-events: none;
+}
+.muigui-open>button>label::before {
+ content: "ⓧ"; /*"▼";*/
+}
+.muigui-closed>button>label::before {
+ content: "⨁"; /*"▶";*/
+}
+.muigui-open>*:nth-child(2) {
+ transition: max-height 0.2s ease-out,
+ opacity 0.5s ease-out;
+ max-height: 100vh;
+ overflow: auto;
+ opacity: 1;
+}
+
+.muigui-closed>*:nth-child(2) {
+ transition: max-height 0.2s ease-out,
+ opacity 1s;
+ max-height: 0;
+ opacity: 0;
+ overflow: hidden;
+}
+
+/* ---- popdown ---- */
+
+.muigui-pop-down-top {
+ display: flex;
+}
+/* fix? */
+.muigui-value>*:nth-child(1).muigui-pop-down-top {
+ flex: 0;
+}
+.muigui-pop-down-bottom {
+
+}
+
+.muigui-pop-down-values {
+ min-width: 0;
+ display: flex;
+}
+.muigui-pop-down-values>* {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+
+.muigui-value.muigui-pop-down-controller {
+ flex-direction: column;
+}
+
+.muigui-pop-down-top input[type=checkbox] {
+ -webkit-appearance: none;
+ appearance: none;
+ width: auto;
+ color: var(--value-color);
+ background-color: var(--value-bg-color);
+ cursor: pointer;
+
+ display: grid;
+ place-content: center;
+ margin: 0;
+ font: inherit;
+ color: currentColor;
+ width: 1.7em;
+ height: 1.7em;
+ transform: translateY(-0.075em);
+}
+
+.muigui-pop-down-top input[type=checkbox]::before {
+ content: "+";
+ display: grid;
+ place-content: center;
+ border-radius: calc(var(--border-radius) + 2px);
+ border-left: 1px solid rgba(255,255,255,0.3);
+ border-top: 1px solid rgba(255,255,255,0.3);
+ border-bottom: 1px solid rgba(0,0,0,0.2);
+ border-right: 1px solid rgba(0,0,0,0.2);
+ background-color: var(--range-color);
+ color: var(--value-bg-color);
+ width: calc(var(--line-height) - 4px);
+ height: calc(var(--line-height) - 4px);
+}
+
+.muigui-pop-down-top input[type=checkbox]:checked::before {
+ content: "X";
+}
+
+
+/* ---- select ---- */
+
+.muigui select,
+.muigui option,
+.muigui input,
+.muigui button {
+ color: var(--value-color);
+ background-color: var(--value-bg-color);
+ font-family: var(--font-family);
+ font-size: var(--font-size);
+ border: none;
+ margin: 0;
+ border-radius: var(--border-radius);
+}
+.muigui select {
+ appearance: none;
+ margin: 0;
+ margin-left: 0; /*?*/
+ overflow: hidden; /* Safari */
+}
+
+.muigui select:focus,
+.muigui input:focus,
+.muigui button:focus {
+ outline: 1px solid var(--focus-color);
+}
+
+.muigui select:hover,
+.muigui option:hover,
+.muigui input:hover,
+.muigui button:hover {
+ background-color: var(--hover-bg-color);
+}
+
+/* ------ [ label ] ------ */
+
+.muigui-label {
+ border-top: 1px solid var(--menu-sep-color);
+ border-bottom: 1px solid var(--menu-sep-color);
+ padding-top: 0.4em;
+ padding-bottom: 0.3em;
+ place-content: center start;
+ background-color: var(--menu-bg-color);
+ white-space: pre;
+ border-radius: var(--border-radius);
+}
+
+/* ------ [ divider] ------ */
+
+.muigui-divider {
+ min-height: 6px;
+ border-top: 2px solid var(--menu-sep-color);
+ margin-top: 6px;
+}
+
+/* ------ [ button ] ------ */
+
+.muigui-button {
+ display: grid;
+
+}
+.muigui-button button {
+ border: none;
+ color: var(--value-color);
+ background-color: var(--button-bg-color);
+ cursor: pointer;
+ place-content: center center;
+}
+
+/* ------ [ color ] ------ */
+
+.muigui-color>div {
+ overflow: hidden;
+ position: relative;
+ margin-left: 0;
+ margin-right: 0; /* why? */
+ max-width: var(--line-height);
+ border-radius: var(--border-radius);
+}
+
+.muigui-color>div:focus-within {
+ outline: 1px solid var(--focus-color);
+}
+
+.muigui-color input[type=color] {
+ border: none;
+ padding: 0;
+ background: inherit;
+ cursor: pointer;
+ position: absolute;
+ width: 200%;
+ left: -10px;
+ top: -10px;
+ height: 200%;
+}
+.muigui-disabled canvas,
+.muigui-disabled svg,
+.muigui-disabled img,
+.muigui-disabled .muigui-color input[type=color] {
+ opacity: 0.2;
+}
+
+/* ------ [ checkbox ] ------ */
+
+.muigui-checkbox>label:nth-child(2) {
+ display: grid;
+ place-content: center start;
+ margin: 0;
+}
+
+.muigui-checkbox input[type=checkbox] {
+ -webkit-appearance: none;
+ appearance: none;
+ width: auto;
+ color: var(--value-color);
+ background-color: var(--value-bg-color);
+ cursor: pointer;
+
+ display: grid;
+ place-content: center;
+ margin: 0;
+ font: inherit;
+ color: currentColor;
+ width: 1.7em;
+ height: 1.7em;
+ transform: translateY(-0.075em);
+}
+
+.muigui-checkbox input[type=checkbox]::before {
+ content: "";
+ color: var(--value-color);
+ display: grid;
+ place-content: center;
+}
+
+.muigui-checkbox input[type=checkbox]:checked::before {
+ content: "✔";
+}
+
+.muigui input[type=number]::-webkit-inner-spin-button,
+.muigui input[type=number]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ appearance: none;
+ margin: 0;
+}
+.muigui input[type=number] {
+ -moz-appearance: textfield;
+}
+
+/* ------ [ radio grid ] ------ */
+
+.muigui-radio-grid>div {
+ display: grid;
+ gap: 2px;
+}
+
+.muigui-radio-grid input {
+ appearance: none;
+ display: none;
+}
+
+.muigui-radio-grid button {
+ color: var(--color);
+ width: 100%;
+ text-align: left;
+}
+
+.muigui-radio-grid input:checked + button {
+ color: var(--value-color);
+ background-color: var(--selected-color);
+}
+
+/* ------ [ color-chooser ] ------ */
+
+.muigui-color-chooser-cursor {
+ stroke-width: 1px;
+ stroke: white;
+ fill: none;
+}
+.muigui-color-chooser-circle {
+ stroke-width: 1px;
+ stroke: white;
+ fill: none;
+}
+
+
+/* ------ [ vec2 ] ------ */
+
+.muigui-vec2 svg {
+ background-color: var(--value-bg-color);
+}
+
+.muigui-vec2-axis {
+ stroke: 1px;
+ stroke: var(--focus-color);
+}
+
+.muigui-vec2-line {
+ stroke-width: 1px;
+ stroke: var(--value-color);
+ fill: var(--value-color);
+}
+
+/* ------ [ direction ] ------ */
+
+.muigui-direction svg {
+ background-color: rgba(0,0,0,0.2);
+}
+
+.muigui-direction:focus-within svg {
+ outline: none;
+}
+.muigui-direction-range {
+ fill: var(--value-bg-color);
+}
+.muigui-direction svg:focus {
+ outline: none;
+}
+.muigui-direction svg:focus .muigui-direction-range {
+ stroke-width: 0.5px;
+ stroke: var(--focus-color);
+}
+
+.muigui-direction-arrow {
+ fill: var(--value-color);
+}
+
+/* ------ [ slider ] ------ */
+
+.muigui-slider>div {
+ display: flex;
+ align-items: stretch;
+ height: var(--line-height);
+}
+.muigui-slider svg {
+ flex: 1 1 auto;
+}
+.muigui-slider .muigui-slider-up #muigui-orientation {
+ transform: scale(1, -1) translateY(-100%);
+}
+
+.muigui-slider .muigui-slider-up #muigui-number-orientation {
+ transform: scale(1,-1);
+}
+
+.muigui-ticks {
+ stroke: var(--range-color);
+}
+.muigui-thicks {
+ stroke: var(--color);
+ stroke-width: 2px;
+}
+.muigui-svg-text {
+ fill: var(--color);
+ font-size: 7px;
+}
+.muigui-mark {
+ fill: var(--value-color);
+}
+
+/* ------ [ range ] ------ */
+
+
+.muigui-range input[type=range] {
+ -webkit-appearance: none;
+ appearance: none;
+ background-color: transparent;
+}
+
+.muigui-range input[type=range]::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ appearance: none;
+ border-radius: calc(var(--border-radius) + 2px);
+ border-left: 1px solid rgba(255,255,255,0.3);
+ border-top: 1px solid rgba(255,255,255,0.3);
+ border-bottom: 1px solid rgba(0,0,0,0.2);
+ border-right: 1px solid rgba(0,0,0,0.2);
+ background-color: var(--range-color);
+ margin-top: calc((var(--line-height) - 2px) / -2);
+ width: calc(var(--line-height) - 2px);
+ height: calc(var(--line-height) - 2px);
+}
+
+.muigui-range input[type=range]::-webkit-slider-runnable-track {
+ -webkit-appearance: none;
+ appearance: none;
+ border: 1px solid var(--menu-sep-color);
+ height: 2px;
+}
+
+
+/* dat.gui style - doesn't work on Safari iOS */
+
+/*
+.muigui-range input[type=range] {
+ cursor: ew-resize;
+ overflow: hidden;
+}
+
+.muigui-range input[type=range] {
+ -webkit-appearance: none;
+ appearance: none;
+ background-color: var(--range-right-color);
+ margin: 0;
+}
+.muigui-range input[type=range]:hover {
+ background-color: var(--range-right-hover-color);
+}
+
+.muigui-range input[type=range]::-webkit-slider-runnable-track {
+ -webkit-appearance: none;
+ appearance: none;
+ height: max-content;
+ color: var(--range-left-color);
+ margin-top: -1px;
+}
+
+.muigui-range input[type=range]::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ appearance: none;
+ width: 0px;
+ height: max-content;
+ box-shadow: -1000px 0 0 1000px var(--range-left-color);
+}
+*/
+
+/* FF */
+/*
+.muigui-range input[type=range]::-moz-slider-progress {
+ background-color: var(--range-left-color);
+}
+.muigui-range input[type=range]::-moz-slider-thumb {
+ height: max-content;
+ width: 0;
+ border: none;
+ box-shadow: -1000px 0 0 1000px var(--range-left-color);
+ box-sizing: border-box;
+}
+*/
+
+.muigui-checkered-background {
+ background-color: #404040;
+ background-image:
+ linear-gradient(45deg, #808080 25%, transparent 25%),
+ linear-gradient(-45deg, #808080 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, #808080 75%),
+ linear-gradient(-45deg, transparent 75%, #808080 75%);
+ background-size: 16px 16px;
+ background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
+}
+
+/* ---------------------------------------------------------- */
+
+/* needs to be at bottom to take precedence */
+.muigui-auto-place {
+ max-height: 100%;
+ position: fixed;
+ top: 0;
+ right: 15px;
+ z-index: 100001;
+}
+
+`,
+themes: {
+ default: '',
+ float: `
+ :root {
+ color-scheme: light dark,
+ }
+
+ .muigui {
+ --width: 400px;
+ --bg-color: initial;
+ --label-width: 25%;
+ --number-width: 20%;
+ }
+
+ input,
+ .muigui-label-controller>label {
+ text-shadow:
+ -1px -1px 0 var(--contrast-color),
+ 1px -1px 0 var(--contrast-color),
+ -1px 1px 0 var(--contrast-color),
+ 1px 1px 0 var(--contrast-color);
+ }
+
+ .muigui-controller > label:nth-child(1) {
+ place-content: center end;
+ margin-right: 1em;
+ }
+
+ .muigui-value > :nth-child(2) {
+ margin-left: 1em;
+ }
+
+ .muigui-root>*:nth-child(1) {
+ display: none;
+ }
+
+ .muigui-range input[type=range]::-webkit-slider-thumb {
+ border-radius: 1em;
+ }
+
+ .muigui-range input[type=range]::-webkit-slider-runnable-track {
+ -webkit-appearance: initial;
+ appearance: none;
+ border: 1px solid rgba(0, 0, 0, 0.25);
+ height: 2px;
+ }
+
+ .muigui-colors {
+ --value-color: var(--color );
+ --value-bg-color: rgba(0, 0, 0, 0.1);
+ --disabled-color: #cccccc;
+ --menu-bg-color: rgba(0, 0, 0, 0.1);
+ --menu-sep-color: #bbbbbb;
+ --hover-bg-color: rgba(0, 0, 0, 0);
+ --invalid-color: #FF0000;
+ --selected-color: rgba(0, 0, 0, 0.3);
+ --range-color: rgba(0, 0, 0, 0.125);
+ }
+`,
+},
+};
+
+function setElemProps(elem, attrs, children) {
+ for (const [key, value] of Object.entries(attrs)) {
+ if (typeof value === 'function' && key.startsWith('on')) {
+ const eventName = key.substring(2).toLowerCase();
+ elem.addEventListener(eventName, value, {passive: false});
+ } else if (typeof value === 'object') {
+ for (const [k, v] of Object.entries(value)) {
+ elem[key][k] = v;
+ }
+ } else if (elem[key] === undefined) {
+ elem.setAttribute(key, value);
+ } else {
+ elem[key] = value;
+ }
+ }
+ for (const child of children) {
+ elem.appendChild(child);
+ }
+ return elem;
+}
+
+function createElem(tag, attrs = {}, children = []) {
+ const elem = document.createElement(tag);
+ setElemProps(elem, attrs, children);
+ return elem;
+}
+
+function addElem(tag, parent, attrs = {}, children = []) {
+ const elem = createElem(tag, attrs, children);
+ parent.appendChild(elem);
+ return elem;
+}
+
+let nextId = 0;
+function getNewId() {
+ return `muigui-id-${nextId++}`;
+}
+
+function removeArrayElem(array, value) {
+ const ndx = array.indexOf(value);
+ if (ndx) {
+ array.splice(ndx, 1);
+ }
+ return array;
+}
+
+/**
+ * Converts an camelCase or snake_case id to "camel case" or "snake case"
+ * @param {string} id
+ */
+const underscoreRE = /_/g;
+const upperLowerRE = /([A-Z])([a-z])/g;
+function idToLabel(id) {
+ return id.replace(underscoreRE, ' ')
+ .replace(upperLowerRE, (m, m1, m2) => `${m1.toLowerCase()} ${m2}`);
+}
+
+function clamp$1(v, min, max) {
+ return Math.max(min, Math.min(max, v));
+}
+
+const isTypedArray = typeof SharedArrayBuffer !== 'undefined'
+ ? function isArrayBufferOrSharedArrayBuffer(a) {
+ return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);
+ }
+ : function isArrayBuffer(a) {
+ return a && a.buffer && a.buffer instanceof ArrayBuffer;
+ };
+
+const isArrayOrTypedArray = v => Array.isArray(v) || isTypedArray(v);
+
+// Yea, I know this should be `Math.round(v / step) * step
+// but try step = 0.1, newV = 19.95
+//
+// I get
+// Math.round(19.95 / 0.1) * 0.1
+// 19.900000000000002
+// vs
+// Math.round(19.95 / 0.1) / (1 / 0.1)
+// 19.9
+//
+const stepify = (v, from, step) => Math.round(from(v) / step) / (1 / step);
+
+const euclideanModulo$1 = (v, n) => ((v % n) + n) % n;
+const lerp$1 = (a, b, t) => a + (b - a) * t;
+function copyExistingProperties(dst, src) {
+ for (const key in src) {
+ if (key in dst) {
+ dst[key] = src[key];
+ }
+ }
+ return dst;
+}
+
+const mapRange = (v, inMin, inMax, outMin, outMax) => (v - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
+
+const makeRangeConverters = ({from, to}) => {
+ return {
+ to: v => mapRange(v, ...from, ...to),
+ from: v => [true, mapRange(v, ...to, ...from)],
+ };
+};
+
+const makeRangeOptions = ({from, to, step}) => {
+ return {
+ min: to[0],
+ max: to[1],
+ ...(step && {step}),
+ converters: makeRangeConverters({from, to}),
+ };
+};
+
+// TODO: remove an use one in conversions. Move makeRangeConverters there?
+const identity$1 = {
+ to: v => v,
+ from: v => [true, v],
+};
+function makeMinMaxPair(gui, properties, minPropName, maxPropName, options) {
+ const { converters: { from } = identity$1 } = options;
+ const { min, max } = options;
+ const guiMinRange = options.minRange || 0;
+ const valueMinRange = from(guiMinRange)[1];
+ const minGui = gui
+ .add(properties, minPropName, {
+ ...options,
+ min,
+ max: max - guiMinRange,
+ })
+ .onChange(v => {
+ maxGui.setValue(Math.min(max, Math.max(v + valueMinRange, properties[maxPropName])));
+ });
+ const maxGui = gui
+ .add(properties, maxPropName, {
+ ...options,
+ min: min + guiMinRange,
+ max,
+ })
+ .onChange(v => {
+ minGui.setValue(Math.max(min, Math.min(v - valueMinRange, properties[minPropName])));
+ });
+ return [ minGui, maxGui ];
+}
+
+class View {
+ domElement;
+ #childDestElem;
+ #views = [];
+ constructor(elem) {
+ this.domElement = elem;
+ this.#childDestElem = elem;
+ }
+ addElem(elem) {
+ this.#childDestElem.appendChild(elem);
+ return elem;
+ }
+ removeElem(elem) {
+ this.#childDestElem.removeChild(elem);
+ return elem;
+ }
+ pushSubElem(elem) {
+ this.#childDestElem.appendChild(elem);
+ this.#childDestElem = elem;
+ }
+ popSubElem() {
+ this.#childDestElem = this.#childDestElem.parentElement;
+ }
+ add(view) {
+ this.#views.push(view);
+ this.addElem(view.domElement);
+ return view;
+ }
+ remove(view) {
+ this.removeElem(view.domElement);
+ removeArrayElem(this.#views, view);
+ return view;
+ }
+ pushSubView(view) {
+ this.pushSubElem(view.domElement);
+ }
+ popSubView() {
+ this.popSubElem();
+ }
+ setOptions(options) {
+ for (const view of this.#views) {
+ view.setOptions(options);
+ }
+ }
+ updateDisplayIfNeeded(newV, ignoreCache) {
+ for (const view of this.#views) {
+ view.updateDisplayIfNeeded(newV, ignoreCache);
+ }
+ return this;
+ }
+ $(selector) {
+ return this.domElement.querySelector(selector);
+ }
+}
+
+class Controller extends View {
+ #changeFns;
+ #finishChangeFns;
+ #parent;
+
+ constructor(className) {
+ super(createElem('div', {className: 'muigui-controller'}));
+ this.#changeFns = [];
+ this.#finishChangeFns = [];
+ // we need the specialization to come last so it takes precedence.
+ if (className) {
+ this.domElement.classList.add(className);
+ }
+ }
+ get parent() {
+ return this.#parent;
+ }
+ setParent(parent) {
+ this.#parent = parent;
+ this.enable(!this.disabled());
+ }
+ show(show = true) {
+ this.domElement.classList.toggle('muigui-hide', !show);
+ this.domElement.classList.toggle('muigui-show', show);
+ return this;
+ }
+ hide() {
+ return this.show(false);
+ }
+ disabled() {
+ return !!this.domElement.closest('.muigui-disabled');
+ }
+
+ enable(enable = true) {
+ this.domElement.classList.toggle('muigui-disabled', !enable);
+
+ // If disabled we need to set the attribute 'disabled=true' to all
+ // input/select/button/textarea's below
+ //
+ // If enabled we need to set the attribute 'disabled=false' to all below
+ // until we hit a disabled controller.
+ //
+ // ATM the problem is we can find the input/select/button/textarea elements
+ // but we can't easily find which controller they belong do.
+ // But we don't need to? We can just check up if it or parent has
+ // '.muigui-disabled'
+ ['input', 'button', 'select', 'textarea'].forEach(tag => {
+ this.domElement.querySelectorAll(tag).forEach(elem => {
+ const disabled = !!elem.closest('.muigui-disabled');
+ elem.disabled = disabled;
+ });
+ });
+
+ return this;
+ }
+ disable(disable = true) {
+ return this.enable(!disable);
+ }
+ onChange(fn) {
+ this.removeChange(fn);
+ this.#changeFns.push(fn);
+ return this;
+ }
+ removeChange(fn) {
+ removeArrayElem(this.#changeFns, fn);
+ return this;
+ }
+ onFinishChange(fn) {
+ this.removeFinishChange(fn);
+ this.#finishChangeFns.push(fn);
+ return this;
+ }
+ removeFinishChange(fn) {
+ removeArrayElem(this.#finishChangeFns, fn);
+ return this;
+ }
+ #callListeners(fns, newV) {
+ for (const fn of fns) {
+ fn.call(this, newV);
+ }
+ }
+ emitChange(value, object, property) {
+ this.#callListeners(this.#changeFns, value);
+ if (this.#parent) {
+ if (object === undefined) {
+ this.#parent.emitChange(value);
+ } else {
+ this.#parent.emitChange({
+ object,
+ property,
+ value,
+ controller: this,
+ });
+ }
+ }
+ }
+ emitFinalChange(value, object, property) {
+ this.#callListeners(this.#finishChangeFns, value);
+ if (this.#parent) {
+ if (object === undefined) {
+ this.#parent.emitChange(value);
+ } else {
+ this.#parent.emitFinalChange({
+ object,
+ property,
+ value,
+ controller: this,
+ });
+ }
+ }
+ }
+ updateDisplay() {
+ // placeholder. override
+ }
+ getColors() {
+ const toCamelCase = s => s.replace(/-([a-z])/g, (m, m1) => m1.toUpperCase());
+ const keys = [
+ 'color',
+ 'bg-color',
+ 'value-color',
+ 'value-bg-color',
+ 'hover-bg-color',
+ 'menu-bg-color',
+ 'menu-sep-color',
+ 'disabled-color',
+ ];
+ const div = createElem('div');
+ this.domElement.appendChild(div);
+ const colors = Object.fromEntries(keys.map(key => {
+ div.style.color = `var(--${key})`;
+ const s = getComputedStyle(div);
+ return [toCamelCase(key), s.color];
+ }));
+ div.remove();
+ return colors;
+ }
+}
+
+class Button extends Controller {
+ #object;
+ #property;
+ #buttonElem;
+ #options = {
+ name: '',
+ };
+
+ constructor(object, property, options = {}) {
+ super('muigui-button', '');
+ this.#object = object;
+ this.#property = property;
+
+ this.#buttonElem = this.addElem(
+ createElem('button', {
+ type: 'button',
+ onClick: () => {
+ this.#object[this.#property](this);
+ },
+ }));
+ this.setOptions({name: property, ...options});
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {name} = this.#options;
+ this.#buttonElem.textContent = name;
+ }
+}
+
+function arraysEqual(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;
+}
+
+function copyArrayElementsFromTo(src, dst) {
+ dst.length = src.length;
+ for (let i = 0; i < src.length; ++i) {
+ dst[i] = src[i];
+ }
+}
+
+class EditView extends View {
+ #oldV;
+ #updateCheck;
+
+ #checkArrayNeedsUpdate(newV) {
+ // It's an array, we need to compare all elements
+ // Example, vec2, [r,g,b], ...
+ const needUpdate = !arraysEqual(newV, this.#oldV);
+ if (needUpdate) {
+ copyArrayElementsFromTo(newV, this.#oldV);
+ }
+ return needUpdate;
+ }
+
+ #checkTypedArrayNeedsUpdate() {
+ let once = true;
+ return function checkTypedArrayNeedsUpdateImpl(newV) {
+ // It's a typedarray, we need to compare all elements
+ // Example: Float32Array([r, g, b])
+ let needUpdate = once;
+ once = false;
+ if (!needUpdate) {
+ needUpdate = !arraysEqual(newV, this.#oldV);
+ }
+ return needUpdate;
+ };
+ }
+
+ #checkObjectNeedsUpdate(newV) {
+ let needUpdate = false;
+ for (const key in newV) {
+ if (newV[key] !== this.#oldV[key]) {
+ needUpdate = true;
+ this.#oldV[key] = newV[key];
+ }
+ }
+ return needUpdate;
+ }
+
+ #checkValueNeedsUpdate(newV) {
+ const needUpdate = newV !== this.#oldV;
+ this.#oldV = newV;
+ return needUpdate;
+ }
+
+ #getUpdateCheckForType(newV) {
+ if (Array.isArray(newV)) {
+ this.#oldV = [];
+ return this.#checkArrayNeedsUpdate.bind(this);
+ } else if (isTypedArray(newV)) {
+ this.#oldV = new newV.constructor(newV);
+ return this.#checkTypedArrayNeedsUpdate(this);
+ } else if (typeof newV === 'object') {
+ this.#oldV = {};
+ return this.#checkObjectNeedsUpdate.bind(this);
+ } else {
+ return this.#checkValueNeedsUpdate.bind(this);
+ }
+ }
+
+ // The point of this is updating DOM elements
+ // is slow but if we've called `listen` then
+ // every frame we're going to try to update
+ // things with the current value so if nothing
+ // has changed then skip it.
+ updateDisplayIfNeeded(newV, ignoreCache) {
+ this.#updateCheck = this.#updateCheck || this.#getUpdateCheckForType(newV);
+ // Note: We call #updateCheck first because it updates
+ // the cache
+ if (this.#updateCheck(newV) || ignoreCache) {
+ this.updateDisplay(newV);
+ }
+ }
+ setOptions(/*options*/) {
+ // override this
+ return this;
+ }
+}
+
+class CheckboxView extends EditView {
+ #checkboxElem;
+ constructor(setter, id) {
+ const checkboxElem = createElem('input', {
+ type: 'checkbox',
+ id,
+ onInput: () => {
+ setter.setValue(checkboxElem.checked);
+ },
+ onChange: () => {
+ setter.setFinalValue(checkboxElem.checked);
+ },
+ });
+ super(createElem('label', {}, [checkboxElem]));
+ this.#checkboxElem = checkboxElem;
+ }
+ updateDisplay(v) {
+ this.#checkboxElem.checked = v;
+ }
+}
+
+const tasks = [];
+const tasksToRemove = new Set();
+
+let requestId;
+let processing;
+
+function removeTasks() {
+ if (!tasksToRemove.size) {
+ return;
+ }
+
+ if (processing) {
+ queueProcessing();
+ return;
+ }
+
+ tasksToRemove.forEach(task => {
+ removeArrayElem(tasks, task);
+ });
+ tasksToRemove.clear();
+}
+
+function processTasks() {
+ requestId = undefined;
+ processing = true;
+ for (const task of tasks) {
+ if (!tasksToRemove.has(task)) {
+ task();
+ }
+ }
+ processing = false;
+ removeTasks();
+ queueProcessing();
+}
+
+function queueProcessing() {
+ if (!requestId && tasks.length) {
+ requestId = requestAnimationFrame(processTasks);
+ }
+}
+
+function addTask(fn) {
+ tasks.push(fn);
+ queueProcessing();
+}
+
+function removeTask(fn) {
+ tasksToRemove.set(fn);
+
+ const ndx = tasks.indexOf(fn);
+ if (ndx >= 0) {
+ tasks.splice(ndx, 1);
+ }
+}
+
+let id = 0;
+
+function makeId() {
+ return `muigui-${++id}`;
+}
+
+class ValueView extends View {
+ constructor(className = '') {
+ super(createElem('div', {className: 'muigui-value'}));
+ if (className) {
+ this.domElement.classList.add(className);
+ }
+ }
+}
+
+class LabelController extends Controller {
+ #id;
+ #nameElem;
+
+ constructor(className = '', name = '') {
+ super('muigui-label-controller');
+ this.#id = makeId();
+ this.#nameElem = createElem('label', {for: this.#id});
+ this.domElement.appendChild(this.#nameElem);
+ this.pushSubView(new ValueView(className));
+ this.name(name);
+ }
+ get id() {
+ return this.#id;
+ }
+ name(name) {
+ if (this.#nameElem.title === this.#nameElem.textContent) {
+ this.#nameElem.title = name;
+ }
+ this.#nameElem.textContent = name;
+ return this;
+ }
+ tooltip(tip) {
+ this.#nameElem.title = tip;
+ }
+}
+
+class ValueController extends LabelController {
+ #object;
+ #property;
+ #initialValue;
+ #listening;
+ #views;
+ #updateFn;
+
+ constructor(object, property, className = '') {
+ super(className, property);
+ this.#object = object;
+ this.#property = property;
+ this.#initialValue = this.getValue();
+ this.#listening = false;
+ this.#views = [];
+ }
+ get initialValue() {
+ return this.#initialValue;
+ }
+ get object() {
+ return this.#object;
+ }
+ get property() {
+ return this.#property;
+ }
+ add(view) {
+ this.#views.push(view);
+ super.add(view);
+ this.updateDisplay();
+ return view;
+ }
+ #setValueImpl(v, ignoreCache) {
+ let isDifferent = false;
+ if (typeof v === 'object') {
+ const dst = this.#object[this.#property];
+ // don't replace objects, just their values.
+ if (Array.isArray(v) || isTypedArray(v)) {
+ for (let i = 0; i < v.length; ++i) {
+ isDifferent ||= dst[i] !== v[i];
+ dst[i] = v[i];
+ }
+ } else {
+ for (const key of Object.keys(v)) {
+ isDifferent ||= dst[key] !== v[key];
+ }
+ Object.assign(dst, v);
+ }
+ } else {
+ isDifferent = this.#object[this.#property] !== v;
+ this.#object[this.#property] = v;
+ }
+ this.updateDisplay(ignoreCache);
+ if (isDifferent) {
+ this.emitChange(this.getValue(), this.#object, this.#property);
+ }
+ return isDifferent;
+ }
+ setValue(v) {
+ this.#setValueImpl(v);
+ }
+ setFinalValue(v) {
+ const isDifferent = this.#setValueImpl(v, true);
+ if (isDifferent) {
+ this.emitFinalChange(this.getValue(), this.#object, this.#property);
+ }
+ return this;
+ }
+ updateDisplay(ignoreCache) {
+ const newV = this.getValue();
+ for (const view of this.#views) {
+ view.updateDisplayIfNeeded(newV, ignoreCache);
+ }
+ return this;
+ }
+ setOptions(options) {
+ for (const view of this.#views) {
+ view.setOptions(options);
+ }
+ this.updateDisplay();
+ return this;
+ }
+ getValue() {
+ return this.#object[this.#property];
+ }
+ value(v) {
+ this.setValue(v);
+ return this;
+ }
+ reset() {
+ this.setValue(this.#initialValue);
+ return this;
+ }
+ listen(listen = true) {
+ if (!this.#updateFn) {
+ this.#updateFn = this.updateDisplay.bind(this);
+ }
+ if (listen) {
+ if (!this.#listening) {
+ this.#listening = true;
+ addTask(this.#updateFn);
+ }
+ } else {
+ if (this.#listening) {
+ this.#listening = false;
+ removeTask(this.#updateFn);
+ }
+ }
+ return this;
+ }
+}
+
+class Checkbox extends ValueController {
+ constructor(object, property) {
+ super(object, property, 'muigui-checkbox');
+ const id = this.id;
+ this.add(new CheckboxView(this, id));
+ this.updateDisplay();
+ }
+}
+
+const identity = {
+ to: v => v,
+ from: v => [true, v],
+};
+
+// from: from string to value
+// to: from value to string
+const strToNumber = {
+ to: v => v.toString(),
+ from: v => {
+ const newV = parseFloat(v);
+ return [!Number.isNaN(newV), newV];
+ },
+};
+
+const converters = {
+ radToDeg: makeRangeConverters({to: [0, 180], from: [0, Math.PI]}),
+};
+
+function createWheelHelper() {
+ let wheelAccum = 0;
+ return function (e, step, wheelScale = 5) {
+ wheelAccum -= e.deltaY * step / wheelScale;
+ const wheelSteps = Math.floor(Math.abs(wheelAccum) / step) * Math.sign(wheelAccum);
+ const delta = wheelSteps * step;
+ wheelAccum -= delta;
+ return delta;
+ };
+}
+
+class NumberView extends EditView {
+ #to;
+ #from;
+ #step;
+ #skipUpdate;
+ #options = {
+ step: 0.01,
+ converters: strToNumber,
+ min: Number.NEGATIVE_INFINITY,
+ max: Number.POSITIVE_INFINITY,
+ };
+
+ constructor(setter, options) {
+ const setValue = setter.setValue.bind(setter);
+ const setFinalValue = setter.setFinalValue.bind(setter);
+ const wheelHelper = createWheelHelper();
+ super(createElem('input', {
+ type: 'number',
+ onInput: () => this.#handleInput(setValue, true),
+ onChange: () => this.#handleInput(setFinalValue, false),
+ onWheel: e => {
+ e.preventDefault();
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ const v = parseFloat(this.domElement.value);
+ const newV = clamp$1(stepify(v + delta, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ this.setOptions(options);
+ }
+ #handleInput(setFn, skipUpdate) {
+ const v = parseFloat(this.domElement.value);
+ const [valid, newV] = this.#from(v);
+ let inRange;
+ if (valid && !Number.isNaN(v)) {
+ const {min, max} = this.#options;
+ inRange = newV >= min && newV <= max;
+ this.#skipUpdate = skipUpdate;
+ setFn(clamp$1(newV, min, max));
+ }
+ this.domElement.classList.toggle('muigui-invalid-value', !valid || !inRange);
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.domElement.value = stepify(v, this.#to, this.#step);
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {
+ step,
+ converters: {to, from},
+ } = this.#options;
+ this.#to = to;
+ this.#from = from;
+ this.#step = step;
+ return this;
+ }
+}
+
+// Wanted to name this `Number` but it conflicts with
+// JavaScript `Number`. It most likely wouldn't be
+// an issue? But users might `import {Number} ...` and
+// things would break.
+class TextNumber extends ValueController {
+ #textView;
+ #step;
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-checkbox');
+ this.#textView = this.add(new NumberView(this, options));
+ this.updateDisplay();
+ }
+}
+
+class SelectView extends EditView {
+ #values;
+
+ constructor(setter, keyValues) {
+ const values = [];
+ super(createElem('select', {
+ onChange: () => {
+ setter.setFinalValue(this.#values[this.domElement.selectedIndex]);
+ },
+ }, keyValues.map(([key, value]) => {
+ values.push(value);
+ return createElem('option', {textContent: key});
+ })));
+ this.#values = values;
+ }
+ updateDisplay(v) {
+ const ndx = this.#values.indexOf(v);
+ this.domElement.selectedIndex = ndx;
+ }
+}
+
+// 4 cases
+// (a) keyValues is array of arrays, each sub array is key value
+// (b) keyValues is array and value is number then keys = array contents, value = index
+// (c) keyValues is array and value is not number, key = array contents, value = array contents
+// (d) keyValues is object then key->value
+function convertToKeyValues(keyValues, valueIsNumber) {
+ if (Array.isArray(keyValues)) {
+ if (Array.isArray(keyValues[0])) {
+ // (a) keyValues is array of arrays, each sub array is key value
+ return keyValues;
+ } else {
+ if (valueIsNumber) {
+ // (b) keyValues is array and value is number then keys = array contents, value = index
+ return keyValues.map((v, ndx) => [v, ndx]);
+ } else {
+ // (c) keyValues is array and value is not number, key = array contents, value = array contents
+ return keyValues.map(v => [v, v]);
+ }
+ }
+ } else {
+ // (d)
+ return [...Object.entries(keyValues)];
+ }
+}
+
+class Select extends ValueController {
+ constructor(object, property, options) {
+ super(object, property, 'muigui-select');
+ const valueIsNumber = typeof this.getValue() === 'number';
+ const {keyValues: keyValuesInput} = options;
+ const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);
+ this.add(new SelectView(this, keyValues));
+ this.updateDisplay();
+ }
+}
+
+class RangeView extends EditView {
+ #to;
+ #from;
+ #step;
+ #skipUpdate;
+ #options = {
+ step: 0.01,
+ min: 0,
+ max: 1,
+ converters: identity,
+ };
+
+ constructor(setter, options) {
+ const wheelHelper = createWheelHelper();
+ super(createElem('input', {
+ type: 'range',
+ onInput: () => {
+ this.#skipUpdate = true;
+ const {min, max, step} = this.#options;
+ const v = parseFloat(this.domElement.value);
+ const newV = clamp$1(stepify(v, v => v, step), min, max);
+ const [valid, validV] = this.#from(newV);
+ if (valid) {
+ setter.setValue(validV);
+ }
+ },
+ onChange: () => {
+ this.#skipUpdate = true;
+ const {min, max, step} = this.#options;
+ const v = parseFloat(this.domElement.value);
+ const newV = clamp$1(stepify(v, v => v, step), min, max);
+ const [valid, validV] = this.#from(newV);
+ if (valid) {
+ setter.setFinalValue(validV);
+ }
+ },
+ onWheel: e => {
+ e.preventDefault();
+ const [valid, v] = this.#from(parseFloat(this.domElement.value));
+ if (!valid) {
+ return;
+ }
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ const newV = clamp$1(stepify(v + delta, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ this.setOptions(options);
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.domElement.value = stepify(v, this.#to, this.#step);
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {
+ step,
+ min,
+ max,
+ converters: {to, from},
+ } = this.#options;
+ this.#to = to;
+ this.#from = from;
+ this.#step = step;
+ this.domElement.step = step;
+ this.domElement.min = min;
+ this.domElement.max = max;
+ return this;
+ }
+}
+
+class Range extends ValueController {
+ constructor(object, property, options) {
+ super(object, property, 'muigui-range');
+ this.add(new RangeView(this, options));
+ this.add(new NumberView(this, options));
+ }
+}
+
+class TextView extends EditView {
+ #to;
+ #from;
+ #skipUpdate;
+ #options = {
+ converters: identity,
+ };
+
+ constructor(setter, options) {
+ const setValue = setter.setValue.bind(setter);
+ const setFinalValue = setter.setFinalValue.bind(setter);
+ super(createElem('input', {
+ type: 'text',
+ onInput: () => this.#handleInput(setValue, true),
+ onChange: () => this.#handleInput(setFinalValue, false),
+ }));
+ this.setOptions(options);
+ }
+ #handleInput(setFn, skipUpdate) {
+ const [valid, newV] = this.#from(this.domElement.value);
+ if (valid) {
+ this.#skipUpdate = skipUpdate;
+ setFn(newV);
+ }
+ this.domElement.style.color = valid ? '' : 'var(--invalid-color)';
+
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.domElement.value = this.#to(v);
+ this.domElement.style.color = '';
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {
+ converters: {to, from},
+ } = this.#options;
+ this.#to = to;
+ this.#from = from;
+ return this;
+ }
+}
+
+class Text extends ValueController {
+ constructor(object, property) {
+ super(object, property, 'muigui-checkbox');
+ this.add(new TextView(this));
+ this.updateDisplay();
+ }
+}
+
+// const isConversion = o => typeof o.to === 'function' && typeof o.from === 'function';
+
+/**
+ * possible inputs
+ * add(o, p, min: number, max: number)
+ * add(o, p, min: number, max: number, step: number)
+ * add(o, p, array: [value])
+ * add(o, p, array: [[key, value]])
+ *
+ * @param {*} object
+ * @param {string} property
+ * @param {...any} args
+ * @returns {Controller}
+ */
+function createController(object, property, ...args) {
+ const [arg1] = args;
+ if (Array.isArray(arg1)) {
+ return new Select(object, property, {keyValues: arg1});
+ }
+
+ const t = typeof object[property];
+ switch (t) {
+ case 'number':
+ if (typeof args[0] === 'number' && typeof args[1] === 'number') {
+ const min = args[0];
+ const max = args[1];
+ const step = args[2];
+ return new Range(object, property, {min, max, ...(step && {step})});
+ }
+ return args.length === 0
+ ? new TextNumber(object, property, ...args)
+ : new Range(object, property, ...args);
+ case 'boolean':
+ return new Checkbox(object, property, ...args);
+ case 'function':
+ return new Button(object, property, ...args);
+ case 'string':
+ return new Text(object, property, ...args);
+ case 'undefined':
+ throw new Error(`no property named ${property}`);
+ default:
+ throw new Error(`unhandled type ${t} for property ${property}`);
+ }
+}
+
+const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
+const lerp = (a, b, t) => a + (b - a) * t;
+const fract = v => v >= 0 ? v % 1 : 1 - (v % 1);
+
+const f0 = v => +v.toFixed(0); // converts to string (eg 1.2 => "1"), then converts back to number (eg, "1.200" => 1.2)
+const f3 = v => +v.toFixed(3); // converts to string (eg 1.2 => "1.200"), then converts back to number (eg, "1.200" => 1.2)
+
+const hexToUint32RGB = v => (parseInt(v.substring(1, 3), 16) << 16) |
+ (parseInt(v.substring(3, 5), 16) << 8 ) |
+ (parseInt(v.substring(5, 7), 16) );
+const uint32RGBToHex = v => `#${(Math.round(v)).toString(16).padStart(6, '0')}`;
+const hexToUint32RGBA = v => (parseInt(v.substring(1, 3), 16) * 2 ** 24) +
+ (parseInt(v.substring(3, 5), 16) * 2 ** 16) +
+ (parseInt(v.substring(5, 7), 16) * 2 ** 8) +
+ (parseInt(v.substring(7, 9), 16) );
+const uint32RGBAToHex = v => `#${(Math.round(v)).toString(16).padStart(8, '0')}`;
+
+const hexToUint8RGB = v => [
+ parseInt(v.substring(1, 3), 16),
+ parseInt(v.substring(3, 5), 16),
+ parseInt(v.substring(5, 7), 16),
+];
+const uint8RGBToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;
+
+const hexToUint8RGBA = v => [
+ parseInt(v.substring(1, 3), 16),
+ parseInt(v.substring(3, 5), 16),
+ parseInt(v.substring(5, 7), 16),
+ parseInt(v.substring(7, 9), 16),
+];
+const uint8RGBAToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;
+
+const hexToFloatRGB = v => hexToUint8RGB(v).map(v => f3(v / 255));
+const floatRGBToHex = v => uint8RGBToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));
+
+const hexToFloatRGBA = v => hexToUint8RGBA(v).map(v => f3(v / 255));
+const floatRGBAToHex = v => uint8RGBAToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));
+
+const scaleAndClamp = v => clamp(Math.round(v * 255), 0, 255).toString(16).padStart(2, '0');
+
+const hexToObjectRGB = v => ({
+ r: parseInt(v.substring(1, 3), 16) / 255,
+ g: parseInt(v.substring(3, 5), 16) / 255,
+ b: parseInt(v.substring(5, 7), 16) / 255,
+});
+const objectRGBToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}`;
+const hexToObjectRGBA = v => ({
+ r: parseInt(v.substring(1, 3), 16) / 255,
+ g: parseInt(v.substring(3, 5), 16) / 255,
+ b: parseInt(v.substring(5, 7), 16) / 255,
+ a: parseInt(v.substring(7, 9), 16) / 255,
+});
+const objectRGBAToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}${scaleAndClamp(v.a)}`;
+
+const hexToCssRGB = v => `rgb(${hexToUint8RGB(v).join(', ')})`;
+const cssRGBRegex = /^\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/;
+const cssRGBToHex = v => {
+ const m = cssRGBRegex.exec(v);
+ return uint8RGBToHex([m[1], m[2], m[3]].map(v => parseInt(v)));
+};
+const hexToCssRGBA = v => `rgba(${hexToUint8RGBA(v).map((v, i) => i === 3 ? v / 255 : v).join(', ')})`;
+const cssRGBARegex = /^\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+\.\d+|\d+)\s*\)\s*$/;
+const cssRGBAToHex = v => {
+ const m = cssRGBARegex.exec(v);
+ return uint8RGBAToHex([m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? (parseFloat(v) * 255 | 0) : parseInt(v)));
+};
+
+const hexToCssHSL = v => {
+ const hsl = rgbUint8ToHsl(hexToUint8RGB(v)).map(v => f0(v));
+ return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`;
+};
+const hexToCssHSLA = v => {
+ const hsla = rgbaUint8ToHsla(hexToUint8RGBA(v)).map((v, i) => i === 3 ? f3(v) : f0(v));
+ return `hsl(${hsla[0]} ${hsla[1]}% ${hsla[2]}% / ${hsla[3]})`;
+};
+const cssHSLRegex = /^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\)\s*$/;
+const cssHSLARegex = /^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\/\s*(\d+\.\d+|\d+)\s*\)\s*$/;
+
+const hex3DigitTo6Digit = v => `${v[0]}${v[0]}${v[1]}${v[1]}${v[2]}${v[2]}`;
+const cssHSLToHex = v => {
+ const m = cssHSLRegex.exec(v);
+ const rgb = hslToRgbUint8([m[1], m[2], m[3]].map(v => parseFloat(v)));
+ return uint8RGBToHex(rgb);
+};
+const cssHSLAToHex = v => {
+ const m = cssHSLARegex.exec(v);
+ const rgba = hslaToRgbaUint8([m[1], m[2], m[3], m[4]].map(v => parseFloat(v)));
+ return uint8RGBAToHex(rgba);
+};
+
+const euclideanModulo = (v, n) => ((v % n) + n) % n;
+
+function hslToRgbUint8([h, s, l]) {
+ h = euclideanModulo(h, 360);
+ s = clamp(s / 100, 0, 1);
+ l = clamp(l / 100, 0, 1);
+
+ const a = s * Math.min(l, 1 - l);
+
+ function f(n) {
+ const k = (n + h / 30) % 12;
+ return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
+ }
+
+ return [f(0), f(8), f(4)].map(v => Math.round(v * 255));
+}
+
+function hslaToRgbaUint8([h, s, l, a]) {
+ const rgb = hslToRgbUint8([h, s, l]);
+ return [...rgb, a * 255 | 0];
+}
+
+function rgbFloatToHsl01([r, g, b]) {
+ const max = Math.max(r, g, b);
+ const min = Math.min(r, g, b);
+ const l = (min + max) * 0.5;
+ const d = max - min;
+ let h = 0;
+ let s = 0;
+
+ if (d !== 0) {
+ s = (l === 0 || l === 1)
+ ? 0
+ : (max - l) / Math.min(l, 1 - l);
+
+ switch (max) {
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
+ case g: h = (b - r) / d + 2; break;
+ case b: h = (r - g) / d + 4;
+ }
+ }
+
+ return [h / 6, s, l];
+}
+
+function rgbaFloatToHsla01([r, g, b, a]) {
+ const hsl = rgbFloatToHsl01([r, g, b]);
+ return [...hsl, a];
+}
+
+const rgbUint8ToHsl = (rgb) => {
+ const [h, s, l] = rgbFloatToHsl01(rgb.map(v => v / 255));
+ return [h * 360, s * 100, l * 100];
+};
+
+const rgbaUint8ToHsla = (rgba) => {
+ const [h, s, l, a] = rgbaFloatToHsla01(rgba.map(v => v / 255));
+ return [h * 360, s * 100, l * 100, a];
+};
+
+function hsv01ToRGBFloat([hue, sat, val]) {
+ sat = clamp(sat, 0, 1);
+ val = clamp(val, 0, 1);
+ return [hue, hue + 2 / 3, hue + 1 / 3].map(
+ v => lerp(1, clamp(Math.abs(fract(v) * 6 - 3.0) - 1, 0, 1), sat) * val
+ );
+}
+
+function hsva01ToRGBAFloat([hue, sat, val, alpha]) {
+ const rgb = hsv01ToRGBFloat([hue, sat, val]);
+ return [...rgb, alpha];
+}
+
+const round3 = v => Math.round(v * 1000) / 1000;
+
+function rgbFloatToHSV01([r, g, b]) {
+ const p = b > g
+ ? [b, g, -1, 2 / 3]
+ : [g, b, 0, -1 / 3];
+ const q = p[0] > r
+ ? [p[0], p[1], p[3], r]
+ : [r, p[1], p[2], p[0]];
+ const d = q[0] - Math.min(q[3], q[1]);
+ return [
+ Math.abs(q[2] + (q[3] - q[1]) / (6 * d + Number.EPSILON)),
+ d / (q[0] + Number.EPSILON),
+ q[0],
+ ].map(round3);
+}
+
+function rgbaFloatToHSVA01([r, g, b, a]) {
+ const hsv = rgbFloatToHSV01([r, g, b]);
+ return [...hsv, a];
+}
+
+// window.hsv01ToRGBFloat = hsv01ToRGBFloat;
+// window.rgbFloatToHSV01 = rgbFloatToHSV01;
+
+// Yea, meh!
+const hasAlpha = format => format.endsWith('a') || format.startsWith('hex8');
+
+const cssStringFormats = [
+ { re: /^#(?:[0-9a-f]){6}$/i, format: 'hex6' },
+ { re: /^(?:[0-9a-f]){6}$/i, format: 'hex6-no-hash' },
+ { re: /^#(?:[0-9a-f]){8}$/i, format: 'hex8' },
+ { re: /^(?:[0-9a-f]){8}$/i, format: 'hex8-no-hash' },
+ { re: /^#(?:[0-9a-f]){3}$/i, format: 'hex3' },
+ { re: /^(?:[0-9a-f]){3}$/i, format: 'hex3-no-hash' },
+ { re: cssRGBRegex, format: 'css-rgb' },
+ { re: cssHSLRegex, format: 'css-hsl' },
+ { re: cssRGBARegex, format: 'css-rgba' },
+ { re: cssHSLARegex, format: 'css-hsla' },
+];
+
+function guessStringColorFormat(v) {
+ for (const formatInfo of cssStringFormats) {
+ if (formatInfo.re.test(v)) {
+ return formatInfo;
+ }
+ }
+ return undefined;
+}
+
+function guessFormat(v) {
+ switch (typeof v) {
+ case 'number':
+ console.warn('can not reliably guess format based on a number. You should pass in a format like {format: "uint32-rgb"} or {format: "uint32-rgb"}');
+ return v <= 0xFFFFFF ? 'uint32-rgb' : 'uint32-rgba';
+ case 'string': {
+ const formatInfo = guessStringColorFormat(v.trim());
+ if (formatInfo) {
+ return formatInfo.format;
+ }
+ break;
+ }
+ case 'object':
+ if (v instanceof Uint8Array || v instanceof Uint8ClampedArray) {
+ if (v.length === 3) {
+ return 'uint8-rgb';
+ } else if (v.length === 4) {
+ return 'uint8-rgba';
+ }
+ } else if (v instanceof Float32Array) {
+ if (v.length === 3) {
+ return 'float-rgb';
+ } else if (v.length === 4) {
+ return 'float-rgba';
+ }
+ } else if (Array.isArray(v)) {
+ if (v.length === 3) {
+ return 'float-rgb';
+ } else if (v.length === 4) {
+ return 'float-rgba';
+ }
+ } else {
+ if ('r' in v && 'g' in v && 'b' in v) {
+ if ('a' in v) {
+ return 'object-rgba';
+ } else {
+ return 'object-rgb';
+ }
+ }
+ }
+ }
+ throw new Error(`unknown color format: ${v}`);
+}
+
+function fixHex6(v) {
+ return v.trim(v);
+ //const formatInfo = guessStringColorFormat(v.trim());
+ //const fix = formatInfo ? formatInfo.fix : v => v;
+ //return fix(v.trim());
+}
+
+function fixHex8(v) {
+ return v.trim(v);
+ //const formatInfo = guessStringColorFormat(v.trim());
+ //const fix = formatInfo ? formatInfo.fix : v => v;
+ //return fix(v.trim());
+}
+
+function hex6ToHex3(hex6) {
+ return (hex6[1] === hex6[2] &&
+ hex6[3] === hex6[4] &&
+ hex6[5] === hex6[6])
+ ? `#${hex6[1]}${hex6[3]}${hex6[5]}`
+ : hex6;
+}
+
+const hex3RE = /^(#|)([0-9a-f]{3})$/i;
+function hex3ToHex6(hex3) {
+ const m = hex3RE.exec(hex3);
+ if (m) {
+ const [, , m2] = m;
+ return `#${hex3DigitTo6Digit(m2)}`;
+ }
+ return hex3;
+}
+
+function fixHex3(v) {
+ return hex6ToHex3(fixHex6(v));
+}
+
+const strToRGBObject = (s) => {
+ try {
+ const json = s.replace(/([a-z])/g, '"$1"');
+ const rgb = JSON.parse(json);
+ if (Number.isNaN(rgb.r) || Number.isNaN(rgb.g) || Number.isNaN(rgb.b)) {
+ throw new Error('not {r, g, b}');
+ }
+ return [true, rgb];
+ } catch (e) {
+ return [false];
+ }
+};
+
+const strToRGBAObject = (s) => {
+ try {
+ const json = s.replace(/([a-z])/g, '"$1"');
+ const rgba = JSON.parse(json);
+ if (Number.isNaN(rgba.r) || Number.isNaN(rgba.g) || Number.isNaN(rgba.b) || Number.isNaN(rgba.a)) {
+ throw new Error('not {r, g, b, a}');
+ }
+ return [true, rgba];
+ } catch (e) {
+ return [false];
+ }
+};
+
+const strToCssRGB = s => {
+ const m = cssRGBRegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3]].map(v => parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, `rgb(${v.join(', ')})`];
+};
+
+const strToCssRGBA = s => {
+ const m = cssRGBARegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? parseFloat(v) : parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, `rgba(${v.join(', ')})`];
+};
+
+const strToCssHSL = s => {
+ const m = cssHSLRegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3]].map(v => parseFloat(v));
+ const outOfRange = v.find(v => Number.isNaN(v));
+ return [!outOfRange, `hsl(${v[0]}, ${v[1]}%, ${v[2]}%)`];
+};
+
+const strToCssHSLA = s => {
+ const m = cssHSLARegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3], m[4]].map(v => parseFloat(v));
+ const outOfRange = v.find(v => Number.isNaN(v));
+ return [!outOfRange, `hsl(${v[0]} ${v[1]}% ${v[2]}% / ${v[3]})`];
+};
+
+const rgbObjectToStr = rgb => {
+ return `{r:${f3(rgb.r)}, g:${f3(rgb.g)}, b:${f3(rgb.b)}}`;
+};
+const rgbaObjectToStr = rgba => {
+ return `{r:${f3(rgba.r)}, g:${f3(rgba.g)}, b:${f3(rgba.b)}}, a:${f3(rgba.a)}}`;
+};
+
+const strTo3IntsRE = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/;
+const strTo3Ints = s => {
+ const m = strTo3IntsRE.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3]].map(v => parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, v];
+};
+
+const strTo4IntsRE = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/;
+const strTo4Ints = s => {
+ const m = strTo4IntsRE.exec(s);
+ if (!m) {
+ return [false];
+ }
+ const v = [m[1], m[2], m[3], m[4]].map(v => parseInt(v));
+ const outOfRange = v.find(v => v > 255);
+ return [!outOfRange, v];
+};
+
+const strTo3Floats = s => {
+ const numbers = s.split(',').map(s => s.trim());
+ const v = numbers.map(v => parseFloat(v));
+ if (v.length !== 3) {
+ return [false];
+ }
+ // Note: using isNaN not Number.isNaN
+ const badNdx = numbers.findIndex(v => isNaN(v));
+ return [badNdx < 0, v.map(v => f3(v))];
+};
+
+const strTo4Floats = s => {
+ const numbers = s.split(',').map(s => s.trim());
+ const v = numbers.map(v => parseFloat(v));
+ if (v.length !== 4) {
+ return [false];
+ }
+ // Note: using isNaN not Number.isNaN
+ const badNdx = numbers.findIndex(v => isNaN(v));
+ return [badNdx < 0, v.map(v => f3(v))];
+};
+
+const strToUint32RGBRegex = /^\s*(?:0x){0,1}([0-9a-z]{1,6})\s*$/i;
+const strToUint32RGB = s => {
+ const m = strToUint32RGBRegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ return [true, parseInt(m[1], 16)];
+};
+
+const strToUint32RGBARegex = /^\s*(?:0x){0,1}([0-9a-z]{1,8})\s*$/i;
+const strToUint32RGBA = s => {
+ const m = strToUint32RGBARegex.exec(s);
+ if (!m) {
+ return [false];
+ }
+ return [true, parseInt(m[1], 16)];
+};
+
+const hex6RE = /^\s*#[a-f0-9]{6}\s*$|^\s*#[a-f0-9]{3}\s*$/i;
+const hexNoHash6RE = /^\s*[a-f0-9]{6}\s*$/i;
+const hex8RE = /^\s*#[a-f0-9]{8}\s*$/i;
+const hexNoHash8RE = /^\s*[a-f0-9]{8}\s*$/i;
+
+// For each format converter
+//
+// fromHex/toHex convert from/to '#RRGGBB'
+//
+// fromHex converts from the string '#RRBBGG' to the format
+// (eg: for uint32-rgb, '#123456' becomes 0x123456)
+//
+// toHex converts from the format to '#RRGGBB'
+// (eg: for uint8-rgb, [16, 33, 50] becomes '#102132')
+//
+//
+// fromStr/toStr convert from/to what's in the input[type=text] element
+//
+// toStr converts from the format to its string representation
+// (eg, for object-rgb, {r: 1, g: 0.5, b:0} becomes "{r: 1, g: 0.5, b:0}")
+// ^object ^string
+//
+// fromStr converts its string representation to its format
+// (eg, for object-rgb) "{r: 1, g: 0.5, b:0}" becomes {r: 1, g: 0.5, b:0})
+// ^string ^object
+// fromString returns an array which is [valid, v]
+// where valid is true if the string was a valid and v is the converted
+// format if v is true.
+//
+// Note: toStr should convert to "ideal" form (whatever that is).
+// (eg, for css-rgb
+// "{ r: 0.10000, g: 001, b: 0}" becomes "{r: 0.1, g: 1, b: 0}"
+// notice that css-rgb is a string to a string
+// )
+const colorFormatConverters = {
+ 'hex6': {
+ color: {
+ from: v => [true, v],
+ to: fixHex6,
+ },
+ text: {
+ from: v => [hex6RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex8': {
+ color: {
+ from: v => [true, v],
+ to: fixHex8,
+ },
+ text: {
+ from: v => [hex8RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex3': {
+ color: {
+ from: v => [true, fixHex3(v)],
+ to: hex3ToHex6,
+ },
+ text: {
+ from: v => [hex6RE.test(v), hex6ToHex3(v.trim())],
+ to: v => v,
+ },
+ },
+ 'hex6-no-hash': {
+ color: {
+ from: v => [true, v.substring(1)],
+ to: v => `#${fixHex6(v)}`,
+ },
+ text: {
+ from: v => [hexNoHash6RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex8-no-hash': {
+ color: {
+ from: v => [true, v.substring(1)],
+ to: v => `#${fixHex8(v)}`,
+ },
+ text: {
+ from: v => [hexNoHash8RE.test(v), v.trim()],
+ to: v => v,
+ },
+ },
+ 'hex3-no-hash': {
+ color: {
+ from: v => [true, fixHex3(v).substring(1)],
+ to: hex3ToHex6,
+ },
+ text: {
+ from: v => [hexNoHash6RE.test(v), hex6ToHex3(v.trim())],
+ to: v => v,
+ },
+ },
+ 'uint32-rgb': {
+ color: {
+ from: v => [true, hexToUint32RGB(v)],
+ to: uint32RGBToHex,
+ },
+ text: {
+ from: v => strToUint32RGB(v),
+ to: v => `0x${v.toString(16).padStart(6, '0')}`,
+ },
+ },
+ 'uint32-rgba': {
+ color: {
+ from: v => [true, hexToUint32RGBA(v)],
+ to: uint32RGBAToHex,
+ },
+ text: {
+ from: v => strToUint32RGBA(v),
+ to: v => `0x${v.toString(16).padStart(8, '0')}`,
+ },
+ },
+ 'uint8-rgb': {
+ color: {
+ from: v => [true, hexToUint8RGB(v)],
+ to: uint8RGBToHex,
+ },
+ text: {
+ from: strTo3Ints,
+ to: v => v.join(', '),
+ },
+ },
+ 'uint8-rgba': {
+ color: {
+ from: v => [true, hexToUint8RGBA(v)],
+ to: uint8RGBAToHex,
+ },
+ text: {
+ from: strTo4Ints,
+ to: v => v.join(', '),
+ },
+ },
+ 'float-rgb': {
+ color: {
+ from: v => [true, hexToFloatRGB(v)],
+ to: floatRGBToHex,
+ },
+ text: {
+ from: strTo3Floats,
+ // need Array.from because map of Float32Array makes a Float32Array
+ to: v => Array.from(v).map(v => f3(v)).join(', '),
+ },
+ },
+ 'float-rgba': {
+ color: {
+ from: v => [true, hexToFloatRGBA(v)],
+ to: floatRGBAToHex,
+ },
+ text: {
+ from: strTo4Floats,
+ // need Array.from because map of Float32Array makes a Float32Array
+ to: v => Array.from(v).map(v => f3(v)).join(', '),
+ },
+ },
+ 'object-rgb': {
+ color: {
+ from: v => [true, hexToObjectRGB(v)],
+ to: objectRGBToHex,
+ },
+ text: {
+ from: strToRGBObject,
+ to: rgbObjectToStr,
+ },
+ },
+ 'object-rgba': {
+ color: {
+ from: v => [true, hexToObjectRGBA(v)],
+ to: objectRGBAToHex,
+ },
+ text: {
+ from: strToRGBAObject,
+ to: rgbaObjectToStr,
+ },
+ },
+ 'css-rgb': {
+ color: {
+ from: v => [true, hexToCssRGB(v)],
+ to: cssRGBToHex,
+ },
+ text: {
+ from: strToCssRGB,
+ to: v => strToCssRGB(v)[1],
+ },
+ },
+ 'css-rgba': {
+ color: {
+ from: v => [true, hexToCssRGBA(v)],
+ to: cssRGBAToHex,
+ },
+ text: {
+ from: strToCssRGBA,
+ to: v => strToCssRGBA(v)[1],
+ },
+ },
+ 'css-hsl': {
+ color: {
+ from: v => [true, hexToCssHSL(v)],
+ to: cssHSLToHex,
+ },
+ text: {
+ from: strToCssHSL,
+ to: v => strToCssHSL(v)[1],
+ },
+ },
+ 'css-hsla': {
+ color: {
+ from: v => [true, hexToCssHSLA(v)],
+ to: cssHSLAToHex,
+ },
+ text: {
+ from: strToCssHSLA,
+ to: v => strToCssHSLA(v)[1],
+ },
+ },
+};
+
+class ElementView extends View {
+ constructor(tag, className) {
+ super(createElem(tag, {className}));
+ }
+}
+
+// TODO: remove this? Should just be user side
+class Canvas extends LabelController {
+ #canvasElem;
+
+ constructor() {
+ super('muigui-canvas');
+ this.#canvasElem = this.add(
+ new ElementView('canvas', 'muigui-canvas'),
+ ).domElement;
+ }
+ get canvas() {
+ return this.#canvasElem;
+ }
+}
+
+class ColorView extends EditView {
+ #to;
+ #from;
+ #colorElem;
+ #skipUpdate;
+ #options = {
+ converters: identity,
+ };
+
+ constructor(setter, options) {
+ const colorElem = createElem('input', {
+ type: 'color',
+ onInput: () => {
+ const [valid, newV] = this.#from(colorElem.value);
+ if (valid) {
+ this.#skipUpdate = true;
+ setter.setValue(newV);
+ }
+ },
+ onChange: () => {
+ const [valid, newV] = this.#from(colorElem.value);
+ if (valid) {
+ this.#skipUpdate = true;
+ setter.setFinalValue(newV);
+ }
+ },
+ });
+ super(createElem('div', {}, [colorElem]));
+ this.setOptions(options);
+ this.#colorElem = colorElem;
+ }
+ updateDisplay(v) {
+ if (!this.#skipUpdate) {
+ this.#colorElem.value = this.#to(v);
+ }
+ this.#skipUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {converters: {to, from}} = this.#options;
+ this.#to = to;
+ this.#from = from;
+ return this;
+ }
+}
+
+class Color extends ValueController {
+ #colorView;
+ #textView;
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-color');
+ const format = options.format || guessFormat(this.getValue());
+ const {color, text} = colorFormatConverters[format];
+ this.#colorView = this.add(new ColorView(this, {converters: color}));
+ this.#textView = this.add(new TextView(this, {converters: text}));
+ this.updateDisplay();
+ }
+ setOptions(options) {
+ const {format} = options;
+ if (format) {
+ const {color, text} = colorFormatConverters[format];
+ this.#colorView.setOptions({converters: color});
+ this.#textView.setOptions({converters: text});
+ }
+ super.setOptions(options);
+ return this;
+ }
+}
+
+// This feels like it should be something else like
+// gui.addController({className: 'muigui-divider')};
+class Divider extends Controller {
+ constructor() {
+ super('muigui-divider');
+ }
+}
+
+class Container extends Controller {
+ #controllers;
+ #childDestController;
+
+ constructor(className) {
+ super(className);
+ this.#controllers = [];
+ this.#childDestController = this;
+ }
+ get children() {
+ return this.#controllers; // should we return a copy?
+ }
+ get controllers() {
+ return this.#controllers.filter(c => !(c instanceof Container));
+ }
+ get folders() {
+ return this.#controllers.filter(c => c instanceof Container);
+ }
+ reset(recursive = true) {
+ for (const controller of this.#controllers) {
+ if (!(controller instanceof Container) || recursive) {
+ controller.reset(recursive);
+ }
+ }
+ return this;
+ }
+ updateDisplay() {
+ for (const controller of this.#controllers) {
+ controller.updateDisplay();
+ }
+ return this;
+ }
+ remove(controller) {
+ const ndx = this.#controllers.indexOf(controller);
+ if (ndx >= 0) {
+ const c = this.#controllers.splice(ndx, 1);
+ const c0 = c[0];
+ const elem = c0.domElement;
+ elem.remove();
+ c0.setParent(null);
+ }
+ return this;
+ }
+ #addControllerImpl(controller) {
+ this.domElement.appendChild(controller.domElement);
+ this.#controllers.push(controller);
+ controller.setParent(this);
+ return controller;
+ }
+ addController(controller) {
+ return this.#childDestController.#addControllerImpl(controller);
+ }
+ pushContainer(container) {
+ this.addController(container);
+ this.#childDestController = container;
+ return container;
+ }
+ popContainer() {
+ this.#childDestController = this.#childDestController.parent;
+ return this;
+ }
+}
+
+class Folder extends Container {
+ #labelElem;
+
+ constructor(name = 'Controls', className = 'muigui-menu') {
+ super(className);
+ this.#labelElem = createElem('label');
+ this.addElem(createElem('button', {
+ type: 'button',
+ onClick: () => this.toggleOpen(),
+ }, [this.#labelElem]));
+ this.pushContainer(new Container());
+ this.name(name);
+ this.open();
+ }
+ open(open = true) {
+ this.domElement.classList.toggle('muigui-closed', !open);
+ this.domElement.classList.toggle('muigui-open', open);
+ return this;
+ }
+ close() {
+ return this.open(false);
+ }
+ name(name) {
+ this.#labelElem.textContent = name;
+ return this;
+ }
+ title(title) {
+ return this.name(title);
+ }
+ toggleOpen() {
+ this.open(!this.domElement.classList.contains('muigui-open'));
+ return this;
+ }
+}
+
+// This feels like it should be something else like
+// gui.addDividing = new Controller()
+class Label extends Controller {
+ constructor(text) {
+ super('muigui-label');
+ this.text(text);
+ }
+ text(text) {
+ this.domElement.textContent = text;
+ return this;
+ }
+}
+
+function noop$1() {
+}
+
+function computeRelativePosition(elem, event, start) {
+ const rect = elem.getBoundingClientRect();
+ const x = event.clientX - rect.left;
+ const y = event.clientY - rect.top;
+ const nx = x / rect.width;
+ const ny = y / rect.height;
+ start = start || [x, y];
+ const dx = x - start[0];
+ const dy = y - start[1];
+ const ndx = dx / rect.width;
+ const ndy = dy / rect.width;
+ return {x, y, nx, ny, dx, dy, ndx, ndy};
+}
+
+function addTouchEvents(elem, {onDown = noop$1, onMove = noop$1, onUp = noop$1}) {
+ let start;
+ const pointerMove = function (event) {
+ const e = {
+ type: 'move',
+ ...computeRelativePosition(elem, event, start),
+ };
+ onMove(e);
+ };
+
+ const pointerUp = function (event) {
+ elem.releasePointerCapture(event.pointerId);
+ elem.removeEventListener('pointermove', pointerMove);
+ elem.removeEventListener('pointerup', pointerUp);
+
+ document.body.style.backgroundColor = '';
+
+ onUp('up');
+ };
+
+ const pointerDown = function (event) {
+ elem.addEventListener('pointermove', pointerMove);
+ elem.addEventListener('pointerup', pointerUp);
+ elem.setPointerCapture(event.pointerId);
+
+ const rel = computeRelativePosition(elem, event);
+ start = [rel.x, rel.y];
+ onDown({
+ type: 'down',
+ ...rel,
+ });
+ };
+
+ elem.addEventListener('pointerdown', pointerDown);
+
+ return function () {
+ elem.removeEventListener('pointerdown', pointerDown);
+ };
+}
+
+const svg$3 = `
+
+
+
+`;
+
+function connectFillTargets(elem) {
+ elem.querySelectorAll('[data-src]').forEach(srcElem => {
+ const id = getNewId();
+ srcElem.id = id;
+ elem.querySelectorAll(`[data-target=${srcElem.dataset.src}]`).forEach(targetElem => {
+ targetElem.setAttribute('fill', `url(#${id})`);
+ });
+ });
+ return elem;
+}
+
+// Was originally going to make alpha an option. Issue is
+// hard coded conversions?
+class ColorChooserView extends EditView {
+ #to;
+ #from;
+ #satLevelElem;
+ #circleElem;
+ #hueUIElem;
+ #hueElem;
+ #hueCursorElem;
+ #alphaUIElem;
+ #alphaElem;
+ #alphaCursorElem;
+ #hsva;
+ #skipHueUpdate;
+ #skipSatLevelUpdate;
+ #skipAlphaUpdate;
+ #options = {
+ converters: identity,
+ alpha: false,
+ };
+ #convertInternalToHex;
+ #convertHexToInternal;
+
+ constructor(setter, options) {
+ super(createElem('div', {
+ innerHTML: svg$3,
+ className: 'muigui-no-scroll',
+ }));
+ this.#satLevelElem = this.domElement.children[0];
+ this.#hueUIElem = this.domElement.children[1];
+ this.#alphaUIElem = this.domElement.children[2];
+ connectFillTargets(this.#satLevelElem);
+ connectFillTargets(this.#hueUIElem);
+ connectFillTargets(this.#alphaUIElem);
+ this.#circleElem = this.$('.muigui-color-chooser-circle');
+ this.#hueElem = this.$('[data-src=muigui-color-chooser-hue]');
+ this.#hueCursorElem = this.$('.muigui-color-chooser-hue-cursor');
+ this.#alphaElem = this.$('[data-src=muigui-color-chooser-alpha]');
+ this.#alphaCursorElem = this.$('.muigui-color-chooser-alpha-cursor');
+
+ const handleSatLevelChange = (e) => {
+ const s = clamp$1(e.nx, 0, 1);
+ const v = clamp$1(e.ny, 0, 1);
+ this.#hsva[1] = s;
+ this.#hsva[2] = (1 - v);
+ this.#skipHueUpdate = true;
+ this.#skipAlphaUpdate = true;
+ const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));
+ if (valid) {
+ setter.setValue(newV);
+ }
+ };
+
+ const handleHueChange = (e) => {
+ const h = clamp$1(e.nx, 0, 1);
+ this.#hsva[0] = h;
+ this.#skipSatLevelUpdate = true;
+ this.#skipAlphaUpdate = true;
+ const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));
+ if (valid) {
+ setter.setValue(newV);
+ }
+ };
+
+ const handleAlphaChange = (e) => {
+ const a = clamp$1(e.nx, 0, 1);
+ this.#hsva[3] = a;
+ this.#skipHueUpdate = true;
+ this.#skipSatLevelUpdate = true;
+ const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));
+ if (valid) {
+ setter.setValue(newV);
+ }
+ };
+
+ addTouchEvents(this.#satLevelElem, {
+ onDown: handleSatLevelChange,
+ onMove: handleSatLevelChange,
+ });
+ addTouchEvents(this.#hueUIElem, {
+ onDown: handleHueChange,
+ onMove: handleHueChange,
+ });
+ addTouchEvents(this.#alphaUIElem, {
+ onDown: handleAlphaChange,
+ onMove: handleAlphaChange,
+ });
+ this.setOptions(options);
+ }
+ updateDisplay(newV) {
+ if (!this.#hsva) {
+ this.#hsva = this.#convertHexToInternal(this.#to(newV));
+ }
+ {
+ const [h, s, v, a = 1] = this.#convertHexToInternal(this.#to(newV));
+ // Don't copy the hue if it was un-computable.
+ if (!this.#skipHueUpdate) {
+ this.#hsva[0] = s > 0.001 && v > 0.001 ? h : this.#hsva[0];
+ }
+ if (!this.#skipSatLevelUpdate) {
+ this.#hsva[1] = s;
+ this.#hsva[2] = v;
+ }
+ if (!this.#skipAlphaUpdate) {
+ this.#hsva[3] = a;
+ }
+ }
+ {
+ const [h, s, v, a] = this.#hsva;
+ const [hue, sat, lum] = rgbaFloatToHsla01(hsva01ToRGBAFloat(this.#hsva));
+
+ if (!this.#skipHueUpdate) {
+ this.#hueCursorElem.setAttribute('transform', `translate(${h * 64}, 0)`);
+ }
+ this.#hueElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} 0% 100% / ${a})`);
+ this.#hueElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} 100% 50% / ${a})`);
+ if (!this.#skipAlphaUpdate) {
+ this.#alphaCursorElem.setAttribute('transform', `translate(${a * 64}, 0)`);
+ }
+ this.#alphaElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 0)`);
+ this.#alphaElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 1)`);
+
+ if (!this.#skipSatLevelUpdate) {
+ this.#circleElem.setAttribute('cx', `${s * 64}`);
+ this.#circleElem.setAttribute('cy', `${(1 - v) * 48}`);
+ }
+ }
+ this.#skipHueUpdate = false;
+ this.#skipSatLevelUpdate = false;
+ this.#skipAlphaUpdate = false;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {converters: {to, from}, alpha} = this.#options;
+ this.#alphaUIElem.style.display = alpha ? '' : 'none';
+ this.#convertInternalToHex = alpha
+ ? v => floatRGBAToHex(hsva01ToRGBAFloat(v))
+ : v => floatRGBToHex(hsv01ToRGBFloat(v));
+ this.#convertHexToInternal = alpha
+ ? v => rgbaFloatToHSVA01(hexToFloatRGBA(v))
+ : v => rgbFloatToHSV01(hexToFloatRGB(v));
+ this.#to = to;
+ this.#from = from;
+ return this;
+ }
+}
+
+/*
+
+holder = new TabHolder
+tab = holder.add(new Tab("name"))
+tab.add(...)
+
+
+pc = new PopdownController
+top = pc.add(new Row())
+top.add(new Button());
+values = topRow.add(new Div())
+bottom = pc.add(new Row());
+
+
+
+pc = new PopdownController
+pc.addTop
+pc.addTop
+
+pc.addBottom
+
+
+*/
+
+class PopDownController extends ValueController {
+ #top;
+ #valuesView;
+ #checkboxElem;
+ #bottom;
+ #options = {
+ open: false,
+ };
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-pop-down-controller');
+ /*
+ [ValueView
+ [[B][values]] upper row
+ [[ visual ]] lower row
+ ]
+ */
+ this.#top = this.add(new ElementView('div', 'muigui-pop-down-top'));
+// this.#top.add(new CheckboxView(makeSetter(this.#options, 'open')));
+ const checkboxElem = this.#top.addElem(createElem('input', {
+ type: 'checkbox',
+ onChange: () => {
+ this.#options.open = checkboxElem.checked;
+ this.updateDisplay();
+ },
+ }));
+ this.#checkboxElem = checkboxElem;
+ this.#valuesView = this.#top.add(new ElementView('div', 'muigui-pop-down-values'));
+ this.#bottom = this.add(new ElementView('div', 'muigui-pop-down-bottom'));
+ this.setOptions(options);
+ }
+ setKnobColor(bgCssColor/*, fgCssColor*/) {
+ if (this.#checkboxElem) {
+ this.#checkboxElem.style = `
+ --range-color: ${bgCssColor};
+ --value-bg-color: ${bgCssColor};
+ `;
+ }
+ }
+ updateDisplay() {
+ super.updateDisplay();
+ const {open} = this.#options;
+ this.domElement.children[1].classList.toggle('muigui-open', open);
+ this.domElement.children[1].classList.toggle('muigui-closed', !open);
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ super.setOptions(options);
+ this.updateDisplay();
+ }
+ addTop(view) {
+ return this.#valuesView.add(view);
+ }
+ addBottom(view) {
+ return this.#bottom.add(view);
+ }
+}
+
+/* eslint-disable no-underscore-dangle */
+
+class ColorChooser extends PopDownController {
+ #colorView;
+ #textView;
+ #to;
+ #setKnobHelper;
+
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-color-chooser');
+ const format = options.format || guessFormat(this.getValue());
+ const {color, text} = colorFormatConverters[format];
+ this.#to = color.to;
+ this.#textView = new TextView(this, {converters: text, alpha: hasAlpha(format)});
+ this.#colorView = new ColorChooserView(this, {converters: color, alpha: hasAlpha(format)});
+ this.addTop(this.#textView);
+ this.addBottom(this.#colorView);
+ // WTF! FIX!
+ this.#setKnobHelper = () => {
+ if (this.#to) {
+ const hex6Or8 = this.#to(this.getValue());
+ const hsl = rgbUint8ToHsl(hexToUint8RGB(hex6Or8));
+ hsl[2] = (hsl[2] + 50) % 100;
+ const hex = uint8RGBToHex(hslToRgbUint8(hsl));
+ this.setKnobColor(`${hex6Or8.substring(0, 7)}FF`, hex);
+ }
+ };
+ this.updateDisplay();
+ }
+ updateDisplay() {
+ super.updateDisplay();
+ if (this.#setKnobHelper) {
+ this.#setKnobHelper();
+ }
+ }
+ setOptions(options) {
+ super.setOptions(options);
+ return this;
+ }
+}
+
+function showCSS(ob) {
+ if (ob.prototype.css) {
+ showCSS(ob.prototype);
+ }
+}
+
+class Layout extends View {
+ static css = 'bar';
+ constructor(tag, className) {
+ super(createElem(tag, {className}));
+
+ showCSS(this);
+ }
+}
+
+/*
+class ValueController ?? {
+ const row = this.add(new Row());
+ const label = row.add(new Label());
+ const div = row.add(new Div());
+ const row = div.add(new Row());
+}
+*/
+
+/*
+class MyCustomThing extends ValueController {
+ constructor(object, property, options) {
+ const topRow = this.add(new Row());
+ const bottomRow = this.add(new Row());
+ topRow.add(new NumberView());
+ topRow.add(new NumberView());
+ topRow.add(new NumberView());
+ topRow.add(new NumberView());
+ bottomRow.add(new DirectionView());
+ bottomRow.add(new DirectionView());
+ bottomRow.add(new DirectionView());
+ bottomRow.add(new DirectionView());
+ }
+}
+ new Grid([
+ [new
+ ]
+ */
+
+class Column extends Layout {
+ constructor() {
+ super('div', 'muigui-row');
+ }
+}
+
+class Frame extends Layout {
+ static css = 'foo';
+ constructor() {
+ super('div', 'muigui-frame');
+ }
+ static get foo() {
+ return 'boo';
+ }
+}
+
+class Grid extends Layout {
+ constructor() {
+ super('div', 'muigui-grid');
+ }
+}
+
+class Row extends Layout {
+ constructor() {
+ super('div', 'muigui-row');
+ }
+}
+
+class GUIFolder extends Folder {
+ add(object, property, ...args) {
+ const controller = object instanceof Controller
+ ? object
+ : createController(object, property, ...args);
+ return this.addController(controller);
+ }
+ addCanvas(name) {
+ return this.addController(new Canvas(name));
+ }
+ addColor(object, property, options = {}) {
+ const value = object[property];
+ if (hasAlpha(options.format || guessFormat(value))) {
+ return this.addController(new ColorChooser(object, property, options));
+ } else {
+ return this.addController(new Color(object, property, options));
+ }
+ }
+ addDivider() {
+ return this.addController(new Divider());
+ }
+ addFolder(name) {
+ return this.addController(new GUIFolder(name));
+ }
+ addLabel(text) {
+ return this.addController(new Label(text));
+ }
+}
+
+class MuiguiElement extends HTMLElement {
+ constructor() {
+ super();
+ this.shadow = this.attachShadow({mode: 'open'});
+ }
+}
+
+customElements.define('muigui-element', MuiguiElement);
+
+const baseStyleSheet = new CSSStyleSheet();
+baseStyleSheet.replaceSync(css.default);
+const userStyleSheet = new CSSStyleSheet();
+
+function makeStyleSheetUpdater(styleSheet) {
+ let newCss;
+ let newCssPromise;
+
+ function updateStyle() {
+ if (newCss && !newCssPromise) {
+ const s = newCss;
+ newCss = undefined;
+ newCssPromise = styleSheet.replace(s).then(() => {
+ newCssPromise = undefined;
+ updateStyle();
+ });
+ }
+ }
+
+ return function updateStyleSheet(css) {
+ newCss = css;
+ updateStyle();
+ };
+}
+
+const updateBaseStyle = makeStyleSheetUpdater(baseStyleSheet);
+const updateUserStyle = makeStyleSheetUpdater(userStyleSheet);
+
+class GUI extends GUIFolder {
+ static converters = converters;
+ static mapRange = mapRange;
+ static makeRangeConverters = makeRangeConverters;
+ static makeRangeOptions = makeRangeOptions;
+ static makeMinMaxPair = makeMinMaxPair;
+ #localStyleSheet = new CSSStyleSheet();
+
+ constructor(options = {}) {
+ super('Controls', 'muigui-root');
+ if (options instanceof HTMLElement) {
+ options = {parent: options};
+ }
+ const {
+ autoPlace = true,
+ width,
+ title = 'Controls',
+ } = options;
+ let {
+ parent,
+ } = options;
+
+ if (width) {
+ this.domElement.style.width = /^\d+$/.test(width) ? `${width}px` : width;
+ }
+ if (parent === undefined && autoPlace) {
+ parent = document.body;
+ this.domElement.classList.add('muigui-auto-place');
+ }
+ if (parent) {
+ const muiguiElement = createElem('muigui-element');
+ muiguiElement.shadowRoot.adoptedStyleSheets = [baseStyleSheet, userStyleSheet, this.#localStyleSheet];
+ muiguiElement.shadow.appendChild(this.domElement);
+ parent.appendChild(muiguiElement);
+ }
+ if (title) {
+ this.title(title);
+ }
+ this.domElement.classList.add('muigui', 'muigui-colors');
+ }
+ setStyle(css) {
+ this.#localStyleSheet.replace(css);
+ }
+ static setBaseStyles(css) {
+ updateBaseStyle(css);
+ }
+ static getBaseStyleSheet() {
+ return baseStyleSheet;
+ }
+ static setUserStyles(css) {
+ updateUserStyle(css);
+ }
+ static getUserStyleSheet() {
+ return userStyleSheet;
+ }
+ static setTheme(name) {
+ GUI.setBaseStyles(`${css.default}\n${css.themes[name] || ''}`);
+ }
+}
+
+function noop() {
+}
+
+const keyDirections = {
+ ArrowLeft: [-1, 0],
+ ArrowRight: [1, 0],
+ ArrowUp: [0, -1],
+ ArrowDown: [0, 1],
+};
+
+// This probably needs to be global
+function addKeyboardEvents(elem, {onDown = noop, onUp = noop}) {
+ const keyDown = function (event) {
+ const mult = event.shiftKey ? 10 : 1;
+ const [dx, dy] = (keyDirections[event.key] || [0, 0]).map(v => v * mult);
+ const fn = event.type === 'keydown' ? onDown : onUp;
+ fn({
+ type: event.type.substring(3),
+ dx,
+ dy,
+ event,
+ });
+ };
+
+ elem.addEventListener('keydown', keyDown);
+ elem.addEventListener('keyup', keyDown);
+
+ return function () {
+ elem.removeEventListener('keydown', keyDown);
+ elem.removeEventListener('keyup', keyDown);
+ };
+}
+
+function assert(truthy, msg = '') {
+ if (!truthy) {
+ throw new Error(msg);
+ }
+}
+
+function getEllipsePointForAngle(cx, cy, rx, ry, phi, theta) {
+ const m = Math.abs(rx) * Math.cos(theta);
+ const n = Math.abs(ry) * Math.sin(theta);
+
+ return [
+ cx + Math.cos(phi) * m - Math.sin(phi) * n,
+ cy + Math.sin(phi) * m + Math.cos(phi) * n,
+ ];
+}
+
+function getEndpointParameters(cx, cy, rx, ry, phi, theta, dTheta) {
+ const [x1, y1] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta);
+ const [x2, y2] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta + dTheta);
+
+ const fa = Math.abs(dTheta) > Math.PI ? 1 : 0;
+ const fs = dTheta > 0 ? 1 : 0;
+
+ return { x1, y1, x2, y2, fa, fs };
+}
+
+function arc(cx, cy, r, start, end) {
+ assert(Math.abs(start - end) <= Math.PI * 2);
+ assert(start >= -Math.PI && start <= Math.PI * 2);
+ assert(start <= end);
+ assert(end >= -Math.PI && end <= Math.PI * 4);
+
+ const { x1, y1, x2, y2, fa, fs } = getEndpointParameters(cx, cy, r, r, 0, start, end - start);
+ return Math.abs(Math.abs(start - end) - Math.PI * 2) > Number.EPSILON
+ ? `M${cx} ${cy} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2} L${cx} ${cy}`
+ : `M${x1} ${y1} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2}`;
+}
+
+const svg$2 = `
+
+`;
+
+const twoPiMod = v => euclideanModulo$1(v + Math.PI, Math.PI * 2) - Math.PI;
+
+class DirectionView extends EditView {
+ #arrowElem;
+ #rangeElem;
+ #lastV;
+ #wrap;
+ #options = {
+ step: 1,
+ min: -180,
+ max: 180,
+
+ /*
+ --------
+ / -π/2 \
+ / | \
+ |<- -π * |
+ | * 0 ->| zero is down the positive X axis
+ |<- +π * |
+ \ | /
+ \ π/2 /
+ --------
+ */
+ dirMin: -Math.PI,
+ dirMax: Math.PI,
+ //dirMin: Math.PI * 0.5,
+ //dirMax: Math.PI * 2.5,
+ //dirMin: -Math.PI * 0.75, // test 10:30 to 7:30
+ //dirMax: Math.PI * 0.75,
+ //dirMin: Math.PI * 0.75, // test 7:30 to 10:30
+ //dirMax: -Math.PI * 0.75,
+ //dirMin: -Math.PI * 0.75, // test 10:30 to 1:30
+ //dirMax: -Math.PI * 0.25,
+ //dirMin: Math.PI * 0.25, // test 4:30 to 7:30
+ //dirMax: Math.PI * 0.75,
+ //dirMin: Math.PI * 0.75, // test 4:30 to 7:30
+ //dirMax: Math.PI * 0.25,
+ wrap: undefined,
+ converters: identity,
+ };
+
+ constructor(setter, options = {}) {
+ const wheelHelper = createWheelHelper();
+ super(createElem('div', {
+ className: 'muigui-direction muigui-no-scroll',
+ innerHTML: svg$2,
+ onWheel: e => {
+ e.preventDefault();
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ let tempV = this.#lastV + delta;
+ if (this.#wrap) {
+ tempV = euclideanModulo$1(tempV - min, max - min) + min;
+ }
+ const newV = clamp$1(stepify(tempV, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ const handleTouch = (e) => {
+ const {min, max, step, dirMin, dirMax} = this.#options;
+ const nx = e.nx * 2 - 1;
+ const ny = e.ny * 2 - 1;
+ const a = Math.atan2(ny, nx);
+
+ const center = (dirMin + dirMax) / 2;
+
+ const centeredAngle = twoPiMod(a - center);
+ const centeredStart = twoPiMod(dirMin - center);
+ const diff = dirMax - dirMin;
+
+ const n = clamp$1((centeredAngle - centeredStart) / (diff), 0, 1);
+ const newV = stepify(min + (max - min) * n, v => v, step);
+ setter.setValue(newV);
+ };
+ addTouchEvents(this.domElement, {
+ onDown: handleTouch,
+ onMove: handleTouch,
+ });
+ addKeyboardEvents(this.domElement, {
+ onDown: (e) => {
+ const {min, max, step} = this.#options;
+ const newV = clamp$1(stepify(this.#lastV + e.dx * step, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ });
+ this.#arrowElem = this.$('#muigui-arrow');
+ this.#rangeElem = this.$('#muigui-range');
+ this.setOptions(options);
+ }
+ updateDisplay(v) {
+ this.#lastV = v;
+ const {min, max} = this.#options;
+ const n = (v - min) / (max - min);
+ const angle = lerp$1(this.#options.dirMin, this.#options.dirMax, n);
+ this.#arrowElem.style.transform = `rotate(${angle}rad)`;
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ const {dirMin, dirMax, wrap} = this.#options;
+ this.#wrap = wrap !== undefined
+ ? wrap
+ : Math.abs(dirMin - dirMax) >= Math.PI * 2 - Number.EPSILON;
+ const [min, max] = dirMin < dirMax ? [dirMin, dirMax] : [dirMax , dirMin];
+ this.#rangeElem.setAttribute('d', arc(0, 0, 28.87, min, max));
+ }
+}
+
+// deg2rad
+// where is 0
+// range (0, 360), (-180, +180), (0,0) Really this is a range
+
+class Direction extends PopDownController {
+ #options;
+ constructor(object, property, options) {
+ super(object, property, 'muigui-direction');
+this.#options = options; // FIX
+ this.addTop(new NumberView(this,
+identity));
+ this.addBottom(new DirectionView(this, options));
+ this.updateDisplay();
+ }
+}
+
+class RadioGridView extends EditView {
+ #values;
+
+ constructor(setter, keyValues, cols = 3) {
+ const values = [];
+ const name = makeId();
+ super(createElem('div', {}, keyValues.map(([key, value], ndx) => {
+ values.push(value);
+ return createElem('label', {}, [
+ createElem('input', {
+ type: 'radio',
+ name,
+ value: ndx,
+ onChange: function () {
+ if (this.checked) {
+ setter.setFinalValue(that.#values[this.value]);
+ }
+ },
+ }),
+ createElem('button', {
+ type: 'button',
+ textContent: key,
+ onClick: function () {
+ this.previousElementSibling.click();
+ },
+ }),
+ ]);
+ })));
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ const that = this;
+ this.#values = values;
+ this.cols(cols);
+ }
+ updateDisplay(v) {
+ const ndx = this.#values.indexOf(v);
+ for (let i = 0; i < this.domElement.children.length; ++i) {
+ this.domElement.children[i].children[0].checked = i === ndx;
+ }
+ }
+ cols(cols) {
+ this.domElement.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
+ }
+}
+
+class RadioGrid extends ValueController {
+ constructor(object, property, options) {
+ super(object, property, 'muigui-radio-grid');
+ const valueIsNumber = typeof this.getValue() === 'number';
+ const {
+ keyValues: keyValuesInput,
+ cols = 3,
+ } = options;
+ const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);
+ this.add(new RadioGridView(this, keyValues, cols));
+ this.updateDisplay();
+ }
+}
+
+function onResize(elem, callback) {
+ new ResizeObserver(() => {
+ callback({rect: elem.getBoundingClientRect(), elem});
+ }).observe(elem);
+}
+
+function onResizeSVGNoScale(elem, hAnchor, vAnchor, callback) {
+ onResize(elem, ({rect}) => {
+ const {width, height} = rect;
+ elem.setAttribute('viewBox', `-${width * hAnchor} -${height * vAnchor} ${width} ${height}`);
+ callback({elem, rect});
+ });
+}
+
+function onResizeCanvas(elem, callback) {
+ onResize(elem, ({rect}) => {
+ const {width, height} = rect;
+ elem.width = width;
+ elem.height = height;
+ callback({elem, rect});
+ });
+}
+
+const svg$1 = `
+
+`;
+
+function createSVGTicks(start, end, step, min, max, height) {
+ const p = [];
+ if (start < min) {
+ start += stepify(min - start, v => v, step);
+ }
+ end = Math.min(end, max);
+ for (let i = start; i <= end; i += step) {
+ p.push(`M${i} 0 l0 ${height}`);
+ }
+ return p.join(' ');
+}
+
+function createSVGNumbers(start, end, unitSize, unit, minusSize, min, max, labelFn) {
+ const texts = [];
+ if (start < min) {
+ start += stepify(min - start, v => v, unitSize);
+ }
+ end = Math.min(end, max);
+ const digits = Math.max(0, -Math.log10(unit));
+ const f = v => labelFn(v.toFixed(digits));
+ for (let i = start; i <= end; i += unitSize) {
+ texts.push(`${f(i / unitSize * unit)}`);
+ }
+ return texts.join('\n');
+}
+
+function computeSizeOfMinus(elem) {
+ const oldHTML = elem.innerHTML;
+ elem.innerHTML = '- ';
+ const text = elem.querySelector('text');
+ const size = text.getComputedTextLength();
+ elem.innerHTML = oldHTML;
+ return size;
+}
+
+class SliderView extends EditView {
+ #svgElem;
+ #originElem;
+ #ticksElem;
+ #thicksElem;
+ #numbersElem;
+ #leftGradElem;
+ #rightGradElem;
+ #width;
+ #height;
+ #lastV;
+ #minusSize;
+ #options = {
+ min: -100,
+ max: 100,
+ step: 1,
+ unit: 10,
+ unitSize: 10,
+ ticksPerUnit: 5,
+ labelFn: v => v,
+ tickHeight: 1,
+ limits: true,
+ thicksColor: undefined,
+ orientation: undefined,
+ };
+
+ constructor(setter, options) {
+ const wheelHelper = createWheelHelper();
+ super(createElem('div', {
+ innerHTML: svg$1,
+ className: 'muigui-no-v-scroll',
+ onWheel: e => {
+ e.preventDefault();
+ const {min, max, step} = this.#options;
+ const delta = wheelHelper(e, step);
+ const newV = clamp$1(stepify(this.#lastV + delta, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ }));
+ this.#svgElem = this.$('svg');
+ this.#originElem = this.$('#muigui-origin');
+ this.#ticksElem = this.$('#muigui-ticks');
+ this.#thicksElem = this.$('#muigui-thicks');
+ this.#numbersElem = this.$('#muigui-numbers');
+ this.#leftGradElem = this.$('#muigui-left-grad');
+ this.#rightGradElem = this.$('#muigui-right-grad');
+ this.setOptions(options);
+ let startV;
+ addTouchEvents(this.domElement, {
+ onDown: () => {
+ startV = this.#lastV;
+ },
+ onMove: (e) => {
+ const {min, max, unitSize, unit, step} = this.#options;
+ const newV = clamp$1(stepify(startV - e.dx / unitSize * unit, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ });
+ addKeyboardEvents(this.domElement, {
+ onDown: (e) => {
+ const {min, max, step} = this.#options;
+ const newV = clamp$1(stepify(this.#lastV + e.dx * step, v => v, step), min, max);
+ setter.setValue(newV);
+ },
+ });
+ onResizeSVGNoScale(this.#svgElem, 0.5, 0, ({rect: {width}}) => {
+ this.#leftGradElem.setAttribute('x', -width / 2);
+ this.#rightGradElem.setAttribute('x', width / 2 - 20);
+ this.#minusSize = computeSizeOfMinus(this.#numbersElem);
+ this.#width = width;
+ this.#updateSlider();
+ });
+ }
+ // |--------V--------|
+ // . . | . . . | . . . |
+ //
+ #updateSlider() {
+ // There's no size if ResizeObserver has not fired yet.
+ if (!this.#width || this.#lastV === undefined) {
+ return;
+ }
+ const {
+ labelFn,
+ limits,
+ min,
+ max,
+ orientation,
+ tickHeight,
+ ticksPerUnit,
+ unit,
+ unitSize,
+ thicksColor,
+ } = this.#options;
+ const unitsAcross = Math.ceil(this.#width / unitSize);
+ const center = this.#lastV;
+ const centerUnitSpace = center / unit;
+ const startUnitSpace = Math.round(centerUnitSpace - unitsAcross);
+ const endUnitSpace = startUnitSpace + unitsAcross * 2;
+ const start = startUnitSpace * unitSize;
+ const end = endUnitSpace * unitSize;
+ const minUnitSpace = limits ? min * unitSize / unit : start;
+ const maxUnitSpace = limits ? max * unitSize / unit : end;
+ const height = labelFn(1) === '' ? 10 : 5;
+ if (ticksPerUnit > 1) {
+ this.#ticksElem.setAttribute('d', createSVGTicks(start, end, unitSize / ticksPerUnit, minUnitSpace, maxUnitSpace, height * tickHeight));
+ }
+ this.#thicksElem.style.stroke = thicksColor; //setAttribute('stroke', thicksColor);
+ this.#thicksElem.setAttribute('d', createSVGTicks(start, end, unitSize, minUnitSpace, maxUnitSpace, height));
+ this.#numbersElem.innerHTML = createSVGNumbers(start, end, unitSize, unit, this.#minusSize, minUnitSpace, maxUnitSpace, labelFn);
+ this.#originElem.setAttribute('transform', `translate(${-this.#lastV * unitSize / unit} 0)`);
+ this.#svgElem.classList.toggle('muigui-slider-up', orientation === 'up');
+ }
+ updateDisplay(v) {
+ this.#lastV = v;
+ this.#updateSlider();
+ }
+ setOptions(options) {
+ copyExistingProperties(this.#options, options);
+ return this;
+ }
+}
+
+class Slider extends ValueController {
+ constructor(object, property, options = {}) {
+ super(object, property, 'muigui-slider');
+ this.add(new SliderView(this, options));
+ this.add(new NumberView(this, options));
+ this.updateDisplay();
+ }
+}
+
+const svg = `
+
+`;
+
+class Vec2View extends EditView {
+ #svgElem;
+ #arrowElem;
+ #circleElem;
+ #lastV = [];
+
+ constructor(setter) {
+ super(createElem('div', {
+ innerHTML: svg,
+ className: 'muigui-no-scroll',
+ }));
+ const onTouch = (e) => {
+ const {width, height} = this.#svgElem.getBoundingClientRect();
+ const nx = e.nx * 2 - 1;
+ const ny = e.ny * 2 - 1;
+ setter.setValue([nx * width * 0.5, ny * height * 0.5]);
+ };
+ addTouchEvents(this.domElement, {
+ onDown: onTouch,
+ onMove: onTouch,
+ });
+ this.#svgElem = this.$('svg');
+ this.#arrowElem = this.$('#muigui-arrow');
+ this.#circleElem = this.$('#muigui-circle');
+ onResizeSVGNoScale(this.#svgElem, 0.5, 0.5, () => this.#updateDisplayImpl);
+ }
+ #updateDisplayImpl() {
+ const [x, y] = this.#lastV;
+ this.#arrowElem.setAttribute('d', `M0,0L${x},${y}`);
+ this.#circleElem.setAttribute('transform', `translate(${x}, ${y})`);
+ }
+ updateDisplay(v) {
+ this.#lastV[0] = v[0];
+ this.#lastV[1] = v[1];
+ this.#updateDisplayImpl();
+ }
+}
+
+// TODO: zoom with wheel and pinch?
+// TODO: grid?
+// // options
+// scale:
+// range: number (both x and y + /)
+// range: array (min, max)
+// xRange:
+// deg/rad/turn
+
+class Vec2 extends PopDownController {
+ constructor(object, property) {
+ super(object, property, 'muigui-vec2');
+
+ const makeSetter = (ndx) => {
+ return {
+ setValue: (v) => {
+ const newV = this.getValue();
+ newV[ndx] = v;
+ this.setValue(newV);
+ },
+ setFinalValue: (v) => {
+ const newV = this.getValue();
+ newV[ndx] = v;
+ this.setFinalValue(newV);
+ },
+ };
+ };
+
+ this.addTop(new NumberView(makeSetter(0), {
+ converters: {
+ to: v => v[0],
+ from: strToNumber.from,
+ },
+ }));
+ this.addTop(new NumberView(makeSetter(1), {
+ converters: {
+ to: v => v[1],
+ from: strToNumber.from,
+ },
+ }));
+ this.addBottom(new Vec2View(this));
+ this.updateDisplay();
+ }
+}
+
+export { ColorChooser, Direction, RadioGrid, Range, Select, Slider, TextNumber, Vec2, GUI as default };
+//# sourceMappingURL=muigui.module.js.map
diff --git a/dist/0.x/muigui.module.js.map b/dist/0.x/muigui.module.js.map
new file mode 100644
index 0000000..339fac6
--- /dev/null
+++ b/dist/0.x/muigui.module.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"muigui.module.js","sources":["../../src/styles/muigui.css.js","../../src/libs/elem.js","../../src/libs/utils.js","../../../src/views/View.ts","../../src/controllers/Controller.js","../../src/controllers/Button.js","../../src/views/EditView.js","../../src/views/CheckboxView.js","../../src/libs/taskrunner.js","../../src/libs/ids.js","../../src/views/ValueView.js","../../src/controllers/LabelController.js","../../src/controllers/ValueController.js","../../src/controllers/Checkbox.js","../../src/libs/conversions.js","../../src/libs/wheel.js","../../src/views/NumberView.js","../../src/controllers/TextNumber.js","../../src/views/SelectView.js","../../src/libs/key-values.js","../../src/controllers/Select.js","../../src/views/RangeView.js","../../src/controllers/Range.js","../../src/views/TextView.js","../../src/controllers/Text.js","../../src/controllers/create-controller.js","../../src/libs/color-utils.js","../../src/views/ElementView.js","../../src/controllers/Canvas.js","../../src/views/ColorView.js","../../src/controllers/Color.js","../../src/controllers/Divider.js","../../src/controllers/Container.js","../../src/controllers/Folder.js","../../src/controllers/Label.js","../../src/libs/touch.js","../../src/views/ColorChooserView.js","../../src/controllers/PopDownController.js","../../src/controllers/ColorChooser.js","../../src/layout/Layout.js","../../src/layout/Column.js","../../src/layout/Frame.js","../../src/layout/Grid.js","../../src/layout/Row.js","../../src/muigui.js","../../src/libs/keyboard.js","../../src/libs/assert.js","../../src/libs/svg.js","../../src/views/DirectionView.js","../../src/controllers/Direction.js","../../src/views/RadioGridView.js","../../src/controllers/RadioGrid.js","../../src/libs/resize-helpers.js","../../src/views/SliderView.js","../../src/controllers/Slider.js","../../src/views/Vec2View.js","../../src/controllers/Vec2.js"],"sourcesContent":["export default {\n default: `\n.muigui {\n --bg-color: #ddd;\n --color: #222;\n --contrast-color: #eee;\n --value-color: #145 ;\n --value-bg-color: #eeee;\n --disabled-color: #999;\n --menu-bg-color: #f8f8f8;\n --menu-sep-color: #bbb;\n --hover-bg-color: #999;\n --focus-color: #68C;\n --range-color: #888888;\n --invalid-color: #FF0000;\n --selected-color: rgb(255, 255, 255, 0.9);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n}\n\n@media (prefers-color-scheme: dark) {\n .muigui {\n --bg-color: #222222;\n --color: #dddddd;\n --contrast-color: #000;\n --value-color: #43e5f7;\n --value-bg-color: #444444;\n --disabled-color: #666666;\n --menu-bg-color: #080808;\n --menu-sep-color: #444444;\n --hover-bg-color: #666666;\n --focus-color: #88AAFF;\n --range-color: #888888;\n --invalid-color: #FF6666;\n --selected-color: rgba(255, 255, 255, 0.3);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n }\n}\n\n.muigui {\n --width: 250px;\n --label-width: 45%;\n --number-width: 40%;\n\n\n --font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Arial, sans-serif;\n --font-size: 11px;\n --font-family-mono: Menlo, Monaco, Consolas, \"Droid Sans Mono\", monospace;\n --font-size-mono: 11px;\n\n --line-height: 1.7em;\n --border-radius: 0px;\n\n width: var(--width);\n font-family: var(--font-family);\n font-size: var(--font-size);\n box-sizing: border-box;\n line-height: 100%;\n}\n.muigui * {\n box-sizing: inherit;\n}\n\n.muigui-no-scroll {\n touch-action: none;\n}\n.muigui-no-h-scroll {\n touch-action: pan-y;\n}\n.muigui-no-v-scroll {\n touch-action: pan-x;\n}\n\n.muigui-invalid-value {\n background-color: red !important;\n color: white !important;\n}\n\n.muigui-grid {\n display: grid;\n}\n.muigui-rows {\n display: flex;\n flex-direction: column;\n\n min-height: 20px;\n border: 2px solid red;\n}\n.muigui-columns {\n display: flex;\n flex-direction: row;\n\n height: 20px;\n border: 2px solid green;\n}\n.muigui-rows>*,\n.muigui-columns>* {\n flex: 1 1 auto;\n align-items: stretch;\n min-height: 0;\n min-width: 0;\n}\n\n.muigui-row {\n border: 2px solid yellow;\n min-height: 10px\n}\n.muigui-column {\n border: 2px solid lightgreen;\n}\n\n/* -------- */\n\n.muigui-show { /* */ }\n.muigui-hide { \n display: none !important;\n}\n.muigui-disabled {\n pointer-events: none;\n --color: var(--disabled-color) !important;\n --value-color: var(--disabled-color) !important;\n --range-left-color: var(--disabled-color) !important;\n}\n\n.muigui canvas,\n.muigui svg {\n display: block;\n border-radius: var(--border-radius);\n}\n.muigui canvas {\n background-color: var(--value-bg-color);\n}\n\n.muigui-controller {\n min-width: 0;\n min-height: var(--line-height);\n}\n.muigui-root,\n.muigui-menu {\n display: flex;\n flex-direction: column;\n position: relative;\n user-select: none;\n height: fit-content;\n margin: 0;\n padding-bottom: 0.1em;\n border-radius: var(--border-radius);\n}\n.muigui-menu {\n border-bottom: 1px solid var(--menu-sep-color);\n}\n\n.muigui-root>button:nth-child(1),\n.muigui-menu>button:nth-child(1) {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n position: relative;\n text-align: left;\n color: var(--color);\n background-color: var(--menu-bg-color);\n min-height: var(--line-height);\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n cursor: pointer;\n border-radius: var(--border-radius);\n}\n.muigui-root>div:nth-child(2),\n.muigui-menu>div:nth-child(2) {\n flex: 1 1 auto;\n}\n\n.muigui-controller {\n margin-left: 0.2em;\n margin-right: 0.2em;\n}\n.muigui-root.muigui-controller,\n.muigui-menu.muigui-controller {\n margin-left: 0;\n margin-right: 0;\n}\n.muigui-controller>*:nth-child(1) {\n flex: 1 0 var(--label-width);\n min-width: 0;\n white-space: pre;\n}\n.muigui-controller>label:nth-child(1) {\n place-content: center start;\n display: inline-grid;\n overflow: hidden;\n}\n.muigui-controller>*:nth-child(2) {\n flex: 1 1 75%;\n min-width: 0;\n}\n\n/* -----------------------------------------\n a label controller is [[label][value]]\n*/\n\n.muigui-label-controller {\n display: flex;\n margin: 0.4em 0 0.4em 0;\n word-wrap: initial;\n align-items: stretch;\n}\n\n.muigui-value {\n display: flex;\n align-items: stretch;\n}\n.muigui-value>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n.muigui-value>*:nth-child(1) {\n flex: 1 1 calc(100% - var(--number-width));\n}\n.muigui-value>*:nth-child(2) {\n flex: 1 1 var(--number-width);\n margin-left: 0.2em;\n}\n\n/* fix! */\n.muigui-open>button>label::before,\n.muigui-closed>button>label::before {\n width: 1.25em;\n height: var(--line-height);\n display: inline-grid;\n place-content: center start;\n pointer-events: none;\n}\n.muigui-open>button>label::before {\n content: \"ⓧ\"; /*\"▼\";*/\n}\n.muigui-closed>button>label::before {\n content: \"⨁\"; /*\"▶\";*/\n}\n.muigui-open>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 0.5s ease-out;\n max-height: 100vh;\n overflow: auto;\n opacity: 1;\n}\n\n.muigui-closed>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 1s;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n}\n\n/* ---- popdown ---- */\n\n.muigui-pop-down-top {\n display: flex;\n}\n/* fix? */\n.muigui-value>*:nth-child(1).muigui-pop-down-top {\n flex: 0;\n}\n.muigui-pop-down-bottom {\n\n}\n\n.muigui-pop-down-values {\n min-width: 0;\n display: flex;\n}\n.muigui-pop-down-values>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.muigui-value.muigui-pop-down-controller {\n flex-direction: column;\n}\n\n.muigui-pop-down-top input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-pop-down-top input[type=checkbox]::before {\n content: \"+\";\n display: grid;\n place-content: center;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n color: var(--value-bg-color);\n width: calc(var(--line-height) - 4px);\n height: calc(var(--line-height) - 4px);\n}\n\n.muigui-pop-down-top input[type=checkbox]:checked::before {\n content: \"X\";\n}\n\n\n/* ---- select ---- */\n\n.muigui select,\n.muigui option,\n.muigui input,\n.muigui button {\n color: var(--value-color);\n background-color: var(--value-bg-color);\n font-family: var(--font-family);\n font-size: var(--font-size);\n border: none;\n margin: 0;\n border-radius: var(--border-radius);\n}\n.muigui select {\n appearance: none;\n margin: 0;\n margin-left: 0; /*?*/\n overflow: hidden; /* Safari */\n}\n\n.muigui select:focus,\n.muigui input:focus,\n.muigui button:focus {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui select:hover,\n.muigui option:hover,\n.muigui input:hover,\n.muigui button:hover {\n background-color: var(--hover-bg-color); \n}\n\n/* ------ [ label ] ------ */\n\n.muigui-label {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n padding-top: 0.4em;\n padding-bottom: 0.3em;\n place-content: center start;\n background-color: var(--menu-bg-color);\n white-space: pre;\n border-radius: var(--border-radius);\n}\n\n/* ------ [ divider] ------ */\n\n.muigui-divider {\n min-height: 6px;\n border-top: 2px solid var(--menu-sep-color);\n margin-top: 6px;\n}\n\n/* ------ [ button ] ------ */\n\n.muigui-button {\n display: grid;\n\n}\n.muigui-button button {\n border: none;\n color: var(--value-color);\n background-color: var(--button-bg-color);\n cursor: pointer;\n place-content: center center;\n}\n\n/* ------ [ color ] ------ */\n\n.muigui-color>div {\n overflow: hidden;\n position: relative;\n margin-left: 0;\n margin-right: 0; /* why? */\n max-width: var(--line-height);\n border-radius: var(--border-radius);\n}\n\n.muigui-color>div:focus-within {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui-color input[type=color] {\n border: none;\n padding: 0;\n background: inherit;\n cursor: pointer;\n position: absolute;\n width: 200%;\n left: -10px;\n top: -10px;\n height: 200%;\n}\n.muigui-disabled canvas,\n.muigui-disabled svg,\n.muigui-disabled img,\n.muigui-disabled .muigui-color input[type=color] {\n opacity: 0.2;\n}\n\n/* ------ [ checkbox ] ------ */\n\n.muigui-checkbox>label:nth-child(2) {\n display: grid;\n place-content: center start;\n margin: 0;\n}\n\n.muigui-checkbox input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-checkbox input[type=checkbox]::before {\n content: \"\";\n color: var(--value-color);\n display: grid;\n place-content: center;\n}\n\n.muigui-checkbox input[type=checkbox]:checked::before {\n content: \"✔\";\n}\n\n.muigui input[type=number]::-webkit-inner-spin-button, \n.muigui input[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none;\n appearance: none;\n margin: 0; \n}\n.muigui input[type=number] {\n -moz-appearance: textfield;\n}\n\n/* ------ [ radio grid ] ------ */\n\n.muigui-radio-grid>div {\n display: grid;\n gap: 2px;\n}\n\n.muigui-radio-grid input {\n appearance: none;\n display: none;\n}\n\n.muigui-radio-grid button {\n color: var(--color);\n width: 100%;\n text-align: left;\n}\n\n.muigui-radio-grid input:checked + button {\n color: var(--value-color);\n background-color: var(--selected-color);\n}\n\n/* ------ [ color-chooser ] ------ */\n\n.muigui-color-chooser-cursor {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n.muigui-color-chooser-circle {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n\n\n/* ------ [ vec2 ] ------ */\n\n.muigui-vec2 svg {\n background-color: var(--value-bg-color);\n}\n\n.muigui-vec2-axis {\n stroke: 1px;\n stroke: var(--focus-color);\n}\n\n.muigui-vec2-line {\n stroke-width: 1px;\n stroke: var(--value-color);\n fill: var(--value-color);\n}\n\n/* ------ [ direction ] ------ */\n\n.muigui-direction svg {\n background-color: rgba(0,0,0,0.2);\n}\n\n.muigui-direction:focus-within svg {\n outline: none;\n}\n.muigui-direction-range {\n fill: var(--value-bg-color);\n}\n.muigui-direction svg:focus {\n outline: none;\n}\n.muigui-direction svg:focus .muigui-direction-range {\n stroke-width: 0.5px;\n stroke: var(--focus-color);\n}\n\n.muigui-direction-arrow {\n fill: var(--value-color);\n}\n\n/* ------ [ slider ] ------ */\n\n.muigui-slider>div {\n display: flex;\n align-items: stretch;\n height: var(--line-height);\n}\n.muigui-slider svg {\n flex: 1 1 auto;\n}\n.muigui-slider .muigui-slider-up #muigui-orientation {\n transform: scale(1, -1) translateY(-100%);\n}\n\n.muigui-slider .muigui-slider-up #muigui-number-orientation {\n transform: scale(1,-1);\n}\n\n.muigui-ticks {\n stroke: var(--range-color);\n}\n.muigui-thicks {\n stroke: var(--color);\n stroke-width: 2px;\n}\n.muigui-svg-text {\n fill: var(--color);\n font-size: 7px;\n}\n.muigui-mark {\n fill: var(--value-color);\n}\n\n/* ------ [ range ] ------ */\n\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: transparent;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n margin-top: calc((var(--line-height) - 2px) / -2);\n width: calc(var(--line-height) - 2px);\n height: calc(var(--line-height) - 2px);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n border: 1px solid var(--menu-sep-color);\n height: 2px;\n}\n\n\n/* dat.gui style - doesn't work on Safari iOS */\n\n/*\n.muigui-range input[type=range] {\n cursor: ew-resize;\n overflow: hidden;\n}\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: var(--range-right-color);\n margin: 0;\n}\n.muigui-range input[type=range]:hover {\n background-color: var(--range-right-hover-color);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n height: max-content;\n color: var(--range-left-color);\n margin-top: -1px;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0px;\n height: max-content;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n}\n*/\n\n/* FF */\n/*\n.muigui-range input[type=range]::-moz-slider-progress {\n background-color: var(--range-left-color); \n}\n.muigui-range input[type=range]::-moz-slider-thumb {\n height: max-content;\n width: 0;\n border: none;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n box-sizing: border-box;\n}\n*/\n\n.muigui-checkered-background {\n background-color: #404040;\n background-image:\n linear-gradient(45deg, #808080 25%, transparent 25%),\n linear-gradient(-45deg, #808080 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #808080 75%),\n linear-gradient(-45deg, transparent 75%, #808080 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0px;\n}\n\n/* ---------------------------------------------------------- */\n\n/* needs to be at bottom to take precedence */\n.muigui-auto-place {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 100001;\n}\n\n`,\nthemes: {\n default: '',\n float: `\n :root {\n color-scheme: light dark,\n }\n\n .muigui {\n --width: 400px;\n --bg-color: initial;\n --label-width: 25%;\n --number-width: 20%;\n }\n\n input,\n .muigui-label-controller>label {\n text-shadow:\n -1px -1px 0 var(--contrast-color),\n 1px -1px 0 var(--contrast-color),\n -1px 1px 0 var(--contrast-color),\n 1px 1px 0 var(--contrast-color);\n }\n\n .muigui-controller > label:nth-child(1) {\n place-content: center end;\n margin-right: 1em;\n }\n\n .muigui-value > :nth-child(2) {\n margin-left: 1em;\n }\n\n .muigui-root>*:nth-child(1) {\n display: none;\n }\n\n .muigui-range input[type=range]::-webkit-slider-thumb {\n border-radius: 1em;\n }\n\n .muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: initial;\n appearance: none;\n border: 1px solid rgba(0, 0, 0, 0.25);\n height: 2px;\n }\n\n .muigui-colors {\n --value-color: var(--color );\n --value-bg-color: rgba(0, 0, 0, 0.1);\n --disabled-color: #cccccc;\n --menu-bg-color: rgba(0, 0, 0, 0.1);\n --menu-sep-color: #bbbbbb;\n --hover-bg-color: rgba(0, 0, 0, 0);\n --invalid-color: #FF0000;\n --selected-color: rgba(0, 0, 0, 0.3);\n --range-color: rgba(0, 0, 0, 0.125);\n }\n`,\n},\n};\n","export function setElemProps(elem, attrs, children) {\n for (const [key, value] of Object.entries(attrs)) {\n if (typeof value === 'function' && key.startsWith('on')) {\n const eventName = key.substring(2).toLowerCase();\n elem.addEventListener(eventName, value, {passive: false});\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n elem[key][k] = v;\n }\n } else if (elem[key] === undefined) {\n elem.setAttribute(key, value);\n } else {\n elem[key] = value;\n }\n }\n for (const child of children) {\n elem.appendChild(child);\n }\n return elem;\n}\n\nexport function createElem(tag, attrs = {}, children = []) {\n const elem = document.createElement(tag);\n setElemProps(elem, attrs, children);\n return elem;\n}\n\nexport function addElem(tag, parent, attrs = {}, children = []) {\n const elem = createElem(tag, attrs, children);\n parent.appendChild(elem);\n return elem;\n}\n\nlet nextId = 0;\nexport function getNewId() {\n return `muigui-id-${nextId++}`;\n}\n","export function removeArrayElem(array, value) {\n const ndx = array.indexOf(value);\n if (ndx) {\n array.splice(ndx, 1);\n }\n return array;\n}\n\n/**\n * Converts an camelCase or snake_case id to \"camel case\" or \"snake case\"\n * @param {string} id\n */\nconst underscoreRE = /_/g;\nconst upperLowerRE = /([A-Z])([a-z])/g;\nexport function idToLabel(id) {\n return id.replace(underscoreRE, ' ')\n .replace(upperLowerRE, (m, m1, m2) => `${m1.toLowerCase()} ${m2}`);\n}\n\nexport function clamp(v, min, max) {\n return Math.max(min, Math.min(max, v));\n}\n\nexport const isTypedArray = typeof SharedArrayBuffer !== 'undefined'\n ? function isArrayBufferOrSharedArrayBuffer(a) {\n return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);\n }\n : function isArrayBuffer(a) {\n return a && a.buffer && a.buffer instanceof ArrayBuffer;\n };\n\nexport const isArrayOrTypedArray = v => Array.isArray(v) || isTypedArray(v);\n\n// Yea, I know this should be `Math.round(v / step) * step\n// but try step = 0.1, newV = 19.95\n//\n// I get\n// Math.round(19.95 / 0.1) * 0.1\n// 19.900000000000002\n// vs\n// Math.round(19.95 / 0.1) / (1 / 0.1)\n// 19.9\n//\nexport const stepify = (v, from, step) => Math.round(from(v) / step) / (1 / step);\n\nexport const euclideanModulo = (v, n) => ((v % n) + n) % n;\nexport const lerp = (a, b, t) => a + (b - a) * t;\nexport function copyExistingProperties(dst, src) {\n for (const key in src) {\n if (key in dst) {\n dst[key] = src[key];\n }\n }\n return dst;\n}\n\nexport const mapRange = (v, inMin, inMax, outMin, outMax) => (v - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;\n\nexport const makeRangeConverters = ({from, to}) => {\n return {\n to: v => mapRange(v, ...from, ...to),\n from: v => [true, mapRange(v, ...to, ...from)],\n };\n};\n\nexport const makeRangeOptions = ({from, to, step}) => {\n return {\n min: to[0],\n max: to[1],\n ...(step && {step}),\n converters: makeRangeConverters({from, to}),\n };\n};\n\n// TODO: remove an use one in conversions. Move makeRangeConverters there?\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\nexport function makeMinMaxPair(gui, properties, minPropName, maxPropName, options) {\n const { converters: { from } = identity } = options;\n const { min, max } = options;\n const guiMinRange = options.minRange || 0;\n const valueMinRange = from(guiMinRange)[1];\n const minGui = gui\n .add(properties, minPropName, {\n ...options,\n min,\n max: max - guiMinRange,\n })\n .onChange(v => {\n maxGui.setValue(Math.min(max, Math.max(v + valueMinRange, properties[maxPropName])));\n });\n const maxGui = gui\n .add(properties, maxPropName, {\n ...options,\n min: min + guiMinRange,\n max,\n })\n .onChange(v => {\n minGui.setValue(Math.max(min, Math.min(v - valueMinRange, properties[minPropName])));\n });\n return [ minGui, maxGui ];\n}\n\n","import { removeArrayElem } from '../libs/utils.js';\n\nexport default class View {\n domElement: HTMLElement;\n\n #childDestElem: HTMLElement;\n #views: View[] = [];\n\n constructor(elem: HTMLElement) {\n this.domElement = elem;\n this.#childDestElem = elem;\n }\n addElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n return elem;\n }\n removeElem(elem: HTMLElement) {\n this.#childDestElem.removeChild(elem);\n return elem;\n }\n pushSubElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n this.#childDestElem = elem;\n }\n popSubElem() {\n this.#childDestElem = this.#childDestElem.parentElement!;\n }\n add(view: View) {\n this.#views.push(view);\n this.addElem(view.domElement);\n return view;\n }\n remove(view: View) {\n this.removeElem(view.domElement);\n removeArrayElem(this.#views, view);\n return view;\n }\n pushSubView(view: View) {\n this.pushSubElem(view.domElement);\n }\n popSubView() {\n this.popSubElem();\n }\n setOptions(options: any) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n }\n updateDisplayIfNeeded(newV: any, ignoreCache?: boolean) {\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n $(selector: string) {\n return this.domElement.querySelector(selector);\n }\n}","import { createElem } from '../libs/elem.js';\nimport { removeArrayElem } from '../libs/utils.js';\nimport View from '../views/View.js';\n\nexport default class Controller extends View {\n #changeFns;\n #finishChangeFns;\n #parent;\n\n constructor(className) {\n super(createElem('div', {className: 'muigui-controller'}));\n this.#changeFns = [];\n this.#finishChangeFns = [];\n // we need the specialization to come last so it takes precedence.\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n get parent() {\n return this.#parent;\n }\n setParent(parent) {\n this.#parent = parent;\n this.enable(!this.disabled());\n }\n show(show = true) {\n this.domElement.classList.toggle('muigui-hide', !show);\n this.domElement.classList.toggle('muigui-show', show);\n return this;\n }\n hide() {\n return this.show(false);\n }\n disabled() {\n return !!this.domElement.closest('.muigui-disabled');\n }\n\n enable(enable = true) {\n this.domElement.classList.toggle('muigui-disabled', !enable);\n\n // If disabled we need to set the attribute 'disabled=true' to all\n // input/select/button/textarea's below\n //\n // If enabled we need to set the attribute 'disabled=false' to all below\n // until we hit a disabled controller.\n //\n // ATM the problem is we can find the input/select/button/textarea elements\n // but we can't easily find which controller they belong do.\n // But we don't need to? We can just check up if it or parent has\n // '.muigui-disabled'\n ['input', 'button', 'select', 'textarea'].forEach(tag => {\n this.domElement.querySelectorAll(tag).forEach(elem => {\n const disabled = !!elem.closest('.muigui-disabled');\n elem.disabled = disabled;\n });\n });\n\n return this;\n }\n disable(disable = true) {\n return this.enable(!disable);\n }\n onChange(fn) {\n this.removeChange(fn);\n this.#changeFns.push(fn);\n return this;\n }\n removeChange(fn) {\n removeArrayElem(this.#changeFns, fn);\n return this;\n }\n onFinishChange(fn) {\n this.removeFinishChange(fn);\n this.#finishChangeFns.push(fn);\n return this;\n }\n removeFinishChange(fn) {\n removeArrayElem(this.#finishChangeFns, fn);\n return this;\n }\n #callListeners(fns, newV) {\n for (const fn of fns) {\n fn.call(this, newV);\n }\n }\n emitChange(value, object, property) {\n this.#callListeners(this.#changeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n emitFinalChange(value, object, property) {\n this.#callListeners(this.#finishChangeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitFinalChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n updateDisplay() {\n // placeholder. override\n }\n getColors() {\n const toCamelCase = s => s.replace(/-([a-z])/g, (m, m1) => m1.toUpperCase());\n const keys = [\n 'color',\n 'bg-color',\n 'value-color',\n 'value-bg-color',\n 'hover-bg-color',\n 'menu-bg-color',\n 'menu-sep-color',\n 'disabled-color',\n ];\n const div = createElem('div');\n this.domElement.appendChild(div);\n const colors = Object.fromEntries(keys.map(key => {\n div.style.color = `var(--${key})`;\n const s = getComputedStyle(div);\n return [toCamelCase(key), s.color];\n }));\n div.remove();\n return colors;\n }\n}\n","import {\n createElem,\n} from '../libs/elem.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport Controller from './Controller.js';\n\nexport default class Button extends Controller {\n #object;\n #property;\n #buttonElem;\n #options = {\n name: '',\n };\n\n constructor(object, property, options = {}) {\n super('muigui-button', '');\n this.#object = object;\n this.#property = property;\n\n this.#buttonElem = this.addElem(\n createElem('button', {\n type: 'button',\n onClick: () => {\n this.#object[this.#property](this);\n },\n }));\n this.setOptions({name: property, ...options});\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {name} = this.#options;\n this.#buttonElem.textContent = name;\n }\n}","import { isTypedArray } from '../libs/utils.js';\nimport View from './View.js';\n\nfunction arraysEqual(a, b) {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; ++i) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction copyArrayElementsFromTo(src, dst) {\n dst.length = src.length;\n for (let i = 0; i < src.length; ++i) {\n dst[i] = src[i];\n }\n}\n\nexport default class EditView extends View {\n #oldV;\n #updateCheck;\n\n #checkArrayNeedsUpdate(newV) {\n // It's an array, we need to compare all elements\n // Example, vec2, [r,g,b], ...\n const needUpdate = !arraysEqual(newV, this.#oldV);\n if (needUpdate) {\n copyArrayElementsFromTo(newV, this.#oldV);\n }\n return needUpdate;\n }\n\n #checkTypedArrayNeedsUpdate() {\n let once = true;\n return function checkTypedArrayNeedsUpdateImpl(newV) {\n // It's a typedarray, we need to compare all elements\n // Example: Float32Array([r, g, b])\n let needUpdate = once;\n once = false;\n if (!needUpdate) {\n needUpdate = !arraysEqual(newV, this.#oldV);\n }\n return needUpdate;\n };\n }\n\n #checkObjectNeedsUpdate(newV) {\n let needUpdate = false;\n for (const key in newV) {\n if (newV[key] !== this.#oldV[key]) {\n needUpdate = true;\n this.#oldV[key] = newV[key];\n }\n }\n return needUpdate;\n }\n\n #checkValueNeedsUpdate(newV) {\n const needUpdate = newV !== this.#oldV;\n this.#oldV = newV;\n return needUpdate;\n }\n\n #getUpdateCheckForType(newV) {\n if (Array.isArray(newV)) {\n this.#oldV = [];\n return this.#checkArrayNeedsUpdate.bind(this);\n } else if (isTypedArray(newV)) {\n this.#oldV = new newV.constructor(newV);\n return this.#checkTypedArrayNeedsUpdate(this);\n } else if (typeof newV === 'object') {\n this.#oldV = {};\n return this.#checkObjectNeedsUpdate.bind(this);\n } else {\n return this.#checkValueNeedsUpdate.bind(this);\n }\n }\n\n // The point of this is updating DOM elements\n // is slow but if we've called `listen` then\n // every frame we're going to try to update\n // things with the current value so if nothing\n // has changed then skip it.\n updateDisplayIfNeeded(newV, ignoreCache) {\n this.#updateCheck = this.#updateCheck || this.#getUpdateCheckForType(newV);\n // Note: We call #updateCheck first because it updates\n // the cache\n if (this.#updateCheck(newV) || ignoreCache) {\n this.updateDisplay(newV);\n }\n }\n setOptions(/*options*/) {\n // override this\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class CheckboxView extends EditView {\n #checkboxElem;\n constructor(setter, id) {\n const checkboxElem = createElem('input', {\n type: 'checkbox',\n id,\n onInput: () => {\n setter.setValue(checkboxElem.checked);\n },\n onChange: () => {\n setter.setFinalValue(checkboxElem.checked);\n },\n });\n super(createElem('label', {}, [checkboxElem]));\n this.#checkboxElem = checkboxElem;\n }\n updateDisplay(v) {\n this.#checkboxElem.checked = v;\n }\n}\n","import { removeArrayElem } from './utils.js';\n\nconst tasks = [];\nconst tasksToRemove = new Set();\n\nlet requestId;\nlet processing;\n\nfunction removeTasks() {\n if (!tasksToRemove.size) {\n return;\n }\n\n if (processing) {\n queueProcessing();\n return;\n }\n\n tasksToRemove.forEach(task => {\n removeArrayElem(tasks, task);\n });\n tasksToRemove.clear();\n}\n\nfunction processTasks() {\n requestId = undefined;\n processing = true;\n for (const task of tasks) {\n if (!tasksToRemove.has(task)) {\n task();\n }\n }\n processing = false;\n removeTasks();\n queueProcessing();\n}\n\nfunction queueProcessing() {\n if (!requestId && tasks.length) {\n requestId = requestAnimationFrame(processTasks);\n }\n}\n\nexport function addTask(fn) {\n tasks.push(fn);\n queueProcessing();\n}\n\nexport function removeTask(fn) {\n tasksToRemove.set(fn);\n\n const ndx = tasks.indexOf(fn);\n if (ndx >= 0) {\n tasks.splice(ndx, 1);\n }\n}","let id = 0;\n\nexport function makeId() {\n return `muigui-${++id}`;\n}\n","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ValueView extends View {\n constructor(className = '') {\n super(createElem('div', {className: 'muigui-value'}));\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n}","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport ValueView from '../views/ValueView.js';\nimport Controller from './Controller.js';\n\nexport default class LabelController extends Controller {\n #id;\n #nameElem;\n\n constructor(className = '', name = '') {\n super('muigui-label-controller');\n this.#id = makeId();\n this.#nameElem = createElem('label', {for: this.#id});\n this.domElement.appendChild(this.#nameElem);\n this.pushSubView(new ValueView(className));\n this.name(name);\n }\n get id() {\n return this.#id;\n }\n name(name) {\n if (this.#nameElem.title === this.#nameElem.textContent) {\n this.#nameElem.title = name;\n }\n this.#nameElem.textContent = name;\n return this;\n }\n tooltip(tip) {\n this.#nameElem.title = tip;\n }\n}\n\n","import {addTask, removeTask} from '../libs/taskrunner.js';\nimport { isTypedArray } from '../libs/utils.js';\nimport LabelController from './LabelController.js';\n\nexport default class ValueController extends LabelController {\n #object;\n #property;\n #initialValue;\n #listening;\n #views;\n #updateFn;\n\n constructor(object, property, className = '') {\n super(className, property);\n this.#object = object;\n this.#property = property;\n this.#initialValue = this.getValue();\n this.#listening = false;\n this.#views = [];\n }\n get initialValue() {\n return this.#initialValue;\n }\n get object() {\n return this.#object;\n }\n get property() {\n return this.#property;\n }\n add(view) {\n this.#views.push(view);\n super.add(view);\n this.updateDisplay();\n return view;\n }\n #setValueImpl(v, ignoreCache) {\n let isDifferent = false;\n if (typeof v === 'object') {\n const dst = this.#object[this.#property];\n // don't replace objects, just their values.\n if (Array.isArray(v) || isTypedArray(v)) {\n for (let i = 0; i < v.length; ++i) {\n isDifferent ||= dst[i] !== v[i];\n dst[i] = v[i];\n }\n } else {\n for (const key of Object.keys(v)) {\n isDifferent ||= dst[key] !== v[key];\n }\n Object.assign(dst, v);\n }\n } else {\n isDifferent = this.#object[this.#property] !== v;\n this.#object[this.#property] = v;\n }\n this.updateDisplay(ignoreCache);\n if (isDifferent) {\n this.emitChange(this.getValue(), this.#object, this.#property);\n }\n return isDifferent;\n }\n setValue(v) {\n this.#setValueImpl(v);\n }\n setFinalValue(v) {\n const isDifferent = this.#setValueImpl(v, true);\n if (isDifferent) {\n this.emitFinalChange(this.getValue(), this.#object, this.#property);\n }\n return this;\n }\n updateDisplay(ignoreCache) {\n const newV = this.getValue();\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n setOptions(options) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n this.updateDisplay();\n return this;\n }\n getValue() {\n return this.#object[this.#property];\n }\n value(v) {\n this.setValue(v);\n return this;\n }\n reset() {\n this.setValue(this.#initialValue);\n return this;\n }\n listen(listen = true) {\n if (!this.#updateFn) {\n this.#updateFn = this.updateDisplay.bind(this);\n }\n if (listen) {\n if (!this.#listening) {\n this.#listening = true;\n addTask(this.#updateFn);\n }\n } else {\n if (this.#listening) {\n this.#listening = false;\n removeTask(this.#updateFn);\n }\n }\n return this;\n }\n}\n\n","import CheckboxView from '../views/CheckboxView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Checkbox extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n const id = this.id;\n this.add(new CheckboxView(this, id));\n this.updateDisplay();\n }\n}","import {\n makeRangeConverters,\n} from './utils.js';\n\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\n\n// from: from string to value\n// to: from value to string\nexport const strToNumber = {\n to: v => v.toString(),\n from: v => {\n const newV = parseFloat(v);\n return [!Number.isNaN(newV), newV];\n },\n};\n\nexport const converters = {\n radToDeg: makeRangeConverters({to: [0, 180], from: [0, Math.PI]}),\n};\n","export function createWheelHelper() {\n let wheelAccum = 0;\n return function (e, step, wheelScale = 5) {\n wheelAccum -= e.deltaY * step / wheelScale;\n const wheelSteps = Math.floor(Math.abs(wheelAccum) / step) * Math.sign(wheelAccum);\n const delta = wheelSteps * step;\n wheelAccum -= delta;\n return delta;\n };\n}\n","import { createElem } from '../libs/elem.js';\nimport { strToNumber } from '../libs/conversions.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nexport default class NumberView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n converters: strToNumber,\n min: Number.NEGATIVE_INFINITY,\n max: Number.POSITIVE_INFINITY,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'number',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const v = parseFloat(this.domElement.value);\n const [valid, newV] = this.#from(v);\n let inRange;\n if (valid && !Number.isNaN(v)) {\n const {min, max} = this.#options;\n inRange = newV >= min && newV <= max;\n this.#skipUpdate = skipUpdate;\n setFn(clamp(newV, min, max));\n }\n this.domElement.classList.toggle('muigui-invalid-value', !valid || !inRange);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n return this;\n }\n}\n","\nimport NumberView from '../views/NumberView.js';\nimport ValueController from './ValueController.js';\n\n// Wanted to name this `Number` but it conflicts with\n// JavaScript `Number`. It most likely wouldn't be\n// an issue? But users might `import {Number} ...` and\n// things would break.\nexport default class TextNumber extends ValueController {\n #textView;\n #step;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-checkbox');\n this.#textView = this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class SelectView extends EditView {\n #values;\n\n constructor(setter, keyValues) {\n const values = [];\n super(createElem('select', {\n onChange: () => {\n setter.setFinalValue(this.#values[this.domElement.selectedIndex]);\n },\n }, keyValues.map(([key, value]) => {\n values.push(value);\n return createElem('option', {textContent: key});\n })));\n this.#values = values;\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n this.domElement.selectedIndex = ndx;\n }\n}\n","\n// 4 cases\n// (a) keyValues is array of arrays, each sub array is key value\n// (b) keyValues is array and value is number then keys = array contents, value = index\n// (c) keyValues is array and value is not number, key = array contents, value = array contents\n// (d) keyValues is object then key->value\nexport function convertToKeyValues(keyValues, valueIsNumber) {\n if (Array.isArray(keyValues)) {\n if (Array.isArray(keyValues[0])) {\n // (a) keyValues is array of arrays, each sub array is key value\n return keyValues;\n } else {\n if (valueIsNumber) {\n // (b) keyValues is array and value is number then keys = array contents, value = index\n return keyValues.map((v, ndx) => [v, ndx]);\n } else {\n // (c) keyValues is array and value is not number, key = array contents, value = array contents\n return keyValues.map(v => [v, v]);\n }\n }\n } else {\n // (d)\n return [...Object.entries(keyValues)];\n }\n}\n","import SelectView from '../views/SelectView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class Select extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-select');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {keyValues: keyValuesInput} = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new SelectView(this, keyValues));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport EditView from './EditView.js';\n\nexport default class RangeView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n min: 0,\n max: 1,\n converters: identity,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'range',\n onInput: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setValue(validV);\n }\n },\n onChange: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setFinalValue(validV);\n }\n },\n onWheel: e => {\n e.preventDefault();\n const [valid, v] = this.#from(parseFloat(this.domElement.value));\n if (!valid) {\n return;\n }\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n min,\n max,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n this.domElement.step = step;\n this.domElement.min = min;\n this.domElement.max = max;\n return this;\n }\n}","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport RangeView from '../views/RangeView.js';\n\nexport default class Range extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-range');\n this.add(new RangeView(this, options));\n this.add(new NumberView(this, options));\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class TextView extends EditView {\n #to;\n #from;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n super(createElem('input', {\n type: 'text',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const [valid, newV] = this.#from(this.domElement.value);\n if (valid) {\n this.#skipUpdate = skipUpdate;\n setFn(newV);\n }\n this.domElement.style.color = valid ? '' : 'var(--invalid-color)';\n\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = this.#to(v);\n this.domElement.style.color = '';\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import TextView from '../views/TextView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Text extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n this.add(new TextView(this));\n this.updateDisplay();\n }\n}","import Button from './Button.js';\nimport Checkbox from './Checkbox.js';\nimport TextNumber from './TextNumber.js';\nimport Select from './Select.js';\nimport Range from './Range.js';\nimport Text from './Text.js';\n\n// const isConversion = o => typeof o.to === 'function' && typeof o.from === 'function';\n\n/**\n * possible inputs\n * add(o, p, min: number, max: number)\n * add(o, p, min: number, max: number, step: number)\n * add(o, p, array: [value])\n * add(o, p, array: [[key, value]])\n *\n * @param {*} object\n * @param {string} property\n * @param {...any} args\n * @returns {Controller}\n */\nexport function createController(object, property, ...args) {\n const [arg1] = args;\n if (Array.isArray(arg1)) {\n return new Select(object, property, {keyValues: arg1});\n }\n\n const t = typeof object[property];\n switch (t) {\n case 'number':\n if (typeof args[0] === 'number' && typeof args[1] === 'number') {\n const min = args[0];\n const max = args[1];\n const step = args[2];\n return new Range(object, property, {min, max, ...(step && {step})});\n }\n return args.length === 0\n ? new TextNumber(object, property, ...args)\n : new Range(object, property, ...args);\n case 'boolean':\n return new Checkbox(object, property, ...args);\n case 'function':\n return new Button(object, property, ...args);\n case 'string':\n return new Text(object, property, ...args);\n case 'undefined':\n throw new Error(`no property named ${property}`);\n default:\n throw new Error(`unhandled type ${t} for property ${property}`);\n }\n}","const clamp = (v, min, max) => Math.max(min, Math.min(max, v));\nconst lerp = (a, b, t) => a + (b - a) * t;\nconst fract = v => v >= 0 ? v % 1 : 1 - (v % 1);\n\nconst f0 = v => +v.toFixed(0); // converts to string (eg 1.2 => \"1\"), then converts back to number (eg, \"1.200\" => 1.2)\nconst f3 = v => +v.toFixed(3); // converts to string (eg 1.2 => \"1.200\"), then converts back to number (eg, \"1.200\" => 1.2)\n\nconst hexToUint32RGB = v => (parseInt(v.substring(1, 3), 16) << 16) |\n (parseInt(v.substring(3, 5), 16) << 8 ) |\n (parseInt(v.substring(5, 7), 16) );\nconst uint32RGBToHex = v => `#${(Math.round(v)).toString(16).padStart(6, '0')}`;\nconst hexToUint32RGBA = v => (parseInt(v.substring(1, 3), 16) * 2 ** 24) +\n (parseInt(v.substring(3, 5), 16) * 2 ** 16) +\n (parseInt(v.substring(5, 7), 16) * 2 ** 8) +\n (parseInt(v.substring(7, 9), 16) );\nconst uint32RGBAToHex = v => `#${(Math.round(v)).toString(16).padStart(8, '0')}`;\n\nexport const hexToUint8RGB = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n];\nexport const uint8RGBToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToUint8RGBA = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n parseInt(v.substring(7, 9), 16),\n];\nexport const uint8RGBAToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToFloatRGB = v => hexToUint8RGB(v).map(v => f3(v / 255));\nexport const floatRGBToHex = v => uint8RGBToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nexport const hexToFloatRGBA = v => hexToUint8RGBA(v).map(v => f3(v / 255));\nexport const floatRGBAToHex = v => uint8RGBAToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nconst scaleAndClamp = v => clamp(Math.round(v * 255), 0, 255).toString(16).padStart(2, '0');\n\nconst hexToObjectRGB = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n});\nconst objectRGBToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}`;\nconst hexToObjectRGBA = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n a: parseInt(v.substring(7, 9), 16) / 255,\n});\nconst objectRGBAToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}${scaleAndClamp(v.a)}`;\n\nconst hexToCssRGB = v => `rgb(${hexToUint8RGB(v).join(', ')})`;\nconst cssRGBRegex = /^\\s*rgb\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\s*$/;\nconst cssRGBToHex = v => {\n const m = cssRGBRegex.exec(v);\n return uint8RGBToHex([m[1], m[2], m[3]].map(v => parseInt(v)));\n};\nconst hexToCssRGBA = v => `rgba(${hexToUint8RGBA(v).map((v, i) => i === 3 ? v / 255 : v).join(', ')})`;\nconst cssRGBARegex = /^\\s*rgba\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\nconst cssRGBAToHex = v => {\n const m = cssRGBARegex.exec(v);\n return uint8RGBAToHex([m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? (parseFloat(v) * 255 | 0) : parseInt(v)));\n};\n\nconst hexToCssHSL = v => {\n const hsl = rgbUint8ToHsl(hexToUint8RGB(v)).map(v => f0(v));\n return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`;\n};\nconst hexToCssHSLA = v => {\n const hsla = rgbaUint8ToHsla(hexToUint8RGBA(v)).map((v, i) => i === 3 ? f3(v) : f0(v));\n return `hsl(${hsla[0]} ${hsla[1]}% ${hsla[2]}% / ${hsla[3]})`;\n};\nconst cssHSLRegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\)\\s*$/;\nconst cssHSLARegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\/\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\n\nconst hex3DigitTo6Digit = v => `${v[0]}${v[0]}${v[1]}${v[1]}${v[2]}${v[2]}`;\nconst cssHSLToHex = v => {\n const m = cssHSLRegex.exec(v);\n const rgb = hslToRgbUint8([m[1], m[2], m[3]].map(v => parseFloat(v)));\n return uint8RGBToHex(rgb);\n};\nconst cssHSLAToHex = v => {\n const m = cssHSLARegex.exec(v);\n const rgba = hslaToRgbaUint8([m[1], m[2], m[3], m[4]].map(v => parseFloat(v)));\n return uint8RGBAToHex(rgba);\n};\n\nconst euclideanModulo = (v, n) => ((v % n) + n) % n;\n\nexport function hslToRgbUint8([h, s, l]) {\n h = euclideanModulo(h, 360);\n s = clamp(s / 100, 0, 1);\n l = clamp(l / 100, 0, 1);\n\n const a = s * Math.min(l, 1 - l);\n\n function f(n) {\n const k = (n + h / 30) % 12;\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n\n return [f(0), f(8), f(4)].map(v => Math.round(v * 255));\n}\n\nexport function hslaToRgbaUint8([h, s, l, a]) {\n const rgb = hslToRgbUint8([h, s, l]);\n return [...rgb, a * 255 | 0];\n}\n\nexport function rgbFloatToHsl01([r, g, b]) {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (min + max) * 0.5;\n const d = max - min;\n let h = 0;\n let s = 0;\n\n if (d !== 0) {\n s = (l === 0 || l === 1)\n ? 0\n : (max - l) / Math.min(l, 1 - l);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4;\n }\n }\n\n return [h / 6, s, l];\n}\n\nexport function rgbaFloatToHsla01([r, g, b, a]) {\n const hsl = rgbFloatToHsl01([r, g, b]);\n return [...hsl, a];\n}\n\nexport const rgbUint8ToHsl = (rgb) => {\n const [h, s, l] = rgbFloatToHsl01(rgb.map(v => v / 255));\n return [h * 360, s * 100, l * 100];\n};\n\nexport const rgbaUint8ToHsla = (rgba) => {\n const [h, s, l, a] = rgbaFloatToHsla01(rgba.map(v => v / 255));\n return [h * 360, s * 100, l * 100, a];\n};\n\nexport function hsv01ToRGBFloat([hue, sat, val]) {\n sat = clamp(sat, 0, 1);\n val = clamp(val, 0, 1);\n return [hue, hue + 2 / 3, hue + 1 / 3].map(\n v => lerp(1, clamp(Math.abs(fract(v) * 6 - 3.0) - 1, 0, 1), sat) * val\n );\n}\n\nexport function hsva01ToRGBAFloat([hue, sat, val, alpha]) {\n const rgb = hsv01ToRGBFloat([hue, sat, val]);\n return [...rgb, alpha];\n}\n\nconst round3 = v => Math.round(v * 1000) / 1000;\n\nexport function rgbFloatToHSV01([r, g, b]) {\n const p = b > g\n ? [b, g, -1, 2 / 3]\n : [g, b, 0, -1 / 3];\n const q = p[0] > r\n ? [p[0], p[1], p[3], r]\n : [r, p[1], p[2], p[0]];\n const d = q[0] - Math.min(q[3], q[1]);\n return [\n Math.abs(q[2] + (q[3] - q[1]) / (6 * d + Number.EPSILON)),\n d / (q[0] + Number.EPSILON),\n q[0],\n ].map(round3);\n}\n\nexport function rgbaFloatToHSVA01([r, g, b, a]) {\n const hsv = rgbFloatToHSV01([r, g, b]);\n return [...hsv, a];\n}\n\n// window.hsv01ToRGBFloat = hsv01ToRGBFloat;\n// window.rgbFloatToHSV01 = rgbFloatToHSV01;\n\n// Yea, meh!\nexport const hasAlpha = format => format.endsWith('a') || format.startsWith('hex8');\n\nconst cssStringFormats = [\n { re: /^#(?:[0-9a-f]){6}$/i, format: 'hex6' },\n { re: /^(?:[0-9a-f]){6}$/i, format: 'hex6-no-hash' },\n { re: /^#(?:[0-9a-f]){8}$/i, format: 'hex8' },\n { re: /^(?:[0-9a-f]){8}$/i, format: 'hex8-no-hash' },\n { re: /^#(?:[0-9a-f]){3}$/i, format: 'hex3' },\n { re: /^(?:[0-9a-f]){3}$/i, format: 'hex3-no-hash' },\n { re: cssRGBRegex, format: 'css-rgb' },\n { re: cssHSLRegex, format: 'css-hsl' },\n { re: cssRGBARegex, format: 'css-rgba' },\n { re: cssHSLARegex, format: 'css-hsla' },\n];\n\nfunction guessStringColorFormat(v) {\n for (const formatInfo of cssStringFormats) {\n if (formatInfo.re.test(v)) {\n return formatInfo;\n }\n }\n return undefined;\n}\n\nexport function guessFormat(v) {\n switch (typeof v) {\n case 'number':\n console.warn('can not reliably guess format based on a number. You should pass in a format like {format: \"uint32-rgb\"} or {format: \"uint32-rgb\"}');\n return v <= 0xFFFFFF ? 'uint32-rgb' : 'uint32-rgba';\n case 'string': {\n const formatInfo = guessStringColorFormat(v.trim());\n if (formatInfo) {\n return formatInfo.format;\n }\n break;\n }\n case 'object':\n if (v instanceof Uint8Array || v instanceof Uint8ClampedArray) {\n if (v.length === 3) {\n return 'uint8-rgb';\n } else if (v.length === 4) {\n return 'uint8-rgba';\n }\n } else if (v instanceof Float32Array) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else if (Array.isArray(v)) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else {\n if ('r' in v && 'g' in v && 'b' in v) {\n if ('a' in v) {\n return 'object-rgba';\n } else {\n return 'object-rgb';\n }\n }\n }\n }\n throw new Error(`unknown color format: ${v}`);\n}\n\nfunction fixHex6(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction fixHex8(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction hex6ToHex3(hex6) {\n return (hex6[1] === hex6[2] &&\n hex6[3] === hex6[4] &&\n hex6[5] === hex6[6])\n ? `#${hex6[1]}${hex6[3]}${hex6[5]}`\n : hex6;\n}\n\nconst hex3RE = /^(#|)([0-9a-f]{3})$/i;\nfunction hex3ToHex6(hex3) {\n const m = hex3RE.exec(hex3);\n if (m) {\n const [, , m2] = m;\n return `#${hex3DigitTo6Digit(m2)}`;\n }\n return hex3;\n}\n\nfunction fixHex3(v) {\n return hex6ToHex3(fixHex6(v));\n}\n\nconst strToRGBObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgb = JSON.parse(json);\n if (Number.isNaN(rgb.r) || Number.isNaN(rgb.g) || Number.isNaN(rgb.b)) {\n throw new Error('not {r, g, b}');\n }\n return [true, rgb];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToRGBAObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgba = JSON.parse(json);\n if (Number.isNaN(rgba.r) || Number.isNaN(rgba.g) || Number.isNaN(rgba.b) || Number.isNaN(rgba.a)) {\n throw new Error('not {r, g, b, a}');\n }\n return [true, rgba];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToCssRGB = s => {\n const m = cssRGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgb(${v.join(', ')})`];\n};\n\nconst strToCssRGBA = s => {\n const m = cssRGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? parseFloat(v) : parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgba(${v.join(', ')})`];\n};\n\nconst strToCssHSL = s => {\n const m = cssHSLRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]}, ${v[1]}%, ${v[2]}%)`];\n};\n\nconst strToCssHSLA = s => {\n const m = cssHSLARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]} ${v[1]}% ${v[2]}% / ${v[3]})`];\n};\n\nconst rgbObjectToStr = rgb => {\n return `{r:${f3(rgb.r)}, g:${f3(rgb.g)}, b:${f3(rgb.b)}}`;\n};\nconst rgbaObjectToStr = rgba => {\n return `{r:${f3(rgba.r)}, g:${f3(rgba.g)}, b:${f3(rgba.b)}}, a:${f3(rgba.a)}}`;\n};\n\nconst strTo3IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo3Ints = s => {\n const m = strTo3IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo4IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo4Ints = s => {\n const m = strTo4IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo3Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 3) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strTo4Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 4) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strToUint32RGBRegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,6})\\s*$/i;\nconst strToUint32RGB = s => {\n const m = strToUint32RGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst strToUint32RGBARegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,8})\\s*$/i;\nconst strToUint32RGBA = s => {\n const m = strToUint32RGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst hex6RE = /^\\s*#[a-f0-9]{6}\\s*$|^\\s*#[a-f0-9]{3}\\s*$/i;\nconst hexNoHash6RE = /^\\s*[a-f0-9]{6}\\s*$/i;\nconst hex8RE = /^\\s*#[a-f0-9]{8}\\s*$/i;\nconst hexNoHash8RE = /^\\s*[a-f0-9]{8}\\s*$/i;\n\n// For each format converter\n//\n// fromHex/toHex convert from/to '#RRGGBB'\n//\n// fromHex converts from the string '#RRBBGG' to the format\n// (eg: for uint32-rgb, '#123456' becomes 0x123456)\n//\n// toHex converts from the format to '#RRGGBB'\n// (eg: for uint8-rgb, [16, 33, 50] becomes '#102132')\n//\n//\n// fromStr/toStr convert from/to what's in the input[type=text] element\n//\n// toStr converts from the format to its string representation\n// (eg, for object-rgb, {r: 1, g: 0.5, b:0} becomes \"{r: 1, g: 0.5, b:0}\")\n// ^object ^string\n//\n// fromStr converts its string representation to its format\n// (eg, for object-rgb) \"{r: 1, g: 0.5, b:0}\" becomes {r: 1, g: 0.5, b:0})\n// ^string ^object\n// fromString returns an array which is [valid, v]\n// where valid is true if the string was a valid and v is the converted\n// format if v is true.\n//\n// Note: toStr should convert to \"ideal\" form (whatever that is).\n// (eg, for css-rgb\n// \"{ r: 0.10000, g: 001, b: 0}\" becomes \"{r: 0.1, g: 1, b: 0}\"\n// notice that css-rgb is a string to a string\n// )\nexport const colorFormatConverters = {\n 'hex6': {\n color: {\n from: v => [true, v],\n to: fixHex6,\n },\n text: {\n from: v => [hex6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8': {\n color: {\n from: v => [true, v],\n to: fixHex8,\n },\n text: {\n from: v => [hex8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3': {\n color: {\n from: v => [true, fixHex3(v)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hex6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'hex6-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex6(v)}`,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex8(v)}`,\n },\n text: {\n from: v => [hexNoHash8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3-no-hash': {\n color: {\n from: v => [true, fixHex3(v).substring(1)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'uint32-rgb': {\n color: {\n from: v => [true, hexToUint32RGB(v)],\n to: uint32RGBToHex,\n },\n text: {\n from: v => strToUint32RGB(v),\n to: v => `0x${v.toString(16).padStart(6, '0')}`,\n },\n },\n 'uint32-rgba': {\n color: {\n from: v => [true, hexToUint32RGBA(v)],\n to: uint32RGBAToHex,\n },\n text: {\n from: v => strToUint32RGBA(v),\n to: v => `0x${v.toString(16).padStart(8, '0')}`,\n },\n },\n 'uint8-rgb': {\n color: {\n from: v => [true, hexToUint8RGB(v)],\n to: uint8RGBToHex,\n },\n text: {\n from: strTo3Ints,\n to: v => v.join(', '),\n },\n },\n 'uint8-rgba': {\n color: {\n from: v => [true, hexToUint8RGBA(v)],\n to: uint8RGBAToHex,\n },\n text: {\n from: strTo4Ints,\n to: v => v.join(', '),\n },\n },\n 'float-rgb': {\n color: {\n from: v => [true, hexToFloatRGB(v)],\n to: floatRGBToHex,\n },\n text: {\n from: strTo3Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'float-rgba': {\n color: {\n from: v => [true, hexToFloatRGBA(v)],\n to: floatRGBAToHex,\n },\n text: {\n from: strTo4Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'object-rgb': {\n color: {\n from: v => [true, hexToObjectRGB(v)],\n to: objectRGBToHex,\n },\n text: {\n from: strToRGBObject,\n to: rgbObjectToStr,\n },\n },\n 'object-rgba': {\n color: {\n from: v => [true, hexToObjectRGBA(v)],\n to: objectRGBAToHex,\n },\n text: {\n from: strToRGBAObject,\n to: rgbaObjectToStr,\n },\n },\n 'css-rgb': {\n color: {\n from: v => [true, hexToCssRGB(v)],\n to: cssRGBToHex,\n },\n text: {\n from: strToCssRGB,\n to: v => strToCssRGB(v)[1],\n },\n },\n 'css-rgba': {\n color: {\n from: v => [true, hexToCssRGBA(v)],\n to: cssRGBAToHex,\n },\n text: {\n from: strToCssRGBA,\n to: v => strToCssRGBA(v)[1],\n },\n },\n 'css-hsl': {\n color: {\n from: v => [true, hexToCssHSL(v)],\n to: cssHSLToHex,\n },\n text: {\n from: strToCssHSL,\n to: v => strToCssHSL(v)[1],\n },\n },\n 'css-hsla': {\n color: {\n from: v => [true, hexToCssHSLA(v)],\n to: cssHSLAToHex,\n },\n text: {\n from: strToCssHSLA,\n to: v => strToCssHSLA(v)[1],\n },\n },\n};","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ElementView extends View {\n constructor(tag, className) {\n super(createElem(tag, {className}));\n }\n}","import ElementView from '../views/ElementView.js';\nimport LabelController from './LabelController.js';\n\n// TODO: remove this? Should just be user side\nexport default class Canvas extends LabelController {\n #canvasElem;\n\n constructor() {\n super('muigui-canvas');\n this.#canvasElem = this.add(\n new ElementView('canvas', 'muigui-canvas'),\n ).domElement;\n }\n get canvas() {\n return this.#canvasElem;\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class ColorView extends EditView {\n #to;\n #from;\n #colorElem;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const colorElem = createElem('input', {\n type: 'color',\n onInput: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setValue(newV);\n }\n },\n onChange: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setFinalValue(newV);\n }\n },\n });\n super(createElem('div', {}, [colorElem]));\n this.setOptions(options);\n this.#colorElem = colorElem;\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.#colorElem.value = this.#to(v);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}} = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import {\n colorFormatConverters,\n guessFormat,\n} from '../libs/color-utils.js';\nimport ValueController from './ValueController.js';\nimport TextView from '../views/TextView.js';\nimport ColorView from '../views/ColorView.js';\n\nexport default class Color extends ValueController {\n #colorView;\n #textView;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#colorView = this.add(new ColorView(this, {converters: color}));\n this.#textView = this.add(new TextView(this, {converters: text}));\n this.updateDisplay();\n }\n setOptions(options) {\n const {format} = options;\n if (format) {\n const {color, text} = colorFormatConverters[format];\n this.#colorView.setOptions({converters: color});\n this.#textView.setOptions({converters: text});\n }\n super.setOptions(options);\n return this;\n }\n}","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addController({className: 'muigui-divider')};\nexport default class Divider extends Controller {\n constructor() {\n super('muigui-divider');\n }\n}","import Controller from './Controller.js';\n\nexport default class Container extends Controller {\n #controllers;\n #childDestController;\n\n constructor(className) {\n super(className);\n this.#controllers = [];\n this.#childDestController = this;\n }\n get children() {\n return this.#controllers; // should we return a copy?\n }\n get controllers() {\n return this.#controllers.filter(c => !(c instanceof Container));\n }\n get folders() {\n return this.#controllers.filter(c => c instanceof Container);\n }\n reset(recursive = true) {\n for (const controller of this.#controllers) {\n if (!(controller instanceof Container) || recursive) {\n controller.reset(recursive);\n }\n }\n return this;\n }\n updateDisplay() {\n for (const controller of this.#controllers) {\n controller.updateDisplay();\n }\n return this;\n }\n remove(controller) {\n const ndx = this.#controllers.indexOf(controller);\n if (ndx >= 0) {\n const c = this.#controllers.splice(ndx, 1);\n const c0 = c[0];\n const elem = c0.domElement;\n elem.remove();\n c0.setParent(null);\n }\n return this;\n }\n #addControllerImpl(controller) {\n this.domElement.appendChild(controller.domElement);\n this.#controllers.push(controller);\n controller.setParent(this);\n return controller;\n }\n addController(controller) {\n return this.#childDestController.#addControllerImpl(controller);\n }\n pushContainer(container) {\n this.addController(container);\n this.#childDestController = container;\n return container;\n }\n popContainer() {\n this.#childDestController = this.#childDestController.parent;\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport Container from './Container.js';\n\nexport default class Folder extends Container {\n #labelElem;\n\n constructor(name = 'Controls', className = 'muigui-menu') {\n super(className);\n this.#labelElem = createElem('label');\n this.addElem(createElem('button', {\n type: 'button',\n onClick: () => this.toggleOpen(),\n }, [this.#labelElem]));\n this.pushContainer(new Container());\n this.name(name);\n this.open();\n }\n open(open = true) {\n this.domElement.classList.toggle('muigui-closed', !open);\n this.domElement.classList.toggle('muigui-open', open);\n return this;\n }\n close() {\n return this.open(false);\n }\n name(name) {\n this.#labelElem.textContent = name;\n return this;\n }\n title(title) {\n return this.name(title);\n }\n toggleOpen() {\n this.open(!this.domElement.classList.contains('muigui-open'));\n return this;\n }\n}\n","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addDividing = new Controller()\nexport default class Label extends Controller {\n constructor(text) {\n super('muigui-label');\n this.text(text);\n }\n text(text) {\n this.domElement.textContent = text;\n return this;\n }\n}","function noop() {\n}\n\nexport function computeRelativePosition(elem, event, start) {\n const rect = elem.getBoundingClientRect();\n const x = event.clientX - rect.left;\n const y = event.clientY - rect.top;\n const nx = x / rect.width;\n const ny = y / rect.height;\n start = start || [x, y];\n const dx = x - start[0];\n const dy = y - start[1];\n const ndx = dx / rect.width;\n const ndy = dy / rect.width;\n return {x, y, nx, ny, dx, dy, ndx, ndy};\n}\n\nexport function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}) {\n let start;\n const pointerMove = function (event) {\n const e = {\n type: 'move',\n ...computeRelativePosition(elem, event, start),\n };\n onMove(e);\n };\n\n const pointerUp = function (event) {\n elem.releasePointerCapture(event.pointerId);\n elem.removeEventListener('pointermove', pointerMove);\n elem.removeEventListener('pointerup', pointerUp);\n\n document.body.style.backgroundColor = '';\n\n onUp('up');\n };\n\n const pointerDown = function (event) {\n elem.addEventListener('pointermove', pointerMove);\n elem.addEventListener('pointerup', pointerUp);\n elem.setPointerCapture(event.pointerId);\n\n const rel = computeRelativePosition(elem, event);\n start = [rel.x, rel.y];\n onDown({\n type: 'down',\n ...rel,\n });\n };\n\n elem.addEventListener('pointerdown', pointerDown);\n\n return function () {\n elem.removeEventListener('pointerdown', pointerDown);\n };\n}","import { createElem, getNewId } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp } from '../libs/utils.js';\nimport EditView from './EditView.js';\nimport {\n hexToFloatRGB,\n hexToFloatRGBA,\n hsv01ToRGBFloat,\n hsva01ToRGBAFloat,\n rgbFloatToHSV01,\n rgbaFloatToHSVA01,\n floatRGBToHex,\n floatRGBAToHex,\n rgbaFloatToHsla01,\n} from '../libs/color-utils.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nconst svg = `\n\n\n\n`;\n\nfunction connectFillTargets(elem) {\n elem.querySelectorAll('[data-src]').forEach(srcElem => {\n const id = getNewId();\n srcElem.id = id;\n elem.querySelectorAll(`[data-target=${srcElem.dataset.src}]`).forEach(targetElem => {\n targetElem.setAttribute('fill', `url(#${id})`);\n });\n });\n return elem;\n}\n\n// Was originally going to make alpha an option. Issue is\n// hard coded conversions?\nexport default class ColorChooserView extends EditView {\n #to;\n #from;\n #satLevelElem;\n #circleElem;\n #hueUIElem;\n #hueElem;\n #hueCursorElem;\n #alphaUIElem;\n #alphaElem;\n #alphaCursorElem;\n #hsva;\n #skipHueUpdate;\n #skipSatLevelUpdate;\n #skipAlphaUpdate;\n #options = {\n converters: identity,\n alpha: false,\n };\n #convertInternalToHex;\n #convertHexToInternal;\n\n constructor(setter, options) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n this.#satLevelElem = this.domElement.children[0];\n this.#hueUIElem = this.domElement.children[1];\n this.#alphaUIElem = this.domElement.children[2];\n connectFillTargets(this.#satLevelElem);\n connectFillTargets(this.#hueUIElem);\n connectFillTargets(this.#alphaUIElem);\n this.#circleElem = this.$('.muigui-color-chooser-circle');\n this.#hueElem = this.$('[data-src=muigui-color-chooser-hue]');\n this.#hueCursorElem = this.$('.muigui-color-chooser-hue-cursor');\n this.#alphaElem = this.$('[data-src=muigui-color-chooser-alpha]');\n this.#alphaCursorElem = this.$('.muigui-color-chooser-alpha-cursor');\n\n const handleSatLevelChange = (e) => {\n const s = clamp(e.nx, 0, 1);\n const v = clamp(e.ny, 0, 1);\n this.#hsva[1] = s;\n this.#hsva[2] = (1 - v);\n this.#skipHueUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleHueChange = (e) => {\n const h = clamp(e.nx, 0, 1);\n this.#hsva[0] = h;\n this.#skipSatLevelUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleAlphaChange = (e) => {\n const a = clamp(e.nx, 0, 1);\n this.#hsva[3] = a;\n this.#skipHueUpdate = true;\n this.#skipSatLevelUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n addTouchEvents(this.#satLevelElem, {\n onDown: handleSatLevelChange,\n onMove: handleSatLevelChange,\n });\n addTouchEvents(this.#hueUIElem, {\n onDown: handleHueChange,\n onMove: handleHueChange,\n });\n addTouchEvents(this.#alphaUIElem, {\n onDown: handleAlphaChange,\n onMove: handleAlphaChange,\n });\n this.setOptions(options);\n }\n updateDisplay(newV) {\n if (!this.#hsva) {\n this.#hsva = this.#convertHexToInternal(this.#to(newV));\n }\n {\n const [h, s, v, a = 1] = this.#convertHexToInternal(this.#to(newV));\n // Don't copy the hue if it was un-computable.\n if (!this.#skipHueUpdate) {\n this.#hsva[0] = s > 0.001 && v > 0.001 ? h : this.#hsva[0];\n }\n if (!this.#skipSatLevelUpdate) {\n this.#hsva[1] = s;\n this.#hsva[2] = v;\n }\n if (!this.#skipAlphaUpdate) {\n this.#hsva[3] = a;\n }\n }\n {\n const [h, s, v, a] = this.#hsva;\n const [hue, sat, lum] = rgbaFloatToHsla01(hsva01ToRGBAFloat(this.#hsva));\n\n if (!this.#skipHueUpdate) {\n this.#hueCursorElem.setAttribute('transform', `translate(${h * 64}, 0)`);\n }\n this.#hueElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} 0% 100% / ${a})`);\n this.#hueElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} 100% 50% / ${a})`);\n if (!this.#skipAlphaUpdate) {\n this.#alphaCursorElem.setAttribute('transform', `translate(${a * 64}, 0)`);\n }\n this.#alphaElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 0)`);\n this.#alphaElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 1)`);\n\n if (!this.#skipSatLevelUpdate) {\n this.#circleElem.setAttribute('cx', `${s * 64}`);\n this.#circleElem.setAttribute('cy', `${(1 - v) * 48}`);\n }\n }\n this.#skipHueUpdate = false;\n this.#skipSatLevelUpdate = false;\n this.#skipAlphaUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}, alpha} = this.#options;\n this.#alphaUIElem.style.display = alpha ? '' : 'none';\n this.#convertInternalToHex = alpha\n ? v => floatRGBAToHex(hsva01ToRGBAFloat(v))\n : v => floatRGBToHex(hsv01ToRGBFloat(v));\n this.#convertHexToInternal = alpha\n ? v => rgbaFloatToHSVA01(hexToFloatRGBA(v))\n : v => rgbFloatToHSV01(hexToFloatRGB(v));\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import ElementView from '../views/ElementView.js';\nimport ValueController from './ValueController.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport { createElem } from '../libs/elem.js';\n/*\n\nholder = new TabHolder\ntab = holder.add(new Tab(\"name\"))\ntab.add(...)\n\n\npc = new PopdownController\ntop = pc.add(new Row())\ntop.add(new Button());\nvalues = topRow.add(new Div())\nbottom = pc.add(new Row());\n\n\n\npc = new PopdownController\npc.addTop\npc.addTop\n\npc.addBottom\n\n\n*/\n\nexport default class PopDownController extends ValueController {\n #top;\n #valuesView;\n #checkboxElem;\n #bottom;\n #options = {\n open: false,\n };\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-pop-down-controller');\n /*\n [ValueView\n [[B][values]] upper row\n [[ visual ]] lower row\n ]\n */\n this.#top = this.add(new ElementView('div', 'muigui-pop-down-top'));\n// this.#top.add(new CheckboxView(makeSetter(this.#options, 'open')));\n const checkboxElem = this.#top.addElem(createElem('input', {\n type: 'checkbox',\n onChange: () => {\n this.#options.open = checkboxElem.checked;\n this.updateDisplay();\n },\n }));\n this.#checkboxElem = checkboxElem;\n this.#valuesView = this.#top.add(new ElementView('div', 'muigui-pop-down-values'));\n this.#bottom = this.add(new ElementView('div', 'muigui-pop-down-bottom'));\n this.setOptions(options);\n }\n setKnobColor(bgCssColor/*, fgCssColor*/) {\n if (this.#checkboxElem) {\n this.#checkboxElem.style = `\n --range-color: ${bgCssColor};\n --value-bg-color: ${bgCssColor};\n `;\n }\n }\n updateDisplay() {\n super.updateDisplay();\n const {open} = this.#options;\n this.domElement.children[1].classList.toggle('muigui-open', open);\n this.domElement.children[1].classList.toggle('muigui-closed', !open);\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n super.setOptions(options);\n this.updateDisplay();\n }\n addTop(view) {\n return this.#valuesView.add(view);\n }\n addBottom(view) {\n return this.#bottom.add(view);\n }\n}","/* eslint-disable no-underscore-dangle */\nimport {\n colorFormatConverters,\n guessFormat,\n hasAlpha,\n hexToUint8RGB,\n hslToRgbUint8,\n rgbUint8ToHsl,\n uint8RGBToHex,\n} from '../libs/color-utils.js';\nimport ColorChooserView from '../views/ColorChooserView.js';\nimport TextView from '../views/TextView.js';\nimport PopDownController from './PopDownController.js';\n\nexport default class ColorChooser extends PopDownController {\n #colorView;\n #textView;\n #to;\n #setKnobHelper;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color-chooser');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#to = color.to;\n this.#textView = new TextView(this, {converters: text, alpha: hasAlpha(format)});\n this.#colorView = new ColorChooserView(this, {converters: color, alpha: hasAlpha(format)});\n this.addTop(this.#textView);\n this.addBottom(this.#colorView);\n // WTF! FIX!\n this.#setKnobHelper = () => {\n if (this.#to) {\n const hex6Or8 = this.#to(this.getValue());\n const hsl = rgbUint8ToHsl(hexToUint8RGB(hex6Or8));\n hsl[2] = (hsl[2] + 50) % 100;\n const hex = uint8RGBToHex(hslToRgbUint8(hsl));\n this.setKnobColor(`${hex6Or8.substring(0, 7)}FF`, hex);\n }\n };\n this.updateDisplay();\n }\n updateDisplay() {\n super.updateDisplay();\n if (this.#setKnobHelper) {\n this.#setKnobHelper();\n }\n }\n setOptions(options) {\n super.setOptions(options);\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport View from '../views/View.js';\n\nfunction showCSS(ob) {\n if (ob.prototype.css) {\n showCSS(ob.prototype);\n }\n}\n\nexport default class Layout extends View {\n static css = 'bar';\n constructor(tag, className) {\n super(createElem(tag, {className}));\n\n showCSS(this);\n }\n}\n\n/*\nclass ValueController ?? {\n const row = this.add(new Row());\n const label = row.add(new Label());\n const div = row.add(new Div());\n const row = div.add(new Row());\n}\n*/\n\n/*\nclass MyCustomThing extends ValueController {\n constructor(object, property, options) {\n const topRow = this.add(new Row());\n const bottomRow = this.add(new Row());\n topRow.add(new NumberView());\n topRow.add(new NumberView());\n topRow.add(new NumberView());\n topRow.add(new NumberView());\n bottomRow.add(new DirectionView());\n bottomRow.add(new DirectionView());\n bottomRow.add(new DirectionView());\n bottomRow.add(new DirectionView());\n }\n}\n new Grid([\n [new\n ]\n */","import Layout from './Layout.js';\n\nexport default class Column extends Layout {\n constructor() {\n super('div', 'muigui-row');\n }\n}\n","import Layout from './Layout.js';\n\nexport default class Frame extends Layout {\n static css = 'foo';\n constructor() {\n super('div', 'muigui-frame');\n }\n static get foo() {\n return 'boo';\n }\n}\n","import Layout from './Layout.js';\n\nexport default class Grid extends Layout {\n constructor() {\n super('div', 'muigui-grid');\n }\n}\n","import Layout from './Layout.js';\n\nexport default class Row extends Layout {\n constructor() {\n super('div', 'muigui-row');\n }\n}\n","import css from './styles/muigui.css.js';\nimport {createElem} from './libs/elem.js';\nimport {createController} from './controllers/create-controller.js';\nimport {\n mapRange,\n makeRangeConverters,\n makeRangeOptions,\n makeMinMaxPair,\n} from './libs/utils.js';\nimport {\n converters\n} from './libs/conversions.js';\nimport {\n hasAlpha,\n guessFormat,\n} from './libs/color-utils.js';\nimport Canvas from './controllers/Canvas.js';\nimport Color from './controllers/Color.js';\nimport Divider from './controllers/Divider.js';\nimport Folder from './controllers/Folder.js';\nimport Label from './controllers/Label.js';\nimport Controller from './controllers/Controller.js';\nimport ColorChooser from './controllers/ColorChooser.js';\n\nimport Column from './layout/Column.js';\nimport Frame from './layout/Frame.js';\nimport Grid from './layout/Grid.js';\nimport Row from './layout/Row.js';\n\nexport {\n Column,\n Frame,\n Grid,\n Row,\n};\n\nexport class GUIFolder extends Folder {\n add(object, property, ...args) {\n const controller = object instanceof Controller\n ? object\n : createController(object, property, ...args);\n return this.addController(controller);\n }\n addCanvas(name) {\n return this.addController(new Canvas(name));\n }\n addColor(object, property, options = {}) {\n const value = object[property];\n if (hasAlpha(options.format || guessFormat(value))) {\n return this.addController(new ColorChooser(object, property, options));\n } else {\n return this.addController(new Color(object, property, options));\n }\n }\n addDivider() {\n return this.addController(new Divider());\n }\n addFolder(name) {\n return this.addController(new GUIFolder(name));\n }\n addLabel(text) {\n return this.addController(new Label(text));\n }\n}\n\nclass MuiguiElement extends HTMLElement {\n constructor() {\n super();\n this.shadow = this.attachShadow({mode: 'open'});\n }\n}\n\ncustomElements.define('muigui-element', MuiguiElement);\n\nconst baseStyleSheet = new CSSStyleSheet();\nbaseStyleSheet.replaceSync(css.default);\nconst userStyleSheet = new CSSStyleSheet();\n\nfunction makeStyleSheetUpdater(styleSheet) {\n let newCss;\n let newCssPromise;\n\n function updateStyle() {\n if (newCss && !newCssPromise) {\n const s = newCss;\n newCss = undefined;\n newCssPromise = styleSheet.replace(s).then(() => {\n newCssPromise = undefined;\n updateStyle();\n });\n }\n }\n\n return function updateStyleSheet(css) {\n newCss = css;\n updateStyle();\n };\n}\n\nconst updateBaseStyle = makeStyleSheetUpdater(baseStyleSheet);\nconst updateUserStyle = makeStyleSheetUpdater(userStyleSheet);\n\nexport class GUI extends GUIFolder {\n static converters = converters;\n static mapRange = mapRange;\n static makeRangeConverters = makeRangeConverters;\n static makeRangeOptions = makeRangeOptions;\n static makeMinMaxPair = makeMinMaxPair;\n #localStyleSheet = new CSSStyleSheet();\n\n constructor(options = {}) {\n super('Controls', 'muigui-root');\n if (options instanceof HTMLElement) {\n options = {parent: options};\n }\n const {\n autoPlace = true,\n width,\n title = 'Controls',\n } = options;\n let {\n parent,\n } = options;\n\n if (width) {\n this.domElement.style.width = /^\\d+$/.test(width) ? `${width}px` : width;\n }\n if (parent === undefined && autoPlace) {\n parent = document.body;\n this.domElement.classList.add('muigui-auto-place');\n }\n if (parent) {\n const muiguiElement = createElem('muigui-element');\n muiguiElement.shadowRoot.adoptedStyleSheets = [baseStyleSheet, userStyleSheet, this.#localStyleSheet];\n muiguiElement.shadow.appendChild(this.domElement);\n parent.appendChild(muiguiElement);\n }\n if (title) {\n this.title(title);\n }\n this.domElement.classList.add('muigui', 'muigui-colors');\n }\n setStyle(css) {\n this.#localStyleSheet.replace(css);\n }\n static setBaseStyles(css) {\n updateBaseStyle(css);\n }\n static getBaseStyleSheet() {\n return baseStyleSheet;\n }\n static setUserStyles(css) {\n updateUserStyle(css);\n }\n static getUserStyleSheet() {\n return userStyleSheet;\n }\n static setTheme(name) {\n GUI.setBaseStyles(`${css.default}\\n${css.themes[name] || ''}`);\n }\n}\n\nexport default GUI;\n","function noop() {\n}\n\nconst keyDirections = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n\n// This probably needs to be global\nexport function addKeyboardEvents(elem, {onDown = noop, onUp = noop}) {\n const keyDown = function (event) {\n const mult = event.shiftKey ? 10 : 1;\n const [dx, dy] = (keyDirections[event.key] || [0, 0]).map(v => v * mult);\n const fn = event.type === 'keydown' ? onDown : onUp;\n fn({\n type: event.type.substring(3),\n dx,\n dy,\n event,\n });\n };\n\n elem.addEventListener('keydown', keyDown);\n elem.addEventListener('keyup', keyDown);\n\n return function () {\n elem.removeEventListener('keydown', keyDown);\n elem.removeEventListener('keyup', keyDown);\n };\n}","export function assert(truthy, msg = '') {\n if (!truthy) {\n throw new Error(msg);\n }\n}","import { assert } from '../libs/assert.js';\n\nfunction getEllipsePointForAngle(cx, cy, rx, ry, phi, theta) {\n const m = Math.abs(rx) * Math.cos(theta);\n const n = Math.abs(ry) * Math.sin(theta);\n\n return [\n cx + Math.cos(phi) * m - Math.sin(phi) * n,\n cy + Math.sin(phi) * m + Math.cos(phi) * n,\n ];\n}\n\nfunction getEndpointParameters(cx, cy, rx, ry, phi, theta, dTheta) {\n const [x1, y1] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta);\n const [x2, y2] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta + dTheta);\n\n const fa = Math.abs(dTheta) > Math.PI ? 1 : 0;\n const fs = dTheta > 0 ? 1 : 0;\n\n return { x1, y1, x2, y2, fa, fs };\n}\n\nexport function arc(cx, cy, r, start, end) {\n assert(Math.abs(start - end) <= Math.PI * 2);\n assert(start >= -Math.PI && start <= Math.PI * 2);\n assert(start <= end);\n assert(end >= -Math.PI && end <= Math.PI * 4);\n\n const { x1, y1, x2, y2, fa, fs } = getEndpointParameters(cx, cy, r, r, 0, start, end - start);\n return Math.abs(Math.abs(start - end) - Math.PI * 2) > Number.EPSILON\n ? `M${cx} ${cy} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2} L${cx} ${cy}`\n : `M${x1} ${y1} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2}`;\n}\n","import { identity } from '../libs/conversions.js';\nimport { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { arc } from '../libs/svg.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, euclideanModulo, lerp, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nconst twoPiMod = v => euclideanModulo(v + Math.PI, Math.PI * 2) - Math.PI;\n\nexport default class DirectionView extends EditView {\n #arrowElem;\n #rangeElem;\n #lastV;\n #wrap;\n #options = {\n step: 1,\n min: -180,\n max: 180,\n\n /*\n --------\n / -π/2 \\\n / | \\\n |<- -π * |\n | * 0 ->| zero is down the positive X axis\n |<- +π * |\n \\ | /\n \\ π/2 /\n --------\n */\n dirMin: -Math.PI,\n dirMax: Math.PI,\n //dirMin: Math.PI * 0.5,\n //dirMax: Math.PI * 2.5,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 7:30 to 10:30\n //dirMax: -Math.PI * 0.75,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 1:30\n //dirMax: -Math.PI * 0.25,\n //dirMin: Math.PI * 0.25, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.25,\n wrap: undefined,\n converters: identity,\n };\n\n constructor(setter, options = {}) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n className: 'muigui-direction muigui-no-scroll',\n innerHTML: svg,\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n let tempV = this.#lastV + delta;\n if (this.#wrap) {\n tempV = euclideanModulo(tempV - min, max - min) + min;\n }\n const newV = clamp(stepify(tempV, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n const handleTouch = (e) => {\n const {min, max, step, dirMin, dirMax} = this.#options;\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n const a = Math.atan2(ny, nx);\n\n const center = (dirMin + dirMax) / 2;\n\n const centeredAngle = twoPiMod(a - center);\n const centeredStart = twoPiMod(dirMin - center);\n const diff = dirMax - dirMin;\n\n const n = clamp((centeredAngle - centeredStart) / (diff), 0, 1);\n const newV = stepify(min + (max - min) * n, v => v, step);\n setter.setValue(newV);\n };\n addTouchEvents(this.domElement, {\n onDown: handleTouch,\n onMove: handleTouch,\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n this.#arrowElem = this.$('#muigui-arrow');\n this.#rangeElem = this.$('#muigui-range');\n this.setOptions(options);\n }\n updateDisplay(v) {\n this.#lastV = v;\n const {min, max} = this.#options;\n const n = (v - min) / (max - min);\n const angle = lerp(this.#options.dirMin, this.#options.dirMax, n);\n this.#arrowElem.style.transform = `rotate(${angle}rad)`;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {dirMin, dirMax, wrap} = this.#options;\n this.#wrap = wrap !== undefined\n ? wrap\n : Math.abs(dirMin - dirMax) >= Math.PI * 2 - Number.EPSILON;\n const [min, max] = dirMin < dirMax ? [dirMin, dirMax] : [dirMax , dirMin];\n this.#rangeElem.setAttribute('d', arc(0, 0, 28.87, min, max));\n }\n}\n","import { identity } from '../libs/conversions.js';\nimport DirectionView from '../views/DirectionView.js';\nimport NumberView from '../views/NumberView.js';\n// import ValueController from './ValueController.js';\nimport PopDownController from './PopDownController.js';\n\n\n// deg2rad\n// where is 0\n// range (0, 360), (-180, +180), (0,0) Really this is a range\n\nexport default class Direction extends PopDownController {\n #options;\n constructor(object, property, options) {\n super(object, property, 'muigui-direction');\nthis.#options = options; // FIX\n this.addTop(new NumberView(this,\nidentity));\n this.addBottom(new DirectionView(this, options));\n this.updateDisplay();\n }\n}\n\n","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport EditView from './EditView.js';\n\nexport default class RadioGridView extends EditView {\n #values;\n\n constructor(setter, keyValues, cols = 3) {\n const values = [];\n const name = makeId();\n super(createElem('div', {}, keyValues.map(([key, value], ndx) => {\n values.push(value);\n return createElem('label', {}, [\n createElem('input', {\n type: 'radio',\n name,\n value: ndx,\n onChange: function () {\n if (this.checked) {\n setter.setFinalValue(that.#values[this.value]);\n }\n },\n }),\n createElem('button', {\n type: 'button',\n textContent: key,\n onClick: function () {\n this.previousElementSibling.click();\n },\n }),\n ]);\n })));\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.#values = values;\n this.cols(cols);\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n for (let i = 0; i < this.domElement.children.length; ++i) {\n this.domElement.children[i].children[0].checked = i === ndx;\n }\n }\n cols(cols) {\n this.domElement.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;\n }\n}\n","import RadioGridView from '../views/RadioGridView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class RadioGrid extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-radio-grid');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {\n keyValues: keyValuesInput,\n cols = 3,\n } = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new RadioGridView(this, keyValues, cols));\n this.updateDisplay();\n }\n}","export function onResize(elem, callback) {\n new ResizeObserver(() => {\n callback({rect: elem.getBoundingClientRect(), elem});\n }).observe(elem);\n}\n\nexport function onResizeSVGNoScale(elem, hAnchor, vAnchor, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.setAttribute('viewBox', `-${width * hAnchor} -${height * vAnchor} ${width} ${height}`);\n callback({elem, rect});\n });\n}\n\nexport function onResizeCanvas(elem, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.width = width;\n elem.height = height;\n callback({elem, rect});\n });\n}\n","import { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nfunction createSVGTicks(start, end, step, min, max, height) {\n const p = [];\n if (start < min) {\n start += stepify(min - start, v => v, step);\n }\n end = Math.min(end, max);\n for (let i = start; i <= end; i += step) {\n p.push(`M${i} 0 l0 ${height}`);\n }\n return p.join(' ');\n}\n\nfunction createSVGNumbers(start, end, unitSize, unit, minusSize, min, max, labelFn) {\n const texts = [];\n if (start < min) {\n start += stepify(min - start, v => v, unitSize);\n }\n end = Math.min(end, max);\n const digits = Math.max(0, -Math.log10(unit));\n const f = v => labelFn(v.toFixed(digits));\n for (let i = start; i <= end; i += unitSize) {\n texts.push(`= 0 ? i : (i - minusSize / 2) }\" y=\"0\">${f(i / unitSize * unit)}`);\n }\n return texts.join('\\n');\n}\n\nfunction computeSizeOfMinus(elem) {\n const oldHTML = elem.innerHTML;\n elem.innerHTML = '- ';\n const text = elem.querySelector('text');\n const size = text.getComputedTextLength();\n elem.innerHTML = oldHTML;\n return size;\n}\n\nexport default class SliderView extends EditView {\n #svgElem;\n #originElem;\n #ticksElem;\n #thicksElem;\n #numbersElem;\n #leftGradElem;\n #rightGradElem;\n #width;\n #height;\n #lastV;\n #minusSize;\n #options = {\n min: -100,\n max: 100,\n step: 1,\n unit: 10,\n unitSize: 10,\n ticksPerUnit: 5,\n labelFn: v => v,\n tickHeight: 1,\n limits: true,\n thicksColor: undefined,\n orientation: undefined,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-v-scroll',\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(this.#lastV + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.#svgElem = this.$('svg');\n this.#originElem = this.$('#muigui-origin');\n this.#ticksElem = this.$('#muigui-ticks');\n this.#thicksElem = this.$('#muigui-thicks');\n this.#numbersElem = this.$('#muigui-numbers');\n this.#leftGradElem = this.$('#muigui-left-grad');\n this.#rightGradElem = this.$('#muigui-right-grad');\n this.setOptions(options);\n let startV;\n addTouchEvents(this.domElement, {\n onDown: () => {\n startV = this.#lastV;\n },\n onMove: (e) => {\n const {min, max, unitSize, unit, step} = this.#options;\n const newV = clamp(stepify(startV - e.dx / unitSize * unit, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n onResizeSVGNoScale(this.#svgElem, 0.5, 0, ({rect: {width}}) => {\n this.#leftGradElem.setAttribute('x', -width / 2);\n this.#rightGradElem.setAttribute('x', width / 2 - 20);\n this.#minusSize = computeSizeOfMinus(this.#numbersElem);\n this.#width = width;\n this.#updateSlider();\n });\n }\n // |--------V--------|\n // . . | . . . | . . . |\n //\n #updateSlider() {\n // There's no size if ResizeObserver has not fired yet.\n if (!this.#width || this.#lastV === undefined) {\n return;\n }\n const {\n labelFn,\n limits,\n min,\n max,\n orientation,\n tickHeight,\n ticksPerUnit,\n unit,\n unitSize,\n thicksColor,\n } = this.#options;\n const unitsAcross = Math.ceil(this.#width / unitSize);\n const center = this.#lastV;\n const centerUnitSpace = center / unit;\n const startUnitSpace = Math.round(centerUnitSpace - unitsAcross);\n const endUnitSpace = startUnitSpace + unitsAcross * 2;\n const start = startUnitSpace * unitSize;\n const end = endUnitSpace * unitSize;\n const minUnitSpace = limits ? min * unitSize / unit : start;\n const maxUnitSpace = limits ? max * unitSize / unit : end;\n const height = labelFn(1) === '' ? 10 : 5;\n if (ticksPerUnit > 1) {\n this.#ticksElem.setAttribute('d', createSVGTicks(start, end, unitSize / ticksPerUnit, minUnitSpace, maxUnitSpace, height * tickHeight));\n }\n this.#thicksElem.style.stroke = thicksColor; //setAttribute('stroke', thicksColor);\n this.#thicksElem.setAttribute('d', createSVGTicks(start, end, unitSize, minUnitSpace, maxUnitSpace, height));\n this.#numbersElem.innerHTML = createSVGNumbers(start, end, unitSize, unit, this.#minusSize, minUnitSpace, maxUnitSpace, labelFn);\n this.#originElem.setAttribute('transform', `translate(${-this.#lastV * unitSize / unit} 0)`);\n this.#svgElem.classList.toggle('muigui-slider-up', orientation === 'up');\n }\n updateDisplay(v) {\n this.#lastV = v;\n this.#updateSlider();\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n return this;\n }\n}\n","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport SliderView from '../views/SliderView.js';\n\nexport default class Slider extends ValueController {\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-slider');\n this.add(new SliderView(this, options));\n this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nexport default class Vec2View extends EditView {\n #svgElem;\n #arrowElem;\n #circleElem;\n #lastV = [];\n\n constructor(setter) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n const onTouch = (e) => {\n const {width, height} = this.#svgElem.getBoundingClientRect();\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n setter.setValue([nx * width * 0.5, ny * height * 0.5]);\n };\n addTouchEvents(this.domElement, {\n onDown: onTouch,\n onMove: onTouch,\n });\n this.#svgElem = this.$('svg');\n this.#arrowElem = this.$('#muigui-arrow');\n this.#circleElem = this.$('#muigui-circle');\n onResizeSVGNoScale(this.#svgElem, 0.5, 0.5, () => this.#updateDisplayImpl);\n }\n #updateDisplayImpl() {\n const [x, y] = this.#lastV;\n this.#arrowElem.setAttribute('d', `M0,0L${x},${y}`);\n this.#circleElem.setAttribute('transform', `translate(${x}, ${y})`);\n }\n updateDisplay(v) {\n this.#lastV[0] = v[0];\n this.#lastV[1] = v[1];\n this.#updateDisplayImpl();\n }\n}\n","import NumberView from '../views/NumberView.js';\nimport Vec2View from '../views/Vec2View.js';\nimport PopDownController from './PopDownController.js';\nimport { strToNumber } from '../libs/conversions.js';\n\n// TODO: zoom with wheel and pinch?\n// TODO: grid?\n// // options\n// scale:\n// range: number (both x and y + /)\n// range: array (min, max)\n// xRange:\n// deg/rad/turn\n\nexport default class Vec2 extends PopDownController {\n constructor(object, property) {\n super(object, property, 'muigui-vec2');\n\n const makeSetter = (ndx) => {\n return {\n setValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setValue(newV);\n },\n setFinalValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setFinalValue(newV);\n },\n };\n };\n\n this.addTop(new NumberView(makeSetter(0), {\n converters: {\n to: v => v[0],\n from: strToNumber.from,\n },\n }));\n this.addTop(new NumberView(makeSetter(1), {\n converters: {\n to: v => v[1],\n from: strToNumber.from,\n },\n }));\n this.addBottom(new Vec2View(this));\n this.updateDisplay();\n }\n}\n"],"names":["clamp","euclideanModulo","lerp","identity","noop","svg"],"mappings":";AAAA,UAAe;AACf,EAAE,OAAO,EAAE,CAAC;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,MAAM,EAAE;AACR,EAAE,OAAO,EAAE,EAAE;AACb,EAAE,KAAK,EAAE,CAAC;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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EAAE;AAC9C,MAAM,UAAU,EAAE;AAClB,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACrB,QAAQ,IAAI,EAAE,WAAW,CAAC,IAAI;AAC9B,OAAO;AACP,KAAK,CAAC,CAAC,CAAC;AACR,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;AACzB,GAAG;AACH;;;;"}
\ No newline at end of file
diff --git a/dist/0.x/muigui.module.min.js b/dist/0.x/muigui.module.min.js
new file mode 100644
index 0000000..6716365
--- /dev/null
+++ b/dist/0.x/muigui.module.min.js
@@ -0,0 +1,2 @@
+var t={default:'\n.muigui {\n --bg-color: #ddd;\n --color: #222;\n --contrast-color: #eee;\n --value-color: #145 ;\n --value-bg-color: #eeee;\n --disabled-color: #999;\n --menu-bg-color: #f8f8f8;\n --menu-sep-color: #bbb;\n --hover-bg-color: #999;\n --focus-color: #68C;\n --range-color: #888888;\n --invalid-color: #FF0000;\n --selected-color: rgb(255, 255, 255, 0.9);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n}\n\n@media (prefers-color-scheme: dark) {\n .muigui {\n --bg-color: #222222;\n --color: #dddddd;\n --contrast-color: #000;\n --value-color: #43e5f7;\n --value-bg-color: #444444;\n --disabled-color: #666666;\n --menu-bg-color: #080808;\n --menu-sep-color: #444444;\n --hover-bg-color: #666666;\n --focus-color: #88AAFF;\n --range-color: #888888;\n --invalid-color: #FF6666;\n --selected-color: rgba(255, 255, 255, 0.3);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n }\n}\n\n.muigui {\n --width: 250px;\n --label-width: 45%;\n --number-width: 40%;\n\n\n --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;\n --font-size: 11px;\n --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;\n --font-size-mono: 11px;\n\n --line-height: 1.7em;\n --border-radius: 0px;\n\n width: var(--width);\n font-family: var(--font-family);\n font-size: var(--font-size);\n box-sizing: border-box;\n line-height: 100%;\n}\n.muigui * {\n box-sizing: inherit;\n}\n\n.muigui-no-scroll {\n touch-action: none;\n}\n.muigui-no-h-scroll {\n touch-action: pan-y;\n}\n.muigui-no-v-scroll {\n touch-action: pan-x;\n}\n\n.muigui-invalid-value {\n background-color: red !important;\n color: white !important;\n}\n\n.muigui-grid {\n display: grid;\n}\n.muigui-rows {\n display: flex;\n flex-direction: column;\n\n min-height: 20px;\n border: 2px solid red;\n}\n.muigui-columns {\n display: flex;\n flex-direction: row;\n\n height: 20px;\n border: 2px solid green;\n}\n.muigui-rows>*,\n.muigui-columns>* {\n flex: 1 1 auto;\n align-items: stretch;\n min-height: 0;\n min-width: 0;\n}\n\n.muigui-row {\n border: 2px solid yellow;\n min-height: 10px\n}\n.muigui-column {\n border: 2px solid lightgreen;\n}\n\n/* -------- */\n\n.muigui-show { /* */ }\n.muigui-hide { \n display: none !important;\n}\n.muigui-disabled {\n pointer-events: none;\n --color: var(--disabled-color) !important;\n --value-color: var(--disabled-color) !important;\n --range-left-color: var(--disabled-color) !important;\n}\n\n.muigui canvas,\n.muigui svg {\n display: block;\n border-radius: var(--border-radius);\n}\n.muigui canvas {\n background-color: var(--value-bg-color);\n}\n\n.muigui-controller {\n min-width: 0;\n min-height: var(--line-height);\n}\n.muigui-root,\n.muigui-menu {\n display: flex;\n flex-direction: column;\n position: relative;\n user-select: none;\n height: fit-content;\n margin: 0;\n padding-bottom: 0.1em;\n border-radius: var(--border-radius);\n}\n.muigui-menu {\n border-bottom: 1px solid var(--menu-sep-color);\n}\n\n.muigui-root>button:nth-child(1),\n.muigui-menu>button:nth-child(1) {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n position: relative;\n text-align: left;\n color: var(--color);\n background-color: var(--menu-bg-color);\n min-height: var(--line-height);\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n cursor: pointer;\n border-radius: var(--border-radius);\n}\n.muigui-root>div:nth-child(2),\n.muigui-menu>div:nth-child(2) {\n flex: 1 1 auto;\n}\n\n.muigui-controller {\n margin-left: 0.2em;\n margin-right: 0.2em;\n}\n.muigui-root.muigui-controller,\n.muigui-menu.muigui-controller {\n margin-left: 0;\n margin-right: 0;\n}\n.muigui-controller>*:nth-child(1) {\n flex: 1 0 var(--label-width);\n min-width: 0;\n white-space: pre;\n}\n.muigui-controller>label:nth-child(1) {\n place-content: center start;\n display: inline-grid;\n overflow: hidden;\n}\n.muigui-controller>*:nth-child(2) {\n flex: 1 1 75%;\n min-width: 0;\n}\n\n/* -----------------------------------------\n a label controller is [[label][value]]\n*/\n\n.muigui-label-controller {\n display: flex;\n margin: 0.4em 0 0.4em 0;\n word-wrap: initial;\n align-items: stretch;\n}\n\n.muigui-value {\n display: flex;\n align-items: stretch;\n}\n.muigui-value>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n.muigui-value>*:nth-child(1) {\n flex: 1 1 calc(100% - var(--number-width));\n}\n.muigui-value>*:nth-child(2) {\n flex: 1 1 var(--number-width);\n margin-left: 0.2em;\n}\n\n/* fix! */\n.muigui-open>button>label::before,\n.muigui-closed>button>label::before {\n width: 1.25em;\n height: var(--line-height);\n display: inline-grid;\n place-content: center start;\n pointer-events: none;\n}\n.muigui-open>button>label::before {\n content: "ⓧ"; /*"▼";*/\n}\n.muigui-closed>button>label::before {\n content: "⨁"; /*"▶";*/\n}\n.muigui-open>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 0.5s ease-out;\n max-height: 100vh;\n overflow: auto;\n opacity: 1;\n}\n\n.muigui-closed>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 1s;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n}\n\n/* ---- popdown ---- */\n\n.muigui-pop-down-top {\n display: flex;\n}\n/* fix? */\n.muigui-value>*:nth-child(1).muigui-pop-down-top {\n flex: 0;\n}\n.muigui-pop-down-bottom {\n\n}\n\n.muigui-pop-down-values {\n min-width: 0;\n display: flex;\n}\n.muigui-pop-down-values>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.muigui-value.muigui-pop-down-controller {\n flex-direction: column;\n}\n\n.muigui-pop-down-top input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-pop-down-top input[type=checkbox]::before {\n content: "+";\n display: grid;\n place-content: center;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n color: var(--value-bg-color);\n width: calc(var(--line-height) - 4px);\n height: calc(var(--line-height) - 4px);\n}\n\n.muigui-pop-down-top input[type=checkbox]:checked::before {\n content: "X";\n}\n\n\n/* ---- select ---- */\n\n.muigui select,\n.muigui option,\n.muigui input,\n.muigui button {\n color: var(--value-color);\n background-color: var(--value-bg-color);\n font-family: var(--font-family);\n font-size: var(--font-size);\n border: none;\n margin: 0;\n border-radius: var(--border-radius);\n}\n.muigui select {\n appearance: none;\n margin: 0;\n margin-left: 0; /*?*/\n overflow: hidden; /* Safari */\n}\n\n.muigui select:focus,\n.muigui input:focus,\n.muigui button:focus {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui select:hover,\n.muigui option:hover,\n.muigui input:hover,\n.muigui button:hover {\n background-color: var(--hover-bg-color); \n}\n\n/* ------ [ label ] ------ */\n\n.muigui-label {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n padding-top: 0.4em;\n padding-bottom: 0.3em;\n place-content: center start;\n background-color: var(--menu-bg-color);\n white-space: pre;\n border-radius: var(--border-radius);\n}\n\n/* ------ [ divider] ------ */\n\n.muigui-divider {\n min-height: 6px;\n border-top: 2px solid var(--menu-sep-color);\n margin-top: 6px;\n}\n\n/* ------ [ button ] ------ */\n\n.muigui-button {\n display: grid;\n\n}\n.muigui-button button {\n border: none;\n color: var(--value-color);\n background-color: var(--button-bg-color);\n cursor: pointer;\n place-content: center center;\n}\n\n/* ------ [ color ] ------ */\n\n.muigui-color>div {\n overflow: hidden;\n position: relative;\n margin-left: 0;\n margin-right: 0; /* why? */\n max-width: var(--line-height);\n border-radius: var(--border-radius);\n}\n\n.muigui-color>div:focus-within {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui-color input[type=color] {\n border: none;\n padding: 0;\n background: inherit;\n cursor: pointer;\n position: absolute;\n width: 200%;\n left: -10px;\n top: -10px;\n height: 200%;\n}\n.muigui-disabled canvas,\n.muigui-disabled svg,\n.muigui-disabled img,\n.muigui-disabled .muigui-color input[type=color] {\n opacity: 0.2;\n}\n\n/* ------ [ checkbox ] ------ */\n\n.muigui-checkbox>label:nth-child(2) {\n display: grid;\n place-content: center start;\n margin: 0;\n}\n\n.muigui-checkbox input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-checkbox input[type=checkbox]::before {\n content: "";\n color: var(--value-color);\n display: grid;\n place-content: center;\n}\n\n.muigui-checkbox input[type=checkbox]:checked::before {\n content: "✔";\n}\n\n.muigui input[type=number]::-webkit-inner-spin-button, \n.muigui input[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none;\n appearance: none;\n margin: 0; \n}\n.muigui input[type=number] {\n -moz-appearance: textfield;\n}\n\n/* ------ [ radio grid ] ------ */\n\n.muigui-radio-grid>div {\n display: grid;\n gap: 2px;\n}\n\n.muigui-radio-grid input {\n appearance: none;\n display: none;\n}\n\n.muigui-radio-grid button {\n color: var(--color);\n width: 100%;\n text-align: left;\n}\n\n.muigui-radio-grid input:checked + button {\n color: var(--value-color);\n background-color: var(--selected-color);\n}\n\n/* ------ [ color-chooser ] ------ */\n\n.muigui-color-chooser-cursor {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n.muigui-color-chooser-circle {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n\n\n/* ------ [ vec2 ] ------ */\n\n.muigui-vec2 svg {\n background-color: var(--value-bg-color);\n}\n\n.muigui-vec2-axis {\n stroke: 1px;\n stroke: var(--focus-color);\n}\n\n.muigui-vec2-line {\n stroke-width: 1px;\n stroke: var(--value-color);\n fill: var(--value-color);\n}\n\n/* ------ [ direction ] ------ */\n\n.muigui-direction svg {\n background-color: rgba(0,0,0,0.2);\n}\n\n.muigui-direction:focus-within svg {\n outline: none;\n}\n.muigui-direction-range {\n fill: var(--value-bg-color);\n}\n.muigui-direction svg:focus {\n outline: none;\n}\n.muigui-direction svg:focus .muigui-direction-range {\n stroke-width: 0.5px;\n stroke: var(--focus-color);\n}\n\n.muigui-direction-arrow {\n fill: var(--value-color);\n}\n\n/* ------ [ slider ] ------ */\n\n.muigui-slider>div {\n display: flex;\n align-items: stretch;\n height: var(--line-height);\n}\n.muigui-slider svg {\n flex: 1 1 auto;\n}\n.muigui-slider .muigui-slider-up #muigui-orientation {\n transform: scale(1, -1) translateY(-100%);\n}\n\n.muigui-slider .muigui-slider-up #muigui-number-orientation {\n transform: scale(1,-1);\n}\n\n.muigui-ticks {\n stroke: var(--range-color);\n}\n.muigui-thicks {\n stroke: var(--color);\n stroke-width: 2px;\n}\n.muigui-svg-text {\n fill: var(--color);\n font-size: 7px;\n}\n.muigui-mark {\n fill: var(--value-color);\n}\n\n/* ------ [ range ] ------ */\n\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: transparent;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n margin-top: calc((var(--line-height) - 2px) / -2);\n width: calc(var(--line-height) - 2px);\n height: calc(var(--line-height) - 2px);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n border: 1px solid var(--menu-sep-color);\n height: 2px;\n}\n\n\n/* dat.gui style - doesn\'t work on Safari iOS */\n\n/*\n.muigui-range input[type=range] {\n cursor: ew-resize;\n overflow: hidden;\n}\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: var(--range-right-color);\n margin: 0;\n}\n.muigui-range input[type=range]:hover {\n background-color: var(--range-right-hover-color);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n height: max-content;\n color: var(--range-left-color);\n margin-top: -1px;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0px;\n height: max-content;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n}\n*/\n\n/* FF */\n/*\n.muigui-range input[type=range]::-moz-slider-progress {\n background-color: var(--range-left-color); \n}\n.muigui-range input[type=range]::-moz-slider-thumb {\n height: max-content;\n width: 0;\n border: none;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n box-sizing: border-box;\n}\n*/\n\n.muigui-checkered-background {\n background-color: #404040;\n background-image:\n linear-gradient(45deg, #808080 25%, transparent 25%),\n linear-gradient(-45deg, #808080 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #808080 75%),\n linear-gradient(-45deg, transparent 75%, #808080 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0px;\n}\n\n/* ---------------------------------------------------------- */\n\n/* needs to be at bottom to take precedence */\n.muigui-auto-place {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 100001;\n}\n\n',themes:{default:"",float:"\n :root {\n color-scheme: light dark,\n }\n\n .muigui {\n --width: 400px;\n --bg-color: initial;\n --label-width: 25%;\n --number-width: 20%;\n }\n\n input,\n .muigui-label-controller>label {\n text-shadow:\n -1px -1px 0 var(--contrast-color),\n 1px -1px 0 var(--contrast-color),\n -1px 1px 0 var(--contrast-color),\n 1px 1px 0 var(--contrast-color);\n }\n\n .muigui-controller > label:nth-child(1) {\n place-content: center end;\n margin-right: 1em;\n }\n\n .muigui-value > :nth-child(2) {\n margin-left: 1em;\n }\n\n .muigui-root>*:nth-child(1) {\n display: none;\n }\n\n .muigui-range input[type=range]::-webkit-slider-thumb {\n border-radius: 1em;\n }\n\n .muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: initial;\n appearance: none;\n border: 1px solid rgba(0, 0, 0, 0.25);\n height: 2px;\n }\n\n .muigui-colors {\n --value-color: var(--color );\n --value-bg-color: rgba(0, 0, 0, 0.1);\n --disabled-color: #cccccc;\n --menu-bg-color: rgba(0, 0, 0, 0.1);\n --menu-sep-color: #bbbbbb;\n --hover-bg-color: rgba(0, 0, 0, 0);\n --invalid-color: #FF0000;\n --selected-color: rgba(0, 0, 0, 0.3);\n --range-color: rgba(0, 0, 0, 0.125);\n }\n"}};function e(t,e={},n=[]){const i=document.createElement(t);return function(t,e,n){for(const[n,i]of Object.entries(e))if("function"==typeof i&&n.startsWith("on")){const e=n.substring(2).toLowerCase();t.addEventListener(e,i,{passive:!1})}else if("object"==typeof i)for(const[e,o]of Object.entries(i))t[n][e]=o;else void 0===t[n]?t.setAttribute(n,i):t[n]=i;for(const e of n)t.appendChild(e)}(i,e,n),i}let n=0;function i(t,e){const n=t.indexOf(e);return n&&t.splice(n,1),t}function o(t,e,n){return Math.max(e,Math.min(n,t))}const r="undefined"!=typeof SharedArrayBuffer?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer},s=(t,e,n)=>Math.round(e(t)/n)/(1/n),a=(t,e)=>(t%e+e)%e;function l(t,e){for(const n in e)n in t&&(t[n]=e[n]);return t}const u=(t,e,n,i,o)=>(t-e)*(o-i)/(n-e)+i,c=({from:t,to:e})=>({to:n=>u(n,...t,...e),from:n=>[!0,u(n,...e,...t)]}),h=({from:t,to:e,step:n})=>({min:e[0],max:e[1],...n&&{step:n},converters:c({from:t,to:e})}),d={to:t=>t,from:t=>[!0,t]};function p(t,e,n,i,o){const{converters:{from:r}=d}=o,{min:s,max:a}=o,l=o.minRange||0,u=r(l)[1],c=t.add(e,n,{...o,min:s,max:a-l}).onChange((t=>{h.setValue(Math.min(a,Math.max(t+u,e[i])))})),h=t.add(e,i,{...o,min:s+l,max:a}).onChange((t=>{c.setValue(Math.max(s,Math.min(t-u,e[n])))}));return[c,h]}class m{domElement;#t;#e=[];constructor(t){this.domElement=t,this.#t=t}addElem(t){return this.#t.appendChild(t),t}removeElem(t){return this.#t.removeChild(t),t}pushSubElem(t){this.#t.appendChild(t),this.#t=t}popSubElem(){this.#t=this.#t.parentElement}add(t){return this.#e.push(t),this.addElem(t.domElement),t}remove(t){return this.removeElem(t.domElement),i(this.#e,t),t}pushSubView(t){this.pushSubElem(t.domElement)}popSubView(){this.popSubElem()}setOptions(t){for(const e of this.#e)e.setOptions(t)}updateDisplayIfNeeded(t,e){for(const n of this.#e)n.updateDisplayIfNeeded(t,e);return this}$(t){return this.domElement.querySelector(t)}}class g extends m{#n;#i;#o;constructor(t){super(e("div",{className:"muigui-controller"})),this.#n=[],this.#i=[],t&&this.domElement.classList.add(t)}get parent(){return this.#o}setParent(t){this.#o=t,this.enable(!this.disabled())}show(t=!0){return this.domElement.classList.toggle("muigui-hide",!t),this.domElement.classList.toggle("muigui-show",t),this}hide(){return this.show(!1)}disabled(){return!!this.domElement.closest(".muigui-disabled")}enable(t=!0){return this.domElement.classList.toggle("muigui-disabled",!t),["input","button","select","textarea"].forEach((t=>{this.domElement.querySelectorAll(t).forEach((t=>{const e=!!t.closest(".muigui-disabled");t.disabled=e}))})),this}disable(t=!0){return this.enable(!t)}onChange(t){return this.removeChange(t),this.#n.push(t),this}removeChange(t){return i(this.#n,t),this}onFinishChange(t){return this.removeFinishChange(t),this.#i.push(t),this}removeFinishChange(t){return i(this.#i,t),this}#r(t,e){for(const n of t)n.call(this,e)}emitChange(t,e,n){this.#r(this.#n,t),this.#o&&(void 0===e?this.#o.emitChange(t):this.#o.emitChange({object:e,property:n,value:t,controller:this}))}emitFinalChange(t,e,n){this.#r(this.#i,t),this.#o&&(void 0===e?this.#o.emitChange(t):this.#o.emitFinalChange({object:e,property:n,value:t,controller:this}))}updateDisplay(){}getColors(){const t=t=>t.replace(/-([a-z])/g,((t,e)=>e.toUpperCase())),n=e("div");this.domElement.appendChild(n);const i=Object.fromEntries(["color","bg-color","value-color","value-bg-color","hover-bg-color","menu-bg-color","menu-sep-color","disabled-color"].map((e=>{n.style.color=`var(--${e})`;const i=getComputedStyle(n);return[t(e),i.color]})));return n.remove(),i}}class f extends g{#s;#a;#l;#u={name:""};constructor(t,n,i={}){super("muigui-button",""),this.#s=t,this.#a=n,this.#l=this.addElem(e("button",{type:"button",onClick:()=>{this.#s[this.#a](this)}})),this.setOptions({name:n,...i})}setOptions(t){l(this.#u,t);const{name:e}=this.#u;this.#l.textContent=e}}function b(t,e){if(t.length!==e.length)return!1;for(let n=0;n{t.setValue(i.checked)},onChange:()=>{t.setFinalValue(i.checked)}});super(e("label",{},[i])),this.#b=i}updateDisplay(t){this.#b.checked=t}}const w=[],y=new Set;let k,E;function $(){k=void 0,E=!0;for(const t of w)y.has(t)||t();E=!1,y.size&&(E?C():(y.forEach((t=>{i(w,t)})),y.clear())),C()}function C(){!k&&w.length&&(k=requestAnimationFrame($))}let V=0;function I(){return"muigui-"+ ++V}class M extends m{constructor(t=""){super(e("div",{className:"muigui-value"})),t&&this.domElement.classList.add(t)}}class S extends g{#v;#x;constructor(t="",n=""){super("muigui-label-controller"),this.#v=I(),this.#x=e("label",{for:this.#v}),this.domElement.appendChild(this.#x),this.pushSubView(new M(t)),this.name(n)}get id(){return this.#v}name(t){return this.#x.title===this.#x.textContent&&(this.#x.title=t),this.#x.textContent=t,this}tooltip(t){this.#x.title=t}}class D extends S{#s;#a;#w;#y;#e;#k;constructor(t,e,n=""){super(n,e),this.#s=t,this.#a=e,this.#w=this.getValue(),this.#y=!1,this.#e=[]}get initialValue(){return this.#w}get object(){return this.#s}get property(){return this.#a}add(t){return this.#e.push(t),super.add(t),this.updateDisplay(),t}#E(t,e){let n=!1;if("object"==typeof t){const e=this.#s[this.#a];if(Array.isArray(t)||r(t))for(let i=0;i=0&&w.splice(e,1)}(this.#k)),this}}class N extends D{constructor(t,e){super(t,e,"muigui-checkbox");const n=this.id;this.add(new x(this,n)),this.updateDisplay()}}const F={to:t=>t,from:t=>[!0,t]},A={to:t=>t.toString(),from:t=>{const e=parseFloat(t);return[!Number.isNaN(e),e]}},U={radToDeg:c({to:[0,180],from:[0,Math.PI]})};function L(){let t=0;return function(e,n,i=5){t-=e.deltaY*n/i;const o=Math.floor(Math.abs(t)/n)*Math.sign(t)*n;return t-=o,o}}class O extends v{#$;#C;#V;#I;#u={step:.01,converters:A,min:Number.NEGATIVE_INFINITY,max:Number.POSITIVE_INFINITY};constructor(t,n){const i=t.setValue.bind(t),r=t.setFinalValue.bind(t),a=L();super(e("input",{type:"number",onInput:()=>this.#M(i,!0),onChange:()=>this.#M(r,!1),onWheel:e=>{e.preventDefault();const{min:n,max:i,step:r}=this.#u,l=a(e,r),u=parseFloat(this.domElement.value),c=o(s(u+l,(t=>t),r),n,i);t.setValue(c)}})),this.setOptions(n)}#M(t,e){const n=parseFloat(this.domElement.value),[i,r]=this.#C(n);let s;if(i&&!Number.isNaN(n)){const{min:n,max:i}=this.#u;s=r>=n&&r<=i,this.#I=e,t(o(r,n,i))}this.domElement.classList.toggle("muigui-invalid-value",!i||!s)}updateDisplay(t){this.#I||(this.domElement.value=s(t,this.#$,this.#V)),this.#I=!1}setOptions(t){l(this.#u,t);const{step:e,converters:{to:n,from:i}}=this.#u;return this.#$=n,this.#C=i,this.#V=e,this}}class j extends D{#S;#V;constructor(t,e,n={}){super(t,e,"muigui-checkbox"),this.#S=this.add(new O(this,n)),this.updateDisplay()}}class T extends v{#D;constructor(t,n){const i=[];super(e("select",{onChange:()=>{t.setFinalValue(this.#D[this.domElement.selectedIndex])}},n.map((([t,n])=>(i.push(n),e("option",{textContent:t})))))),this.#D=i}updateDisplay(t){const e=this.#D.indexOf(t);this.domElement.selectedIndex=e}}function H(t,e){return Array.isArray(t)?Array.isArray(t[0])?t:e?t.map(((t,e)=>[t,e])):t.map((t=>[t,t])):[...Object.entries(t)]}class z extends D{constructor(t,e,n){super(t,e,"muigui-select");const i="number"==typeof this.getValue(),{keyValues:o}=n,r=H(o,i);this.add(new T(this,r)),this.updateDisplay()}}class P extends v{#$;#C;#V;#I;#u={step:.01,min:0,max:1,converters:F};constructor(t,n){const i=L();super(e("input",{type:"range",onInput:()=>{this.#I=!0;const{min:e,max:n,step:i}=this.#u,r=parseFloat(this.domElement.value),a=o(s(r,(t=>t),i),e,n),[l,u]=this.#C(a);l&&t.setValue(u)},onChange:()=>{this.#I=!0;const{min:e,max:n,step:i}=this.#u,r=parseFloat(this.domElement.value),a=o(s(r,(t=>t),i),e,n),[l,u]=this.#C(a);l&&t.setFinalValue(u)},onWheel:e=>{e.preventDefault();const[n,r]=this.#C(parseFloat(this.domElement.value));if(!n)return;const{min:a,max:l,step:u}=this.#u,c=i(e,u),h=o(s(r+c,(t=>t),u),a,l);t.setValue(h)}})),this.setOptions(n)}updateDisplay(t){this.#I||(this.domElement.value=s(t,this.#$,this.#V)),this.#I=!1}setOptions(t){l(this.#u,t);const{step:e,min:n,max:i,converters:{to:o,from:r}}=this.#u;return this.#$=o,this.#C=r,this.#V=e,this.domElement.step=e,this.domElement.min=n,this.domElement.max=i,this}}class B extends D{constructor(t,e,n){super(t,e,"muigui-range"),this.add(new P(this,n)),this.add(new O(this,n))}}class G extends v{#$;#C;#I;#u={converters:F};constructor(t,n){const i=t.setValue.bind(t),o=t.setFinalValue.bind(t);super(e("input",{type:"text",onInput:()=>this.#M(i,!0),onChange:()=>this.#M(o,!1)})),this.setOptions(n)}#M(t,e){const[n,i]=this.#C(this.domElement.value);n&&(this.#I=e,t(i)),this.domElement.style.color=n?"":"var(--invalid-color)"}updateDisplay(t){this.#I||(this.domElement.value=this.#$(t),this.domElement.style.color=""),this.#I=!1}setOptions(t){l(this.#u,t);const{converters:{to:e,from:n}}=this.#u;return this.#$=e,this.#C=n,this}}class R extends D{constructor(t,e){super(t,e,"muigui-checkbox"),this.add(new G(this)),this.updateDisplay()}}const Y=(t,e,n)=>Math.max(e,Math.min(n,t)),K=(t,e,n)=>t+(e-t)*n,W=t=>t>=0?t%1:1-t%1,q=t=>+t.toFixed(0),J=t=>+t.toFixed(3),_=t=>parseInt(t.substring(1,3),16)<<16|parseInt(t.substring(3,5),16)<<8|parseInt(t.substring(5,7),16),X=t=>parseInt(t.substring(1,3),16)*2**24+65536*parseInt(t.substring(3,5),16)+256*parseInt(t.substring(5,7),16)+parseInt(t.substring(7,9),16),Z=t=>[parseInt(t.substring(1,3),16),parseInt(t.substring(3,5),16),parseInt(t.substring(5,7),16)],Q=t=>`#${Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}`,tt=t=>[parseInt(t.substring(1,3),16),parseInt(t.substring(3,5),16),parseInt(t.substring(5,7),16),parseInt(t.substring(7,9),16)],et=t=>`#${Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}`,nt=t=>Z(t).map((t=>J(t/255))),it=t=>Q(Array.from(t).map((t=>Math.round(Y(255*t,0,255))))),ot=t=>tt(t).map((t=>J(t/255))),rt=t=>et(Array.from(t).map((t=>Math.round(Y(255*t,0,255))))),st=t=>Y(Math.round(255*t),0,255).toString(16).padStart(2,"0"),at=t=>({r:parseInt(t.substring(1,3),16)/255,g:parseInt(t.substring(3,5),16)/255,b:parseInt(t.substring(5,7),16)/255}),lt=t=>({r:parseInt(t.substring(1,3),16)/255,g:parseInt(t.substring(3,5),16)/255,b:parseInt(t.substring(5,7),16)/255,a:parseInt(t.substring(7,9),16)/255}),ut=t=>`rgb(${Z(t).join(", ")})`,ct=/^\s*rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/,ht=t=>`rgba(${tt(t).map(((t,e)=>3===e?t/255:t)).join(", ")})`,dt=/^\s*rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+\.\d+|\d+)\s*\)\s*$/,pt=t=>{const e=yt(Z(t)).map((t=>q(t)));return`hsl(${e[0]}, ${e[1]}%, ${e[2]}%)`},mt=t=>{const e=kt(tt(t)).map(((t,e)=>3===e?J(t):q(t)));return`hsl(${e[0]} ${e[1]}% ${e[2]}% / ${e[3]})`},gt=/^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\)\s*$/,ft=/^\s*hsl\(\s*(\d+)(?:deg|)\s*(?:,|)\s*(\d+)%\s*(?:,|)\s*(\d+)%\s*\/\s*(\d+\.\d+|\d+)\s*\)\s*$/,bt=(t,e)=>(t%e+e)%e;function vt([t,e,n]){t=bt(t,360),e=Y(e/100,0,1),n=Y(n/100,0,1);const i=e*Math.min(n,1-n);function o(e){const o=(e+t/30)%12;return n-i*Math.max(-1,Math.min(o-3,9-o,1))}return[o(0),o(8),o(4)].map((t=>Math.round(255*t)))}function xt([t,e,n]){const i=Math.max(t,e,n),o=Math.min(t,e,n),r=.5*(o+i),s=i-o;let a=0,l=0;if(0!==s)switch(l=0===r||1===r?0:(i-r)/Math.min(r,1-r),i){case t:a=(e-n)/s+(e{const[e,n,i]=xt(t.map((t=>t/255)));return[360*e,100*n,100*i]},kt=t=>{const[e,n,i,o]=wt(t.map((t=>t/255)));return[360*e,100*n,100*i,o]};function Et([t,e,n]){return e=Y(e,0,1),n=Y(n,0,1),[t,t+2/3,t+1/3].map((t=>K(1,Y(Math.abs(6*W(t)-3)-1,0,1),e)*n))}function $t([t,e,n,i]){return[...Et([t,e,n]),i]}const Ct=t=>Math.round(1e3*t)/1e3;function Vt([t,e,n]){const i=n>e?[n,e,-1,2/3]:[e,n,0,-1/3],o=i[0]>t?[i[0],i[1],i[3],t]:[t,i[1],i[2],i[0]],r=o[0]-Math.min(o[3],o[1]);return[Math.abs(o[2]+(o[3]-o[1])/(6*r+Number.EPSILON)),r/(o[0]+Number.EPSILON),o[0]].map(Ct)}const It=t=>t.endsWith("a")||t.startsWith("hex8"),Mt=[{re:/^#(?:[0-9a-f]){6}$/i,format:"hex6"},{re:/^(?:[0-9a-f]){6}$/i,format:"hex6-no-hash"},{re:/^#(?:[0-9a-f]){8}$/i,format:"hex8"},{re:/^(?:[0-9a-f]){8}$/i,format:"hex8-no-hash"},{re:/^#(?:[0-9a-f]){3}$/i,format:"hex3"},{re:/^(?:[0-9a-f]){3}$/i,format:"hex3-no-hash"},{re:ct,format:"css-rgb"},{re:gt,format:"css-hsl"},{re:dt,format:"css-rgba"},{re:ft,format:"css-hsla"}];function St(t){switch(typeof t){case"number":return console.warn('can not reliably guess format based on a number. You should pass in a format like {format: "uint32-rgb"} or {format: "uint32-rgb"}'),t<=16777215?"uint32-rgb":"uint32-rgba";case"string":{const e=function(t){for(const e of Mt)if(e.re.test(t))return e}(t.trim());if(e)return e.format;break}case"object":if(t instanceof Uint8Array||t instanceof Uint8ClampedArray){if(3===t.length)return"uint8-rgb";if(4===t.length)return"uint8-rgba"}else if(t instanceof Float32Array){if(3===t.length)return"float-rgb";if(4===t.length)return"float-rgba"}else if(Array.isArray(t)){if(3===t.length)return"float-rgb";if(4===t.length)return"float-rgba"}else if("r"in t&&"g"in t&&"b"in t)return"a"in t?"object-rgba":"object-rgb"}throw new Error(`unknown color format: ${t}`)}function Dt(t){return t.trim(t)}function Nt(t){return t.trim(t)}function Ft(t){return t[1]===t[2]&&t[3]===t[4]&&t[5]===t[6]?`#${t[1]}${t[3]}${t[5]}`:t}const At=/^(#|)([0-9a-f]{3})$/i;function Ut(t){const e=At.exec(t);if(e){const[,,t]=e;return"#"+`${(n=t)[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`}var n;return t}function Lt(t){return Ft(Dt(t))}const Ot=t=>{const e=ct.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3]].map((t=>parseInt(t)));return[!n.find((t=>t>255)),`rgb(${n.join(", ")})`]},jt=t=>{const e=dt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3],e[4]].map(((t,e)=>3===e?parseFloat(t):parseInt(t)));return[!n.find((t=>t>255)),`rgba(${n.join(", ")})`]},Tt=t=>{const e=gt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3]].map((t=>parseFloat(t)));return[!n.find((t=>Number.isNaN(t))),`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`]},Ht=t=>{const e=ft.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3],e[4]].map((t=>parseFloat(t)));return[!n.find((t=>Number.isNaN(t))),`hsl(${n[0]} ${n[1]}% ${n[2]}% / ${n[3]})`]},zt=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/,Pt=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*$/,Bt=/^\s*(?:0x){0,1}([0-9a-z]{1,6})\s*$/i,Gt=/^\s*(?:0x){0,1}([0-9a-z]{1,8})\s*$/i,Rt=/^\s*#[a-f0-9]{6}\s*$|^\s*#[a-f0-9]{3}\s*$/i,Yt=/^\s*[a-f0-9]{6}\s*$/i,Kt=/^\s*#[a-f0-9]{8}\s*$/i,Wt=/^\s*[a-f0-9]{8}\s*$/i,qt={hex6:{color:{from:t=>[!0,t],to:Dt},text:{from:t=>[Rt.test(t),t.trim()],to:t=>t}},hex8:{color:{from:t=>[!0,t],to:Nt},text:{from:t=>[Kt.test(t),t.trim()],to:t=>t}},hex3:{color:{from:t=>[!0,Lt(t)],to:Ut},text:{from:t=>[Rt.test(t),Ft(t.trim())],to:t=>t}},"hex6-no-hash":{color:{from:t=>[!0,t.substring(1)],to:t=>`#${Dt(t)}`},text:{from:t=>[Yt.test(t),t.trim()],to:t=>t}},"hex8-no-hash":{color:{from:t=>[!0,t.substring(1)],to:t=>`#${Nt(t)}`},text:{from:t=>[Wt.test(t),t.trim()],to:t=>t}},"hex3-no-hash":{color:{from:t=>[!0,Lt(t).substring(1)],to:Ut},text:{from:t=>[Yt.test(t),Ft(t.trim())],to:t=>t}},"uint32-rgb":{color:{from:t=>[!0,_(t)],to:t=>`#${Math.round(t).toString(16).padStart(6,"0")}`},text:{from:t=>(t=>{const e=Bt.exec(t);return e?[!0,parseInt(e[1],16)]:[!1]})(t),to:t=>`0x${t.toString(16).padStart(6,"0")}`}},"uint32-rgba":{color:{from:t=>[!0,X(t)],to:t=>`#${Math.round(t).toString(16).padStart(8,"0")}`},text:{from:t=>(t=>{const e=Gt.exec(t);return e?[!0,parseInt(e[1],16)]:[!1]})(t),to:t=>`0x${t.toString(16).padStart(8,"0")}`}},"uint8-rgb":{color:{from:t=>[!0,Z(t)],to:Q},text:{from:t=>{const e=zt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3]].map((t=>parseInt(t)));return[!n.find((t=>t>255)),n]},to:t=>t.join(", ")}},"uint8-rgba":{color:{from:t=>[!0,tt(t)],to:et},text:{from:t=>{const e=Pt.exec(t);if(!e)return[!1];const n=[e[1],e[2],e[3],e[4]].map((t=>parseInt(t)));return[!n.find((t=>t>255)),n]},to:t=>t.join(", ")}},"float-rgb":{color:{from:t=>[!0,nt(t)],to:it},text:{from:t=>{const e=t.split(",").map((t=>t.trim())),n=e.map((t=>parseFloat(t)));if(3!==n.length)return[!1];const i=e.findIndex((t=>isNaN(t)));return[i<0,n.map((t=>J(t)))]},to:t=>Array.from(t).map((t=>J(t))).join(", ")}},"float-rgba":{color:{from:t=>[!0,ot(t)],to:rt},text:{from:t=>{const e=t.split(",").map((t=>t.trim())),n=e.map((t=>parseFloat(t)));if(4!==n.length)return[!1];const i=e.findIndex((t=>isNaN(t)));return[i<0,n.map((t=>J(t)))]},to:t=>Array.from(t).map((t=>J(t))).join(", ")}},"object-rgb":{color:{from:t=>[!0,at(t)],to:t=>`#${st(t.r)}${st(t.g)}${st(t.b)}`},text:{from:t=>{try{const e=t.replace(/([a-z])/g,'"$1"'),n=JSON.parse(e);if(Number.isNaN(n.r)||Number.isNaN(n.g)||Number.isNaN(n.b))throw new Error("not {r, g, b}");return[!0,n]}catch(t){return[!1]}},to:t=>`{r:${J(t.r)}, g:${J(t.g)}, b:${J(t.b)}}`}},"object-rgba":{color:{from:t=>[!0,lt(t)],to:t=>`#${st(t.r)}${st(t.g)}${st(t.b)}${st(t.a)}`},text:{from:t=>{try{const e=t.replace(/([a-z])/g,'"$1"'),n=JSON.parse(e);if(Number.isNaN(n.r)||Number.isNaN(n.g)||Number.isNaN(n.b)||Number.isNaN(n.a))throw new Error("not {r, g, b, a}");return[!0,n]}catch(t){return[!1]}},to:t=>`{r:${J(t.r)}, g:${J(t.g)}, b:${J(t.b)}}, a:${J(t.a)}}`}},"css-rgb":{color:{from:t=>[!0,ut(t)],to:t=>{const e=ct.exec(t);return Q([e[1],e[2],e[3]].map((t=>parseInt(t))))}},text:{from:Ot,to:t=>Ot(t)[1]}},"css-rgba":{color:{from:t=>[!0,ht(t)],to:t=>{const e=dt.exec(t);return et([e[1],e[2],e[3],e[4]].map(((t,e)=>3===e?255*parseFloat(t)|0:parseInt(t))))}},text:{from:jt,to:t=>jt(t)[1]}},"css-hsl":{color:{from:t=>[!0,pt(t)],to:t=>{const e=gt.exec(t),n=vt([e[1],e[2],e[3]].map((t=>parseFloat(t))));return Q(n)}},text:{from:Tt,to:t=>Tt(t)[1]}},"css-hsla":{color:{from:t=>[!0,mt(t)],to:t=>{const e=ft.exec(t),n=function([t,e,n,i]){return[...vt([t,e,n]),255*i|0]}([e[1],e[2],e[3],e[4]].map((t=>parseFloat(t))));return et(n)}},text:{from:Ht,to:t=>Ht(t)[1]}}};class Jt extends m{constructor(t,n){super(e(t,{className:n}))}}class _t extends S{#N;constructor(){super("muigui-canvas"),this.#N=this.add(new Jt("canvas","muigui-canvas")).domElement}get canvas(){return this.#N}}class Xt extends v{#$;#C;#F;#I;#u={converters:F};constructor(t,n){const i=e("input",{type:"color",onInput:()=>{const[e,n]=this.#C(i.value);e&&(this.#I=!0,t.setValue(n))},onChange:()=>{const[e,n]=this.#C(i.value);e&&(this.#I=!0,t.setFinalValue(n))}});super(e("div",{},[i])),this.setOptions(n),this.#F=i}updateDisplay(t){this.#I||(this.#F.value=this.#$(t)),this.#I=!1}setOptions(t){l(this.#u,t);const{converters:{to:e,from:n}}=this.#u;return this.#$=e,this.#C=n,this}}class Zt extends D{#A;#S;constructor(t,e,n={}){super(t,e,"muigui-color");const i=n.format||St(this.getValue()),{color:o,text:r}=qt[i];this.#A=this.add(new Xt(this,{converters:o})),this.#S=this.add(new G(this,{converters:r})),this.updateDisplay()}setOptions(t){const{format:e}=t;if(e){const{color:t,text:n}=qt[e];this.#A.setOptions({converters:t}),this.#S.setOptions({converters:n})}return super.setOptions(t),this}}class Qt extends g{constructor(){super("muigui-divider")}}class te extends g{#U;#L;constructor(t){super(t),this.#U=[],this.#L=this}get children(){return this.#U}get controllers(){return this.#U.filter((t=>!(t instanceof te)))}get folders(){return this.#U.filter((t=>t instanceof te))}reset(t=!0){for(const e of this.#U)e instanceof te&&!t||e.reset(t);return this}updateDisplay(){for(const t of this.#U)t.updateDisplay();return this}remove(t){const e=this.#U.indexOf(t);if(e>=0){const t=this.#U.splice(e,1)[0];t.domElement.remove(),t.setParent(null)}return this}#O(t){return this.domElement.appendChild(t.domElement),this.#U.push(t),t.setParent(this),t}addController(t){return this.#L.#O(t)}pushContainer(t){return this.addController(t),this.#L=t,t}popContainer(){return this.#L=this.#L.parent,this}}class ee extends te{#j;constructor(t="Controls",n="muigui-menu"){super(n),this.#j=e("label"),this.addElem(e("button",{type:"button",onClick:()=>this.toggleOpen()},[this.#j])),this.pushContainer(new te),this.name(t),this.open()}open(t=!0){return this.domElement.classList.toggle("muigui-closed",!t),this.domElement.classList.toggle("muigui-open",t),this}close(){return this.open(!1)}name(t){return this.#j.textContent=t,this}title(t){return this.name(t)}toggleOpen(){return this.open(!this.domElement.classList.contains("muigui-open")),this}}class ne extends g{constructor(t){super("muigui-label"),this.text(t)}text(t){return this.domElement.textContent=t,this}}function ie(){}function oe(t,e,n){const i=t.getBoundingClientRect(),o=e.clientX-i.left,r=e.clientY-i.top,s=o/i.width,a=r/i.height,l=o-(n=n||[o,r])[0],u=r-n[1];return{x:o,y:r,nx:s,ny:a,dx:l,dy:u,ndx:l/i.width,ndy:u/i.width}}function re(t,{onDown:e=ie,onMove:n=ie,onUp:i=ie}){let o;const r=function(e){const i={type:"move",...oe(t,e,o)};n(i)},s=function(e){t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",s),document.body.style.backgroundColor="",i("up")},a=function(n){t.addEventListener("pointermove",r),t.addEventListener("pointerup",s),t.setPointerCapture(n.pointerId);const i=oe(t,n);o=[i.x,i.y],e({type:"down",...i})};return t.addEventListener("pointerdown",a),function(){t.removeEventListener("pointerdown",a)}}function se(t){return t.querySelectorAll("[data-src]").forEach((e=>{const i="muigui-id-"+n++;e.id=i,t.querySelectorAll(`[data-target=${e.dataset.src}]`).forEach((t=>{t.setAttribute("fill",`url(#${i})`)}))})),t}class ae extends v{#$;#C;#T;#H;#z;#P;#B;#G;#R;#Y;#K;#W;#q;#J;#u={converters:F,alpha:!1};#_;#X;constructor(t,n){super(e("div",{innerHTML:'\n\n\n\n',className:"muigui-no-scroll"})),this.#T=this.domElement.children[0],this.#z=this.domElement.children[1],this.#G=this.domElement.children[2],se(this.#T),se(this.#z),se(this.#G),this.#H=this.$(".muigui-color-chooser-circle"),this.#P=this.$("[data-src=muigui-color-chooser-hue]"),this.#B=this.$(".muigui-color-chooser-hue-cursor"),this.#R=this.$("[data-src=muigui-color-chooser-alpha]"),this.#Y=this.$(".muigui-color-chooser-alpha-cursor");const i=e=>{const n=o(e.nx,0,1),i=o(e.ny,0,1);this.#K[1]=n,this.#K[2]=1-i,this.#W=!0,this.#J=!0;const[r,s]=this.#C(this.#_(this.#K));r&&t.setValue(s)},r=e=>{const n=o(e.nx,0,1);this.#K[0]=n,this.#q=!0,this.#J=!0;const[i,r]=this.#C(this.#_(this.#K));i&&t.setValue(r)},s=e=>{const n=o(e.nx,0,1);this.#K[3]=n,this.#W=!0,this.#q=!0;const[i,r]=this.#C(this.#_(this.#K));i&&t.setValue(r)};re(this.#T,{onDown:i,onMove:i}),re(this.#z,{onDown:r,onMove:r}),re(this.#G,{onDown:s,onMove:s}),this.setOptions(n)}updateDisplay(t){this.#K||(this.#K=this.#X(this.#$(t)));{const[e,n,i,o=1]=this.#X(this.#$(t));this.#W||(this.#K[0]=n>.001&&i>.001?e:this.#K[0]),this.#q||(this.#K[1]=n,this.#K[2]=i),this.#J||(this.#K[3]=o)}{const[t,e,n,i]=this.#K,[o,r,s]=wt($t(this.#K));this.#W||this.#B.setAttribute("transform",`translate(${64*t}, 0)`),this.#P.children[0].setAttribute("stop-color",`hsl(${360*o} 0% 100% / ${i})`),this.#P.children[1].setAttribute("stop-color",`hsl(${360*o} 100% 50% / ${i})`),this.#J||this.#Y.setAttribute("transform",`translate(${64*i}, 0)`),this.#R.children[0].setAttribute("stop-color",`hsl(${360*o} ${100*r}% ${100*s}% / 0)`),this.#R.children[1].setAttribute("stop-color",`hsl(${360*o} ${100*r}% ${100*s}% / 1)`),this.#q||(this.#H.setAttribute("cx",""+64*e),this.#H.setAttribute("cy",""+48*(1-n)))}this.#W=!1,this.#q=!1,this.#J=!1}setOptions(t){l(this.#u,t);const{converters:{to:e,from:n},alpha:i}=this.#u;return this.#G.style.display=i?"":"none",this.#_=i?t=>rt($t(t)):t=>it(Et(t)),this.#X=i?t=>function([t,e,n,i]){return[...Vt([t,e,n]),i]}(ot(t)):t=>Vt(nt(t)),this.#$=e,this.#C=n,this}}class le extends D{#Z;#Q;#b;#tt;#u={open:!1};constructor(t,n,i={}){super(t,n,"muigui-pop-down-controller"),this.#Z=this.add(new Jt("div","muigui-pop-down-top"));const o=this.#Z.addElem(e("input",{type:"checkbox",onChange:()=>{this.#u.open=o.checked,this.updateDisplay()}}));this.#b=o,this.#Q=this.#Z.add(new Jt("div","muigui-pop-down-values")),this.#tt=this.add(new Jt("div","muigui-pop-down-bottom")),this.setOptions(i)}setKnobColor(t){this.#b&&(this.#b.style=`\n --range-color: ${t};\n --value-bg-color: ${t};\n `)}updateDisplay(){super.updateDisplay();const{open:t}=this.#u;this.domElement.children[1].classList.toggle("muigui-open",t),this.domElement.children[1].classList.toggle("muigui-closed",!t)}setOptions(t){l(this.#u,t),super.setOptions(t),this.updateDisplay()}addTop(t){return this.#Q.add(t)}addBottom(t){return this.#tt.add(t)}}class ue extends le{#A;#S;#$;#et;constructor(t,e,n={}){super(t,e,"muigui-color-chooser");const i=n.format||St(this.getValue()),{color:o,text:r}=qt[i];this.#$=o.to,this.#S=new G(this,{converters:r,alpha:It(i)}),this.#A=new ae(this,{converters:o,alpha:It(i)}),this.addTop(this.#S),this.addBottom(this.#A),this.#et=()=>{if(this.#$){const t=this.#$(this.getValue()),e=yt(Z(t));e[2]=(e[2]+50)%100;const n=Q(vt(e));this.setKnobColor(`${t.substring(0,7)}FF`,n)}},this.updateDisplay()}updateDisplay(){super.updateDisplay(),this.#et&&this.#et()}setOptions(t){return super.setOptions(t),this}}class ce extends ee{add(t,e,...n){const i=t instanceof g?t:function(t,e,...n){const[i]=n;if(Array.isArray(i))return new z(t,e,{keyValues:i});const o=typeof t[e];switch(o){case"number":if("number"==typeof n[0]&&"number"==typeof n[1]){const i=n[0],o=n[1],r=n[2];return new B(t,e,{min:i,max:o,...r&&{step:r}})}return 0===n.length?new j(t,e,...n):new B(t,e,...n);case"boolean":return new N(t,e,...n);case"function":return new f(t,e,...n);case"string":return new R(t,e,...n);case"undefined":throw new Error(`no property named ${e}`);default:throw new Error(`unhandled type ${o} for property ${e}`)}}(t,e,...n);return this.addController(i)}addCanvas(t){return this.addController(new _t(t))}addColor(t,e,n={}){const i=t[e];return It(n.format||St(i))?this.addController(new ue(t,e,n)):this.addController(new Zt(t,e,n))}addDivider(){return this.addController(new Qt)}addFolder(t){return this.addController(new ce(t))}addLabel(t){return this.addController(new ne(t))}}class he extends HTMLElement{constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}}customElements.define("muigui-element",he);const de=new CSSStyleSheet;de.replaceSync(t.default);const pe=new CSSStyleSheet;function me(t){let e,n;function i(){if(e&&!n){const o=e;e=void 0,n=t.replace(o).then((()=>{n=void 0,i()}))}}return function(t){e=t,i()}}const ge=me(de),fe=me(pe);class be extends ce{static converters=U;static mapRange=u;static makeRangeConverters=c;static makeRangeOptions=h;static makeMinMaxPair=p;#nt=new CSSStyleSheet;constructor(t={}){super("Controls","muigui-root"),t instanceof HTMLElement&&(t={parent:t});const{autoPlace:n=!0,width:i,title:o="Controls"}=t;let{parent:r}=t;if(i&&(this.domElement.style.width=/^\d+$/.test(i)?`${i}px`:i),void 0===r&&n&&(r=document.body,this.domElement.classList.add("muigui-auto-place")),r){const t=e("muigui-element");t.shadowRoot.adoptedStyleSheets=[de,pe,this.#nt],t.shadow.appendChild(this.domElement),r.appendChild(t)}o&&this.title(o),this.domElement.classList.add("muigui","muigui-colors")}setStyle(t){this.#nt.replace(t)}static setBaseStyles(t){ge(t)}static getBaseStyleSheet(){return de}static setUserStyles(t){fe(t)}static getUserStyleSheet(){return pe}static setTheme(e){be.setBaseStyles(`${t.default}\n${t.themes[e]||""}`)}}function ve(){}const xe={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};function we(t,{onDown:e=ve,onUp:n=ve}){const i=function(t){const i=t.shiftKey?10:1,[o,r]=(xe[t.key]||[0,0]).map((t=>t*i));("keydown"===t.type?e:n)({type:t.type.substring(3),dx:o,dy:r,event:t})};return t.addEventListener("keydown",i),t.addEventListener("keyup",i),function(){t.removeEventListener("keydown",i),t.removeEventListener("keyup",i)}}function ye(t,e=""){if(!t)throw new Error(e)}function ke(t,e,n,i,o,r){const s=Math.abs(n)*Math.cos(r),a=Math.abs(i)*Math.sin(r);return[t+Math.cos(o)*s-Math.sin(o)*a,e+Math.sin(o)*s+Math.cos(o)*a]}function Ee(t,e,n,i,o){ye(Math.abs(i-o)<=2*Math.PI),ye(i>=-Math.PI&&i<=2*Math.PI),ye(i<=o),ye(o>=-Math.PI&&o<=4*Math.PI);const{x1:r,y1:s,x2:a,y2:l,fa:u,fs:c}=function(t,e,n,i,o,r,s){const[a,l]=ke(t,e,n,i,o,r),[u,c]=ke(t,e,n,i,o,r+s);return{x1:a,y1:l,x2:u,y2:c,fa:Math.abs(s)>Math.PI?1:0,fs:s>0?1:0}}(t,e,n,n,0,i,o-i);return Math.abs(Math.abs(i-o)-2*Math.PI)>Number.EPSILON?`M${t} ${e} L${r} ${s} A ${n} ${n} 0 ${u} ${c} ${a} ${l} L${t} ${e}`:`M${r} ${s} L${r} ${s} A ${n} ${n} 0 ${u} ${c} ${a} ${l}`}const $e=t=>a(t+Math.PI,2*Math.PI)-Math.PI;class Ce extends v{#it;#ot;#rt;#st;#u={step:1,min:-180,max:180,dirMin:-Math.PI,dirMax:Math.PI,wrap:void 0,converters:F};constructor(t,n={}){const i=L();super(e("div",{className:"muigui-direction muigui-no-scroll",innerHTML:'\n\n',onWheel:e=>{e.preventDefault();const{min:n,max:r,step:l}=this.#u,u=i(e,l);let c=this.#rt+u;this.#st&&(c=a(c-n,r-n)+n);const h=o(s(c,(t=>t),l),n,r);t.setValue(h)}}));const r=e=>{const{min:n,max:i,step:r,dirMin:a,dirMax:l}=this.#u,u=2*e.nx-1,c=2*e.ny-1,h=Math.atan2(c,u),d=(a+l)/2,p=o(($e(h-d)-$e(a-d))/(l-a),0,1),m=s(n+(i-n)*p,(t=>t),r);t.setValue(m)};re(this.domElement,{onDown:r,onMove:r}),we(this.domElement,{onDown:e=>{const{min:n,max:i,step:r}=this.#u,a=o(s(this.#rt+e.dx*r,(t=>t),r),n,i);t.setValue(a)}}),this.#it=this.$("#muigui-arrow"),this.#ot=this.$("#muigui-range"),this.setOptions(n)}updateDisplay(t){this.#rt=t;const{min:e,max:n}=this.#u,i=(t-e)/(n-e),o=(r=this.#u.dirMin,s=this.#u.dirMax,r+(s-r)*i);var r,s;this.#it.style.transform=`rotate(${o}rad)`}setOptions(t){l(this.#u,t);const{dirMin:e,dirMax:n,wrap:i}=this.#u;this.#st=void 0!==i?i:Math.abs(e-n)>=2*Math.PI-Number.EPSILON;const[o,r]=e(o.push(i),e("label",{},[e("input",{type:"radio",name:r,value:a,onChange:function(){this.checked&&t.setFinalValue(s.#D[this.value])}}),e("button",{type:"button",textContent:n,onClick:function(){this.previousElementSibling.click()}})]))))));const s=this;this.#D=o,this.cols(i)}updateDisplay(t){const e=this.#D.indexOf(t);for(let t=0;t{e({rect:t.getBoundingClientRect(),elem:t})})).observe(t)}function De(t,e,n,i){Se(t,(({rect:o})=>{const{width:r,height:s}=o;t.setAttribute("viewBox",`-${r*e} -${s*n} ${r} ${s}`),i({elem:t,rect:o})}))}function Ne(t,e,n,i,o,r){const a=[];tt),n)),e=Math.min(e,o);for(let i=t;i<=e;i+=n)a.push(`M${i} 0 l0 ${r}`);return a.join(" ")}class Fe extends v{#at;#lt;#ut;#ct;#ht;#dt;#pt;#mt;#gt;#rt;#ft;#u={min:-100,max:100,step:1,unit:10,unitSize:10,ticksPerUnit:5,labelFn:t=>t,tickHeight:1,limits:!0,thicksColor:void 0,orientation:void 0};constructor(t,n){const i=L();let r;super(e("div",{innerHTML:'\n\n',className:"muigui-no-v-scroll",onWheel:e=>{e.preventDefault();const{min:n,max:r,step:a}=this.#u,l=i(e,a),u=o(s(this.#rt+l,(t=>t),a),n,r);t.setValue(u)}})),this.#at=this.$("svg"),this.#lt=this.$("#muigui-origin"),this.#ut=this.$("#muigui-ticks"),this.#ct=this.$("#muigui-thicks"),this.#ht=this.$("#muigui-numbers"),this.#dt=this.$("#muigui-left-grad"),this.#pt=this.$("#muigui-right-grad"),this.setOptions(n),re(this.domElement,{onDown:()=>{r=this.#rt},onMove:e=>{const{min:n,max:i,unitSize:a,unit:l,step:u}=this.#u,c=o(s(r-e.dx/a*l,(t=>t),u),n,i);t.setValue(c)}}),we(this.domElement,{onDown:e=>{const{min:n,max:i,step:r}=this.#u,a=o(s(this.#rt+e.dx*r,(t=>t),r),n,i);t.setValue(a)}}),De(this.#at,.5,0,(({rect:{width:t}})=>{this.#dt.setAttribute("x",-t/2),this.#pt.setAttribute("x",t/2-20),this.#ft=function(t){const e=t.innerHTML;t.innerHTML="- ";const n=t.querySelector("text").getComputedTextLength();return t.innerHTML=e,n}(this.#ht),this.#mt=t,this.#bt()}))}#bt(){if(!this.#mt||void 0===this.#rt)return;const{labelFn:t,limits:e,min:n,max:i,orientation:o,tickHeight:r,ticksPerUnit:a,unit:l,unitSize:u,thicksColor:c}=this.#u,h=Math.ceil(this.#mt/u),d=this.#rt/l,p=Math.round(d-h),m=p*u,g=(p+2*h)*u,f=e?n*u/l:m,b=e?i*u/l:g,v=""===t(1)?10:5;a>1&&this.#ut.setAttribute("d",Ne(m,g,u/a,f,b,v*r)),this.#ct.style.stroke=c,this.#ct.setAttribute("d",Ne(m,g,u,f,b,v)),this.#ht.innerHTML=function(t,e,n,i,o,r,a,l){const u=[];tt),n)),e=Math.min(e,a);const c=Math.max(0,-Math.log10(i));for(let r=t;r<=e;r+=n)u.push(`${h=r/n*i,l(h.toFixed(c))}`);var h;return u.join("\n")}(m,g,u,l,this.#ft,f,b,t),this.#lt.setAttribute("transform",`translate(${-this.#rt*u/l} 0)`),this.#at.classList.toggle("muigui-slider-up","up"===o)}updateDisplay(t){this.#rt=t,this.#bt()}setOptions(t){return l(this.#u,t),this}}class Ae extends D{constructor(t,e,n={}){super(t,e,"muigui-slider"),this.add(new Fe(this,n)),this.add(new O(this,n)),this.updateDisplay()}}class Ue extends v{#at;#it;#H;#rt=[];constructor(t){super(e("div",{innerHTML:'\n\n',className:"muigui-no-scroll"}));const n=e=>{const{width:n,height:i}=this.#at.getBoundingClientRect(),o=2*e.nx-1,r=2*e.ny-1;t.setValue([o*n*.5,r*i*.5])};re(this.domElement,{onDown:n,onMove:n}),this.#at=this.$("svg"),this.#it=this.$("#muigui-arrow"),this.#H=this.$("#muigui-circle"),De(this.#at,.5,.5,(()=>this.#vt))}#vt(){const[t,e]=this.#rt;this.#it.setAttribute("d",`M0,0L${t},${e}`),this.#H.setAttribute("transform",`translate(${t}, ${e})`)}updateDisplay(t){this.#rt[0]=t[0],this.#rt[1]=t[1],this.#vt()}}class Le extends le{constructor(t,e){super(t,e,"muigui-vec2");const n=t=>({setValue:e=>{const n=this.getValue();n[t]=e,this.setValue(n)},setFinalValue:e=>{const n=this.getValue();n[t]=e,this.setFinalValue(n)}});this.addTop(new O(n(0),{converters:{to:t=>t[0],from:A.from}})),this.addTop(new O(n(1),{converters:{to:t=>t[1],from:A.from}})),this.addBottom(new Ue(this)),this.updateDisplay()}}export{ue as ColorChooser,Ve as Direction,Me as RadioGrid,B as Range,z as Select,Ae as Slider,j as TextNumber,Le as Vec2,be as default};
+//# sourceMappingURL=muigui.module.min.js.map
diff --git a/dist/0.x/muigui.module.min.js.map b/dist/0.x/muigui.module.min.js.map
new file mode 100644
index 0000000..3feaea2
--- /dev/null
+++ b/dist/0.x/muigui.module.min.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"muigui.module.min.js","sources":["../../src/styles/muigui.css.js","../../src/libs/elem.js","../../src/libs/utils.js","../../../src/views/View.ts","../../src/controllers/Controller.js","../../src/controllers/Button.js","../../src/views/EditView.js","../../src/views/CheckboxView.js","../../src/libs/taskrunner.js","../../src/libs/ids.js","../../src/views/ValueView.js","../../src/controllers/LabelController.js","../../src/controllers/ValueController.js","../../src/controllers/Checkbox.js","../../src/libs/conversions.js","../../src/libs/wheel.js","../../src/views/NumberView.js","../../src/controllers/TextNumber.js","../../src/views/SelectView.js","../../src/libs/key-values.js","../../src/controllers/Select.js","../../src/views/RangeView.js","../../src/controllers/Range.js","../../src/views/TextView.js","../../src/controllers/Text.js","../../src/libs/color-utils.js","../../src/views/ElementView.js","../../src/controllers/Canvas.js","../../src/views/ColorView.js","../../src/controllers/Color.js","../../src/controllers/Divider.js","../../src/controllers/Container.js","../../src/controllers/Folder.js","../../src/controllers/Label.js","../../src/libs/touch.js","../../src/views/ColorChooserView.js","../../src/controllers/PopDownController.js","../../src/controllers/ColorChooser.js","../../src/muigui.js","../../src/controllers/create-controller.js","../../src/libs/keyboard.js","../../src/libs/assert.js","../../src/libs/svg.js","../../src/views/DirectionView.js","../../src/controllers/Direction.js","../../src/views/RadioGridView.js","../../src/controllers/RadioGrid.js","../../src/libs/resize-helpers.js","../../src/views/SliderView.js","../../src/controllers/Slider.js","../../src/views/Vec2View.js","../../src/controllers/Vec2.js"],"sourcesContent":["export default {\n default: `\n.muigui {\n --bg-color: #ddd;\n --color: #222;\n --contrast-color: #eee;\n --value-color: #145 ;\n --value-bg-color: #eeee;\n --disabled-color: #999;\n --menu-bg-color: #f8f8f8;\n --menu-sep-color: #bbb;\n --hover-bg-color: #999;\n --focus-color: #68C;\n --range-color: #888888;\n --invalid-color: #FF0000;\n --selected-color: rgb(255, 255, 255, 0.9);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n}\n\n@media (prefers-color-scheme: dark) {\n .muigui {\n --bg-color: #222222;\n --color: #dddddd;\n --contrast-color: #000;\n --value-color: #43e5f7;\n --value-bg-color: #444444;\n --disabled-color: #666666;\n --menu-bg-color: #080808;\n --menu-sep-color: #444444;\n --hover-bg-color: #666666;\n --focus-color: #88AAFF;\n --range-color: #888888;\n --invalid-color: #FF6666;\n --selected-color: rgba(255, 255, 255, 0.3);\n\n --button-bg-color: var(--value-bg-color);\n\n --range-left-color: var(--value-color);\n --range-right-color: var(--value-bg-color); \n --range-right-hover-color: var(--hover-bg-color);\n\n color: var(--color);\n background-color: var(--bg-color);\n }\n}\n\n.muigui {\n --width: 250px;\n --label-width: 45%;\n --number-width: 40%;\n\n\n --font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Arial, sans-serif;\n --font-size: 11px;\n --font-family-mono: Menlo, Monaco, Consolas, \"Droid Sans Mono\", monospace;\n --font-size-mono: 11px;\n\n --line-height: 1.7em;\n --border-radius: 0px;\n\n width: var(--width);\n font-family: var(--font-family);\n font-size: var(--font-size);\n box-sizing: border-box;\n line-height: 100%;\n}\n.muigui * {\n box-sizing: inherit;\n}\n\n.muigui-no-scroll {\n touch-action: none;\n}\n.muigui-no-h-scroll {\n touch-action: pan-y;\n}\n.muigui-no-v-scroll {\n touch-action: pan-x;\n}\n\n.muigui-invalid-value {\n background-color: red !important;\n color: white !important;\n}\n\n.muigui-grid {\n display: grid;\n}\n.muigui-rows {\n display: flex;\n flex-direction: column;\n\n min-height: 20px;\n border: 2px solid red;\n}\n.muigui-columns {\n display: flex;\n flex-direction: row;\n\n height: 20px;\n border: 2px solid green;\n}\n.muigui-rows>*,\n.muigui-columns>* {\n flex: 1 1 auto;\n align-items: stretch;\n min-height: 0;\n min-width: 0;\n}\n\n.muigui-row {\n border: 2px solid yellow;\n min-height: 10px\n}\n.muigui-column {\n border: 2px solid lightgreen;\n}\n\n/* -------- */\n\n.muigui-show { /* */ }\n.muigui-hide { \n display: none !important;\n}\n.muigui-disabled {\n pointer-events: none;\n --color: var(--disabled-color) !important;\n --value-color: var(--disabled-color) !important;\n --range-left-color: var(--disabled-color) !important;\n}\n\n.muigui canvas,\n.muigui svg {\n display: block;\n border-radius: var(--border-radius);\n}\n.muigui canvas {\n background-color: var(--value-bg-color);\n}\n\n.muigui-controller {\n min-width: 0;\n min-height: var(--line-height);\n}\n.muigui-root,\n.muigui-menu {\n display: flex;\n flex-direction: column;\n position: relative;\n user-select: none;\n height: fit-content;\n margin: 0;\n padding-bottom: 0.1em;\n border-radius: var(--border-radius);\n}\n.muigui-menu {\n border-bottom: 1px solid var(--menu-sep-color);\n}\n\n.muigui-root>button:nth-child(1),\n.muigui-menu>button:nth-child(1) {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n position: relative;\n text-align: left;\n color: var(--color);\n background-color: var(--menu-bg-color);\n min-height: var(--line-height);\n padding-top: 0.2em;\n padding-bottom: 0.2em;\n cursor: pointer;\n border-radius: var(--border-radius);\n}\n.muigui-root>div:nth-child(2),\n.muigui-menu>div:nth-child(2) {\n flex: 1 1 auto;\n}\n\n.muigui-controller {\n margin-left: 0.2em;\n margin-right: 0.2em;\n}\n.muigui-root.muigui-controller,\n.muigui-menu.muigui-controller {\n margin-left: 0;\n margin-right: 0;\n}\n.muigui-controller>*:nth-child(1) {\n flex: 1 0 var(--label-width);\n min-width: 0;\n white-space: pre;\n}\n.muigui-controller>label:nth-child(1) {\n place-content: center start;\n display: inline-grid;\n overflow: hidden;\n}\n.muigui-controller>*:nth-child(2) {\n flex: 1 1 75%;\n min-width: 0;\n}\n\n/* -----------------------------------------\n a label controller is [[label][value]]\n*/\n\n.muigui-label-controller {\n display: flex;\n margin: 0.4em 0 0.4em 0;\n word-wrap: initial;\n align-items: stretch;\n}\n\n.muigui-value {\n display: flex;\n align-items: stretch;\n}\n.muigui-value>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n.muigui-value>*:nth-child(1) {\n flex: 1 1 calc(100% - var(--number-width));\n}\n.muigui-value>*:nth-child(2) {\n flex: 1 1 var(--number-width);\n margin-left: 0.2em;\n}\n\n/* fix! */\n.muigui-open>button>label::before,\n.muigui-closed>button>label::before {\n width: 1.25em;\n height: var(--line-height);\n display: inline-grid;\n place-content: center start;\n pointer-events: none;\n}\n.muigui-open>button>label::before {\n content: \"ⓧ\"; /*\"▼\";*/\n}\n.muigui-closed>button>label::before {\n content: \"⨁\"; /*\"▶\";*/\n}\n.muigui-open>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 0.5s ease-out;\n max-height: 100vh;\n overflow: auto;\n opacity: 1;\n}\n\n.muigui-closed>*:nth-child(2) {\n transition: max-height 0.2s ease-out,\n opacity 1s;\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n}\n\n/* ---- popdown ---- */\n\n.muigui-pop-down-top {\n display: flex;\n}\n/* fix? */\n.muigui-value>*:nth-child(1).muigui-pop-down-top {\n flex: 0;\n}\n.muigui-pop-down-bottom {\n\n}\n\n.muigui-pop-down-values {\n min-width: 0;\n display: flex;\n}\n.muigui-pop-down-values>* {\n flex: 1 1 auto;\n min-width: 0;\n}\n\n.muigui-value.muigui-pop-down-controller {\n flex-direction: column;\n}\n\n.muigui-pop-down-top input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-pop-down-top input[type=checkbox]::before {\n content: \"+\";\n display: grid;\n place-content: center;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n color: var(--value-bg-color);\n width: calc(var(--line-height) - 4px);\n height: calc(var(--line-height) - 4px);\n}\n\n.muigui-pop-down-top input[type=checkbox]:checked::before {\n content: \"X\";\n}\n\n\n/* ---- select ---- */\n\n.muigui select,\n.muigui option,\n.muigui input,\n.muigui button {\n color: var(--value-color);\n background-color: var(--value-bg-color);\n font-family: var(--font-family);\n font-size: var(--font-size);\n border: none;\n margin: 0;\n border-radius: var(--border-radius);\n}\n.muigui select {\n appearance: none;\n margin: 0;\n margin-left: 0; /*?*/\n overflow: hidden; /* Safari */\n}\n\n.muigui select:focus,\n.muigui input:focus,\n.muigui button:focus {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui select:hover,\n.muigui option:hover,\n.muigui input:hover,\n.muigui button:hover {\n background-color: var(--hover-bg-color); \n}\n\n/* ------ [ label ] ------ */\n\n.muigui-label {\n border-top: 1px solid var(--menu-sep-color);\n border-bottom: 1px solid var(--menu-sep-color);\n padding-top: 0.4em;\n padding-bottom: 0.3em;\n place-content: center start;\n background-color: var(--menu-bg-color);\n white-space: pre;\n border-radius: var(--border-radius);\n}\n\n/* ------ [ divider] ------ */\n\n.muigui-divider {\n min-height: 6px;\n border-top: 2px solid var(--menu-sep-color);\n margin-top: 6px;\n}\n\n/* ------ [ button ] ------ */\n\n.muigui-button {\n display: grid;\n\n}\n.muigui-button button {\n border: none;\n color: var(--value-color);\n background-color: var(--button-bg-color);\n cursor: pointer;\n place-content: center center;\n}\n\n/* ------ [ color ] ------ */\n\n.muigui-color>div {\n overflow: hidden;\n position: relative;\n margin-left: 0;\n margin-right: 0; /* why? */\n max-width: var(--line-height);\n border-radius: var(--border-radius);\n}\n\n.muigui-color>div:focus-within {\n outline: 1px solid var(--focus-color);\n}\n\n.muigui-color input[type=color] {\n border: none;\n padding: 0;\n background: inherit;\n cursor: pointer;\n position: absolute;\n width: 200%;\n left: -10px;\n top: -10px;\n height: 200%;\n}\n.muigui-disabled canvas,\n.muigui-disabled svg,\n.muigui-disabled img,\n.muigui-disabled .muigui-color input[type=color] {\n opacity: 0.2;\n}\n\n/* ------ [ checkbox ] ------ */\n\n.muigui-checkbox>label:nth-child(2) {\n display: grid;\n place-content: center start;\n margin: 0;\n}\n\n.muigui-checkbox input[type=checkbox] {\n -webkit-appearance: none;\n appearance: none;\n width: auto;\n color: var(--value-color);\n background-color: var(--value-bg-color);\n cursor: pointer;\n\n display: grid;\n place-content: center;\n margin: 0;\n font: inherit;\n color: currentColor;\n width: 1.7em;\n height: 1.7em;\n transform: translateY(-0.075em);\n}\n\n.muigui-checkbox input[type=checkbox]::before {\n content: \"\";\n color: var(--value-color);\n display: grid;\n place-content: center;\n}\n\n.muigui-checkbox input[type=checkbox]:checked::before {\n content: \"✔\";\n}\n\n.muigui input[type=number]::-webkit-inner-spin-button, \n.muigui input[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none;\n appearance: none;\n margin: 0; \n}\n.muigui input[type=number] {\n -moz-appearance: textfield;\n}\n\n/* ------ [ radio grid ] ------ */\n\n.muigui-radio-grid>div {\n display: grid;\n gap: 2px;\n}\n\n.muigui-radio-grid input {\n appearance: none;\n display: none;\n}\n\n.muigui-radio-grid button {\n color: var(--color);\n width: 100%;\n text-align: left;\n}\n\n.muigui-radio-grid input:checked + button {\n color: var(--value-color);\n background-color: var(--selected-color);\n}\n\n/* ------ [ color-chooser ] ------ */\n\n.muigui-color-chooser-cursor {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n.muigui-color-chooser-circle {\n stroke-width: 1px;\n stroke: white;\n fill: none;\n}\n\n\n/* ------ [ vec2 ] ------ */\n\n.muigui-vec2 svg {\n background-color: var(--value-bg-color);\n}\n\n.muigui-vec2-axis {\n stroke: 1px;\n stroke: var(--focus-color);\n}\n\n.muigui-vec2-line {\n stroke-width: 1px;\n stroke: var(--value-color);\n fill: var(--value-color);\n}\n\n/* ------ [ direction ] ------ */\n\n.muigui-direction svg {\n background-color: rgba(0,0,0,0.2);\n}\n\n.muigui-direction:focus-within svg {\n outline: none;\n}\n.muigui-direction-range {\n fill: var(--value-bg-color);\n}\n.muigui-direction svg:focus {\n outline: none;\n}\n.muigui-direction svg:focus .muigui-direction-range {\n stroke-width: 0.5px;\n stroke: var(--focus-color);\n}\n\n.muigui-direction-arrow {\n fill: var(--value-color);\n}\n\n/* ------ [ slider ] ------ */\n\n.muigui-slider>div {\n display: flex;\n align-items: stretch;\n height: var(--line-height);\n}\n.muigui-slider svg {\n flex: 1 1 auto;\n}\n.muigui-slider .muigui-slider-up #muigui-orientation {\n transform: scale(1, -1) translateY(-100%);\n}\n\n.muigui-slider .muigui-slider-up #muigui-number-orientation {\n transform: scale(1,-1);\n}\n\n.muigui-ticks {\n stroke: var(--range-color);\n}\n.muigui-thicks {\n stroke: var(--color);\n stroke-width: 2px;\n}\n.muigui-svg-text {\n fill: var(--color);\n font-size: 7px;\n}\n.muigui-mark {\n fill: var(--value-color);\n}\n\n/* ------ [ range ] ------ */\n\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: transparent;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n border-radius: calc(var(--border-radius) + 2px);\n border-left: 1px solid rgba(255,255,255,0.3);\n border-top: 1px solid rgba(255,255,255,0.3);\n border-bottom: 1px solid rgba(0,0,0,0.2);\n border-right: 1px solid rgba(0,0,0,0.2);\n background-color: var(--range-color);\n margin-top: calc((var(--line-height) - 2px) / -2);\n width: calc(var(--line-height) - 2px);\n height: calc(var(--line-height) - 2px);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n border: 1px solid var(--menu-sep-color);\n height: 2px;\n}\n\n\n/* dat.gui style - doesn't work on Safari iOS */\n\n/*\n.muigui-range input[type=range] {\n cursor: ew-resize;\n overflow: hidden;\n}\n\n.muigui-range input[type=range] {\n -webkit-appearance: none;\n appearance: none;\n background-color: var(--range-right-color);\n margin: 0;\n}\n.muigui-range input[type=range]:hover {\n background-color: var(--range-right-hover-color);\n}\n\n.muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: none;\n appearance: none;\n height: max-content;\n color: var(--range-left-color);\n margin-top: -1px;\n}\n\n.muigui-range input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 0px;\n height: max-content;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n}\n*/\n\n/* FF */\n/*\n.muigui-range input[type=range]::-moz-slider-progress {\n background-color: var(--range-left-color); \n}\n.muigui-range input[type=range]::-moz-slider-thumb {\n height: max-content;\n width: 0;\n border: none;\n box-shadow: -1000px 0 0 1000px var(--range-left-color);\n box-sizing: border-box;\n}\n*/\n\n.muigui-checkered-background {\n background-color: #404040;\n background-image:\n linear-gradient(45deg, #808080 25%, transparent 25%),\n linear-gradient(-45deg, #808080 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, #808080 75%),\n linear-gradient(-45deg, transparent 75%, #808080 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0px;\n}\n\n/* ---------------------------------------------------------- */\n\n/* needs to be at bottom to take precedence */\n.muigui-auto-place {\n max-height: 100%;\n position: fixed;\n top: 0;\n right: 15px;\n z-index: 100001;\n}\n\n`,\nthemes: {\n default: '',\n float: `\n :root {\n color-scheme: light dark,\n }\n\n .muigui {\n --width: 400px;\n --bg-color: initial;\n --label-width: 25%;\n --number-width: 20%;\n }\n\n input,\n .muigui-label-controller>label {\n text-shadow:\n -1px -1px 0 var(--contrast-color),\n 1px -1px 0 var(--contrast-color),\n -1px 1px 0 var(--contrast-color),\n 1px 1px 0 var(--contrast-color);\n }\n\n .muigui-controller > label:nth-child(1) {\n place-content: center end;\n margin-right: 1em;\n }\n\n .muigui-value > :nth-child(2) {\n margin-left: 1em;\n }\n\n .muigui-root>*:nth-child(1) {\n display: none;\n }\n\n .muigui-range input[type=range]::-webkit-slider-thumb {\n border-radius: 1em;\n }\n\n .muigui-range input[type=range]::-webkit-slider-runnable-track {\n -webkit-appearance: initial;\n appearance: none;\n border: 1px solid rgba(0, 0, 0, 0.25);\n height: 2px;\n }\n\n .muigui-colors {\n --value-color: var(--color );\n --value-bg-color: rgba(0, 0, 0, 0.1);\n --disabled-color: #cccccc;\n --menu-bg-color: rgba(0, 0, 0, 0.1);\n --menu-sep-color: #bbbbbb;\n --hover-bg-color: rgba(0, 0, 0, 0);\n --invalid-color: #FF0000;\n --selected-color: rgba(0, 0, 0, 0.3);\n --range-color: rgba(0, 0, 0, 0.125);\n }\n`,\n},\n};\n","export function setElemProps(elem, attrs, children) {\n for (const [key, value] of Object.entries(attrs)) {\n if (typeof value === 'function' && key.startsWith('on')) {\n const eventName = key.substring(2).toLowerCase();\n elem.addEventListener(eventName, value, {passive: false});\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n elem[key][k] = v;\n }\n } else if (elem[key] === undefined) {\n elem.setAttribute(key, value);\n } else {\n elem[key] = value;\n }\n }\n for (const child of children) {\n elem.appendChild(child);\n }\n return elem;\n}\n\nexport function createElem(tag, attrs = {}, children = []) {\n const elem = document.createElement(tag);\n setElemProps(elem, attrs, children);\n return elem;\n}\n\nexport function addElem(tag, parent, attrs = {}, children = []) {\n const elem = createElem(tag, attrs, children);\n parent.appendChild(elem);\n return elem;\n}\n\nlet nextId = 0;\nexport function getNewId() {\n return `muigui-id-${nextId++}`;\n}\n","export function removeArrayElem(array, value) {\n const ndx = array.indexOf(value);\n if (ndx) {\n array.splice(ndx, 1);\n }\n return array;\n}\n\n/**\n * Converts an camelCase or snake_case id to \"camel case\" or \"snake case\"\n * @param {string} id\n */\nconst underscoreRE = /_/g;\nconst upperLowerRE = /([A-Z])([a-z])/g;\nexport function idToLabel(id) {\n return id.replace(underscoreRE, ' ')\n .replace(upperLowerRE, (m, m1, m2) => `${m1.toLowerCase()} ${m2}`);\n}\n\nexport function clamp(v, min, max) {\n return Math.max(min, Math.min(max, v));\n}\n\nexport const isTypedArray = typeof SharedArrayBuffer !== 'undefined'\n ? function isArrayBufferOrSharedArrayBuffer(a) {\n return a && a.buffer && (a.buffer instanceof ArrayBuffer || a.buffer instanceof SharedArrayBuffer);\n }\n : function isArrayBuffer(a) {\n return a && a.buffer && a.buffer instanceof ArrayBuffer;\n };\n\nexport const isArrayOrTypedArray = v => Array.isArray(v) || isTypedArray(v);\n\n// Yea, I know this should be `Math.round(v / step) * step\n// but try step = 0.1, newV = 19.95\n//\n// I get\n// Math.round(19.95 / 0.1) * 0.1\n// 19.900000000000002\n// vs\n// Math.round(19.95 / 0.1) / (1 / 0.1)\n// 19.9\n//\nexport const stepify = (v, from, step) => Math.round(from(v) / step) / (1 / step);\n\nexport const euclideanModulo = (v, n) => ((v % n) + n) % n;\nexport const lerp = (a, b, t) => a + (b - a) * t;\nexport function copyExistingProperties(dst, src) {\n for (const key in src) {\n if (key in dst) {\n dst[key] = src[key];\n }\n }\n return dst;\n}\n\nexport const mapRange = (v, inMin, inMax, outMin, outMax) => (v - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;\n\nexport const makeRangeConverters = ({from, to}) => {\n return {\n to: v => mapRange(v, ...from, ...to),\n from: v => [true, mapRange(v, ...to, ...from)],\n };\n};\n\nexport const makeRangeOptions = ({from, to, step}) => {\n return {\n min: to[0],\n max: to[1],\n ...(step && {step}),\n converters: makeRangeConverters({from, to}),\n };\n};\n\n// TODO: remove an use one in conversions. Move makeRangeConverters there?\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\nexport function makeMinMaxPair(gui, properties, minPropName, maxPropName, options) {\n const { converters: { from } = identity } = options;\n const { min, max } = options;\n const guiMinRange = options.minRange || 0;\n const valueMinRange = from(guiMinRange)[1];\n const minGui = gui\n .add(properties, minPropName, {\n ...options,\n min,\n max: max - guiMinRange,\n })\n .onChange(v => {\n maxGui.setValue(Math.min(max, Math.max(v + valueMinRange, properties[maxPropName])));\n });\n const maxGui = gui\n .add(properties, maxPropName, {\n ...options,\n min: min + guiMinRange,\n max,\n })\n .onChange(v => {\n minGui.setValue(Math.max(min, Math.min(v - valueMinRange, properties[minPropName])));\n });\n return [ minGui, maxGui ];\n}\n\n","import { removeArrayElem } from '../libs/utils.js';\n\nexport default class View {\n domElement: HTMLElement;\n\n #childDestElem: HTMLElement;\n #views: View[] = [];\n\n constructor(elem: HTMLElement) {\n this.domElement = elem;\n this.#childDestElem = elem;\n }\n addElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n return elem;\n }\n removeElem(elem: HTMLElement) {\n this.#childDestElem.removeChild(elem);\n return elem;\n }\n pushSubElem(elem: HTMLElement) {\n this.#childDestElem.appendChild(elem);\n this.#childDestElem = elem;\n }\n popSubElem() {\n this.#childDestElem = this.#childDestElem.parentElement!;\n }\n add(view: View) {\n this.#views.push(view);\n this.addElem(view.domElement);\n return view;\n }\n remove(view: View) {\n this.removeElem(view.domElement);\n removeArrayElem(this.#views, view);\n return view;\n }\n pushSubView(view: View) {\n this.pushSubElem(view.domElement);\n }\n popSubView() {\n this.popSubElem();\n }\n setOptions(options: any) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n }\n updateDisplayIfNeeded(newV: any, ignoreCache?: boolean) {\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n $(selector: string) {\n return this.domElement.querySelector(selector);\n }\n}","import { createElem } from '../libs/elem.js';\nimport { removeArrayElem } from '../libs/utils.js';\nimport View from '../views/View.js';\n\nexport default class Controller extends View {\n #changeFns;\n #finishChangeFns;\n #parent;\n\n constructor(className) {\n super(createElem('div', {className: 'muigui-controller'}));\n this.#changeFns = [];\n this.#finishChangeFns = [];\n // we need the specialization to come last so it takes precedence.\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n get parent() {\n return this.#parent;\n }\n setParent(parent) {\n this.#parent = parent;\n this.enable(!this.disabled());\n }\n show(show = true) {\n this.domElement.classList.toggle('muigui-hide', !show);\n this.domElement.classList.toggle('muigui-show', show);\n return this;\n }\n hide() {\n return this.show(false);\n }\n disabled() {\n return !!this.domElement.closest('.muigui-disabled');\n }\n\n enable(enable = true) {\n this.domElement.classList.toggle('muigui-disabled', !enable);\n\n // If disabled we need to set the attribute 'disabled=true' to all\n // input/select/button/textarea's below\n //\n // If enabled we need to set the attribute 'disabled=false' to all below\n // until we hit a disabled controller.\n //\n // ATM the problem is we can find the input/select/button/textarea elements\n // but we can't easily find which controller they belong do.\n // But we don't need to? We can just check up if it or parent has\n // '.muigui-disabled'\n ['input', 'button', 'select', 'textarea'].forEach(tag => {\n this.domElement.querySelectorAll(tag).forEach(elem => {\n const disabled = !!elem.closest('.muigui-disabled');\n elem.disabled = disabled;\n });\n });\n\n return this;\n }\n disable(disable = true) {\n return this.enable(!disable);\n }\n onChange(fn) {\n this.removeChange(fn);\n this.#changeFns.push(fn);\n return this;\n }\n removeChange(fn) {\n removeArrayElem(this.#changeFns, fn);\n return this;\n }\n onFinishChange(fn) {\n this.removeFinishChange(fn);\n this.#finishChangeFns.push(fn);\n return this;\n }\n removeFinishChange(fn) {\n removeArrayElem(this.#finishChangeFns, fn);\n return this;\n }\n #callListeners(fns, newV) {\n for (const fn of fns) {\n fn.call(this, newV);\n }\n }\n emitChange(value, object, property) {\n this.#callListeners(this.#changeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n emitFinalChange(value, object, property) {\n this.#callListeners(this.#finishChangeFns, value);\n if (this.#parent) {\n if (object === undefined) {\n this.#parent.emitChange(value);\n } else {\n this.#parent.emitFinalChange({\n object,\n property,\n value,\n controller: this,\n });\n }\n }\n }\n updateDisplay() {\n // placeholder. override\n }\n getColors() {\n const toCamelCase = s => s.replace(/-([a-z])/g, (m, m1) => m1.toUpperCase());\n const keys = [\n 'color',\n 'bg-color',\n 'value-color',\n 'value-bg-color',\n 'hover-bg-color',\n 'menu-bg-color',\n 'menu-sep-color',\n 'disabled-color',\n ];\n const div = createElem('div');\n this.domElement.appendChild(div);\n const colors = Object.fromEntries(keys.map(key => {\n div.style.color = `var(--${key})`;\n const s = getComputedStyle(div);\n return [toCamelCase(key), s.color];\n }));\n div.remove();\n return colors;\n }\n}\n","import {\n createElem,\n} from '../libs/elem.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport Controller from './Controller.js';\n\nexport default class Button extends Controller {\n #object;\n #property;\n #buttonElem;\n #options = {\n name: '',\n };\n\n constructor(object, property, options = {}) {\n super('muigui-button', '');\n this.#object = object;\n this.#property = property;\n\n this.#buttonElem = this.addElem(\n createElem('button', {\n type: 'button',\n onClick: () => {\n this.#object[this.#property](this);\n },\n }));\n this.setOptions({name: property, ...options});\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {name} = this.#options;\n this.#buttonElem.textContent = name;\n }\n}","import { isTypedArray } from '../libs/utils.js';\nimport View from './View.js';\n\nfunction arraysEqual(a, b) {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; ++i) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction copyArrayElementsFromTo(src, dst) {\n dst.length = src.length;\n for (let i = 0; i < src.length; ++i) {\n dst[i] = src[i];\n }\n}\n\nexport default class EditView extends View {\n #oldV;\n #updateCheck;\n\n #checkArrayNeedsUpdate(newV) {\n // It's an array, we need to compare all elements\n // Example, vec2, [r,g,b], ...\n const needUpdate = !arraysEqual(newV, this.#oldV);\n if (needUpdate) {\n copyArrayElementsFromTo(newV, this.#oldV);\n }\n return needUpdate;\n }\n\n #checkTypedArrayNeedsUpdate() {\n let once = true;\n return function checkTypedArrayNeedsUpdateImpl(newV) {\n // It's a typedarray, we need to compare all elements\n // Example: Float32Array([r, g, b])\n let needUpdate = once;\n once = false;\n if (!needUpdate) {\n needUpdate = !arraysEqual(newV, this.#oldV);\n }\n return needUpdate;\n };\n }\n\n #checkObjectNeedsUpdate(newV) {\n let needUpdate = false;\n for (const key in newV) {\n if (newV[key] !== this.#oldV[key]) {\n needUpdate = true;\n this.#oldV[key] = newV[key];\n }\n }\n return needUpdate;\n }\n\n #checkValueNeedsUpdate(newV) {\n const needUpdate = newV !== this.#oldV;\n this.#oldV = newV;\n return needUpdate;\n }\n\n #getUpdateCheckForType(newV) {\n if (Array.isArray(newV)) {\n this.#oldV = [];\n return this.#checkArrayNeedsUpdate.bind(this);\n } else if (isTypedArray(newV)) {\n this.#oldV = new newV.constructor(newV);\n return this.#checkTypedArrayNeedsUpdate(this);\n } else if (typeof newV === 'object') {\n this.#oldV = {};\n return this.#checkObjectNeedsUpdate.bind(this);\n } else {\n return this.#checkValueNeedsUpdate.bind(this);\n }\n }\n\n // The point of this is updating DOM elements\n // is slow but if we've called `listen` then\n // every frame we're going to try to update\n // things with the current value so if nothing\n // has changed then skip it.\n updateDisplayIfNeeded(newV, ignoreCache) {\n this.#updateCheck = this.#updateCheck || this.#getUpdateCheckForType(newV);\n // Note: We call #updateCheck first because it updates\n // the cache\n if (this.#updateCheck(newV) || ignoreCache) {\n this.updateDisplay(newV);\n }\n }\n setOptions(/*options*/) {\n // override this\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class CheckboxView extends EditView {\n #checkboxElem;\n constructor(setter, id) {\n const checkboxElem = createElem('input', {\n type: 'checkbox',\n id,\n onInput: () => {\n setter.setValue(checkboxElem.checked);\n },\n onChange: () => {\n setter.setFinalValue(checkboxElem.checked);\n },\n });\n super(createElem('label', {}, [checkboxElem]));\n this.#checkboxElem = checkboxElem;\n }\n updateDisplay(v) {\n this.#checkboxElem.checked = v;\n }\n}\n","import { removeArrayElem } from './utils.js';\n\nconst tasks = [];\nconst tasksToRemove = new Set();\n\nlet requestId;\nlet processing;\n\nfunction removeTasks() {\n if (!tasksToRemove.size) {\n return;\n }\n\n if (processing) {\n queueProcessing();\n return;\n }\n\n tasksToRemove.forEach(task => {\n removeArrayElem(tasks, task);\n });\n tasksToRemove.clear();\n}\n\nfunction processTasks() {\n requestId = undefined;\n processing = true;\n for (const task of tasks) {\n if (!tasksToRemove.has(task)) {\n task();\n }\n }\n processing = false;\n removeTasks();\n queueProcessing();\n}\n\nfunction queueProcessing() {\n if (!requestId && tasks.length) {\n requestId = requestAnimationFrame(processTasks);\n }\n}\n\nexport function addTask(fn) {\n tasks.push(fn);\n queueProcessing();\n}\n\nexport function removeTask(fn) {\n tasksToRemove.set(fn);\n\n const ndx = tasks.indexOf(fn);\n if (ndx >= 0) {\n tasks.splice(ndx, 1);\n }\n}","let id = 0;\n\nexport function makeId() {\n return `muigui-${++id}`;\n}\n","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ValueView extends View {\n constructor(className = '') {\n super(createElem('div', {className: 'muigui-value'}));\n if (className) {\n this.domElement.classList.add(className);\n }\n }\n}","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport ValueView from '../views/ValueView.js';\nimport Controller from './Controller.js';\n\nexport default class LabelController extends Controller {\n #id;\n #nameElem;\n\n constructor(className = '', name = '') {\n super('muigui-label-controller');\n this.#id = makeId();\n this.#nameElem = createElem('label', {for: this.#id});\n this.domElement.appendChild(this.#nameElem);\n this.pushSubView(new ValueView(className));\n this.name(name);\n }\n get id() {\n return this.#id;\n }\n name(name) {\n if (this.#nameElem.title === this.#nameElem.textContent) {\n this.#nameElem.title = name;\n }\n this.#nameElem.textContent = name;\n return this;\n }\n tooltip(tip) {\n this.#nameElem.title = tip;\n }\n}\n\n","import {addTask, removeTask} from '../libs/taskrunner.js';\nimport { isTypedArray } from '../libs/utils.js';\nimport LabelController from './LabelController.js';\n\nexport default class ValueController extends LabelController {\n #object;\n #property;\n #initialValue;\n #listening;\n #views;\n #updateFn;\n\n constructor(object, property, className = '') {\n super(className, property);\n this.#object = object;\n this.#property = property;\n this.#initialValue = this.getValue();\n this.#listening = false;\n this.#views = [];\n }\n get initialValue() {\n return this.#initialValue;\n }\n get object() {\n return this.#object;\n }\n get property() {\n return this.#property;\n }\n add(view) {\n this.#views.push(view);\n super.add(view);\n this.updateDisplay();\n return view;\n }\n #setValueImpl(v, ignoreCache) {\n let isDifferent = false;\n if (typeof v === 'object') {\n const dst = this.#object[this.#property];\n // don't replace objects, just their values.\n if (Array.isArray(v) || isTypedArray(v)) {\n for (let i = 0; i < v.length; ++i) {\n isDifferent ||= dst[i] !== v[i];\n dst[i] = v[i];\n }\n } else {\n for (const key of Object.keys(v)) {\n isDifferent ||= dst[key] !== v[key];\n }\n Object.assign(dst, v);\n }\n } else {\n isDifferent = this.#object[this.#property] !== v;\n this.#object[this.#property] = v;\n }\n this.updateDisplay(ignoreCache);\n if (isDifferent) {\n this.emitChange(this.getValue(), this.#object, this.#property);\n }\n return isDifferent;\n }\n setValue(v) {\n this.#setValueImpl(v);\n }\n setFinalValue(v) {\n const isDifferent = this.#setValueImpl(v, true);\n if (isDifferent) {\n this.emitFinalChange(this.getValue(), this.#object, this.#property);\n }\n return this;\n }\n updateDisplay(ignoreCache) {\n const newV = this.getValue();\n for (const view of this.#views) {\n view.updateDisplayIfNeeded(newV, ignoreCache);\n }\n return this;\n }\n setOptions(options) {\n for (const view of this.#views) {\n view.setOptions(options);\n }\n this.updateDisplay();\n return this;\n }\n getValue() {\n return this.#object[this.#property];\n }\n value(v) {\n this.setValue(v);\n return this;\n }\n reset() {\n this.setValue(this.#initialValue);\n return this;\n }\n listen(listen = true) {\n if (!this.#updateFn) {\n this.#updateFn = this.updateDisplay.bind(this);\n }\n if (listen) {\n if (!this.#listening) {\n this.#listening = true;\n addTask(this.#updateFn);\n }\n } else {\n if (this.#listening) {\n this.#listening = false;\n removeTask(this.#updateFn);\n }\n }\n return this;\n }\n}\n\n","import CheckboxView from '../views/CheckboxView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Checkbox extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n const id = this.id;\n this.add(new CheckboxView(this, id));\n this.updateDisplay();\n }\n}","import {\n makeRangeConverters,\n} from './utils.js';\n\nexport const identity = {\n to: v => v,\n from: v => [true, v],\n};\n\n// from: from string to value\n// to: from value to string\nexport const strToNumber = {\n to: v => v.toString(),\n from: v => {\n const newV = parseFloat(v);\n return [!Number.isNaN(newV), newV];\n },\n};\n\nexport const converters = {\n radToDeg: makeRangeConverters({to: [0, 180], from: [0, Math.PI]}),\n};\n","export function createWheelHelper() {\n let wheelAccum = 0;\n return function (e, step, wheelScale = 5) {\n wheelAccum -= e.deltaY * step / wheelScale;\n const wheelSteps = Math.floor(Math.abs(wheelAccum) / step) * Math.sign(wheelAccum);\n const delta = wheelSteps * step;\n wheelAccum -= delta;\n return delta;\n };\n}\n","import { createElem } from '../libs/elem.js';\nimport { strToNumber } from '../libs/conversions.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nexport default class NumberView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n converters: strToNumber,\n min: Number.NEGATIVE_INFINITY,\n max: Number.POSITIVE_INFINITY,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'number',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const v = parseFloat(this.domElement.value);\n const [valid, newV] = this.#from(v);\n let inRange;\n if (valid && !Number.isNaN(v)) {\n const {min, max} = this.#options;\n inRange = newV >= min && newV <= max;\n this.#skipUpdate = skipUpdate;\n setFn(clamp(newV, min, max));\n }\n this.domElement.classList.toggle('muigui-invalid-value', !valid || !inRange);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n return this;\n }\n}\n","\nimport NumberView from '../views/NumberView.js';\nimport ValueController from './ValueController.js';\n\n// Wanted to name this `Number` but it conflicts with\n// JavaScript `Number`. It most likely wouldn't be\n// an issue? But users might `import {Number} ...` and\n// things would break.\nexport default class TextNumber extends ValueController {\n #textView;\n #step;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-checkbox');\n this.#textView = this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport EditView from './EditView.js';\n\nexport default class SelectView extends EditView {\n #values;\n\n constructor(setter, keyValues) {\n const values = [];\n super(createElem('select', {\n onChange: () => {\n setter.setFinalValue(this.#values[this.domElement.selectedIndex]);\n },\n }, keyValues.map(([key, value]) => {\n values.push(value);\n return createElem('option', {textContent: key});\n })));\n this.#values = values;\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n this.domElement.selectedIndex = ndx;\n }\n}\n","\n// 4 cases\n// (a) keyValues is array of arrays, each sub array is key value\n// (b) keyValues is array and value is number then keys = array contents, value = index\n// (c) keyValues is array and value is not number, key = array contents, value = array contents\n// (d) keyValues is object then key->value\nexport function convertToKeyValues(keyValues, valueIsNumber) {\n if (Array.isArray(keyValues)) {\n if (Array.isArray(keyValues[0])) {\n // (a) keyValues is array of arrays, each sub array is key value\n return keyValues;\n } else {\n if (valueIsNumber) {\n // (b) keyValues is array and value is number then keys = array contents, value = index\n return keyValues.map((v, ndx) => [v, ndx]);\n } else {\n // (c) keyValues is array and value is not number, key = array contents, value = array contents\n return keyValues.map(v => [v, v]);\n }\n }\n } else {\n // (d)\n return [...Object.entries(keyValues)];\n }\n}\n","import SelectView from '../views/SelectView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class Select extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-select');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {keyValues: keyValuesInput} = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new SelectView(this, keyValues));\n this.updateDisplay();\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport EditView from './EditView.js';\n\nexport default class RangeView extends EditView {\n #to;\n #from;\n #step;\n #skipUpdate;\n #options = {\n step: 0.01,\n min: 0,\n max: 1,\n converters: identity,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('input', {\n type: 'range',\n onInput: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setValue(validV);\n }\n },\n onChange: () => {\n this.#skipUpdate = true;\n const {min, max, step} = this.#options;\n const v = parseFloat(this.domElement.value);\n const newV = clamp(stepify(v, v => v, step), min, max);\n const [valid, validV] = this.#from(newV);\n if (valid) {\n setter.setFinalValue(validV);\n }\n },\n onWheel: e => {\n e.preventDefault();\n const [valid, v] = this.#from(parseFloat(this.domElement.value));\n if (!valid) {\n return;\n }\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(v + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.setOptions(options);\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = stepify(v, this.#to, this.#step);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n step,\n min,\n max,\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n this.#step = step;\n this.domElement.step = step;\n this.domElement.min = min;\n this.domElement.max = max;\n return this;\n }\n}","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport RangeView from '../views/RangeView.js';\n\nexport default class Range extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-range');\n this.add(new RangeView(this, options));\n this.add(new NumberView(this, options));\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class TextView extends EditView {\n #to;\n #from;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const setValue = setter.setValue.bind(setter);\n const setFinalValue = setter.setFinalValue.bind(setter);\n super(createElem('input', {\n type: 'text',\n onInput: () => this.#handleInput(setValue, true),\n onChange: () => this.#handleInput(setFinalValue, false),\n }));\n this.setOptions(options);\n }\n #handleInput(setFn, skipUpdate) {\n const [valid, newV] = this.#from(this.domElement.value);\n if (valid) {\n this.#skipUpdate = skipUpdate;\n setFn(newV);\n }\n this.domElement.style.color = valid ? '' : 'var(--invalid-color)';\n\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.domElement.value = this.#to(v);\n this.domElement.style.color = '';\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {\n converters: {to, from},\n } = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import TextView from '../views/TextView.js';\nimport ValueController from './ValueController.js';\n\nexport default class Text extends ValueController {\n constructor(object, property) {\n super(object, property, 'muigui-checkbox');\n this.add(new TextView(this));\n this.updateDisplay();\n }\n}","const clamp = (v, min, max) => Math.max(min, Math.min(max, v));\nconst lerp = (a, b, t) => a + (b - a) * t;\nconst fract = v => v >= 0 ? v % 1 : 1 - (v % 1);\n\nconst f0 = v => +v.toFixed(0); // converts to string (eg 1.2 => \"1\"), then converts back to number (eg, \"1.200\" => 1.2)\nconst f3 = v => +v.toFixed(3); // converts to string (eg 1.2 => \"1.200\"), then converts back to number (eg, \"1.200\" => 1.2)\n\nconst hexToUint32RGB = v => (parseInt(v.substring(1, 3), 16) << 16) |\n (parseInt(v.substring(3, 5), 16) << 8 ) |\n (parseInt(v.substring(5, 7), 16) );\nconst uint32RGBToHex = v => `#${(Math.round(v)).toString(16).padStart(6, '0')}`;\nconst hexToUint32RGBA = v => (parseInt(v.substring(1, 3), 16) * 2 ** 24) +\n (parseInt(v.substring(3, 5), 16) * 2 ** 16) +\n (parseInt(v.substring(5, 7), 16) * 2 ** 8) +\n (parseInt(v.substring(7, 9), 16) );\nconst uint32RGBAToHex = v => `#${(Math.round(v)).toString(16).padStart(8, '0')}`;\n\nexport const hexToUint8RGB = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n];\nexport const uint8RGBToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToUint8RGBA = v => [\n parseInt(v.substring(1, 3), 16),\n parseInt(v.substring(3, 5), 16),\n parseInt(v.substring(5, 7), 16),\n parseInt(v.substring(7, 9), 16),\n];\nexport const uint8RGBAToHex = v => `#${Array.from(v).map(v => v.toString(16).padStart(2, '0')).join('')}`;\n\nexport const hexToFloatRGB = v => hexToUint8RGB(v).map(v => f3(v / 255));\nexport const floatRGBToHex = v => uint8RGBToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nexport const hexToFloatRGBA = v => hexToUint8RGBA(v).map(v => f3(v / 255));\nexport const floatRGBAToHex = v => uint8RGBAToHex(Array.from(v).map(v => Math.round(clamp(v * 255, 0, 255))));\n\nconst scaleAndClamp = v => clamp(Math.round(v * 255), 0, 255).toString(16).padStart(2, '0');\n\nconst hexToObjectRGB = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n});\nconst objectRGBToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}`;\nconst hexToObjectRGBA = v => ({\n r: parseInt(v.substring(1, 3), 16) / 255,\n g: parseInt(v.substring(3, 5), 16) / 255,\n b: parseInt(v.substring(5, 7), 16) / 255,\n a: parseInt(v.substring(7, 9), 16) / 255,\n});\nconst objectRGBAToHex = v => `#${scaleAndClamp(v.r)}${scaleAndClamp(v.g)}${scaleAndClamp(v.b)}${scaleAndClamp(v.a)}`;\n\nconst hexToCssRGB = v => `rgb(${hexToUint8RGB(v).join(', ')})`;\nconst cssRGBRegex = /^\\s*rgb\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\s*$/;\nconst cssRGBToHex = v => {\n const m = cssRGBRegex.exec(v);\n return uint8RGBToHex([m[1], m[2], m[3]].map(v => parseInt(v)));\n};\nconst hexToCssRGBA = v => `rgba(${hexToUint8RGBA(v).map((v, i) => i === 3 ? v / 255 : v).join(', ')})`;\nconst cssRGBARegex = /^\\s*rgba\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\nconst cssRGBAToHex = v => {\n const m = cssRGBARegex.exec(v);\n return uint8RGBAToHex([m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? (parseFloat(v) * 255 | 0) : parseInt(v)));\n};\n\nconst hexToCssHSL = v => {\n const hsl = rgbUint8ToHsl(hexToUint8RGB(v)).map(v => f0(v));\n return `hsl(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%)`;\n};\nconst hexToCssHSLA = v => {\n const hsla = rgbaUint8ToHsla(hexToUint8RGBA(v)).map((v, i) => i === 3 ? f3(v) : f0(v));\n return `hsl(${hsla[0]} ${hsla[1]}% ${hsla[2]}% / ${hsla[3]})`;\n};\nconst cssHSLRegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\)\\s*$/;\nconst cssHSLARegex = /^\\s*hsl\\(\\s*(\\d+)(?:deg|)\\s*(?:,|)\\s*(\\d+)%\\s*(?:,|)\\s*(\\d+)%\\s*\\/\\s*(\\d+\\.\\d+|\\d+)\\s*\\)\\s*$/;\n\nconst hex3DigitTo6Digit = v => `${v[0]}${v[0]}${v[1]}${v[1]}${v[2]}${v[2]}`;\nconst cssHSLToHex = v => {\n const m = cssHSLRegex.exec(v);\n const rgb = hslToRgbUint8([m[1], m[2], m[3]].map(v => parseFloat(v)));\n return uint8RGBToHex(rgb);\n};\nconst cssHSLAToHex = v => {\n const m = cssHSLARegex.exec(v);\n const rgba = hslaToRgbaUint8([m[1], m[2], m[3], m[4]].map(v => parseFloat(v)));\n return uint8RGBAToHex(rgba);\n};\n\nconst euclideanModulo = (v, n) => ((v % n) + n) % n;\n\nexport function hslToRgbUint8([h, s, l]) {\n h = euclideanModulo(h, 360);\n s = clamp(s / 100, 0, 1);\n l = clamp(l / 100, 0, 1);\n\n const a = s * Math.min(l, 1 - l);\n\n function f(n) {\n const k = (n + h / 30) % 12;\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n\n return [f(0), f(8), f(4)].map(v => Math.round(v * 255));\n}\n\nexport function hslaToRgbaUint8([h, s, l, a]) {\n const rgb = hslToRgbUint8([h, s, l]);\n return [...rgb, a * 255 | 0];\n}\n\nexport function rgbFloatToHsl01([r, g, b]) {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (min + max) * 0.5;\n const d = max - min;\n let h = 0;\n let s = 0;\n\n if (d !== 0) {\n s = (l === 0 || l === 1)\n ? 0\n : (max - l) / Math.min(l, 1 - l);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4;\n }\n }\n\n return [h / 6, s, l];\n}\n\nexport function rgbaFloatToHsla01([r, g, b, a]) {\n const hsl = rgbFloatToHsl01([r, g, b]);\n return [...hsl, a];\n}\n\nexport const rgbUint8ToHsl = (rgb) => {\n const [h, s, l] = rgbFloatToHsl01(rgb.map(v => v / 255));\n return [h * 360, s * 100, l * 100];\n};\n\nexport const rgbaUint8ToHsla = (rgba) => {\n const [h, s, l, a] = rgbaFloatToHsla01(rgba.map(v => v / 255));\n return [h * 360, s * 100, l * 100, a];\n};\n\nexport function hsv01ToRGBFloat([hue, sat, val]) {\n sat = clamp(sat, 0, 1);\n val = clamp(val, 0, 1);\n return [hue, hue + 2 / 3, hue + 1 / 3].map(\n v => lerp(1, clamp(Math.abs(fract(v) * 6 - 3.0) - 1, 0, 1), sat) * val\n );\n}\n\nexport function hsva01ToRGBAFloat([hue, sat, val, alpha]) {\n const rgb = hsv01ToRGBFloat([hue, sat, val]);\n return [...rgb, alpha];\n}\n\nconst round3 = v => Math.round(v * 1000) / 1000;\n\nexport function rgbFloatToHSV01([r, g, b]) {\n const p = b > g\n ? [b, g, -1, 2 / 3]\n : [g, b, 0, -1 / 3];\n const q = p[0] > r\n ? [p[0], p[1], p[3], r]\n : [r, p[1], p[2], p[0]];\n const d = q[0] - Math.min(q[3], q[1]);\n return [\n Math.abs(q[2] + (q[3] - q[1]) / (6 * d + Number.EPSILON)),\n d / (q[0] + Number.EPSILON),\n q[0],\n ].map(round3);\n}\n\nexport function rgbaFloatToHSVA01([r, g, b, a]) {\n const hsv = rgbFloatToHSV01([r, g, b]);\n return [...hsv, a];\n}\n\n// window.hsv01ToRGBFloat = hsv01ToRGBFloat;\n// window.rgbFloatToHSV01 = rgbFloatToHSV01;\n\n// Yea, meh!\nexport const hasAlpha = format => format.endsWith('a') || format.startsWith('hex8');\n\nconst cssStringFormats = [\n { re: /^#(?:[0-9a-f]){6}$/i, format: 'hex6' },\n { re: /^(?:[0-9a-f]){6}$/i, format: 'hex6-no-hash' },\n { re: /^#(?:[0-9a-f]){8}$/i, format: 'hex8' },\n { re: /^(?:[0-9a-f]){8}$/i, format: 'hex8-no-hash' },\n { re: /^#(?:[0-9a-f]){3}$/i, format: 'hex3' },\n { re: /^(?:[0-9a-f]){3}$/i, format: 'hex3-no-hash' },\n { re: cssRGBRegex, format: 'css-rgb' },\n { re: cssHSLRegex, format: 'css-hsl' },\n { re: cssRGBARegex, format: 'css-rgba' },\n { re: cssHSLARegex, format: 'css-hsla' },\n];\n\nfunction guessStringColorFormat(v) {\n for (const formatInfo of cssStringFormats) {\n if (formatInfo.re.test(v)) {\n return formatInfo;\n }\n }\n return undefined;\n}\n\nexport function guessFormat(v) {\n switch (typeof v) {\n case 'number':\n console.warn('can not reliably guess format based on a number. You should pass in a format like {format: \"uint32-rgb\"} or {format: \"uint32-rgb\"}');\n return v <= 0xFFFFFF ? 'uint32-rgb' : 'uint32-rgba';\n case 'string': {\n const formatInfo = guessStringColorFormat(v.trim());\n if (formatInfo) {\n return formatInfo.format;\n }\n break;\n }\n case 'object':\n if (v instanceof Uint8Array || v instanceof Uint8ClampedArray) {\n if (v.length === 3) {\n return 'uint8-rgb';\n } else if (v.length === 4) {\n return 'uint8-rgba';\n }\n } else if (v instanceof Float32Array) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else if (Array.isArray(v)) {\n if (v.length === 3) {\n return 'float-rgb';\n } else if (v.length === 4) {\n return 'float-rgba';\n }\n } else {\n if ('r' in v && 'g' in v && 'b' in v) {\n if ('a' in v) {\n return 'object-rgba';\n } else {\n return 'object-rgb';\n }\n }\n }\n }\n throw new Error(`unknown color format: ${v}`);\n}\n\nfunction fixHex6(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction fixHex8(v) {\n return v.trim(v);\n //const formatInfo = guessStringColorFormat(v.trim());\n //const fix = formatInfo ? formatInfo.fix : v => v;\n //return fix(v.trim());\n}\n\nfunction hex6ToHex3(hex6) {\n return (hex6[1] === hex6[2] &&\n hex6[3] === hex6[4] &&\n hex6[5] === hex6[6])\n ? `#${hex6[1]}${hex6[3]}${hex6[5]}`\n : hex6;\n}\n\nconst hex3RE = /^(#|)([0-9a-f]{3})$/i;\nfunction hex3ToHex6(hex3) {\n const m = hex3RE.exec(hex3);\n if (m) {\n const [, , m2] = m;\n return `#${hex3DigitTo6Digit(m2)}`;\n }\n return hex3;\n}\n\nfunction fixHex3(v) {\n return hex6ToHex3(fixHex6(v));\n}\n\nconst strToRGBObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgb = JSON.parse(json);\n if (Number.isNaN(rgb.r) || Number.isNaN(rgb.g) || Number.isNaN(rgb.b)) {\n throw new Error('not {r, g, b}');\n }\n return [true, rgb];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToRGBAObject = (s) => {\n try {\n const json = s.replace(/([a-z])/g, '\"$1\"');\n const rgba = JSON.parse(json);\n if (Number.isNaN(rgba.r) || Number.isNaN(rgba.g) || Number.isNaN(rgba.b) || Number.isNaN(rgba.a)) {\n throw new Error('not {r, g, b, a}');\n }\n return [true, rgba];\n } catch (e) {\n return [false];\n }\n};\n\nconst strToCssRGB = s => {\n const m = cssRGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgb(${v.join(', ')})`];\n};\n\nconst strToCssRGBA = s => {\n const m = cssRGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map((v, i) => i === 3 ? parseFloat(v) : parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, `rgba(${v.join(', ')})`];\n};\n\nconst strToCssHSL = s => {\n const m = cssHSLRegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]}, ${v[1]}%, ${v[2]}%)`];\n};\n\nconst strToCssHSLA = s => {\n const m = cssHSLARegex.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseFloat(v));\n const outOfRange = v.find(v => Number.isNaN(v));\n return [!outOfRange, `hsl(${v[0]} ${v[1]}% ${v[2]}% / ${v[3]})`];\n};\n\nconst rgbObjectToStr = rgb => {\n return `{r:${f3(rgb.r)}, g:${f3(rgb.g)}, b:${f3(rgb.b)}}`;\n};\nconst rgbaObjectToStr = rgba => {\n return `{r:${f3(rgba.r)}, g:${f3(rgba.g)}, b:${f3(rgba.b)}}, a:${f3(rgba.a)}}`;\n};\n\nconst strTo3IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo3Ints = s => {\n const m = strTo3IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo4IntsRE = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*$/;\nconst strTo4Ints = s => {\n const m = strTo4IntsRE.exec(s);\n if (!m) {\n return [false];\n }\n const v = [m[1], m[2], m[3], m[4]].map(v => parseInt(v));\n const outOfRange = v.find(v => v > 255);\n return [!outOfRange, v];\n};\n\nconst strTo3Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 3) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strTo4Floats = s => {\n const numbers = s.split(',').map(s => s.trim());\n const v = numbers.map(v => parseFloat(v));\n if (v.length !== 4) {\n return [false];\n }\n // Note: using isNaN not Number.isNaN\n const badNdx = numbers.findIndex(v => isNaN(v));\n return [badNdx < 0, v.map(v => f3(v))];\n};\n\nconst strToUint32RGBRegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,6})\\s*$/i;\nconst strToUint32RGB = s => {\n const m = strToUint32RGBRegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst strToUint32RGBARegex = /^\\s*(?:0x){0,1}([0-9a-z]{1,8})\\s*$/i;\nconst strToUint32RGBA = s => {\n const m = strToUint32RGBARegex.exec(s);\n if (!m) {\n return [false];\n }\n return [true, parseInt(m[1], 16)];\n};\n\nconst hex6RE = /^\\s*#[a-f0-9]{6}\\s*$|^\\s*#[a-f0-9]{3}\\s*$/i;\nconst hexNoHash6RE = /^\\s*[a-f0-9]{6}\\s*$/i;\nconst hex8RE = /^\\s*#[a-f0-9]{8}\\s*$/i;\nconst hexNoHash8RE = /^\\s*[a-f0-9]{8}\\s*$/i;\n\n// For each format converter\n//\n// fromHex/toHex convert from/to '#RRGGBB'\n//\n// fromHex converts from the string '#RRBBGG' to the format\n// (eg: for uint32-rgb, '#123456' becomes 0x123456)\n//\n// toHex converts from the format to '#RRGGBB'\n// (eg: for uint8-rgb, [16, 33, 50] becomes '#102132')\n//\n//\n// fromStr/toStr convert from/to what's in the input[type=text] element\n//\n// toStr converts from the format to its string representation\n// (eg, for object-rgb, {r: 1, g: 0.5, b:0} becomes \"{r: 1, g: 0.5, b:0}\")\n// ^object ^string\n//\n// fromStr converts its string representation to its format\n// (eg, for object-rgb) \"{r: 1, g: 0.5, b:0}\" becomes {r: 1, g: 0.5, b:0})\n// ^string ^object\n// fromString returns an array which is [valid, v]\n// where valid is true if the string was a valid and v is the converted\n// format if v is true.\n//\n// Note: toStr should convert to \"ideal\" form (whatever that is).\n// (eg, for css-rgb\n// \"{ r: 0.10000, g: 001, b: 0}\" becomes \"{r: 0.1, g: 1, b: 0}\"\n// notice that css-rgb is a string to a string\n// )\nexport const colorFormatConverters = {\n 'hex6': {\n color: {\n from: v => [true, v],\n to: fixHex6,\n },\n text: {\n from: v => [hex6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8': {\n color: {\n from: v => [true, v],\n to: fixHex8,\n },\n text: {\n from: v => [hex8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3': {\n color: {\n from: v => [true, fixHex3(v)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hex6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'hex6-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex6(v)}`,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex8-no-hash': {\n color: {\n from: v => [true, v.substring(1)],\n to: v => `#${fixHex8(v)}`,\n },\n text: {\n from: v => [hexNoHash8RE.test(v), v.trim()],\n to: v => v,\n },\n },\n 'hex3-no-hash': {\n color: {\n from: v => [true, fixHex3(v).substring(1)],\n to: hex3ToHex6,\n },\n text: {\n from: v => [hexNoHash6RE.test(v), hex6ToHex3(v.trim())],\n to: v => v,\n },\n },\n 'uint32-rgb': {\n color: {\n from: v => [true, hexToUint32RGB(v)],\n to: uint32RGBToHex,\n },\n text: {\n from: v => strToUint32RGB(v),\n to: v => `0x${v.toString(16).padStart(6, '0')}`,\n },\n },\n 'uint32-rgba': {\n color: {\n from: v => [true, hexToUint32RGBA(v)],\n to: uint32RGBAToHex,\n },\n text: {\n from: v => strToUint32RGBA(v),\n to: v => `0x${v.toString(16).padStart(8, '0')}`,\n },\n },\n 'uint8-rgb': {\n color: {\n from: v => [true, hexToUint8RGB(v)],\n to: uint8RGBToHex,\n },\n text: {\n from: strTo3Ints,\n to: v => v.join(', '),\n },\n },\n 'uint8-rgba': {\n color: {\n from: v => [true, hexToUint8RGBA(v)],\n to: uint8RGBAToHex,\n },\n text: {\n from: strTo4Ints,\n to: v => v.join(', '),\n },\n },\n 'float-rgb': {\n color: {\n from: v => [true, hexToFloatRGB(v)],\n to: floatRGBToHex,\n },\n text: {\n from: strTo3Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'float-rgba': {\n color: {\n from: v => [true, hexToFloatRGBA(v)],\n to: floatRGBAToHex,\n },\n text: {\n from: strTo4Floats,\n // need Array.from because map of Float32Array makes a Float32Array\n to: v => Array.from(v).map(v => f3(v)).join(', '),\n },\n },\n 'object-rgb': {\n color: {\n from: v => [true, hexToObjectRGB(v)],\n to: objectRGBToHex,\n },\n text: {\n from: strToRGBObject,\n to: rgbObjectToStr,\n },\n },\n 'object-rgba': {\n color: {\n from: v => [true, hexToObjectRGBA(v)],\n to: objectRGBAToHex,\n },\n text: {\n from: strToRGBAObject,\n to: rgbaObjectToStr,\n },\n },\n 'css-rgb': {\n color: {\n from: v => [true, hexToCssRGB(v)],\n to: cssRGBToHex,\n },\n text: {\n from: strToCssRGB,\n to: v => strToCssRGB(v)[1],\n },\n },\n 'css-rgba': {\n color: {\n from: v => [true, hexToCssRGBA(v)],\n to: cssRGBAToHex,\n },\n text: {\n from: strToCssRGBA,\n to: v => strToCssRGBA(v)[1],\n },\n },\n 'css-hsl': {\n color: {\n from: v => [true, hexToCssHSL(v)],\n to: cssHSLToHex,\n },\n text: {\n from: strToCssHSL,\n to: v => strToCssHSL(v)[1],\n },\n },\n 'css-hsla': {\n color: {\n from: v => [true, hexToCssHSLA(v)],\n to: cssHSLAToHex,\n },\n text: {\n from: strToCssHSLA,\n to: v => strToCssHSLA(v)[1],\n },\n },\n};","import { createElem } from '../libs/elem.js';\nimport View from './View.js';\n\nexport default class ElementView extends View {\n constructor(tag, className) {\n super(createElem(tag, {className}));\n }\n}","import ElementView from '../views/ElementView.js';\nimport LabelController from './LabelController.js';\n\n// TODO: remove this? Should just be user side\nexport default class Canvas extends LabelController {\n #canvasElem;\n\n constructor() {\n super('muigui-canvas');\n this.#canvasElem = this.add(\n new ElementView('canvas', 'muigui-canvas'),\n ).domElement;\n }\n get canvas() {\n return this.#canvasElem;\n }\n}","import { createElem } from '../libs/elem.js';\nimport { identity } from '../libs/conversions.js';\nimport EditView from './EditView.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nexport default class ColorView extends EditView {\n #to;\n #from;\n #colorElem;\n #skipUpdate;\n #options = {\n converters: identity,\n };\n\n constructor(setter, options) {\n const colorElem = createElem('input', {\n type: 'color',\n onInput: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setValue(newV);\n }\n },\n onChange: () => {\n const [valid, newV] = this.#from(colorElem.value);\n if (valid) {\n this.#skipUpdate = true;\n setter.setFinalValue(newV);\n }\n },\n });\n super(createElem('div', {}, [colorElem]));\n this.setOptions(options);\n this.#colorElem = colorElem;\n }\n updateDisplay(v) {\n if (!this.#skipUpdate) {\n this.#colorElem.value = this.#to(v);\n }\n this.#skipUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}} = this.#options;\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import {\n colorFormatConverters,\n guessFormat,\n} from '../libs/color-utils.js';\nimport ValueController from './ValueController.js';\nimport TextView from '../views/TextView.js';\nimport ColorView from '../views/ColorView.js';\n\nexport default class Color extends ValueController {\n #colorView;\n #textView;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#colorView = this.add(new ColorView(this, {converters: color}));\n this.#textView = this.add(new TextView(this, {converters: text}));\n this.updateDisplay();\n }\n setOptions(options) {\n const {format} = options;\n if (format) {\n const {color, text} = colorFormatConverters[format];\n this.#colorView.setOptions({converters: color});\n this.#textView.setOptions({converters: text});\n }\n super.setOptions(options);\n return this;\n }\n}","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addController({className: 'muigui-divider')};\nexport default class Divider extends Controller {\n constructor() {\n super('muigui-divider');\n }\n}","import Controller from './Controller.js';\n\nexport default class Container extends Controller {\n #controllers;\n #childDestController;\n\n constructor(className) {\n super(className);\n this.#controllers = [];\n this.#childDestController = this;\n }\n get children() {\n return this.#controllers; // should we return a copy?\n }\n get controllers() {\n return this.#controllers.filter(c => !(c instanceof Container));\n }\n get folders() {\n return this.#controllers.filter(c => c instanceof Container);\n }\n reset(recursive = true) {\n for (const controller of this.#controllers) {\n if (!(controller instanceof Container) || recursive) {\n controller.reset(recursive);\n }\n }\n return this;\n }\n updateDisplay() {\n for (const controller of this.#controllers) {\n controller.updateDisplay();\n }\n return this;\n }\n remove(controller) {\n const ndx = this.#controllers.indexOf(controller);\n if (ndx >= 0) {\n const c = this.#controllers.splice(ndx, 1);\n const c0 = c[0];\n const elem = c0.domElement;\n elem.remove();\n c0.setParent(null);\n }\n return this;\n }\n #addControllerImpl(controller) {\n this.domElement.appendChild(controller.domElement);\n this.#controllers.push(controller);\n controller.setParent(this);\n return controller;\n }\n addController(controller) {\n return this.#childDestController.#addControllerImpl(controller);\n }\n pushContainer(container) {\n this.addController(container);\n this.#childDestController = container;\n return container;\n }\n popContainer() {\n this.#childDestController = this.#childDestController.parent;\n return this;\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport Container from './Container.js';\n\nexport default class Folder extends Container {\n #labelElem;\n\n constructor(name = 'Controls', className = 'muigui-menu') {\n super(className);\n this.#labelElem = createElem('label');\n this.addElem(createElem('button', {\n type: 'button',\n onClick: () => this.toggleOpen(),\n }, [this.#labelElem]));\n this.pushContainer(new Container());\n this.name(name);\n this.open();\n }\n open(open = true) {\n this.domElement.classList.toggle('muigui-closed', !open);\n this.domElement.classList.toggle('muigui-open', open);\n return this;\n }\n close() {\n return this.open(false);\n }\n name(name) {\n this.#labelElem.textContent = name;\n return this;\n }\n title(title) {\n return this.name(title);\n }\n toggleOpen() {\n this.open(!this.domElement.classList.contains('muigui-open'));\n return this;\n }\n}\n","import Controller from './Controller.js';\n\n// This feels like it should be something else like\n// gui.addDividing = new Controller()\nexport default class Label extends Controller {\n constructor(text) {\n super('muigui-label');\n this.text(text);\n }\n text(text) {\n this.domElement.textContent = text;\n return this;\n }\n}","function noop() {\n}\n\nexport function computeRelativePosition(elem, event, start) {\n const rect = elem.getBoundingClientRect();\n const x = event.clientX - rect.left;\n const y = event.clientY - rect.top;\n const nx = x / rect.width;\n const ny = y / rect.height;\n start = start || [x, y];\n const dx = x - start[0];\n const dy = y - start[1];\n const ndx = dx / rect.width;\n const ndy = dy / rect.width;\n return {x, y, nx, ny, dx, dy, ndx, ndy};\n}\n\nexport function addTouchEvents(elem, {onDown = noop, onMove = noop, onUp = noop}) {\n let start;\n const pointerMove = function (event) {\n const e = {\n type: 'move',\n ...computeRelativePosition(elem, event, start),\n };\n onMove(e);\n };\n\n const pointerUp = function (event) {\n elem.releasePointerCapture(event.pointerId);\n elem.removeEventListener('pointermove', pointerMove);\n elem.removeEventListener('pointerup', pointerUp);\n\n document.body.style.backgroundColor = '';\n\n onUp('up');\n };\n\n const pointerDown = function (event) {\n elem.addEventListener('pointermove', pointerMove);\n elem.addEventListener('pointerup', pointerUp);\n elem.setPointerCapture(event.pointerId);\n\n const rel = computeRelativePosition(elem, event);\n start = [rel.x, rel.y];\n onDown({\n type: 'down',\n ...rel,\n });\n };\n\n elem.addEventListener('pointerdown', pointerDown);\n\n return function () {\n elem.removeEventListener('pointerdown', pointerDown);\n };\n}","import { createElem, getNewId } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { identity } from '../libs/conversions.js';\nimport { clamp } from '../libs/utils.js';\nimport EditView from './EditView.js';\nimport {\n hexToFloatRGB,\n hexToFloatRGBA,\n hsv01ToRGBFloat,\n hsva01ToRGBAFloat,\n rgbFloatToHSV01,\n rgbaFloatToHSVA01,\n floatRGBToHex,\n floatRGBAToHex,\n rgbaFloatToHsla01,\n} from '../libs/color-utils.js';\nimport { copyExistingProperties } from '../libs/utils.js';\n\nconst svg = `\n\n\n\n`;\n\nfunction connectFillTargets(elem) {\n elem.querySelectorAll('[data-src]').forEach(srcElem => {\n const id = getNewId();\n srcElem.id = id;\n elem.querySelectorAll(`[data-target=${srcElem.dataset.src}]`).forEach(targetElem => {\n targetElem.setAttribute('fill', `url(#${id})`);\n });\n });\n return elem;\n}\n\n// Was originally going to make alpha an option. Issue is\n// hard coded conversions?\nexport default class ColorChooserView extends EditView {\n #to;\n #from;\n #satLevelElem;\n #circleElem;\n #hueUIElem;\n #hueElem;\n #hueCursorElem;\n #alphaUIElem;\n #alphaElem;\n #alphaCursorElem;\n #hsva;\n #skipHueUpdate;\n #skipSatLevelUpdate;\n #skipAlphaUpdate;\n #options = {\n converters: identity,\n alpha: false,\n };\n #convertInternalToHex;\n #convertHexToInternal;\n\n constructor(setter, options) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n this.#satLevelElem = this.domElement.children[0];\n this.#hueUIElem = this.domElement.children[1];\n this.#alphaUIElem = this.domElement.children[2];\n connectFillTargets(this.#satLevelElem);\n connectFillTargets(this.#hueUIElem);\n connectFillTargets(this.#alphaUIElem);\n this.#circleElem = this.$('.muigui-color-chooser-circle');\n this.#hueElem = this.$('[data-src=muigui-color-chooser-hue]');\n this.#hueCursorElem = this.$('.muigui-color-chooser-hue-cursor');\n this.#alphaElem = this.$('[data-src=muigui-color-chooser-alpha]');\n this.#alphaCursorElem = this.$('.muigui-color-chooser-alpha-cursor');\n\n const handleSatLevelChange = (e) => {\n const s = clamp(e.nx, 0, 1);\n const v = clamp(e.ny, 0, 1);\n this.#hsva[1] = s;\n this.#hsva[2] = (1 - v);\n this.#skipHueUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleHueChange = (e) => {\n const h = clamp(e.nx, 0, 1);\n this.#hsva[0] = h;\n this.#skipSatLevelUpdate = true;\n this.#skipAlphaUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n const handleAlphaChange = (e) => {\n const a = clamp(e.nx, 0, 1);\n this.#hsva[3] = a;\n this.#skipHueUpdate = true;\n this.#skipSatLevelUpdate = true;\n const [valid, newV] = this.#from(this.#convertInternalToHex(this.#hsva));\n if (valid) {\n setter.setValue(newV);\n }\n };\n\n addTouchEvents(this.#satLevelElem, {\n onDown: handleSatLevelChange,\n onMove: handleSatLevelChange,\n });\n addTouchEvents(this.#hueUIElem, {\n onDown: handleHueChange,\n onMove: handleHueChange,\n });\n addTouchEvents(this.#alphaUIElem, {\n onDown: handleAlphaChange,\n onMove: handleAlphaChange,\n });\n this.setOptions(options);\n }\n updateDisplay(newV) {\n if (!this.#hsva) {\n this.#hsva = this.#convertHexToInternal(this.#to(newV));\n }\n {\n const [h, s, v, a = 1] = this.#convertHexToInternal(this.#to(newV));\n // Don't copy the hue if it was un-computable.\n if (!this.#skipHueUpdate) {\n this.#hsva[0] = s > 0.001 && v > 0.001 ? h : this.#hsva[0];\n }\n if (!this.#skipSatLevelUpdate) {\n this.#hsva[1] = s;\n this.#hsva[2] = v;\n }\n if (!this.#skipAlphaUpdate) {\n this.#hsva[3] = a;\n }\n }\n {\n const [h, s, v, a] = this.#hsva;\n const [hue, sat, lum] = rgbaFloatToHsla01(hsva01ToRGBAFloat(this.#hsva));\n\n if (!this.#skipHueUpdate) {\n this.#hueCursorElem.setAttribute('transform', `translate(${h * 64}, 0)`);\n }\n this.#hueElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} 0% 100% / ${a})`);\n this.#hueElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} 100% 50% / ${a})`);\n if (!this.#skipAlphaUpdate) {\n this.#alphaCursorElem.setAttribute('transform', `translate(${a * 64}, 0)`);\n }\n this.#alphaElem.children[0].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 0)`);\n this.#alphaElem.children[1].setAttribute('stop-color', `hsl(${hue * 360} ${sat * 100}% ${lum * 100}% / 1)`);\n\n if (!this.#skipSatLevelUpdate) {\n this.#circleElem.setAttribute('cx', `${s * 64}`);\n this.#circleElem.setAttribute('cy', `${(1 - v) * 48}`);\n }\n }\n this.#skipHueUpdate = false;\n this.#skipSatLevelUpdate = false;\n this.#skipAlphaUpdate = false;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {converters: {to, from}, alpha} = this.#options;\n this.#alphaUIElem.style.display = alpha ? '' : 'none';\n this.#convertInternalToHex = alpha\n ? v => floatRGBAToHex(hsva01ToRGBAFloat(v))\n : v => floatRGBToHex(hsv01ToRGBFloat(v));\n this.#convertHexToInternal = alpha\n ? v => rgbaFloatToHSVA01(hexToFloatRGBA(v))\n : v => rgbFloatToHSV01(hexToFloatRGB(v));\n this.#to = to;\n this.#from = from;\n return this;\n }\n}\n","import ElementView from '../views/ElementView.js';\nimport ValueController from './ValueController.js';\nimport { copyExistingProperties } from '../libs/utils.js';\nimport { createElem } from '../libs/elem.js';\n/*\n\nholder = new TabHolder\ntab = holder.add(new Tab(\"name\"))\ntab.add(...)\n\n\npc = new PopdownController\ntop = pc.add(new Row())\ntop.add(new Button());\nvalues = topRow.add(new Div())\nbottom = pc.add(new Row());\n\n\n\npc = new PopdownController\npc.addTop\npc.addTop\n\npc.addBottom\n\n\n*/\n\nexport default class PopDownController extends ValueController {\n #top;\n #valuesView;\n #checkboxElem;\n #bottom;\n #options = {\n open: false,\n };\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-pop-down-controller');\n /*\n [ValueView\n [[B][values]] upper row\n [[ visual ]] lower row\n ]\n */\n this.#top = this.add(new ElementView('div', 'muigui-pop-down-top'));\n// this.#top.add(new CheckboxView(makeSetter(this.#options, 'open')));\n const checkboxElem = this.#top.addElem(createElem('input', {\n type: 'checkbox',\n onChange: () => {\n this.#options.open = checkboxElem.checked;\n this.updateDisplay();\n },\n }));\n this.#checkboxElem = checkboxElem;\n this.#valuesView = this.#top.add(new ElementView('div', 'muigui-pop-down-values'));\n this.#bottom = this.add(new ElementView('div', 'muigui-pop-down-bottom'));\n this.setOptions(options);\n }\n setKnobColor(bgCssColor/*, fgCssColor*/) {\n if (this.#checkboxElem) {\n this.#checkboxElem.style = `\n --range-color: ${bgCssColor};\n --value-bg-color: ${bgCssColor};\n `;\n }\n }\n updateDisplay() {\n super.updateDisplay();\n const {open} = this.#options;\n this.domElement.children[1].classList.toggle('muigui-open', open);\n this.domElement.children[1].classList.toggle('muigui-closed', !open);\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n super.setOptions(options);\n this.updateDisplay();\n }\n addTop(view) {\n return this.#valuesView.add(view);\n }\n addBottom(view) {\n return this.#bottom.add(view);\n }\n}","/* eslint-disable no-underscore-dangle */\nimport {\n colorFormatConverters,\n guessFormat,\n hasAlpha,\n hexToUint8RGB,\n hslToRgbUint8,\n rgbUint8ToHsl,\n uint8RGBToHex,\n} from '../libs/color-utils.js';\nimport ColorChooserView from '../views/ColorChooserView.js';\nimport TextView from '../views/TextView.js';\nimport PopDownController from './PopDownController.js';\n\nexport default class ColorChooser extends PopDownController {\n #colorView;\n #textView;\n #to;\n #setKnobHelper;\n\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-color-chooser');\n const format = options.format || guessFormat(this.getValue());\n const {color, text} = colorFormatConverters[format];\n this.#to = color.to;\n this.#textView = new TextView(this, {converters: text, alpha: hasAlpha(format)});\n this.#colorView = new ColorChooserView(this, {converters: color, alpha: hasAlpha(format)});\n this.addTop(this.#textView);\n this.addBottom(this.#colorView);\n // WTF! FIX!\n this.#setKnobHelper = () => {\n if (this.#to) {\n const hex6Or8 = this.#to(this.getValue());\n const hsl = rgbUint8ToHsl(hexToUint8RGB(hex6Or8));\n hsl[2] = (hsl[2] + 50) % 100;\n const hex = uint8RGBToHex(hslToRgbUint8(hsl));\n this.setKnobColor(`${hex6Or8.substring(0, 7)}FF`, hex);\n }\n };\n this.updateDisplay();\n }\n updateDisplay() {\n super.updateDisplay();\n if (this.#setKnobHelper) {\n this.#setKnobHelper();\n }\n }\n setOptions(options) {\n super.setOptions(options);\n return this;\n }\n}\n","import css from './styles/muigui.css.js';\nimport {createElem} from './libs/elem.js';\nimport {createController} from './controllers/create-controller.js';\nimport {\n mapRange,\n makeRangeConverters,\n makeRangeOptions,\n makeMinMaxPair,\n} from './libs/utils.js';\nimport {\n converters\n} from './libs/conversions.js';\nimport {\n hasAlpha,\n guessFormat,\n} from './libs/color-utils.js';\nimport Canvas from './controllers/Canvas.js';\nimport Color from './controllers/Color.js';\nimport Divider from './controllers/Divider.js';\nimport Folder from './controllers/Folder.js';\nimport Label from './controllers/Label.js';\nimport Controller from './controllers/Controller.js';\nimport ColorChooser from './controllers/ColorChooser.js';\n\nimport Column from './layout/Column.js';\nimport Frame from './layout/Frame.js';\nimport Grid from './layout/Grid.js';\nimport Row from './layout/Row.js';\n\nexport {\n Column,\n Frame,\n Grid,\n Row,\n};\n\nexport class GUIFolder extends Folder {\n add(object, property, ...args) {\n const controller = object instanceof Controller\n ? object\n : createController(object, property, ...args);\n return this.addController(controller);\n }\n addCanvas(name) {\n return this.addController(new Canvas(name));\n }\n addColor(object, property, options = {}) {\n const value = object[property];\n if (hasAlpha(options.format || guessFormat(value))) {\n return this.addController(new ColorChooser(object, property, options));\n } else {\n return this.addController(new Color(object, property, options));\n }\n }\n addDivider() {\n return this.addController(new Divider());\n }\n addFolder(name) {\n return this.addController(new GUIFolder(name));\n }\n addLabel(text) {\n return this.addController(new Label(text));\n }\n}\n\nclass MuiguiElement extends HTMLElement {\n constructor() {\n super();\n this.shadow = this.attachShadow({mode: 'open'});\n }\n}\n\ncustomElements.define('muigui-element', MuiguiElement);\n\nconst baseStyleSheet = new CSSStyleSheet();\nbaseStyleSheet.replaceSync(css.default);\nconst userStyleSheet = new CSSStyleSheet();\n\nfunction makeStyleSheetUpdater(styleSheet) {\n let newCss;\n let newCssPromise;\n\n function updateStyle() {\n if (newCss && !newCssPromise) {\n const s = newCss;\n newCss = undefined;\n newCssPromise = styleSheet.replace(s).then(() => {\n newCssPromise = undefined;\n updateStyle();\n });\n }\n }\n\n return function updateStyleSheet(css) {\n newCss = css;\n updateStyle();\n };\n}\n\nconst updateBaseStyle = makeStyleSheetUpdater(baseStyleSheet);\nconst updateUserStyle = makeStyleSheetUpdater(userStyleSheet);\n\nexport class GUI extends GUIFolder {\n static converters = converters;\n static mapRange = mapRange;\n static makeRangeConverters = makeRangeConverters;\n static makeRangeOptions = makeRangeOptions;\n static makeMinMaxPair = makeMinMaxPair;\n #localStyleSheet = new CSSStyleSheet();\n\n constructor(options = {}) {\n super('Controls', 'muigui-root');\n if (options instanceof HTMLElement) {\n options = {parent: options};\n }\n const {\n autoPlace = true,\n width,\n title = 'Controls',\n } = options;\n let {\n parent,\n } = options;\n\n if (width) {\n this.domElement.style.width = /^\\d+$/.test(width) ? `${width}px` : width;\n }\n if (parent === undefined && autoPlace) {\n parent = document.body;\n this.domElement.classList.add('muigui-auto-place');\n }\n if (parent) {\n const muiguiElement = createElem('muigui-element');\n muiguiElement.shadowRoot.adoptedStyleSheets = [baseStyleSheet, userStyleSheet, this.#localStyleSheet];\n muiguiElement.shadow.appendChild(this.domElement);\n parent.appendChild(muiguiElement);\n }\n if (title) {\n this.title(title);\n }\n this.domElement.classList.add('muigui', 'muigui-colors');\n }\n setStyle(css) {\n this.#localStyleSheet.replace(css);\n }\n static setBaseStyles(css) {\n updateBaseStyle(css);\n }\n static getBaseStyleSheet() {\n return baseStyleSheet;\n }\n static setUserStyles(css) {\n updateUserStyle(css);\n }\n static getUserStyleSheet() {\n return userStyleSheet;\n }\n static setTheme(name) {\n GUI.setBaseStyles(`${css.default}\\n${css.themes[name] || ''}`);\n }\n}\n\nexport default GUI;\n","import Button from './Button.js';\nimport Checkbox from './Checkbox.js';\nimport TextNumber from './TextNumber.js';\nimport Select from './Select.js';\nimport Range from './Range.js';\nimport Text from './Text.js';\n\n// const isConversion = o => typeof o.to === 'function' && typeof o.from === 'function';\n\n/**\n * possible inputs\n * add(o, p, min: number, max: number)\n * add(o, p, min: number, max: number, step: number)\n * add(o, p, array: [value])\n * add(o, p, array: [[key, value]])\n *\n * @param {*} object\n * @param {string} property\n * @param {...any} args\n * @returns {Controller}\n */\nexport function createController(object, property, ...args) {\n const [arg1] = args;\n if (Array.isArray(arg1)) {\n return new Select(object, property, {keyValues: arg1});\n }\n\n const t = typeof object[property];\n switch (t) {\n case 'number':\n if (typeof args[0] === 'number' && typeof args[1] === 'number') {\n const min = args[0];\n const max = args[1];\n const step = args[2];\n return new Range(object, property, {min, max, ...(step && {step})});\n }\n return args.length === 0\n ? new TextNumber(object, property, ...args)\n : new Range(object, property, ...args);\n case 'boolean':\n return new Checkbox(object, property, ...args);\n case 'function':\n return new Button(object, property, ...args);\n case 'string':\n return new Text(object, property, ...args);\n case 'undefined':\n throw new Error(`no property named ${property}`);\n default:\n throw new Error(`unhandled type ${t} for property ${property}`);\n }\n}","function noop() {\n}\n\nconst keyDirections = {\n ArrowLeft: [-1, 0],\n ArrowRight: [1, 0],\n ArrowUp: [0, -1],\n ArrowDown: [0, 1],\n};\n\n// This probably needs to be global\nexport function addKeyboardEvents(elem, {onDown = noop, onUp = noop}) {\n const keyDown = function (event) {\n const mult = event.shiftKey ? 10 : 1;\n const [dx, dy] = (keyDirections[event.key] || [0, 0]).map(v => v * mult);\n const fn = event.type === 'keydown' ? onDown : onUp;\n fn({\n type: event.type.substring(3),\n dx,\n dy,\n event,\n });\n };\n\n elem.addEventListener('keydown', keyDown);\n elem.addEventListener('keyup', keyDown);\n\n return function () {\n elem.removeEventListener('keydown', keyDown);\n elem.removeEventListener('keyup', keyDown);\n };\n}","export function assert(truthy, msg = '') {\n if (!truthy) {\n throw new Error(msg);\n }\n}","import { assert } from '../libs/assert.js';\n\nfunction getEllipsePointForAngle(cx, cy, rx, ry, phi, theta) {\n const m = Math.abs(rx) * Math.cos(theta);\n const n = Math.abs(ry) * Math.sin(theta);\n\n return [\n cx + Math.cos(phi) * m - Math.sin(phi) * n,\n cy + Math.sin(phi) * m + Math.cos(phi) * n,\n ];\n}\n\nfunction getEndpointParameters(cx, cy, rx, ry, phi, theta, dTheta) {\n const [x1, y1] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta);\n const [x2, y2] = getEllipsePointForAngle(cx, cy, rx, ry, phi, theta + dTheta);\n\n const fa = Math.abs(dTheta) > Math.PI ? 1 : 0;\n const fs = dTheta > 0 ? 1 : 0;\n\n return { x1, y1, x2, y2, fa, fs };\n}\n\nexport function arc(cx, cy, r, start, end) {\n assert(Math.abs(start - end) <= Math.PI * 2);\n assert(start >= -Math.PI && start <= Math.PI * 2);\n assert(start <= end);\n assert(end >= -Math.PI && end <= Math.PI * 4);\n\n const { x1, y1, x2, y2, fa, fs } = getEndpointParameters(cx, cy, r, r, 0, start, end - start);\n return Math.abs(Math.abs(start - end) - Math.PI * 2) > Number.EPSILON\n ? `M${cx} ${cy} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2} L${cx} ${cy}`\n : `M${x1} ${y1} L${x1} ${y1} A ${r} ${r} 0 ${fa} ${fs} ${x2} ${y2}`;\n}\n","import { identity } from '../libs/conversions.js';\nimport { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { arc } from '../libs/svg.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { clamp, copyExistingProperties, euclideanModulo, lerp, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nconst twoPiMod = v => euclideanModulo(v + Math.PI, Math.PI * 2) - Math.PI;\n\nexport default class DirectionView extends EditView {\n #arrowElem;\n #rangeElem;\n #lastV;\n #wrap;\n #options = {\n step: 1,\n min: -180,\n max: 180,\n\n /*\n --------\n / -π/2 \\\n / | \\\n |<- -π * |\n | * 0 ->| zero is down the positive X axis\n |<- +π * |\n \\ | /\n \\ π/2 /\n --------\n */\n dirMin: -Math.PI,\n dirMax: Math.PI,\n //dirMin: Math.PI * 0.5,\n //dirMax: Math.PI * 2.5,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 7:30 to 10:30\n //dirMax: -Math.PI * 0.75,\n //dirMin: -Math.PI * 0.75, // test 10:30 to 1:30\n //dirMax: -Math.PI * 0.25,\n //dirMin: Math.PI * 0.25, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.75,\n //dirMin: Math.PI * 0.75, // test 4:30 to 7:30\n //dirMax: Math.PI * 0.25,\n wrap: undefined,\n converters: identity,\n };\n\n constructor(setter, options = {}) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n className: 'muigui-direction muigui-no-scroll',\n innerHTML: svg,\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n let tempV = this.#lastV + delta;\n if (this.#wrap) {\n tempV = euclideanModulo(tempV - min, max - min) + min;\n }\n const newV = clamp(stepify(tempV, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n const handleTouch = (e) => {\n const {min, max, step, dirMin, dirMax} = this.#options;\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n const a = Math.atan2(ny, nx);\n\n const center = (dirMin + dirMax) / 2;\n\n const centeredAngle = twoPiMod(a - center);\n const centeredStart = twoPiMod(dirMin - center);\n const diff = dirMax - dirMin;\n\n const n = clamp((centeredAngle - centeredStart) / (diff), 0, 1);\n const newV = stepify(min + (max - min) * n, v => v, step);\n setter.setValue(newV);\n };\n addTouchEvents(this.domElement, {\n onDown: handleTouch,\n onMove: handleTouch,\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n this.#arrowElem = this.$('#muigui-arrow');\n this.#rangeElem = this.$('#muigui-range');\n this.setOptions(options);\n }\n updateDisplay(v) {\n this.#lastV = v;\n const {min, max} = this.#options;\n const n = (v - min) / (max - min);\n const angle = lerp(this.#options.dirMin, this.#options.dirMax, n);\n this.#arrowElem.style.transform = `rotate(${angle}rad)`;\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n const {dirMin, dirMax, wrap} = this.#options;\n this.#wrap = wrap !== undefined\n ? wrap\n : Math.abs(dirMin - dirMax) >= Math.PI * 2 - Number.EPSILON;\n const [min, max] = dirMin < dirMax ? [dirMin, dirMax] : [dirMax , dirMin];\n this.#rangeElem.setAttribute('d', arc(0, 0, 28.87, min, max));\n }\n}\n","import { identity } from '../libs/conversions.js';\nimport DirectionView from '../views/DirectionView.js';\nimport NumberView from '../views/NumberView.js';\n// import ValueController from './ValueController.js';\nimport PopDownController from './PopDownController.js';\n\n\n// deg2rad\n// where is 0\n// range (0, 360), (-180, +180), (0,0) Really this is a range\n\nexport default class Direction extends PopDownController {\n #options;\n constructor(object, property, options) {\n super(object, property, 'muigui-direction');\nthis.#options = options; // FIX\n this.addTop(new NumberView(this,\nidentity));\n this.addBottom(new DirectionView(this, options));\n this.updateDisplay();\n }\n}\n\n","import { createElem } from '../libs/elem.js';\nimport { makeId } from '../libs/ids.js';\nimport EditView from './EditView.js';\n\nexport default class RadioGridView extends EditView {\n #values;\n\n constructor(setter, keyValues, cols = 3) {\n const values = [];\n const name = makeId();\n super(createElem('div', {}, keyValues.map(([key, value], ndx) => {\n values.push(value);\n return createElem('label', {}, [\n createElem('input', {\n type: 'radio',\n name,\n value: ndx,\n onChange: function () {\n if (this.checked) {\n setter.setFinalValue(that.#values[this.value]);\n }\n },\n }),\n createElem('button', {\n type: 'button',\n textContent: key,\n onClick: function () {\n this.previousElementSibling.click();\n },\n }),\n ]);\n })));\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.#values = values;\n this.cols(cols);\n }\n updateDisplay(v) {\n const ndx = this.#values.indexOf(v);\n for (let i = 0; i < this.domElement.children.length; ++i) {\n this.domElement.children[i].children[0].checked = i === ndx;\n }\n }\n cols(cols) {\n this.domElement.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;\n }\n}\n","import RadioGridView from '../views/RadioGridView.js';\nimport ValueController from './ValueController.js';\nimport { convertToKeyValues } from '../libs/key-values.js';\n\nexport default class RadioGrid extends ValueController {\n constructor(object, property, options) {\n super(object, property, 'muigui-radio-grid');\n const valueIsNumber = typeof this.getValue() === 'number';\n const {\n keyValues: keyValuesInput,\n cols = 3,\n } = options;\n const keyValues = convertToKeyValues(keyValuesInput, valueIsNumber);\n this.add(new RadioGridView(this, keyValues, cols));\n this.updateDisplay();\n }\n}","export function onResize(elem, callback) {\n new ResizeObserver(() => {\n callback({rect: elem.getBoundingClientRect(), elem});\n }).observe(elem);\n}\n\nexport function onResizeSVGNoScale(elem, hAnchor, vAnchor, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.setAttribute('viewBox', `-${width * hAnchor} -${height * vAnchor} ${width} ${height}`);\n callback({elem, rect});\n });\n}\n\nexport function onResizeCanvas(elem, callback) {\n onResize(elem, ({rect}) => {\n const {width, height} = rect;\n elem.width = width;\n elem.height = height;\n callback({elem, rect});\n });\n}\n","import { createElem } from '../libs/elem.js';\nimport { addKeyboardEvents } from '../libs/keyboard.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { createWheelHelper } from '../libs/wheel.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport { clamp, copyExistingProperties, stepify } from '../libs/utils.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nfunction createSVGTicks(start, end, step, min, max, height) {\n const p = [];\n if (start < min) {\n start += stepify(min - start, v => v, step);\n }\n end = Math.min(end, max);\n for (let i = start; i <= end; i += step) {\n p.push(`M${i} 0 l0 ${height}`);\n }\n return p.join(' ');\n}\n\nfunction createSVGNumbers(start, end, unitSize, unit, minusSize, min, max, labelFn) {\n const texts = [];\n if (start < min) {\n start += stepify(min - start, v => v, unitSize);\n }\n end = Math.min(end, max);\n const digits = Math.max(0, -Math.log10(unit));\n const f = v => labelFn(v.toFixed(digits));\n for (let i = start; i <= end; i += unitSize) {\n texts.push(`= 0 ? i : (i - minusSize / 2) }\" y=\"0\">${f(i / unitSize * unit)}`);\n }\n return texts.join('\\n');\n}\n\nfunction computeSizeOfMinus(elem) {\n const oldHTML = elem.innerHTML;\n elem.innerHTML = '- ';\n const text = elem.querySelector('text');\n const size = text.getComputedTextLength();\n elem.innerHTML = oldHTML;\n return size;\n}\n\nexport default class SliderView extends EditView {\n #svgElem;\n #originElem;\n #ticksElem;\n #thicksElem;\n #numbersElem;\n #leftGradElem;\n #rightGradElem;\n #width;\n #height;\n #lastV;\n #minusSize;\n #options = {\n min: -100,\n max: 100,\n step: 1,\n unit: 10,\n unitSize: 10,\n ticksPerUnit: 5,\n labelFn: v => v,\n tickHeight: 1,\n limits: true,\n thicksColor: undefined,\n orientation: undefined,\n };\n\n constructor(setter, options) {\n const wheelHelper = createWheelHelper();\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-v-scroll',\n onWheel: e => {\n e.preventDefault();\n const {min, max, step} = this.#options;\n const delta = wheelHelper(e, step);\n const newV = clamp(stepify(this.#lastV + delta, v => v, step), min, max);\n setter.setValue(newV);\n },\n }));\n this.#svgElem = this.$('svg');\n this.#originElem = this.$('#muigui-origin');\n this.#ticksElem = this.$('#muigui-ticks');\n this.#thicksElem = this.$('#muigui-thicks');\n this.#numbersElem = this.$('#muigui-numbers');\n this.#leftGradElem = this.$('#muigui-left-grad');\n this.#rightGradElem = this.$('#muigui-right-grad');\n this.setOptions(options);\n let startV;\n addTouchEvents(this.domElement, {\n onDown: () => {\n startV = this.#lastV;\n },\n onMove: (e) => {\n const {min, max, unitSize, unit, step} = this.#options;\n const newV = clamp(stepify(startV - e.dx / unitSize * unit, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n addKeyboardEvents(this.domElement, {\n onDown: (e) => {\n const {min, max, step} = this.#options;\n const newV = clamp(stepify(this.#lastV + e.dx * step, v => v, step), min, max);\n setter.setValue(newV);\n },\n });\n onResizeSVGNoScale(this.#svgElem, 0.5, 0, ({rect: {width}}) => {\n this.#leftGradElem.setAttribute('x', -width / 2);\n this.#rightGradElem.setAttribute('x', width / 2 - 20);\n this.#minusSize = computeSizeOfMinus(this.#numbersElem);\n this.#width = width;\n this.#updateSlider();\n });\n }\n // |--------V--------|\n // . . | . . . | . . . |\n //\n #updateSlider() {\n // There's no size if ResizeObserver has not fired yet.\n if (!this.#width || this.#lastV === undefined) {\n return;\n }\n const {\n labelFn,\n limits,\n min,\n max,\n orientation,\n tickHeight,\n ticksPerUnit,\n unit,\n unitSize,\n thicksColor,\n } = this.#options;\n const unitsAcross = Math.ceil(this.#width / unitSize);\n const center = this.#lastV;\n const centerUnitSpace = center / unit;\n const startUnitSpace = Math.round(centerUnitSpace - unitsAcross);\n const endUnitSpace = startUnitSpace + unitsAcross * 2;\n const start = startUnitSpace * unitSize;\n const end = endUnitSpace * unitSize;\n const minUnitSpace = limits ? min * unitSize / unit : start;\n const maxUnitSpace = limits ? max * unitSize / unit : end;\n const height = labelFn(1) === '' ? 10 : 5;\n if (ticksPerUnit > 1) {\n this.#ticksElem.setAttribute('d', createSVGTicks(start, end, unitSize / ticksPerUnit, minUnitSpace, maxUnitSpace, height * tickHeight));\n }\n this.#thicksElem.style.stroke = thicksColor; //setAttribute('stroke', thicksColor);\n this.#thicksElem.setAttribute('d', createSVGTicks(start, end, unitSize, minUnitSpace, maxUnitSpace, height));\n this.#numbersElem.innerHTML = createSVGNumbers(start, end, unitSize, unit, this.#minusSize, minUnitSpace, maxUnitSpace, labelFn);\n this.#originElem.setAttribute('transform', `translate(${-this.#lastV * unitSize / unit} 0)`);\n this.#svgElem.classList.toggle('muigui-slider-up', orientation === 'up');\n }\n updateDisplay(v) {\n this.#lastV = v;\n this.#updateSlider();\n }\n setOptions(options) {\n copyExistingProperties(this.#options, options);\n return this;\n }\n}\n","import ValueController from './ValueController.js';\nimport NumberView from '../views/NumberView.js';\nimport SliderView from '../views/SliderView.js';\n\nexport default class Slider extends ValueController {\n constructor(object, property, options = {}) {\n super(object, property, 'muigui-slider');\n this.add(new SliderView(this, options));\n this.add(new NumberView(this, options));\n this.updateDisplay();\n }\n}\n","import { createElem } from '../libs/elem.js';\nimport { addTouchEvents } from '../libs/touch.js';\nimport { onResizeSVGNoScale } from '../libs/resize-helpers.js';\nimport EditView from './EditView.js';\n\nconst svg = `\n\n`;\n\nexport default class Vec2View extends EditView {\n #svgElem;\n #arrowElem;\n #circleElem;\n #lastV = [];\n\n constructor(setter) {\n super(createElem('div', {\n innerHTML: svg,\n className: 'muigui-no-scroll',\n }));\n const onTouch = (e) => {\n const {width, height} = this.#svgElem.getBoundingClientRect();\n const nx = e.nx * 2 - 1;\n const ny = e.ny * 2 - 1;\n setter.setValue([nx * width * 0.5, ny * height * 0.5]);\n };\n addTouchEvents(this.domElement, {\n onDown: onTouch,\n onMove: onTouch,\n });\n this.#svgElem = this.$('svg');\n this.#arrowElem = this.$('#muigui-arrow');\n this.#circleElem = this.$('#muigui-circle');\n onResizeSVGNoScale(this.#svgElem, 0.5, 0.5, () => this.#updateDisplayImpl);\n }\n #updateDisplayImpl() {\n const [x, y] = this.#lastV;\n this.#arrowElem.setAttribute('d', `M0,0L${x},${y}`);\n this.#circleElem.setAttribute('transform', `translate(${x}, ${y})`);\n }\n updateDisplay(v) {\n this.#lastV[0] = v[0];\n this.#lastV[1] = v[1];\n this.#updateDisplayImpl();\n }\n}\n","import NumberView from '../views/NumberView.js';\nimport Vec2View from '../views/Vec2View.js';\nimport PopDownController from './PopDownController.js';\nimport { strToNumber } from '../libs/conversions.js';\n\n// TODO: zoom with wheel and pinch?\n// TODO: grid?\n// // options\n// scale:\n// range: number (both x and y + /)\n// range: array (min, max)\n// xRange:\n// deg/rad/turn\n\nexport default class Vec2 extends PopDownController {\n constructor(object, property) {\n super(object, property, 'muigui-vec2');\n\n const makeSetter = (ndx) => {\n return {\n setValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setValue(newV);\n },\n setFinalValue: (v) => {\n const newV = this.getValue();\n newV[ndx] = v;\n this.setFinalValue(newV);\n },\n };\n };\n\n this.addTop(new NumberView(makeSetter(0), {\n converters: {\n to: v => v[0],\n from: strToNumber.from,\n },\n }));\n this.addTop(new NumberView(makeSetter(1), {\n converters: {\n to: v => v[1],\n from: strToNumber.from,\n },\n }));\n this.addBottom(new Vec2View(this));\n this.updateDisplay();\n }\n}\n"],"names":["css","default","themes","float","createElem","tag","attrs","children","elem","document","createElement","key","value","Object","entries","startsWith","eventName","substring","toLowerCase","addEventListener","passive","k","v","undefined","setAttribute","child","appendChild","setElemProps","nextId","removeArrayElem","array","ndx","indexOf","splice","clamp","min","max","Math","isTypedArray","SharedArrayBuffer","a","buffer","ArrayBuffer","stepify","from","step","round","euclideanModulo","n","copyExistingProperties","dst","src","mapRange","inMin","inMax","outMin","outMax","makeRangeConverters","to","makeRangeOptions","converters","identity","makeMinMaxPair","gui","properties","minPropName","maxPropName","options","guiMinRange","minRange","valueMinRange","minGui","add","onChange","maxGui","setValue","View","domElement","childDestElem","views","constructor","this","addElem","removeElem","removeChild","pushSubElem","popSubElem","parentElement","view","push","remove","pushSubView","popSubView","setOptions","updateDisplayIfNeeded","newV","ignoreCache","$","selector","querySelector","Controller","changeFns","finishChangeFns","parent","className","super","classList","setParent","enable","disabled","show","toggle","hide","closest","forEach","querySelectorAll","disable","fn","removeChange","onFinishChange","removeFinishChange","callListeners","fns","call","emitChange","object","property","controller","emitFinalChange","updateDisplay","getColors","toCamelCase","s","replace","m","m1","toUpperCase","div","colors","fromEntries","map","style","color","getComputedStyle","Button","buttonElem","name","type","onClick","textContent","arraysEqual","b","length","i","EditView","oldV","updateCheck","checkArrayNeedsUpdate","needUpdate","copyArrayElementsFromTo","checkTypedArrayNeedsUpdate","once","checkObjectNeedsUpdate","checkValueNeedsUpdate","getUpdateCheckForType","Array","isArray","bind","CheckboxView","checkboxElem","setter","id","onInput","checked","setFinalValue","tasks","tasksToRemove","Set","requestId","processing","processTasks","task","has","size","queueProcessing","clear","requestAnimationFrame","makeId","ValueView","LabelController","nameElem","for","title","tooltip","tip","ValueController","initialValue","listening","updateFn","getValue","setValueImpl","isDifferent","keys","assign","reset","listen","set","removeTask","Checkbox","strToNumber","toString","parseFloat","Number","isNaN","radToDeg","PI","createWheelHelper","wheelAccum","e","wheelScale","deltaY","delta","floor","abs","sign","NumberView","skipUpdate","NEGATIVE_INFINITY","POSITIVE_INFINITY","wheelHelper","handleInput","onWheel","preventDefault","setFn","valid","inRange","TextNumber","textView","SelectView","values","keyValues","selectedIndex","convertToKeyValues","valueIsNumber","Select","keyValuesInput","RangeView","validV","Range","TextView","Text","lerp","t","fract","f0","toFixed","f3","hexToUint32RGB","parseInt","hexToUint32RGBA","hexToUint8RGB","uint8RGBToHex","padStart","join","hexToUint8RGBA","uint8RGBAToHex","hexToFloatRGB","floatRGBToHex","hexToFloatRGBA","floatRGBAToHex","scaleAndClamp","hexToObjectRGB","r","g","hexToObjectRGBA","hexToCssRGB","cssRGBRegex","hexToCssRGBA","cssRGBARegex","hexToCssHSL","hsl","rgbUint8ToHsl","hexToCssHSLA","hsla","rgbaUint8ToHsla","cssHSLRegex","cssHSLARegex","hslToRgbUint8","h","l","f","rgbFloatToHsl01","d","rgbaFloatToHsla01","rgb","rgba","hsv01ToRGBFloat","hue","sat","val","hsva01ToRGBAFloat","alpha","round3","rgbFloatToHSV01","p","q","EPSILON","hasAlpha","format","endsWith","cssStringFormats","re","guessFormat","console","warn","formatInfo","test","guessStringColorFormat","trim","Uint8Array","Uint8ClampedArray","Float32Array","Error","fixHex6","fixHex8","hex6ToHex3","hex6","hex3RE","hex3ToHex6","hex3","exec","m2","fixHex3","strToCssRGB","find","strToCssRGBA","strToCssHSL","strToCssHSLA","strTo3IntsRE","strTo4IntsRE","strToUint32RGBRegex","strToUint32RGBARegex","hex6RE","hexNoHash6RE","hex8RE","hexNoHash8RE","colorFormatConverters","text","hex8","strToUint32RGB","strToUint32RGBA","numbers","split","badNdx","findIndex","json","JSON","parse","hslaToRgbaUint8","ElementView","Canvas","canvasElem","canvas","ColorView","colorElem","Color","colorView","Divider","Container","controllers","childDestController","filter","c","folders","recursive","c0","addControllerImpl","addController","pushContainer","container","popContainer","Folder","labelElem","toggleOpen","open","close","contains","Label","noop","computeRelativePosition","event","start","rect","getBoundingClientRect","x","clientX","left","y","clientY","top","nx","width","ny","height","dx","dy","ndy","addTouchEvents","onDown","onMove","onUp","pointerMove","pointerUp","releasePointerCapture","pointerId","removeEventListener","body","backgroundColor","pointerDown","setPointerCapture","rel","connectFillTargets","srcElem","dataset","targetElem","ColorChooserView","satLevelElem","circleElem","hueUIElem","hueElem","hueCursorElem","alphaUIElem","alphaElem","alphaCursorElem","hsva","skipHueUpdate","skipSatLevelUpdate","skipAlphaUpdate","convertInternalToHex","convertHexToInternal","innerHTML","handleSatLevelChange","handleHueChange","handleAlphaChange","lum","display","rgbaFloatToHSVA01","PopDownController","valuesView","bottom","setKnobColor","bgCssColor","addTop","addBottom","ColorChooser","setKnobHelper","hex6Or8","hex","GUIFolder","args","arg1","createController","addCanvas","addColor","addDivider","addFolder","addLabel","MuiguiElement","HTMLElement","shadow","attachShadow","mode","customElements","define","baseStyleSheet","CSSStyleSheet","replaceSync","userStyleSheet","makeStyleSheetUpdater","styleSheet","newCss","newCssPromise","updateStyle","then","updateBaseStyle","updateUserStyle","GUI","static","localStyleSheet","autoPlace","muiguiElement","shadowRoot","adoptedStyleSheets","setStyle","setBaseStyles","keyDirections","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","addKeyboardEvents","keyDown","mult","shiftKey","assert","truthy","msg","getEllipsePointForAngle","cx","cy","rx","ry","phi","theta","cos","sin","arc","end","x1","y1","x2","y2","fa","fs","dTheta","getEndpointParameters","twoPiMod","DirectionView","arrowElem","rangeElem","lastV","wrap","dirMin","dirMax","tempV","handleTouch","atan2","center","angle","transform","Direction","RadioGridView","cols","that","previousElementSibling","click","gridTemplateColumns","RadioGrid","onResize","callback","ResizeObserver","observe","onResizeSVGNoScale","hAnchor","vAnchor","createSVGTicks","SliderView","svgElem","originElem","ticksElem","thicksElem","numbersElem","leftGradElem","rightGradElem","minusSize","unit","unitSize","ticksPerUnit","labelFn","tickHeight","limits","thicksColor","orientation","startV","oldHTML","getComputedTextLength","computeSizeOfMinus","updateSlider","unitsAcross","ceil","centerUnitSpace","startUnitSpace","minUnitSpace","maxUnitSpace","stroke","texts","digits","log10","createSVGNumbers","Slider","Vec2View","onTouch","updateDisplayImpl","Vec2","makeSetter"],"mappings":"AAAA,IAAeA,EAAA,CACbC,QAAS,s7cAsrBXC,OAAQ,CACND,QAAS,GACTE,MAAO,gyCCpqBF,SAASC,EAAWC,EAAKC,EAAQ,CAAA,EAAIC,EAAW,IACrD,MAAMC,EAAOC,SAASC,cAAcL,GAEpC,OAxBK,SAAsBG,EAAMF,EAAOC,GACxC,IAAK,MAAOI,EAAKC,KAAUC,OAAOC,QAAQR,GACxC,GAAqB,mBAAVM,GAAwBD,EAAII,WAAW,MAAO,CACvD,MAAMC,EAAYL,EAAIM,UAAU,GAAGC,cACnCV,EAAKW,iBAAiBH,EAAWJ,EAAO,CAACQ,SAAS,GACxD,MAAW,GAAqB,iBAAVR,EAChB,IAAK,MAAOS,EAAGC,KAAMT,OAAOC,QAAQF,GAClCJ,EAAKG,GAAKU,GAAKC,YAEMC,IAAdf,EAAKG,GACdH,EAAKgB,aAAab,EAAKC,GAEvBJ,EAAKG,GAAOC,EAGhB,IAAK,MAAMa,KAASlB,EAClBC,EAAKkB,YAAYD,EAGrB,CAIEE,CAAanB,EAAMF,EAAOC,GACnBC,CACT,CAQA,IAAIoB,EAAS,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tBqC,KAAKmX,OAAO,IAAInO,EAAWiX,EAAW,GAAI,CACxCthB,WAAY,CACVF,GAAIpC,GAAKA,EAAE,GACXsB,KAAMqK,EAAYrK,SAGtBqC,KAAKoX,UAAU,IAAIyI,GAAS7f,OAC5BA,KAAKgD,eACN"}
\ No newline at end of file
diff --git a/dist/0.x/styles/muigui.css.d.ts b/dist/0.x/styles/muigui.css.d.ts
new file mode 100644
index 0000000..8ba9894
--- /dev/null
+++ b/dist/0.x/styles/muigui.css.d.ts
@@ -0,0 +1,10 @@
+declare namespace _default {
+ let _default: string;
+ export { _default as default };
+ export namespace themes {
+ let _default_1: string;
+ export { _default_1 as default };
+ export let float: string;
+ }
+}
+export default _default;
diff --git a/dist/0.x/views/CheckboxView.d.ts b/dist/0.x/views/CheckboxView.d.ts
new file mode 100644
index 0000000..c59b489
--- /dev/null
+++ b/dist/0.x/views/CheckboxView.d.ts
@@ -0,0 +1,6 @@
+export default class CheckboxView extends EditView {
+ constructor(setter: any, id: any);
+ updateDisplay(v: any): void;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/ColorChooserView.d.ts b/dist/0.x/views/ColorChooserView.d.ts
new file mode 100644
index 0000000..3d3e6bf
--- /dev/null
+++ b/dist/0.x/views/ColorChooserView.d.ts
@@ -0,0 +1,7 @@
+export default class ColorChooserView extends EditView {
+ constructor(setter: any, options: any);
+ updateDisplay(newV: any): void;
+ setOptions(options: any): this;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/ColorView.d.ts b/dist/0.x/views/ColorView.d.ts
new file mode 100644
index 0000000..c720fce
--- /dev/null
+++ b/dist/0.x/views/ColorView.d.ts
@@ -0,0 +1,7 @@
+export default class ColorView extends EditView {
+ constructor(setter: any, options: any);
+ updateDisplay(v: any): void;
+ setOptions(options: any): this;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/DirectionView.d.ts b/dist/0.x/views/DirectionView.d.ts
new file mode 100644
index 0000000..02b64d8
--- /dev/null
+++ b/dist/0.x/views/DirectionView.d.ts
@@ -0,0 +1,7 @@
+export default class DirectionView extends EditView {
+ constructor(setter: any, options?: {});
+ updateDisplay(v: any): void;
+ setOptions(options: any): void;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/EditView.d.ts b/dist/0.x/views/EditView.d.ts
new file mode 100644
index 0000000..a9b29b2
--- /dev/null
+++ b/dist/0.x/views/EditView.d.ts
@@ -0,0 +1,6 @@
+export default class EditView extends View {
+ updateDisplayIfNeeded(newV: any, ignoreCache: any): void;
+ setOptions(): this;
+ #private;
+}
+import View from './View.js';
diff --git a/dist/0.x/views/ElementView.d.ts b/dist/0.x/views/ElementView.d.ts
new file mode 100644
index 0000000..8c9129b
--- /dev/null
+++ b/dist/0.x/views/ElementView.d.ts
@@ -0,0 +1,4 @@
+export default class ElementView extends View {
+ constructor(tag: any, className: any);
+}
+import View from './View.js';
diff --git a/dist/0.x/views/NumberView.d.ts b/dist/0.x/views/NumberView.d.ts
new file mode 100644
index 0000000..60ab85f
--- /dev/null
+++ b/dist/0.x/views/NumberView.d.ts
@@ -0,0 +1,7 @@
+export default class NumberView extends EditView {
+ constructor(setter: any, options: any);
+ updateDisplay(v: any): void;
+ setOptions(options: any): this;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/RadioGridView.d.ts b/dist/0.x/views/RadioGridView.d.ts
new file mode 100644
index 0000000..22fa167
--- /dev/null
+++ b/dist/0.x/views/RadioGridView.d.ts
@@ -0,0 +1,7 @@
+export default class RadioGridView extends EditView {
+ constructor(setter: any, keyValues: any, cols?: number);
+ updateDisplay(v: any): void;
+ cols(cols: any): void;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/RangeView.d.ts b/dist/0.x/views/RangeView.d.ts
new file mode 100644
index 0000000..5f0a8fe
--- /dev/null
+++ b/dist/0.x/views/RangeView.d.ts
@@ -0,0 +1,7 @@
+export default class RangeView extends EditView {
+ constructor(setter: any, options: any);
+ updateDisplay(v: any): void;
+ setOptions(options: any): this;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/SelectView.d.ts b/dist/0.x/views/SelectView.d.ts
new file mode 100644
index 0000000..a285fa0
--- /dev/null
+++ b/dist/0.x/views/SelectView.d.ts
@@ -0,0 +1,6 @@
+export default class SelectView extends EditView {
+ constructor(setter: any, keyValues: any);
+ updateDisplay(v: any): void;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/SliderView.d.ts b/dist/0.x/views/SliderView.d.ts
new file mode 100644
index 0000000..548e030
--- /dev/null
+++ b/dist/0.x/views/SliderView.d.ts
@@ -0,0 +1,7 @@
+export default class SliderView extends EditView {
+ constructor(setter: any, options: any);
+ updateDisplay(v: any): void;
+ setOptions(options: any): this;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/TextView.d.ts b/dist/0.x/views/TextView.d.ts
new file mode 100644
index 0000000..1e16541
--- /dev/null
+++ b/dist/0.x/views/TextView.d.ts
@@ -0,0 +1,7 @@
+export default class TextView extends EditView {
+ constructor(setter: any, options: any);
+ updateDisplay(v: any): void;
+ setOptions(options: any): this;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/ValueView.d.ts b/dist/0.x/views/ValueView.d.ts
new file mode 100644
index 0000000..bb0bcf1
--- /dev/null
+++ b/dist/0.x/views/ValueView.d.ts
@@ -0,0 +1,4 @@
+export default class ValueView extends View {
+ constructor(className?: string);
+}
+import View from './View.js';
diff --git a/dist/0.x/views/Vec2View.d.ts b/dist/0.x/views/Vec2View.d.ts
new file mode 100644
index 0000000..03df976
--- /dev/null
+++ b/dist/0.x/views/Vec2View.d.ts
@@ -0,0 +1,6 @@
+export default class Vec2View extends EditView {
+ constructor(setter: any);
+ updateDisplay(v: any): void;
+ #private;
+}
+import EditView from './EditView.js';
diff --git a/dist/0.x/views/View.d.ts b/dist/0.x/views/View.d.ts
new file mode 100644
index 0000000..058dcb3
--- /dev/null
+++ b/dist/0.x/views/View.d.ts
@@ -0,0 +1,16 @@
+export default class View {
+ #private;
+ domElement: HTMLElement;
+ constructor(elem: HTMLElement);
+ addElem(elem: HTMLElement): HTMLElement;
+ removeElem(elem: HTMLElement): HTMLElement;
+ pushSubElem(elem: HTMLElement): void;
+ popSubElem(): void;
+ add(view: View): View;
+ remove(view: View): View;
+ pushSubView(view: View): void;
+ popSubView(): void;
+ setOptions(options: any): void;
+ updateDisplayIfNeeded(newV: any, ignoreCache?: boolean): this;
+ $(selector: string): Element | null;
+}
diff --git a/examples/3rdParty/threejs/build/three.module.js b/examples/3rdParty/threejs/build/three.module.js
new file mode 100644
index 0000000..4630d4a
--- /dev/null
+++ b/examples/3rdParty/threejs/build/three.module.js
@@ -0,0 +1,49023 @@
+/**
+ * @license
+ * Copyright 2010-2022 Three.js Authors
+ * SPDX-License-Identifier: MIT
+ */
+const REVISION = '142';
+const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
+const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
+const CullFaceNone = 0;
+const CullFaceBack = 1;
+const CullFaceFront = 2;
+const CullFaceFrontBack = 3;
+const BasicShadowMap = 0;
+const PCFShadowMap = 1;
+const PCFSoftShadowMap = 2;
+const VSMShadowMap = 3;
+const FrontSide = 0;
+const BackSide = 1;
+const DoubleSide = 2;
+const FlatShading = 1;
+const SmoothShading = 2;
+const NoBlending = 0;
+const NormalBlending = 1;
+const AdditiveBlending = 2;
+const SubtractiveBlending = 3;
+const MultiplyBlending = 4;
+const CustomBlending = 5;
+const AddEquation = 100;
+const SubtractEquation = 101;
+const ReverseSubtractEquation = 102;
+const MinEquation = 103;
+const MaxEquation = 104;
+const ZeroFactor = 200;
+const OneFactor = 201;
+const SrcColorFactor = 202;
+const OneMinusSrcColorFactor = 203;
+const SrcAlphaFactor = 204;
+const OneMinusSrcAlphaFactor = 205;
+const DstAlphaFactor = 206;
+const OneMinusDstAlphaFactor = 207;
+const DstColorFactor = 208;
+const OneMinusDstColorFactor = 209;
+const SrcAlphaSaturateFactor = 210;
+const NeverDepth = 0;
+const AlwaysDepth = 1;
+const LessDepth = 2;
+const LessEqualDepth = 3;
+const EqualDepth = 4;
+const GreaterEqualDepth = 5;
+const GreaterDepth = 6;
+const NotEqualDepth = 7;
+const MultiplyOperation = 0;
+const MixOperation = 1;
+const AddOperation = 2;
+const NoToneMapping = 0;
+const LinearToneMapping = 1;
+const ReinhardToneMapping = 2;
+const CineonToneMapping = 3;
+const ACESFilmicToneMapping = 4;
+const CustomToneMapping = 5;
+
+const UVMapping = 300;
+const CubeReflectionMapping = 301;
+const CubeRefractionMapping = 302;
+const EquirectangularReflectionMapping = 303;
+const EquirectangularRefractionMapping = 304;
+const CubeUVReflectionMapping = 306;
+const RepeatWrapping = 1000;
+const ClampToEdgeWrapping = 1001;
+const MirroredRepeatWrapping = 1002;
+const NearestFilter = 1003;
+const NearestMipmapNearestFilter = 1004;
+const NearestMipMapNearestFilter = 1004;
+const NearestMipmapLinearFilter = 1005;
+const NearestMipMapLinearFilter = 1005;
+const LinearFilter = 1006;
+const LinearMipmapNearestFilter = 1007;
+const LinearMipMapNearestFilter = 1007;
+const LinearMipmapLinearFilter = 1008;
+const LinearMipMapLinearFilter = 1008;
+const UnsignedByteType = 1009;
+const ByteType = 1010;
+const ShortType = 1011;
+const UnsignedShortType = 1012;
+const IntType = 1013;
+const UnsignedIntType = 1014;
+const FloatType = 1015;
+const HalfFloatType = 1016;
+const UnsignedShort4444Type = 1017;
+const UnsignedShort5551Type = 1018;
+const UnsignedInt248Type = 1020;
+const AlphaFormat = 1021;
+const RGBFormat = 1022;
+const RGBAFormat = 1023;
+const LuminanceFormat = 1024;
+const LuminanceAlphaFormat = 1025;
+const DepthFormat = 1026;
+const DepthStencilFormat = 1027;
+const RedFormat = 1028;
+const RedIntegerFormat = 1029;
+const RGFormat = 1030;
+const RGIntegerFormat = 1031;
+const RGBAIntegerFormat = 1033;
+
+const RGB_S3TC_DXT1_Format = 33776;
+const RGBA_S3TC_DXT1_Format = 33777;
+const RGBA_S3TC_DXT3_Format = 33778;
+const RGBA_S3TC_DXT5_Format = 33779;
+const RGB_PVRTC_4BPPV1_Format = 35840;
+const RGB_PVRTC_2BPPV1_Format = 35841;
+const RGBA_PVRTC_4BPPV1_Format = 35842;
+const RGBA_PVRTC_2BPPV1_Format = 35843;
+const RGB_ETC1_Format = 36196;
+const RGB_ETC2_Format = 37492;
+const RGBA_ETC2_EAC_Format = 37496;
+const RGBA_ASTC_4x4_Format = 37808;
+const RGBA_ASTC_5x4_Format = 37809;
+const RGBA_ASTC_5x5_Format = 37810;
+const RGBA_ASTC_6x5_Format = 37811;
+const RGBA_ASTC_6x6_Format = 37812;
+const RGBA_ASTC_8x5_Format = 37813;
+const RGBA_ASTC_8x6_Format = 37814;
+const RGBA_ASTC_8x8_Format = 37815;
+const RGBA_ASTC_10x5_Format = 37816;
+const RGBA_ASTC_10x6_Format = 37817;
+const RGBA_ASTC_10x8_Format = 37818;
+const RGBA_ASTC_10x10_Format = 37819;
+const RGBA_ASTC_12x10_Format = 37820;
+const RGBA_ASTC_12x12_Format = 37821;
+const RGBA_BPTC_Format = 36492;
+const LoopOnce = 2200;
+const LoopRepeat = 2201;
+const LoopPingPong = 2202;
+const InterpolateDiscrete = 2300;
+const InterpolateLinear = 2301;
+const InterpolateSmooth = 2302;
+const ZeroCurvatureEnding = 2400;
+const ZeroSlopeEnding = 2401;
+const WrapAroundEnding = 2402;
+const NormalAnimationBlendMode = 2500;
+const AdditiveAnimationBlendMode = 2501;
+const TrianglesDrawMode = 0;
+const TriangleStripDrawMode = 1;
+const TriangleFanDrawMode = 2;
+const LinearEncoding = 3000;
+const sRGBEncoding = 3001;
+const BasicDepthPacking = 3200;
+const RGBADepthPacking = 3201;
+const TangentSpaceNormalMap = 0;
+const ObjectSpaceNormalMap = 1;
+
+// Color space string identifiers, matching CSS Color Module Level 4 and WebGPU names where available.
+const NoColorSpace = '';
+const SRGBColorSpace = 'srgb';
+const LinearSRGBColorSpace = 'srgb-linear';
+
+const ZeroStencilOp = 0;
+const KeepStencilOp = 7680;
+const ReplaceStencilOp = 7681;
+const IncrementStencilOp = 7682;
+const DecrementStencilOp = 7683;
+const IncrementWrapStencilOp = 34055;
+const DecrementWrapStencilOp = 34056;
+const InvertStencilOp = 5386;
+
+const NeverStencilFunc = 512;
+const LessStencilFunc = 513;
+const EqualStencilFunc = 514;
+const LessEqualStencilFunc = 515;
+const GreaterStencilFunc = 516;
+const NotEqualStencilFunc = 517;
+const GreaterEqualStencilFunc = 518;
+const AlwaysStencilFunc = 519;
+
+const StaticDrawUsage = 35044;
+const DynamicDrawUsage = 35048;
+const StreamDrawUsage = 35040;
+const StaticReadUsage = 35045;
+const DynamicReadUsage = 35049;
+const StreamReadUsage = 35041;
+const StaticCopyUsage = 35046;
+const DynamicCopyUsage = 35050;
+const StreamCopyUsage = 35042;
+
+const GLSL1 = '100';
+const GLSL3 = '300 es';
+
+const _SRGBAFormat = 1035; // fallback for WebGL 1
+
+/**
+ * https://github.com/mrdoob/eventdispatcher.js/
+ */
+
+class EventDispatcher {
+
+ addEventListener( type, listener ) {
+
+ if ( this._listeners === undefined ) this._listeners = {};
+
+ const listeners = this._listeners;
+
+ if ( listeners[ type ] === undefined ) {
+
+ listeners[ type ] = [];
+
+ }
+
+ if ( listeners[ type ].indexOf( listener ) === - 1 ) {
+
+ listeners[ type ].push( listener );
+
+ }
+
+ }
+
+ hasEventListener( type, listener ) {
+
+ if ( this._listeners === undefined ) return false;
+
+ const listeners = this._listeners;
+
+ return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
+
+ }
+
+ removeEventListener( type, listener ) {
+
+ if ( this._listeners === undefined ) return;
+
+ const listeners = this._listeners;
+ const listenerArray = listeners[ type ];
+
+ if ( listenerArray !== undefined ) {
+
+ const index = listenerArray.indexOf( listener );
+
+ if ( index !== - 1 ) {
+
+ listenerArray.splice( index, 1 );
+
+ }
+
+ }
+
+ }
+
+ dispatchEvent( event ) {
+
+ if ( this._listeners === undefined ) return;
+
+ const listeners = this._listeners;
+ const listenerArray = listeners[ event.type ];
+
+ if ( listenerArray !== undefined ) {
+
+ event.target = this;
+
+ // Make a copy, in case listeners are removed while iterating.
+ const array = listenerArray.slice( 0 );
+
+ for ( let i = 0, l = array.length; i < l; i ++ ) {
+
+ array[ i ].call( this, event );
+
+ }
+
+ event.target = null;
+
+ }
+
+ }
+
+}
+
+const _lut = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff' ];
+
+let _seed = 1234567;
+
+
+const DEG2RAD = Math.PI / 180;
+const RAD2DEG = 180 / Math.PI;
+
+// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
+function generateUUID() {
+
+ const d0 = Math.random() * 0xffffffff | 0;
+ const d1 = Math.random() * 0xffffffff | 0;
+ const d2 = Math.random() * 0xffffffff | 0;
+ const d3 = Math.random() * 0xffffffff | 0;
+ const uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +
+ _lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +
+ _lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +
+ _lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];
+
+ // .toLowerCase() here flattens concatenated strings to save heap memory space.
+ return uuid.toLowerCase();
+
+}
+
+function clamp( value, min, max ) {
+
+ return Math.max( min, Math.min( max, value ) );
+
+}
+
+// compute euclidean modulo of m % n
+// https://en.wikipedia.org/wiki/Modulo_operation
+function euclideanModulo( n, m ) {
+
+ return ( ( n % m ) + m ) % m;
+
+}
+
+// Linear mapping from range to range
+function mapLinear( x, a1, a2, b1, b2 ) {
+
+ return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
+
+}
+
+// https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
+function inverseLerp( x, y, value ) {
+
+ if ( x !== y ) {
+
+ return ( value - x ) / ( y - x );
+
+ } else {
+
+ return 0;
+
+ }
+
+}
+
+// https://en.wikipedia.org/wiki/Linear_interpolation
+function lerp( x, y, t ) {
+
+ return ( 1 - t ) * x + t * y;
+
+}
+
+// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
+function damp( x, y, lambda, dt ) {
+
+ return lerp( x, y, 1 - Math.exp( - lambda * dt ) );
+
+}
+
+// https://www.desmos.com/calculator/vcsjnyz7x4
+function pingpong( x, length = 1 ) {
+
+ return length - Math.abs( euclideanModulo( x, length * 2 ) - length );
+
+}
+
+// http://en.wikipedia.org/wiki/Smoothstep
+function smoothstep( x, min, max ) {
+
+ if ( x <= min ) return 0;
+ if ( x >= max ) return 1;
+
+ x = ( x - min ) / ( max - min );
+
+ return x * x * ( 3 - 2 * x );
+
+}
+
+function smootherstep( x, min, max ) {
+
+ if ( x <= min ) return 0;
+ if ( x >= max ) return 1;
+
+ x = ( x - min ) / ( max - min );
+
+ return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
+
+}
+
+// Random integer from interval
+function randInt( low, high ) {
+
+ return low + Math.floor( Math.random() * ( high - low + 1 ) );
+
+}
+
+// Random float from interval
+function randFloat( low, high ) {
+
+ return low + Math.random() * ( high - low );
+
+}
+
+// Random float from <-range/2, range/2> interval
+function randFloatSpread( range ) {
+
+ return range * ( 0.5 - Math.random() );
+
+}
+
+// Deterministic pseudo-random float in the interval [ 0, 1 ]
+function seededRandom( s ) {
+
+ if ( s !== undefined ) _seed = s;
+
+ // Mulberry32 generator
+
+ let t = _seed += 0x6D2B79F5;
+
+ t = Math.imul( t ^ t >>> 15, t | 1 );
+
+ t ^= t + Math.imul( t ^ t >>> 7, t | 61 );
+
+ return ( ( t ^ t >>> 14 ) >>> 0 ) / 4294967296;
+
+}
+
+function degToRad( degrees ) {
+
+ return degrees * DEG2RAD;
+
+}
+
+function radToDeg( radians ) {
+
+ return radians * RAD2DEG;
+
+}
+
+function isPowerOfTwo( value ) {
+
+ return ( value & ( value - 1 ) ) === 0 && value !== 0;
+
+}
+
+function ceilPowerOfTwo( value ) {
+
+ return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
+
+}
+
+function floorPowerOfTwo( value ) {
+
+ return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
+
+}
+
+function setQuaternionFromProperEuler( q, a, b, c, order ) {
+
+ // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles
+
+ // rotations are applied to the axes in the order specified by 'order'
+ // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'
+ // angles are in radians
+
+ const cos = Math.cos;
+ const sin = Math.sin;
+
+ const c2 = cos( b / 2 );
+ const s2 = sin( b / 2 );
+
+ const c13 = cos( ( a + c ) / 2 );
+ const s13 = sin( ( a + c ) / 2 );
+
+ const c1_3 = cos( ( a - c ) / 2 );
+ const s1_3 = sin( ( a - c ) / 2 );
+
+ const c3_1 = cos( ( c - a ) / 2 );
+ const s3_1 = sin( ( c - a ) / 2 );
+
+ switch ( order ) {
+
+ case 'XYX':
+ q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );
+ break;
+
+ case 'YZY':
+ q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );
+ break;
+
+ case 'ZXZ':
+ q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );
+ break;
+
+ case 'XZX':
+ q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );
+ break;
+
+ case 'YXY':
+ q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );
+ break;
+
+ case 'ZYZ':
+ q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );
+ break;
+
+ default:
+ console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
+
+ }
+
+}
+
+function denormalize$1( value, array ) {
+
+ switch ( array.constructor ) {
+
+ case Float32Array:
+
+ return value;
+
+ case Uint16Array:
+
+ return value / 65535.0;
+
+ case Uint8Array:
+
+ return value / 255.0;
+
+ case Int16Array:
+
+ return Math.max( value / 32767.0, - 1.0 );
+
+ case Int8Array:
+
+ return Math.max( value / 127.0, - 1.0 );
+
+ default:
+
+ throw new Error( 'Invalid component type.' );
+
+ }
+
+}
+
+function normalize( value, array ) {
+
+ switch ( array.constructor ) {
+
+ case Float32Array:
+
+ return value;
+
+ case Uint16Array:
+
+ return Math.round( value * 65535.0 );
+
+ case Uint8Array:
+
+ return Math.round( value * 255.0 );
+
+ case Int16Array:
+
+ return Math.round( value * 32767.0 );
+
+ case Int8Array:
+
+ return Math.round( value * 127.0 );
+
+ default:
+
+ throw new Error( 'Invalid component type.' );
+
+ }
+
+}
+
+var MathUtils = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ DEG2RAD: DEG2RAD,
+ RAD2DEG: RAD2DEG,
+ generateUUID: generateUUID,
+ clamp: clamp,
+ euclideanModulo: euclideanModulo,
+ mapLinear: mapLinear,
+ inverseLerp: inverseLerp,
+ lerp: lerp,
+ damp: damp,
+ pingpong: pingpong,
+ smoothstep: smoothstep,
+ smootherstep: smootherstep,
+ randInt: randInt,
+ randFloat: randFloat,
+ randFloatSpread: randFloatSpread,
+ seededRandom: seededRandom,
+ degToRad: degToRad,
+ radToDeg: radToDeg,
+ isPowerOfTwo: isPowerOfTwo,
+ ceilPowerOfTwo: ceilPowerOfTwo,
+ floorPowerOfTwo: floorPowerOfTwo,
+ setQuaternionFromProperEuler: setQuaternionFromProperEuler,
+ normalize: normalize,
+ denormalize: denormalize$1
+});
+
+class Vector2 {
+
+ constructor( x = 0, y = 0 ) {
+
+ Vector2.prototype.isVector2 = true;
+
+ this.x = x;
+ this.y = y;
+
+ }
+
+ get width() {
+
+ return this.x;
+
+ }
+
+ set width( value ) {
+
+ this.x = value;
+
+ }
+
+ get height() {
+
+ return this.y;
+
+ }
+
+ set height( value ) {
+
+ this.y = value;
+
+ }
+
+ set( x, y ) {
+
+ this.x = x;
+ this.y = y;
+
+ return this;
+
+ }
+
+ setScalar( scalar ) {
+
+ this.x = scalar;
+ this.y = scalar;
+
+ return this;
+
+ }
+
+ setX( x ) {
+
+ this.x = x;
+
+ return this;
+
+ }
+
+ setY( y ) {
+
+ this.y = y;
+
+ return this;
+
+ }
+
+ setComponent( index, value ) {
+
+ switch ( index ) {
+
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
+
+ }
+
+ return this;
+
+ }
+
+ getComponent( index ) {
+
+ switch ( index ) {
+
+ case 0: return this.x;
+ case 1: return this.y;
+ default: throw new Error( 'index is out of range: ' + index );
+
+ }
+
+ }
+
+ clone() {
+
+ return new this.constructor( this.x, this.y );
+
+ }
+
+ copy( v ) {
+
+ this.x = v.x;
+ this.y = v.y;
+
+ return this;
+
+ }
+
+ add( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
+
+ }
+
+ this.x += v.x;
+ this.y += v.y;
+
+ return this;
+
+ }
+
+ addScalar( s ) {
+
+ this.x += s;
+ this.y += s;
+
+ return this;
+
+ }
+
+ addVectors( a, b ) {
+
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+
+ return this;
+
+ }
+
+ addScaledVector( v, s ) {
+
+ this.x += v.x * s;
+ this.y += v.y * s;
+
+ return this;
+
+ }
+
+ sub( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
+
+ }
+
+ this.x -= v.x;
+ this.y -= v.y;
+
+ return this;
+
+ }
+
+ subScalar( s ) {
+
+ this.x -= s;
+ this.y -= s;
+
+ return this;
+
+ }
+
+ subVectors( a, b ) {
+
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+
+ return this;
+
+ }
+
+ multiply( v ) {
+
+ this.x *= v.x;
+ this.y *= v.y;
+
+ return this;
+
+ }
+
+ multiplyScalar( scalar ) {
+
+ this.x *= scalar;
+ this.y *= scalar;
+
+ return this;
+
+ }
+
+ divide( v ) {
+
+ this.x /= v.x;
+ this.y /= v.y;
+
+ return this;
+
+ }
+
+ divideScalar( scalar ) {
+
+ return this.multiplyScalar( 1 / scalar );
+
+ }
+
+ applyMatrix3( m ) {
+
+ const x = this.x, y = this.y;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];
+
+ return this;
+
+ }
+
+ min( v ) {
+
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+
+ return this;
+
+ }
+
+ max( v ) {
+
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+
+ return this;
+
+ }
+
+ clamp( min, max ) {
+
+ // assumes min < max, componentwise
+
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+
+ return this;
+
+ }
+
+ clampScalar( minVal, maxVal ) {
+
+ this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
+ this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
+
+ return this;
+
+ }
+
+ clampLength( min, max ) {
+
+ const length = this.length();
+
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+
+ }
+
+ floor() {
+
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+
+ return this;
+
+ }
+
+ ceil() {
+
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+
+ return this;
+
+ }
+
+ round() {
+
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+
+ return this;
+
+ }
+
+ roundToZero() {
+
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+
+ return this;
+
+ }
+
+ negate() {
+
+ this.x = - this.x;
+ this.y = - this.y;
+
+ return this;
+
+ }
+
+ dot( v ) {
+
+ return this.x * v.x + this.y * v.y;
+
+ }
+
+ cross( v ) {
+
+ return this.x * v.y - this.y * v.x;
+
+ }
+
+ lengthSq() {
+
+ return this.x * this.x + this.y * this.y;
+
+ }
+
+ length() {
+
+ return Math.sqrt( this.x * this.x + this.y * this.y );
+
+ }
+
+ manhattanLength() {
+
+ return Math.abs( this.x ) + Math.abs( this.y );
+
+ }
+
+ normalize() {
+
+ return this.divideScalar( this.length() || 1 );
+
+ }
+
+ angle() {
+
+ // computes the angle in radians with respect to the positive x-axis
+
+ const angle = Math.atan2( - this.y, - this.x ) + Math.PI;
+
+ return angle;
+
+ }
+
+ distanceTo( v ) {
+
+ return Math.sqrt( this.distanceToSquared( v ) );
+
+ }
+
+ distanceToSquared( v ) {
+
+ const dx = this.x - v.x, dy = this.y - v.y;
+ return dx * dx + dy * dy;
+
+ }
+
+ manhattanDistanceTo( v ) {
+
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
+
+ }
+
+ setLength( length ) {
+
+ return this.normalize().multiplyScalar( length );
+
+ }
+
+ lerp( v, alpha ) {
+
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+
+ return this;
+
+ }
+
+ lerpVectors( v1, v2, alpha ) {
+
+ this.x = v1.x + ( v2.x - v1.x ) * alpha;
+ this.y = v1.y + ( v2.y - v1.y ) * alpha;
+
+ return this;
+
+ }
+
+ equals( v ) {
+
+ return ( ( v.x === this.x ) && ( v.y === this.y ) );
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+
+ return array;
+
+ }
+
+ fromBufferAttribute( attribute, index, offset ) {
+
+ if ( offset !== undefined ) {
+
+ console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );
+
+ }
+
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+
+ return this;
+
+ }
+
+ rotateAround( center, angle ) {
+
+ const c = Math.cos( angle ), s = Math.sin( angle );
+
+ const x = this.x - center.x;
+ const y = this.y - center.y;
+
+ this.x = x * c - y * s + center.x;
+ this.y = x * s + y * c + center.y;
+
+ return this;
+
+ }
+
+ random() {
+
+ this.x = Math.random();
+ this.y = Math.random();
+
+ return this;
+
+ }
+
+ *[ Symbol.iterator ]() {
+
+ yield this.x;
+ yield this.y;
+
+ }
+
+}
+
+class Matrix3 {
+
+ constructor() {
+
+ Matrix3.prototype.isMatrix3 = true;
+
+ this.elements = [
+
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
+
+ ];
+
+ if ( arguments.length > 0 ) {
+
+ console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
+
+ }
+
+ }
+
+ set( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
+
+ const te = this.elements;
+
+ te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;
+ te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;
+ te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;
+
+ return this;
+
+ }
+
+ identity() {
+
+ this.set(
+
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ copy( m ) {
+
+ const te = this.elements;
+ const me = m.elements;
+
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
+ te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
+ te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
+
+ return this;
+
+ }
+
+ extractBasis( xAxis, yAxis, zAxis ) {
+
+ xAxis.setFromMatrix3Column( this, 0 );
+ yAxis.setFromMatrix3Column( this, 1 );
+ zAxis.setFromMatrix3Column( this, 2 );
+
+ return this;
+
+ }
+
+ setFromMatrix4( m ) {
+
+ const me = m.elements;
+
+ this.set(
+
+ me[ 0 ], me[ 4 ], me[ 8 ],
+ me[ 1 ], me[ 5 ], me[ 9 ],
+ me[ 2 ], me[ 6 ], me[ 10 ]
+
+ );
+
+ return this;
+
+ }
+
+ multiply( m ) {
+
+ return this.multiplyMatrices( this, m );
+
+ }
+
+ premultiply( m ) {
+
+ return this.multiplyMatrices( m, this );
+
+ }
+
+ multiplyMatrices( a, b ) {
+
+ const ae = a.elements;
+ const be = b.elements;
+ const te = this.elements;
+
+ const a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];
+ const a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];
+ const a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];
+
+ const b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];
+ const b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];
+ const b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];
+
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;
+ te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;
+ te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;
+
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;
+ te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;
+ te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;
+
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;
+ te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;
+ te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;
+
+ return this;
+
+ }
+
+ multiplyScalar( s ) {
+
+ const te = this.elements;
+
+ te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;
+ te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;
+ te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;
+
+ return this;
+
+ }
+
+ determinant() {
+
+ const te = this.elements;
+
+ const a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],
+ d = te[ 3 ], e = te[ 4 ], f = te[ 5 ],
+ g = te[ 6 ], h = te[ 7 ], i = te[ 8 ];
+
+ return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
+
+ }
+
+ invert() {
+
+ const te = this.elements,
+
+ n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ],
+ n12 = te[ 3 ], n22 = te[ 4 ], n32 = te[ 5 ],
+ n13 = te[ 6 ], n23 = te[ 7 ], n33 = te[ 8 ],
+
+ t11 = n33 * n22 - n32 * n23,
+ t12 = n32 * n13 - n33 * n12,
+ t13 = n23 * n12 - n22 * n13,
+
+ det = n11 * t11 + n21 * t12 + n31 * t13;
+
+ if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+
+ const detInv = 1 / det;
+
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;
+ te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;
+
+ te[ 3 ] = t12 * detInv;
+ te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;
+ te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;
+
+ te[ 6 ] = t13 * detInv;
+ te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;
+ te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;
+
+ return this;
+
+ }
+
+ transpose() {
+
+ let tmp;
+ const m = this.elements;
+
+ tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;
+ tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;
+ tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;
+
+ return this;
+
+ }
+
+ getNormalMatrix( matrix4 ) {
+
+ return this.setFromMatrix4( matrix4 ).invert().transpose();
+
+ }
+
+ transposeIntoArray( r ) {
+
+ const m = this.elements;
+
+ r[ 0 ] = m[ 0 ];
+ r[ 1 ] = m[ 3 ];
+ r[ 2 ] = m[ 6 ];
+ r[ 3 ] = m[ 1 ];
+ r[ 4 ] = m[ 4 ];
+ r[ 5 ] = m[ 7 ];
+ r[ 6 ] = m[ 2 ];
+ r[ 7 ] = m[ 5 ];
+ r[ 8 ] = m[ 8 ];
+
+ return this;
+
+ }
+
+ setUvTransform( tx, ty, sx, sy, rotation, cx, cy ) {
+
+ const c = Math.cos( rotation );
+ const s = Math.sin( rotation );
+
+ this.set(
+ sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,
+ - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,
+ 0, 0, 1
+ );
+
+ return this;
+
+ }
+
+ scale( sx, sy ) {
+
+ const te = this.elements;
+
+ te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;
+ te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;
+
+ return this;
+
+ }
+
+ rotate( theta ) {
+
+ const c = Math.cos( theta );
+ const s = Math.sin( theta );
+
+ const te = this.elements;
+
+ const a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];
+ const a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];
+
+ te[ 0 ] = c * a11 + s * a21;
+ te[ 3 ] = c * a12 + s * a22;
+ te[ 6 ] = c * a13 + s * a23;
+
+ te[ 1 ] = - s * a11 + c * a21;
+ te[ 4 ] = - s * a12 + c * a22;
+ te[ 7 ] = - s * a13 + c * a23;
+
+ return this;
+
+ }
+
+ translate( tx, ty ) {
+
+ const te = this.elements;
+
+ te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];
+ te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];
+
+ return this;
+
+ }
+
+ equals( matrix ) {
+
+ const te = this.elements;
+ const me = matrix.elements;
+
+ for ( let i = 0; i < 9; i ++ ) {
+
+ if ( te[ i ] !== me[ i ] ) return false;
+
+ }
+
+ return true;
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ for ( let i = 0; i < 9; i ++ ) {
+
+ this.elements[ i ] = array[ i + offset ];
+
+ }
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ const te = this.elements;
+
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
+
+ array[ offset + 3 ] = te[ 3 ];
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
+
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
+ array[ offset + 8 ] = te[ 8 ];
+
+ return array;
+
+ }
+
+ clone() {
+
+ return new this.constructor().fromArray( this.elements );
+
+ }
+
+}
+
+function arrayNeedsUint32( array ) {
+
+ // assumes larger values usually on last
+
+ for ( let i = array.length - 1; i >= 0; -- i ) {
+
+ if ( array[ i ] > 65535 ) return true;
+
+ }
+
+ return false;
+
+}
+
+const TYPED_ARRAYS = {
+ Int8Array: Int8Array,
+ Uint8Array: Uint8Array,
+ Uint8ClampedArray: Uint8ClampedArray,
+ Int16Array: Int16Array,
+ Uint16Array: Uint16Array,
+ Int32Array: Int32Array,
+ Uint32Array: Uint32Array,
+ Float32Array: Float32Array,
+ Float64Array: Float64Array
+};
+
+function getTypedArray( type, buffer ) {
+
+ return new TYPED_ARRAYS[ type ]( buffer );
+
+}
+
+function createElementNS( name ) {
+
+ return document.createElementNS( 'http://www.w3.org/1999/xhtml', name );
+
+}
+
+function SRGBToLinear( c ) {
+
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
+
+}
+
+function LinearToSRGB( c ) {
+
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
+
+}
+
+// JavaScript RGB-to-RGB transforms, defined as
+// FN[InputColorSpace][OutputColorSpace] callback functions.
+const FN = {
+ [ SRGBColorSpace ]: { [ LinearSRGBColorSpace ]: SRGBToLinear },
+ [ LinearSRGBColorSpace ]: { [ SRGBColorSpace ]: LinearToSRGB },
+};
+
+const ColorManagement = {
+
+ legacyMode: true,
+
+ get workingColorSpace() {
+
+ return LinearSRGBColorSpace;
+
+ },
+
+ set workingColorSpace( colorSpace ) {
+
+ console.warn( 'THREE.ColorManagement: .workingColorSpace is readonly.' );
+
+ },
+
+ convert: function ( color, sourceColorSpace, targetColorSpace ) {
+
+ if ( this.legacyMode || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
+
+ return color;
+
+ }
+
+ if ( FN[ sourceColorSpace ] && FN[ sourceColorSpace ][ targetColorSpace ] !== undefined ) {
+
+ const fn = FN[ sourceColorSpace ][ targetColorSpace ];
+
+ color.r = fn( color.r );
+ color.g = fn( color.g );
+ color.b = fn( color.b );
+
+ return color;
+
+ }
+
+ throw new Error( 'Unsupported color space conversion.' );
+
+ },
+
+ fromWorkingColorSpace: function ( color, targetColorSpace ) {
+
+ return this.convert( color, this.workingColorSpace, targetColorSpace );
+
+ },
+
+ toWorkingColorSpace: function ( color, sourceColorSpace ) {
+
+ return this.convert( color, sourceColorSpace, this.workingColorSpace );
+
+ },
+
+};
+
+const _colorKeywords = { '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 };
+
+const _rgb = { r: 0, g: 0, b: 0 };
+const _hslA = { h: 0, s: 0, l: 0 };
+const _hslB = { h: 0, s: 0, l: 0 };
+
+function hue2rgb( p, q, t ) {
+
+ if ( t < 0 ) t += 1;
+ if ( t > 1 ) t -= 1;
+ if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;
+ if ( t < 1 / 2 ) return q;
+ if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );
+ return p;
+
+}
+
+function toComponents( source, target ) {
+
+ target.r = source.r;
+ target.g = source.g;
+ target.b = source.b;
+
+ return target;
+
+}
+
+class Color {
+
+ constructor( r, g, b ) {
+
+ this.isColor = true;
+
+ this.r = 1;
+ this.g = 1;
+ this.b = 1;
+
+ if ( g === undefined && b === undefined ) {
+
+ // r is THREE.Color, hex or string
+ return this.set( r );
+
+ }
+
+ return this.setRGB( r, g, b );
+
+ }
+
+ set( value ) {
+
+ if ( value && value.isColor ) {
+
+ this.copy( value );
+
+ } else if ( typeof value === 'number' ) {
+
+ this.setHex( value );
+
+ } else if ( typeof value === 'string' ) {
+
+ this.setStyle( value );
+
+ }
+
+ return this;
+
+ }
+
+ setScalar( scalar ) {
+
+ this.r = scalar;
+ this.g = scalar;
+ this.b = scalar;
+
+ return this;
+
+ }
+
+ setHex( hex, colorSpace = SRGBColorSpace ) {
+
+ hex = Math.floor( hex );
+
+ this.r = ( hex >> 16 & 255 ) / 255;
+ this.g = ( hex >> 8 & 255 ) / 255;
+ this.b = ( hex & 255 ) / 255;
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ return this;
+
+ }
+
+ setRGB( r, g, b, colorSpace = LinearSRGBColorSpace ) {
+
+ this.r = r;
+ this.g = g;
+ this.b = b;
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ return this;
+
+ }
+
+ setHSL( h, s, l, colorSpace = LinearSRGBColorSpace ) {
+
+ // h,s,l ranges are in 0.0 - 1.0
+ h = euclideanModulo( h, 1 );
+ s = clamp( s, 0, 1 );
+ l = clamp( l, 0, 1 );
+
+ if ( s === 0 ) {
+
+ this.r = this.g = this.b = l;
+
+ } else {
+
+ const p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );
+ const q = ( 2 * l ) - p;
+
+ this.r = hue2rgb( q, p, h + 1 / 3 );
+ this.g = hue2rgb( q, p, h );
+ this.b = hue2rgb( q, p, h - 1 / 3 );
+
+ }
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ return this;
+
+ }
+
+ setStyle( style, colorSpace = SRGBColorSpace ) {
+
+ function handleAlpha( string ) {
+
+ if ( string === undefined ) return;
+
+ if ( parseFloat( string ) < 1 ) {
+
+ console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );
+
+ }
+
+ }
+
+
+ let m;
+
+ if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) {
+
+ // rgb / hsl
+
+ let color;
+ const name = m[ 1 ];
+ const components = m[ 2 ];
+
+ switch ( name ) {
+
+ case 'rgb':
+ case 'rgba':
+
+ if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
+
+ // rgb(255,0,0) rgba(255,0,0,0.5)
+ this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
+ this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;
+ this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ handleAlpha( color[ 4 ] );
+
+ return this;
+
+ }
+
+ if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
+
+ // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
+ this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
+ this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;
+ this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ handleAlpha( color[ 4 ] );
+
+ return this;
+
+ }
+
+ break;
+
+ case 'hsl':
+ case 'hsla':
+
+ if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
+
+ // hsl(120,50%,50%) hsla(120,50%,50%,0.5)
+ const h = parseFloat( color[ 1 ] ) / 360;
+ const s = parseInt( color[ 2 ], 10 ) / 100;
+ const l = parseInt( color[ 3 ], 10 ) / 100;
+
+ handleAlpha( color[ 4 ] );
+
+ return this.setHSL( h, s, l, colorSpace );
+
+ }
+
+ break;
+
+ }
+
+ } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) {
+
+ // hex color
+
+ const hex = m[ 1 ];
+ const size = hex.length;
+
+ if ( size === 3 ) {
+
+ // #ff0
+ this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;
+ this.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;
+ this.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ return this;
+
+ } else if ( size === 6 ) {
+
+ // #ff0000
+ this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;
+ this.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;
+ this.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;
+
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
+
+ return this;
+
+ }
+
+ }
+
+ if ( style && style.length > 0 ) {
+
+ return this.setColorName( style, colorSpace );
+
+ }
+
+ return this;
+
+ }
+
+ setColorName( style, colorSpace = SRGBColorSpace ) {
+
+ // color keywords
+ const hex = _colorKeywords[ style.toLowerCase() ];
+
+ if ( hex !== undefined ) {
+
+ // red
+ this.setHex( hex, colorSpace );
+
+ } else {
+
+ // unknown color
+ console.warn( 'THREE.Color: Unknown color ' + style );
+
+ }
+
+ return this;
+
+ }
+
+ clone() {
+
+ return new this.constructor( this.r, this.g, this.b );
+
+ }
+
+ copy( color ) {
+
+ this.r = color.r;
+ this.g = color.g;
+ this.b = color.b;
+
+ return this;
+
+ }
+
+ copySRGBToLinear( color ) {
+
+ this.r = SRGBToLinear( color.r );
+ this.g = SRGBToLinear( color.g );
+ this.b = SRGBToLinear( color.b );
+
+ return this;
+
+ }
+
+ copyLinearToSRGB( color ) {
+
+ this.r = LinearToSRGB( color.r );
+ this.g = LinearToSRGB( color.g );
+ this.b = LinearToSRGB( color.b );
+
+ return this;
+
+ }
+
+ convertSRGBToLinear() {
+
+ this.copySRGBToLinear( this );
+
+ return this;
+
+ }
+
+ convertLinearToSRGB() {
+
+ this.copyLinearToSRGB( this );
+
+ return this;
+
+ }
+
+ getHex( colorSpace = SRGBColorSpace ) {
+
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
+
+ return clamp( _rgb.r * 255, 0, 255 ) << 16 ^ clamp( _rgb.g * 255, 0, 255 ) << 8 ^ clamp( _rgb.b * 255, 0, 255 ) << 0;
+
+ }
+
+ getHexString( colorSpace = SRGBColorSpace ) {
+
+ return ( '000000' + this.getHex( colorSpace ).toString( 16 ) ).slice( - 6 );
+
+ }
+
+ getHSL( target, colorSpace = LinearSRGBColorSpace ) {
+
+ // h,s,l ranges are in 0.0 - 1.0
+
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
+
+ const r = _rgb.r, g = _rgb.g, b = _rgb.b;
+
+ const max = Math.max( r, g, b );
+ const min = Math.min( r, g, b );
+
+ let hue, saturation;
+ const lightness = ( min + max ) / 2.0;
+
+ if ( min === max ) {
+
+ hue = 0;
+ saturation = 0;
+
+ } else {
+
+ const delta = max - min;
+
+ saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );
+
+ switch ( max ) {
+
+ case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;
+ case g: hue = ( b - r ) / delta + 2; break;
+ case b: hue = ( r - g ) / delta + 4; break;
+
+ }
+
+ hue /= 6;
+
+ }
+
+ target.h = hue;
+ target.s = saturation;
+ target.l = lightness;
+
+ return target;
+
+ }
+
+ getRGB( target, colorSpace = LinearSRGBColorSpace ) {
+
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
+
+ target.r = _rgb.r;
+ target.g = _rgb.g;
+ target.b = _rgb.b;
+
+ return target;
+
+ }
+
+ getStyle( colorSpace = SRGBColorSpace ) {
+
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
+
+ if ( colorSpace !== SRGBColorSpace ) {
+
+ // Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).
+ return `color(${ colorSpace } ${ _rgb.r } ${ _rgb.g } ${ _rgb.b })`;
+
+ }
+
+ return `rgb(${( _rgb.r * 255 ) | 0},${( _rgb.g * 255 ) | 0},${( _rgb.b * 255 ) | 0})`;
+
+ }
+
+ offsetHSL( h, s, l ) {
+
+ this.getHSL( _hslA );
+
+ _hslA.h += h; _hslA.s += s; _hslA.l += l;
+
+ this.setHSL( _hslA.h, _hslA.s, _hslA.l );
+
+ return this;
+
+ }
+
+ add( color ) {
+
+ this.r += color.r;
+ this.g += color.g;
+ this.b += color.b;
+
+ return this;
+
+ }
+
+ addColors( color1, color2 ) {
+
+ this.r = color1.r + color2.r;
+ this.g = color1.g + color2.g;
+ this.b = color1.b + color2.b;
+
+ return this;
+
+ }
+
+ addScalar( s ) {
+
+ this.r += s;
+ this.g += s;
+ this.b += s;
+
+ return this;
+
+ }
+
+ sub( color ) {
+
+ this.r = Math.max( 0, this.r - color.r );
+ this.g = Math.max( 0, this.g - color.g );
+ this.b = Math.max( 0, this.b - color.b );
+
+ return this;
+
+ }
+
+ multiply( color ) {
+
+ this.r *= color.r;
+ this.g *= color.g;
+ this.b *= color.b;
+
+ return this;
+
+ }
+
+ multiplyScalar( s ) {
+
+ this.r *= s;
+ this.g *= s;
+ this.b *= s;
+
+ return this;
+
+ }
+
+ lerp( color, alpha ) {
+
+ this.r += ( color.r - this.r ) * alpha;
+ this.g += ( color.g - this.g ) * alpha;
+ this.b += ( color.b - this.b ) * alpha;
+
+ return this;
+
+ }
+
+ lerpColors( color1, color2, alpha ) {
+
+ this.r = color1.r + ( color2.r - color1.r ) * alpha;
+ this.g = color1.g + ( color2.g - color1.g ) * alpha;
+ this.b = color1.b + ( color2.b - color1.b ) * alpha;
+
+ return this;
+
+ }
+
+ lerpHSL( color, alpha ) {
+
+ this.getHSL( _hslA );
+ color.getHSL( _hslB );
+
+ const h = lerp( _hslA.h, _hslB.h, alpha );
+ const s = lerp( _hslA.s, _hslB.s, alpha );
+ const l = lerp( _hslA.l, _hslB.l, alpha );
+
+ this.setHSL( h, s, l );
+
+ return this;
+
+ }
+
+ equals( c ) {
+
+ return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ this.r = array[ offset ];
+ this.g = array[ offset + 1 ];
+ this.b = array[ offset + 2 ];
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this.r;
+ array[ offset + 1 ] = this.g;
+ array[ offset + 2 ] = this.b;
+
+ return array;
+
+ }
+
+ fromBufferAttribute( attribute, index ) {
+
+ this.r = attribute.getX( index );
+ this.g = attribute.getY( index );
+ this.b = attribute.getZ( index );
+
+ if ( attribute.normalized === true ) {
+
+ // assuming Uint8Array
+
+ this.r /= 255;
+ this.g /= 255;
+ this.b /= 255;
+
+ }
+
+ return this;
+
+ }
+
+ toJSON() {
+
+ return this.getHex();
+
+ }
+
+ *[ Symbol.iterator ]() {
+
+ yield this.r;
+ yield this.g;
+ yield this.b;
+
+ }
+
+}
+
+Color.NAMES = _colorKeywords;
+
+let _canvas;
+
+class ImageUtils {
+
+ static getDataURL( image ) {
+
+ if ( /^data:/i.test( image.src ) ) {
+
+ return image.src;
+
+ }
+
+ if ( typeof HTMLCanvasElement == 'undefined' ) {
+
+ return image.src;
+
+ }
+
+ let canvas;
+
+ if ( image instanceof HTMLCanvasElement ) {
+
+ canvas = image;
+
+ } else {
+
+ if ( _canvas === undefined ) _canvas = createElementNS( 'canvas' );
+
+ _canvas.width = image.width;
+ _canvas.height = image.height;
+
+ const context = _canvas.getContext( '2d' );
+
+ if ( image instanceof ImageData ) {
+
+ context.putImageData( image, 0, 0 );
+
+ } else {
+
+ context.drawImage( image, 0, 0, image.width, image.height );
+
+ }
+
+ canvas = _canvas;
+
+ }
+
+ if ( canvas.width > 2048 || canvas.height > 2048 ) {
+
+ console.warn( 'THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', image );
+
+ return canvas.toDataURL( 'image/jpeg', 0.6 );
+
+ } else {
+
+ return canvas.toDataURL( 'image/png' );
+
+ }
+
+ }
+
+ static sRGBToLinear( image ) {
+
+ if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
+ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
+
+ const canvas = createElementNS( 'canvas' );
+
+ canvas.width = image.width;
+ canvas.height = image.height;
+
+ const context = canvas.getContext( '2d' );
+ context.drawImage( image, 0, 0, image.width, image.height );
+
+ const imageData = context.getImageData( 0, 0, image.width, image.height );
+ const data = imageData.data;
+
+ for ( let i = 0; i < data.length; i ++ ) {
+
+ data[ i ] = SRGBToLinear( data[ i ] / 255 ) * 255;
+
+ }
+
+ context.putImageData( imageData, 0, 0 );
+
+ return canvas;
+
+ } else if ( image.data ) {
+
+ const data = image.data.slice( 0 );
+
+ for ( let i = 0; i < data.length; i ++ ) {
+
+ if ( data instanceof Uint8Array || data instanceof Uint8ClampedArray ) {
+
+ data[ i ] = Math.floor( SRGBToLinear( data[ i ] / 255 ) * 255 );
+
+ } else {
+
+ // assuming float
+
+ data[ i ] = SRGBToLinear( data[ i ] );
+
+ }
+
+ }
+
+ return {
+ data: data,
+ width: image.width,
+ height: image.height
+ };
+
+ } else {
+
+ console.warn( 'THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
+ return image;
+
+ }
+
+ }
+
+}
+
+class Source {
+
+ constructor( data = null ) {
+
+ this.isSource = true;
+
+ this.uuid = generateUUID();
+
+ this.data = data;
+
+ this.version = 0;
+
+ }
+
+ set needsUpdate( value ) {
+
+ if ( value === true ) this.version ++;
+
+ }
+
+ toJSON( meta ) {
+
+ const isRootObject = ( meta === undefined || typeof meta === 'string' );
+
+ if ( ! isRootObject && meta.images[ this.uuid ] !== undefined ) {
+
+ return meta.images[ this.uuid ];
+
+ }
+
+ const output = {
+ uuid: this.uuid,
+ url: ''
+ };
+
+ const data = this.data;
+
+ if ( data !== null ) {
+
+ let url;
+
+ if ( Array.isArray( data ) ) {
+
+ // cube texture
+
+ url = [];
+
+ for ( let i = 0, l = data.length; i < l; i ++ ) {
+
+ if ( data[ i ].isDataTexture ) {
+
+ url.push( serializeImage( data[ i ].image ) );
+
+ } else {
+
+ url.push( serializeImage( data[ i ] ) );
+
+ }
+
+ }
+
+ } else {
+
+ // texture
+
+ url = serializeImage( data );
+
+ }
+
+ output.url = url;
+
+ }
+
+ if ( ! isRootObject ) {
+
+ meta.images[ this.uuid ] = output;
+
+ }
+
+ return output;
+
+ }
+
+}
+
+function serializeImage( image ) {
+
+ if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
+ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
+
+ // default images
+
+ return ImageUtils.getDataURL( image );
+
+ } else {
+
+ if ( image.data ) {
+
+ // images of DataTexture
+
+ return {
+ data: Array.from( image.data ),
+ width: image.width,
+ height: image.height,
+ type: image.data.constructor.name
+ };
+
+ } else {
+
+ console.warn( 'THREE.Texture: Unable to serialize Texture.' );
+ return {};
+
+ }
+
+ }
+
+}
+
+let textureId = 0;
+
+class Texture extends EventDispatcher {
+
+ constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) {
+
+ super();
+
+ this.isTexture = true;
+
+ Object.defineProperty( this, 'id', { value: textureId ++ } );
+
+ this.uuid = generateUUID();
+
+ this.name = '';
+
+ this.source = new Source( image );
+ this.mipmaps = [];
+
+ this.mapping = mapping;
+
+ this.wrapS = wrapS;
+ this.wrapT = wrapT;
+
+ this.magFilter = magFilter;
+ this.minFilter = minFilter;
+
+ this.anisotropy = anisotropy;
+
+ this.format = format;
+ this.internalFormat = null;
+ this.type = type;
+
+ this.offset = new Vector2( 0, 0 );
+ this.repeat = new Vector2( 1, 1 );
+ this.center = new Vector2( 0, 0 );
+ this.rotation = 0;
+
+ this.matrixAutoUpdate = true;
+ this.matrix = new Matrix3();
+
+ this.generateMipmaps = true;
+ this.premultiplyAlpha = false;
+ this.flipY = true;
+ this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
+
+ // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
+ //
+ // Also changing the encoding after already used by a Material will not automatically make the Material
+ // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
+ this.encoding = encoding;
+
+ this.userData = {};
+
+ this.version = 0;
+ this.onUpdate = null;
+
+ this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
+ this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
+
+ }
+
+ get image() {
+
+ return this.source.data;
+
+ }
+
+ set image( value ) {
+
+ this.source.data = value;
+
+ }
+
+ updateMatrix() {
+
+ this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ copy( source ) {
+
+ this.name = source.name;
+
+ this.source = source.source;
+ this.mipmaps = source.mipmaps.slice( 0 );
+
+ this.mapping = source.mapping;
+
+ this.wrapS = source.wrapS;
+ this.wrapT = source.wrapT;
+
+ this.magFilter = source.magFilter;
+ this.minFilter = source.minFilter;
+
+ this.anisotropy = source.anisotropy;
+
+ this.format = source.format;
+ this.internalFormat = source.internalFormat;
+ this.type = source.type;
+
+ this.offset.copy( source.offset );
+ this.repeat.copy( source.repeat );
+ this.center.copy( source.center );
+ this.rotation = source.rotation;
+
+ this.matrixAutoUpdate = source.matrixAutoUpdate;
+ this.matrix.copy( source.matrix );
+
+ this.generateMipmaps = source.generateMipmaps;
+ this.premultiplyAlpha = source.premultiplyAlpha;
+ this.flipY = source.flipY;
+ this.unpackAlignment = source.unpackAlignment;
+ this.encoding = source.encoding;
+
+ this.userData = JSON.parse( JSON.stringify( source.userData ) );
+
+ this.needsUpdate = true;
+
+ return this;
+
+ }
+
+ toJSON( meta ) {
+
+ const isRootObject = ( meta === undefined || typeof meta === 'string' );
+
+ if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
+
+ return meta.textures[ this.uuid ];
+
+ }
+
+ const output = {
+
+ metadata: {
+ version: 4.5,
+ type: 'Texture',
+ generator: 'Texture.toJSON'
+ },
+
+ uuid: this.uuid,
+ name: this.name,
+
+ image: this.source.toJSON( meta ).uuid,
+
+ mapping: this.mapping,
+
+ repeat: [ this.repeat.x, this.repeat.y ],
+ offset: [ this.offset.x, this.offset.y ],
+ center: [ this.center.x, this.center.y ],
+ rotation: this.rotation,
+
+ wrap: [ this.wrapS, this.wrapT ],
+
+ format: this.format,
+ type: this.type,
+ encoding: this.encoding,
+
+ minFilter: this.minFilter,
+ magFilter: this.magFilter,
+ anisotropy: this.anisotropy,
+
+ flipY: this.flipY,
+
+ premultiplyAlpha: this.premultiplyAlpha,
+ unpackAlignment: this.unpackAlignment
+
+ };
+
+ if ( JSON.stringify( this.userData ) !== '{}' ) output.userData = this.userData;
+
+ if ( ! isRootObject ) {
+
+ meta.textures[ this.uuid ] = output;
+
+ }
+
+ return output;
+
+ }
+
+ dispose() {
+
+ this.dispatchEvent( { type: 'dispose' } );
+
+ }
+
+ transformUv( uv ) {
+
+ if ( this.mapping !== UVMapping ) return uv;
+
+ uv.applyMatrix3( this.matrix );
+
+ if ( uv.x < 0 || uv.x > 1 ) {
+
+ switch ( this.wrapS ) {
+
+ case RepeatWrapping:
+
+ uv.x = uv.x - Math.floor( uv.x );
+ break;
+
+ case ClampToEdgeWrapping:
+
+ uv.x = uv.x < 0 ? 0 : 1;
+ break;
+
+ case MirroredRepeatWrapping:
+
+ if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {
+
+ uv.x = Math.ceil( uv.x ) - uv.x;
+
+ } else {
+
+ uv.x = uv.x - Math.floor( uv.x );
+
+ }
+
+ break;
+
+ }
+
+ }
+
+ if ( uv.y < 0 || uv.y > 1 ) {
+
+ switch ( this.wrapT ) {
+
+ case RepeatWrapping:
+
+ uv.y = uv.y - Math.floor( uv.y );
+ break;
+
+ case ClampToEdgeWrapping:
+
+ uv.y = uv.y < 0 ? 0 : 1;
+ break;
+
+ case MirroredRepeatWrapping:
+
+ if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {
+
+ uv.y = Math.ceil( uv.y ) - uv.y;
+
+ } else {
+
+ uv.y = uv.y - Math.floor( uv.y );
+
+ }
+
+ break;
+
+ }
+
+ }
+
+ if ( this.flipY ) {
+
+ uv.y = 1 - uv.y;
+
+ }
+
+ return uv;
+
+ }
+
+ set needsUpdate( value ) {
+
+ if ( value === true ) {
+
+ this.version ++;
+ this.source.needsUpdate = true;
+
+ }
+
+ }
+
+}
+
+Texture.DEFAULT_IMAGE = null;
+Texture.DEFAULT_MAPPING = UVMapping;
+
+class Vector4 {
+
+ constructor( x = 0, y = 0, z = 0, w = 1 ) {
+
+ Vector4.prototype.isVector4 = true;
+
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+
+ }
+
+ get width() {
+
+ return this.z;
+
+ }
+
+ set width( value ) {
+
+ this.z = value;
+
+ }
+
+ get height() {
+
+ return this.w;
+
+ }
+
+ set height( value ) {
+
+ this.w = value;
+
+ }
+
+ set( x, y, z, w ) {
+
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+
+ return this;
+
+ }
+
+ setScalar( scalar ) {
+
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+ this.w = scalar;
+
+ return this;
+
+ }
+
+ setX( x ) {
+
+ this.x = x;
+
+ return this;
+
+ }
+
+ setY( y ) {
+
+ this.y = y;
+
+ return this;
+
+ }
+
+ setZ( z ) {
+
+ this.z = z;
+
+ return this;
+
+ }
+
+ setW( w ) {
+
+ this.w = w;
+
+ return this;
+
+ }
+
+ setComponent( index, value ) {
+
+ switch ( index ) {
+
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ case 3: this.w = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
+
+ }
+
+ return this;
+
+ }
+
+ getComponent( index ) {
+
+ switch ( index ) {
+
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ case 3: return this.w;
+ default: throw new Error( 'index is out of range: ' + index );
+
+ }
+
+ }
+
+ clone() {
+
+ return new this.constructor( this.x, this.y, this.z, this.w );
+
+ }
+
+ copy( v ) {
+
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ this.w = ( v.w !== undefined ) ? v.w : 1;
+
+ return this;
+
+ }
+
+ add( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
+
+ }
+
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ this.w += v.w;
+
+ return this;
+
+ }
+
+ addScalar( s ) {
+
+ this.x += s;
+ this.y += s;
+ this.z += s;
+ this.w += s;
+
+ return this;
+
+ }
+
+ addVectors( a, b ) {
+
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
+ this.w = a.w + b.w;
+
+ return this;
+
+ }
+
+ addScaledVector( v, s ) {
+
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+ this.w += v.w * s;
+
+ return this;
+
+ }
+
+ sub( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
+
+ }
+
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+ this.w -= v.w;
+
+ return this;
+
+ }
+
+ subScalar( s ) {
+
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+ this.w -= s;
+
+ return this;
+
+ }
+
+ subVectors( a, b ) {
+
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
+ this.w = a.w - b.w;
+
+ return this;
+
+ }
+
+ multiply( v ) {
+
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
+ this.w *= v.w;
+
+ return this;
+
+ }
+
+ multiplyScalar( scalar ) {
+
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+ this.w *= scalar;
+
+ return this;
+
+ }
+
+ applyMatrix4( m ) {
+
+ const x = this.x, y = this.y, z = this.z, w = this.w;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;
+ this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;
+
+ return this;
+
+ }
+
+ divideScalar( scalar ) {
+
+ return this.multiplyScalar( 1 / scalar );
+
+ }
+
+ setAxisAngleFromQuaternion( q ) {
+
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
+
+ // q is assumed to be normalized
+
+ this.w = 2 * Math.acos( q.w );
+
+ const s = Math.sqrt( 1 - q.w * q.w );
+
+ if ( s < 0.0001 ) {
+
+ this.x = 1;
+ this.y = 0;
+ this.z = 0;
+
+ } else {
+
+ this.x = q.x / s;
+ this.y = q.y / s;
+ this.z = q.z / s;
+
+ }
+
+ return this;
+
+ }
+
+ setAxisAngleFromRotationMatrix( m ) {
+
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
+
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+
+ let angle, x, y, z; // variables for result
+ const epsilon = 0.01, // margin to allow for rounding errors
+ epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees
+
+ te = m.elements,
+
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
+
+ if ( ( Math.abs( m12 - m21 ) < epsilon ) &&
+ ( Math.abs( m13 - m31 ) < epsilon ) &&
+ ( Math.abs( m23 - m32 ) < epsilon ) ) {
+
+ // singularity found
+ // first check for identity matrix which must have +1 for all terms
+ // in leading diagonal and zero in other terms
+
+ if ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&
+ ( Math.abs( m13 + m31 ) < epsilon2 ) &&
+ ( Math.abs( m23 + m32 ) < epsilon2 ) &&
+ ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {
+
+ // this singularity is identity matrix so angle = 0
+
+ this.set( 1, 0, 0, 0 );
+
+ return this; // zero angle, arbitrary axis
+
+ }
+
+ // otherwise this singularity is angle = 180
+
+ angle = Math.PI;
+
+ const xx = ( m11 + 1 ) / 2;
+ const yy = ( m22 + 1 ) / 2;
+ const zz = ( m33 + 1 ) / 2;
+ const xy = ( m12 + m21 ) / 4;
+ const xz = ( m13 + m31 ) / 4;
+ const yz = ( m23 + m32 ) / 4;
+
+ if ( ( xx > yy ) && ( xx > zz ) ) {
+
+ // m11 is the largest diagonal term
+
+ if ( xx < epsilon ) {
+
+ x = 0;
+ y = 0.707106781;
+ z = 0.707106781;
+
+ } else {
+
+ x = Math.sqrt( xx );
+ y = xy / x;
+ z = xz / x;
+
+ }
+
+ } else if ( yy > zz ) {
+
+ // m22 is the largest diagonal term
+
+ if ( yy < epsilon ) {
+
+ x = 0.707106781;
+ y = 0;
+ z = 0.707106781;
+
+ } else {
+
+ y = Math.sqrt( yy );
+ x = xy / y;
+ z = yz / y;
+
+ }
+
+ } else {
+
+ // m33 is the largest diagonal term so base result on this
+
+ if ( zz < epsilon ) {
+
+ x = 0.707106781;
+ y = 0.707106781;
+ z = 0;
+
+ } else {
+
+ z = Math.sqrt( zz );
+ x = xz / z;
+ y = yz / z;
+
+ }
+
+ }
+
+ this.set( x, y, z, angle );
+
+ return this; // return 180 deg rotation
+
+ }
+
+ // as we have reached here there are no singularities so we can handle normally
+
+ let s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +
+ ( m13 - m31 ) * ( m13 - m31 ) +
+ ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize
+
+ if ( Math.abs( s ) < 0.001 ) s = 1;
+
+ // prevent divide by zero, should not happen if matrix is orthogonal and should be
+ // caught by singularity test above, but I've left it in just in case
+
+ this.x = ( m32 - m23 ) / s;
+ this.y = ( m13 - m31 ) / s;
+ this.z = ( m21 - m12 ) / s;
+ this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );
+
+ return this;
+
+ }
+
+ min( v ) {
+
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
+ this.w = Math.min( this.w, v.w );
+
+ return this;
+
+ }
+
+ max( v ) {
+
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
+ this.w = Math.max( this.w, v.w );
+
+ return this;
+
+ }
+
+ clamp( min, max ) {
+
+ // assumes min < max, componentwise
+
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.z = Math.max( min.z, Math.min( max.z, this.z ) );
+ this.w = Math.max( min.w, Math.min( max.w, this.w ) );
+
+ return this;
+
+ }
+
+ clampScalar( minVal, maxVal ) {
+
+ this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
+ this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
+ this.z = Math.max( minVal, Math.min( maxVal, this.z ) );
+ this.w = Math.max( minVal, Math.min( maxVal, this.w ) );
+
+ return this;
+
+ }
+
+ clampLength( min, max ) {
+
+ const length = this.length();
+
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+
+ }
+
+ floor() {
+
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
+ this.w = Math.floor( this.w );
+
+ return this;
+
+ }
+
+ ceil() {
+
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
+ this.w = Math.ceil( this.w );
+
+ return this;
+
+ }
+
+ round() {
+
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
+ this.w = Math.round( this.w );
+
+ return this;
+
+ }
+
+ roundToZero() {
+
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+ this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
+
+ return this;
+
+ }
+
+ negate() {
+
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
+ this.w = - this.w;
+
+ return this;
+
+ }
+
+ dot( v ) {
+
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
+
+ }
+
+ lengthSq() {
+
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+
+ }
+
+ length() {
+
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
+
+ }
+
+ manhattanLength() {
+
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
+
+ }
+
+ normalize() {
+
+ return this.divideScalar( this.length() || 1 );
+
+ }
+
+ setLength( length ) {
+
+ return this.normalize().multiplyScalar( length );
+
+ }
+
+ lerp( v, alpha ) {
+
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
+ this.w += ( v.w - this.w ) * alpha;
+
+ return this;
+
+ }
+
+ lerpVectors( v1, v2, alpha ) {
+
+ this.x = v1.x + ( v2.x - v1.x ) * alpha;
+ this.y = v1.y + ( v2.y - v1.y ) * alpha;
+ this.z = v1.z + ( v2.z - v1.z ) * alpha;
+ this.w = v1.w + ( v2.w - v1.w ) * alpha;
+
+ return this;
+
+ }
+
+ equals( v ) {
+
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
+ this.w = array[ offset + 3 ];
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
+ array[ offset + 3 ] = this.w;
+
+ return array;
+
+ }
+
+ fromBufferAttribute( attribute, index, offset ) {
+
+ if ( offset !== undefined ) {
+
+ console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );
+
+ }
+
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
+ this.w = attribute.getW( index );
+
+ return this;
+
+ }
+
+ random() {
+
+ this.x = Math.random();
+ this.y = Math.random();
+ this.z = Math.random();
+ this.w = Math.random();
+
+ return this;
+
+ }
+
+ *[ Symbol.iterator ]() {
+
+ yield this.x;
+ yield this.y;
+ yield this.z;
+ yield this.w;
+
+ }
+
+}
+
+/*
+ In options, we can specify:
+ * Texture parameters for an auto-generated target texture
+ * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
+*/
+class WebGLRenderTarget extends EventDispatcher {
+
+ constructor( width, height, options = {} ) {
+
+ super();
+
+ this.isWebGLRenderTarget = true;
+
+ this.width = width;
+ this.height = height;
+ this.depth = 1;
+
+ this.scissor = new Vector4( 0, 0, width, height );
+ this.scissorTest = false;
+
+ this.viewport = new Vector4( 0, 0, width, height );
+
+ const image = { width: width, height: height, depth: 1 };
+
+ this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+ this.texture.isRenderTargetTexture = true;
+
+ this.texture.flipY = false;
+ this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
+ this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
+ this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
+
+ this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
+ this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
+
+ this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
+
+ this.samples = options.samples !== undefined ? options.samples : 0;
+
+ }
+
+ setSize( width, height, depth = 1 ) {
+
+ if ( this.width !== width || this.height !== height || this.depth !== depth ) {
+
+ this.width = width;
+ this.height = height;
+ this.depth = depth;
+
+ this.texture.image.width = width;
+ this.texture.image.height = height;
+ this.texture.image.depth = depth;
+
+ this.dispose();
+
+ }
+
+ this.viewport.set( 0, 0, width, height );
+ this.scissor.set( 0, 0, width, height );
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ copy( source ) {
+
+ this.width = source.width;
+ this.height = source.height;
+ this.depth = source.depth;
+
+ this.viewport.copy( source.viewport );
+
+ this.texture = source.texture.clone();
+ this.texture.isRenderTargetTexture = true;
+
+ // ensure image object is not shared, see #20328
+
+ const image = Object.assign( {}, source.texture.image );
+ this.texture.source = new Source( image );
+
+ this.depthBuffer = source.depthBuffer;
+ this.stencilBuffer = source.stencilBuffer;
+
+ if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
+
+ this.samples = source.samples;
+
+ return this;
+
+ }
+
+ dispose() {
+
+ this.dispatchEvent( { type: 'dispose' } );
+
+ }
+
+}
+
+class DataArrayTexture extends Texture {
+
+ constructor( data = null, width = 1, height = 1, depth = 1 ) {
+
+ super( null );
+
+ this.isDataArrayTexture = true;
+
+ this.image = { data, width, height, depth };
+
+ this.magFilter = NearestFilter;
+ this.minFilter = NearestFilter;
+
+ this.wrapR = ClampToEdgeWrapping;
+
+ this.generateMipmaps = false;
+ this.flipY = false;
+ this.unpackAlignment = 1;
+
+ }
+
+}
+
+class WebGLArrayRenderTarget extends WebGLRenderTarget {
+
+ constructor( width, height, depth ) {
+
+ super( width, height );
+
+ this.isWebGLArrayRenderTarget = true;
+
+ this.depth = depth;
+
+ this.texture = new DataArrayTexture( null, width, height, depth );
+
+ this.texture.isRenderTargetTexture = true;
+
+ }
+
+}
+
+class Data3DTexture extends Texture {
+
+ constructor( data = null, width = 1, height = 1, depth = 1 ) {
+
+ // We're going to add .setXXX() methods for setting properties later.
+ // Users can still set in DataTexture3D directly.
+ //
+ // const texture = new THREE.DataTexture3D( data, width, height, depth );
+ // texture.anisotropy = 16;
+ //
+ // See #14839
+
+ super( null );
+
+ this.isData3DTexture = true;
+
+ this.image = { data, width, height, depth };
+
+ this.magFilter = NearestFilter;
+ this.minFilter = NearestFilter;
+
+ this.wrapR = ClampToEdgeWrapping;
+
+ this.generateMipmaps = false;
+ this.flipY = false;
+ this.unpackAlignment = 1;
+
+ }
+
+}
+
+class WebGL3DRenderTarget extends WebGLRenderTarget {
+
+ constructor( width, height, depth ) {
+
+ super( width, height );
+
+ this.isWebGL3DRenderTarget = true;
+
+ this.depth = depth;
+
+ this.texture = new Data3DTexture( null, width, height, depth );
+
+ this.texture.isRenderTargetTexture = true;
+
+ }
+
+}
+
+class WebGLMultipleRenderTargets extends WebGLRenderTarget {
+
+ constructor( width, height, count, options = {} ) {
+
+ super( width, height, options );
+
+ this.isWebGLMultipleRenderTargets = true;
+
+ const texture = this.texture;
+
+ this.texture = [];
+
+ for ( let i = 0; i < count; i ++ ) {
+
+ this.texture[ i ] = texture.clone();
+ this.texture[ i ].isRenderTargetTexture = true;
+
+ }
+
+ }
+
+ setSize( width, height, depth = 1 ) {
+
+ if ( this.width !== width || this.height !== height || this.depth !== depth ) {
+
+ this.width = width;
+ this.height = height;
+ this.depth = depth;
+
+ for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
+
+ this.texture[ i ].image.width = width;
+ this.texture[ i ].image.height = height;
+ this.texture[ i ].image.depth = depth;
+
+ }
+
+ this.dispose();
+
+ }
+
+ this.viewport.set( 0, 0, width, height );
+ this.scissor.set( 0, 0, width, height );
+
+ return this;
+
+ }
+
+ copy( source ) {
+
+ this.dispose();
+
+ this.width = source.width;
+ this.height = source.height;
+ this.depth = source.depth;
+
+ this.viewport.set( 0, 0, this.width, this.height );
+ this.scissor.set( 0, 0, this.width, this.height );
+
+ this.depthBuffer = source.depthBuffer;
+ this.stencilBuffer = source.stencilBuffer;
+
+ if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
+
+ this.texture.length = 0;
+
+ for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
+
+ this.texture[ i ] = source.texture[ i ].clone();
+ this.texture[ i ].isRenderTargetTexture = true;
+
+ }
+
+ return this;
+
+ }
+
+}
+
+class Quaternion {
+
+ constructor( x = 0, y = 0, z = 0, w = 1 ) {
+
+ this.isQuaternion = true;
+
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
+
+ }
+
+ static slerp( qa, qb, qm, t ) {
+
+ console.warn( 'THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead.' );
+ return qm.slerpQuaternions( qa, qb, t );
+
+ }
+
+ static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
+
+ // fuzz-free, array-based Quaternion SLERP operation
+
+ let x0 = src0[ srcOffset0 + 0 ],
+ y0 = src0[ srcOffset0 + 1 ],
+ z0 = src0[ srcOffset0 + 2 ],
+ w0 = src0[ srcOffset0 + 3 ];
+
+ const x1 = src1[ srcOffset1 + 0 ],
+ y1 = src1[ srcOffset1 + 1 ],
+ z1 = src1[ srcOffset1 + 2 ],
+ w1 = src1[ srcOffset1 + 3 ];
+
+ if ( t === 0 ) {
+
+ dst[ dstOffset + 0 ] = x0;
+ dst[ dstOffset + 1 ] = y0;
+ dst[ dstOffset + 2 ] = z0;
+ dst[ dstOffset + 3 ] = w0;
+ return;
+
+ }
+
+ if ( t === 1 ) {
+
+ dst[ dstOffset + 0 ] = x1;
+ dst[ dstOffset + 1 ] = y1;
+ dst[ dstOffset + 2 ] = z1;
+ dst[ dstOffset + 3 ] = w1;
+ return;
+
+ }
+
+ if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
+
+ let s = 1 - t;
+ const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
+ dir = ( cos >= 0 ? 1 : - 1 ),
+ sqrSin = 1 - cos * cos;
+
+ // Skip the Slerp for tiny steps to avoid numeric problems:
+ if ( sqrSin > Number.EPSILON ) {
+
+ const sin = Math.sqrt( sqrSin ),
+ len = Math.atan2( sin, cos * dir );
+
+ s = Math.sin( s * len ) / sin;
+ t = Math.sin( t * len ) / sin;
+
+ }
+
+ const tDir = t * dir;
+
+ x0 = x0 * s + x1 * tDir;
+ y0 = y0 * s + y1 * tDir;
+ z0 = z0 * s + z1 * tDir;
+ w0 = w0 * s + w1 * tDir;
+
+ // Normalize in case we just did a lerp:
+ if ( s === 1 - t ) {
+
+ const f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
+
+ x0 *= f;
+ y0 *= f;
+ z0 *= f;
+ w0 *= f;
+
+ }
+
+ }
+
+ dst[ dstOffset ] = x0;
+ dst[ dstOffset + 1 ] = y0;
+ dst[ dstOffset + 2 ] = z0;
+ dst[ dstOffset + 3 ] = w0;
+
+ }
+
+ static multiplyQuaternionsFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {
+
+ const x0 = src0[ srcOffset0 ];
+ const y0 = src0[ srcOffset0 + 1 ];
+ const z0 = src0[ srcOffset0 + 2 ];
+ const w0 = src0[ srcOffset0 + 3 ];
+
+ const x1 = src1[ srcOffset1 ];
+ const y1 = src1[ srcOffset1 + 1 ];
+ const z1 = src1[ srcOffset1 + 2 ];
+ const w1 = src1[ srcOffset1 + 3 ];
+
+ dst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
+ dst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
+ dst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
+ dst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
+
+ return dst;
+
+ }
+
+ get x() {
+
+ return this._x;
+
+ }
+
+ set x( value ) {
+
+ this._x = value;
+ this._onChangeCallback();
+
+ }
+
+ get y() {
+
+ return this._y;
+
+ }
+
+ set y( value ) {
+
+ this._y = value;
+ this._onChangeCallback();
+
+ }
+
+ get z() {
+
+ return this._z;
+
+ }
+
+ set z( value ) {
+
+ this._z = value;
+ this._onChangeCallback();
+
+ }
+
+ get w() {
+
+ return this._w;
+
+ }
+
+ set w( value ) {
+
+ this._w = value;
+ this._onChangeCallback();
+
+ }
+
+ set( x, y, z, w ) {
+
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ clone() {
+
+ return new this.constructor( this._x, this._y, this._z, this._w );
+
+ }
+
+ copy( quaternion ) {
+
+ this._x = quaternion.x;
+ this._y = quaternion.y;
+ this._z = quaternion.z;
+ this._w = quaternion.w;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ setFromEuler( euler, update ) {
+
+ if ( ! ( euler && euler.isEuler ) ) {
+
+ throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+
+ }
+
+ const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
+
+ // http://www.mathworks.com/matlabcentral/fileexchange/
+ // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
+ // content/SpinCalc.m
+
+ const cos = Math.cos;
+ const sin = Math.sin;
+
+ const c1 = cos( x / 2 );
+ const c2 = cos( y / 2 );
+ const c3 = cos( z / 2 );
+
+ const s1 = sin( x / 2 );
+ const s2 = sin( y / 2 );
+ const s3 = sin( z / 2 );
+
+ switch ( order ) {
+
+ case 'XYZ':
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+
+ case 'YXZ':
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+
+ case 'ZXY':
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+
+ case 'ZYX':
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+
+ case 'YZX':
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ break;
+
+ case 'XZY':
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ break;
+
+ default:
+ console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );
+
+ }
+
+ if ( update !== false ) this._onChangeCallback();
+
+ return this;
+
+ }
+
+ setFromAxisAngle( axis, angle ) {
+
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
+
+ // assumes axis is normalized
+
+ const halfAngle = angle / 2, s = Math.sin( halfAngle );
+
+ this._x = axis.x * s;
+ this._y = axis.y * s;
+ this._z = axis.z * s;
+ this._w = Math.cos( halfAngle );
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ setFromRotationMatrix( m ) {
+
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
+
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+
+ const te = m.elements,
+
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],
+
+ trace = m11 + m22 + m33;
+
+ if ( trace > 0 ) {
+
+ const s = 0.5 / Math.sqrt( trace + 1.0 );
+
+ this._w = 0.25 / s;
+ this._x = ( m32 - m23 ) * s;
+ this._y = ( m13 - m31 ) * s;
+ this._z = ( m21 - m12 ) * s;
+
+ } else if ( m11 > m22 && m11 > m33 ) {
+
+ const s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
+
+ this._w = ( m32 - m23 ) / s;
+ this._x = 0.25 * s;
+ this._y = ( m12 + m21 ) / s;
+ this._z = ( m13 + m31 ) / s;
+
+ } else if ( m22 > m33 ) {
+
+ const s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
+
+ this._w = ( m13 - m31 ) / s;
+ this._x = ( m12 + m21 ) / s;
+ this._y = 0.25 * s;
+ this._z = ( m23 + m32 ) / s;
+
+ } else {
+
+ const s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
+
+ this._w = ( m21 - m12 ) / s;
+ this._x = ( m13 + m31 ) / s;
+ this._y = ( m23 + m32 ) / s;
+ this._z = 0.25 * s;
+
+ }
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ setFromUnitVectors( vFrom, vTo ) {
+
+ // assumes direction vectors vFrom and vTo are normalized
+
+ let r = vFrom.dot( vTo ) + 1;
+
+ if ( r < Number.EPSILON ) {
+
+ // vFrom and vTo point in opposite directions
+
+ r = 0;
+
+ if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
+
+ this._x = - vFrom.y;
+ this._y = vFrom.x;
+ this._z = 0;
+ this._w = r;
+
+ } else {
+
+ this._x = 0;
+ this._y = - vFrom.z;
+ this._z = vFrom.y;
+ this._w = r;
+
+ }
+
+ } else {
+
+ // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
+
+ this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
+ this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
+ this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
+ this._w = r;
+
+ }
+
+ return this.normalize();
+
+ }
+
+ angleTo( q ) {
+
+ return 2 * Math.acos( Math.abs( clamp( this.dot( q ), - 1, 1 ) ) );
+
+ }
+
+ rotateTowards( q, step ) {
+
+ const angle = this.angleTo( q );
+
+ if ( angle === 0 ) return this;
+
+ const t = Math.min( 1, step / angle );
+
+ this.slerp( q, t );
+
+ return this;
+
+ }
+
+ identity() {
+
+ return this.set( 0, 0, 0, 1 );
+
+ }
+
+ invert() {
+
+ // quaternion is assumed to have unit length
+
+ return this.conjugate();
+
+ }
+
+ conjugate() {
+
+ this._x *= - 1;
+ this._y *= - 1;
+ this._z *= - 1;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ dot( v ) {
+
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
+
+ }
+
+ lengthSq() {
+
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
+
+ }
+
+ length() {
+
+ return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
+
+ }
+
+ normalize() {
+
+ let l = this.length();
+
+ if ( l === 0 ) {
+
+ this._x = 0;
+ this._y = 0;
+ this._z = 0;
+ this._w = 1;
+
+ } else {
+
+ l = 1 / l;
+
+ this._x = this._x * l;
+ this._y = this._y * l;
+ this._z = this._z * l;
+ this._w = this._w * l;
+
+ }
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ multiply( q, p ) {
+
+ if ( p !== undefined ) {
+
+ console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );
+ return this.multiplyQuaternions( q, p );
+
+ }
+
+ return this.multiplyQuaternions( this, q );
+
+ }
+
+ premultiply( q ) {
+
+ return this.multiplyQuaternions( q, this );
+
+ }
+
+ multiplyQuaternions( a, b ) {
+
+ // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
+
+ const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
+ const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
+
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ slerp( qb, t ) {
+
+ if ( t === 0 ) return this;
+ if ( t === 1 ) return this.copy( qb );
+
+ const x = this._x, y = this._y, z = this._z, w = this._w;
+
+ // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
+
+ let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
+
+ if ( cosHalfTheta < 0 ) {
+
+ this._w = - qb._w;
+ this._x = - qb._x;
+ this._y = - qb._y;
+ this._z = - qb._z;
+
+ cosHalfTheta = - cosHalfTheta;
+
+ } else {
+
+ this.copy( qb );
+
+ }
+
+ if ( cosHalfTheta >= 1.0 ) {
+
+ this._w = w;
+ this._x = x;
+ this._y = y;
+ this._z = z;
+
+ return this;
+
+ }
+
+ const sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
+
+ if ( sqrSinHalfTheta <= Number.EPSILON ) {
+
+ const s = 1 - t;
+ this._w = s * w + t * this._w;
+ this._x = s * x + t * this._x;
+ this._y = s * y + t * this._y;
+ this._z = s * z + t * this._z;
+
+ this.normalize();
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ const sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
+ const halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
+ const ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
+ ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
+
+ this._w = ( w * ratioA + this._w * ratioB );
+ this._x = ( x * ratioA + this._x * ratioB );
+ this._y = ( y * ratioA + this._y * ratioB );
+ this._z = ( z * ratioA + this._z * ratioB );
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ slerpQuaternions( qa, qb, t ) {
+
+ return this.copy( qa ).slerp( qb, t );
+
+ }
+
+ random() {
+
+ // Derived from http://planning.cs.uiuc.edu/node198.html
+ // Note, this source uses w, x, y, z ordering,
+ // so we swap the order below.
+
+ const u1 = Math.random();
+ const sqrt1u1 = Math.sqrt( 1 - u1 );
+ const sqrtu1 = Math.sqrt( u1 );
+
+ const u2 = 2 * Math.PI * Math.random();
+
+ const u3 = 2 * Math.PI * Math.random();
+
+ return this.set(
+ sqrt1u1 * Math.cos( u2 ),
+ sqrtu1 * Math.sin( u3 ),
+ sqrtu1 * Math.cos( u3 ),
+ sqrt1u1 * Math.sin( u2 ),
+ );
+
+ }
+
+ equals( quaternion ) {
+
+ return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ this._x = array[ offset ];
+ this._y = array[ offset + 1 ];
+ this._z = array[ offset + 2 ];
+ this._w = array[ offset + 3 ];
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this._x;
+ array[ offset + 1 ] = this._y;
+ array[ offset + 2 ] = this._z;
+ array[ offset + 3 ] = this._w;
+
+ return array;
+
+ }
+
+ fromBufferAttribute( attribute, index ) {
+
+ this._x = attribute.getX( index );
+ this._y = attribute.getY( index );
+ this._z = attribute.getZ( index );
+ this._w = attribute.getW( index );
+
+ return this;
+
+ }
+
+ _onChange( callback ) {
+
+ this._onChangeCallback = callback;
+
+ return this;
+
+ }
+
+ _onChangeCallback() {}
+
+ *[ Symbol.iterator ]() {
+
+ yield this._x;
+ yield this._y;
+ yield this._z;
+ yield this._w;
+
+ }
+
+}
+
+class Vector3 {
+
+ constructor( x = 0, y = 0, z = 0 ) {
+
+ Vector3.prototype.isVector3 = true;
+
+ this.x = x;
+ this.y = y;
+ this.z = z;
+
+ }
+
+ set( x, y, z ) {
+
+ if ( z === undefined ) z = this.z; // sprite.scale.set(x,y)
+
+ this.x = x;
+ this.y = y;
+ this.z = z;
+
+ return this;
+
+ }
+
+ setScalar( scalar ) {
+
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+
+ return this;
+
+ }
+
+ setX( x ) {
+
+ this.x = x;
+
+ return this;
+
+ }
+
+ setY( y ) {
+
+ this.y = y;
+
+ return this;
+
+ }
+
+ setZ( z ) {
+
+ this.z = z;
+
+ return this;
+
+ }
+
+ setComponent( index, value ) {
+
+ switch ( index ) {
+
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
+
+ }
+
+ return this;
+
+ }
+
+ getComponent( index ) {
+
+ switch ( index ) {
+
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ default: throw new Error( 'index is out of range: ' + index );
+
+ }
+
+ }
+
+ clone() {
+
+ return new this.constructor( this.x, this.y, this.z );
+
+ }
+
+ copy( v ) {
+
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+
+ return this;
+
+ }
+
+ add( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
+
+ }
+
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+
+ return this;
+
+ }
+
+ addScalar( s ) {
+
+ this.x += s;
+ this.y += s;
+ this.z += s;
+
+ return this;
+
+ }
+
+ addVectors( a, b ) {
+
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
+
+ return this;
+
+ }
+
+ addScaledVector( v, s ) {
+
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+
+ return this;
+
+ }
+
+ sub( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
+
+ }
+
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+
+ return this;
+
+ }
+
+ subScalar( s ) {
+
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+
+ return this;
+
+ }
+
+ subVectors( a, b ) {
+
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
+
+ return this;
+
+ }
+
+ multiply( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );
+ return this.multiplyVectors( v, w );
+
+ }
+
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
+
+ return this;
+
+ }
+
+ multiplyScalar( scalar ) {
+
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+
+ return this;
+
+ }
+
+ multiplyVectors( a, b ) {
+
+ this.x = a.x * b.x;
+ this.y = a.y * b.y;
+ this.z = a.z * b.z;
+
+ return this;
+
+ }
+
+ applyEuler( euler ) {
+
+ if ( ! ( euler && euler.isEuler ) ) {
+
+ console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+
+ }
+
+ return this.applyQuaternion( _quaternion$4.setFromEuler( euler ) );
+
+ }
+
+ applyAxisAngle( axis, angle ) {
+
+ return this.applyQuaternion( _quaternion$4.setFromAxisAngle( axis, angle ) );
+
+ }
+
+ applyMatrix3( m ) {
+
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
+ this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
+
+ return this;
+
+ }
+
+ applyNormalMatrix( m ) {
+
+ return this.applyMatrix3( m ).normalize();
+
+ }
+
+ applyMatrix4( m ) {
+
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+
+ const w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
+
+ this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
+ this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
+ this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
+
+ return this;
+
+ }
+
+ applyQuaternion( q ) {
+
+ const x = this.x, y = this.y, z = this.z;
+ const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
+
+ // calculate quat * vector
+
+ const ix = qw * x + qy * z - qz * y;
+ const iy = qw * y + qz * x - qx * z;
+ const iz = qw * z + qx * y - qy * x;
+ const iw = - qx * x - qy * y - qz * z;
+
+ // calculate result * inverse quat
+
+ this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
+ this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
+ this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
+
+ return this;
+
+ }
+
+ project( camera ) {
+
+ return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
+
+ }
+
+ unproject( camera ) {
+
+ return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
+
+ }
+
+ transformDirection( m ) {
+
+ // input: THREE.Matrix4 affine matrix
+ // vector interpreted as a direction
+
+ const x = this.x, y = this.y, z = this.z;
+ const e = m.elements;
+
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;
+
+ return this.normalize();
+
+ }
+
+ divide( v ) {
+
+ this.x /= v.x;
+ this.y /= v.y;
+ this.z /= v.z;
+
+ return this;
+
+ }
+
+ divideScalar( scalar ) {
+
+ return this.multiplyScalar( 1 / scalar );
+
+ }
+
+ min( v ) {
+
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
+
+ return this;
+
+ }
+
+ max( v ) {
+
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
+
+ return this;
+
+ }
+
+ clamp( min, max ) {
+
+ // assumes min < max, componentwise
+
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.z = Math.max( min.z, Math.min( max.z, this.z ) );
+
+ return this;
+
+ }
+
+ clampScalar( minVal, maxVal ) {
+
+ this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
+ this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
+ this.z = Math.max( minVal, Math.min( maxVal, this.z ) );
+
+ return this;
+
+ }
+
+ clampLength( min, max ) {
+
+ const length = this.length();
+
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+
+ }
+
+ floor() {
+
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
+
+ return this;
+
+ }
+
+ ceil() {
+
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
+
+ return this;
+
+ }
+
+ round() {
+
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
+
+ return this;
+
+ }
+
+ roundToZero() {
+
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+
+ return this;
+
+ }
+
+ negate() {
+
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
+
+ return this;
+
+ }
+
+ dot( v ) {
+
+ return this.x * v.x + this.y * v.y + this.z * v.z;
+
+ }
+
+ // TODO lengthSquared?
+
+ lengthSq() {
+
+ return this.x * this.x + this.y * this.y + this.z * this.z;
+
+ }
+
+ length() {
+
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+
+ }
+
+ manhattanLength() {
+
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
+
+ }
+
+ normalize() {
+
+ return this.divideScalar( this.length() || 1 );
+
+ }
+
+ setLength( length ) {
+
+ return this.normalize().multiplyScalar( length );
+
+ }
+
+ lerp( v, alpha ) {
+
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
+
+ return this;
+
+ }
+
+ lerpVectors( v1, v2, alpha ) {
+
+ this.x = v1.x + ( v2.x - v1.x ) * alpha;
+ this.y = v1.y + ( v2.y - v1.y ) * alpha;
+ this.z = v1.z + ( v2.z - v1.z ) * alpha;
+
+ return this;
+
+ }
+
+ cross( v, w ) {
+
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );
+ return this.crossVectors( v, w );
+
+ }
+
+ return this.crossVectors( this, v );
+
+ }
+
+ crossVectors( a, b ) {
+
+ const ax = a.x, ay = a.y, az = a.z;
+ const bx = b.x, by = b.y, bz = b.z;
+
+ this.x = ay * bz - az * by;
+ this.y = az * bx - ax * bz;
+ this.z = ax * by - ay * bx;
+
+ return this;
+
+ }
+
+ projectOnVector( v ) {
+
+ const denominator = v.lengthSq();
+
+ if ( denominator === 0 ) return this.set( 0, 0, 0 );
+
+ const scalar = v.dot( this ) / denominator;
+
+ return this.copy( v ).multiplyScalar( scalar );
+
+ }
+
+ projectOnPlane( planeNormal ) {
+
+ _vector$c.copy( this ).projectOnVector( planeNormal );
+
+ return this.sub( _vector$c );
+
+ }
+
+ reflect( normal ) {
+
+ // reflect incident vector off plane orthogonal to normal
+ // normal is assumed to have unit length
+
+ return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
+
+ }
+
+ angleTo( v ) {
+
+ const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
+
+ if ( denominator === 0 ) return Math.PI / 2;
+
+ const theta = this.dot( v ) / denominator;
+
+ // clamp, to handle numerical problems
+
+ return Math.acos( clamp( theta, - 1, 1 ) );
+
+ }
+
+ distanceTo( v ) {
+
+ return Math.sqrt( this.distanceToSquared( v ) );
+
+ }
+
+ distanceToSquared( v ) {
+
+ const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+
+ return dx * dx + dy * dy + dz * dz;
+
+ }
+
+ manhattanDistanceTo( v ) {
+
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
+
+ }
+
+ setFromSpherical( s ) {
+
+ return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
+
+ }
+
+ setFromSphericalCoords( radius, phi, theta ) {
+
+ const sinPhiRadius = Math.sin( phi ) * radius;
+
+ this.x = sinPhiRadius * Math.sin( theta );
+ this.y = Math.cos( phi ) * radius;
+ this.z = sinPhiRadius * Math.cos( theta );
+
+ return this;
+
+ }
+
+ setFromCylindrical( c ) {
+
+ return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
+
+ }
+
+ setFromCylindricalCoords( radius, theta, y ) {
+
+ this.x = radius * Math.sin( theta );
+ this.y = y;
+ this.z = radius * Math.cos( theta );
+
+ return this;
+
+ }
+
+ setFromMatrixPosition( m ) {
+
+ const e = m.elements;
+
+ this.x = e[ 12 ];
+ this.y = e[ 13 ];
+ this.z = e[ 14 ];
+
+ return this;
+
+ }
+
+ setFromMatrixScale( m ) {
+
+ const sx = this.setFromMatrixColumn( m, 0 ).length();
+ const sy = this.setFromMatrixColumn( m, 1 ).length();
+ const sz = this.setFromMatrixColumn( m, 2 ).length();
+
+ this.x = sx;
+ this.y = sy;
+ this.z = sz;
+
+ return this;
+
+ }
+
+ setFromMatrixColumn( m, index ) {
+
+ return this.fromArray( m.elements, index * 4 );
+
+ }
+
+ setFromMatrix3Column( m, index ) {
+
+ return this.fromArray( m.elements, index * 3 );
+
+ }
+
+ setFromEuler( e ) {
+
+ this.x = e._x;
+ this.y = e._y;
+ this.z = e._z;
+
+ return this;
+
+ }
+
+ equals( v ) {
+
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
+
+ return array;
+
+ }
+
+ fromBufferAttribute( attribute, index, offset ) {
+
+ if ( offset !== undefined ) {
+
+ console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );
+
+ }
+
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
+
+ return this;
+
+ }
+
+ random() {
+
+ this.x = Math.random();
+ this.y = Math.random();
+ this.z = Math.random();
+
+ return this;
+
+ }
+
+ randomDirection() {
+
+ // Derived from https://mathworld.wolfram.com/SpherePointPicking.html
+
+ const u = ( Math.random() - 0.5 ) * 2;
+ const t = Math.random() * Math.PI * 2;
+ const f = Math.sqrt( 1 - u ** 2 );
+
+ this.x = f * Math.cos( t );
+ this.y = f * Math.sin( t );
+ this.z = u;
+
+ return this;
+
+ }
+
+ *[ Symbol.iterator ]() {
+
+ yield this.x;
+ yield this.y;
+ yield this.z;
+
+ }
+
+}
+
+const _vector$c = /*@__PURE__*/ new Vector3();
+const _quaternion$4 = /*@__PURE__*/ new Quaternion();
+
+class Box3 {
+
+ constructor( min = new Vector3( + Infinity, + Infinity, + Infinity ), max = new Vector3( - Infinity, - Infinity, - Infinity ) ) {
+
+ this.isBox3 = true;
+
+ this.min = min;
+ this.max = max;
+
+ }
+
+ set( min, max ) {
+
+ this.min.copy( min );
+ this.max.copy( max );
+
+ return this;
+
+ }
+
+ setFromArray( array ) {
+
+ let minX = + Infinity;
+ let minY = + Infinity;
+ let minZ = + Infinity;
+
+ let maxX = - Infinity;
+ let maxY = - Infinity;
+ let maxZ = - Infinity;
+
+ for ( let i = 0, l = array.length; i < l; i += 3 ) {
+
+ const x = array[ i ];
+ const y = array[ i + 1 ];
+ const z = array[ i + 2 ];
+
+ if ( x < minX ) minX = x;
+ if ( y < minY ) minY = y;
+ if ( z < minZ ) minZ = z;
+
+ if ( x > maxX ) maxX = x;
+ if ( y > maxY ) maxY = y;
+ if ( z > maxZ ) maxZ = z;
+
+ }
+
+ this.min.set( minX, minY, minZ );
+ this.max.set( maxX, maxY, maxZ );
+
+ return this;
+
+ }
+
+ setFromBufferAttribute( attribute ) {
+
+ let minX = + Infinity;
+ let minY = + Infinity;
+ let minZ = + Infinity;
+
+ let maxX = - Infinity;
+ let maxY = - Infinity;
+ let maxZ = - Infinity;
+
+ for ( let i = 0, l = attribute.count; i < l; i ++ ) {
+
+ const x = attribute.getX( i );
+ const y = attribute.getY( i );
+ const z = attribute.getZ( i );
+
+ if ( x < minX ) minX = x;
+ if ( y < minY ) minY = y;
+ if ( z < minZ ) minZ = z;
+
+ if ( x > maxX ) maxX = x;
+ if ( y > maxY ) maxY = y;
+ if ( z > maxZ ) maxZ = z;
+
+ }
+
+ this.min.set( minX, minY, minZ );
+ this.max.set( maxX, maxY, maxZ );
+
+ return this;
+
+ }
+
+ setFromPoints( points ) {
+
+ this.makeEmpty();
+
+ for ( let i = 0, il = points.length; i < il; i ++ ) {
+
+ this.expandByPoint( points[ i ] );
+
+ }
+
+ return this;
+
+ }
+
+ setFromCenterAndSize( center, size ) {
+
+ const halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 );
+
+ this.min.copy( center ).sub( halfSize );
+ this.max.copy( center ).add( halfSize );
+
+ return this;
+
+ }
+
+ setFromObject( object, precise = false ) {
+
+ this.makeEmpty();
+
+ return this.expandByObject( object, precise );
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ copy( box ) {
+
+ this.min.copy( box.min );
+ this.max.copy( box.max );
+
+ return this;
+
+ }
+
+ makeEmpty() {
+
+ this.min.x = this.min.y = this.min.z = + Infinity;
+ this.max.x = this.max.y = this.max.z = - Infinity;
+
+ return this;
+
+ }
+
+ isEmpty() {
+
+ // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
+
+ return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );
+
+ }
+
+ getCenter( target ) {
+
+ return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
+
+ }
+
+ getSize( target ) {
+
+ return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
+
+ }
+
+ expandByPoint( point ) {
+
+ this.min.min( point );
+ this.max.max( point );
+
+ return this;
+
+ }
+
+ expandByVector( vector ) {
+
+ this.min.sub( vector );
+ this.max.add( vector );
+
+ return this;
+
+ }
+
+ expandByScalar( scalar ) {
+
+ this.min.addScalar( - scalar );
+ this.max.addScalar( scalar );
+
+ return this;
+
+ }
+
+ expandByObject( object, precise = false ) {
+
+ // Computes the world-axis-aligned bounding box of an object (including its children),
+ // accounting for both the object's, and children's, world transforms
+
+ object.updateWorldMatrix( false, false );
+
+ const geometry = object.geometry;
+
+ if ( geometry !== undefined ) {
+
+ if ( precise && geometry.attributes != undefined && geometry.attributes.position !== undefined ) {
+
+ const position = geometry.attributes.position;
+ for ( let i = 0, l = position.count; i < l; i ++ ) {
+
+ _vector$b.fromBufferAttribute( position, i ).applyMatrix4( object.matrixWorld );
+ this.expandByPoint( _vector$b );
+
+ }
+
+ } else {
+
+ if ( geometry.boundingBox === null ) {
+
+ geometry.computeBoundingBox();
+
+ }
+
+ _box$3.copy( geometry.boundingBox );
+ _box$3.applyMatrix4( object.matrixWorld );
+
+ this.union( _box$3 );
+
+ }
+
+ }
+
+ const children = object.children;
+
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+ this.expandByObject( children[ i ], precise );
+
+ }
+
+ return this;
+
+ }
+
+ containsPoint( point ) {
+
+ return point.x < this.min.x || point.x > this.max.x ||
+ point.y < this.min.y || point.y > this.max.y ||
+ point.z < this.min.z || point.z > this.max.z ? false : true;
+
+ }
+
+ containsBox( box ) {
+
+ return this.min.x <= box.min.x && box.max.x <= this.max.x &&
+ this.min.y <= box.min.y && box.max.y <= this.max.y &&
+ this.min.z <= box.min.z && box.max.z <= this.max.z;
+
+ }
+
+ getParameter( point, target ) {
+
+ // This can potentially have a divide by zero if the box
+ // has a size dimension of 0.
+
+ return target.set(
+ ( point.x - this.min.x ) / ( this.max.x - this.min.x ),
+ ( point.y - this.min.y ) / ( this.max.y - this.min.y ),
+ ( point.z - this.min.z ) / ( this.max.z - this.min.z )
+ );
+
+ }
+
+ intersectsBox( box ) {
+
+ // using 6 splitting planes to rule out intersections.
+ return box.max.x < this.min.x || box.min.x > this.max.x ||
+ box.max.y < this.min.y || box.min.y > this.max.y ||
+ box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
+
+ }
+
+ intersectsSphere( sphere ) {
+
+ // Find the point on the AABB closest to the sphere center.
+ this.clampPoint( sphere.center, _vector$b );
+
+ // If that point is inside the sphere, the AABB and sphere intersect.
+ return _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
+
+ }
+
+ intersectsPlane( plane ) {
+
+ // We compute the minimum and maximum dot product values. If those values
+ // are on the same side (back or front) of the plane, then there is no intersection.
+
+ let min, max;
+
+ if ( plane.normal.x > 0 ) {
+
+ min = plane.normal.x * this.min.x;
+ max = plane.normal.x * this.max.x;
+
+ } else {
+
+ min = plane.normal.x * this.max.x;
+ max = plane.normal.x * this.min.x;
+
+ }
+
+ if ( plane.normal.y > 0 ) {
+
+ min += plane.normal.y * this.min.y;
+ max += plane.normal.y * this.max.y;
+
+ } else {
+
+ min += plane.normal.y * this.max.y;
+ max += plane.normal.y * this.min.y;
+
+ }
+
+ if ( plane.normal.z > 0 ) {
+
+ min += plane.normal.z * this.min.z;
+ max += plane.normal.z * this.max.z;
+
+ } else {
+
+ min += plane.normal.z * this.max.z;
+ max += plane.normal.z * this.min.z;
+
+ }
+
+ return ( min <= - plane.constant && max >= - plane.constant );
+
+ }
+
+ intersectsTriangle( triangle ) {
+
+ if ( this.isEmpty() ) {
+
+ return false;
+
+ }
+
+ // compute box center and extents
+ this.getCenter( _center );
+ _extents.subVectors( this.max, _center );
+
+ // translate triangle to aabb origin
+ _v0$2.subVectors( triangle.a, _center );
+ _v1$7.subVectors( triangle.b, _center );
+ _v2$3.subVectors( triangle.c, _center );
+
+ // compute edge vectors for triangle
+ _f0.subVectors( _v1$7, _v0$2 );
+ _f1.subVectors( _v2$3, _v1$7 );
+ _f2.subVectors( _v0$2, _v2$3 );
+
+ // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
+ // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
+ // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
+ let axes = [
+ 0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,
+ _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
+ - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
+ ];
+ if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ) ) {
+
+ return false;
+
+ }
+
+ // test 3 face normals from the aabb
+ axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
+ if ( ! satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents ) ) {
+
+ return false;
+
+ }
+
+ // finally testing the face normal of the triangle
+ // use already existing triangle edge vectors here
+ _triangleNormal.crossVectors( _f0, _f1 );
+ axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
+
+ return satForAxes( axes, _v0$2, _v1$7, _v2$3, _extents );
+
+ }
+
+ clampPoint( point, target ) {
+
+ return target.copy( point ).clamp( this.min, this.max );
+
+ }
+
+ distanceToPoint( point ) {
+
+ const clampedPoint = _vector$b.copy( point ).clamp( this.min, this.max );
+
+ return clampedPoint.sub( point ).length();
+
+ }
+
+ getBoundingSphere( target ) {
+
+ this.getCenter( target.center );
+
+ target.radius = this.getSize( _vector$b ).length() * 0.5;
+
+ return target;
+
+ }
+
+ intersect( box ) {
+
+ this.min.max( box.min );
+ this.max.min( box.max );
+
+ // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
+ if ( this.isEmpty() ) this.makeEmpty();
+
+ return this;
+
+ }
+
+ union( box ) {
+
+ this.min.min( box.min );
+ this.max.max( box.max );
+
+ return this;
+
+ }
+
+ applyMatrix4( matrix ) {
+
+ // transform of empty box is an empty box.
+ if ( this.isEmpty() ) return this;
+
+ // NOTE: I am using a binary pattern to specify all 2^3 combinations below
+ _points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
+ _points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
+ _points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
+ _points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
+ _points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
+ _points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
+ _points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
+ _points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
+
+ this.setFromPoints( _points );
+
+ return this;
+
+ }
+
+ translate( offset ) {
+
+ this.min.add( offset );
+ this.max.add( offset );
+
+ return this;
+
+ }
+
+ equals( box ) {
+
+ return box.min.equals( this.min ) && box.max.equals( this.max );
+
+ }
+
+}
+
+const _points = [
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3(),
+ /*@__PURE__*/ new Vector3()
+];
+
+const _vector$b = /*@__PURE__*/ new Vector3();
+
+const _box$3 = /*@__PURE__*/ new Box3();
+
+// triangle centered vertices
+
+const _v0$2 = /*@__PURE__*/ new Vector3();
+const _v1$7 = /*@__PURE__*/ new Vector3();
+const _v2$3 = /*@__PURE__*/ new Vector3();
+
+// triangle edge vectors
+
+const _f0 = /*@__PURE__*/ new Vector3();
+const _f1 = /*@__PURE__*/ new Vector3();
+const _f2 = /*@__PURE__*/ new Vector3();
+
+const _center = /*@__PURE__*/ new Vector3();
+const _extents = /*@__PURE__*/ new Vector3();
+const _triangleNormal = /*@__PURE__*/ new Vector3();
+const _testAxis = /*@__PURE__*/ new Vector3();
+
+function satForAxes( axes, v0, v1, v2, extents ) {
+
+ for ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {
+
+ _testAxis.fromArray( axes, i );
+ // project the aabb onto the separating axis
+ const r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );
+ // project all 3 vertices of the triangle onto the separating axis
+ const p0 = v0.dot( _testAxis );
+ const p1 = v1.dot( _testAxis );
+ const p2 = v2.dot( _testAxis );
+ // actual test, basically see if either of the most extreme of the triangle points intersects r
+ if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
+
+ // points of the projected triangle are outside the projected half-length of the aabb
+ // the axis is separating and we can exit
+ return false;
+
+ }
+
+ }
+
+ return true;
+
+}
+
+const _box$2 = /*@__PURE__*/ new Box3();
+const _v1$6 = /*@__PURE__*/ new Vector3();
+const _toFarthestPoint = /*@__PURE__*/ new Vector3();
+const _toPoint = /*@__PURE__*/ new Vector3();
+
+class Sphere {
+
+ constructor( center = new Vector3(), radius = - 1 ) {
+
+ this.center = center;
+ this.radius = radius;
+
+ }
+
+ set( center, radius ) {
+
+ this.center.copy( center );
+ this.radius = radius;
+
+ return this;
+
+ }
+
+ setFromPoints( points, optionalCenter ) {
+
+ const center = this.center;
+
+ if ( optionalCenter !== undefined ) {
+
+ center.copy( optionalCenter );
+
+ } else {
+
+ _box$2.setFromPoints( points ).getCenter( center );
+
+ }
+
+ let maxRadiusSq = 0;
+
+ for ( let i = 0, il = points.length; i < il; i ++ ) {
+
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );
+
+ }
+
+ this.radius = Math.sqrt( maxRadiusSq );
+
+ return this;
+
+ }
+
+ copy( sphere ) {
+
+ this.center.copy( sphere.center );
+ this.radius = sphere.radius;
+
+ return this;
+
+ }
+
+ isEmpty() {
+
+ return ( this.radius < 0 );
+
+ }
+
+ makeEmpty() {
+
+ this.center.set( 0, 0, 0 );
+ this.radius = - 1;
+
+ return this;
+
+ }
+
+ containsPoint( point ) {
+
+ return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );
+
+ }
+
+ distanceToPoint( point ) {
+
+ return ( point.distanceTo( this.center ) - this.radius );
+
+ }
+
+ intersectsSphere( sphere ) {
+
+ const radiusSum = this.radius + sphere.radius;
+
+ return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );
+
+ }
+
+ intersectsBox( box ) {
+
+ return box.intersectsSphere( this );
+
+ }
+
+ intersectsPlane( plane ) {
+
+ return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;
+
+ }
+
+ clampPoint( point, target ) {
+
+ const deltaLengthSq = this.center.distanceToSquared( point );
+
+ target.copy( point );
+
+ if ( deltaLengthSq > ( this.radius * this.radius ) ) {
+
+ target.sub( this.center ).normalize();
+ target.multiplyScalar( this.radius ).add( this.center );
+
+ }
+
+ return target;
+
+ }
+
+ getBoundingBox( target ) {
+
+ if ( this.isEmpty() ) {
+
+ // Empty sphere produces empty bounding box
+ target.makeEmpty();
+ return target;
+
+ }
+
+ target.set( this.center, this.center );
+ target.expandByScalar( this.radius );
+
+ return target;
+
+ }
+
+ applyMatrix4( matrix ) {
+
+ this.center.applyMatrix4( matrix );
+ this.radius = this.radius * matrix.getMaxScaleOnAxis();
+
+ return this;
+
+ }
+
+ translate( offset ) {
+
+ this.center.add( offset );
+
+ return this;
+
+ }
+
+ expandByPoint( point ) {
+
+ // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671
+
+ _toPoint.subVectors( point, this.center );
+
+ const lengthSq = _toPoint.lengthSq();
+
+ if ( lengthSq > ( this.radius * this.radius ) ) {
+
+ const length = Math.sqrt( lengthSq );
+ const missingRadiusHalf = ( length - this.radius ) * 0.5;
+
+ // Nudge this sphere towards the target point. Add half the missing distance to radius,
+ // and the other half to position. This gives a tighter enclosure, instead of if
+ // the whole missing distance were just added to radius.
+
+ this.center.add( _toPoint.multiplyScalar( missingRadiusHalf / length ) );
+ this.radius += missingRadiusHalf;
+
+ }
+
+ return this;
+
+ }
+
+ union( sphere ) {
+
+ // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769
+
+ // To enclose another sphere into this sphere, we only need to enclose two points:
+ // 1) Enclose the farthest point on the other sphere into this sphere.
+ // 2) Enclose the opposite point of the farthest point into this sphere.
+
+ if ( this.center.equals( sphere.center ) === true ) {
+
+ _toFarthestPoint.set( 0, 0, 1 ).multiplyScalar( sphere.radius );
+
+
+ } else {
+
+ _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius );
+
+ }
+
+ this.expandByPoint( _v1$6.copy( sphere.center ).add( _toFarthestPoint ) );
+ this.expandByPoint( _v1$6.copy( sphere.center ).sub( _toFarthestPoint ) );
+
+ return this;
+
+ }
+
+ equals( sphere ) {
+
+ return sphere.center.equals( this.center ) && ( sphere.radius === this.radius );
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+}
+
+const _vector$a = /*@__PURE__*/ new Vector3();
+const _segCenter = /*@__PURE__*/ new Vector3();
+const _segDir = /*@__PURE__*/ new Vector3();
+const _diff = /*@__PURE__*/ new Vector3();
+
+const _edge1 = /*@__PURE__*/ new Vector3();
+const _edge2 = /*@__PURE__*/ new Vector3();
+const _normal$1 = /*@__PURE__*/ new Vector3();
+
+class Ray {
+
+ constructor( origin = new Vector3(), direction = new Vector3( 0, 0, - 1 ) ) {
+
+ this.origin = origin;
+ this.direction = direction;
+
+ }
+
+ set( origin, direction ) {
+
+ this.origin.copy( origin );
+ this.direction.copy( direction );
+
+ return this;
+
+ }
+
+ copy( ray ) {
+
+ this.origin.copy( ray.origin );
+ this.direction.copy( ray.direction );
+
+ return this;
+
+ }
+
+ at( t, target ) {
+
+ return target.copy( this.direction ).multiplyScalar( t ).add( this.origin );
+
+ }
+
+ lookAt( v ) {
+
+ this.direction.copy( v ).sub( this.origin ).normalize();
+
+ return this;
+
+ }
+
+ recast( t ) {
+
+ this.origin.copy( this.at( t, _vector$a ) );
+
+ return this;
+
+ }
+
+ closestPointToPoint( point, target ) {
+
+ target.subVectors( point, this.origin );
+
+ const directionDistance = target.dot( this.direction );
+
+ if ( directionDistance < 0 ) {
+
+ return target.copy( this.origin );
+
+ }
+
+ return target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
+
+ }
+
+ distanceToPoint( point ) {
+
+ return Math.sqrt( this.distanceSqToPoint( point ) );
+
+ }
+
+ distanceSqToPoint( point ) {
+
+ const directionDistance = _vector$a.subVectors( point, this.origin ).dot( this.direction );
+
+ // point behind the ray
+
+ if ( directionDistance < 0 ) {
+
+ return this.origin.distanceToSquared( point );
+
+ }
+
+ _vector$a.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
+
+ return _vector$a.distanceToSquared( point );
+
+ }
+
+ distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {
+
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h
+ // It returns the min distance between the ray and the segment
+ // defined by v0 and v1
+ // It can also set two optional targets :
+ // - The closest point on the ray
+ // - The closest point on the segment
+
+ _segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );
+ _segDir.copy( v1 ).sub( v0 ).normalize();
+ _diff.copy( this.origin ).sub( _segCenter );
+
+ const segExtent = v0.distanceTo( v1 ) * 0.5;
+ const a01 = - this.direction.dot( _segDir );
+ const b0 = _diff.dot( this.direction );
+ const b1 = - _diff.dot( _segDir );
+ const c = _diff.lengthSq();
+ const det = Math.abs( 1 - a01 * a01 );
+ let s0, s1, sqrDist, extDet;
+
+ if ( det > 0 ) {
+
+ // The ray and segment are not parallel.
+
+ s0 = a01 * b1 - b0;
+ s1 = a01 * b0 - b1;
+ extDet = segExtent * det;
+
+ if ( s0 >= 0 ) {
+
+ if ( s1 >= - extDet ) {
+
+ if ( s1 <= extDet ) {
+
+ // region 0
+ // Minimum at interior points of ray and segment.
+
+ const invDet = 1 / det;
+ s0 *= invDet;
+ s1 *= invDet;
+ sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;
+
+ } else {
+
+ // region 1
+
+ s1 = segExtent;
+ s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+
+ }
+
+ } else {
+
+ // region 5
+
+ s1 = - segExtent;
+ s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+
+ }
+
+ } else {
+
+ if ( s1 <= - extDet ) {
+
+ // region 4
+
+ s0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );
+ s1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+
+ } else if ( s1 <= extDet ) {
+
+ // region 3
+
+ s0 = 0;
+ s1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );
+ sqrDist = s1 * ( s1 + 2 * b1 ) + c;
+
+ } else {
+
+ // region 2
+
+ s0 = Math.max( 0, - ( a01 * segExtent + b0 ) );
+ s1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+
+ }
+
+ }
+
+ } else {
+
+ // Ray and segment are parallel.
+
+ s1 = ( a01 > 0 ) ? - segExtent : segExtent;
+ s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+
+ }
+
+ if ( optionalPointOnRay ) {
+
+ optionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );
+
+ }
+
+ if ( optionalPointOnSegment ) {
+
+ optionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter );
+
+ }
+
+ return sqrDist;
+
+ }
+
+ intersectSphere( sphere, target ) {
+
+ _vector$a.subVectors( sphere.center, this.origin );
+ const tca = _vector$a.dot( this.direction );
+ const d2 = _vector$a.dot( _vector$a ) - tca * tca;
+ const radius2 = sphere.radius * sphere.radius;
+
+ if ( d2 > radius2 ) return null;
+
+ const thc = Math.sqrt( radius2 - d2 );
+
+ // t0 = first intersect point - entrance on front of sphere
+ const t0 = tca - thc;
+
+ // t1 = second intersect point - exit point on back of sphere
+ const t1 = tca + thc;
+
+ // test to see if both t0 and t1 are behind the ray - if so, return null
+ if ( t0 < 0 && t1 < 0 ) return null;
+
+ // test to see if t0 is behind the ray:
+ // if it is, the ray is inside the sphere, so return the second exit point scaled by t1,
+ // in order to always return an intersect point that is in front of the ray.
+ if ( t0 < 0 ) return this.at( t1, target );
+
+ // else t0 is in front of the ray, so return the first collision point scaled by t0
+ return this.at( t0, target );
+
+ }
+
+ intersectsSphere( sphere ) {
+
+ return this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );
+
+ }
+
+ distanceToPlane( plane ) {
+
+ const denominator = plane.normal.dot( this.direction );
+
+ if ( denominator === 0 ) {
+
+ // line is coplanar, return origin
+ if ( plane.distanceToPoint( this.origin ) === 0 ) {
+
+ return 0;
+
+ }
+
+ // Null is preferable to undefined since undefined means.... it is undefined
+
+ return null;
+
+ }
+
+ const t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;
+
+ // Return if the ray never intersects the plane
+
+ return t >= 0 ? t : null;
+
+ }
+
+ intersectPlane( plane, target ) {
+
+ const t = this.distanceToPlane( plane );
+
+ if ( t === null ) {
+
+ return null;
+
+ }
+
+ return this.at( t, target );
+
+ }
+
+ intersectsPlane( plane ) {
+
+ // check if the ray lies on the plane first
+
+ const distToPoint = plane.distanceToPoint( this.origin );
+
+ if ( distToPoint === 0 ) {
+
+ return true;
+
+ }
+
+ const denominator = plane.normal.dot( this.direction );
+
+ if ( denominator * distToPoint < 0 ) {
+
+ return true;
+
+ }
+
+ // ray origin is behind the plane (and is pointing behind it)
+
+ return false;
+
+ }
+
+ intersectBox( box, target ) {
+
+ let tmin, tmax, tymin, tymax, tzmin, tzmax;
+
+ const invdirx = 1 / this.direction.x,
+ invdiry = 1 / this.direction.y,
+ invdirz = 1 / this.direction.z;
+
+ const origin = this.origin;
+
+ if ( invdirx >= 0 ) {
+
+ tmin = ( box.min.x - origin.x ) * invdirx;
+ tmax = ( box.max.x - origin.x ) * invdirx;
+
+ } else {
+
+ tmin = ( box.max.x - origin.x ) * invdirx;
+ tmax = ( box.min.x - origin.x ) * invdirx;
+
+ }
+
+ if ( invdiry >= 0 ) {
+
+ tymin = ( box.min.y - origin.y ) * invdiry;
+ tymax = ( box.max.y - origin.y ) * invdiry;
+
+ } else {
+
+ tymin = ( box.max.y - origin.y ) * invdiry;
+ tymax = ( box.min.y - origin.y ) * invdiry;
+
+ }
+
+ if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;
+
+ // These lines also handle the case where tmin or tmax is NaN
+ // (result of 0 * Infinity). x !== x returns true if x is NaN
+
+ if ( tymin > tmin || tmin !== tmin ) tmin = tymin;
+
+ if ( tymax < tmax || tmax !== tmax ) tmax = tymax;
+
+ if ( invdirz >= 0 ) {
+
+ tzmin = ( box.min.z - origin.z ) * invdirz;
+ tzmax = ( box.max.z - origin.z ) * invdirz;
+
+ } else {
+
+ tzmin = ( box.max.z - origin.z ) * invdirz;
+ tzmax = ( box.min.z - origin.z ) * invdirz;
+
+ }
+
+ if ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;
+
+ if ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;
+
+ if ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;
+
+ //return point closest to the ray (positive side)
+
+ if ( tmax < 0 ) return null;
+
+ return this.at( tmin >= 0 ? tmin : tmax, target );
+
+ }
+
+ intersectsBox( box ) {
+
+ return this.intersectBox( box, _vector$a ) !== null;
+
+ }
+
+ intersectTriangle( a, b, c, backfaceCulling, target ) {
+
+ // Compute the offset origin, edges, and normal.
+
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
+
+ _edge1.subVectors( b, a );
+ _edge2.subVectors( c, a );
+ _normal$1.crossVectors( _edge1, _edge2 );
+
+ // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,
+ // E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by
+ // |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))
+ // |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))
+ // |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)
+ let DdN = this.direction.dot( _normal$1 );
+ let sign;
+
+ if ( DdN > 0 ) {
+
+ if ( backfaceCulling ) return null;
+ sign = 1;
+
+ } else if ( DdN < 0 ) {
+
+ sign = - 1;
+ DdN = - DdN;
+
+ } else {
+
+ return null;
+
+ }
+
+ _diff.subVectors( this.origin, a );
+ const DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );
+
+ // b1 < 0, no intersection
+ if ( DdQxE2 < 0 ) {
+
+ return null;
+
+ }
+
+ const DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );
+
+ // b2 < 0, no intersection
+ if ( DdE1xQ < 0 ) {
+
+ return null;
+
+ }
+
+ // b1+b2 > 1, no intersection
+ if ( DdQxE2 + DdE1xQ > DdN ) {
+
+ return null;
+
+ }
+
+ // Line intersects triangle, check if ray does.
+ const QdN = - sign * _diff.dot( _normal$1 );
+
+ // t < 0, no intersection
+ if ( QdN < 0 ) {
+
+ return null;
+
+ }
+
+ // Ray intersects triangle.
+ return this.at( QdN / DdN, target );
+
+ }
+
+ applyMatrix4( matrix4 ) {
+
+ this.origin.applyMatrix4( matrix4 );
+ this.direction.transformDirection( matrix4 );
+
+ return this;
+
+ }
+
+ equals( ray ) {
+
+ return ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+}
+
+class Matrix4 {
+
+ constructor() {
+
+ Matrix4.prototype.isMatrix4 = true;
+
+ this.elements = [
+
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
+
+ ];
+
+ if ( arguments.length > 0 ) {
+
+ console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
+
+ }
+
+ }
+
+ set( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+
+ const te = this.elements;
+
+ te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;
+ te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;
+ te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;
+ te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;
+
+ return this;
+
+ }
+
+ identity() {
+
+ this.set(
+
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ clone() {
+
+ return new Matrix4().fromArray( this.elements );
+
+ }
+
+ copy( m ) {
+
+ const te = this.elements;
+ const me = m.elements;
+
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];
+ te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];
+ te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];
+ te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];
+
+ return this;
+
+ }
+
+ copyPosition( m ) {
+
+ const te = this.elements, me = m.elements;
+
+ te[ 12 ] = me[ 12 ];
+ te[ 13 ] = me[ 13 ];
+ te[ 14 ] = me[ 14 ];
+
+ return this;
+
+ }
+
+ setFromMatrix3( m ) {
+
+ const me = m.elements;
+
+ this.set(
+
+ me[ 0 ], me[ 3 ], me[ 6 ], 0,
+ me[ 1 ], me[ 4 ], me[ 7 ], 0,
+ me[ 2 ], me[ 5 ], me[ 8 ], 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ extractBasis( xAxis, yAxis, zAxis ) {
+
+ xAxis.setFromMatrixColumn( this, 0 );
+ yAxis.setFromMatrixColumn( this, 1 );
+ zAxis.setFromMatrixColumn( this, 2 );
+
+ return this;
+
+ }
+
+ makeBasis( xAxis, yAxis, zAxis ) {
+
+ this.set(
+ xAxis.x, yAxis.x, zAxis.x, 0,
+ xAxis.y, yAxis.y, zAxis.y, 0,
+ xAxis.z, yAxis.z, zAxis.z, 0,
+ 0, 0, 0, 1
+ );
+
+ return this;
+
+ }
+
+ extractRotation( m ) {
+
+ // this method does not support reflection matrices
+
+ const te = this.elements;
+ const me = m.elements;
+
+ const scaleX = 1 / _v1$5.setFromMatrixColumn( m, 0 ).length();
+ const scaleY = 1 / _v1$5.setFromMatrixColumn( m, 1 ).length();
+ const scaleZ = 1 / _v1$5.setFromMatrixColumn( m, 2 ).length();
+
+ te[ 0 ] = me[ 0 ] * scaleX;
+ te[ 1 ] = me[ 1 ] * scaleX;
+ te[ 2 ] = me[ 2 ] * scaleX;
+ te[ 3 ] = 0;
+
+ te[ 4 ] = me[ 4 ] * scaleY;
+ te[ 5 ] = me[ 5 ] * scaleY;
+ te[ 6 ] = me[ 6 ] * scaleY;
+ te[ 7 ] = 0;
+
+ te[ 8 ] = me[ 8 ] * scaleZ;
+ te[ 9 ] = me[ 9 ] * scaleZ;
+ te[ 10 ] = me[ 10 ] * scaleZ;
+ te[ 11 ] = 0;
+
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
+
+ return this;
+
+ }
+
+ makeRotationFromEuler( euler ) {
+
+ if ( ! ( euler && euler.isEuler ) ) {
+
+ console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );
+
+ }
+
+ const te = this.elements;
+
+ const x = euler.x, y = euler.y, z = euler.z;
+ const a = Math.cos( x ), b = Math.sin( x );
+ const c = Math.cos( y ), d = Math.sin( y );
+ const e = Math.cos( z ), f = Math.sin( z );
+
+ if ( euler.order === 'XYZ' ) {
+
+ const ae = a * e, af = a * f, be = b * e, bf = b * f;
+
+ te[ 0 ] = c * e;
+ te[ 4 ] = - c * f;
+ te[ 8 ] = d;
+
+ te[ 1 ] = af + be * d;
+ te[ 5 ] = ae - bf * d;
+ te[ 9 ] = - b * c;
+
+ te[ 2 ] = bf - ae * d;
+ te[ 6 ] = be + af * d;
+ te[ 10 ] = a * c;
+
+ } else if ( euler.order === 'YXZ' ) {
+
+ const ce = c * e, cf = c * f, de = d * e, df = d * f;
+
+ te[ 0 ] = ce + df * b;
+ te[ 4 ] = de * b - cf;
+ te[ 8 ] = a * d;
+
+ te[ 1 ] = a * f;
+ te[ 5 ] = a * e;
+ te[ 9 ] = - b;
+
+ te[ 2 ] = cf * b - de;
+ te[ 6 ] = df + ce * b;
+ te[ 10 ] = a * c;
+
+ } else if ( euler.order === 'ZXY' ) {
+
+ const ce = c * e, cf = c * f, de = d * e, df = d * f;
+
+ te[ 0 ] = ce - df * b;
+ te[ 4 ] = - a * f;
+ te[ 8 ] = de + cf * b;
+
+ te[ 1 ] = cf + de * b;
+ te[ 5 ] = a * e;
+ te[ 9 ] = df - ce * b;
+
+ te[ 2 ] = - a * d;
+ te[ 6 ] = b;
+ te[ 10 ] = a * c;
+
+ } else if ( euler.order === 'ZYX' ) {
+
+ const ae = a * e, af = a * f, be = b * e, bf = b * f;
+
+ te[ 0 ] = c * e;
+ te[ 4 ] = be * d - af;
+ te[ 8 ] = ae * d + bf;
+
+ te[ 1 ] = c * f;
+ te[ 5 ] = bf * d + ae;
+ te[ 9 ] = af * d - be;
+
+ te[ 2 ] = - d;
+ te[ 6 ] = b * c;
+ te[ 10 ] = a * c;
+
+ } else if ( euler.order === 'YZX' ) {
+
+ const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+
+ te[ 0 ] = c * e;
+ te[ 4 ] = bd - ac * f;
+ te[ 8 ] = bc * f + ad;
+
+ te[ 1 ] = f;
+ te[ 5 ] = a * e;
+ te[ 9 ] = - b * e;
+
+ te[ 2 ] = - d * e;
+ te[ 6 ] = ad * f + bc;
+ te[ 10 ] = ac - bd * f;
+
+ } else if ( euler.order === 'XZY' ) {
+
+ const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+
+ te[ 0 ] = c * e;
+ te[ 4 ] = - f;
+ te[ 8 ] = d * e;
+
+ te[ 1 ] = ac * f + bd;
+ te[ 5 ] = a * e;
+ te[ 9 ] = ad * f - bc;
+
+ te[ 2 ] = bc * f - ad;
+ te[ 6 ] = b * e;
+ te[ 10 ] = bd * f + ac;
+
+ }
+
+ // bottom row
+ te[ 3 ] = 0;
+ te[ 7 ] = 0;
+ te[ 11 ] = 0;
+
+ // last column
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
+
+ return this;
+
+ }
+
+ makeRotationFromQuaternion( q ) {
+
+ return this.compose( _zero, q, _one );
+
+ }
+
+ lookAt( eye, target, up ) {
+
+ const te = this.elements;
+
+ _z.subVectors( eye, target );
+
+ if ( _z.lengthSq() === 0 ) {
+
+ // eye and target are in the same position
+
+ _z.z = 1;
+
+ }
+
+ _z.normalize();
+ _x.crossVectors( up, _z );
+
+ if ( _x.lengthSq() === 0 ) {
+
+ // up and z are parallel
+
+ if ( Math.abs( up.z ) === 1 ) {
+
+ _z.x += 0.0001;
+
+ } else {
+
+ _z.z += 0.0001;
+
+ }
+
+ _z.normalize();
+ _x.crossVectors( up, _z );
+
+ }
+
+ _x.normalize();
+ _y.crossVectors( _z, _x );
+
+ te[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;
+ te[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;
+ te[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;
+
+ return this;
+
+ }
+
+ multiply( m, n ) {
+
+ if ( n !== undefined ) {
+
+ console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );
+ return this.multiplyMatrices( m, n );
+
+ }
+
+ return this.multiplyMatrices( this, m );
+
+ }
+
+ premultiply( m ) {
+
+ return this.multiplyMatrices( m, this );
+
+ }
+
+ multiplyMatrices( a, b ) {
+
+ const ae = a.elements;
+ const be = b.elements;
+ const te = this.elements;
+
+ const a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];
+ const a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];
+ const a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];
+ const a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];
+
+ const b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];
+ const b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];
+ const b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];
+ const b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];
+
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
+ te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
+ te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
+ te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
+
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
+ te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
+ te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
+ te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
+
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
+ te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
+ te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
+ te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
+
+ te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
+ te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
+ te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
+ te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
+
+ return this;
+
+ }
+
+ multiplyScalar( s ) {
+
+ const te = this.elements;
+
+ te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;
+ te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;
+ te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;
+ te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;
+
+ return this;
+
+ }
+
+ determinant() {
+
+ const te = this.elements;
+
+ const n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];
+ const n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
+ const n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
+ const n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];
+
+ //TODO: make this more efficient
+ //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
+
+ return (
+ n41 * (
+ + n14 * n23 * n32
+ - n13 * n24 * n32
+ - n14 * n22 * n33
+ + n12 * n24 * n33
+ + n13 * n22 * n34
+ - n12 * n23 * n34
+ ) +
+ n42 * (
+ + n11 * n23 * n34
+ - n11 * n24 * n33
+ + n14 * n21 * n33
+ - n13 * n21 * n34
+ + n13 * n24 * n31
+ - n14 * n23 * n31
+ ) +
+ n43 * (
+ + n11 * n24 * n32
+ - n11 * n22 * n34
+ - n14 * n21 * n32
+ + n12 * n21 * n34
+ + n14 * n22 * n31
+ - n12 * n24 * n31
+ ) +
+ n44 * (
+ - n13 * n22 * n31
+ - n11 * n23 * n32
+ + n11 * n22 * n33
+ + n13 * n21 * n32
+ - n12 * n21 * n33
+ + n12 * n23 * n31
+ )
+
+ );
+
+ }
+
+ transpose() {
+
+ const te = this.elements;
+ let tmp;
+
+ tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;
+ tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;
+ tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;
+
+ tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;
+ tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;
+ tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;
+
+ return this;
+
+ }
+
+ setPosition( x, y, z ) {
+
+ const te = this.elements;
+
+ if ( x.isVector3 ) {
+
+ te[ 12 ] = x.x;
+ te[ 13 ] = x.y;
+ te[ 14 ] = x.z;
+
+ } else {
+
+ te[ 12 ] = x;
+ te[ 13 ] = y;
+ te[ 14 ] = z;
+
+ }
+
+ return this;
+
+ }
+
+ invert() {
+
+ // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
+ const te = this.elements,
+
+ n11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], n41 = te[ 3 ],
+ n12 = te[ 4 ], n22 = te[ 5 ], n32 = te[ 6 ], n42 = te[ 7 ],
+ n13 = te[ 8 ], n23 = te[ 9 ], n33 = te[ 10 ], n43 = te[ 11 ],
+ n14 = te[ 12 ], n24 = te[ 13 ], n34 = te[ 14 ], n44 = te[ 15 ],
+
+ t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
+ t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
+ t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
+ t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
+
+ const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
+
+ if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
+
+ const detInv = 1 / det;
+
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;
+ te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;
+ te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;
+
+ te[ 4 ] = t12 * detInv;
+ te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;
+ te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;
+ te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;
+
+ te[ 8 ] = t13 * detInv;
+ te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;
+ te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;
+ te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;
+
+ te[ 12 ] = t14 * detInv;
+ te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;
+ te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;
+ te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;
+
+ return this;
+
+ }
+
+ scale( v ) {
+
+ const te = this.elements;
+ const x = v.x, y = v.y, z = v.z;
+
+ te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;
+ te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;
+ te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;
+ te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;
+
+ return this;
+
+ }
+
+ getMaxScaleOnAxis() {
+
+ const te = this.elements;
+
+ const scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];
+ const scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];
+ const scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];
+
+ return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
+
+ }
+
+ makeTranslation( x, y, z ) {
+
+ this.set(
+
+ 1, 0, 0, x,
+ 0, 1, 0, y,
+ 0, 0, 1, z,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ makeRotationX( theta ) {
+
+ const c = Math.cos( theta ), s = Math.sin( theta );
+
+ this.set(
+
+ 1, 0, 0, 0,
+ 0, c, - s, 0,
+ 0, s, c, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ makeRotationY( theta ) {
+
+ const c = Math.cos( theta ), s = Math.sin( theta );
+
+ this.set(
+
+ c, 0, s, 0,
+ 0, 1, 0, 0,
+ - s, 0, c, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ makeRotationZ( theta ) {
+
+ const c = Math.cos( theta ), s = Math.sin( theta );
+
+ this.set(
+
+ c, - s, 0, 0,
+ s, c, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ makeRotationAxis( axis, angle ) {
+
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
+
+ const c = Math.cos( angle );
+ const s = Math.sin( angle );
+ const t = 1 - c;
+ const x = axis.x, y = axis.y, z = axis.z;
+ const tx = t * x, ty = t * y;
+
+ this.set(
+
+ tx * x + c, tx * y - s * z, tx * z + s * y, 0,
+ tx * y + s * z, ty * y + c, ty * z - s * x, 0,
+ tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ makeScale( x, y, z ) {
+
+ this.set(
+
+ x, 0, 0, 0,
+ 0, y, 0, 0,
+ 0, 0, z, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ makeShear( xy, xz, yx, yz, zx, zy ) {
+
+ this.set(
+
+ 1, yx, zx, 0,
+ xy, 1, zy, 0,
+ xz, yz, 1, 0,
+ 0, 0, 0, 1
+
+ );
+
+ return this;
+
+ }
+
+ compose( position, quaternion, scale ) {
+
+ const te = this.elements;
+
+ const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
+ const x2 = x + x, y2 = y + y, z2 = z + z;
+ const xx = x * x2, xy = x * y2, xz = x * z2;
+ const yy = y * y2, yz = y * z2, zz = z * z2;
+ const wx = w * x2, wy = w * y2, wz = w * z2;
+
+ const sx = scale.x, sy = scale.y, sz = scale.z;
+
+ te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;
+ te[ 1 ] = ( xy + wz ) * sx;
+ te[ 2 ] = ( xz - wy ) * sx;
+ te[ 3 ] = 0;
+
+ te[ 4 ] = ( xy - wz ) * sy;
+ te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;
+ te[ 6 ] = ( yz + wx ) * sy;
+ te[ 7 ] = 0;
+
+ te[ 8 ] = ( xz + wy ) * sz;
+ te[ 9 ] = ( yz - wx ) * sz;
+ te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;
+ te[ 11 ] = 0;
+
+ te[ 12 ] = position.x;
+ te[ 13 ] = position.y;
+ te[ 14 ] = position.z;
+ te[ 15 ] = 1;
+
+ return this;
+
+ }
+
+ decompose( position, quaternion, scale ) {
+
+ const te = this.elements;
+
+ let sx = _v1$5.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
+ const sy = _v1$5.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
+ const sz = _v1$5.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
+
+ // if determine is negative, we need to invert one scale
+ const det = this.determinant();
+ if ( det < 0 ) sx = - sx;
+
+ position.x = te[ 12 ];
+ position.y = te[ 13 ];
+ position.z = te[ 14 ];
+
+ // scale the rotation part
+ _m1$2.copy( this );
+
+ const invSX = 1 / sx;
+ const invSY = 1 / sy;
+ const invSZ = 1 / sz;
+
+ _m1$2.elements[ 0 ] *= invSX;
+ _m1$2.elements[ 1 ] *= invSX;
+ _m1$2.elements[ 2 ] *= invSX;
+
+ _m1$2.elements[ 4 ] *= invSY;
+ _m1$2.elements[ 5 ] *= invSY;
+ _m1$2.elements[ 6 ] *= invSY;
+
+ _m1$2.elements[ 8 ] *= invSZ;
+ _m1$2.elements[ 9 ] *= invSZ;
+ _m1$2.elements[ 10 ] *= invSZ;
+
+ quaternion.setFromRotationMatrix( _m1$2 );
+
+ scale.x = sx;
+ scale.y = sy;
+ scale.z = sz;
+
+ return this;
+
+ }
+
+ makePerspective( left, right, top, bottom, near, far ) {
+
+ if ( far === undefined ) {
+
+ console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );
+
+ }
+
+ const te = this.elements;
+ const x = 2 * near / ( right - left );
+ const y = 2 * near / ( top - bottom );
+
+ const a = ( right + left ) / ( right - left );
+ const b = ( top + bottom ) / ( top - bottom );
+ const c = - ( far + near ) / ( far - near );
+ const d = - 2 * far * near / ( far - near );
+
+ te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0;
+ te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0;
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
+ te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0;
+
+ return this;
+
+ }
+
+ makeOrthographic( left, right, top, bottom, near, far ) {
+
+ const te = this.elements;
+ const w = 1.0 / ( right - left );
+ const h = 1.0 / ( top - bottom );
+ const p = 1.0 / ( far - near );
+
+ const x = ( right + left ) * w;
+ const y = ( top + bottom ) * h;
+ const z = ( far + near ) * p;
+
+ te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
+ te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z;
+ te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
+
+ return this;
+
+ }
+
+ equals( matrix ) {
+
+ const te = this.elements;
+ const me = matrix.elements;
+
+ for ( let i = 0; i < 16; i ++ ) {
+
+ if ( te[ i ] !== me[ i ] ) return false;
+
+ }
+
+ return true;
+
+ }
+
+ fromArray( array, offset = 0 ) {
+
+ for ( let i = 0; i < 16; i ++ ) {
+
+ this.elements[ i ] = array[ i + offset ];
+
+ }
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ const te = this.elements;
+
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
+ array[ offset + 3 ] = te[ 3 ];
+
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
+
+ array[ offset + 8 ] = te[ 8 ];
+ array[ offset + 9 ] = te[ 9 ];
+ array[ offset + 10 ] = te[ 10 ];
+ array[ offset + 11 ] = te[ 11 ];
+
+ array[ offset + 12 ] = te[ 12 ];
+ array[ offset + 13 ] = te[ 13 ];
+ array[ offset + 14 ] = te[ 14 ];
+ array[ offset + 15 ] = te[ 15 ];
+
+ return array;
+
+ }
+
+}
+
+const _v1$5 = /*@__PURE__*/ new Vector3();
+const _m1$2 = /*@__PURE__*/ new Matrix4();
+const _zero = /*@__PURE__*/ new Vector3( 0, 0, 0 );
+const _one = /*@__PURE__*/ new Vector3( 1, 1, 1 );
+const _x = /*@__PURE__*/ new Vector3();
+const _y = /*@__PURE__*/ new Vector3();
+const _z = /*@__PURE__*/ new Vector3();
+
+const _matrix$1 = /*@__PURE__*/ new Matrix4();
+const _quaternion$3 = /*@__PURE__*/ new Quaternion();
+
+class Euler {
+
+ constructor( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
+
+ this.isEuler = true;
+
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._order = order;
+
+ }
+
+ get x() {
+
+ return this._x;
+
+ }
+
+ set x( value ) {
+
+ this._x = value;
+ this._onChangeCallback();
+
+ }
+
+ get y() {
+
+ return this._y;
+
+ }
+
+ set y( value ) {
+
+ this._y = value;
+ this._onChangeCallback();
+
+ }
+
+ get z() {
+
+ return this._z;
+
+ }
+
+ set z( value ) {
+
+ this._z = value;
+ this._onChangeCallback();
+
+ }
+
+ get order() {
+
+ return this._order;
+
+ }
+
+ set order( value ) {
+
+ this._order = value;
+ this._onChangeCallback();
+
+ }
+
+ set( x, y, z, order = this._order ) {
+
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._order = order;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ clone() {
+
+ return new this.constructor( this._x, this._y, this._z, this._order );
+
+ }
+
+ copy( euler ) {
+
+ this._x = euler._x;
+ this._y = euler._y;
+ this._z = euler._z;
+ this._order = euler._order;
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ setFromRotationMatrix( m, order = this._order, update = true ) {
+
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+
+ const te = m.elements;
+ const m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];
+ const m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];
+ const m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
+
+ switch ( order ) {
+
+ case 'XYZ':
+
+ this._y = Math.asin( clamp( m13, - 1, 1 ) );
+
+ if ( Math.abs( m13 ) < 0.9999999 ) {
+
+ this._x = Math.atan2( - m23, m33 );
+ this._z = Math.atan2( - m12, m11 );
+
+ } else {
+
+ this._x = Math.atan2( m32, m22 );
+ this._z = 0;
+
+ }
+
+ break;
+
+ case 'YXZ':
+
+ this._x = Math.asin( - clamp( m23, - 1, 1 ) );
+
+ if ( Math.abs( m23 ) < 0.9999999 ) {
+
+ this._y = Math.atan2( m13, m33 );
+ this._z = Math.atan2( m21, m22 );
+
+ } else {
+
+ this._y = Math.atan2( - m31, m11 );
+ this._z = 0;
+
+ }
+
+ break;
+
+ case 'ZXY':
+
+ this._x = Math.asin( clamp( m32, - 1, 1 ) );
+
+ if ( Math.abs( m32 ) < 0.9999999 ) {
+
+ this._y = Math.atan2( - m31, m33 );
+ this._z = Math.atan2( - m12, m22 );
+
+ } else {
+
+ this._y = 0;
+ this._z = Math.atan2( m21, m11 );
+
+ }
+
+ break;
+
+ case 'ZYX':
+
+ this._y = Math.asin( - clamp( m31, - 1, 1 ) );
+
+ if ( Math.abs( m31 ) < 0.9999999 ) {
+
+ this._x = Math.atan2( m32, m33 );
+ this._z = Math.atan2( m21, m11 );
+
+ } else {
+
+ this._x = 0;
+ this._z = Math.atan2( - m12, m22 );
+
+ }
+
+ break;
+
+ case 'YZX':
+
+ this._z = Math.asin( clamp( m21, - 1, 1 ) );
+
+ if ( Math.abs( m21 ) < 0.9999999 ) {
+
+ this._x = Math.atan2( - m23, m22 );
+ this._y = Math.atan2( - m31, m11 );
+
+ } else {
+
+ this._x = 0;
+ this._y = Math.atan2( m13, m33 );
+
+ }
+
+ break;
+
+ case 'XZY':
+
+ this._z = Math.asin( - clamp( m12, - 1, 1 ) );
+
+ if ( Math.abs( m12 ) < 0.9999999 ) {
+
+ this._x = Math.atan2( m32, m22 );
+ this._y = Math.atan2( m13, m11 );
+
+ } else {
+
+ this._x = Math.atan2( - m23, m33 );
+ this._y = 0;
+
+ }
+
+ break;
+
+ default:
+
+ console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );
+
+ }
+
+ this._order = order;
+
+ if ( update === true ) this._onChangeCallback();
+
+ return this;
+
+ }
+
+ setFromQuaternion( q, order, update ) {
+
+ _matrix$1.makeRotationFromQuaternion( q );
+
+ return this.setFromRotationMatrix( _matrix$1, order, update );
+
+ }
+
+ setFromVector3( v, order = this._order ) {
+
+ return this.set( v.x, v.y, v.z, order );
+
+ }
+
+ reorder( newOrder ) {
+
+ // WARNING: this discards revolution information -bhouston
+
+ _quaternion$3.setFromEuler( this );
+
+ return this.setFromQuaternion( _quaternion$3, newOrder );
+
+ }
+
+ equals( euler ) {
+
+ return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );
+
+ }
+
+ fromArray( array ) {
+
+ this._x = array[ 0 ];
+ this._y = array[ 1 ];
+ this._z = array[ 2 ];
+ if ( array[ 3 ] !== undefined ) this._order = array[ 3 ];
+
+ this._onChangeCallback();
+
+ return this;
+
+ }
+
+ toArray( array = [], offset = 0 ) {
+
+ array[ offset ] = this._x;
+ array[ offset + 1 ] = this._y;
+ array[ offset + 2 ] = this._z;
+ array[ offset + 3 ] = this._order;
+
+ return array;
+
+ }
+
+ _onChange( callback ) {
+
+ this._onChangeCallback = callback;
+
+ return this;
+
+ }
+
+ _onChangeCallback() {}
+
+ *[ Symbol.iterator ]() {
+
+ yield this._x;
+ yield this._y;
+ yield this._z;
+ yield this._order;
+
+ }
+
+ // @deprecated since r138, 02cf0df1cb4575d5842fef9c85bb5a89fe020d53
+
+ toVector3() {
+
+ console.error( 'THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead' );
+
+ }
+
+}
+
+Euler.DefaultOrder = 'XYZ';
+Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
+
+class Layers {
+
+ constructor() {
+
+ this.mask = 1 | 0;
+
+ }
+
+ set( channel ) {
+
+ this.mask = ( 1 << channel | 0 ) >>> 0;
+
+ }
+
+ enable( channel ) {
+
+ this.mask |= 1 << channel | 0;
+
+ }
+
+ enableAll() {
+
+ this.mask = 0xffffffff | 0;
+
+ }
+
+ toggle( channel ) {
+
+ this.mask ^= 1 << channel | 0;
+
+ }
+
+ disable( channel ) {
+
+ this.mask &= ~ ( 1 << channel | 0 );
+
+ }
+
+ disableAll() {
+
+ this.mask = 0;
+
+ }
+
+ test( layers ) {
+
+ return ( this.mask & layers.mask ) !== 0;
+
+ }
+
+ isEnabled( channel ) {
+
+ return ( this.mask & ( 1 << channel | 0 ) ) !== 0;
+
+ }
+
+}
+
+let _object3DId = 0;
+
+const _v1$4 = /*@__PURE__*/ new Vector3();
+const _q1 = /*@__PURE__*/ new Quaternion();
+const _m1$1 = /*@__PURE__*/ new Matrix4();
+const _target = /*@__PURE__*/ new Vector3();
+
+const _position$3 = /*@__PURE__*/ new Vector3();
+const _scale$2 = /*@__PURE__*/ new Vector3();
+const _quaternion$2 = /*@__PURE__*/ new Quaternion();
+
+const _xAxis = /*@__PURE__*/ new Vector3( 1, 0, 0 );
+const _yAxis = /*@__PURE__*/ new Vector3( 0, 1, 0 );
+const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 );
+
+const _addedEvent = { type: 'added' };
+const _removedEvent = { type: 'removed' };
+
+class Object3D extends EventDispatcher {
+
+ constructor() {
+
+ super();
+
+ this.isObject3D = true;
+
+ Object.defineProperty( this, 'id', { value: _object3DId ++ } );
+
+ this.uuid = generateUUID();
+
+ this.name = '';
+ this.type = 'Object3D';
+
+ this.parent = null;
+ this.children = [];
+
+ this.up = Object3D.DefaultUp.clone();
+
+ const position = new Vector3();
+ const rotation = new Euler();
+ const quaternion = new Quaternion();
+ const scale = new Vector3( 1, 1, 1 );
+
+ function onRotationChange() {
+
+ quaternion.setFromEuler( rotation, false );
+
+ }
+
+ function onQuaternionChange() {
+
+ rotation.setFromQuaternion( quaternion, undefined, false );
+
+ }
+
+ rotation._onChange( onRotationChange );
+ quaternion._onChange( onQuaternionChange );
+
+ Object.defineProperties( this, {
+ position: {
+ configurable: true,
+ enumerable: true,
+ value: position
+ },
+ rotation: {
+ configurable: true,
+ enumerable: true,
+ value: rotation
+ },
+ quaternion: {
+ configurable: true,
+ enumerable: true,
+ value: quaternion
+ },
+ scale: {
+ configurable: true,
+ enumerable: true,
+ value: scale
+ },
+ modelViewMatrix: {
+ value: new Matrix4()
+ },
+ normalMatrix: {
+ value: new Matrix3()
+ }
+ } );
+
+ this.matrix = new Matrix4();
+ this.matrixWorld = new Matrix4();
+
+ this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
+ this.matrixWorldNeedsUpdate = false;
+
+ this.layers = new Layers();
+ this.visible = true;
+
+ this.castShadow = false;
+ this.receiveShadow = false;
+
+ this.frustumCulled = true;
+ this.renderOrder = 0;
+
+ this.animations = [];
+
+ this.userData = {};
+
+ }
+
+ onBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {}
+
+ onAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {}
+
+ applyMatrix4( matrix ) {
+
+ if ( this.matrixAutoUpdate ) this.updateMatrix();
+
+ this.matrix.premultiply( matrix );
+
+ this.matrix.decompose( this.position, this.quaternion, this.scale );
+
+ }
+
+ applyQuaternion( q ) {
+
+ this.quaternion.premultiply( q );
+
+ return this;
+
+ }
+
+ setRotationFromAxisAngle( axis, angle ) {
+
+ // assumes axis is normalized
+
+ this.quaternion.setFromAxisAngle( axis, angle );
+
+ }
+
+ setRotationFromEuler( euler ) {
+
+ this.quaternion.setFromEuler( euler, true );
+
+ }
+
+ setRotationFromMatrix( m ) {
+
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+
+ this.quaternion.setFromRotationMatrix( m );
+
+ }
+
+ setRotationFromQuaternion( q ) {
+
+ // assumes q is normalized
+
+ this.quaternion.copy( q );
+
+ }
+
+ rotateOnAxis( axis, angle ) {
+
+ // rotate object on axis in object space
+ // axis is assumed to be normalized
+
+ _q1.setFromAxisAngle( axis, angle );
+
+ this.quaternion.multiply( _q1 );
+
+ return this;
+
+ }
+
+ rotateOnWorldAxis( axis, angle ) {
+
+ // rotate object on axis in world space
+ // axis is assumed to be normalized
+ // method assumes no rotated parent
+
+ _q1.setFromAxisAngle( axis, angle );
+
+ this.quaternion.premultiply( _q1 );
+
+ return this;
+
+ }
+
+ rotateX( angle ) {
+
+ return this.rotateOnAxis( _xAxis, angle );
+
+ }
+
+ rotateY( angle ) {
+
+ return this.rotateOnAxis( _yAxis, angle );
+
+ }
+
+ rotateZ( angle ) {
+
+ return this.rotateOnAxis( _zAxis, angle );
+
+ }
+
+ translateOnAxis( axis, distance ) {
+
+ // translate object by distance along axis in object space
+ // axis is assumed to be normalized
+
+ _v1$4.copy( axis ).applyQuaternion( this.quaternion );
+
+ this.position.add( _v1$4.multiplyScalar( distance ) );
+
+ return this;
+
+ }
+
+ translateX( distance ) {
+
+ return this.translateOnAxis( _xAxis, distance );
+
+ }
+
+ translateY( distance ) {
+
+ return this.translateOnAxis( _yAxis, distance );
+
+ }
+
+ translateZ( distance ) {
+
+ return this.translateOnAxis( _zAxis, distance );
+
+ }
+
+ localToWorld( vector ) {
+
+ return vector.applyMatrix4( this.matrixWorld );
+
+ }
+
+ worldToLocal( vector ) {
+
+ return vector.applyMatrix4( _m1$1.copy( this.matrixWorld ).invert() );
+
+ }
+
+ lookAt( x, y, z ) {
+
+ // This method does not support objects having non-uniformly-scaled parent(s)
+
+ if ( x.isVector3 ) {
+
+ _target.copy( x );
+
+ } else {
+
+ _target.set( x, y, z );
+
+ }
+
+ const parent = this.parent;
+
+ this.updateWorldMatrix( true, false );
+
+ _position$3.setFromMatrixPosition( this.matrixWorld );
+
+ if ( this.isCamera || this.isLight ) {
+
+ _m1$1.lookAt( _position$3, _target, this.up );
+
+ } else {
+
+ _m1$1.lookAt( _target, _position$3, this.up );
+
+ }
+
+ this.quaternion.setFromRotationMatrix( _m1$1 );
+
+ if ( parent ) {
+
+ _m1$1.extractRotation( parent.matrixWorld );
+ _q1.setFromRotationMatrix( _m1$1 );
+ this.quaternion.premultiply( _q1.invert() );
+
+ }
+
+ }
+
+ add( object ) {
+
+ if ( arguments.length > 1 ) {
+
+ for ( let i = 0; i < arguments.length; i ++ ) {
+
+ this.add( arguments[ i ] );
+
+ }
+
+ return this;
+
+ }
+
+ if ( object === this ) {
+
+ console.error( 'THREE.Object3D.add: object can\'t be added as a child of itself.', object );
+ return this;
+
+ }
+
+ if ( object && object.isObject3D ) {
+
+ if ( object.parent !== null ) {
+
+ object.parent.remove( object );
+
+ }
+
+ object.parent = this;
+ this.children.push( object );
+
+ object.dispatchEvent( _addedEvent );
+
+ } else {
+
+ console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object );
+
+ }
+
+ return this;
+
+ }
+
+ remove( object ) {
+
+ if ( arguments.length > 1 ) {
+
+ for ( let i = 0; i < arguments.length; i ++ ) {
+
+ this.remove( arguments[ i ] );
+
+ }
+
+ return this;
+
+ }
+
+ const index = this.children.indexOf( object );
+
+ if ( index !== - 1 ) {
+
+ object.parent = null;
+ this.children.splice( index, 1 );
+
+ object.dispatchEvent( _removedEvent );
+
+ }
+
+ return this;
+
+ }
+
+ removeFromParent() {
+
+ const parent = this.parent;
+
+ if ( parent !== null ) {
+
+ parent.remove( this );
+
+ }
+
+ return this;
+
+ }
+
+ clear() {
+
+ for ( let i = 0; i < this.children.length; i ++ ) {
+
+ const object = this.children[ i ];
+
+ object.parent = null;
+
+ object.dispatchEvent( _removedEvent );
+
+ }
+
+ this.children.length = 0;
+
+ return this;
+
+
+ }
+
+ attach( object ) {
+
+ // adds object as a child of this, while maintaining the object's world transform
+
+ // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)
+
+ this.updateWorldMatrix( true, false );
+
+ _m1$1.copy( this.matrixWorld ).invert();
+
+ if ( object.parent !== null ) {
+
+ object.parent.updateWorldMatrix( true, false );
+
+ _m1$1.multiply( object.parent.matrixWorld );
+
+ }
+
+ object.applyMatrix4( _m1$1 );
+
+ this.add( object );
+
+ object.updateWorldMatrix( false, true );
+
+ return this;
+
+ }
+
+ getObjectById( id ) {
+
+ return this.getObjectByProperty( 'id', id );
+
+ }
+
+ getObjectByName( name ) {
+
+ return this.getObjectByProperty( 'name', name );
+
+ }
+
+ getObjectByProperty( name, value ) {
+
+ if ( this[ name ] === value ) return this;
+
+ for ( let i = 0, l = this.children.length; i < l; i ++ ) {
+
+ const child = this.children[ i ];
+ const object = child.getObjectByProperty( name, value );
+
+ if ( object !== undefined ) {
+
+ return object;
+
+ }
+
+ }
+
+ return undefined;
+
+ }
+
+ getWorldPosition( target ) {
+
+ this.updateWorldMatrix( true, false );
+
+ return target.setFromMatrixPosition( this.matrixWorld );
+
+ }
+
+ getWorldQuaternion( target ) {
+
+ this.updateWorldMatrix( true, false );
+
+ this.matrixWorld.decompose( _position$3, target, _scale$2 );
+
+ return target;
+
+ }
+
+ getWorldScale( target ) {
+
+ this.updateWorldMatrix( true, false );
+
+ this.matrixWorld.decompose( _position$3, _quaternion$2, target );
+
+ return target;
+
+ }
+
+ getWorldDirection( target ) {
+
+ this.updateWorldMatrix( true, false );
+
+ const e = this.matrixWorld.elements;
+
+ return target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();
+
+ }
+
+ raycast( /* raycaster, intersects */ ) {}
+
+ traverse( callback ) {
+
+ callback( this );
+
+ const children = this.children;
+
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+ children[ i ].traverse( callback );
+
+ }
+
+ }
+
+ traverseVisible( callback ) {
+
+ if ( this.visible === false ) return;
+
+ callback( this );
+
+ const children = this.children;
+
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+ children[ i ].traverseVisible( callback );
+
+ }
+
+ }
+
+ traverseAncestors( callback ) {
+
+ const parent = this.parent;
+
+ if ( parent !== null ) {
+
+ callback( parent );
+
+ parent.traverseAncestors( callback );
+
+ }
+
+ }
+
+ updateMatrix() {
+
+ this.matrix.compose( this.position, this.quaternion, this.scale );
+
+ this.matrixWorldNeedsUpdate = true;
+
+ }
+
+ updateMatrixWorld( force ) {
+
+ if ( this.matrixAutoUpdate ) this.updateMatrix();
+
+ if ( this.matrixWorldNeedsUpdate || force ) {
+
+ if ( this.parent === null ) {
+
+ this.matrixWorld.copy( this.matrix );
+
+ } else {
+
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
+
+ }
+
+ this.matrixWorldNeedsUpdate = false;
+
+ force = true;
+
+ }
+
+ // update children
+
+ const children = this.children;
+
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+ children[ i ].updateMatrixWorld( force );
+
+ }
+
+ }
+
+ updateWorldMatrix( updateParents, updateChildren ) {
+
+ const parent = this.parent;
+
+ if ( updateParents === true && parent !== null ) {
+
+ parent.updateWorldMatrix( true, false );
+
+ }
+
+ if ( this.matrixAutoUpdate ) this.updateMatrix();
+
+ if ( this.parent === null ) {
+
+ this.matrixWorld.copy( this.matrix );
+
+ } else {
+
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
+
+ }
+
+ // update children
+
+ if ( updateChildren === true ) {
+
+ const children = this.children;
+
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
+
+ children[ i ].updateWorldMatrix( false, true );
+
+ }
+
+ }
+
+ }
+
+ toJSON( meta ) {
+
+ // meta is a string when called from JSON.stringify
+ const isRootObject = ( meta === undefined || typeof meta === 'string' );
+
+ const output = {};
+
+ // meta is a hash used to collect geometries, materials.
+ // not providing it implies that this is the root object
+ // being serialized.
+ if ( isRootObject ) {
+
+ // initialize meta obj
+ meta = {
+ geometries: {},
+ materials: {},
+ textures: {},
+ images: {},
+ shapes: {},
+ skeletons: {},
+ animations: {},
+ nodes: {}
+ };
+
+ output.metadata = {
+ version: 4.5,
+ type: 'Object',
+ generator: 'Object3D.toJSON'
+ };
+
+ }
+
+ // standard Object3D serialization
+
+ const object = {};
+
+ object.uuid = this.uuid;
+ object.type = this.type;
+
+ if ( this.name !== '' ) object.name = this.name;
+ if ( this.castShadow === true ) object.castShadow = true;
+ if ( this.receiveShadow === true ) object.receiveShadow = true;
+ if ( this.visible === false ) object.visible = false;
+ if ( this.frustumCulled === false ) object.frustumCulled = false;
+ if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;
+ if ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;
+
+ object.layers = this.layers.mask;
+ object.matrix = this.matrix.toArray();
+
+ if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;
+
+ // object specific properties
+
+ if ( this.isInstancedMesh ) {
+
+ object.type = 'InstancedMesh';
+ object.count = this.count;
+ object.instanceMatrix = this.instanceMatrix.toJSON();
+ if ( this.instanceColor !== null ) object.instanceColor = this.instanceColor.toJSON();
+
+ }
+
+ //
+
+ function serialize( library, element ) {
+
+ if ( library[ element.uuid ] === undefined ) {
+
+ library[ element.uuid ] = element.toJSON( meta );
+
+ }
+
+ return element.uuid;
+
+ }
+
+ if ( this.isScene ) {
+
+ if ( this.background ) {
+
+ if ( this.background.isColor ) {
+
+ object.background = this.background.toJSON();
+
+ } else if ( this.background.isTexture ) {
+
+ object.background = this.background.toJSON( meta ).uuid;
+
+ }
+
+ }
+
+ if ( this.environment && this.environment.isTexture ) {
+
+ object.environment = this.environment.toJSON( meta ).uuid;
+
+ }
+
+ } else if ( this.isMesh || this.isLine || this.isPoints ) {
+
+ object.geometry = serialize( meta.geometries, this.geometry );
+
+ const parameters = this.geometry.parameters;
+
+ if ( parameters !== undefined && parameters.shapes !== undefined ) {
+
+ const shapes = parameters.shapes;
+
+ if ( Array.isArray( shapes ) ) {
+
+ for ( let i = 0, l = shapes.length; i < l; i ++ ) {
+
+ const shape = shapes[ i ];
+
+ serialize( meta.shapes, shape );
+
+ }
+
+ } else {
+
+ serialize( meta.shapes, shapes );
+
+ }
+
+ }
+
+ }
+
+ if ( this.isSkinnedMesh ) {
+
+ object.bindMode = this.bindMode;
+ object.bindMatrix = this.bindMatrix.toArray();
+
+ if ( this.skeleton !== undefined ) {
+
+ serialize( meta.skeletons, this.skeleton );
+
+ object.skeleton = this.skeleton.uuid;
+
+ }
+
+ }
+
+ if ( this.material !== undefined ) {
+
+ if ( Array.isArray( this.material ) ) {
+
+ const uuids = [];
+
+ for ( let i = 0, l = this.material.length; i < l; i ++ ) {
+
+ uuids.push( serialize( meta.materials, this.material[ i ] ) );
+
+ }
+
+ object.material = uuids;
+
+ } else {
+
+ object.material = serialize( meta.materials, this.material );
+
+ }
+
+ }
+
+ //
+
+ if ( this.children.length > 0 ) {
+
+ object.children = [];
+
+ for ( let i = 0; i < this.children.length; i ++ ) {
+
+ object.children.push( this.children[ i ].toJSON( meta ).object );
+
+ }
+
+ }
+
+ //
+
+ if ( this.animations.length > 0 ) {
+
+ object.animations = [];
+
+ for ( let i = 0; i < this.animations.length; i ++ ) {
+
+ const animation = this.animations[ i ];
+
+ object.animations.push( serialize( meta.animations, animation ) );
+
+ }
+
+ }
+
+ if ( isRootObject ) {
+
+ const geometries = extractFromCache( meta.geometries );
+ const materials = extractFromCache( meta.materials );
+ const textures = extractFromCache( meta.textures );
+ const images = extractFromCache( meta.images );
+ const shapes = extractFromCache( meta.shapes );
+ const skeletons = extractFromCache( meta.skeletons );
+ const animations = extractFromCache( meta.animations );
+ const nodes = extractFromCache( meta.nodes );
+
+ if ( geometries.length > 0 ) output.geometries = geometries;
+ if ( materials.length > 0 ) output.materials = materials;
+ if ( textures.length > 0 ) output.textures = textures;
+ if ( images.length > 0 ) output.images = images;
+ if ( shapes.length > 0 ) output.shapes = shapes;
+ if ( skeletons.length > 0 ) output.skeletons = skeletons;
+ if ( animations.length > 0 ) output.animations = animations;
+ if ( nodes.length > 0 ) output.nodes = nodes;
+
+ }
+
+ output.object = object;
+
+ return output;
+
+ // extract data from the cache hash
+ // remove metadata on each item
+ // and return as array
+ function extractFromCache( cache ) {
+
+ const values = [];
+ for ( const key in cache ) {
+
+ const data = cache[ key ];
+ delete data.metadata;
+ values.push( data );
+
+ }
+
+ return values;
+
+ }
+
+ }
+
+ clone( recursive ) {
+
+ return new this.constructor().copy( this, recursive );
+
+ }
+
+ copy( source, recursive = true ) {
+
+ this.name = source.name;
+
+ this.up.copy( source.up );
+
+ this.position.copy( source.position );
+ this.rotation.order = source.rotation.order;
+ this.quaternion.copy( source.quaternion );
+ this.scale.copy( source.scale );
+
+ this.matrix.copy( source.matrix );
+ this.matrixWorld.copy( source.matrixWorld );
+
+ this.matrixAutoUpdate = source.matrixAutoUpdate;
+ this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
+
+ this.layers.mask = source.layers.mask;
+ this.visible = source.visible;
+
+ this.castShadow = source.castShadow;
+ this.receiveShadow = source.receiveShadow;
+
+ this.frustumCulled = source.frustumCulled;
+ this.renderOrder = source.renderOrder;
+
+ this.userData = JSON.parse( JSON.stringify( source.userData ) );
+
+ if ( recursive === true ) {
+
+ for ( let i = 0; i < source.children.length; i ++ ) {
+
+ const child = source.children[ i ];
+ this.add( child.clone() );
+
+ }
+
+ }
+
+ return this;
+
+ }
+
+}
+
+Object3D.DefaultUp = /*@__PURE__*/ new Vector3( 0, 1, 0 );
+Object3D.DefaultMatrixAutoUpdate = true;
+
+const _v0$1 = /*@__PURE__*/ new Vector3();
+const _v1$3 = /*@__PURE__*/ new Vector3();
+const _v2$2 = /*@__PURE__*/ new Vector3();
+const _v3$1 = /*@__PURE__*/ new Vector3();
+
+const _vab = /*@__PURE__*/ new Vector3();
+const _vac = /*@__PURE__*/ new Vector3();
+const _vbc = /*@__PURE__*/ new Vector3();
+const _vap = /*@__PURE__*/ new Vector3();
+const _vbp = /*@__PURE__*/ new Vector3();
+const _vcp = /*@__PURE__*/ new Vector3();
+
+class Triangle {
+
+ constructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) {
+
+ this.a = a;
+ this.b = b;
+ this.c = c;
+
+ }
+
+ static getNormal( a, b, c, target ) {
+
+ target.subVectors( c, b );
+ _v0$1.subVectors( a, b );
+ target.cross( _v0$1 );
+
+ const targetLengthSq = target.lengthSq();
+ if ( targetLengthSq > 0 ) {
+
+ return target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );
+
+ }
+
+ return target.set( 0, 0, 0 );
+
+ }
+
+ // static/instance method to calculate barycentric coordinates
+ // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
+ static getBarycoord( point, a, b, c, target ) {
+
+ _v0$1.subVectors( c, a );
+ _v1$3.subVectors( b, a );
+ _v2$2.subVectors( point, a );
+
+ const dot00 = _v0$1.dot( _v0$1 );
+ const dot01 = _v0$1.dot( _v1$3 );
+ const dot02 = _v0$1.dot( _v2$2 );
+ const dot11 = _v1$3.dot( _v1$3 );
+ const dot12 = _v1$3.dot( _v2$2 );
+
+ const denom = ( dot00 * dot11 - dot01 * dot01 );
+
+ // collinear or singular triangle
+ if ( denom === 0 ) {
+
+ // arbitrary location outside of triangle?
+ // not sure if this is the best idea, maybe should be returning undefined
+ return target.set( - 2, - 1, - 1 );
+
+ }
+
+ const invDenom = 1 / denom;
+ const u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
+ const v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
+
+ // barycentric coordinates must always sum to 1
+ return target.set( 1 - u - v, v, u );
+
+ }
+
+ static containsPoint( point, a, b, c ) {
+
+ this.getBarycoord( point, a, b, c, _v3$1 );
+
+ return ( _v3$1.x >= 0 ) && ( _v3$1.y >= 0 ) && ( ( _v3$1.x + _v3$1.y ) <= 1 );
+
+ }
+
+ static getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) {
+
+ this.getBarycoord( point, p1, p2, p3, _v3$1 );
+
+ target.set( 0, 0 );
+ target.addScaledVector( uv1, _v3$1.x );
+ target.addScaledVector( uv2, _v3$1.y );
+ target.addScaledVector( uv3, _v3$1.z );
+
+ return target;
+
+ }
+
+ static isFrontFacing( a, b, c, direction ) {
+
+ _v0$1.subVectors( c, b );
+ _v1$3.subVectors( a, b );
+
+ // strictly front facing
+ return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
+
+ }
+
+ set( a, b, c ) {
+
+ this.a.copy( a );
+ this.b.copy( b );
+ this.c.copy( c );
+
+ return this;
+
+ }
+
+ setFromPointsAndIndices( points, i0, i1, i2 ) {
+
+ this.a.copy( points[ i0 ] );
+ this.b.copy( points[ i1 ] );
+ this.c.copy( points[ i2 ] );
+
+ return this;
+
+ }
+
+ setFromAttributeAndIndices( attribute, i0, i1, i2 ) {
+
+ this.a.fromBufferAttribute( attribute, i0 );
+ this.b.fromBufferAttribute( attribute, i1 );
+ this.c.fromBufferAttribute( attribute, i2 );
+
+ return this;
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ copy( triangle ) {
+
+ this.a.copy( triangle.a );
+ this.b.copy( triangle.b );
+ this.c.copy( triangle.c );
+
+ return this;
+
+ }
+
+ getArea() {
+
+ _v0$1.subVectors( this.c, this.b );
+ _v1$3.subVectors( this.a, this.b );
+
+ return _v0$1.cross( _v1$3 ).length() * 0.5;
+
+ }
+
+ getMidpoint( target ) {
+
+ return target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );
+
+ }
+
+ getNormal( target ) {
+
+ return Triangle.getNormal( this.a, this.b, this.c, target );
+
+ }
+
+ getPlane( target ) {
+
+ return target.setFromCoplanarPoints( this.a, this.b, this.c );
+
+ }
+
+ getBarycoord( point, target ) {
+
+ return Triangle.getBarycoord( point, this.a, this.b, this.c, target );
+
+ }
+
+ getUV( point, uv1, uv2, uv3, target ) {
+
+ return Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target );
+
+ }
+
+ containsPoint( point ) {
+
+ return Triangle.containsPoint( point, this.a, this.b, this.c );
+
+ }
+
+ isFrontFacing( direction ) {
+
+ return Triangle.isFrontFacing( this.a, this.b, this.c, direction );
+
+ }
+
+ intersectsBox( box ) {
+
+ return box.intersectsTriangle( this );
+
+ }
+
+ closestPointToPoint( p, target ) {
+
+ const a = this.a, b = this.b, c = this.c;
+ let v, w;
+
+ // algorithm thanks to Real-Time Collision Detection by Christer Ericson,
+ // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,
+ // under the accompanying license; see chapter 5.1.5 for detailed explanation.
+ // basically, we're distinguishing which of the voronoi regions of the triangle
+ // the point lies in with the minimum amount of redundant computation.
+
+ _vab.subVectors( b, a );
+ _vac.subVectors( c, a );
+ _vap.subVectors( p, a );
+ const d1 = _vab.dot( _vap );
+ const d2 = _vac.dot( _vap );
+ if ( d1 <= 0 && d2 <= 0 ) {
+
+ // vertex region of A; barycentric coords (1, 0, 0)
+ return target.copy( a );
+
+ }
+
+ _vbp.subVectors( p, b );
+ const d3 = _vab.dot( _vbp );
+ const d4 = _vac.dot( _vbp );
+ if ( d3 >= 0 && d4 <= d3 ) {
+
+ // vertex region of B; barycentric coords (0, 1, 0)
+ return target.copy( b );
+
+ }
+
+ const vc = d1 * d4 - d3 * d2;
+ if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {
+
+ v = d1 / ( d1 - d3 );
+ // edge region of AB; barycentric coords (1-v, v, 0)
+ return target.copy( a ).addScaledVector( _vab, v );
+
+ }
+
+ _vcp.subVectors( p, c );
+ const d5 = _vab.dot( _vcp );
+ const d6 = _vac.dot( _vcp );
+ if ( d6 >= 0 && d5 <= d6 ) {
+
+ // vertex region of C; barycentric coords (0, 0, 1)
+ return target.copy( c );
+
+ }
+
+ const vb = d5 * d2 - d1 * d6;
+ if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {
+
+ w = d2 / ( d2 - d6 );
+ // edge region of AC; barycentric coords (1-w, 0, w)
+ return target.copy( a ).addScaledVector( _vac, w );
+
+ }
+
+ const va = d3 * d6 - d5 * d4;
+ if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {
+
+ _vbc.subVectors( c, b );
+ w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );
+ // edge region of BC; barycentric coords (0, 1-w, w)
+ return target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC
+
+ }
+
+ // face region
+ const denom = 1 / ( va + vb + vc );
+ // u = va * denom
+ v = vb * denom;
+ w = vc * denom;
+
+ return target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );
+
+ }
+
+ equals( triangle ) {
+
+ return triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );
+
+ }
+
+}
+
+let materialId = 0;
+
+class Material extends EventDispatcher {
+
+ constructor() {
+
+ super();
+
+ this.isMaterial = true;
+
+ Object.defineProperty( this, 'id', { value: materialId ++ } );
+
+ this.uuid = generateUUID();
+
+ this.name = '';
+ this.type = 'Material';
+
+ this.blending = NormalBlending;
+ this.side = FrontSide;
+ this.vertexColors = false;
+
+ this.opacity = 1;
+ this.transparent = false;
+
+ this.blendSrc = SrcAlphaFactor;
+ this.blendDst = OneMinusSrcAlphaFactor;
+ this.blendEquation = AddEquation;
+ this.blendSrcAlpha = null;
+ this.blendDstAlpha = null;
+ this.blendEquationAlpha = null;
+
+ this.depthFunc = LessEqualDepth;
+ this.depthTest = true;
+ this.depthWrite = true;
+
+ this.stencilWriteMask = 0xff;
+ this.stencilFunc = AlwaysStencilFunc;
+ this.stencilRef = 0;
+ this.stencilFuncMask = 0xff;
+ this.stencilFail = KeepStencilOp;
+ this.stencilZFail = KeepStencilOp;
+ this.stencilZPass = KeepStencilOp;
+ this.stencilWrite = false;
+
+ this.clippingPlanes = null;
+ this.clipIntersection = false;
+ this.clipShadows = false;
+
+ this.shadowSide = null;
+
+ this.colorWrite = true;
+
+ this.precision = null; // override the renderer's default precision for this material
+
+ this.polygonOffset = false;
+ this.polygonOffsetFactor = 0;
+ this.polygonOffsetUnits = 0;
+
+ this.dithering = false;
+
+ this.alphaToCoverage = false;
+ this.premultipliedAlpha = false;
+
+ this.visible = true;
+
+ this.toneMapped = true;
+
+ this.userData = {};
+
+ this.version = 0;
+
+ this._alphaTest = 0;
+
+ }
+
+ get alphaTest() {
+
+ return this._alphaTest;
+
+ }
+
+ set alphaTest( value ) {
+
+ if ( this._alphaTest > 0 !== value > 0 ) {
+
+ this.version ++;
+
+ }
+
+ this._alphaTest = value;
+
+ }
+
+ onBuild( /* shaderobject, renderer */ ) {}
+
+ onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}
+
+ onBeforeCompile( /* shaderobject, renderer */ ) {}
+
+ customProgramCacheKey() {
+
+ return this.onBeforeCompile.toString();
+
+ }
+
+ setValues( values ) {
+
+ if ( values === undefined ) return;
+
+ for ( const key in values ) {
+
+ const newValue = values[ key ];
+
+ if ( newValue === undefined ) {
+
+ console.warn( 'THREE.Material: \'' + key + '\' parameter is undefined.' );
+ continue;
+
+ }
+
+ // for backward compatibility if shading is set in the constructor
+ if ( key === 'shading' ) {
+
+ console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );
+ this.flatShading = ( newValue === FlatShading ) ? true : false;
+ continue;
+
+ }
+
+ const currentValue = this[ key ];
+
+ if ( currentValue === undefined ) {
+
+ console.warn( 'THREE.' + this.type + ': \'' + key + '\' is not a property of this material.' );
+ continue;
+
+ }
+
+ if ( currentValue && currentValue.isColor ) {
+
+ currentValue.set( newValue );
+
+ } else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {
+
+ currentValue.copy( newValue );
+
+ } else {
+
+ this[ key ] = newValue;
+
+ }
+
+ }
+
+ }
+
+ toJSON( meta ) {
+
+ const isRootObject = ( meta === undefined || typeof meta === 'string' );
+
+ if ( isRootObject ) {
+
+ meta = {
+ textures: {},
+ images: {}
+ };
+
+ }
+
+ const data = {
+ metadata: {
+ version: 4.5,
+ type: 'Material',
+ generator: 'Material.toJSON'
+ }
+ };
+
+ // standard Material serialization
+ data.uuid = this.uuid;
+ data.type = this.type;
+
+ if ( this.name !== '' ) data.name = this.name;
+
+ if ( this.color && this.color.isColor ) data.color = this.color.getHex();
+
+ if ( this.roughness !== undefined ) data.roughness = this.roughness;
+ if ( this.metalness !== undefined ) data.metalness = this.metalness;
+
+ if ( this.sheen !== undefined ) data.sheen = this.sheen;
+ if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
+ if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
+ if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
+ if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
+
+ if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
+ if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
+ if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex();
+ if ( this.shininess !== undefined ) data.shininess = this.shininess;
+ if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;
+ if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;
+
+ if ( this.clearcoatMap && this.clearcoatMap.isTexture ) {
+
+ data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;
+
+ }
+
+ if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {
+
+ data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;
+
+ }
+
+ if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {
+
+ data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;
+ data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
+
+ }
+
+ if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
+ if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
+ if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
+
+ if ( this.iridescenceMap && this.iridescenceMap.isTexture ) {
+
+ data.iridescenceMap = this.iridescenceMap.toJSON( meta ).uuid;
+
+ }
+
+ if ( this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture ) {
+
+ data.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON( meta ).uuid;
+
+ }
+
+ if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;
+ if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;
+ if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;
+
+ if ( this.lightMap && this.lightMap.isTexture ) {
+
+ data.lightMap = this.lightMap.toJSON( meta ).uuid;
+ data.lightMapIntensity = this.lightMapIntensity;
+
+ }
+
+ if ( this.aoMap && this.aoMap.isTexture ) {
+
+ data.aoMap = this.aoMap.toJSON( meta ).uuid;
+ data.aoMapIntensity = this.aoMapIntensity;
+
+ }
+
+ if ( this.bumpMap && this.bumpMap.isTexture ) {
+
+ data.bumpMap = this.bumpMap.toJSON( meta ).uuid;
+ data.bumpScale = this.bumpScale;
+
+ }
+
+ if ( this.normalMap && this.normalMap.isTexture ) {
+
+ data.normalMap = this.normalMap.toJSON( meta ).uuid;
+ data.normalMapType = this.normalMapType;
+ data.normalScale = this.normalScale.toArray();
+
+ }
+
+ if ( this.displacementMap && this.displacementMap.isTexture ) {
+
+ data.displacementMap = this.displacementMap.toJSON( meta ).uuid;
+ data.displacementScale = this.displacementScale;
+ data.displacementBias = this.displacementBias;
+
+ }
+
+ if ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;
+ if ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;
+
+ if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;
+ if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;
+ if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid;
+ if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid;
+
+ if ( this.envMap && this.envMap.isTexture ) {
+
+ data.envMap = this.envMap.toJSON( meta ).uuid;
+
+ if ( this.combine !== undefined ) data.combine = this.combine;
+
+ }
+
+ if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
+ if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;
+ if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;
+
+ if ( this.gradientMap && this.gradientMap.isTexture ) {
+
+ data.gradientMap = this.gradientMap.toJSON( meta ).uuid;
+
+ }
+
+ if ( this.transmission !== undefined ) data.transmission = this.transmission;
+ if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;
+ if ( this.thickness !== undefined ) data.thickness = this.thickness;
+ if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
+ if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance;
+ if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
+
+ if ( this.size !== undefined ) data.size = this.size;
+ if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;
+ if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;
+
+ if ( this.blending !== NormalBlending ) data.blending = this.blending;
+ if ( this.side !== FrontSide ) data.side = this.side;
+ if ( this.vertexColors ) data.vertexColors = true;
+
+ if ( this.opacity < 1 ) data.opacity = this.opacity;
+ if ( this.transparent === true ) data.transparent = this.transparent;
+
+ data.depthFunc = this.depthFunc;
+ data.depthTest = this.depthTest;
+ data.depthWrite = this.depthWrite;
+ data.colorWrite = this.colorWrite;
+
+ data.stencilWrite = this.stencilWrite;
+ data.stencilWriteMask = this.stencilWriteMask;
+ data.stencilFunc = this.stencilFunc;
+ data.stencilRef = this.stencilRef;
+ data.stencilFuncMask = this.stencilFuncMask;
+ data.stencilFail = this.stencilFail;
+ data.stencilZFail = this.stencilZFail;
+ data.stencilZPass = this.stencilZPass;
+
+ // rotation (SpriteMaterial)
+ if ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation;
+
+ if ( this.polygonOffset === true ) data.polygonOffset = true;
+ if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
+ if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
+
+ if ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth;
+ if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
+ if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
+ if ( this.scale !== undefined ) data.scale = this.scale;
+
+ if ( this.dithering === true ) data.dithering = true;
+
+ if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
+ if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage;
+ if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
+
+ if ( this.wireframe === true ) data.wireframe = this.wireframe;
+ if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
+ if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
+ if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
+
+ if ( this.flatShading === true ) data.flatShading = this.flatShading;
+
+ if ( this.visible === false ) data.visible = false;
+
+ if ( this.toneMapped === false ) data.toneMapped = false;
+
+ if ( this.fog === false ) data.fog = false;
+
+ if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
+
+ // TODO: Copied from Object3D.toJSON
+
+ function extractFromCache( cache ) {
+
+ const values = [];
+
+ for ( const key in cache ) {
+
+ const data = cache[ key ];
+ delete data.metadata;
+ values.push( data );
+
+ }
+
+ return values;
+
+ }
+
+ if ( isRootObject ) {
+
+ const textures = extractFromCache( meta.textures );
+ const images = extractFromCache( meta.images );
+
+ if ( textures.length > 0 ) data.textures = textures;
+ if ( images.length > 0 ) data.images = images;
+
+ }
+
+ return data;
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ copy( source ) {
+
+ this.name = source.name;
+
+ this.blending = source.blending;
+ this.side = source.side;
+ this.vertexColors = source.vertexColors;
+
+ this.opacity = source.opacity;
+ this.transparent = source.transparent;
+
+ this.blendSrc = source.blendSrc;
+ this.blendDst = source.blendDst;
+ this.blendEquation = source.blendEquation;
+ this.blendSrcAlpha = source.blendSrcAlpha;
+ this.blendDstAlpha = source.blendDstAlpha;
+ this.blendEquationAlpha = source.blendEquationAlpha;
+
+ this.depthFunc = source.depthFunc;
+ this.depthTest = source.depthTest;
+ this.depthWrite = source.depthWrite;
+
+ this.stencilWriteMask = source.stencilWriteMask;
+ this.stencilFunc = source.stencilFunc;
+ this.stencilRef = source.stencilRef;
+ this.stencilFuncMask = source.stencilFuncMask;
+ this.stencilFail = source.stencilFail;
+ this.stencilZFail = source.stencilZFail;
+ this.stencilZPass = source.stencilZPass;
+ this.stencilWrite = source.stencilWrite;
+
+ const srcPlanes = source.clippingPlanes;
+ let dstPlanes = null;
+
+ if ( srcPlanes !== null ) {
+
+ const n = srcPlanes.length;
+ dstPlanes = new Array( n );
+
+ for ( let i = 0; i !== n; ++ i ) {
+
+ dstPlanes[ i ] = srcPlanes[ i ].clone();
+
+ }
+
+ }
+
+ this.clippingPlanes = dstPlanes;
+ this.clipIntersection = source.clipIntersection;
+ this.clipShadows = source.clipShadows;
+
+ this.shadowSide = source.shadowSide;
+
+ this.colorWrite = source.colorWrite;
+
+ this.precision = source.precision;
+
+ this.polygonOffset = source.polygonOffset;
+ this.polygonOffsetFactor = source.polygonOffsetFactor;
+ this.polygonOffsetUnits = source.polygonOffsetUnits;
+
+ this.dithering = source.dithering;
+
+ this.alphaTest = source.alphaTest;
+ this.alphaToCoverage = source.alphaToCoverage;
+ this.premultipliedAlpha = source.premultipliedAlpha;
+
+ this.visible = source.visible;
+
+ this.toneMapped = source.toneMapped;
+
+ this.userData = JSON.parse( JSON.stringify( source.userData ) );
+
+ return this;
+
+ }
+
+ dispose() {
+
+ this.dispatchEvent( { type: 'dispose' } );
+
+ }
+
+ set needsUpdate( value ) {
+
+ if ( value === true ) this.version ++;
+
+ }
+
+}
+
+class MeshBasicMaterial extends Material {
+
+ constructor( parameters ) {
+
+ super();
+
+ this.isMeshBasicMaterial = true;
+
+ this.type = 'MeshBasicMaterial';
+
+ this.color = new Color( 0xffffff ); // emissive
+
+ this.map = null;
+
+ this.lightMap = null;
+ this.lightMapIntensity = 1.0;
+
+ this.aoMap = null;
+ this.aoMapIntensity = 1.0;
+
+ this.specularMap = null;
+
+ this.alphaMap = null;
+
+ this.envMap = null;
+ this.combine = MultiplyOperation;
+ this.reflectivity = 1;
+ this.refractionRatio = 0.98;
+
+ this.wireframe = false;
+ this.wireframeLinewidth = 1;
+ this.wireframeLinecap = 'round';
+ this.wireframeLinejoin = 'round';
+
+ this.fog = true;
+
+ this.setValues( parameters );
+
+ }
+
+ copy( source ) {
+
+ super.copy( source );
+
+ this.color.copy( source.color );
+
+ this.map = source.map;
+
+ this.lightMap = source.lightMap;
+ this.lightMapIntensity = source.lightMapIntensity;
+
+ this.aoMap = source.aoMap;
+ this.aoMapIntensity = source.aoMapIntensity;
+
+ this.specularMap = source.specularMap;
+
+ this.alphaMap = source.alphaMap;
+
+ this.envMap = source.envMap;
+ this.combine = source.combine;
+ this.reflectivity = source.reflectivity;
+ this.refractionRatio = source.refractionRatio;
+
+ this.wireframe = source.wireframe;
+ this.wireframeLinewidth = source.wireframeLinewidth;
+ this.wireframeLinecap = source.wireframeLinecap;
+ this.wireframeLinejoin = source.wireframeLinejoin;
+
+ this.fog = source.fog;
+
+ return this;
+
+ }
+
+}
+
+const _vector$9 = /*@__PURE__*/ new Vector3();
+const _vector2$1 = /*@__PURE__*/ new Vector2();
+
+class BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ if ( Array.isArray( array ) ) {
+
+ throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
+
+ }
+
+ this.isBufferAttribute = true;
+
+ this.name = '';
+
+ this.array = array;
+ this.itemSize = itemSize;
+ this.count = array !== undefined ? array.length / itemSize : 0;
+ this.normalized = normalized === true;
+
+ this.usage = StaticDrawUsage;
+ this.updateRange = { offset: 0, count: - 1 };
+
+ this.version = 0;
+
+ }
+
+ onUploadCallback() {}
+
+ set needsUpdate( value ) {
+
+ if ( value === true ) this.version ++;
+
+ }
+
+ setUsage( value ) {
+
+ this.usage = value;
+
+ return this;
+
+ }
+
+ copy( source ) {
+
+ this.name = source.name;
+ this.array = new source.array.constructor( source.array );
+ this.itemSize = source.itemSize;
+ this.count = source.count;
+ this.normalized = source.normalized;
+
+ this.usage = source.usage;
+
+ return this;
+
+ }
+
+ copyAt( index1, attribute, index2 ) {
+
+ index1 *= this.itemSize;
+ index2 *= attribute.itemSize;
+
+ for ( let i = 0, l = this.itemSize; i < l; i ++ ) {
+
+ this.array[ index1 + i ] = attribute.array[ index2 + i ];
+
+ }
+
+ return this;
+
+ }
+
+ copyArray( array ) {
+
+ this.array.set( array );
+
+ return this;
+
+ }
+
+ copyColorsArray( colors ) {
+
+ const array = this.array;
+ let offset = 0;
+
+ for ( let i = 0, l = colors.length; i < l; i ++ ) {
+
+ let color = colors[ i ];
+
+ if ( color === undefined ) {
+
+ console.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );
+ color = new Color();
+
+ }
+
+ array[ offset ++ ] = color.r;
+ array[ offset ++ ] = color.g;
+ array[ offset ++ ] = color.b;
+
+ }
+
+ return this;
+
+ }
+
+ copyVector2sArray( vectors ) {
+
+ const array = this.array;
+ let offset = 0;
+
+ for ( let i = 0, l = vectors.length; i < l; i ++ ) {
+
+ let vector = vectors[ i ];
+
+ if ( vector === undefined ) {
+
+ console.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );
+ vector = new Vector2();
+
+ }
+
+ array[ offset ++ ] = vector.x;
+ array[ offset ++ ] = vector.y;
+
+ }
+
+ return this;
+
+ }
+
+ copyVector3sArray( vectors ) {
+
+ const array = this.array;
+ let offset = 0;
+
+ for ( let i = 0, l = vectors.length; i < l; i ++ ) {
+
+ let vector = vectors[ i ];
+
+ if ( vector === undefined ) {
+
+ console.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );
+ vector = new Vector3();
+
+ }
+
+ array[ offset ++ ] = vector.x;
+ array[ offset ++ ] = vector.y;
+ array[ offset ++ ] = vector.z;
+
+ }
+
+ return this;
+
+ }
+
+ copyVector4sArray( vectors ) {
+
+ const array = this.array;
+ let offset = 0;
+
+ for ( let i = 0, l = vectors.length; i < l; i ++ ) {
+
+ let vector = vectors[ i ];
+
+ if ( vector === undefined ) {
+
+ console.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );
+ vector = new Vector4();
+
+ }
+
+ array[ offset ++ ] = vector.x;
+ array[ offset ++ ] = vector.y;
+ array[ offset ++ ] = vector.z;
+ array[ offset ++ ] = vector.w;
+
+ }
+
+ return this;
+
+ }
+
+ applyMatrix3( m ) {
+
+ if ( this.itemSize === 2 ) {
+
+ for ( let i = 0, l = this.count; i < l; i ++ ) {
+
+ _vector2$1.fromBufferAttribute( this, i );
+ _vector2$1.applyMatrix3( m );
+
+ this.setXY( i, _vector2$1.x, _vector2$1.y );
+
+ }
+
+ } else if ( this.itemSize === 3 ) {
+
+ for ( let i = 0, l = this.count; i < l; i ++ ) {
+
+ _vector$9.fromBufferAttribute( this, i );
+ _vector$9.applyMatrix3( m );
+
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
+
+ }
+
+ }
+
+ return this;
+
+ }
+
+ applyMatrix4( m ) {
+
+ for ( let i = 0, l = this.count; i < l; i ++ ) {
+
+ _vector$9.fromBufferAttribute( this, i );
+
+ _vector$9.applyMatrix4( m );
+
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
+
+ }
+
+ return this;
+
+ }
+
+ applyNormalMatrix( m ) {
+
+ for ( let i = 0, l = this.count; i < l; i ++ ) {
+
+ _vector$9.fromBufferAttribute( this, i );
+
+ _vector$9.applyNormalMatrix( m );
+
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
+
+ }
+
+ return this;
+
+ }
+
+ transformDirection( m ) {
+
+ for ( let i = 0, l = this.count; i < l; i ++ ) {
+
+ _vector$9.fromBufferAttribute( this, i );
+
+ _vector$9.transformDirection( m );
+
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
+
+ }
+
+ return this;
+
+ }
+
+ set( value, offset = 0 ) {
+
+ this.array.set( value, offset );
+
+ return this;
+
+ }
+
+ getX( index ) {
+
+ return this.array[ index * this.itemSize ];
+
+ }
+
+ setX( index, x ) {
+
+ this.array[ index * this.itemSize ] = x;
+
+ return this;
+
+ }
+
+ getY( index ) {
+
+ return this.array[ index * this.itemSize + 1 ];
+
+ }
+
+ setY( index, y ) {
+
+ this.array[ index * this.itemSize + 1 ] = y;
+
+ return this;
+
+ }
+
+ getZ( index ) {
+
+ return this.array[ index * this.itemSize + 2 ];
+
+ }
+
+ setZ( index, z ) {
+
+ this.array[ index * this.itemSize + 2 ] = z;
+
+ return this;
+
+ }
+
+ getW( index ) {
+
+ return this.array[ index * this.itemSize + 3 ];
+
+ }
+
+ setW( index, w ) {
+
+ this.array[ index * this.itemSize + 3 ] = w;
+
+ return this;
+
+ }
+
+ setXY( index, x, y ) {
+
+ index *= this.itemSize;
+
+ this.array[ index + 0 ] = x;
+ this.array[ index + 1 ] = y;
+
+ return this;
+
+ }
+
+ setXYZ( index, x, y, z ) {
+
+ index *= this.itemSize;
+
+ this.array[ index + 0 ] = x;
+ this.array[ index + 1 ] = y;
+ this.array[ index + 2 ] = z;
+
+ return this;
+
+ }
+
+ setXYZW( index, x, y, z, w ) {
+
+ index *= this.itemSize;
+
+ this.array[ index + 0 ] = x;
+ this.array[ index + 1 ] = y;
+ this.array[ index + 2 ] = z;
+ this.array[ index + 3 ] = w;
+
+ return this;
+
+ }
+
+ onUpload( callback ) {
+
+ this.onUploadCallback = callback;
+
+ return this;
+
+ }
+
+ clone() {
+
+ return new this.constructor( this.array, this.itemSize ).copy( this );
+
+ }
+
+ toJSON() {
+
+ const data = {
+ itemSize: this.itemSize,
+ type: this.array.constructor.name,
+ array: Array.from( this.array ),
+ normalized: this.normalized
+ };
+
+ if ( this.name !== '' ) data.name = this.name;
+ if ( this.usage !== StaticDrawUsage ) data.usage = this.usage;
+ if ( this.updateRange.offset !== 0 || this.updateRange.count !== - 1 ) data.updateRange = this.updateRange;
+
+ return data;
+
+ }
+
+}
+
+//
+
+class Int8BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Int8Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Uint8BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Uint8Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Uint8ClampedBufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Uint8ClampedArray( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Int16BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Int16Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Uint16BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Uint16Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Int32BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Int32Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Uint32BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Uint32Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Float16BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Uint16Array( array ), itemSize, normalized );
+
+ this.isFloat16BufferAttribute = true;
+
+ }
+
+}
+
+
+class Float32BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Float32Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+class Float64BufferAttribute extends BufferAttribute {
+
+ constructor( array, itemSize, normalized ) {
+
+ super( new Float64Array( array ), itemSize, normalized );
+
+ }
+
+}
+
+let _id$1 = 0;
+
+const _m1 = /*@__PURE__*/ new Matrix4();
+const _obj = /*@__PURE__*/ new Object3D();
+const _offset = /*@__PURE__*/ new Vector3();
+const _box$1 = /*@__PURE__*/ new Box3();
+const _boxMorphTargets = /*@__PURE__*/ new Box3();
+const _vector$8 = /*@__PURE__*/ new Vector3();
+
+class BufferGeometry extends EventDispatcher {
+
+ constructor() {
+
+ super();
+
+ this.isBufferGeometry = true;
+
+ Object.defineProperty( this, 'id', { value: _id$1 ++ } );
+
+ this.uuid = generateUUID();
+
+ this.name = '';
+ this.type = 'BufferGeometry';
+
+ this.index = null;
+ this.attributes = {};
+
+ this.morphAttributes = {};
+ this.morphTargetsRelative = false;
+
+ this.groups = [];
+
+ this.boundingBox = null;
+ this.boundingSphere = null;
+
+ this.drawRange = { start: 0, count: Infinity };
+
+ this.userData = {};
+
+ }
+
+ getIndex() {
+
+ return this.index;
+
+ }
+
+ setIndex( index ) {
+
+ if ( Array.isArray( index ) ) {
+
+ this.index = new ( arrayNeedsUint32( index ) ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );
+
+ } else {
+
+ this.index = index;
+
+ }
+
+ return this;
+
+ }
+
+ getAttribute( name ) {
+
+ return this.attributes[ name ];
+
+ }
+
+ setAttribute( name, attribute ) {
+
+ this.attributes[ name ] = attribute;
+
+ return this;
+
+ }
+
+ deleteAttribute( name ) {
+
+ delete this.attributes[ name ];
+
+ return this;
+
+ }
+
+ hasAttribute( name ) {
+
+ return this.attributes[ name ] !== undefined;
+
+ }
+
+ addGroup( start, count, materialIndex = 0 ) {
+
+ this.groups.push( {
+
+ start: start,
+ count: count,
+ materialIndex: materialIndex
+
+ } );
+
+ }
+
+ clearGroups() {
+
+ this.groups = [];
+
+ }
+
+ setDrawRange( start, count ) {
+
+ this.drawRange.start = start;
+ this.drawRange.count = count;
+
+ }
+
+ applyMatrix4( matrix ) {
+
+ const position = this.attributes.position;
+
+ if ( position !== undefined ) {
+
+ position.applyMatrix4( matrix );
+
+ position.needsUpdate = true;
+
+ }
+
+ const normal = this.attributes.normal;
+
+ if ( normal !== undefined ) {
+
+ const normalMatrix = new Matrix3().getNormalMatrix( matrix );
+
+ normal.applyNormalMatrix( normalMatrix );
+
+ normal.needsUpdate = true;
+
+ }
+
+ const tangent = this.attributes.tangent;
+
+ if ( tangent !== undefined ) {
+
+ tangent.transformDirection( matrix );
+
+ tangent.needsUpdate = true;
+
+ }
+
+ if ( this.boundingBox !== null ) {
+
+ this.computeBoundingBox();
+
+ }
+
+ if ( this.boundingSphere !== null ) {
+
+ this.computeBoundingSphere();
+
+ }
+
+ return this;
+
+ }
+
+ applyQuaternion( q ) {
+
+ _m1.makeRotationFromQuaternion( q );
+
+ this.applyMatrix4( _m1 );
+
+ return this;
+
+ }
+
+ rotateX( angle ) {
+
+ // rotate geometry around world x-axis
+
+ _m1.makeRotationX( angle );
+
+ this.applyMatrix4( _m1 );
+
+ return this;
+
+ }
+
+ rotateY( angle ) {
+
+ // rotate geometry around world y-axis
+
+ _m1.makeRotationY( angle );
+
+ this.applyMatrix4( _m1 );
+
+ return this;
+
+ }
+
+ rotateZ( angle ) {
+
+ // rotate geometry around world z-axis
+
+ _m1.makeRotationZ( angle );
+
+ this.applyMatrix4( _m1 );
+
+ return this;
+
+ }
+
+ translate( x, y, z ) {
+
+ // translate geometry
+
+ _m1.makeTranslation( x, y, z );
+
+ this.applyMatrix4( _m1 );
+
+ return this;
+
+ }
+
+ scale( x, y, z ) {
+
+ // scale geometry
+
+ _m1.makeScale( x, y, z );
+
+ this.applyMatrix4( _m1 );
+
+ return this;
+
+ }
+
+ lookAt( vector ) {
+
+ _obj.lookAt( vector );
+
+ _obj.updateMatrix();
+
+ this.applyMatrix4( _obj.matrix );
+
+ return this;
+
+ }
+
+ center() {
+
+ this.computeBoundingBox();
+
+ this.boundingBox.getCenter( _offset ).negate();
+
+ this.translate( _offset.x, _offset.y, _offset.z );
+
+ return this;
+
+ }
+
+ setFromPoints( points ) {
+
+ const position = [];
+
+ for ( let i = 0, l = points.length; i < l; i ++ ) {
+
+ const point = points[ i ];
+ position.push( point.x, point.y, point.z || 0 );
+
+ }
+
+ this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
+
+ return this;
+
+ }
+
+ computeBoundingBox() {
+
+ if ( this.boundingBox === null ) {
+
+ this.boundingBox = new Box3();
+
+ }
+
+ const position = this.attributes.position;
+ const morphAttributesPosition = this.morphAttributes.position;
+
+ if ( position && position.isGLBufferAttribute ) {
+
+ console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this );
+
+ this.boundingBox.set(
+ new Vector3( - Infinity, - Infinity, - Infinity ),
+ new Vector3( + Infinity, + Infinity, + Infinity )
+ );
+
+ return;
+
+ }
+
+ if ( position !== undefined ) {
+
+ this.boundingBox.setFromBufferAttribute( position );
+
+ // process morph attributes if present
+
+ if ( morphAttributesPosition ) {
+
+ for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+
+ const morphAttribute = morphAttributesPosition[ i ];
+ _box$1.setFromBufferAttribute( morphAttribute );
+
+ if ( this.morphTargetsRelative ) {
+
+ _vector$8.addVectors( this.boundingBox.min, _box$1.min );
+ this.boundingBox.expandByPoint( _vector$8 );
+
+ _vector$8.addVectors( this.boundingBox.max, _box$1.max );
+ this.boundingBox.expandByPoint( _vector$8 );
+
+ } else {
+
+ this.boundingBox.expandByPoint( _box$1.min );
+ this.boundingBox.expandByPoint( _box$1.max );
+
+ }
+
+ }
+
+ }
+
+ } else {
+
+ this.boundingBox.makeEmpty();
+
+ }
+
+ if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
+
+ console.error( 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
+
+ }
+
+ }
+
+ computeBoundingSphere() {
+
+ if ( this.boundingSphere === null ) {
+
+ this.boundingSphere = new Sphere();
+
+ }
+
+ const position = this.attributes.position;
+ const morphAttributesPosition = this.morphAttributes.position;
+
+ if ( position && position.isGLBufferAttribute ) {
+
+ console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this );
+
+ this.boundingSphere.set( new Vector3(), Infinity );
+
+ return;
+
+ }
+
+ if ( position ) {
+
+ // first, find the center of the bounding sphere
+
+ const center = this.boundingSphere.center;
+
+ _box$1.setFromBufferAttribute( position );
+
+ // process morph attributes if present
+
+ if ( morphAttributesPosition ) {
+
+ for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+
+ const morphAttribute = morphAttributesPosition[ i ];
+ _boxMorphTargets.setFromBufferAttribute( morphAttribute );
+
+ if ( this.morphTargetsRelative ) {
+
+ _vector$8.addVectors( _box$1.min, _boxMorphTargets.min );
+ _box$1.expandByPoint( _vector$8 );
+
+ _vector$8.addVectors( _box$1.max, _boxMorphTargets.max );
+ _box$1.expandByPoint( _vector$8 );
+
+ } else {
+
+ _box$1.expandByPoint( _boxMorphTargets.min );
+ _box$1.expandByPoint( _boxMorphTargets.max );
+
+ }
+
+ }
+
+ }
+
+ _box$1.getCenter( center );
+
+ // second, try to find a boundingSphere with a radius smaller than the
+ // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
+
+ let maxRadiusSq = 0;
+
+ for ( let i = 0, il = position.count; i < il; i ++ ) {
+
+ _vector$8.fromBufferAttribute( position, i );
+
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
+
+ }
+
+ // process morph attributes if present
+
+ if ( morphAttributesPosition ) {
+
+ for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+
+ const morphAttribute = morphAttributesPosition[ i ];
+ const morphTargetsRelative = this.morphTargetsRelative;
+
+ for ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
+
+ _vector$8.fromBufferAttribute( morphAttribute, j );
+
+ if ( morphTargetsRelative ) {
+
+ _offset.fromBufferAttribute( position, j );
+ _vector$8.add( _offset );
+
+ }
+
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
+
+ }
+
+ }
+
+ }
+
+ this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
+
+ if ( isNaN( this.boundingSphere.radius ) ) {
+
+ console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
+
+ }
+
+ }
+
+ }
+
+ computeTangents() {
+
+ const index = this.index;
+ const attributes = this.attributes;
+
+ // based on http://www.terathon.com/code/tangent.html
+ // (per vertex tangents)
+
+ if ( index === null ||
+ attributes.position === undefined ||
+ attributes.normal === undefined ||
+ attributes.uv === undefined ) {
+
+ console.error( 'THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' );
+ return;
+
+ }
+
+ const indices = index.array;
+ const positions = attributes.position.array;
+ const normals = attributes.normal.array;
+ const uvs = attributes.uv.array;
+
+ const nVertices = positions.length / 3;
+
+ if ( this.hasAttribute( 'tangent' ) === false ) {
+
+ this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) );
+
+ }
+
+ const tangents = this.getAttribute( 'tangent' ).array;
+
+ const tan1 = [], tan2 = [];
+
+ for ( let i = 0; i < nVertices; i ++ ) {
+
+ tan1[ i ] = new Vector3();
+ tan2[ i ] = new Vector3();
+
+ }
+
+ const vA = new Vector3(),
+ vB = new Vector3(),
+ vC = new Vector3(),
+
+ uvA = new Vector2(),
+ uvB = new Vector2(),
+ uvC = new Vector2(),
+
+ sdir = new Vector3(),
+ tdir = new Vector3();
+
+ function handleTriangle( a, b, c ) {
+
+ vA.fromArray( positions, a * 3 );
+ vB.fromArray( positions, b * 3 );
+ vC.fromArray( positions, c * 3 );
+
+ uvA.fromArray( uvs, a * 2 );
+ uvB.fromArray( uvs, b * 2 );
+ uvC.fromArray( uvs, c * 2 );
+
+ vB.sub( vA );
+ vC.sub( vA );
+
+ uvB.sub( uvA );
+ uvC.sub( uvA );
+
+ const r = 1.0 / ( uvB.x * uvC.y - uvC.x * uvB.y );
+
+ // silently ignore degenerate uv triangles having coincident or colinear vertices
+
+ if ( ! isFinite( r ) ) return;
+
+ sdir.copy( vB ).multiplyScalar( uvC.y ).addScaledVector( vC, - uvB.y ).multiplyScalar( r );
+ tdir.copy( vC ).multiplyScalar( uvB.x ).addScaledVector( vB, - uvC.x ).multiplyScalar( r );
+
+ tan1[ a ].add( sdir );
+ tan1[ b ].add( sdir );
+ tan1[ c ].add( sdir );
+
+ tan2[ a ].add( tdir );
+ tan2[ b ].add( tdir );
+ tan2[ c ].add( tdir );
+
+ }
+
+ let groups = this.groups;
+
+ if ( groups.length === 0 ) {
+
+ groups = [ {
+ start: 0,
+ count: indices.length
+ } ];
+
+ }
+
+ for ( let i = 0, il = groups.length; i < il; ++ i ) {
+
+ const group = groups[ i ];
+
+ const start = group.start;
+ const count = group.count;
+
+ for ( let j = start, jl = start + count; j < jl; j += 3 ) {
+
+ handleTriangle(
+ indices[ j + 0 ],
+ indices[ j + 1 ],
+ indices[ j + 2 ]
+ );
+
+ }
+
+ }
+
+ const tmp = new Vector3(), tmp2 = new Vector3();
+ const n = new Vector3(), n2 = new Vector3();
+
+ function handleVertex( v ) {
+
+ n.fromArray( normals, v * 3 );
+ n2.copy( n );
+
+ const t = tan1[ v ];
+
+ // Gram-Schmidt orthogonalize
+
+ tmp.copy( t );
+ tmp.sub( n.multiplyScalar( n.dot( t ) ) ).normalize();
+
+ // Calculate handedness
+
+ tmp2.crossVectors( n2, t );
+ const test = tmp2.dot( tan2[ v ] );
+ const w = ( test < 0.0 ) ? - 1.0 : 1.0;
+
+ tangents[ v * 4 ] = tmp.x;
+ tangents[ v * 4 + 1 ] = tmp.y;
+ tangents[ v * 4 + 2 ] = tmp.z;
+ tangents[ v * 4 + 3 ] = w;
+
+ }
+
+ for ( let i = 0, il = groups.length; i < il; ++ i ) {
+
+ const group = groups[ i ];
+
+ const start = group.start;
+ const count = group.count;
+
+ for ( let j = start, jl = start + count; j < jl; j += 3 ) {
+
+ handleVertex( indices[ j + 0 ] );
+ handleVertex( indices[ j + 1 ] );
+ handleVertex( indices[ j + 2 ] );
+
+ }
+
+ }
+
+ }
+
+ computeVertexNormals() {
+
+ const index = this.index;
+ const positionAttribute = this.getAttribute( 'position' );
+
+ if ( positionAttribute !== undefined ) {
+
+ let normalAttribute = this.getAttribute( 'normal' );
+
+ if ( normalAttribute === undefined ) {
+
+ normalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );
+ this.setAttribute( 'normal', normalAttribute );
+
+ } else {
+
+ // reset existing normals to zero
+
+ for ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {
+
+ normalAttribute.setXYZ( i, 0, 0, 0 );
+
+ }
+
+ }
+
+ const pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
+ const nA = new Vector3(), nB = new Vector3(), nC = new Vector3();
+ const cb = new Vector3(), ab = new Vector3();
+
+ // indexed elements
+
+ if ( index ) {
+
+ for ( let i = 0, il = index.count; i < il; i += 3 ) {
+
+ const vA = index.getX( i + 0 );
+ const vB = index.getX( i + 1 );
+ const vC = index.getX( i + 2 );
+
+ pA.fromBufferAttribute( positionAttribute, vA );
+ pB.fromBufferAttribute( positionAttribute, vB );
+ pC.fromBufferAttribute( positionAttribute, vC );
+
+ cb.subVectors( pC, pB );
+ ab.subVectors( pA, pB );
+ cb.cross( ab );
+
+ nA.fromBufferAttribute( normalAttribute, vA );
+ nB.fromBufferAttribute( normalAttribute, vB );
+ nC.fromBufferAttribute( normalAttribute, vC );
+
+ nA.add( cb );
+ nB.add( cb );
+ nC.add( cb );
+
+ normalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );
+ normalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );
+ normalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );
+
+ }
+
+ } else {
+
+ // non-indexed elements (unconnected triangle soup)
+
+ for ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {
+
+ pA.fromBufferAttribute( positionAttribute, i + 0 );
+ pB.fromBufferAttribute( positionAttribute, i + 1 );
+ pC.fromBufferAttribute( positionAttribute, i + 2 );
+
+ cb.subVectors( pC, pB );
+ ab.subVectors( pA, pB );
+ cb.cross( ab );
+
+ normalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );
+ normalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );
+ normalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );
+
+ }
+
+ }
+
+ this.normalizeNormals();
+
+ normalAttribute.needsUpdate = true;
+
+ }
+
+ }
+
+ merge( geometry, offset ) {
+
+ if ( ! ( geometry && geometry.isBufferGeometry ) ) {
+
+ console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );
+ return;
+
+ }
+
+ if ( offset === undefined ) {
+
+ offset = 0;
+
+ console.warn(
+ 'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '
+ + 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.'
+ );
+
+ }
+
+ const attributes = this.attributes;
+
+ for ( const key in attributes ) {
+
+ if ( geometry.attributes[ key ] === undefined ) continue;
+
+ const attribute1 = attributes[ key ];
+ const attributeArray1 = attribute1.array;
+
+ const attribute2 = geometry.attributes[ key ];
+ const attributeArray2 = attribute2.array;
+
+ const attributeOffset = attribute2.itemSize * offset;
+ const length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset );
+
+ for ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) {
+
+ attributeArray1[ j ] = attributeArray2[ i ];
+
+ }
+
+ }
+
+ return this;
+
+ }
+
+ normalizeNormals() {
+
+ const normals = this.attributes.normal;
+
+ for ( let i = 0, il = normals.count; i < il; i ++ ) {
+
+ _vector$8.fromBufferAttribute( normals, i );
+
+ _vector$8.normalize();
+
+ normals.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
+
+ }
+
+ }
+
+ toNonIndexed() {
+
+ function convertBufferAttribute( attribute, indices ) {
+
+ const array = attribute.array;
+ const itemSize = attribute.itemSize;
+ const normalized = attribute.normalized;
+
+ const array2 = new array.constructor( indices.length * itemSize );
+
+ let index = 0, index2 = 0;
+
+ for ( let i = 0, l = indices.length; i < l; i ++ ) {
+
+ if ( attribute.isInterleavedBufferAttribute ) {
+
+ index = indices[ i ] * attribute.data.stride + attribute.offset;
+
+ } else {
+
+ index = indices[ i ] * itemSize;
+
+ }
+
+ for ( let j = 0; j < itemSize; j ++ ) {
+
+ array2[ index2 ++ ] = array[ index ++ ];
+
+ }
+
+ }
+
+ return new BufferAttribute( array2, itemSize, normalized );
+
+ }
+
+ //
+
+ if ( this.index === null ) {
+
+ console.warn( 'THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );
+ return this;
+
+ }
+
+ const geometry2 = new BufferGeometry();
+
+ const indices = this.index.array;
+ const attributes = this.attributes;
+
+ // attributes
+
+ for ( const name in attributes ) {
+
+ const attribute = attributes[ name ];
+
+ const newAttribute = convertBufferAttribute( attribute, indices );
+
+ geometry2.setAttribute( name, newAttribute );
+
+ }
+
+ // morph attributes
+
+ const morphAttributes = this.morphAttributes;
+
+ for ( const name in morphAttributes ) {
+
+ const morphArray = [];
+ const morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes
+
+ for ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {
+
+ const attribute = morphAttribute[ i ];
+
+ const newAttribute = convertBufferAttribute( attribute, indices );
+
+ morphArray.push( newAttribute );
+
+ }
+
+ geometry2.morphAttributes[ name ] = morphArray;
+
+ }
+
+ geometry2.morphTargetsRelative = this.morphTargetsRelative;
+
+ // groups
+
+ const groups = this.groups;
+
+ for ( let i = 0, l = groups.length; i < l; i ++ ) {
+
+ const group = groups[ i ];
+ geometry2.addGroup( group.start, group.count, group.materialIndex );
+
+ }
+
+ return geometry2;
+
+ }
+
+ toJSON() {
+
+ const data = {
+ metadata: {
+ version: 4.5,
+ type: 'BufferGeometry',
+ generator: 'BufferGeometry.toJSON'
+ }
+ };
+
+ // standard BufferGeometry serialization
+
+ data.uuid = this.uuid;
+ data.type = this.type;
+ if ( this.name !== '' ) data.name = this.name;
+ if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
+
+ if ( this.parameters !== undefined ) {
+
+ const parameters = this.parameters;
+
+ for ( const key in parameters ) {
+
+ if ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];
+
+ }
+
+ return data;
+
+ }
+
+ // for simplicity the code assumes attributes are not shared across geometries, see #15811
+
+ data.data = { attributes: {} };
+
+ const index = this.index;
+
+ if ( index !== null ) {
+
+ data.data.index = {
+ type: index.array.constructor.name,
+ array: Array.prototype.slice.call( index.array )
+ };
+
+ }
+
+ const attributes = this.attributes;
+
+ for ( const key in attributes ) {
+
+ const attribute = attributes[ key ];
+
+ data.data.attributes[ key ] = attribute.toJSON( data.data );
+
+ }
+
+ const morphAttributes = {};
+ let hasMorphAttributes = false;
+
+ for ( const key in this.morphAttributes ) {
+
+ const attributeArray = this.morphAttributes[ key ];
+
+ const array = [];
+
+ for ( let i = 0, il = attributeArray.length; i < il; i ++ ) {
+
+ const attribute = attributeArray[ i ];
+
+ array.push( attribute.toJSON( data.data ) );
+
+ }
+
+ if ( array.length > 0 ) {
+
+ morphAttributes[ key ] = array;
+
+ hasMorphAttributes = true;
+
+ }
+
+ }
+
+ if ( hasMorphAttributes ) {
+
+ data.data.morphAttributes = morphAttributes;
+ data.data.morphTargetsRelative = this.morphTargetsRelative;
+
+ }
+
+ const groups = this.groups;
+
+ if ( groups.length > 0 ) {
+
+ data.data.groups = JSON.parse( JSON.stringify( groups ) );
+
+ }
+
+ const boundingSphere = this.boundingSphere;
+
+ if ( boundingSphere !== null ) {
+
+ data.data.boundingSphere = {
+ center: boundingSphere.center.toArray(),
+ radius: boundingSphere.radius
+ };
+
+ }
+
+ return data;
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ copy( source ) {
+
+ // reset
+
+ this.index = null;
+ this.attributes = {};
+ this.morphAttributes = {};
+ this.groups = [];
+ this.boundingBox = null;
+ this.boundingSphere = null;
+
+ // used for storing cloned, shared data
+
+ const data = {};
+
+ // name
+
+ this.name = source.name;
+
+ // index
+
+ const index = source.index;
+
+ if ( index !== null ) {
+
+ this.setIndex( index.clone( data ) );
+
+ }
+
+ // attributes
+
+ const attributes = source.attributes;
+
+ for ( const name in attributes ) {
+
+ const attribute = attributes[ name ];
+ this.setAttribute( name, attribute.clone( data ) );
+
+ }
+
+ // morph attributes
+
+ const morphAttributes = source.morphAttributes;
+
+ for ( const name in morphAttributes ) {
+
+ const array = [];
+ const morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes
+
+ for ( let i = 0, l = morphAttribute.length; i < l; i ++ ) {
+
+ array.push( morphAttribute[ i ].clone( data ) );
+
+ }
+
+ this.morphAttributes[ name ] = array;
+
+ }
+
+ this.morphTargetsRelative = source.morphTargetsRelative;
+
+ // groups
+
+ const groups = source.groups;
+
+ for ( let i = 0, l = groups.length; i < l; i ++ ) {
+
+ const group = groups[ i ];
+ this.addGroup( group.start, group.count, group.materialIndex );
+
+ }
+
+ // bounding box
+
+ const boundingBox = source.boundingBox;
+
+ if ( boundingBox !== null ) {
+
+ this.boundingBox = boundingBox.clone();
+
+ }
+
+ // bounding sphere
+
+ const boundingSphere = source.boundingSphere;
+
+ if ( boundingSphere !== null ) {
+
+ this.boundingSphere = boundingSphere.clone();
+
+ }
+
+ // draw range
+
+ this.drawRange.start = source.drawRange.start;
+ this.drawRange.count = source.drawRange.count;
+
+ // user data
+
+ this.userData = source.userData;
+
+ // geometry generator parameters
+
+ if ( source.parameters !== undefined ) this.parameters = Object.assign( {}, source.parameters );
+
+ return this;
+
+ }
+
+ dispose() {
+
+ this.dispatchEvent( { type: 'dispose' } );
+
+ }
+
+}
+
+const _inverseMatrix$2 = /*@__PURE__*/ new Matrix4();
+const _ray$2 = /*@__PURE__*/ new Ray();
+const _sphere$3 = /*@__PURE__*/ new Sphere();
+
+const _vA$1 = /*@__PURE__*/ new Vector3();
+const _vB$1 = /*@__PURE__*/ new Vector3();
+const _vC$1 = /*@__PURE__*/ new Vector3();
+
+const _tempA = /*@__PURE__*/ new Vector3();
+const _tempB = /*@__PURE__*/ new Vector3();
+const _tempC = /*@__PURE__*/ new Vector3();
+
+const _morphA = /*@__PURE__*/ new Vector3();
+const _morphB = /*@__PURE__*/ new Vector3();
+const _morphC = /*@__PURE__*/ new Vector3();
+
+const _uvA$1 = /*@__PURE__*/ new Vector2();
+const _uvB$1 = /*@__PURE__*/ new Vector2();
+const _uvC$1 = /*@__PURE__*/ new Vector2();
+
+const _intersectionPoint = /*@__PURE__*/ new Vector3();
+const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
+
+class Mesh extends Object3D {
+
+ constructor( geometry = new BufferGeometry(), material = new MeshBasicMaterial() ) {
+
+ super();
+
+ this.isMesh = true;
+
+ this.type = 'Mesh';
+
+ this.geometry = geometry;
+ this.material = material;
+
+ this.updateMorphTargets();
+
+ }
+
+ copy( source, recursive ) {
+
+ super.copy( source, recursive );
+
+ if ( source.morphTargetInfluences !== undefined ) {
+
+ this.morphTargetInfluences = source.morphTargetInfluences.slice();
+
+ }
+
+ if ( source.morphTargetDictionary !== undefined ) {
+
+ this.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );
+
+ }
+
+ this.material = source.material;
+ this.geometry = source.geometry;
+
+ return this;
+
+ }
+
+ updateMorphTargets() {
+
+ const geometry = this.geometry;
+
+ const morphAttributes = geometry.morphAttributes;
+ const keys = Object.keys( morphAttributes );
+
+ if ( keys.length > 0 ) {
+
+ const morphAttribute = morphAttributes[ keys[ 0 ] ];
+
+ if ( morphAttribute !== undefined ) {
+
+ this.morphTargetInfluences = [];
+ this.morphTargetDictionary = {};
+
+ for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
+
+ const name = morphAttribute[ m ].name || String( m );
+
+ this.morphTargetInfluences.push( 0 );
+ this.morphTargetDictionary[ name ] = m;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ raycast( raycaster, intersects ) {
+
+ const geometry = this.geometry;
+ const material = this.material;
+ const matrixWorld = this.matrixWorld;
+
+ if ( material === undefined ) return;
+
+ // Checking boundingSphere distance to ray
+
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+
+ _sphere$3.copy( geometry.boundingSphere );
+ _sphere$3.applyMatrix4( matrixWorld );
+
+ if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
+
+ //
+
+ _inverseMatrix$2.copy( matrixWorld ).invert();
+ _ray$2.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$2 );
+
+ // Check boundingBox before continuing
+
+ if ( geometry.boundingBox !== null ) {
+
+ if ( _ray$2.intersectsBox( geometry.boundingBox ) === false ) return;
+
+ }
+
+ let intersection;
+
+ const index = geometry.index;
+ const position = geometry.attributes.position;
+ const morphPosition = geometry.morphAttributes.position;
+ const morphTargetsRelative = geometry.morphTargetsRelative;
+ const uv = geometry.attributes.uv;
+ const uv2 = geometry.attributes.uv2;
+ const groups = geometry.groups;
+ const drawRange = geometry.drawRange;
+
+ if ( index !== null ) {
+
+ // indexed buffer geometry
+
+ if ( Array.isArray( material ) ) {
+
+ for ( let i = 0, il = groups.length; i < il; i ++ ) {
+
+ const group = groups[ i ];
+ const groupMaterial = material[ group.materialIndex ];
+
+ const start = Math.max( group.start, drawRange.start );
+ const end = Math.min( index.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) );
+
+ for ( let j = start, jl = end; j < jl; j += 3 ) {
+
+ const a = index.getX( j );
+ const b = index.getX( j + 1 );
+ const c = index.getX( j + 2 );
+
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
+
+ if ( intersection ) {
+
+ intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
+ intersection.face.materialIndex = group.materialIndex;
+ intersects.push( intersection );
+
+ }
+
+ }
+
+ }
+
+ } else {
+
+ const start = Math.max( 0, drawRange.start );
+ const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
+
+ for ( let i = start, il = end; i < il; i += 3 ) {
+
+ const a = index.getX( i );
+ const b = index.getX( i + 1 );
+ const c = index.getX( i + 2 );
+
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
+
+ if ( intersection ) {
+
+ intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
+ intersects.push( intersection );
+
+ }
+
+ }
+
+ }
+
+ } else if ( position !== undefined ) {
+
+ // non-indexed buffer geometry
+
+ if ( Array.isArray( material ) ) {
+
+ for ( let i = 0, il = groups.length; i < il; i ++ ) {
+
+ const group = groups[ i ];
+ const groupMaterial = material[ group.materialIndex ];
+
+ const start = Math.max( group.start, drawRange.start );
+ const end = Math.min( position.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) );
+
+ for ( let j = start, jl = end; j < jl; j += 3 ) {
+
+ const a = j;
+ const b = j + 1;
+ const c = j + 2;
+
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
+
+ if ( intersection ) {
+
+ intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
+ intersection.face.materialIndex = group.materialIndex;
+ intersects.push( intersection );
+
+ }
+
+ }
+
+ }
+
+ } else {
+
+ const start = Math.max( 0, drawRange.start );
+ const end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
+
+ for ( let i = start, il = end; i < il; i += 3 ) {
+
+ const a = i;
+ const b = i + 1;
+ const c = i + 2;
+
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray$2, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
+
+ if ( intersection ) {
+
+ intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
+ intersects.push( intersection );
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+}
+
+function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
+
+ let intersect;
+
+ if ( material.side === BackSide ) {
+
+ intersect = ray.intersectTriangle( pC, pB, pA, true, point );
+
+ } else {
+
+ intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );
+
+ }
+
+ if ( intersect === null ) return null;
+
+ _intersectionPointWorld.copy( point );
+ _intersectionPointWorld.applyMatrix4( object.matrixWorld );
+
+ const distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );
+
+ if ( distance < raycaster.near || distance > raycaster.far ) return null;
+
+ return {
+ distance: distance,
+ point: _intersectionPointWorld.clone(),
+ object: object
+ };
+
+}
+
+function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) {
+
+ _vA$1.fromBufferAttribute( position, a );
+ _vB$1.fromBufferAttribute( position, b );
+ _vC$1.fromBufferAttribute( position, c );
+
+ const morphInfluences = object.morphTargetInfluences;
+
+ if ( morphPosition && morphInfluences ) {
+
+ _morphA.set( 0, 0, 0 );
+ _morphB.set( 0, 0, 0 );
+ _morphC.set( 0, 0, 0 );
+
+ for ( let i = 0, il = morphPosition.length; i < il; i ++ ) {
+
+ const influence = morphInfluences[ i ];
+ const morphAttribute = morphPosition[ i ];
+
+ if ( influence === 0 ) continue;
+
+ _tempA.fromBufferAttribute( morphAttribute, a );
+ _tempB.fromBufferAttribute( morphAttribute, b );
+ _tempC.fromBufferAttribute( morphAttribute, c );
+
+ if ( morphTargetsRelative ) {
+
+ _morphA.addScaledVector( _tempA, influence );
+ _morphB.addScaledVector( _tempB, influence );
+ _morphC.addScaledVector( _tempC, influence );
+
+ } else {
+
+ _morphA.addScaledVector( _tempA.sub( _vA$1 ), influence );
+ _morphB.addScaledVector( _tempB.sub( _vB$1 ), influence );
+ _morphC.addScaledVector( _tempC.sub( _vC$1 ), influence );
+
+ }
+
+ }
+
+ _vA$1.add( _morphA );
+ _vB$1.add( _morphB );
+ _vC$1.add( _morphC );
+
+ }
+
+ if ( object.isSkinnedMesh ) {
+
+ object.boneTransform( a, _vA$1 );
+ object.boneTransform( b, _vB$1 );
+ object.boneTransform( c, _vC$1 );
+
+ }
+
+ const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
+
+ if ( intersection ) {
+
+ if ( uv ) {
+
+ _uvA$1.fromBufferAttribute( uv, a );
+ _uvB$1.fromBufferAttribute( uv, b );
+ _uvC$1.fromBufferAttribute( uv, c );
+
+ intersection.uv = Triangle.getUV( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
+
+ }
+
+ if ( uv2 ) {
+
+ _uvA$1.fromBufferAttribute( uv2, a );
+ _uvB$1.fromBufferAttribute( uv2, b );
+ _uvC$1.fromBufferAttribute( uv2, c );
+
+ intersection.uv2 = Triangle.getUV( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
+
+ }
+
+ const face = {
+ a: a,
+ b: b,
+ c: c,
+ normal: new Vector3(),
+ materialIndex: 0
+ };
+
+ Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal );
+
+ intersection.face = face;
+
+ }
+
+ return intersection;
+
+}
+
+class BoxGeometry extends BufferGeometry {
+
+ constructor( width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1 ) {
+
+ super();
+
+ this.type = 'BoxGeometry';
+
+ this.parameters = {
+ width: width,
+ height: height,
+ depth: depth,
+ widthSegments: widthSegments,
+ heightSegments: heightSegments,
+ depthSegments: depthSegments
+ };
+
+ const scope = this;
+
+ // segments
+
+ widthSegments = Math.floor( widthSegments );
+ heightSegments = Math.floor( heightSegments );
+ depthSegments = Math.floor( depthSegments );
+
+ // buffers
+
+ const indices = [];
+ const vertices = [];
+ const normals = [];
+ const uvs = [];
+
+ // helper variables
+
+ let numberOfVertices = 0;
+ let groupStart = 0;
+
+ // build each side of the box geometry
+
+ buildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px
+ buildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx
+ buildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py
+ buildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny
+ buildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz
+ buildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz
+
+ // build geometry
+
+ this.setIndex( indices );
+ this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+ this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+ this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+
+ function buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) {
+
+ const segmentWidth = width / gridX;
+ const segmentHeight = height / gridY;
+
+ const widthHalf = width / 2;
+ const heightHalf = height / 2;
+ const depthHalf = depth / 2;
+
+ const gridX1 = gridX + 1;
+ const gridY1 = gridY + 1;
+
+ let vertexCounter = 0;
+ let groupCount = 0;
+
+ const vector = new Vector3();
+
+ // generate vertices, normals and uvs
+
+ for ( let iy = 0; iy < gridY1; iy ++ ) {
+
+ const y = iy * segmentHeight - heightHalf;
+
+ for ( let ix = 0; ix < gridX1; ix ++ ) {
+
+ const x = ix * segmentWidth - widthHalf;
+
+ // set values to correct vector component
+
+ vector[ u ] = x * udir;
+ vector[ v ] = y * vdir;
+ vector[ w ] = depthHalf;
+
+ // now apply vector to vertex buffer
+
+ vertices.push( vector.x, vector.y, vector.z );
+
+ // set values to correct vector component
+
+ vector[ u ] = 0;
+ vector[ v ] = 0;
+ vector[ w ] = depth > 0 ? 1 : - 1;
+
+ // now apply vector to normal buffer
+
+ normals.push( vector.x, vector.y, vector.z );
+
+ // uvs
+
+ uvs.push( ix / gridX );
+ uvs.push( 1 - ( iy / gridY ) );
+
+ // counters
+
+ vertexCounter += 1;
+
+ }
+
+ }
+
+ // indices
+
+ // 1. you need three indices to draw a single face
+ // 2. a single segment consists of two faces
+ // 3. so we need to generate six (2*3) indices per segment
+
+ for ( let iy = 0; iy < gridY; iy ++ ) {
+
+ for ( let ix = 0; ix < gridX; ix ++ ) {
+
+ const a = numberOfVertices + ix + gridX1 * iy;
+ const b = numberOfVertices + ix + gridX1 * ( iy + 1 );
+ const c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 );
+ const d = numberOfVertices + ( ix + 1 ) + gridX1 * iy;
+
+ // faces
+
+ indices.push( a, b, d );
+ indices.push( b, c, d );
+
+ // increase counter
+
+ groupCount += 6;
+
+ }
+
+ }
+
+ // add a group to the geometry. this will ensure multi material support
+
+ scope.addGroup( groupStart, groupCount, materialIndex );
+
+ // calculate new start value for groups
+
+ groupStart += groupCount;
+
+ // update total number of vertices
+
+ numberOfVertices += vertexCounter;
+
+ }
+
+ }
+
+ static fromJSON( data ) {
+
+ return new BoxGeometry( data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments );
+
+ }
+
+}
+
+/**
+ * Uniform Utilities
+ */
+
+function cloneUniforms( src ) {
+
+ const dst = {};
+
+ for ( const u in src ) {
+
+ dst[ u ] = {};
+
+ for ( const p in src[ u ] ) {
+
+ const property = src[ u ][ p ];
+
+ if ( property && ( property.isColor ||
+ property.isMatrix3 || property.isMatrix4 ||
+ property.isVector2 || property.isVector3 || property.isVector4 ||
+ property.isTexture || property.isQuaternion ) ) {
+
+ dst[ u ][ p ] = property.clone();
+
+ } else if ( Array.isArray( property ) ) {
+
+ dst[ u ][ p ] = property.slice();
+
+ } else {
+
+ dst[ u ][ p ] = property;
+
+ }
+
+ }
+
+ }
+
+ return dst;
+
+}
+
+function mergeUniforms( uniforms ) {
+
+ const merged = {};
+
+ for ( let u = 0; u < uniforms.length; u ++ ) {
+
+ const tmp = cloneUniforms( uniforms[ u ] );
+
+ for ( const p in tmp ) {
+
+ merged[ p ] = tmp[ p ];
+
+ }
+
+ }
+
+ return merged;
+
+}
+
+// Legacy
+
+const UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
+
+var default_vertex = "void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";
+
+var default_fragment = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";
+
+class ShaderMaterial extends Material {
+
+ constructor( parameters ) {
+
+ super();
+
+ this.isShaderMaterial = true;
+
+ this.type = 'ShaderMaterial';
+
+ this.defines = {};
+ this.uniforms = {};
+
+ this.vertexShader = default_vertex;
+ this.fragmentShader = default_fragment;
+
+ this.linewidth = 1;
+
+ this.wireframe = false;
+ this.wireframeLinewidth = 1;
+
+ this.fog = false; // set to use scene fog
+ this.lights = false; // set to use scene lights
+ this.clipping = false; // set to use user-defined clipping planes
+
+ this.extensions = {
+ derivatives: false, // set to use derivatives
+ fragDepth: false, // set to use fragment depth values
+ drawBuffers: false, // set to use draw buffers
+ shaderTextureLOD: false // set to use shader texture LOD
+ };
+
+ // When rendered geometry doesn't include these attributes but the material does,
+ // use these default values in WebGL. This avoids errors when buffer data is missing.
+ this.defaultAttributeValues = {
+ 'color': [ 1, 1, 1 ],
+ 'uv': [ 0, 0 ],
+ 'uv2': [ 0, 0 ]
+ };
+
+ this.index0AttributeName = undefined;
+ this.uniformsNeedUpdate = false;
+
+ this.glslVersion = null;
+
+ if ( parameters !== undefined ) {
+
+ if ( parameters.attributes !== undefined ) {
+
+ console.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );
+
+ }
+
+ this.setValues( parameters );
+
+ }
+
+ }
+
+ copy( source ) {
+
+ super.copy( source );
+
+ this.fragmentShader = source.fragmentShader;
+ this.vertexShader = source.vertexShader;
+
+ this.uniforms = cloneUniforms( source.uniforms );
+
+ this.defines = Object.assign( {}, source.defines );
+
+ this.wireframe = source.wireframe;
+ this.wireframeLinewidth = source.wireframeLinewidth;
+
+ this.fog = source.fog;
+ this.lights = source.lights;
+ this.clipping = source.clipping;
+
+ this.extensions = Object.assign( {}, source.extensions );
+
+ this.glslVersion = source.glslVersion;
+
+ return this;
+
+ }
+
+ toJSON( meta ) {
+
+ const data = super.toJSON( meta );
+
+ data.glslVersion = this.glslVersion;
+ data.uniforms = {};
+
+ for ( const name in this.uniforms ) {
+
+ const uniform = this.uniforms[ name ];
+ const value = uniform.value;
+
+ if ( value && value.isTexture ) {
+
+ data.uniforms[ name ] = {
+ type: 't',
+ value: value.toJSON( meta ).uuid
+ };
+
+ } else if ( value && value.isColor ) {
+
+ data.uniforms[ name ] = {
+ type: 'c',
+ value: value.getHex()
+ };
+
+ } else if ( value && value.isVector2 ) {
+
+ data.uniforms[ name ] = {
+ type: 'v2',
+ value: value.toArray()
+ };
+
+ } else if ( value && value.isVector3 ) {
+
+ data.uniforms[ name ] = {
+ type: 'v3',
+ value: value.toArray()
+ };
+
+ } else if ( value && value.isVector4 ) {
+
+ data.uniforms[ name ] = {
+ type: 'v4',
+ value: value.toArray()
+ };
+
+ } else if ( value && value.isMatrix3 ) {
+
+ data.uniforms[ name ] = {
+ type: 'm3',
+ value: value.toArray()
+ };
+
+ } else if ( value && value.isMatrix4 ) {
+
+ data.uniforms[ name ] = {
+ type: 'm4',
+ value: value.toArray()
+ };
+
+ } else {
+
+ data.uniforms[ name ] = {
+ value: value
+ };
+
+ // note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far
+
+ }
+
+ }
+
+ if ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;
+
+ data.vertexShader = this.vertexShader;
+ data.fragmentShader = this.fragmentShader;
+
+ const extensions = {};
+
+ for ( const key in this.extensions ) {
+
+ if ( this.extensions[ key ] === true ) extensions[ key ] = true;
+
+ }
+
+ if ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;
+
+ return data;
+
+ }
+
+}
+
+class Camera extends Object3D {
+
+ constructor() {
+
+ super();
+
+ this.isCamera = true;
+
+ this.type = 'Camera';
+
+ this.matrixWorldInverse = new Matrix4();
+
+ this.projectionMatrix = new Matrix4();
+ this.projectionMatrixInverse = new Matrix4();
+
+ }
+
+ copy( source, recursive ) {
+
+ super.copy( source, recursive );
+
+ this.matrixWorldInverse.copy( source.matrixWorldInverse );
+
+ this.projectionMatrix.copy( source.projectionMatrix );
+ this.projectionMatrixInverse.copy( source.projectionMatrixInverse );
+
+ return this;
+
+ }
+
+ getWorldDirection( target ) {
+
+ this.updateWorldMatrix( true, false );
+
+ const e = this.matrixWorld.elements;
+
+ return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();
+
+ }
+
+ updateMatrixWorld( force ) {
+
+ super.updateMatrixWorld( force );
+
+ this.matrixWorldInverse.copy( this.matrixWorld ).invert();
+
+ }
+
+ updateWorldMatrix( updateParents, updateChildren ) {
+
+ super.updateWorldMatrix( updateParents, updateChildren );
+
+ this.matrixWorldInverse.copy( this.matrixWorld ).invert();
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+}
+
+class PerspectiveCamera extends Camera {
+
+ constructor( fov = 50, aspect = 1, near = 0.1, far = 2000 ) {
+
+ super();
+
+ this.isPerspectiveCamera = true;
+
+ this.type = 'PerspectiveCamera';
+
+ this.fov = fov;
+ this.zoom = 1;
+
+ this.near = near;
+ this.far = far;
+ this.focus = 10;
+
+ this.aspect = aspect;
+ this.view = null;
+
+ this.filmGauge = 35; // width of the film (default in millimeters)
+ this.filmOffset = 0; // horizontal film offset (same unit as gauge)
+
+ this.updateProjectionMatrix();
+
+ }
+
+ copy( source, recursive ) {
+
+ super.copy( source, recursive );
+
+ this.fov = source.fov;
+ this.zoom = source.zoom;
+
+ this.near = source.near;
+ this.far = source.far;
+ this.focus = source.focus;
+
+ this.aspect = source.aspect;
+ this.view = source.view === null ? null : Object.assign( {}, source.view );
+
+ this.filmGauge = source.filmGauge;
+ this.filmOffset = source.filmOffset;
+
+ return this;
+
+ }
+
+ /**
+ * Sets the FOV by focal length in respect to the current .filmGauge.
+ *
+ * The default film gauge is 35, so that the focal length can be specified for
+ * a 35mm (full frame) camera.
+ *
+ * Values for focal length and film gauge must have the same unit.
+ */
+ setFocalLength( focalLength ) {
+
+ /** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */
+ const vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
+
+ this.fov = RAD2DEG * 2 * Math.atan( vExtentSlope );
+ this.updateProjectionMatrix();
+
+ }
+
+ /**
+ * Calculates the focal length from the current .fov and .filmGauge.
+ */
+ getFocalLength() {
+
+ const vExtentSlope = Math.tan( DEG2RAD * 0.5 * this.fov );
+
+ return 0.5 * this.getFilmHeight() / vExtentSlope;
+
+ }
+
+ getEffectiveFOV() {
+
+ return RAD2DEG * 2 * Math.atan(
+ Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom );
+
+ }
+
+ getFilmWidth() {
+
+ // film not completely covered in portrait format (aspect < 1)
+ return this.filmGauge * Math.min( this.aspect, 1 );
+
+ }
+
+ getFilmHeight() {
+
+ // film not completely covered in landscape format (aspect > 1)
+ return this.filmGauge / Math.max( this.aspect, 1 );
+
+ }
+
+ /**
+ * Sets an offset in a larger frustum. This is useful for multi-window or
+ * multi-monitor/multi-machine setups.
+ *
+ * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
+ * the monitors are in grid like this
+ *
+ * +---+---+---+
+ * | A | B | C |
+ * +---+---+---+
+ * | D | E | F |
+ * +---+---+---+
+ *
+ * then for each monitor you would call it like this
+ *
+ * const w = 1920;
+ * const h = 1080;
+ * const fullWidth = w * 3;
+ * const fullHeight = h * 2;
+ *
+ * --A--
+ * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
+ * --B--
+ * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
+ * --C--
+ * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
+ * --D--
+ * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
+ * --E--
+ * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
+ * --F--
+ * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
+ *
+ * Note there is no reason monitors have to be the same size or in a grid.
+ */
+ setViewOffset( fullWidth, fullHeight, x, y, width, height ) {
+
+ this.aspect = fullWidth / fullHeight;
+
+ if ( this.view === null ) {
+
+ this.view = {
+ enabled: true,
+ fullWidth: 1,
+ fullHeight: 1,
+ offsetX: 0,
+ offsetY: 0,
+ width: 1,
+ height: 1
+ };
+
+ }
+
+ this.view.enabled = true;
+ this.view.fullWidth = fullWidth;
+ this.view.fullHeight = fullHeight;
+ this.view.offsetX = x;
+ this.view.offsetY = y;
+ this.view.width = width;
+ this.view.height = height;
+
+ this.updateProjectionMatrix();
+
+ }
+
+ clearViewOffset() {
+
+ if ( this.view !== null ) {
+
+ this.view.enabled = false;
+
+ }
+
+ this.updateProjectionMatrix();
+
+ }
+
+ updateProjectionMatrix() {
+
+ const near = this.near;
+ let top = near * Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom;
+ let height = 2 * top;
+ let width = this.aspect * height;
+ let left = - 0.5 * width;
+ const view = this.view;
+
+ if ( this.view !== null && this.view.enabled ) {
+
+ const fullWidth = view.fullWidth,
+ fullHeight = view.fullHeight;
+
+ left += view.offsetX * width / fullWidth;
+ top -= view.offsetY * height / fullHeight;
+ width *= view.width / fullWidth;
+ height *= view.height / fullHeight;
+
+ }
+
+ const skew = this.filmOffset;
+ if ( skew !== 0 ) left += near * skew / this.getFilmWidth();
+
+ this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );
+
+ this.projectionMatrixInverse.copy( this.projectionMatrix ).invert();
+
+ }
+
+ toJSON( meta ) {
+
+ const data = super.toJSON( meta );
+
+ data.object.fov = this.fov;
+ data.object.zoom = this.zoom;
+
+ data.object.near = this.near;
+ data.object.far = this.far;
+ data.object.focus = this.focus;
+
+ data.object.aspect = this.aspect;
+
+ if ( this.view !== null ) data.object.view = Object.assign( {}, this.view );
+
+ data.object.filmGauge = this.filmGauge;
+ data.object.filmOffset = this.filmOffset;
+
+ return data;
+
+ }
+
+}
+
+const fov = 90, aspect = 1;
+
+class CubeCamera extends Object3D {
+
+ constructor( near, far, renderTarget ) {
+
+ super();
+
+ this.type = 'CubeCamera';
+
+ if ( renderTarget.isWebGLCubeRenderTarget !== true ) {
+
+ console.error( 'THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.' );
+ return;
+
+ }
+
+ this.renderTarget = renderTarget;
+
+ const cameraPX = new PerspectiveCamera( fov, aspect, near, far );
+ cameraPX.layers = this.layers;
+ cameraPX.up.set( 0, - 1, 0 );
+ cameraPX.lookAt( new Vector3( 1, 0, 0 ) );
+ this.add( cameraPX );
+
+ const cameraNX = new PerspectiveCamera( fov, aspect, near, far );
+ cameraNX.layers = this.layers;
+ cameraNX.up.set( 0, - 1, 0 );
+ cameraNX.lookAt( new Vector3( - 1, 0, 0 ) );
+ this.add( cameraNX );
+
+ const cameraPY = new PerspectiveCamera( fov, aspect, near, far );
+ cameraPY.layers = this.layers;
+ cameraPY.up.set( 0, 0, 1 );
+ cameraPY.lookAt( new Vector3( 0, 1, 0 ) );
+ this.add( cameraPY );
+
+ const cameraNY = new PerspectiveCamera( fov, aspect, near, far );
+ cameraNY.layers = this.layers;
+ cameraNY.up.set( 0, 0, - 1 );
+ cameraNY.lookAt( new Vector3( 0, - 1, 0 ) );
+ this.add( cameraNY );
+
+ const cameraPZ = new PerspectiveCamera( fov, aspect, near, far );
+ cameraPZ.layers = this.layers;
+ cameraPZ.up.set( 0, - 1, 0 );
+ cameraPZ.lookAt( new Vector3( 0, 0, 1 ) );
+ this.add( cameraPZ );
+
+ const cameraNZ = new PerspectiveCamera( fov, aspect, near, far );
+ cameraNZ.layers = this.layers;
+ cameraNZ.up.set( 0, - 1, 0 );
+ cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) );
+ this.add( cameraNZ );
+
+ }
+
+ update( renderer, scene ) {
+
+ if ( this.parent === null ) this.updateMatrixWorld();
+
+ const renderTarget = this.renderTarget;
+
+ const [ cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ ] = this.children;
+
+ const currentRenderTarget = renderer.getRenderTarget();
+
+ const currentToneMapping = renderer.toneMapping;
+ const currentXrEnabled = renderer.xr.enabled;
+
+ renderer.toneMapping = NoToneMapping;
+ renderer.xr.enabled = false;
+
+ const generateMipmaps = renderTarget.texture.generateMipmaps;
+
+ renderTarget.texture.generateMipmaps = false;
+
+ renderer.setRenderTarget( renderTarget, 0 );
+ renderer.render( scene, cameraPX );
+
+ renderer.setRenderTarget( renderTarget, 1 );
+ renderer.render( scene, cameraNX );
+
+ renderer.setRenderTarget( renderTarget, 2 );
+ renderer.render( scene, cameraPY );
+
+ renderer.setRenderTarget( renderTarget, 3 );
+ renderer.render( scene, cameraNY );
+
+ renderer.setRenderTarget( renderTarget, 4 );
+ renderer.render( scene, cameraPZ );
+
+ renderTarget.texture.generateMipmaps = generateMipmaps;
+
+ renderer.setRenderTarget( renderTarget, 5 );
+ renderer.render( scene, cameraNZ );
+
+ renderer.setRenderTarget( currentRenderTarget );
+
+ renderer.toneMapping = currentToneMapping;
+ renderer.xr.enabled = currentXrEnabled;
+
+ renderTarget.texture.needsPMREMUpdate = true;
+
+ }
+
+}
+
+class CubeTexture extends Texture {
+
+ constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
+
+ images = images !== undefined ? images : [];
+ mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
+
+ super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+
+ this.isCubeTexture = true;
+
+ this.flipY = false;
+
+ }
+
+ get images() {
+
+ return this.image;
+
+ }
+
+ set images( value ) {
+
+ this.image = value;
+
+ }
+
+}
+
+class WebGLCubeRenderTarget extends WebGLRenderTarget {
+
+ constructor( size, options = {} ) {
+
+ super( size, size, options );
+
+ this.isWebGLCubeRenderTarget = true;
+
+ const image = { width: size, height: size, depth: 1 };
+ const images = [ image, image, image, image, image, image ];
+
+ this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+
+ // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
+ // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,
+ // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.
+
+ // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped
+ // and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture
+ // as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures).
+
+ this.texture.isRenderTargetTexture = true;
+
+ this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
+ this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
+
+ }
+
+ fromEquirectangularTexture( renderer, texture ) {
+
+ this.texture.type = texture.type;
+ this.texture.encoding = texture.encoding;
+
+ this.texture.generateMipmaps = texture.generateMipmaps;
+ this.texture.minFilter = texture.minFilter;
+ this.texture.magFilter = texture.magFilter;
+
+ const shader = {
+
+ uniforms: {
+ tEquirect: { value: null },
+ },
+
+ vertexShader: /* glsl */`
+
+ varying vec3 vWorldDirection;
+
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
+
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
+
+ }
+
+ void main() {
+
+ vWorldDirection = transformDirection( position, modelMatrix );
+
+ #include
+ #include
+
+ }
+ `,
+
+ fragmentShader: /* glsl */`
+
+ uniform sampler2D tEquirect;
+
+ varying vec3 vWorldDirection;
+
+ #include
+
+ void main() {
+
+ vec3 direction = normalize( vWorldDirection );
+
+ vec2 sampleUV = equirectUv( direction );
+
+ gl_FragColor = texture2D( tEquirect, sampleUV );
+
+ }
+ `
+ };
+
+ const geometry = new BoxGeometry( 5, 5, 5 );
+
+ const material = new ShaderMaterial( {
+
+ name: 'CubemapFromEquirect',
+
+ uniforms: cloneUniforms( shader.uniforms ),
+ vertexShader: shader.vertexShader,
+ fragmentShader: shader.fragmentShader,
+ side: BackSide,
+ blending: NoBlending
+
+ } );
+
+ material.uniforms.tEquirect.value = texture;
+
+ const mesh = new Mesh( geometry, material );
+
+ const currentMinFilter = texture.minFilter;
+
+ // Avoid blurred poles
+ if ( texture.minFilter === LinearMipmapLinearFilter ) texture.minFilter = LinearFilter;
+
+ const camera = new CubeCamera( 1, 10, this );
+ camera.update( renderer, mesh );
+
+ texture.minFilter = currentMinFilter;
+
+ mesh.geometry.dispose();
+ mesh.material.dispose();
+
+ return this;
+
+ }
+
+ clear( renderer, color, depth, stencil ) {
+
+ const currentRenderTarget = renderer.getRenderTarget();
+
+ for ( let i = 0; i < 6; i ++ ) {
+
+ renderer.setRenderTarget( this, i );
+
+ renderer.clear( color, depth, stencil );
+
+ }
+
+ renderer.setRenderTarget( currentRenderTarget );
+
+ }
+
+}
+
+const _vector1 = /*@__PURE__*/ new Vector3();
+const _vector2 = /*@__PURE__*/ new Vector3();
+const _normalMatrix = /*@__PURE__*/ new Matrix3();
+
+class Plane {
+
+ constructor( normal = new Vector3( 1, 0, 0 ), constant = 0 ) {
+
+ this.isPlane = true;
+
+ // normal is assumed to be normalized
+
+ this.normal = normal;
+ this.constant = constant;
+
+ }
+
+ set( normal, constant ) {
+
+ this.normal.copy( normal );
+ this.constant = constant;
+
+ return this;
+
+ }
+
+ setComponents( x, y, z, w ) {
+
+ this.normal.set( x, y, z );
+ this.constant = w;
+
+ return this;
+
+ }
+
+ setFromNormalAndCoplanarPoint( normal, point ) {
+
+ this.normal.copy( normal );
+ this.constant = - point.dot( this.normal );
+
+ return this;
+
+ }
+
+ setFromCoplanarPoints( a, b, c ) {
+
+ const normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();
+
+ // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+
+ this.setFromNormalAndCoplanarPoint( normal, a );
+
+ return this;
+
+ }
+
+ copy( plane ) {
+
+ this.normal.copy( plane.normal );
+ this.constant = plane.constant;
+
+ return this;
+
+ }
+
+ normalize() {
+
+ // Note: will lead to a divide by zero if the plane is invalid.
+
+ const inverseNormalLength = 1.0 / this.normal.length();
+ this.normal.multiplyScalar( inverseNormalLength );
+ this.constant *= inverseNormalLength;
+
+ return this;
+
+ }
+
+ negate() {
+
+ this.constant *= - 1;
+ this.normal.negate();
+
+ return this;
+
+ }
+
+ distanceToPoint( point ) {
+
+ return this.normal.dot( point ) + this.constant;
+
+ }
+
+ distanceToSphere( sphere ) {
+
+ return this.distanceToPoint( sphere.center ) - sphere.radius;
+
+ }
+
+ projectPoint( point, target ) {
+
+ return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
+
+ }
+
+ intersectLine( line, target ) {
+
+ const direction = line.delta( _vector1 );
+
+ const denominator = this.normal.dot( direction );
+
+ if ( denominator === 0 ) {
+
+ // line is coplanar, return origin
+ if ( this.distanceToPoint( line.start ) === 0 ) {
+
+ return target.copy( line.start );
+
+ }
+
+ // Unsure if this is the correct method to handle this case.
+ return null;
+
+ }
+
+ const t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+
+ if ( t < 0 || t > 1 ) {
+
+ return null;
+
+ }
+
+ return target.copy( direction ).multiplyScalar( t ).add( line.start );
+
+ }
+
+ intersectsLine( line ) {
+
+ // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
+
+ const startSign = this.distanceToPoint( line.start );
+ const endSign = this.distanceToPoint( line.end );
+
+ return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );
+
+ }
+
+ intersectsBox( box ) {
+
+ return box.intersectsPlane( this );
+
+ }
+
+ intersectsSphere( sphere ) {
+
+ return sphere.intersectsPlane( this );
+
+ }
+
+ coplanarPoint( target ) {
+
+ return target.copy( this.normal ).multiplyScalar( - this.constant );
+
+ }
+
+ applyMatrix4( matrix, optionalNormalMatrix ) {
+
+ const normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );
+
+ const referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );
+
+ const normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+
+ this.constant = - referencePoint.dot( normal );
+
+ return this;
+
+ }
+
+ translate( offset ) {
+
+ this.constant -= offset.dot( this.normal );
+
+ return this;
+
+ }
+
+ equals( plane ) {
+
+ return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+}
+
+const _sphere$2 = /*@__PURE__*/ new Sphere();
+const _vector$7 = /*@__PURE__*/ new Vector3();
+
+class Frustum {
+
+ constructor( p0 = new Plane(), p1 = new Plane(), p2 = new Plane(), p3 = new Plane(), p4 = new Plane(), p5 = new Plane() ) {
+
+ this.planes = [ p0, p1, p2, p3, p4, p5 ];
+
+ }
+
+ set( p0, p1, p2, p3, p4, p5 ) {
+
+ const planes = this.planes;
+
+ planes[ 0 ].copy( p0 );
+ planes[ 1 ].copy( p1 );
+ planes[ 2 ].copy( p2 );
+ planes[ 3 ].copy( p3 );
+ planes[ 4 ].copy( p4 );
+ planes[ 5 ].copy( p5 );
+
+ return this;
+
+ }
+
+ copy( frustum ) {
+
+ const planes = this.planes;
+
+ for ( let i = 0; i < 6; i ++ ) {
+
+ planes[ i ].copy( frustum.planes[ i ] );
+
+ }
+
+ return this;
+
+ }
+
+ setFromProjectionMatrix( m ) {
+
+ const planes = this.planes;
+ const me = m.elements;
+ const me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
+ const me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
+ const me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
+ const me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
+
+ planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
+ planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
+ planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
+ planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
+ planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
+ planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
+
+ return this;
+
+ }
+
+ intersectsObject( object ) {
+
+ const geometry = object.geometry;
+
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+
+ _sphere$2.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
+
+ return this.intersectsSphere( _sphere$2 );
+
+ }
+
+ intersectsSprite( sprite ) {
+
+ _sphere$2.center.set( 0, 0, 0 );
+ _sphere$2.radius = 0.7071067811865476;
+ _sphere$2.applyMatrix4( sprite.matrixWorld );
+
+ return this.intersectsSphere( _sphere$2 );
+
+ }
+
+ intersectsSphere( sphere ) {
+
+ const planes = this.planes;
+ const center = sphere.center;
+ const negRadius = - sphere.radius;
+
+ for ( let i = 0; i < 6; i ++ ) {
+
+ const distance = planes[ i ].distanceToPoint( center );
+
+ if ( distance < negRadius ) {
+
+ return false;
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ intersectsBox( box ) {
+
+ const planes = this.planes;
+
+ for ( let i = 0; i < 6; i ++ ) {
+
+ const plane = planes[ i ];
+
+ // corner at max distance
+
+ _vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+ _vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+ _vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+
+ if ( plane.distanceToPoint( _vector$7 ) < 0 ) {
+
+ return false;
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ containsPoint( point ) {
+
+ const planes = this.planes;
+
+ for ( let i = 0; i < 6; i ++ ) {
+
+ if ( planes[ i ].distanceToPoint( point ) < 0 ) {
+
+ return false;
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ clone() {
+
+ return new this.constructor().copy( this );
+
+ }
+
+}
+
+function WebGLAnimation() {
+
+ let context = null;
+ let isAnimating = false;
+ let animationLoop = null;
+ let requestId = null;
+
+ function onAnimationFrame( time, frame ) {
+
+ animationLoop( time, frame );
+
+ requestId = context.requestAnimationFrame( onAnimationFrame );
+
+ }
+
+ return {
+
+ start: function () {
+
+ if ( isAnimating === true ) return;
+ if ( animationLoop === null ) return;
+
+ requestId = context.requestAnimationFrame( onAnimationFrame );
+
+ isAnimating = true;
+
+ },
+
+ stop: function () {
+
+ context.cancelAnimationFrame( requestId );
+
+ isAnimating = false;
+
+ },
+
+ setAnimationLoop: function ( callback ) {
+
+ animationLoop = callback;
+
+ },
+
+ setContext: function ( value ) {
+
+ context = value;
+
+ }
+
+ };
+
+}
+
+function WebGLAttributes( gl, capabilities ) {
+
+ const isWebGL2 = capabilities.isWebGL2;
+
+ const buffers = new WeakMap();
+
+ function createBuffer( attribute, bufferType ) {
+
+ const array = attribute.array;
+ const usage = attribute.usage;
+
+ const buffer = gl.createBuffer();
+
+ gl.bindBuffer( bufferType, buffer );
+ gl.bufferData( bufferType, array, usage );
+
+ attribute.onUploadCallback();
+
+ let type;
+
+ if ( array instanceof Float32Array ) {
+
+ type = 5126;
+
+ } else if ( array instanceof Uint16Array ) {
+
+ if ( attribute.isFloat16BufferAttribute ) {
+
+ if ( isWebGL2 ) {
+
+ type = 5131;
+
+ } else {
+
+ throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
+
+ }
+
+ } else {
+
+ type = 5123;
+
+ }
+
+ } else if ( array instanceof Int16Array ) {
+
+ type = 5122;
+
+ } else if ( array instanceof Uint32Array ) {
+
+ type = 5125;
+
+ } else if ( array instanceof Int32Array ) {
+
+ type = 5124;
+
+ } else if ( array instanceof Int8Array ) {
+
+ type = 5120;
+
+ } else if ( array instanceof Uint8Array ) {
+
+ type = 5121;
+
+ } else if ( array instanceof Uint8ClampedArray ) {
+
+ type = 5121;
+
+ } else {
+
+ throw new Error( 'THREE.WebGLAttributes: Unsupported buffer data format: ' + array );
+
+ }
+
+ return {
+ buffer: buffer,
+ type: type,
+ bytesPerElement: array.BYTES_PER_ELEMENT,
+ version: attribute.version
+ };
+
+ }
+
+ function updateBuffer( buffer, attribute, bufferType ) {
+
+ const array = attribute.array;
+ const updateRange = attribute.updateRange;
+
+ gl.bindBuffer( bufferType, buffer );
+
+ if ( updateRange.count === - 1 ) {
+
+ // Not using update ranges
+
+ gl.bufferSubData( bufferType, 0, array );
+
+ } else {
+
+ if ( isWebGL2 ) {
+
+ gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
+ array, updateRange.offset, updateRange.count );
+
+ } else {
+
+ gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
+ array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
+
+ }
+
+ updateRange.count = - 1; // reset range
+
+ }
+
+ }
+
+ //
+
+ function get( attribute ) {
+
+ if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
+
+ return buffers.get( attribute );
+
+ }
+
+ function remove( attribute ) {
+
+ if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
+
+ const data = buffers.get( attribute );
+
+ if ( data ) {
+
+ gl.deleteBuffer( data.buffer );
+
+ buffers.delete( attribute );
+
+ }
+
+ }
+
+ function update( attribute, bufferType ) {
+
+ if ( attribute.isGLBufferAttribute ) {
+
+ const cached = buffers.get( attribute );
+
+ if ( ! cached || cached.version < attribute.version ) {
+
+ buffers.set( attribute, {
+ buffer: attribute.buffer,
+ type: attribute.type,
+ bytesPerElement: attribute.elementSize,
+ version: attribute.version
+ } );
+
+ }
+
+ return;
+
+ }
+
+ if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
+
+ const data = buffers.get( attribute );
+
+ if ( data === undefined ) {
+
+ buffers.set( attribute, createBuffer( attribute, bufferType ) );
+
+ } else if ( data.version < attribute.version ) {
+
+ updateBuffer( data.buffer, attribute, bufferType );
+
+ data.version = attribute.version;
+
+ }
+
+ }
+
+ return {
+
+ get: get,
+ remove: remove,
+ update: update
+
+ };
+
+}
+
+class PlaneGeometry extends BufferGeometry {
+
+ constructor( width = 1, height = 1, widthSegments = 1, heightSegments = 1 ) {
+
+ super();
+ this.type = 'PlaneGeometry';
+
+ this.parameters = {
+ width: width,
+ height: height,
+ widthSegments: widthSegments,
+ heightSegments: heightSegments
+ };
+
+ const width_half = width / 2;
+ const height_half = height / 2;
+
+ const gridX = Math.floor( widthSegments );
+ const gridY = Math.floor( heightSegments );
+
+ const gridX1 = gridX + 1;
+ const gridY1 = gridY + 1;
+
+ const segment_width = width / gridX;
+ const segment_height = height / gridY;
+
+ //
+
+ const indices = [];
+ const vertices = [];
+ const normals = [];
+ const uvs = [];
+
+ for ( let iy = 0; iy < gridY1; iy ++ ) {
+
+ const y = iy * segment_height - height_half;
+
+ for ( let ix = 0; ix < gridX1; ix ++ ) {
+
+ const x = ix * segment_width - width_half;
+
+ vertices.push( x, - y, 0 );
+
+ normals.push( 0, 0, 1 );
+
+ uvs.push( ix / gridX );
+ uvs.push( 1 - ( iy / gridY ) );
+
+ }
+
+ }
+
+ for ( let iy = 0; iy < gridY; iy ++ ) {
+
+ for ( let ix = 0; ix < gridX; ix ++ ) {
+
+ const a = ix + gridX1 * iy;
+ const b = ix + gridX1 * ( iy + 1 );
+ const c = ( ix + 1 ) + gridX1 * ( iy + 1 );
+ const d = ( ix + 1 ) + gridX1 * iy;
+
+ indices.push( a, b, d );
+ indices.push( b, c, d );
+
+ }
+
+ }
+
+ this.setIndex( indices );
+ this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+ this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+ this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+
+ }
+
+ static fromJSON( data ) {
+
+ return new PlaneGeometry( data.width, data.height, data.widthSegments, data.heightSegments );
+
+ }
+
+}
+
+var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif";
+
+var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif";
+
+var alphatest_fragment = "#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif";
+
+var alphatest_pars_fragment = "#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif";
+
+var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif";
+
+var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
+
+var begin_vertex = "vec3 transformed = vec3( position );";
+
+var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
+
+var bsdfs = "vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\n#ifdef USE_IRIDESCENCE\nvec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = mix(F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence);\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\n#endif\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif";
+
+var iridescence_fragment = "#ifdef USE_IRIDESCENCE\nconst mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n);\nvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n}\nvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n}\nfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n}\nvec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( -pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[0] ) * exp( -4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 srgb = XYZ_TO_REC709 * xyz;\n return srgb;\n}\nvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float R21 = R12;\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[0] < iridescenceIOR ) phi23[0] = PI;\n if ( baseIOR[1] < iridescenceIOR ) phi23[1] = PI;\n if ( baseIOR[2] < iridescenceIOR ) phi23[2] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n}\n#endif";
+
+var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif";
+
+var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif";
+
+var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif";
+
+var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif";
+
+var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif";
+
+var color_fragment = "#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif";
+
+var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif";
+
+var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif";
+
+var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif";
+
+var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}";
+
+var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
+
+var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
+
+var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif";
+
+var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif";
+
+var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif";
+
+var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif";
+
+var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
+
+var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
+
+var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
+
+var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
+
+var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
+
+var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif";
+
+var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif";
+
+var fog_vertex = "#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif";
+
+var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif";
+
+var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif";
+
+var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
+
+var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
+
+var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
+
+var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
+
+var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif";
+
+var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
+
+var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif";
+
+var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
+
+var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)";
+
+var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
+
+var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)";
+
+var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif";
+
+var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
+
+var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\nfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\nif ( material.iridescenceThickness == 0.0 ) {\n\tmaterial.iridescence = 0.0;\n} else {\n\tmaterial.iridescence = saturate( material.iridescence );\n}\nif ( material.iridescence > 0.0 ) {\n\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
+
+var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
+
+var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif";
+
+var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
+
+var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
+
+var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif";
+
+var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif";
+
+var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
+
+var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";
+
+var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif";
+
+var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif";
+
+var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif";
+
+var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
+
+var morphcolor_vertex = "#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
+
+var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif";
+
+var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif";
+
+var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif";
+
+var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;";
+
+var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
+
+var normal_pars_fragment = "#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif";
+
+var normal_pars_vertex = "#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif";
+
+var normal_vertex = "#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif";
+
+var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif";
+
+var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif";
+
+var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif";
+
+var clearcoat_pars_fragment = "#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif";
+
+var iridescence_pars_fragment = "#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif";
+
+var output_fragment = "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );";
+
+var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
+
+var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
+
+var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
+
+var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
+
+var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif";
+
+var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif";
+
+var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
+
+var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif";
+
+var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
+
+var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif";
+
+var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
+
+var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
+
+var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif";
+
+var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
+
+var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif";
+
+var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";
+
+var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";
+
+var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
+
+var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
+
+var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif";
+
+var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif";
+
+var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif";
+
+var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif";
+
+var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
+
+var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";
+
+var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif";
+
+var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif";
+
+var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";
+
+const vertex$g = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
+
+const fragment$g = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\n\t#include \n\t#include \n}";
+
+const vertex$f = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}";
+
+const fragment$f = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}";
+
+const vertex$e = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}";
+
+const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}";
+
+const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}";
+
+const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}";
+
+const vertex$c = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}";
+
+const fragment$c = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}";
+
+const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}";
+
+const fragment$b = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}";
+
+const vertex$a = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}";
+
+const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}";
+
+const vertex$9 = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}";
+
+const fragment$9 = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include