Skip to content

⬅️ Back to Table of Contents

📄 offscreencanvas-worker-orbitcontrols.js

📊 Analysis Summary

Metric Count
🔧 Functions 11
🧱 Classes 2
📦 Imports 2
📊 Variables & Constants 4

📚 Table of Contents

🛠️ File Location:

📂 manual/examples/offscreencanvas-worker-orbitcontrols.js

📦 Imports

Name Source
init ./shared-orbitcontrols.js
EventDispatcher https://cdn.skypack.dev/three@0.136.0/build/three.module.js

Variables & Constants

Name Type Kind Value Exported
proxy ElementProxyReceiver let/var new ElementProxyReceiver()
proxyManager ProxyManager let/var new ProxyManager()
handlers { start: (data: any) => void; makePro... let/var { start, makeProxy, event: proxyManager.handleEvent, }
fn any let/var handlers[ e.data.type ]

Functions

noop(): void

Returns: void

Code
function noop() {
}

ElementProxyReceiver.setPointerCapture(): void

Returns: void

Code
setPointerCapture() { }

ElementProxyReceiver.releasePointerCapture(): void

Returns: void

Code
releasePointerCapture() { }

ElementProxyReceiver.getBoundingClientRect(): { left: any; top: any; width: any; height: any; right: any; bottom: any; }

Returns: { left: any; top: any; width: any; height: any; right: any; bottom: any; }

Code
getBoundingClientRect() {

        return {
            left: this.left,
            top: this.top,
            width: this.width,
            height: this.height,
            right: this.left + this.width,
            bottom: this.top + this.height,
        };

    }

ElementProxyReceiver.handleEvent(data: any): void

Parameters:

  • data any

Returns: void

Calls:

  • this.dispatchEvent
Code
handleEvent( data ) {

        if ( data.type === 'size' ) {

            this.left = data.left;
            this.top = data.top;
            this.width = data.width;
            this.height = data.height;
            return;

        }

        data.preventDefault = noop;
        data.stopPropagation = noop;
        this.dispatchEvent( data );

    }

ElementProxyReceiver.focus(): void

Returns: void

Code
focus() {
        // no-op
    }

ProxyManager.makeProxy(data: any): void

Parameters:

  • data any

Returns: void

Code
makeProxy( data ) {

        const { id } = data;
        const proxy = new ElementProxyReceiver();
        this.targets[ id ] = proxy;

    }

ProxyManager.getProxy(id: any): any

Parameters:

  • id any

Returns: any

Code
getProxy( id ) {

        return this.targets[ id ];

    }

ProxyManager.handleEvent(data: any): void

Parameters:

  • data any

Returns: void

Calls:

  • this.targets[ data.id ].handleEvent
Code
handleEvent( data ) {

        this.targets[ data.id ].handleEvent( data.data );

    }

start(data: any): void

Parameters:

  • data any

Returns: void

Calls:

  • proxyManager.getProxy
  • init (from ./shared-orbitcontrols.js)
Code
function start( data ) {

    const proxy = proxyManager.getProxy( data.canvasId );
    proxy.ownerDocument = proxy; // HACK!
    self.document = {}; // HACK!
    init( {
        canvas: data.canvas,
        inputElement: proxy,
    } );

}

makeProxy(data: any): void

Parameters:

  • data any

Returns: void

Calls:

  • proxyManager.makeProxy
Code
function makeProxy( data ) {

    proxyManager.makeProxy( data );

}

Classes

ElementProxyReceiver

Class Code
class ElementProxyReceiver extends EventDispatcher {

    constructor() {

        super();
        // because OrbitControls try to set style.touchAction;
        this.style = {};

    }
    get clientWidth() {

        return this.width;

    }
    get clientHeight() {

        return this.height;

    }
    // OrbitControls call these as of r132. Maybe we should implement them
    setPointerCapture() { }
    releasePointerCapture() { }
    getBoundingClientRect() {

        return {
            left: this.left,
            top: this.top,
            width: this.width,
            height: this.height,
            right: this.left + this.width,
            bottom: this.top + this.height,
        };

    }
    handleEvent( data ) {

        if ( data.type === 'size' ) {

            this.left = data.left;
            this.top = data.top;
            this.width = data.width;
            this.height = data.height;
            return;

        }

        data.preventDefault = noop;
        data.stopPropagation = noop;
        this.dispatchEvent( data );

    }
    focus() {
        // no-op
    }

}

Methods

setPointerCapture(): void
Code
setPointerCapture() { }
releasePointerCapture(): void
Code
releasePointerCapture() { }
getBoundingClientRect(): { left: any; top: any; width: any; height: any; right: any; bottom: any; }
Code
getBoundingClientRect() {

        return {
            left: this.left,
            top: this.top,
            width: this.width,
            height: this.height,
            right: this.left + this.width,
            bottom: this.top + this.height,
        };

    }
handleEvent(data: any): void
Code
handleEvent( data ) {

        if ( data.type === 'size' ) {

            this.left = data.left;
            this.top = data.top;
            this.width = data.width;
            this.height = data.height;
            return;

        }

        data.preventDefault = noop;
        data.stopPropagation = noop;
        this.dispatchEvent( data );

    }
focus(): void
Code
focus() {
        // no-op
    }

ProxyManager

Class Code
class ProxyManager {

    constructor() {

        this.targets = {};
        this.handleEvent = this.handleEvent.bind( this );

    }
    makeProxy( data ) {

        const { id } = data;
        const proxy = new ElementProxyReceiver();
        this.targets[ id ] = proxy;

    }
    getProxy( id ) {

        return this.targets[ id ];

    }
    handleEvent( data ) {

        this.targets[ data.id ].handleEvent( data.data );

    }

}

Methods

makeProxy(data: any): void
Code
makeProxy( data ) {

        const { id } = data;
        const proxy = new ElementProxyReceiver();
        this.targets[ id ] = proxy;

    }
getProxy(id: any): any
Code
getProxy( id ) {

        return this.targets[ id ];

    }
handleEvent(data: any): void
Code
handleEvent( data ) {

        this.targets[ data.id ].handleEvent( data.data );

    }