build/browser/index.js
/**
         * @param canvas The canvas element identifier, or canvas element, or WebGL rendering context.
         * @param attributes Allows the context to be configured.
         * @param dom The document object model that contains the canvas.
         */
@param canvas The canvas element identifier, or canvas element, or WebGL rendering context.
@param attributes Allows the context to be configured.
@param dom The document object model that contains the canvas.
@param canvas The canvas element identifier or canvas element or WebGL rendering context . @param attributes Allows the context to be configured . @param dom The document object model that contains the canvas .
function Engine(canvas, attributes, dom) {
            if (attributes === void 0) { attributes = {}; }
            var _this = _super.call(this) || this;
            _this._users = [];
            _this._commands = new ShareableArray([]);
            _this.setLoggingName('Engine');
            _this._attributes = attributes;
            if (isDefined(attributes.contextId)) {
                _this._overrideContextId = mustBeWebGLContextId("attributes.contextId", attributes.contextId);
            }
            if (attributes.eightLogging) {
                _this._commands.pushWeakRef(new EIGHTLogger());
            }
            if (attributes.webglLogging) {
                _this._commands.pushWeakRef(new VersionLogger(_this));
            }
            _this._webGLContextLost = function (event) {
                if (isDefined(_this._gl)) {
                    event.preventDefault();
                    _this._gl = void 0;
                    _this._users.forEach(function (user) {
                        user.contextLost();
                    });
                }
            };
            _this._webGLContextRestored = function (event) {
                if (isDefined(_this._gl)) {
                    if (_this._gl.canvas instanceof HTMLCanvasElement) {
                        event.preventDefault();
                        var result = initWebGL(_this._gl.canvas, attributes, _this._overrideContextId);
                        _this._gl = checkEnums(result.context);
                        _this._contextId = result.contextId;
                        _this._users.forEach(function (user) {
                            user.contextGain();
                        });
                    }
                }
            };
            if (canvas) {
                if (dom) {
                    _this.start(canvas, dom);
                }
                else {
                    _this.start(canvas, getWindowDocument(window));
                }
            }
            return _this;
        }
function Engine ( canvas , attributes , dom ) { if ( attributes === void 0 ) { attributes = { } ; } var _this = _super . call ( this ) || this ; _this . _users = [ ] ; _this . _commands = new ShareableArray ( [ ] ) ; _this . setLoggingName ( 'Engine' ) ; _this . _attributes = attributes ; if ( isDefined ( attributes . contextId ) ) { _this . _overrideContextId = mustBeWebGLContextId ( "attributes.contextId" , attributes . contextId ) ; } if ( attributes . eightLogging ) { _this . _commands . pushWeakRef ( new EIGHTLogger ( ) ) ; } if ( attributes . webglLogging ) { _this . _commands . pushWeakRef ( new VersionLogger ( _this ) ) ; } _this . _webGLContextLost = function ( event ) { if ( isDefined ( _this . _gl ) ) { event . preventDefault ( ) ; _this . _gl = void 0 ; _this . _users . forEach ( function ( user ) { user . contextLost ( ) ; } ) ; } } ; _this . _webGLContextRestored = function ( event ) { if ( isDefined ( _this . _gl ) ) { if ( _this . _gl . canvas instanceof HTMLCanvasElement ) { event . preventDefault ( ) ; var result = initWebGL ( _this . _gl . canvas , attributes , _this . _overrideContextId ) ; _this . _gl = checkEnums ( result . context ) ; _this . _contextId = result . contextId ; _this . _users . forEach ( function ( user ) { user . contextGain ( ) ; } ) ; } } } ; if ( canvas ) { if ( dom ) { _this . start ( canvas , dom ) ; } else { _this . start ( canvas , getWindowDocument ( window ) ) ; } } return _this ; }
@param canvas The canvas element identifier, or canvas element, or WebGL rendering context.
@param canvas The canvas element identifier or canvas element or WebGL rendering context .
// Remark: We only hold weak references to users so that the lifetime of resource // objects is not affected by the fact that they are listening for gl events. // Users should automatically add themselves upon construction and remove upon release. /**
             * Actions that are executed when a WebGL rendering context is gained.
             */ // TODO: Defensive copy and strip off the extra attributes on EngineAttributes just in case the WebGL runtime gets strict and complains.