Socket
Book a DemoInstallSign in
Socket

dat-gui-defaults

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dat-gui-defaults

dat.GUI wrapper with defaults support

1.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

dat-gui-defaults

A useful wrapper of dat.GUI with defaults support. The provided DatGuiDefaults class makes it easy to write a demo app that requires default configuration handling.

Setup

Installation

$ npm install dat-gui-defaults

Usage

  • First, subclass DatGuiDefaults and implement initGui(gui, data, params). For example, here we create DemoGui class.
class DemoGui extends DatGuiDefaults {
    // override
    initGui(gui, data, params) {
        //-------- begin sample --------
        let controller = gui.add(params, 'wireframe').name('Wireframe');
        controller.onChange((value) => {
            data.wireframe = value;
        });
        controller = gui.add(params, 'reset').name("Restore Defaults");
        controller.onChange((value) => {
            this.applyDefaults();         // API to restore defaults for dat.GUI
            Object.assign(data, params);  // reflect the change in the app
        });
        //-------- end sample --------
    }
}
  • Use the custom class with an application data object.
const data = {                // app data
    wireframe: true,
};

const dg = new DemoGui(data); // instantiate with data
dg.setDefaults({              // defaults passed to dat.GUI
    wireframe: data.wireframe,
    reset: () => {},
});

API

  • new DatGuiDefaults(data)

    data (Object): app data object to be manipulated.

  • datGuiDefaults.setDefaults(params)

    params (Object): the params object for dat.GUI.

    Set the default parameters.

  • datGuiDefaults.applyDefaults()

    Restore the default parameters for dat.GUI.

  • datGuiDefaults.gui

    The underlying dat.GUI object can be accessed this way.

References

dat.GUI API documentation

Demo

Live demo (examples/demo-script-tag/index.html)

image

Build

$ npm install  # set up build tools
$ npm run build

Keywords

dat.gui

FAQs

Package last updated on 28 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.