npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@voxelfarm/voxelfarm-react-viewer

v1.0.1

Published

Voxel Farm Embedded Viewer

Readme

Voxel Farm Embedded Viewer

Installation

$ npm install --save @voxelfarm/voxelfarm-react-viewer

Usage

You can use the component the following way:


import React from 'react'
import EmbeddedViewer from '@voxelfarm/voxelfarm-react-viewer';

/**
 * React component that encapsulates a viewer to spatial data.
 */
<EmbeddedViewer
    /**  the id of the project. */
    projectId={string}
    /** the url of the streaming server. */
    streamingUrl={string}
    /** the url of the rest server. */
    restUrl={string}
    /** the id of the view. */
    viewId={string}
    /* create a view with json */
    viewJSON={string}
    /** (true/false) show/hide zoomToExtent button. */
    zoomToExtent={boolean}
    /** (true/false) show/hide fullscreen button. */
    fullscreen={boolean}
    /** (true/false) show/hide home button. */
    home={boolean}
    /** (true/false) show/hide the options button. */
    options={boolean}
    /** (true/false) show the controls inside/outside of the view. */
    showControlsInView={boolean}
    /** Event Notification is triggered when a change in a region occurs. 
     *  The event includes the following properties:
     *  voxelfarmPoints: the position of the region in Voxel Farm coordinates.
     *  voxelfarmMinY: min Y in Voxel Farm coordinates.
     *  voxelfarmMaxY: max Y in Voxel Farm coordinates.
     *  worldPoints: the position of the region in World coordinates.
     *  worldMinZ: min Z in world coordinates.
     *  worldMaxZ: max Z in world coordinates.
    */
    onRegionChange={EventHandler}
     /** Event Notification is triggered when clicking on a layer. 
      *  The event includes the following properties:
      *  eventType: mousedown/mouseup
      *  canvasPosition: the position of the canvas.
      *  layerId: the layer Id where the click occured.
      *  position: the position of the click in the screen.
      *  voxelfarmPosition: the position of the layer in Voxel Farm coordinates.
      *  windowPosition: the position of the window.
      *  worldPosition: the position of the layer in world coordinates.
      * 
     */
    onLayerClick={EventHandler}
     /** Function to return authentication if it is required */
    requestAuthToken={function}
/>

Examples

This is an example on how to retrieve layer information from the embedded view, how to change an input parameter for a layer and how to refresh the view.


import React, {Component} from 'react';
import EmbeddedViewer from '@voxelfarm/voxelfarm-react-viewer';

/**
 * React component that uses a EmbeddedViewer Component and add HTML input and a button .
 */
export default class App extends Component {
    /**
     * Event handler of the onClick Event
     *
     */
    onClick(){
        /* Using the React ref of the instance of the Emebedded Viewer Component. */
        if (this.viewer){
            /* getLayers method is called first to retreive the list of layers with their inputs. */
            const layers = this.viewer.getLayers();
            /* In this example we chose "com.voxelfarm.program.view.blockmodel" as the layer's type to make the modification upon. */
            if (layers.length > 0 && layers[0].type == "com.voxelfarm.program.view.blockmodel"){
                /* chosing the first layer */
                const firstLayer = layers[0];
                /* get the first layer id */
                const layerId = firstLayer.id;
                /* get the list of available inputs for this particular layer. */
                const inputs = firstLayer.inputs;
                /* get the input for a particular id here will take query as an example. */
                const inputId = "query";
                const input = inputs[inputId];
                /* get the label of this particular input */
                const label = input.label;
                /* get the type of this particular input */
                const type = input.type;
                /* retreive the value from the html input */
                const inputValue = document.querySelector('input').value;
                /* call setLayerInput method to set the value from the input string */
                this.viewer.setLayerInput(layerId, inputId, inputValue);
                /* call refreshView to update the view with the new value passed */
                this.viewer.refreshView();
            }
        }
    }

    /**
     * render function for the react component
     *
     */
    render(){
        return (     
            <div>
                <EmbeddedViewer 
                    /* ref is used to point to the instance of the EmbeddedViewer and assigned to variable called this.viewer */
                    ref={elem => this.viewer = elem}
                    projectId="<projectId>"
                    streamingUrl="<streamingUrl>"
                    restUrl="<restUrl>}"
                    /* either property viewId or viewJSON that can be used*/ 
                    viewId="<viewId>"
                    fullscreen="true"
                    zoomToExtent="true"
                    options="true"
                    home="false"
                    showControlsInView="true"                    
                />
                {/* adding an html input that includes the value that needs to be changed in the view. */}
                <input type="text" defaultValue="ins_fe > 10" />
                {/* an html button to trigger the modification of the view. */}
                <button onClick={e=>{this.onClick()}}>Search</button>
            </div>
        )
    }
}

Note

  • Either property viewJSON or viewId can be used at one time to create the viewer.

License

Voxel Farm Copyright 2022 © (https://www.voxelfarm.com/)