repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
AzureAD/azure-activedirectory-library-for-nodejs | lib/token-request.js | TokenRequest | function TokenRequest(callContext, authenticationContext, clientId, resource, redirectUri) {
this._log = new Logger('TokenRequest', callContext._logContext);
this._callContext = callContext;
this._authenticationContext = authenticationContext;
this._resource = resource;
this._clientId = clientId;
this._redi... | javascript | function TokenRequest(callContext, authenticationContext, clientId, resource, redirectUri) {
this._log = new Logger('TokenRequest', callContext._logContext);
this._callContext = callContext;
this._authenticationContext = authenticationContext;
this._resource = resource;
this._clientId = clientId;
this._redi... | [
"function",
"TokenRequest",
"(",
"callContext",
",",
"authenticationContext",
",",
"clientId",
",",
"resource",
",",
"redirectUri",
")",
"{",
"this",
".",
"_log",
"=",
"new",
"Logger",
"(",
"'TokenRequest'",
",",
"callContext",
".",
"_logContext",
")",
";",
"t... | Constructs a new TokenRequest object.
@constructor
@private
@param {object} callContext Contains any context information that applies to the request.
@param {AuthenticationContext} authenticationContext
@param {string} resource
@param {string} clientId
@param {string} redirectUri | [
"Constructs",
"a",
"new",
"TokenRequest",
"object",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/token-request.js#L51-L65 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/user-realm.js | UserRealm | function UserRealm(callContext, userPrinciple, authority) {
this._log = new Logger('UserRealm', callContext._logContext);
this._callContext = callContext;
this._apiVersion = '1.0';
this._federationProtocol = null;
this._accountType = null;
this._federationMetadataUrl = null;
this._federationActiveAuthUrl ... | javascript | function UserRealm(callContext, userPrinciple, authority) {
this._log = new Logger('UserRealm', callContext._logContext);
this._callContext = callContext;
this._apiVersion = '1.0';
this._federationProtocol = null;
this._accountType = null;
this._federationMetadataUrl = null;
this._federationActiveAuthUrl ... | [
"function",
"UserRealm",
"(",
"callContext",
",",
"userPrinciple",
",",
"authority",
")",
"{",
"this",
".",
"_log",
"=",
"new",
"Logger",
"(",
"'UserRealm'",
",",
"callContext",
".",
"_logContext",
")",
";",
"this",
".",
"_callContext",
"=",
"callContext",
"... | Create a new UserRealm object
@private
@constructor
@param {object} callContext Contains any context information that applies to the request.
@param {string} userPrinciple The username for which a realm needs to be discovered.
@param {string} authority The string url of the authority that owns the userPrinciple... | [
"Create",
"a",
"new",
"UserRealm",
"object"
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/user-realm.js#L45-L55 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/wstrust-request.js | WSTrustRequest | function WSTrustRequest(callContext, wstrustEndpointUrl, appliesTo, wstrustEndpointVersion) {
this._log = new Logger('WSTrustRequest', callContext._logContext);
this._callContext = callContext;
this._wstrustEndpointUrl = wstrustEndpointUrl;
this._appliesTo = appliesTo;
this._wstrustEndpointVersion = wstrustEn... | javascript | function WSTrustRequest(callContext, wstrustEndpointUrl, appliesTo, wstrustEndpointVersion) {
this._log = new Logger('WSTrustRequest', callContext._logContext);
this._callContext = callContext;
this._wstrustEndpointUrl = wstrustEndpointUrl;
this._appliesTo = appliesTo;
this._wstrustEndpointVersion = wstrustEn... | [
"function",
"WSTrustRequest",
"(",
"callContext",
",",
"wstrustEndpointUrl",
",",
"appliesTo",
",",
"wstrustEndpointVersion",
")",
"{",
"this",
".",
"_log",
"=",
"new",
"Logger",
"(",
"'WSTrustRequest'",
",",
"callContext",
".",
"_logContext",
")",
";",
"this",
... | Creates a new instance of WSTrustRequest
@constructor
@private
@param {object} callContext Contains any context information that applies to the request.
@param {string} wstrustEndpointUrl An STS WS-Trust soap endpoint.
@param {string} appliesTo A URI that identifies a service for which the a toke... | [
"Creates",
"a",
"new",
"instance",
"of",
"WSTrustRequest"
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/wstrust-request.js#L42-L48 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/wstrust-request.js | _datePlusMinutes | function _datePlusMinutes(date, minutes) {
var minutesInMilliSeconds = minutes * 60 * 1000;
var epochTime = date.getTime() + minutesInMilliSeconds;
return new Date(epochTime);
} | javascript | function _datePlusMinutes(date, minutes) {
var minutesInMilliSeconds = minutes * 60 * 1000;
var epochTime = date.getTime() + minutesInMilliSeconds;
return new Date(epochTime);
} | [
"function",
"_datePlusMinutes",
"(",
"date",
",",
"minutes",
")",
"{",
"var",
"minutesInMilliSeconds",
"=",
"minutes",
"*",
"60",
"*",
"1000",
";",
"var",
"epochTime",
"=",
"date",
".",
"getTime",
"(",
")",
"+",
"minutesInMilliSeconds",
";",
"return",
"new",... | Given a Date object adds the minutes parameter and returns a new Date object.
@private
@static
@memberOf WSTrustRequest
@param {Date} date A Date object.
@param {Number} minutes The number of minutes to add to the date parameter.
@returns {Date} Returns a Date object. | [
"Given",
"a",
"Date",
"object",
"adds",
"the",
"minutes",
"parameter",
"and",
"returns",
"a",
"new",
"Date",
"object",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/wstrust-request.js#L59-L63 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/util.js | createRequestOptions | function createRequestOptions(self, options) {
var defaultOptions = {}; //{ strictSSL : true };
var mergedOptions = defaultOptions;
if (options) {
_.extend(mergedOptions, options);
}
if (self._callContext.options && self._callContext.options.http) {
_.extend(mergedOptions, self._callContext.options.ht... | javascript | function createRequestOptions(self, options) {
var defaultOptions = {}; //{ strictSSL : true };
var mergedOptions = defaultOptions;
if (options) {
_.extend(mergedOptions, options);
}
if (self._callContext.options && self._callContext.options.http) {
_.extend(mergedOptions, self._callContext.options.ht... | [
"function",
"createRequestOptions",
"(",
"self",
",",
"options",
")",
"{",
"var",
"defaultOptions",
"=",
"{",
"}",
";",
"//{ strictSSL : true };",
"var",
"mergedOptions",
"=",
"defaultOptions",
";",
"if",
"(",
"options",
")",
"{",
"_",
".",
"extend",
"(",
"m... | Central place for housing default request options. This is a place holder
for when SSL validation is implemented an all requests are subject to that
policy.
@static
@memberOf Util
@param {object} options A set of options that will be merged with teh default options
These will override any default options.
@returns {... | [
"Central",
"place",
"for",
"housing",
"default",
"request",
"options",
".",
"This",
"is",
"a",
"place",
"holder",
"for",
"when",
"SSL",
"validation",
"is",
"implemented",
"an",
"all",
"requests",
"are",
"subject",
"to",
"that",
"policy",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/util.js#L80-L92 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/wstrust-response.js | scrubRSTRLogMessage | function scrubRSTRLogMessage(RSTR) {
var scrubbedRSTR = null;
var singleLineRSTR = RSTR.replace(/(\r\n|\n|\r)/gm,'');
var matchResult = assertionRegEx.exec(singleLineRSTR);
if (null === matchResult) {
// No Assertion was matched so just return the RSTR as is.
scrubbedRSTR = singleLineRSTR;
} else {
... | javascript | function scrubRSTRLogMessage(RSTR) {
var scrubbedRSTR = null;
var singleLineRSTR = RSTR.replace(/(\r\n|\n|\r)/gm,'');
var matchResult = assertionRegEx.exec(singleLineRSTR);
if (null === matchResult) {
// No Assertion was matched so just return the RSTR as is.
scrubbedRSTR = singleLineRSTR;
} else {
... | [
"function",
"scrubRSTRLogMessage",
"(",
"RSTR",
")",
"{",
"var",
"scrubbedRSTR",
"=",
"null",
";",
"var",
"singleLineRSTR",
"=",
"RSTR",
".",
"replace",
"(",
"/",
"(\\r\\n|\\n|\\r)",
"/",
"gm",
",",
"''",
")",
";",
"var",
"matchResult",
"=",
"assertionRegEx"... | Creates a log message that contains the RSTR scrubbed of the actual SAML assertion.
@private
@return {string} A log message. | [
"Creates",
"a",
"log",
"message",
"that",
"contains",
"the",
"RSTR",
"scrubbed",
"of",
"the",
"actual",
"SAML",
"assertion",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/wstrust-response.js#L43-L60 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/wstrust-response.js | WSTrustResponse | function WSTrustResponse(callContext, response, wstrustVersion) {
this._log = new Logger('WSTrustResponse', callContext._logContext);
this._callContext = callContext;
this._response = response;
this._dom = null;
this._errorCode = null;
this._faultMessage = null;
this._tokenType = null;
this._token = nul... | javascript | function WSTrustResponse(callContext, response, wstrustVersion) {
this._log = new Logger('WSTrustResponse', callContext._logContext);
this._callContext = callContext;
this._response = response;
this._dom = null;
this._errorCode = null;
this._faultMessage = null;
this._tokenType = null;
this._token = nul... | [
"function",
"WSTrustResponse",
"(",
"callContext",
",",
"response",
",",
"wstrustVersion",
")",
"{",
"this",
".",
"_log",
"=",
"new",
"Logger",
"(",
"'WSTrustResponse'",
",",
"callContext",
".",
"_logContext",
")",
";",
"this",
".",
"_callContext",
"=",
"callC... | Creates a new WSTrustResponse instance.
@constructor
@private
@param {object} callContext Contains any context information that applies to the request.
@param {string} response A soap response from a WS-Trust request.
@param {sting} wstrustVersion The version for the WS-Trust request. | [
"Creates",
"a",
"new",
"WSTrustResponse",
"instance",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/wstrust-response.js#L70-L82 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/code-request.js | CodeRequest | function CodeRequest(callContext, authenticationContext, clientId, resource) {
this._log = new Logger('DeviceCodeRequest', callContext._logContext);
this._callContext = callContext;
this._authenticationContext = authenticationContext;
this._resource = resource;
this._clientId = clientId;
//... | javascript | function CodeRequest(callContext, authenticationContext, clientId, resource) {
this._log = new Logger('DeviceCodeRequest', callContext._logContext);
this._callContext = callContext;
this._authenticationContext = authenticationContext;
this._resource = resource;
this._clientId = clientId;
//... | [
"function",
"CodeRequest",
"(",
"callContext",
",",
"authenticationContext",
",",
"clientId",
",",
"resource",
")",
"{",
"this",
".",
"_log",
"=",
"new",
"Logger",
"(",
"'DeviceCodeRequest'",
",",
"callContext",
".",
"_logContext",
")",
";",
"this",
".",
"_cal... | Constructs a new CodeRequest object.
@constructor
@private
@param {object} callContext Contains any context information that applies to the request.
@param {AuthenticationContext} authenticationContext
@param {string} resource
@param {string} clientId
TODO: probably need to modify the parameter list. | [
"Constructs",
"a",
"new",
"CodeRequest",
"object",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/code-request.js#L43-L53 | train |
AzureAD/azure-activedirectory-library-for-nodejs | lib/mex.js | Mex | function Mex(callContext, url) {
this._log = new Logger('MEX', callContext._logContext);
this._callContext = callContext;
this._url = url;
this._dom = null;
this._mexDoc = null;
this._usernamePasswordPolicy = {};
this._log.verbose('Mex created');
this._log.verbose('Mex created with url: ' + url, true);
... | javascript | function Mex(callContext, url) {
this._log = new Logger('MEX', callContext._logContext);
this._callContext = callContext;
this._url = url;
this._dom = null;
this._mexDoc = null;
this._usernamePasswordPolicy = {};
this._log.verbose('Mex created');
this._log.verbose('Mex created with url: ' + url, true);
... | [
"function",
"Mex",
"(",
"callContext",
",",
"url",
")",
"{",
"this",
".",
"_log",
"=",
"new",
"Logger",
"(",
"'MEX'",
",",
"callContext",
".",
"_logContext",
")",
";",
"this",
".",
"_callContext",
"=",
"callContext",
";",
"this",
".",
"_url",
"=",
"url... | Create a new Mex object.
@private
@constructor
@param {object} callContext Contains any context information that applies to the request.
@param {string} url The url of the mex endpoint. | [
"Create",
"a",
"new",
"Mex",
"object",
"."
] | 89ccef01b565d9f56a6f702f835aa2f9d1230aaf | https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/89ccef01b565d9f56a6f702f835aa2f9d1230aaf/lib/mex.js#L43-L52 | train |
stomp-js/stompjs | spec/unit/frame.spec.js | function(data, escapeHeaderValues) {
const onFrame = jasmine.createSpy('onFrame');
const onIncomingPing = jasmine.createSpy('onIncomingPing');
const parser = new StompJs.Parser(onFrame, onIncomingPing);
parser.parseChunk(data);
const rawFrame = onFrame.calls.first().args[0];
return StompJs.Fra... | javascript | function(data, escapeHeaderValues) {
const onFrame = jasmine.createSpy('onFrame');
const onIncomingPing = jasmine.createSpy('onIncomingPing');
const parser = new StompJs.Parser(onFrame, onIncomingPing);
parser.parseChunk(data);
const rawFrame = onFrame.calls.first().args[0];
return StompJs.Fra... | [
"function",
"(",
"data",
",",
"escapeHeaderValues",
")",
"{",
"const",
"onFrame",
"=",
"jasmine",
".",
"createSpy",
"(",
"'onFrame'",
")",
";",
"const",
"onIncomingPing",
"=",
"jasmine",
".",
"createSpy",
"(",
"'onIncomingPing'",
")",
";",
"const",
"parser",
... | un-marshall a data chunk, for ease of matching body is converted to string | [
"un",
"-",
"marshall",
"a",
"data",
"chunk",
"for",
"ease",
"of",
"matching",
"body",
"is",
"converted",
"to",
"string"
] | f11ad889211b9a8bd5c90d7309a23b832e1b60af | https://github.com/stomp-js/stompjs/blob/f11ad889211b9a8bd5c90d7309a23b832e1b60af/spec/unit/frame.spec.js#L4-L13 | train | |
eBay/ebayui-core | src/components/ebay-dialog/index.js | trap | function trap(opts) {
const { isTrapped: wasTrapped, restoreTrap } = this;
const isTrapped = this.isTrapped = this.state.open;
const isFirstRender = (opts && opts.firstRender);
const wasToggled = isTrapped !== wasTrapped;
const focusEl = (this.state.focus && document.getElementById(this.state.focus)... | javascript | function trap(opts) {
const { isTrapped: wasTrapped, restoreTrap } = this;
const isTrapped = this.isTrapped = this.state.open;
const isFirstRender = (opts && opts.firstRender);
const wasToggled = isTrapped !== wasTrapped;
const focusEl = (this.state.focus && document.getElementById(this.state.focus)... | [
"function",
"trap",
"(",
"opts",
")",
"{",
"const",
"{",
"isTrapped",
":",
"wasTrapped",
",",
"restoreTrap",
"}",
"=",
"this",
";",
"const",
"isTrapped",
"=",
"this",
".",
"isTrapped",
"=",
"this",
".",
"state",
".",
"open",
";",
"const",
"isFirstRender"... | Ensures that if a component is supposed to be trapped that this is
trapped after rendering. | [
"Ensures",
"that",
"if",
"a",
"component",
"is",
"supposed",
"to",
"be",
"trapped",
"that",
"this",
"is",
"trapped",
"after",
"rendering",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-dialog/index.js#L76-L138 | train |
eBay/ebayui-core | src/components/ebay-dialog/index.js | release | function release() {
if (this.isTrapped) {
this.restoreTrap = this.state.open;
screenReaderTrap.untrap(this.windowEl);
keyboardTrap.untrap(this.windowEl);
} else {
this.restoreTrap = false;
}
} | javascript | function release() {
if (this.isTrapped) {
this.restoreTrap = this.state.open;
screenReaderTrap.untrap(this.windowEl);
keyboardTrap.untrap(this.windowEl);
} else {
this.restoreTrap = false;
}
} | [
"function",
"release",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isTrapped",
")",
"{",
"this",
".",
"restoreTrap",
"=",
"this",
".",
"state",
".",
"open",
";",
"screenReaderTrap",
".",
"untrap",
"(",
"this",
".",
"windowEl",
")",
";",
"keyboardTrap",
"."... | Releases the trap before each render and on destroy so
that Marko can update normally without the inserted dom nodes. | [
"Releases",
"the",
"trap",
"before",
"each",
"render",
"and",
"on",
"destroy",
"so",
"that",
"Marko",
"can",
"update",
"normally",
"without",
"the",
"inserted",
"dom",
"nodes",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-dialog/index.js#L144-L152 | train |
eBay/ebayui-core | src/components/ebay-pagination/index.js | handlePageClick | function handlePageClick(originalEvent) {
const target = originalEvent.target;
emitAndFire(this, 'pagination-select', {
originalEvent,
el: target,
value: target.innerText
});
} | javascript | function handlePageClick(originalEvent) {
const target = originalEvent.target;
emitAndFire(this, 'pagination-select', {
originalEvent,
el: target,
value: target.innerText
});
} | [
"function",
"handlePageClick",
"(",
"originalEvent",
")",
"{",
"const",
"target",
"=",
"originalEvent",
".",
"target",
";",
"emitAndFire",
"(",
"this",
",",
"'pagination-select'",
",",
"{",
"originalEvent",
",",
"el",
":",
"target",
",",
"value",
":",
"target"... | Handle normal mouse click for item, next page and previous page respectively.
@param {MouseEvent} event | [
"Handle",
"normal",
"mouse",
"click",
"for",
"item",
"next",
"page",
"and",
"previous",
"page",
"respectively",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-pagination/index.js#L144-L151 | train |
eBay/ebayui-core | src/common/transition/index.js | cancel | function cancel() {
if (ended) {
return;
}
ended = true;
for (let i = ran; i < pending; i++) {
const child = waitFor[i];
child.removeEventListener(TRANSITION_END, listener);
}
if (cancelFrame) {
cancelFrame();
... | javascript | function cancel() {
if (ended) {
return;
}
ended = true;
for (let i = ran; i < pending; i++) {
const child = waitFor[i];
child.removeEventListener(TRANSITION_END, listener);
}
if (cancelFrame) {
cancelFrame();
... | [
"function",
"cancel",
"(",
")",
"{",
"if",
"(",
"ended",
")",
"{",
"return",
";",
"}",
"ended",
"=",
"true",
";",
"for",
"(",
"let",
"i",
"=",
"ran",
";",
"i",
"<",
"pending",
";",
"i",
"++",
")",
"{",
"const",
"child",
"=",
"waitFor",
"[",
"... | Cancels the current transition and resets the className. | [
"Cancels",
"the",
"current",
"transition",
"and",
"resets",
"the",
"className",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/transition/index.js#L49-L67 | train |
eBay/ebayui-core | src/common/transition/index.js | listener | function listener({ target }) {
target.removeEventListener(TRANSITION_END, listener);
if (++ran === pending) {
ended = true;
classList.remove(className);
if (cb) {
cb();
}
}
} | javascript | function listener({ target }) {
target.removeEventListener(TRANSITION_END, listener);
if (++ran === pending) {
ended = true;
classList.remove(className);
if (cb) {
cb();
}
}
} | [
"function",
"listener",
"(",
"{",
"target",
"}",
")",
"{",
"target",
".",
"removeEventListener",
"(",
"TRANSITION_END",
",",
"listener",
")",
";",
"if",
"(",
"++",
"ran",
"===",
"pending",
")",
"{",
"ended",
"=",
"true",
";",
"classList",
".",
"remove",
... | Handles a single transition end event.
Once all child transitions have ended the overall animation is completed. | [
"Handles",
"a",
"single",
"transition",
"end",
"event",
".",
"Once",
"all",
"child",
"transitions",
"have",
"ended",
"the",
"overall",
"animation",
"is",
"completed",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/transition/index.js#L73-L84 | train |
eBay/ebayui-core | src/common/transition/index.js | nextFrame | function nextFrame(fn) {
let frame;
let cancelFrame;
if (window.requestAnimationFrame) {
frame = requestAnimationFrame(() => {
frame = requestAnimationFrame(fn);
});
cancelFrame = cancelAnimationFrame;
} else {
frame = setTimeout(fn, 26); // 16ms to simulate ... | javascript | function nextFrame(fn) {
let frame;
let cancelFrame;
if (window.requestAnimationFrame) {
frame = requestAnimationFrame(() => {
frame = requestAnimationFrame(fn);
});
cancelFrame = cancelAnimationFrame;
} else {
frame = setTimeout(fn, 26); // 16ms to simulate ... | [
"function",
"nextFrame",
"(",
"fn",
")",
"{",
"let",
"frame",
";",
"let",
"cancelFrame",
";",
"if",
"(",
"window",
".",
"requestAnimationFrame",
")",
"{",
"frame",
"=",
"requestAnimationFrame",
"(",
"(",
")",
"=>",
"{",
"frame",
"=",
"requestAnimationFrame",... | Runs a function during the next animation frame.
@param {function} fn a function to run on the next animation frame.
@return {function} a function to cancel the callback. | [
"Runs",
"a",
"function",
"during",
"the",
"next",
"animation",
"frame",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/transition/index.js#L93-L113 | train |
eBay/ebayui-core | src/common/html-attributes/index.js | processHtmlAttributes | function processHtmlAttributes(input = {}) {
const attributes = {};
const htmlAttributes = input.htmlAttributes;
const wildcardAttributes = input['*'];
let obj = htmlAttributes || wildcardAttributes;
if (htmlAttributes && wildcardAttributes) {
obj = Object.assign(wildcardAttributes, htmlAtt... | javascript | function processHtmlAttributes(input = {}) {
const attributes = {};
const htmlAttributes = input.htmlAttributes;
const wildcardAttributes = input['*'];
let obj = htmlAttributes || wildcardAttributes;
if (htmlAttributes && wildcardAttributes) {
obj = Object.assign(wildcardAttributes, htmlAtt... | [
"function",
"processHtmlAttributes",
"(",
"input",
"=",
"{",
"}",
")",
"{",
"const",
"attributes",
"=",
"{",
"}",
";",
"const",
"htmlAttributes",
"=",
"input",
".",
"htmlAttributes",
";",
"const",
"wildcardAttributes",
"=",
"input",
"[",
"'*'",
"]",
";",
"... | Create object of HTML attributes for pass-through to the DOM
@param {Object} input | [
"Create",
"object",
"of",
"HTML",
"attributes",
"for",
"pass",
"-",
"through",
"to",
"the",
"DOM"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/html-attributes/index.js#L14-L31 | train |
eBay/ebayui-core | src/common/emit-and-fire/index.js | emitAndFire | function emitAndFire(widget, eventName, eventArg) {
const originalEmit = widget.emit;
let event;
if ('CustomEvent' in window && typeof window.CustomEvent === 'function') {
event = new CustomEvent(eventName, { detail: eventArg });
} else {
event = document.createEvent('CustomEvent');
... | javascript | function emitAndFire(widget, eventName, eventArg) {
const originalEmit = widget.emit;
let event;
if ('CustomEvent' in window && typeof window.CustomEvent === 'function') {
event = new CustomEvent(eventName, { detail: eventArg });
} else {
event = document.createEvent('CustomEvent');
... | [
"function",
"emitAndFire",
"(",
"widget",
",",
"eventName",
",",
"eventArg",
")",
"{",
"const",
"originalEmit",
"=",
"widget",
".",
"emit",
";",
"let",
"event",
";",
"if",
"(",
"'CustomEvent'",
"in",
"window",
"&&",
"typeof",
"window",
".",
"CustomEvent",
... | Emit marko event and fire custom event on the root element
@param {Object} widget
@param {String} eventName
@param {Object} eventArg | [
"Emit",
"marko",
"event",
"and",
"fire",
"custom",
"event",
"on",
"the",
"root",
"element"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/emit-and-fire/index.js#L7-L18 | train |
eBay/ebayui-core | src/components/ebay-tab/index.js | processStateChange | function processStateChange(index) {
if (index >= 0 && index < this.state.headings.length && index !== this.state.index) {
this.setState('index', index);
emitAndFire(this, 'tab-select', { index });
}
} | javascript | function processStateChange(index) {
if (index >= 0 && index < this.state.headings.length && index !== this.state.index) {
this.setState('index', index);
emitAndFire(this, 'tab-select', { index });
}
} | [
"function",
"processStateChange",
"(",
"index",
")",
"{",
"if",
"(",
"index",
">=",
"0",
"&&",
"index",
"<",
"this",
".",
"state",
".",
"headings",
".",
"length",
"&&",
"index",
"!==",
"this",
".",
"state",
".",
"index",
")",
"{",
"this",
".",
"setSt... | Common processing of index change via both UI and API
@param {Number} index | [
"Common",
"processing",
"of",
"index",
"change",
"via",
"both",
"UI",
"and",
"API"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-tab/index.js#L56-L61 | train |
eBay/ebayui-core | src/components/ebay-tab/index.js | getHeadingEl | function getHeadingEl(e, isFake) {
let headingEl = e.target;
const headingClass = prefix(isFake, 'tabs__item');
while (!headingEl.classList.contains(headingClass)) {
headingEl = headingEl.parentNode;
}
return headingEl;
} | javascript | function getHeadingEl(e, isFake) {
let headingEl = e.target;
const headingClass = prefix(isFake, 'tabs__item');
while (!headingEl.classList.contains(headingClass)) {
headingEl = headingEl.parentNode;
}
return headingEl;
} | [
"function",
"getHeadingEl",
"(",
"e",
",",
"isFake",
")",
"{",
"let",
"headingEl",
"=",
"e",
".",
"target",
";",
"const",
"headingClass",
"=",
"prefix",
"(",
"isFake",
",",
"'tabs__item'",
")",
";",
"while",
"(",
"!",
"headingEl",
".",
"classList",
".",
... | Get heading element from event
@param {Event} e
@param {Boolean} isFake - If the tabs are fake | [
"Get",
"heading",
"element",
"from",
"event"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-tab/index.js#L76-L83 | train |
eBay/ebayui-core | src/components/ebay-tab/index.js | getElementIndex | function getElementIndex(headingEl) {
return Array.prototype.slice.call(headingEl.parentNode.children).indexOf(headingEl);
} | javascript | function getElementIndex(headingEl) {
return Array.prototype.slice.call(headingEl.parentNode.children).indexOf(headingEl);
} | [
"function",
"getElementIndex",
"(",
"headingEl",
")",
"{",
"return",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"headingEl",
".",
"parentNode",
".",
"children",
")",
".",
"indexOf",
"(",
"headingEl",
")",
";",
"}"
] | Get 0-based index of element within its parent
@param {HTMLElement} headingEl | [
"Get",
"0",
"-",
"based",
"index",
"of",
"element",
"within",
"its",
"parent"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-tab/index.js#L89-L91 | train |
eBay/ebayui-core | src/components/ebay-menu/index.js | handleItemClick | function handleItemClick(e) {
let itemEl = e.target;
const parentEl = itemEl.closest('.menu__item, .fake-menu__item');
if (parentEl) { // nested click inside menu_item
itemEl = parentEl;
}
this.setCheckedItem(getItemElementIndex(itemEl), true);
} | javascript | function handleItemClick(e) {
let itemEl = e.target;
const parentEl = itemEl.closest('.menu__item, .fake-menu__item');
if (parentEl) { // nested click inside menu_item
itemEl = parentEl;
}
this.setCheckedItem(getItemElementIndex(itemEl), true);
} | [
"function",
"handleItemClick",
"(",
"e",
")",
"{",
"let",
"itemEl",
"=",
"e",
".",
"target",
";",
"const",
"parentEl",
"=",
"itemEl",
".",
"closest",
"(",
"'.menu__item, .fake-menu__item'",
")",
";",
"if",
"(",
"parentEl",
")",
"{",
"// nested click inside men... | Handle normal mouse click for item
@param {MouseEvent} e | [
"Handle",
"normal",
"mouse",
"click",
"for",
"item"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-menu/index.js#L246-L255 | train |
eBay/ebayui-core | src/components/ebay-menu/index.js | setCheckedItem | function setCheckedItem(itemIndex, toggle) {
const item = this.state.items[itemIndex];
if (item) {
if (this.state.isCheckbox && !toggle) {
item.checked = true;
} else if (this.state.isCheckbox && toggle) {
item.checked = !item.checked;
} else if (this.state.isRad... | javascript | function setCheckedItem(itemIndex, toggle) {
const item = this.state.items[itemIndex];
if (item) {
if (this.state.isCheckbox && !toggle) {
item.checked = true;
} else if (this.state.isCheckbox && toggle) {
item.checked = !item.checked;
} else if (this.state.isRad... | [
"function",
"setCheckedItem",
"(",
"itemIndex",
",",
"toggle",
")",
"{",
"const",
"item",
"=",
"this",
".",
"state",
".",
"items",
"[",
"itemIndex",
"]",
";",
"if",
"(",
"item",
")",
"{",
"if",
"(",
"this",
".",
"state",
".",
"isCheckbox",
"&&",
"!",... | Set the checked item based on the index
@param {Integer} itemIndex
@param {Boolean} toggle | [
"Set",
"the",
"checked",
"item",
"based",
"on",
"the",
"index"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-menu/index.js#L262-L282 | train |
eBay/ebayui-core | src/components/ebay-menu/index.js | setCheckedList | function setCheckedList(indexArray) {
if (indexArray) {
this.state.items.forEach((item) => {
item.checked = false;
});
indexArray.forEach((index) => {
this.setCheckedItem(index);
});
this.processAfterStateChange(indexArray);
}
} | javascript | function setCheckedList(indexArray) {
if (indexArray) {
this.state.items.forEach((item) => {
item.checked = false;
});
indexArray.forEach((index) => {
this.setCheckedItem(index);
});
this.processAfterStateChange(indexArray);
}
} | [
"function",
"setCheckedList",
"(",
"indexArray",
")",
"{",
"if",
"(",
"indexArray",
")",
"{",
"this",
".",
"state",
".",
"items",
".",
"forEach",
"(",
"(",
"item",
")",
"=>",
"{",
"item",
".",
"checked",
"=",
"false",
";",
"}",
")",
";",
"indexArray"... | Set the list of options by their index
@param {Array} indexArray | [
"Set",
"the",
"list",
"of",
"options",
"by",
"their",
"index"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-menu/index.js#L353-L365 | train |
eBay/ebayui-core | src/common/transformers/ebayui-attribute/index.js | transform | function transform(el, context) {
// Only runs on top level ebay ui templates (skips demos).
const isEbayUIComponentFile = COMPONENT_FILES.indexOf(context.filename) !== -1;
if (isEbayUIComponentFile && el.hasAttribute('w-bind')) {
el.setAttributeValue('data-ebayui', context.builder.literal(true));
... | javascript | function transform(el, context) {
// Only runs on top level ebay ui templates (skips demos).
const isEbayUIComponentFile = COMPONENT_FILES.indexOf(context.filename) !== -1;
if (isEbayUIComponentFile && el.hasAttribute('w-bind')) {
el.setAttributeValue('data-ebayui', context.builder.literal(true));
... | [
"function",
"transform",
"(",
"el",
",",
"context",
")",
"{",
"// Only runs on top level ebay ui templates (skips demos).",
"const",
"isEbayUIComponentFile",
"=",
"COMPONENT_FILES",
".",
"indexOf",
"(",
"context",
".",
"filename",
")",
"!==",
"-",
"1",
";",
"if",
"(... | Transform to add the `data-ebayui` attribute to top level elements for all components.
@param {Object} el
@param {Object} context | [
"Transform",
"to",
"add",
"the",
"data",
"-",
"ebayui",
"attribute",
"to",
"top",
"level",
"elements",
"for",
"all",
"components",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/transformers/ebayui-attribute/index.js#L14-L21 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | handleMove | function handleMove(originalEvent, target) {
if (this.isMoving) {
return;
}
const { state } = this;
const direction = parseInt(target.getAttribute('data-direction'), 10);
const nextIndex = this.move(direction);
const slide = getSlide(state, nextIndex);
emitAndFire(this, 'carousel-sli... | javascript | function handleMove(originalEvent, target) {
if (this.isMoving) {
return;
}
const { state } = this;
const direction = parseInt(target.getAttribute('data-direction'), 10);
const nextIndex = this.move(direction);
const slide = getSlide(state, nextIndex);
emitAndFire(this, 'carousel-sli... | [
"function",
"handleMove",
"(",
"originalEvent",
",",
"target",
")",
"{",
"if",
"(",
"this",
".",
"isMoving",
")",
"{",
"return",
";",
"}",
"const",
"{",
"state",
"}",
"=",
"this",
";",
"const",
"direction",
"=",
"parseInt",
"(",
"target",
".",
"getAttr... | Moves the carousel in the `data-direction` of the clicked element if possible.
@param {MouseEvent} originalEvent
@param {HTMLElement} target | [
"Moves",
"the",
"carousel",
"in",
"the",
"data",
"-",
"direction",
"of",
"the",
"clicked",
"element",
"if",
"possible",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L263-L273 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | handleDotClick | function handleDotClick(originalEvent, target) {
if (this.isMoving) {
return;
}
const { state: { config, itemsPerSlide } } = this;
const slide = parseInt(target.getAttribute('data-slide'), 10);
config.preserveItems = true;
this.setState('index', slide * itemsPerSlide);
emitAndFire(th... | javascript | function handleDotClick(originalEvent, target) {
if (this.isMoving) {
return;
}
const { state: { config, itemsPerSlide } } = this;
const slide = parseInt(target.getAttribute('data-slide'), 10);
config.preserveItems = true;
this.setState('index', slide * itemsPerSlide);
emitAndFire(th... | [
"function",
"handleDotClick",
"(",
"originalEvent",
",",
"target",
")",
"{",
"if",
"(",
"this",
".",
"isMoving",
")",
"{",
"return",
";",
"}",
"const",
"{",
"state",
":",
"{",
"config",
",",
"itemsPerSlide",
"}",
"}",
"=",
"this",
";",
"const",
"slide"... | Moves the carousel to the slide at `data-slide` for the clicked element if possible.
@param {MouseEvent} originalEvent
@param {HTMLElement} target | [
"Moves",
"the",
"carousel",
"to",
"the",
"slide",
"at",
"data",
"-",
"slide",
"for",
"the",
"clicked",
"element",
"if",
"possible",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L281-L290 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | togglePlay | function togglePlay(originalEvent) {
const { state: { config, paused } } = this;
config.preserveItems = true;
this.setState('paused', !paused);
if (paused && !this.isMoving) {
this.move(RIGHT);
}
emitAndFire(this, `carousel-${paused ? 'play' : 'pause'}`, { originalEvent });
} | javascript | function togglePlay(originalEvent) {
const { state: { config, paused } } = this;
config.preserveItems = true;
this.setState('paused', !paused);
if (paused && !this.isMoving) {
this.move(RIGHT);
}
emitAndFire(this, `carousel-${paused ? 'play' : 'pause'}`, { originalEvent });
} | [
"function",
"togglePlay",
"(",
"originalEvent",
")",
"{",
"const",
"{",
"state",
":",
"{",
"config",
",",
"paused",
"}",
"}",
"=",
"this",
";",
"config",
".",
"preserveItems",
"=",
"true",
";",
"this",
".",
"setState",
"(",
"'paused'",
",",
"!",
"pause... | Toggles the play state of an autoplay carousel.
@param {MouseEvent} originalEvent | [
"Toggles",
"the",
"play",
"state",
"of",
"an",
"autoplay",
"carousel",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L297-L305 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | handleScroll | function handleScroll(scrollLeft) {
const { state } = this;
const { config, items, gap } = state;
let closest;
if (scrollLeft >= getMaxOffset(state) - gap) {
closest = items.length - 1;
} else {
// Find the closest item using a binary search on each carousel slide.
const ite... | javascript | function handleScroll(scrollLeft) {
const { state } = this;
const { config, items, gap } = state;
let closest;
if (scrollLeft >= getMaxOffset(state) - gap) {
closest = items.length - 1;
} else {
// Find the closest item using a binary search on each carousel slide.
const ite... | [
"function",
"handleScroll",
"(",
"scrollLeft",
")",
"{",
"const",
"{",
"state",
"}",
"=",
"this",
";",
"const",
"{",
"config",
",",
"items",
",",
"gap",
"}",
"=",
"state",
";",
"let",
"closest",
";",
"if",
"(",
"scrollLeft",
">=",
"getMaxOffset",
"(",
... | Find the closest item index to the scroll offset and triggers an update.
@param {number} scrollLeft The current scroll position of the carousel. | [
"Find",
"the",
"closest",
"item",
"index",
"to",
"the",
"scroll",
"offset",
"and",
"triggers",
"an",
"update",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L312-L346 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | move | function move(delta) {
const { state } = this;
const { index, items, itemsPerSlide, autoplayInterval, slideWidth, gap, peek, config } = state;
const nextIndex = getNextIndex(state, delta);
let offsetOverride;
config.preserveItems = true;
this.isMoving = true;
// When we are in autoplay mod... | javascript | function move(delta) {
const { state } = this;
const { index, items, itemsPerSlide, autoplayInterval, slideWidth, gap, peek, config } = state;
const nextIndex = getNextIndex(state, delta);
let offsetOverride;
config.preserveItems = true;
this.isMoving = true;
// When we are in autoplay mod... | [
"function",
"move",
"(",
"delta",
")",
"{",
"const",
"{",
"state",
"}",
"=",
"this",
";",
"const",
"{",
"index",
",",
"items",
",",
"itemsPerSlide",
",",
"autoplayInterval",
",",
"slideWidth",
",",
"gap",
",",
"peek",
",",
"config",
"}",
"=",
"state",
... | Causes the carousel to move to the provided index.
@param {-1|1} delta 1 for right and -1 for left.
@return {number} the updated index. | [
"Causes",
"the",
"carousel",
"to",
"move",
"to",
"the",
"provided",
"index",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L354-L401 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | getOffset | function getOffset(state) {
const { items, index } = state;
if (!items.length) {
return 0;
}
return Math.min(items[index].left, getMaxOffset(state)) || 0;
} | javascript | function getOffset(state) {
const { items, index } = state;
if (!items.length) {
return 0;
}
return Math.min(items[index].left, getMaxOffset(state)) || 0;
} | [
"function",
"getOffset",
"(",
"state",
")",
"{",
"const",
"{",
"items",
",",
"index",
"}",
"=",
"state",
";",
"if",
"(",
"!",
"items",
".",
"length",
")",
"{",
"return",
"0",
";",
"}",
"return",
"Math",
".",
"min",
"(",
"items",
"[",
"index",
"]"... | Given the current widget state, finds the active offset left of the selected item.
Also automatically caps the offset at the max offset.
@param {object} state The widget state.
@return {number} | [
"Given",
"the",
"current",
"widget",
"state",
"finds",
"the",
"active",
"offset",
"left",
"of",
"the",
"selected",
"item",
".",
"Also",
"automatically",
"caps",
"the",
"offset",
"at",
"the",
"max",
"offset",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L410-L416 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | getMaxOffset | function getMaxOffset({ items, slideWidth }) {
if (!items.length) {
return 0;
}
return Math.max(items[items.length - 1].right - slideWidth, 0) || 0;
} | javascript | function getMaxOffset({ items, slideWidth }) {
if (!items.length) {
return 0;
}
return Math.max(items[items.length - 1].right - slideWidth, 0) || 0;
} | [
"function",
"getMaxOffset",
"(",
"{",
"items",
",",
"slideWidth",
"}",
")",
"{",
"if",
"(",
"!",
"items",
".",
"length",
")",
"{",
"return",
"0",
";",
"}",
"return",
"Math",
".",
"max",
"(",
"items",
"[",
"items",
".",
"length",
"-",
"1",
"]",
".... | Given the current widget state, finds the last valid offset.
@param {object} state The widget state.
@return {number} | [
"Given",
"the",
"current",
"widget",
"state",
"finds",
"the",
"last",
"valid",
"offset",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L424-L429 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | getSlide | function getSlide({ index, itemsPerSlide }, i = index) {
if (!itemsPerSlide) {
return;
}
return Math.ceil(i / itemsPerSlide);
} | javascript | function getSlide({ index, itemsPerSlide }, i = index) {
if (!itemsPerSlide) {
return;
}
return Math.ceil(i / itemsPerSlide);
} | [
"function",
"getSlide",
"(",
"{",
"index",
",",
"itemsPerSlide",
"}",
",",
"i",
"=",
"index",
")",
"{",
"if",
"(",
"!",
"itemsPerSlide",
")",
"{",
"return",
";",
"}",
"return",
"Math",
".",
"ceil",
"(",
"i",
"/",
"itemsPerSlide",
")",
";",
"}"
] | Gets the slide for a given index.
Defaults to the current index if none provided.
@param {object} state The widget state.
@param {number?} i the index to get the slide for.
@return {number} | [
"Gets",
"the",
"slide",
"for",
"a",
"given",
"index",
".",
"Defaults",
"to",
"the",
"current",
"index",
"if",
"none",
"provided",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L439-L445 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | normalizeIndex | function normalizeIndex({ items, itemsPerSlide }, index) {
let result = index;
result %= items.length || 1; // Ensure index is within bounds.
result -= result % (itemsPerSlide || 1); // Round index to the nearest valid slide index.
result = Math.abs(result); // Ensure positive value.
return result;
... | javascript | function normalizeIndex({ items, itemsPerSlide }, index) {
let result = index;
result %= items.length || 1; // Ensure index is within bounds.
result -= result % (itemsPerSlide || 1); // Round index to the nearest valid slide index.
result = Math.abs(result); // Ensure positive value.
return result;
... | [
"function",
"normalizeIndex",
"(",
"{",
"items",
",",
"itemsPerSlide",
"}",
",",
"index",
")",
"{",
"let",
"result",
"=",
"index",
";",
"result",
"%=",
"items",
".",
"length",
"||",
"1",
";",
"// Ensure index is within bounds.",
"result",
"-=",
"result",
"%"... | Ensures that an index is valid.
@param {object} state The widget state.
@param {number} index the index to normalize. | [
"Ensures",
"that",
"an",
"index",
"is",
"valid",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L453-L459 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | getNextIndex | function getNextIndex(state, delta) {
const { index, items, slideWidth, itemsPerSlide } = state;
let i = index;
let item;
// If going backward from 0, we go to the end.
if (delta === LEFT && i === 0) {
i = items.length - 1;
} else {
// Find the index of the next item that is not... | javascript | function getNextIndex(state, delta) {
const { index, items, slideWidth, itemsPerSlide } = state;
let i = index;
let item;
// If going backward from 0, we go to the end.
if (delta === LEFT && i === 0) {
i = items.length - 1;
} else {
// Find the index of the next item that is not... | [
"function",
"getNextIndex",
"(",
"state",
",",
"delta",
")",
"{",
"const",
"{",
"index",
",",
"items",
",",
"slideWidth",
",",
"itemsPerSlide",
"}",
"=",
"state",
";",
"let",
"i",
"=",
"index",
";",
"let",
"item",
";",
"// If going backward from 0, we go to ... | Calculates the next valid index in a direction.
@param {object} state The widget state.
@param {-1|1} delta 1 for right and -1 for left.
@return {number} | [
"Calculates",
"the",
"next",
"valid",
"index",
"in",
"a",
"direction",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L468-L493 | train |
eBay/ebayui-core | src/components/ebay-carousel/index.js | forEls | function forEls(parent, fn) {
let i = 0;
let child = parent.firstElementChild;
while (child) {
fn(child, i++);
child = child.nextElementSibling;
}
} | javascript | function forEls(parent, fn) {
let i = 0;
let child = parent.firstElementChild;
while (child) {
fn(child, i++);
child = child.nextElementSibling;
}
} | [
"function",
"forEls",
"(",
"parent",
",",
"fn",
")",
"{",
"let",
"i",
"=",
"0",
";",
"let",
"child",
"=",
"parent",
".",
"firstElementChild",
";",
"while",
"(",
"child",
")",
"{",
"fn",
"(",
"child",
",",
"i",
"++",
")",
";",
"child",
"=",
"child... | Calls a function on each element within a parent element.
@param {HTMLElement} parent The parent to walk through.
@param {(el: HTMLElement, i: number) => any} fn The function to call. | [
"Calls",
"a",
"function",
"on",
"each",
"element",
"within",
"a",
"parent",
"element",
"."
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-carousel/index.js#L501-L508 | train |
eBay/ebayui-core | src/common/property-observer/index.js | observeRoot | function observeRoot(widget, attributes, callback, skipSetState) {
attributes.forEach(attribute => {
Object.defineProperty(widget.el, attribute, {
get() {
return widget.state[attribute];
},
set(value) {
if (!skipSetState) {
... | javascript | function observeRoot(widget, attributes, callback, skipSetState) {
attributes.forEach(attribute => {
Object.defineProperty(widget.el, attribute, {
get() {
return widget.state[attribute];
},
set(value) {
if (!skipSetState) {
... | [
"function",
"observeRoot",
"(",
"widget",
",",
"attributes",
",",
"callback",
",",
"skipSetState",
")",
"{",
"attributes",
".",
"forEach",
"(",
"attribute",
"=>",
"{",
"Object",
".",
"defineProperty",
"(",
"widget",
".",
"el",
",",
"attribute",
",",
"{",
"... | For each attribute, define getter and setter on root DOM element of the widget
@param {Object} widget
@param {Array} attributes
@param {Function} callback
@param {Boolean} skipSetState: useful for handling setState in your component, rather than here | [
"For",
"each",
"attribute",
"define",
"getter",
"and",
"setter",
"on",
"root",
"DOM",
"element",
"of",
"the",
"widget"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/property-observer/index.js#L11-L27 | train |
eBay/ebayui-core | src/common/property-observer/index.js | observeInner | function observeInner(widget, el, attribute, path, dirtyPath, callback) {
Object.defineProperty(el, attribute, {
get() {
return _get(widget.state, `${path}.${attribute}`);
},
set(value) {
_set(widget.state, `${path}.${attribute}`, value);
if (dirtyPath) {
... | javascript | function observeInner(widget, el, attribute, path, dirtyPath, callback) {
Object.defineProperty(el, attribute, {
get() {
return _get(widget.state, `${path}.${attribute}`);
},
set(value) {
_set(widget.state, `${path}.${attribute}`, value);
if (dirtyPath) {
... | [
"function",
"observeInner",
"(",
"widget",
",",
"el",
",",
"attribute",
",",
"path",
",",
"dirtyPath",
",",
"callback",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"el",
",",
"attribute",
",",
"{",
"get",
"(",
")",
"{",
"return",
"_get",
"(",
"widg... | Define getter and setter on a non-root DOM element of the widget
@param {Object} widget: Widget instance
@param {HTMLElement} el: Element for attaching observer
@param {String} attribute: Name of stateful property
@param {String} path: Path to part of state that needs to be accessed
@param {String} dirtyPath: Path to u... | [
"Define",
"getter",
"and",
"setter",
"on",
"a",
"non",
"-",
"root",
"DOM",
"element",
"of",
"the",
"widget"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/property-observer/index.js#L37-L50 | train |
eBay/ebayui-core | src/common/element-scroll/index.js | scroll | function scroll(el) {
if (!el) {
return;
}
const parentEl = el && el.parentElement;
const offsetBottom = el.offsetTop + el.offsetHeight;
const scrollBottom = parentEl.scrollTop + parentEl.offsetHeight;
if (el.offsetTop < parentEl.scrollTop) {
parentEl.scrollTop = el.offsetTop;
... | javascript | function scroll(el) {
if (!el) {
return;
}
const parentEl = el && el.parentElement;
const offsetBottom = el.offsetTop + el.offsetHeight;
const scrollBottom = parentEl.scrollTop + parentEl.offsetHeight;
if (el.offsetTop < parentEl.scrollTop) {
parentEl.scrollTop = el.offsetTop;
... | [
"function",
"scroll",
"(",
"el",
")",
"{",
"if",
"(",
"!",
"el",
")",
"{",
"return",
";",
"}",
"const",
"parentEl",
"=",
"el",
"&&",
"el",
".",
"parentElement",
";",
"const",
"offsetBottom",
"=",
"el",
".",
"offsetTop",
"+",
"el",
".",
"offsetHeight"... | Scrolls the parent element until the child element is in view | [
"Scrolls",
"the",
"parent",
"element",
"until",
"the",
"child",
"element",
"is",
"in",
"view"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/element-scroll/index.js#L4-L18 | train |
eBay/ebayui-core | src/common/event-utils/index.js | handleKeydown | function handleKeydown(keyCodes, e, callback) {
const keyCode = e.charCode || e.keyCode;
if (keyCodes.indexOf(keyCode) !== -1) {
callback();
}
} | javascript | function handleKeydown(keyCodes, e, callback) {
const keyCode = e.charCode || e.keyCode;
if (keyCodes.indexOf(keyCode) !== -1) {
callback();
}
} | [
"function",
"handleKeydown",
"(",
"keyCodes",
",",
"e",
",",
"callback",
")",
"{",
"const",
"keyCode",
"=",
"e",
".",
"charCode",
"||",
"e",
".",
"keyCode",
";",
"if",
"(",
"keyCodes",
".",
"indexOf",
"(",
"keyCode",
")",
"!==",
"-",
"1",
")",
"{",
... | Generic keydown handler used by more specific cases
@param {Array} keyCodes: List of acceptable keyCodes
@param {KeyboardEvent} e
@param {Function} callback | [
"Generic",
"keydown",
"handler",
"used",
"by",
"more",
"specific",
"cases"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/event-utils/index.js#L7-L12 | train |
eBay/ebayui-core | src/common/event-utils/index.js | handleNotKeydown | function handleNotKeydown(keyCodes, e, callback) {
const keyCode = e.charCode || e.keyCode;
if (keyCodes.indexOf(keyCode) === -1) {
callback();
}
} | javascript | function handleNotKeydown(keyCodes, e, callback) {
const keyCode = e.charCode || e.keyCode;
if (keyCodes.indexOf(keyCode) === -1) {
callback();
}
} | [
"function",
"handleNotKeydown",
"(",
"keyCodes",
",",
"e",
",",
"callback",
")",
"{",
"const",
"keyCode",
"=",
"e",
".",
"charCode",
"||",
"e",
".",
"keyCode",
";",
"if",
"(",
"keyCodes",
".",
"indexOf",
"(",
"keyCode",
")",
"===",
"-",
"1",
")",
"{"... | inverse of found keys | [
"inverse",
"of",
"found",
"keys"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/common/event-utils/index.js#L15-L20 | train |
eBay/ebayui-core | demo/utils.js | isDirectory | function isDirectory(obj) {
return obj.sources.every(path => {
try {
return fs.lstatSync(path).isDirectory();
} catch (e) {
return false;
}
});
} | javascript | function isDirectory(obj) {
return obj.sources.every(path => {
try {
return fs.lstatSync(path).isDirectory();
} catch (e) {
return false;
}
});
} | [
"function",
"isDirectory",
"(",
"obj",
")",
"{",
"return",
"obj",
".",
"sources",
".",
"every",
"(",
"path",
"=>",
"{",
"try",
"{",
"return",
"fs",
".",
"lstatSync",
"(",
"path",
")",
".",
"isDirectory",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
... | check that paths exist as directories | [
"check",
"that",
"paths",
"exist",
"as",
"directories"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/demo/utils.js#L4-L12 | train |
eBay/ebayui-core | src/components/ebay-combobox-readonly/index.js | handleOptionClick | function handleOptionClick(event) {
let el;
// find the element with the data
// start with the target element
if (event.target.dataset.optionValue) {
el = event.target;
// check up the tree one level (in case option text or status was clicked)
} else if (event.target.parentNode.dataset... | javascript | function handleOptionClick(event) {
let el;
// find the element with the data
// start with the target element
if (event.target.dataset.optionValue) {
el = event.target;
// check up the tree one level (in case option text or status was clicked)
} else if (event.target.parentNode.dataset... | [
"function",
"handleOptionClick",
"(",
"event",
")",
"{",
"let",
"el",
";",
"// find the element with the data",
"// start with the target element",
"if",
"(",
"event",
".",
"target",
".",
"dataset",
".",
"optionValue",
")",
"{",
"el",
"=",
"event",
".",
"target",
... | Handle mouse click for option
@param {MouseEvent} event | [
"Handle",
"mouse",
"click",
"for",
"option"
] | a7250c25eaab355881947c159301a78865d0d5c9 | https://github.com/eBay/ebayui-core/blob/a7250c25eaab355881947c159301a78865d0d5c9/src/components/ebay-combobox-readonly/index.js#L117-L132 | train |
mattermost/mattermost-redux | src/actions/websocket.js | handleChannelConvertedEvent | function handleChannelConvertedEvent(msg) {
return (dispatch, getState) => {
const channelId = msg.data.channel_id;
if (channelId) {
const channel = getChannel(getState(), channelId);
if (channel) {
dispatch({
type: ChannelTypes.RECEIVED_CH... | javascript | function handleChannelConvertedEvent(msg) {
return (dispatch, getState) => {
const channelId = msg.data.channel_id;
if (channelId) {
const channel = getChannel(getState(), channelId);
if (channel) {
dispatch({
type: ChannelTypes.RECEIVED_CH... | [
"function",
"handleChannelConvertedEvent",
"(",
"msg",
")",
"{",
"return",
"(",
"dispatch",
",",
"getState",
")",
"=>",
"{",
"const",
"channelId",
"=",
"msg",
".",
"data",
".",
"channel_id",
";",
"if",
"(",
"channelId",
")",
"{",
"const",
"channel",
"=",
... | handleChannelConvertedEvent handles updating of channel which is converted from public to private | [
"handleChannelConvertedEvent",
"handles",
"updating",
"of",
"channel",
"which",
"is",
"converted",
"from",
"public",
"to",
"private"
] | a6b5a325126821c8e6fe22a3dbef747a4d325c5e | https://github.com/mattermost/mattermost-redux/blob/a6b5a325126821c8e6fe22a3dbef747a4d325c5e/src/actions/websocket.js#L546-L559 | train |
zeit/ms | index.js | plural | function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
} | javascript | function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
} | [
"function",
"plural",
"(",
"ms",
",",
"msAbs",
",",
"n",
",",
"name",
")",
"{",
"var",
"isPlural",
"=",
"msAbs",
">=",
"n",
"*",
"1.5",
";",
"return",
"Math",
".",
"round",
"(",
"ms",
"/",
"n",
")",
"+",
"' '",
"+",
"name",
"+",
"(",
"isPlural"... | Pluralization helper. | [
"Pluralization",
"helper",
"."
] | d1add60365fe2340b750b1f7a254b83bea34e52d | https://github.com/zeit/ms/blob/d1add60365fe2340b750b1f7a254b83bea34e52d/index.js#L159-L162 | train |
pqina/vue-filepond | dist/vue-filepond.js | getNativeConstructorFromType | function getNativeConstructorFromType(type) {
return {
string: String,
boolean: Boolean,
array: Array,
function: Function,
int: Number,
serverapi: Object,
object: Object
}[type];
} | javascript | function getNativeConstructorFromType(type) {
return {
string: String,
boolean: Boolean,
array: Array,
function: Function,
int: Number,
serverapi: Object,
object: Object
}[type];
} | [
"function",
"getNativeConstructorFromType",
"(",
"type",
")",
"{",
"return",
"{",
"string",
":",
"String",
",",
"boolean",
":",
"Boolean",
",",
"array",
":",
"Array",
",",
"function",
":",
"Function",
",",
"int",
":",
"Number",
",",
"serverapi",
":",
"Obje... | Setup initial prop types and update when plugins are added | [
"Setup",
"initial",
"prop",
"types",
"and",
"update",
"when",
"plugins",
"are",
"added"
] | bf7ea99e11da095eb10b4f703be0827e807130b7 | https://github.com/pqina/vue-filepond/blob/bf7ea99e11da095eb10b4f703be0827e807130b7/dist/vue-filepond.js#L46-L56 | train |
greggman/twgl.js | src/helper.js | copyExistingProperties | function copyExistingProperties(src, dst) {
Object.keys(dst).forEach(function(key) {
if (dst.hasOwnProperty(key) && src.hasOwnProperty(key)) {
dst[key] = src[key];
}
});
} | javascript | function copyExistingProperties(src, dst) {
Object.keys(dst).forEach(function(key) {
if (dst.hasOwnProperty(key) && src.hasOwnProperty(key)) {
dst[key] = src[key];
}
});
} | [
"function",
"copyExistingProperties",
"(",
"src",
",",
"dst",
")",
"{",
"Object",
".",
"keys",
"(",
"dst",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"dst",
".",
"hasOwnProperty",
"(",
"key",
")",
"&&",
"src",
".",
"hasOwn... | Copies properties from source to dest only if a matching key is in dest
@param {Object.<string, ?>} src the source
@param {Object.<string, ?>} dst the dest
@private | [
"Copies",
"properties",
"from",
"source",
"to",
"dest",
"only",
"if",
"a",
"matching",
"key",
"is",
"in",
"dest"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/helper.js#L49-L55 | train |
greggman/twgl.js | src/twgl.js | setDefaults | function setDefaults(newDefaults) {
helper.copyExistingProperties(newDefaults, defaults);
attributes.setAttributeDefaults_(newDefaults); // eslint-disable-line
textures.setTextureDefaults_(newDefaults); // eslint-disable-line
} | javascript | function setDefaults(newDefaults) {
helper.copyExistingProperties(newDefaults, defaults);
attributes.setAttributeDefaults_(newDefaults); // eslint-disable-line
textures.setTextureDefaults_(newDefaults); // eslint-disable-line
} | [
"function",
"setDefaults",
"(",
"newDefaults",
")",
"{",
"helper",
".",
"copyExistingProperties",
"(",
"newDefaults",
",",
"defaults",
")",
";",
"attributes",
".",
"setAttributeDefaults_",
"(",
"newDefaults",
")",
";",
"// eslint-disable-line",
"textures",
".",
"set... | Various default settings for twgl.
Note: You can call this any number of times. Example:
twgl.setDefaults({ textureColor: [1, 0, 0, 1] });
twgl.setDefaults({ attribPrefix: 'a_' });
is equivalent to
twgl.setDefaults({
textureColor: [1, 0, 0, 1],
attribPrefix: 'a_',
});
@typedef {Object} Defaults
@property {string} ... | [
"Various",
"default",
"settings",
"for",
"twgl",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/twgl.js#L133-L137 | train |
greggman/twgl.js | src/twgl.js | addExtensionsToContext | function addExtensionsToContext(gl) {
for (let ii = 0; ii < supportedExtensions.length; ++ii) {
addExtensionToContext(gl, supportedExtensions[ii]);
}
} | javascript | function addExtensionsToContext(gl) {
for (let ii = 0; ii < supportedExtensions.length; ++ii) {
addExtensionToContext(gl, supportedExtensions[ii]);
}
} | [
"function",
"addExtensionsToContext",
"(",
"gl",
")",
"{",
"for",
"(",
"let",
"ii",
"=",
"0",
";",
"ii",
"<",
"supportedExtensions",
".",
"length",
";",
"++",
"ii",
")",
"{",
"addExtensionToContext",
"(",
"gl",
",",
"supportedExtensions",
"[",
"ii",
"]",
... | Attempts to enable all of the following extensions
and add their functions and constants to the
`WebGLRenderingContext` using their normal non-extension like names.
ANGLE_instanced_arrays
EXT_blend_minmax
EXT_color_buffer_float
EXT_color_buffer_half_float
EXT_disjoint_timer_query
EXT_disjoint_timer_query_webgl2
EXT_fr... | [
"Attempts",
"to",
"enable",
"all",
"of",
"the",
"following",
"extensions",
"and",
"add",
"their",
"functions",
"and",
"constants",
"to",
"the",
"WebGLRenderingContext",
"using",
"their",
"normal",
"non",
"-",
"extension",
"like",
"names",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/twgl.js#L267-L271 | train |
greggman/twgl.js | src/twgl.js | createContext | function createContext(canvas, opt_attribs) {
const names = ["webgl2", "webgl", "experimental-webgl"];
let context = null;
for (let ii = 0; ii < names.length; ++ii) {
context = canvas.getContext(names[ii], opt_attribs);
if (context) {
if (defaults.addExtensionsToContext) {
addExtensionsToCon... | javascript | function createContext(canvas, opt_attribs) {
const names = ["webgl2", "webgl", "experimental-webgl"];
let context = null;
for (let ii = 0; ii < names.length; ++ii) {
context = canvas.getContext(names[ii], opt_attribs);
if (context) {
if (defaults.addExtensionsToContext) {
addExtensionsToCon... | [
"function",
"createContext",
"(",
"canvas",
",",
"opt_attribs",
")",
"{",
"const",
"names",
"=",
"[",
"\"webgl2\"",
",",
"\"webgl\"",
",",
"\"experimental-webgl\"",
"]",
";",
"let",
"context",
"=",
"null",
";",
"for",
"(",
"let",
"ii",
"=",
"0",
";",
"ii... | Creates a webgl context.
Will return a WebGL2 context if possible.
You can check if it's WebGL2 with
twgl.isWebGL2(gl);
@param {HTMLCanvasElement} canvas The canvas tag to get
context from. If one is not passed in one will be
created.
@return {WebGLRenderingContext} The created context. | [
"Creates",
"a",
"webgl",
"context",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/twgl.js#L327-L340 | train |
greggman/twgl.js | src/draw.js | drawBufferInfo | function drawBufferInfo(gl, bufferInfo, type, count, offset, instanceCount) {
type = type === undefined ? gl.TRIANGLES : type;
const indices = bufferInfo.indices;
const elementType = bufferInfo.elementType;
const numElements = count === undefined ? bufferInfo.numElements : count;
offset = offset === undefined... | javascript | function drawBufferInfo(gl, bufferInfo, type, count, offset, instanceCount) {
type = type === undefined ? gl.TRIANGLES : type;
const indices = bufferInfo.indices;
const elementType = bufferInfo.elementType;
const numElements = count === undefined ? bufferInfo.numElements : count;
offset = offset === undefined... | [
"function",
"drawBufferInfo",
"(",
"gl",
",",
"bufferInfo",
",",
"type",
",",
"count",
",",
"offset",
",",
"instanceCount",
")",
"{",
"type",
"=",
"type",
"===",
"undefined",
"?",
"gl",
".",
"TRIANGLES",
":",
"type",
";",
"const",
"indices",
"=",
"buffer... | Drawing related functions
For backward compatibily they are available at both `twgl.draw` and `twgl`
itself
See {@link module:twgl} for core functions
@module twgl/draw
Calls `gl.drawElements` or `gl.drawArrays`, whichever is appropriate
normally you'd call `gl.drawElements` or `gl.drawArrays` yourself
but callin... | [
"Drawing",
"related",
"functions"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/draw.js#L52-L71 | train |
greggman/twgl.js | src/typedarrays.js | getGLTypeForTypedArray | function getGLTypeForTypedArray(typedArray) {
if (typedArray instanceof Int8Array) { return BYTE; } // eslint-disable-line
if (typedArray instanceof Uint8Array) { return UNSIGNED_BYTE; } // eslint-disable-line
if (typedArray instanceof Uint8ClampedArray) { return UNSIGNED_BYTE; } // esl... | javascript | function getGLTypeForTypedArray(typedArray) {
if (typedArray instanceof Int8Array) { return BYTE; } // eslint-disable-line
if (typedArray instanceof Uint8Array) { return UNSIGNED_BYTE; } // eslint-disable-line
if (typedArray instanceof Uint8ClampedArray) { return UNSIGNED_BYTE; } // esl... | [
"function",
"getGLTypeForTypedArray",
"(",
"typedArray",
")",
"{",
"if",
"(",
"typedArray",
"instanceof",
"Int8Array",
")",
"{",
"return",
"BYTE",
";",
"}",
"// eslint-disable-line",
"if",
"(",
"typedArray",
"instanceof",
"Uint8Array",
")",
"{",
"return",
"UNSIGNE... | Get the GL type for a typedArray
@param {ArrayBufferView} typedArray a typedArray
@return {number} the GL type for array. For example pass in an `Int8Array` and `gl.BYTE` will
be returned. Pass in a `Uint32Array` and `gl.UNSIGNED_INT` will be returned
@memberOf module:twgl/typedArray | [
"Get",
"the",
"GL",
"type",
"for",
"a",
"typedArray"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/typedarrays.js#L87-L97 | train |
greggman/twgl.js | src/typedarrays.js | getGLTypeForTypedArrayType | function getGLTypeForTypedArrayType(typedArrayType) {
if (typedArrayType === Int8Array) { return BYTE; } // eslint-disable-line
if (typedArrayType === Uint8Array) { return UNSIGNED_BYTE; } // eslint-disable-line
if (typedArrayType === Uint8ClampedArray) { return UNSIGNED_BYTE; } // esli... | javascript | function getGLTypeForTypedArrayType(typedArrayType) {
if (typedArrayType === Int8Array) { return BYTE; } // eslint-disable-line
if (typedArrayType === Uint8Array) { return UNSIGNED_BYTE; } // eslint-disable-line
if (typedArrayType === Uint8ClampedArray) { return UNSIGNED_BYTE; } // esli... | [
"function",
"getGLTypeForTypedArrayType",
"(",
"typedArrayType",
")",
"{",
"if",
"(",
"typedArrayType",
"===",
"Int8Array",
")",
"{",
"return",
"BYTE",
";",
"}",
"// eslint-disable-line",
"if",
"(",
"typedArrayType",
"===",
"Uint8Array",
")",
"{",
"return",
"UNSIG... | Get the GL type for a typedArray type
@param {ArrayBufferView} typedArrayType a typedArray constructor
@return {number} the GL type for type. For example pass in `Int8Array` and `gl.BYTE` will
be returned. Pass in `Uint32Array` and `gl.UNSIGNED_INT` will be returned
@memberOf module:twgl/typedArray | [
"Get",
"the",
"GL",
"type",
"for",
"a",
"typedArray",
"type"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/typedarrays.js#L106-L116 | train |
greggman/twgl.js | src/m4.js | negate | function negate(m, dst) {
dst = dst || new MatType(16);
dst[ 0] = -m[ 0];
dst[ 1] = -m[ 1];
dst[ 2] = -m[ 2];
dst[ 3] = -m[ 3];
dst[ 4] = -m[ 4];
dst[ 5] = -m[ 5];
dst[ 6] = -m[ 6];
dst[ 7] = -m[ 7];
dst[ 8] = -m[ 8];
dst[ 9] = -m[ 9];
dst[10] = -m[10];
dst[11] = -m[11];
dst[12] = -m[12];
... | javascript | function negate(m, dst) {
dst = dst || new MatType(16);
dst[ 0] = -m[ 0];
dst[ 1] = -m[ 1];
dst[ 2] = -m[ 2];
dst[ 3] = -m[ 3];
dst[ 4] = -m[ 4];
dst[ 5] = -m[ 5];
dst[ 6] = -m[ 6];
dst[ 7] = -m[ 7];
dst[ 8] = -m[ 8];
dst[ 9] = -m[ 9];
dst[10] = -m[10];
dst[11] = -m[11];
dst[12] = -m[12];
... | [
"function",
"negate",
"(",
"m",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"-",
"m",
"[",
"0",
"]",
";",
"dst",
"[",
"1",
"]",
"=",
"-",
"m",
"[",
"1",
"]",
";",
"dst... | Negates a matrix.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} -m.
@memberOf module:twgl/m4 | [
"Negates",
"a",
"matrix",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L82-L103 | train |
greggman/twgl.js | src/m4.js | copy | function copy(m, dst) {
dst = dst || new MatType(16);
dst[ 0] = m[ 0];
dst[ 1] = m[ 1];
dst[ 2] = m[ 2];
dst[ 3] = m[ 3];
dst[ 4] = m[ 4];
dst[ 5] = m[ 5];
dst[ 6] = m[ 6];
dst[ 7] = m[ 7];
dst[ 8] = m[ 8];
dst[ 9] = m[ 9];
dst[10] = m[10];
dst[11] = m[11];
dst[12] = m[12];
dst[13] = m[13... | javascript | function copy(m, dst) {
dst = dst || new MatType(16);
dst[ 0] = m[ 0];
dst[ 1] = m[ 1];
dst[ 2] = m[ 2];
dst[ 3] = m[ 3];
dst[ 4] = m[ 4];
dst[ 5] = m[ 5];
dst[ 6] = m[ 6];
dst[ 7] = m[ 7];
dst[ 8] = m[ 8];
dst[ 9] = m[ 9];
dst[10] = m[10];
dst[11] = m[11];
dst[12] = m[12];
dst[13] = m[13... | [
"function",
"copy",
"(",
"m",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"m",
"[",
"0",
"]",
";",
"dst",
"[",
"1",
"]",
"=",
"m",
"[",
"1",
"]",
";",
"dst",
"[",
"2",... | Copies a matrix.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/m4.Mat4} [dst] The matrix.
@return {module:twgl/m4.Mat4} A copy of m.
@memberOf module:twgl/m4 | [
"Copies",
"a",
"matrix",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L112-L133 | train |
greggman/twgl.js | src/m4.js | identity | function identity(dst) {
dst = dst || new MatType(16);
dst[ 0] = 1;
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = 1;
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = 1;
dst[11] = 0;
dst[12] = 0;
dst[13] = 0;
dst[14] = 0;
dst[15] = 1;
return dst;
} | javascript | function identity(dst) {
dst = dst || new MatType(16);
dst[ 0] = 1;
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = 1;
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = 1;
dst[11] = 0;
dst[12] = 0;
dst[13] = 0;
dst[14] = 0;
dst[15] = 1;
return dst;
} | [
"function",
"identity",
"(",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"1",
";",
"dst",
"[",
"1",
"]",
"=",
"0",
";",
"dst",
"[",
"2",
"]",
"=",
"0",
";",
"dst",
"[",
"3",
... | Creates an n-by-n identity matrix.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} An n-by-n identity matrix.
@memberOf module:twgl/m4 | [
"Creates",
"an",
"n",
"-",
"by",
"-",
"n",
"identity",
"matrix",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L142-L163 | train |
greggman/twgl.js | src/m4.js | transpose | function transpose(m, dst) {
dst = dst || new MatType(16);
if (dst === m) {
let t;
t = m[1];
m[1] = m[4];
m[4] = t;
t = m[2];
m[2] = m[8];
m[8] = t;
t = m[3];
m[3] = m[12];
m[12] = t;
t = m[6];
m[6] = m[9];
m[9] = t;
t = m[7];
m[7] = m[13];
m[13] ... | javascript | function transpose(m, dst) {
dst = dst || new MatType(16);
if (dst === m) {
let t;
t = m[1];
m[1] = m[4];
m[4] = t;
t = m[2];
m[2] = m[8];
m[8] = t;
t = m[3];
m[3] = m[12];
m[12] = t;
t = m[6];
m[6] = m[9];
m[9] = t;
t = m[7];
m[7] = m[13];
m[13] ... | [
"function",
"transpose",
"(",
"m",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"if",
"(",
"dst",
"===",
"m",
")",
"{",
"let",
"t",
";",
"t",
"=",
"m",
"[",
"1",
"]",
";",
"m",
"[",
"1",
"]",
"=",
... | Takes the transpose of a matrix.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} The transpose of m.
@memberOf module:twgl/m4 | [
"Takes",
"the",
"transpose",
"of",
"a",
"matrix",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L172-L238 | train |
greggman/twgl.js | src/m4.js | setTranslation | function setTranslation(a, v, dst) {
dst = dst || identity();
if (a !== dst) {
dst[ 0] = a[ 0];
dst[ 1] = a[ 1];
dst[ 2] = a[ 2];
dst[ 3] = a[ 3];
dst[ 4] = a[ 4];
dst[ 5] = a[ 5];
dst[ 6] = a[ 6];
dst[ 7] = a[ 7];
dst[ 8] = a[ 8];
dst[ 9] = a[ 9];
dst[10] = a[10];
ds... | javascript | function setTranslation(a, v, dst) {
dst = dst || identity();
if (a !== dst) {
dst[ 0] = a[ 0];
dst[ 1] = a[ 1];
dst[ 2] = a[ 2];
dst[ 3] = a[ 3];
dst[ 4] = a[ 4];
dst[ 5] = a[ 5];
dst[ 6] = a[ 6];
dst[ 7] = a[ 7];
dst[ 8] = a[ 8];
dst[ 9] = a[ 9];
dst[10] = a[10];
ds... | [
"function",
"setTranslation",
"(",
"a",
",",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"identity",
"(",
")",
";",
"if",
"(",
"a",
"!==",
"dst",
")",
"{",
"dst",
"[",
"0",
"]",
"=",
"a",
"[",
"0",
"]",
";",
"dst",
"[",
"1",
"]",
... | Sets the translation component of a 4-by-4 matrix to the given
vector.
@param {module:twgl/m4.Mat4} a The matrix.
@param {module:twgl/v3.Vec3} v The vector.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none, a new one is created.
@return {module:twgl/m4.Mat4} a once modified.
@memberOf module:twgl/m4 | [
"Sets",
"the",
"translation",
"component",
"of",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"to",
"the",
"given",
"vector",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L407-L428 | train |
greggman/twgl.js | src/m4.js | getTranslation | function getTranslation(m, dst) {
dst = dst || v3.create();
dst[0] = m[12];
dst[1] = m[13];
dst[2] = m[14];
return dst;
} | javascript | function getTranslation(m, dst) {
dst = dst || v3.create();
dst[0] = m[12];
dst[1] = m[13];
dst[2] = m[14];
return dst;
} | [
"function",
"getTranslation",
"(",
"m",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"v3",
".",
"create",
"(",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"m",
"[",
"12",
"]",
";",
"dst",
"[",
"1",
"]",
"=",
"m",
"[",
"13",
"]",
";",
"dst",
"[... | Returns the translation component of a 4-by-4 matrix as a vector with 3
entries.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/v3.Vec3} [dst] vector.
@return {module:twgl/v3.Vec3} The translation component of m.
@memberOf module:twgl/m4 | [
"Returns",
"the",
"translation",
"component",
"of",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"as",
"a",
"vector",
"with",
"3",
"entries",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L438-L444 | train |
greggman/twgl.js | src/m4.js | getAxis | function getAxis(m, axis, dst) {
dst = dst || v3.create();
const off = axis * 4;
dst[0] = m[off + 0];
dst[1] = m[off + 1];
dst[2] = m[off + 2];
return dst;
} | javascript | function getAxis(m, axis, dst) {
dst = dst || v3.create();
const off = axis * 4;
dst[0] = m[off + 0];
dst[1] = m[off + 1];
dst[2] = m[off + 2];
return dst;
} | [
"function",
"getAxis",
"(",
"m",
",",
"axis",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"v3",
".",
"create",
"(",
")",
";",
"const",
"off",
"=",
"axis",
"*",
"4",
";",
"dst",
"[",
"0",
"]",
"=",
"m",
"[",
"off",
"+",
"0",
"]",
";",
"... | Returns an axis of a 4x4 matrix as a vector with 3 entries
@param {module:twgl/m4.Mat4} m The matrix.
@param {number} axis The axis 0 = x, 1 = y, 2 = z;
@return {module:twgl/v3.Vec3} [dst] vector.
@return {module:twgl/v3.Vec3} The axis component of m.
@memberOf module:twgl/m4 | [
"Returns",
"an",
"axis",
"of",
"a",
"4x4",
"matrix",
"as",
"a",
"vector",
"with",
"3",
"entries"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L454-L461 | train |
greggman/twgl.js | src/m4.js | setAxis | function setAxis(a, v, axis, dst) {
if (dst !== a) {
dst = copy(a, dst);
}
const off = axis * 4;
dst[off + 0] = v[0];
dst[off + 1] = v[1];
dst[off + 2] = v[2];
return dst;
} | javascript | function setAxis(a, v, axis, dst) {
if (dst !== a) {
dst = copy(a, dst);
}
const off = axis * 4;
dst[off + 0] = v[0];
dst[off + 1] = v[1];
dst[off + 2] = v[2];
return dst;
} | [
"function",
"setAxis",
"(",
"a",
",",
"v",
",",
"axis",
",",
"dst",
")",
"{",
"if",
"(",
"dst",
"!==",
"a",
")",
"{",
"dst",
"=",
"copy",
"(",
"a",
",",
"dst",
")",
";",
"}",
"const",
"off",
"=",
"axis",
"*",
"4",
";",
"dst",
"[",
"off",
... | Sets an axis of a 4x4 matrix as a vector with 3 entries
@param {module:twgl/v3.Vec3} v the axis vector
@param {number} axis The axis 0 = x, 1 = y, 2 = z;
@param {module:twgl/m4.Mat4} [dst] The matrix to set. If none, a new one is created.
@return {module:twgl/m4.Mat4} dst
@memberOf module:twgl/m4 | [
"Sets",
"an",
"axis",
"of",
"a",
"4x4",
"matrix",
"as",
"a",
"vector",
"with",
"3",
"entries"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L471-L480 | train |
greggman/twgl.js | src/m4.js | perspective | function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) {
dst = dst || new MatType(16);
const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);
const rangeInv = 1.0 / (zNear - zFar);
dst[0] = f / aspect;
dst[1] = 0;
dst[2] = 0;
dst[3] = 0;
dst[4] = 0;
dst[5] = f;
dst[... | javascript | function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) {
dst = dst || new MatType(16);
const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);
const rangeInv = 1.0 / (zNear - zFar);
dst[0] = f / aspect;
dst[1] = 0;
dst[2] = 0;
dst[3] = 0;
dst[4] = 0;
dst[5] = f;
dst[... | [
"function",
"perspective",
"(",
"fieldOfViewYInRadians",
",",
"aspect",
",",
"zNear",
",",
"zFar",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"f",
"=",
"Math",
".",
"tan",
"(",
"Math",
".",
"PI",
... | Computes a 4-by-4 perspective transformation matrix given the angular height
of the frustum, the aspect ratio, and the near and far clipping planes. The
arguments define a frustum extending in the negative z direction. The given
angle is the vertical angle of the frustum, and the horizontal angle is
determined to pro... | [
"Computes",
"a",
"4",
"-",
"by",
"-",
"4",
"perspective",
"transformation",
"matrix",
"given",
"the",
"angular",
"height",
"of",
"the",
"frustum",
"the",
"aspect",
"ratio",
"and",
"the",
"near",
"and",
"far",
"clipping",
"planes",
".",
"The",
"arguments",
... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L503-L530 | train |
greggman/twgl.js | src/m4.js | ortho | function ortho(left, right, bottom, top, near, far, dst) {
dst = dst || new MatType(16);
dst[0] = 2 / (right - left);
dst[1] = 0;
dst[2] = 0;
dst[3] = 0;
dst[4] = 0;
dst[5] = 2 / (top - bottom);
dst[6] = 0;
dst[7] = 0;
dst[8] = 0;
dst[9] = 0;
dst[10] = 2 / (near - far);
dst[11] = ... | javascript | function ortho(left, right, bottom, top, near, far, dst) {
dst = dst || new MatType(16);
dst[0] = 2 / (right - left);
dst[1] = 0;
dst[2] = 0;
dst[3] = 0;
dst[4] = 0;
dst[5] = 2 / (top - bottom);
dst[6] = 0;
dst[7] = 0;
dst[8] = 0;
dst[9] = 0;
dst[10] = 2 / (near - far);
dst[11] = ... | [
"function",
"ortho",
"(",
"left",
",",
"right",
",",
"bottom",
",",
"top",
",",
"near",
",",
"far",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"2",
"/",
"(",
"right",
"-",
... | Computes a 4-by-4 othogonal transformation matrix given the left, right,
bottom, and top dimensions of the near clipping plane as well as the
near and far clipping plane distances.
@param {number} left Left side of the near clipping plane viewport.
@param {number} right Right side of the near clipping plane viewport.
@... | [
"Computes",
"a",
"4",
"-",
"by",
"-",
"4",
"othogonal",
"transformation",
"matrix",
"given",
"the",
"left",
"right",
"bottom",
"and",
"top",
"dimensions",
"of",
"the",
"near",
"clipping",
"plane",
"as",
"well",
"as",
"the",
"near",
"and",
"far",
"clipping"... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L548-L572 | train |
greggman/twgl.js | src/m4.js | frustum | function frustum(left, right, bottom, top, near, far, dst) {
dst = dst || new MatType(16);
const dx = (right - left);
const dy = (top - bottom);
const dz = (near - far);
dst[ 0] = 2 * near / dx;
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = 2 * near / dy;
dst[ 6] = 0;
dst[ 7] =... | javascript | function frustum(left, right, bottom, top, near, far, dst) {
dst = dst || new MatType(16);
const dx = (right - left);
const dy = (top - bottom);
const dz = (near - far);
dst[ 0] = 2 * near / dx;
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = 2 * near / dy;
dst[ 6] = 0;
dst[ 7] =... | [
"function",
"frustum",
"(",
"left",
",",
"right",
",",
"bottom",
",",
"top",
",",
"near",
",",
"far",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"dx",
"=",
"(",
"right",
"-",
"left",
")",
";",... | Computes a 4-by-4 perspective transformation matrix given the left, right,
top, bottom, near and far clipping planes. The arguments define a frustum
extending in the negative z direction. The arguments near and far are the
distances to the near and far clipping planes. Note that near and far are not
z coordinates, but ... | [
"Computes",
"a",
"4",
"-",
"by",
"-",
"4",
"perspective",
"transformation",
"matrix",
"given",
"the",
"left",
"right",
"top",
"bottom",
"near",
"and",
"far",
"clipping",
"planes",
".",
"The",
"arguments",
"define",
"a",
"frustum",
"extending",
"in",
"the",
... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L593-L618 | train |
greggman/twgl.js | src/m4.js | lookAt | function lookAt(eye, target, up, dst) {
dst = dst || new MatType(16);
const xAxis = tempV3a;
const yAxis = tempV3b;
const zAxis = tempV3c;
v3.normalize(
v3.subtract(eye, target, zAxis), zAxis);
v3.normalize(v3.cross(up, zAxis, xAxis), xAxis);
v3.normalize(v3.cross(zAxis, xAxis, yAxis), yAxis);
... | javascript | function lookAt(eye, target, up, dst) {
dst = dst || new MatType(16);
const xAxis = tempV3a;
const yAxis = tempV3b;
const zAxis = tempV3c;
v3.normalize(
v3.subtract(eye, target, zAxis), zAxis);
v3.normalize(v3.cross(up, zAxis, xAxis), xAxis);
v3.normalize(v3.cross(zAxis, xAxis, yAxis), yAxis);
... | [
"function",
"lookAt",
"(",
"eye",
",",
"target",
",",
"up",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"xAxis",
"=",
"tempV3a",
";",
"const",
"yAxis",
"=",
"tempV3b",
";",
"const",
"zAxis",
"=",
... | Computes a 4-by-4 look-at transformation.
This is a matrix which positions the camera itself. If you want
a view matrix (a matrix which moves things in front of the camera)
take the inverse of this.
@param {module:twgl/v3.Vec3} eye The position of the eye.
@param {module:twgl/v3.Vec3} target The position meant to be ... | [
"Computes",
"a",
"4",
"-",
"by",
"-",
"4",
"look",
"-",
"at",
"transformation",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L634-L664 | train |
greggman/twgl.js | src/m4.js | translation | function translation(v, dst) {
dst = dst || new MatType(16);
dst[ 0] = 1;
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = 1;
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = 1;
dst[11] = 0;
dst[12] = v[0];
dst[13] = v[1];
dst[14] = v[2];
dst[15] = 1;
retur... | javascript | function translation(v, dst) {
dst = dst || new MatType(16);
dst[ 0] = 1;
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = 1;
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = 1;
dst[11] = 0;
dst[12] = v[0];
dst[13] = v[1];
dst[14] = v[2];
dst[15] = 1;
retur... | [
"function",
"translation",
"(",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"1",
";",
"dst",
"[",
"1",
"]",
"=",
"0",
";",
"dst",
"[",
"2",
"]",
"=",
"0",
";",
"dst... | Creates a 4-by-4 matrix which translates by the given vector v.
@param {module:twgl/v3.Vec3} v The vector by
which to translate.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} The translation matrix.
@memberOf module:twgl/m4 | [
"Creates",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"which",
"translates",
"by",
"the",
"given",
"vector",
"v",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L674-L694 | train |
greggman/twgl.js | src/m4.js | translate | function translate(m, v, dst) {
dst = dst || new MatType(16);
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
const m00 = m[0];
const m01 = m[1];
const m02 = m[2];
const m03 = m[3];
const m10 = m[1 * 4 + 0];
const m11 = m[1 * 4 + 1];
const m12 = m[1 * 4 + 2];
const m13 = m[1 * 4 + 3];
cons... | javascript | function translate(m, v, dst) {
dst = dst || new MatType(16);
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
const m00 = m[0];
const m01 = m[1];
const m02 = m[2];
const m03 = m[3];
const m10 = m[1 * 4 + 0];
const m11 = m[1 * 4 + 1];
const m12 = m[1 * 4 + 2];
const m13 = m[1 * 4 + 3];
cons... | [
"function",
"translate",
"(",
"m",
",",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"v0",
"=",
"v",
"[",
"0",
"]",
";",
"const",
"v1",
"=",
"v",
"[",
"1",
"]",
";",
"const",
"v2",
"=",... | Modifies the given 4-by-4 matrix by translation by the given vector v.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/v3.Vec3} v The vector by
which to translate.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} m once modified.
@member... | [
"Modifies",
"the",
"given",
"4",
"-",
"by",
"-",
"4",
"matrix",
"by",
"translation",
"by",
"the",
"given",
"vector",
"v",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L705-L749 | train |
greggman/twgl.js | src/m4.js | rotateX | function rotateX(m, angleInRadians, dst) {
dst = dst || new MatType(16);
const m10 = m[4];
const m11 = m[5];
const m12 = m[6];
const m13 = m[7];
const m20 = m[8];
const m21 = m[9];
const m22 = m[10];
const m23 = m[11];
const c = Math.cos(angleInRadians);
const s = Math.sin(angleInRadians);
dst... | javascript | function rotateX(m, angleInRadians, dst) {
dst = dst || new MatType(16);
const m10 = m[4];
const m11 = m[5];
const m12 = m[6];
const m13 = m[7];
const m20 = m[8];
const m21 = m[9];
const m22 = m[10];
const m23 = m[11];
const c = Math.cos(angleInRadians);
const s = Math.sin(angleInRadians);
dst... | [
"function",
"rotateX",
"(",
"m",
",",
"angleInRadians",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"m10",
"=",
"m",
"[",
"4",
"]",
";",
"const",
"m11",
"=",
"m",
"[",
"5",
"]",
";",
"const",
... | Modifies the given 4-by-4 matrix by a rotation around the x-axis by the given
angle.
@param {module:twgl/m4.Mat4} m The matrix.
@param {number} angleInRadians The angle by which to rotate (in radians).
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} m... | [
"Modifies",
"the",
"given",
"4",
"-",
"by",
"-",
"4",
"matrix",
"by",
"a",
"rotation",
"around",
"the",
"x",
"-",
"axis",
"by",
"the",
"given",
"angle",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L793-L828 | train |
greggman/twgl.js | src/m4.js | rotateY | function rotateY(m, angleInRadians, dst) {
dst = dst || new MatType(16);
const m00 = m[0 * 4 + 0];
const m01 = m[0 * 4 + 1];
const m02 = m[0 * 4 + 2];
const m03 = m[0 * 4 + 3];
const m20 = m[2 * 4 + 0];
const m21 = m[2 * 4 + 1];
const m22 = m[2 * 4 + 2];
const m23 = m[2 * 4 + 3];
const c = Math.cos... | javascript | function rotateY(m, angleInRadians, dst) {
dst = dst || new MatType(16);
const m00 = m[0 * 4 + 0];
const m01 = m[0 * 4 + 1];
const m02 = m[0 * 4 + 2];
const m03 = m[0 * 4 + 3];
const m20 = m[2 * 4 + 0];
const m21 = m[2 * 4 + 1];
const m22 = m[2 * 4 + 2];
const m23 = m[2 * 4 + 3];
const c = Math.cos... | [
"function",
"rotateY",
"(",
"m",
",",
"angleInRadians",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"m00",
"=",
"m",
"[",
"0",
"*",
"4",
"+",
"0",
"]",
";",
"const",
"m01",
"=",
"m",
"[",
"0"... | Modifies the given 4-by-4 matrix by a rotation around the y-axis by the given
angle.
@param {module:twgl/m4.Mat4} m The matrix.
@param {number} angleInRadians The angle by which to rotate (in radians).
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} m... | [
"Modifies",
"the",
"given",
"4",
"-",
"by",
"-",
"4",
"matrix",
"by",
"a",
"rotation",
"around",
"the",
"y",
"-",
"axis",
"by",
"the",
"given",
"angle",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L872-L907 | train |
greggman/twgl.js | src/m4.js | rotationZ | function rotationZ(angleInRadians, dst) {
dst = dst || new MatType(16);
const c = Math.cos(angleInRadians);
const s = Math.sin(angleInRadians);
dst[ 0] = c;
dst[ 1] = s;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = -s;
dst[ 5] = c;
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = 1;
... | javascript | function rotationZ(angleInRadians, dst) {
dst = dst || new MatType(16);
const c = Math.cos(angleInRadians);
const s = Math.sin(angleInRadians);
dst[ 0] = c;
dst[ 1] = s;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = -s;
dst[ 5] = c;
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = 1;
... | [
"function",
"rotationZ",
"(",
"angleInRadians",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"c",
"=",
"Math",
".",
"cos",
"(",
"angleInRadians",
")",
";",
"const",
"s",
"=",
"Math",
".",
"sin",
"("... | Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.
@param {number} angleInRadians The angle by which to rotate (in radians).
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} The rotation matrix.
@memberOf module:twgl/m4 | [
"Creates",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"which",
"rotates",
"around",
"the",
"z",
"-",
"axis",
"by",
"the",
"given",
"angle",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L916-L940 | train |
greggman/twgl.js | src/m4.js | rotateZ | function rotateZ(m, angleInRadians, dst) {
dst = dst || new MatType(16);
const m00 = m[0 * 4 + 0];
const m01 = m[0 * 4 + 1];
const m02 = m[0 * 4 + 2];
const m03 = m[0 * 4 + 3];
const m10 = m[1 * 4 + 0];
const m11 = m[1 * 4 + 1];
const m12 = m[1 * 4 + 2];
const m13 = m[1 * 4 + 3];
const c = Math.cos... | javascript | function rotateZ(m, angleInRadians, dst) {
dst = dst || new MatType(16);
const m00 = m[0 * 4 + 0];
const m01 = m[0 * 4 + 1];
const m02 = m[0 * 4 + 2];
const m03 = m[0 * 4 + 3];
const m10 = m[1 * 4 + 0];
const m11 = m[1 * 4 + 1];
const m12 = m[1 * 4 + 2];
const m13 = m[1 * 4 + 3];
const c = Math.cos... | [
"function",
"rotateZ",
"(",
"m",
",",
"angleInRadians",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"m00",
"=",
"m",
"[",
"0",
"*",
"4",
"+",
"0",
"]",
";",
"const",
"m01",
"=",
"m",
"[",
"0"... | Modifies the given 4-by-4 matrix by a rotation around the z-axis by the given
angle.
@param {module:twgl/m4.Mat4} m The matrix.
@param {number} angleInRadians The angle by which to rotate (in radians).
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} m... | [
"Modifies",
"the",
"given",
"4",
"-",
"by",
"-",
"4",
"matrix",
"by",
"a",
"rotation",
"around",
"the",
"z",
"-",
"axis",
"by",
"the",
"given",
"angle",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L951-L986 | train |
greggman/twgl.js | src/m4.js | axisRotation | function axisRotation(axis, angleInRadians, dst) {
dst = dst || new MatType(16);
let x = axis[0];
let y = axis[1];
let z = axis[2];
const n = Math.sqrt(x * x + y * y + z * z);
x /= n;
y /= n;
z /= n;
const xx = x * x;
const yy = y * y;
const zz = z * z;
const c = Math.cos(angleInRadians);
con... | javascript | function axisRotation(axis, angleInRadians, dst) {
dst = dst || new MatType(16);
let x = axis[0];
let y = axis[1];
let z = axis[2];
const n = Math.sqrt(x * x + y * y + z * z);
x /= n;
y /= n;
z /= n;
const xx = x * x;
const yy = y * y;
const zz = z * z;
const c = Math.cos(angleInRadians);
con... | [
"function",
"axisRotation",
"(",
"axis",
",",
"angleInRadians",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"let",
"x",
"=",
"axis",
"[",
"0",
"]",
";",
"let",
"y",
"=",
"axis",
"[",
"1",
"]",
";",
"let... | Creates a 4-by-4 matrix which rotates around the given axis by the given
angle.
@param {module:twgl/v3.Vec3} axis The axis
about which to rotate.
@param {number} angleInRadians The angle by which to rotate (in radians).
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {modu... | [
"Creates",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"which",
"rotates",
"around",
"the",
"given",
"axis",
"by",
"the",
"given",
"angle",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L999-L1034 | train |
greggman/twgl.js | src/m4.js | scaling | function scaling(v, dst) {
dst = dst || new MatType(16);
dst[ 0] = v[0];
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = v[1];
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = v[2];
dst[11] = 0;
dst[12] = 0;
dst[13] = 0;
dst[14] = 0;
dst[15] = 1;
return d... | javascript | function scaling(v, dst) {
dst = dst || new MatType(16);
dst[ 0] = v[0];
dst[ 1] = 0;
dst[ 2] = 0;
dst[ 3] = 0;
dst[ 4] = 0;
dst[ 5] = v[1];
dst[ 6] = 0;
dst[ 7] = 0;
dst[ 8] = 0;
dst[ 9] = 0;
dst[10] = v[2];
dst[11] = 0;
dst[12] = 0;
dst[13] = 0;
dst[14] = 0;
dst[15] = 1;
return d... | [
"function",
"scaling",
"(",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"dst",
"[",
"0",
"]",
"=",
"v",
"[",
"0",
"]",
";",
"dst",
"[",
"1",
"]",
"=",
"0",
";",
"dst",
"[",
"2",
"]",
"=",
"... | Creates a 4-by-4 matrix which scales in each dimension by an amount given by
the corresponding entry in the given vector; assumes the vector has three
entries.
@param {module:twgl/v3.Vec3} v A vector of
three entries specifying the factor by which to scale in each dimension.
@param {module:twgl/m4.Mat4} [dst] matrix to... | [
"Creates",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"which",
"scales",
"in",
"each",
"dimension",
"by",
"an",
"amount",
"given",
"by",
"the",
"corresponding",
"entry",
"in",
"the",
"given",
"vector",
";",
"assumes",
"the",
"vector",
"has",
"three",
"entr... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L1120-L1141 | train |
greggman/twgl.js | src/m4.js | scale | function scale(m, v, dst) {
dst = dst || new MatType(16);
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
dst[ 0] = v0 * m[0 * 4 + 0];
dst[ 1] = v0 * m[0 * 4 + 1];
dst[ 2] = v0 * m[0 * 4 + 2];
dst[ 3] = v0 * m[0 * 4 + 3];
dst[ 4] = v1 * m[1 * 4 + 0];
dst[ 5] = v1 * m[1 * 4 + 1];
dst[ 6] = v1 ... | javascript | function scale(m, v, dst) {
dst = dst || new MatType(16);
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
dst[ 0] = v0 * m[0 * 4 + 0];
dst[ 1] = v0 * m[0 * 4 + 1];
dst[ 2] = v0 * m[0 * 4 + 2];
dst[ 3] = v0 * m[0 * 4 + 3];
dst[ 4] = v1 * m[1 * 4 + 0];
dst[ 5] = v1 * m[1 * 4 + 1];
dst[ 6] = v1 ... | [
"function",
"scale",
"(",
"m",
",",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"new",
"MatType",
"(",
"16",
")",
";",
"const",
"v0",
"=",
"v",
"[",
"0",
"]",
";",
"const",
"v1",
"=",
"v",
"[",
"1",
"]",
";",
"const",
"v2",
"=",
"... | Modifies the given 4-by-4 matrix, scaling in each dimension by an amount
given by the corresponding entry in the given vector; assumes the vector has
three entries.
@param {module:twgl/m4.Mat4} m The matrix to be modified.
@param {module:twgl/v3.Vec3} v A vector of three entries specifying the
factor by which to scale ... | [
"Modifies",
"the",
"given",
"4",
"-",
"by",
"-",
"4",
"matrix",
"scaling",
"in",
"each",
"dimension",
"by",
"an",
"amount",
"given",
"by",
"the",
"corresponding",
"entry",
"in",
"the",
"given",
"vector",
";",
"assumes",
"the",
"vector",
"has",
"three",
"... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L1154-L1182 | train |
greggman/twgl.js | src/m4.js | transformPoint | function transformPoint(m, v, dst) {
dst = dst || v3.create();
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
const d = v0 * m[0 * 4 + 3] + v1 * m[1 * 4 + 3] + v2 * m[2 * 4 + 3] + m[3 * 4 + 3];
dst[0] = (v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0] + m[3 * 4 + 0]) / d;
dst[1] = (v0 * m[0... | javascript | function transformPoint(m, v, dst) {
dst = dst || v3.create();
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
const d = v0 * m[0 * 4 + 3] + v1 * m[1 * 4 + 3] + v2 * m[2 * 4 + 3] + m[3 * 4 + 3];
dst[0] = (v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0] + m[3 * 4 + 0]) / d;
dst[1] = (v0 * m[0... | [
"function",
"transformPoint",
"(",
"m",
",",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"v3",
".",
"create",
"(",
")",
";",
"const",
"v0",
"=",
"v",
"[",
"0",
"]",
";",
"const",
"v1",
"=",
"v",
"[",
"1",
"]",
";",
"const",
"v2",
"=... | Takes a 4-by-4 matrix and a vector with 3 entries,
interprets the vector as a point, transforms that point by the matrix, and
returns the result as a vector with 3 entries.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/v3.Vec3} v The point.
@param {module:twgl/v3.Vec3} dst optional vec3 to store result... | [
"Takes",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"and",
"a",
"vector",
"with",
"3",
"entries",
"interprets",
"the",
"vector",
"as",
"a",
"point",
"transforms",
"that",
"point",
"by",
"the",
"matrix",
"and",
"returns",
"the",
"result",
"as",
"a",
"vect... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L1194-L1206 | train |
greggman/twgl.js | src/m4.js | transformDirection | function transformDirection(m, v, dst) {
dst = dst || v3.create();
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];
dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];
dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v... | javascript | function transformDirection(m, v, dst) {
dst = dst || v3.create();
const v0 = v[0];
const v1 = v[1];
const v2 = v[2];
dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];
dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];
dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v... | [
"function",
"transformDirection",
"(",
"m",
",",
"v",
",",
"dst",
")",
"{",
"dst",
"=",
"dst",
"||",
"v3",
".",
"create",
"(",
")",
";",
"const",
"v0",
"=",
"v",
"[",
"0",
"]",
";",
"const",
"v1",
"=",
"v",
"[",
"1",
"]",
";",
"const",
"v2",
... | Takes a 4-by-4 matrix and a vector with 3 entries, interprets the vector as a
direction, transforms that direction by the matrix, and returns the result;
assumes the transformation of 3-dimensional space represented by the matrix
is parallel-preserving, i.e. any combination of rotation, scaling and
translation, but not... | [
"Takes",
"a",
"4",
"-",
"by",
"-",
"4",
"matrix",
"and",
"a",
"vector",
"with",
"3",
"entries",
"interprets",
"the",
"vector",
"as",
"a",
"direction",
"transforms",
"that",
"direction",
"by",
"the",
"matrix",
"and",
"returns",
"the",
"result",
";",
"assu... | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/m4.js#L1221-L1233 | train |
greggman/twgl.js | src/attributes.js | createBufferFromTypedArray | function createBufferFromTypedArray(gl, typedArray, type, drawType) {
if (helper.isBuffer(gl, typedArray)) {
return typedArray;
}
type = type || gl.ARRAY_BUFFER;
const buffer = gl.createBuffer();
setBufferFromTypedArray(gl, type, buffer, typedArray, drawType);
return buffer;
} | javascript | function createBufferFromTypedArray(gl, typedArray, type, drawType) {
if (helper.isBuffer(gl, typedArray)) {
return typedArray;
}
type = type || gl.ARRAY_BUFFER;
const buffer = gl.createBuffer();
setBufferFromTypedArray(gl, type, buffer, typedArray, drawType);
return buffer;
} | [
"function",
"createBufferFromTypedArray",
"(",
"gl",
",",
"typedArray",
",",
"type",
",",
"drawType",
")",
"{",
"if",
"(",
"helper",
".",
"isBuffer",
"(",
"gl",
",",
"typedArray",
")",
")",
"{",
"return",
"typedArray",
";",
"}",
"type",
"=",
"type",
"||"... | Given typed array creates a WebGLBuffer and copies the typed array
into it.
@param {WebGLRenderingContext} gl A WebGLRenderingContext
@param {ArrayBuffer|SharedArrayBuffer|ArrayBufferView|WebGLBuffer} typedArray the typed array. Note: If a WebGLBuffer is passed in it will just be returned. No action will be taken
@par... | [
"Given",
"typed",
"array",
"creates",
"a",
"WebGLBuffer",
"and",
"copies",
"the",
"typed",
"array",
"into",
"it",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/attributes.js#L91-L99 | train |
greggman/twgl.js | src/attributes.js | setAttribInfoBufferFromArray | function setAttribInfoBufferFromArray(gl, attribInfo, array, offset) {
array = makeTypedArray(array);
if (offset !== undefined) {
gl.bindBuffer(gl.ARRAY_BUFFER, attribInfo.buffer);
gl.bufferSubData(gl.ARRAY_BUFFER, offset, array);
} else {
setBufferFromTypedArray(gl, gl.ARRAY_BUFFER, attribInfo.buffer... | javascript | function setAttribInfoBufferFromArray(gl, attribInfo, array, offset) {
array = makeTypedArray(array);
if (offset !== undefined) {
gl.bindBuffer(gl.ARRAY_BUFFER, attribInfo.buffer);
gl.bufferSubData(gl.ARRAY_BUFFER, offset, array);
} else {
setBufferFromTypedArray(gl, gl.ARRAY_BUFFER, attribInfo.buffer... | [
"function",
"setAttribInfoBufferFromArray",
"(",
"gl",
",",
"attribInfo",
",",
"array",
",",
"offset",
")",
"{",
"array",
"=",
"makeTypedArray",
"(",
"array",
")",
";",
"if",
"(",
"offset",
"!==",
"undefined",
")",
"{",
"gl",
".",
"bindBuffer",
"(",
"gl",
... | Sets the contents of a buffer attached to an attribInfo
This is helper function to dynamically update a buffer.
Let's say you make a bufferInfo
var arrays = {
position: new Float32Array([0, 0, 0, 10, 0, 0, 0, 10, 0, 10, 10, 0]),
texcoord: new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]),
normal: new Float32Array([0, 0, ... | [
"Sets",
"the",
"contents",
"of",
"a",
"buffer",
"attached",
"to",
"an",
"attribInfo"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/attributes.js#L437-L445 | train |
greggman/twgl.js | src/attributes.js | createBufferFromArray | function createBufferFromArray(gl, array, arrayName) {
const type = arrayName === "indices" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
const typedArray = makeTypedArray(array, arrayName);
return createBufferFromTypedArray(gl, typedArray, type);
} | javascript | function createBufferFromArray(gl, array, arrayName) {
const type = arrayName === "indices" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
const typedArray = makeTypedArray(array, arrayName);
return createBufferFromTypedArray(gl, typedArray, type);
} | [
"function",
"createBufferFromArray",
"(",
"gl",
",",
"array",
",",
"arrayName",
")",
"{",
"const",
"type",
"=",
"arrayName",
"===",
"\"indices\"",
"?",
"gl",
".",
"ELEMENT_ARRAY_BUFFER",
":",
"gl",
".",
"ARRAY_BUFFER",
";",
"const",
"typedArray",
"=",
"makeTyp... | Creates a buffer from an array, typed array, or array spec
Given something like this
[1, 2, 3],
or
new Uint16Array([1,2,3]);
or
{
data: [1, 2, 3],
type: Uint8Array,
}
returns a WebGLBuffer that constains the given data.
@param {WebGLRenderingContext} gl A WebGLRenderingContext.
@param {module:twgl.ArraySpec} ar... | [
"Creates",
"a",
"buffer",
"from",
"an",
"array",
"typed",
"array",
"or",
"array",
"spec"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/attributes.js#L662-L666 | train |
greggman/twgl.js | src/attributes.js | createBuffersFromArrays | function createBuffersFromArrays(gl, arrays) {
const buffers = { };
Object.keys(arrays).forEach(function(key) {
buffers[key] = createBufferFromArray(gl, arrays[key], key);
});
// Ugh!
if (arrays.indices) {
buffers.numElements = arrays.indices.length;
buffers.elementType = typedArrays.getGLTypeFor... | javascript | function createBuffersFromArrays(gl, arrays) {
const buffers = { };
Object.keys(arrays).forEach(function(key) {
buffers[key] = createBufferFromArray(gl, arrays[key], key);
});
// Ugh!
if (arrays.indices) {
buffers.numElements = arrays.indices.length;
buffers.elementType = typedArrays.getGLTypeFor... | [
"function",
"createBuffersFromArrays",
"(",
"gl",
",",
"arrays",
")",
"{",
"const",
"buffers",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"arrays",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"buffers",
"[",
"key",
"]",
"=",
"cre... | Creates buffers from arrays or typed arrays
Given something like this
var arrays = {
positions: [1, 2, 3],
normals: [0, 0, 1],
}
returns something like
buffers = {
positions: WebGLBuffer,
normals: WebGLBuffer,
}
If the buffer is named 'indices' it will be made an ELEMENT_ARRAY_BUFFER.
@param {WebGLRenderingContex... | [
"Creates",
"buffers",
"from",
"arrays",
"or",
"typed",
"arrays"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/attributes.js#L692-L707 | train |
greggman/twgl.js | src/programs.js | addLineNumbers | function addLineNumbers(src, lineOffset) {
lineOffset = lineOffset || 0;
++lineOffset;
return src.split("\n").map(function(line, ndx) {
return (ndx + lineOffset) + ": " + line;
}).join("\n");
} | javascript | function addLineNumbers(src, lineOffset) {
lineOffset = lineOffset || 0;
++lineOffset;
return src.split("\n").map(function(line, ndx) {
return (ndx + lineOffset) + ": " + line;
}).join("\n");
} | [
"function",
"addLineNumbers",
"(",
"src",
",",
"lineOffset",
")",
"{",
"lineOffset",
"=",
"lineOffset",
"||",
"0",
";",
"++",
"lineOffset",
";",
"return",
"src",
".",
"split",
"(",
"\"\\n\"",
")",
".",
"map",
"(",
"function",
"(",
"line",
",",
"ndx",
"... | eslint-disable-line
Error Callback
@callback ErrorCallback
@param {string} msg error message.
@param {number} [lineOffset] amount to add to line number
@memberOf module:twgl | [
"eslint",
"-",
"disable",
"-",
"line",
"Error",
"Callback"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L457-L464 | train |
greggman/twgl.js | src/programs.js | loadShader | function loadShader(gl, shaderSource, shaderType, opt_errorCallback) {
const errFn = opt_errorCallback || error;
// Create the shader object
const shader = gl.createShader(shaderType);
// Remove the first end of line because WebGL 2.0 requires
// #version 300 es
// as the first line. No whitespace allowed ... | javascript | function loadShader(gl, shaderSource, shaderType, opt_errorCallback) {
const errFn = opt_errorCallback || error;
// Create the shader object
const shader = gl.createShader(shaderType);
// Remove the first end of line because WebGL 2.0 requires
// #version 300 es
// as the first line. No whitespace allowed ... | [
"function",
"loadShader",
"(",
"gl",
",",
"shaderSource",
",",
"shaderType",
",",
"opt_errorCallback",
")",
"{",
"const",
"errFn",
"=",
"opt_errorCallback",
"||",
"error",
";",
"// Create the shader object",
"const",
"shader",
"=",
"gl",
".",
"createShader",
"(",
... | Loads a shader.
@param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {module:twgl.ErrorCallback} opt_errorCallback callback for errors.
@return {WebGLShader} The created shader.
@private | [
"Loads",
"a",
"shader",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L477-L516 | train |
greggman/twgl.js | src/programs.js | createUniformSetters | function createUniformSetters(gl, program) {
let textureUnit = 0;
/**
* Creates a setter for a uniform of the given program with it's
* location embedded in the setter.
* @param {WebGLProgram} program
* @param {WebGLUniformInfo} uniformInfo
* @returns {function} the created setter.
*/
function ... | javascript | function createUniformSetters(gl, program) {
let textureUnit = 0;
/**
* Creates a setter for a uniform of the given program with it's
* location embedded in the setter.
* @param {WebGLProgram} program
* @param {WebGLUniformInfo} uniformInfo
* @returns {function} the created setter.
*/
function ... | [
"function",
"createUniformSetters",
"(",
"gl",
",",
"program",
")",
"{",
"let",
"textureUnit",
"=",
"0",
";",
"/**\n * Creates a setter for a uniform of the given program with it's\n * location embedded in the setter.\n * @param {WebGLProgram} program\n * @param {WebGLUniformInfo} ... | Creates setter functions for all uniforms of a shader
program.
@see {@link module:twgl.setUniforms}
@param {WebGLProgram} program the program to create setters for.
@returns {Object.<string, function>} an object with a setter by name for each uniform
@memberOf module:twgl/programs | [
"Creates",
"setter",
"functions",
"for",
"all",
"uniforms",
"of",
"a",
"shader",
"program",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L815-L871 | train |
greggman/twgl.js | src/programs.js | createUniformSetter | function createUniformSetter(program, uniformInfo) {
const location = gl.getUniformLocation(program, uniformInfo.name);
const isArray = (uniformInfo.size > 1 && uniformInfo.name.substr(-3) === "[0]");
const type = uniformInfo.type;
const typeInfo = typeMap[type];
if (!typeInfo) {
throw ("unkno... | javascript | function createUniformSetter(program, uniformInfo) {
const location = gl.getUniformLocation(program, uniformInfo.name);
const isArray = (uniformInfo.size > 1 && uniformInfo.name.substr(-3) === "[0]");
const type = uniformInfo.type;
const typeInfo = typeMap[type];
if (!typeInfo) {
throw ("unkno... | [
"function",
"createUniformSetter",
"(",
"program",
",",
"uniformInfo",
")",
"{",
"const",
"location",
"=",
"gl",
".",
"getUniformLocation",
"(",
"program",
",",
"uniformInfo",
".",
"name",
")",
";",
"const",
"isArray",
"=",
"(",
"uniformInfo",
".",
"size",
"... | Creates a setter for a uniform of the given program with it's
location embedded in the setter.
@param {WebGLProgram} program
@param {WebGLUniformInfo} uniformInfo
@returns {function} the created setter. | [
"Creates",
"a",
"setter",
"for",
"a",
"uniform",
"of",
"the",
"given",
"program",
"with",
"it",
"s",
"location",
"embedded",
"in",
"the",
"setter",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L825-L852 | train |
greggman/twgl.js | src/programs.js | bindTransformFeedbackInfo | function bindTransformFeedbackInfo(gl, transformFeedbackInfo, bufferInfo) {
if (transformFeedbackInfo.transformFeedbackInfo) {
transformFeedbackInfo = transformFeedbackInfo.transformFeedbackInfo;
}
if (bufferInfo.attribs) {
bufferInfo = bufferInfo.attribs;
}
for (const name in bufferInfo) {
const ... | javascript | function bindTransformFeedbackInfo(gl, transformFeedbackInfo, bufferInfo) {
if (transformFeedbackInfo.transformFeedbackInfo) {
transformFeedbackInfo = transformFeedbackInfo.transformFeedbackInfo;
}
if (bufferInfo.attribs) {
bufferInfo = bufferInfo.attribs;
}
for (const name in bufferInfo) {
const ... | [
"function",
"bindTransformFeedbackInfo",
"(",
"gl",
",",
"transformFeedbackInfo",
",",
"bufferInfo",
")",
"{",
"if",
"(",
"transformFeedbackInfo",
".",
"transformFeedbackInfo",
")",
"{",
"transformFeedbackInfo",
"=",
"transformFeedbackInfo",
".",
"transformFeedbackInfo",
... | Binds buffers for transform feedback.
@param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
@param {(module:twgl.ProgramInfo|Object<string, module:twgl.TransformFeedbackInfo>)} transformFeedbackInfo A ProgramInfo or TransformFeedbackInfo.
@param {(module:twgl.BufferInfo|Object<string, module:twgl.AttribI... | [
"Binds",
"buffers",
"for",
"transform",
"feedback",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L910-L928 | train |
greggman/twgl.js | src/programs.js | createTransformFeedback | function createTransformFeedback(gl, programInfo, bufferInfo) {
const tf = gl.createTransformFeedback();
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, tf);
gl.useProgram(programInfo.program);
bindTransformFeedbackInfo(gl, programInfo, bufferInfo);
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, null);
ret... | javascript | function createTransformFeedback(gl, programInfo, bufferInfo) {
const tf = gl.createTransformFeedback();
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, tf);
gl.useProgram(programInfo.program);
bindTransformFeedbackInfo(gl, programInfo, bufferInfo);
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, null);
ret... | [
"function",
"createTransformFeedback",
"(",
"gl",
",",
"programInfo",
",",
"bufferInfo",
")",
"{",
"const",
"tf",
"=",
"gl",
".",
"createTransformFeedback",
"(",
")",
";",
"gl",
".",
"bindTransformFeedback",
"(",
"gl",
".",
"TRANSFORM_FEEDBACK",
",",
"tf",
")"... | Creates a transform feedback and sets the buffers
@param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
@param {module:twgl.ProgramInfo} programInfo A ProgramInfo as returned from {@link module:twgl.createProgramInfo}
@param {(module:twgl.BufferInfo|Object<string, module:twgl.AttribInfo>)} [bufferInfo] A ... | [
"Creates",
"a",
"transform",
"feedback",
"and",
"sets",
"the",
"buffers"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L938-L945 | train |
greggman/twgl.js | src/programs.js | createUniformBlockSpecFromProgram | function createUniformBlockSpecFromProgram(gl, program) {
const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
const uniformData = [];
const uniformIndices = [];
for (let ii = 0; ii < numUniforms; ++ii) {
uniformIndices.push(ii);
uniformData.push({});
const uniformInfo = gl.getA... | javascript | function createUniformBlockSpecFromProgram(gl, program) {
const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
const uniformData = [];
const uniformIndices = [];
for (let ii = 0; ii < numUniforms; ++ii) {
uniformIndices.push(ii);
uniformData.push({});
const uniformInfo = gl.getA... | [
"function",
"createUniformBlockSpecFromProgram",
"(",
"gl",
",",
"program",
")",
"{",
"const",
"numUniforms",
"=",
"gl",
".",
"getProgramParameter",
"(",
"program",
",",
"gl",
".",
"ACTIVE_UNIFORMS",
")",
";",
"const",
"uniformData",
"=",
"[",
"]",
";",
"const... | A `UniformBlockSpec` represents the data needed to create and bind
UniformBlockObjects for a given program
@typedef {Object} UniformBlockSpec
@property {Object.<string, module:twgl.BlockSpec> blockSpecs The BlockSpec for each block by block name
@property {UniformData[]} uniformData An array of data for each uniform b... | [
"A",
"UniformBlockSpec",
"represents",
"the",
"data",
"needed",
"to",
"create",
"and",
"bind",
"UniformBlockObjects",
"for",
"a",
"given",
"program"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L991-L1040 | train |
greggman/twgl.js | src/programs.js | createUniformBlockInfoFromProgram | function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockName) {
const blockSpecs = uniformBlockSpec.blockSpecs;
const uniformData = uniformBlockSpec.uniformData;
const blockSpec = blockSpecs[blockName];
if (!blockSpec) {
warn("no uniform block object named:", blockName);
return {
... | javascript | function createUniformBlockInfoFromProgram(gl, program, uniformBlockSpec, blockName) {
const blockSpecs = uniformBlockSpec.blockSpecs;
const uniformData = uniformBlockSpec.uniformData;
const blockSpec = blockSpecs[blockName];
if (!blockSpec) {
warn("no uniform block object named:", blockName);
return {
... | [
"function",
"createUniformBlockInfoFromProgram",
"(",
"gl",
",",
"program",
",",
"uniformBlockSpec",
",",
"blockName",
")",
"{",
"const",
"blockSpecs",
"=",
"uniformBlockSpec",
".",
"blockSpecs",
";",
"const",
"uniformData",
"=",
"uniformBlockSpec",
".",
"uniformData"... | Represents a UniformBlockObject including an ArrayBuffer with all the uniform values
and a corresponding WebGLBuffer to hold those values on the GPU
@typedef {Object} UniformBlockInfo
@property {string} name The name of the block
@property {ArrayBuffer} array The array buffer that contains the uniform values
@property... | [
"Represents",
"a",
"UniformBlockObject",
"including",
"an",
"ArrayBuffer",
"with",
"all",
"the",
"uniform",
"values",
"and",
"a",
"corresponding",
"WebGLBuffer",
"to",
"hold",
"those",
"values",
"on",
"the",
"GPU"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L1080-L1120 | train |
greggman/twgl.js | src/programs.js | createUniformBlockInfo | function createUniformBlockInfo(gl, programInfo, blockName) {
return createUniformBlockInfoFromProgram(gl, programInfo.program, programInfo.uniformBlockSpec, blockName);
} | javascript | function createUniformBlockInfo(gl, programInfo, blockName) {
return createUniformBlockInfoFromProgram(gl, programInfo.program, programInfo.uniformBlockSpec, blockName);
} | [
"function",
"createUniformBlockInfo",
"(",
"gl",
",",
"programInfo",
",",
"blockName",
")",
"{",
"return",
"createUniformBlockInfoFromProgram",
"(",
"gl",
",",
"programInfo",
".",
"program",
",",
"programInfo",
".",
"uniformBlockSpec",
",",
"blockName",
")",
";",
... | Creates a `UniformBlockInfo` for the specified block
Note: **If the blockName matches no existing blocks a warning is printed to the console and a dummy
`UniformBlockInfo` is returned**. This is because when debugging GLSL
it is common to comment out large portions of a shader or for example set
the final output to a ... | [
"Creates",
"a",
"UniformBlockInfo",
"for",
"the",
"specified",
"block"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L1138-L1140 | train |
greggman/twgl.js | src/programs.js | bindUniformBlock | function bindUniformBlock(gl, programInfo, uniformBlockInfo) {
const uniformBlockSpec = programInfo.uniformBlockSpec || programInfo;
const blockSpec = uniformBlockSpec.blockSpecs[uniformBlockInfo.name];
if (blockSpec) {
const bufferBindIndex = blockSpec.index;
gl.bindBufferRange(gl.UNIFORM_BUFFER, bufferB... | javascript | function bindUniformBlock(gl, programInfo, uniformBlockInfo) {
const uniformBlockSpec = programInfo.uniformBlockSpec || programInfo;
const blockSpec = uniformBlockSpec.blockSpecs[uniformBlockInfo.name];
if (blockSpec) {
const bufferBindIndex = blockSpec.index;
gl.bindBufferRange(gl.UNIFORM_BUFFER, bufferB... | [
"function",
"bindUniformBlock",
"(",
"gl",
",",
"programInfo",
",",
"uniformBlockInfo",
")",
"{",
"const",
"uniformBlockSpec",
"=",
"programInfo",
".",
"uniformBlockSpec",
"||",
"programInfo",
";",
"const",
"blockSpec",
"=",
"uniformBlockSpec",
".",
"blockSpecs",
"[... | Binds a unform block to the matching uniform block point.
Matches by blocks by name so blocks must have the same name not just the same
structure.
If you have changed any values and you upload the valus into the corresponding WebGLBuffer
call {@link module:twgl.setUniformBlock} instead.
@param {WebGL2RenderingContext... | [
"Binds",
"a",
"unform",
"block",
"to",
"the",
"matching",
"uniform",
"block",
"point",
".",
"Matches",
"by",
"blocks",
"by",
"name",
"so",
"blocks",
"must",
"have",
"the",
"same",
"name",
"not",
"just",
"the",
"same",
"structure",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L1160-L1169 | train |
greggman/twgl.js | src/programs.js | setUniformBlock | function setUniformBlock(gl, programInfo, uniformBlockInfo) {
if (bindUniformBlock(gl, programInfo, uniformBlockInfo)) {
gl.bufferData(gl.UNIFORM_BUFFER, uniformBlockInfo.array, gl.DYNAMIC_DRAW);
}
} | javascript | function setUniformBlock(gl, programInfo, uniformBlockInfo) {
if (bindUniformBlock(gl, programInfo, uniformBlockInfo)) {
gl.bufferData(gl.UNIFORM_BUFFER, uniformBlockInfo.array, gl.DYNAMIC_DRAW);
}
} | [
"function",
"setUniformBlock",
"(",
"gl",
",",
"programInfo",
",",
"uniformBlockInfo",
")",
"{",
"if",
"(",
"bindUniformBlock",
"(",
"gl",
",",
"programInfo",
",",
"uniformBlockInfo",
")",
")",
"{",
"gl",
".",
"bufferData",
"(",
"gl",
".",
"UNIFORM_BUFFER",
... | Uploads the current uniform values to the corresponding WebGLBuffer
and binds that buffer to the program's corresponding bind point for the uniform block object.
If you haven't changed any values and you only need to bind the uniform block object
call {@link module:twgl.bindUniformBlock} instead.
@param {WebGL2Render... | [
"Uploads",
"the",
"current",
"uniform",
"values",
"to",
"the",
"corresponding",
"WebGLBuffer",
"and",
"binds",
"that",
"buffer",
"to",
"the",
"program",
"s",
"corresponding",
"bind",
"point",
"for",
"the",
"uniform",
"block",
"object",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L1186-L1190 | train |
greggman/twgl.js | src/programs.js | setBlockUniforms | function setBlockUniforms(uniformBlockInfo, values) {
const uniforms = uniformBlockInfo.uniforms;
for (const name in values) {
const array = uniforms[name];
if (array) {
const value = values[name];
if (value.length) {
array.set(value);
} else {
array[0] = value;
}
... | javascript | function setBlockUniforms(uniformBlockInfo, values) {
const uniforms = uniformBlockInfo.uniforms;
for (const name in values) {
const array = uniforms[name];
if (array) {
const value = values[name];
if (value.length) {
array.set(value);
} else {
array[0] = value;
}
... | [
"function",
"setBlockUniforms",
"(",
"uniformBlockInfo",
",",
"values",
")",
"{",
"const",
"uniforms",
"=",
"uniformBlockInfo",
".",
"uniforms",
";",
"for",
"(",
"const",
"name",
"in",
"values",
")",
"{",
"const",
"array",
"=",
"uniforms",
"[",
"name",
"]",
... | Sets values of a uniform block object
@param {module:twgl.UniformBlockInfo} uniformBlockInfo A UniformBlockInfo as returned by {@link module:twgl.createUniformBlockInfo}.
@param {Object.<string, ?>} values A uniform name to value map where the value is correct for the given
type of uniform. So for example given a bloc... | [
"Sets",
"values",
"of",
"a",
"uniform",
"block",
"object"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L1220-L1233 | train |
greggman/twgl.js | src/programs.js | createProgramInfo | function createProgramInfo(
gl, shaderSources, opt_attribs, opt_locations, opt_errorCallback) {
const progOptions = getProgramOptions(opt_attribs, opt_locations, opt_errorCallback);
let good = true;
shaderSources = shaderSources.map(function(source) {
// Lets assume if there is no \n it's an id
if (so... | javascript | function createProgramInfo(
gl, shaderSources, opt_attribs, opt_locations, opt_errorCallback) {
const progOptions = getProgramOptions(opt_attribs, opt_locations, opt_errorCallback);
let good = true;
shaderSources = shaderSources.map(function(source) {
// Lets assume if there is no \n it's an id
if (so... | [
"function",
"createProgramInfo",
"(",
"gl",
",",
"shaderSources",
",",
"opt_attribs",
",",
"opt_locations",
",",
"opt_errorCallback",
")",
"{",
"const",
"progOptions",
"=",
"getProgramOptions",
"(",
"opt_attribs",
",",
"opt_locations",
",",
"opt_errorCallback",
")",
... | Creates a ProgramInfo from 2 sources.
A ProgramInfo contains
programInfo = {
program: WebGLProgram,
uniformSetters: object of setters as returned from createUniformSetters,
attribSetters: object of setters as returned from createAttribSetters,
}
NOTE: There are 4 signatures for this function
twgl.createProgramInfo(... | [
"Creates",
"a",
"ProgramInfo",
"from",
"2",
"sources",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/programs.js#L1584-L1609 | train |
greggman/twgl.js | src/textures.js | canGenerateMipmap | function canGenerateMipmap(gl, width, height, internalFormat /*, type */) {
if (!utils.isWebGL2(gl)) {
return isPowerOf2(width) && isPowerOf2(height);
}
const info = textureInternalFormatInfo[internalFormat];
if (!info) {
throw "unknown internal format";
}
return info.colorRenderable && info.texture... | javascript | function canGenerateMipmap(gl, width, height, internalFormat /*, type */) {
if (!utils.isWebGL2(gl)) {
return isPowerOf2(width) && isPowerOf2(height);
}
const info = textureInternalFormatInfo[internalFormat];
if (!info) {
throw "unknown internal format";
}
return info.colorRenderable && info.texture... | [
"function",
"canGenerateMipmap",
"(",
"gl",
",",
"width",
",",
"height",
",",
"internalFormat",
"/*, type */",
")",
"{",
"if",
"(",
"!",
"utils",
".",
"isWebGL2",
"(",
"gl",
")",
")",
"{",
"return",
"isPowerOf2",
"(",
"width",
")",
"&&",
"isPowerOf2",
"(... | Gets whether or not we can generate mips for the given
internal format.
@param {number} internalFormat The internalFormat parameter from texImage2D etc..
@param {number} type The type parameter for texImage2D etc..
@return {boolean} true if we can generate mips
@memberOf module:twgl/textures | [
"Gets",
"whether",
"or",
"not",
"we",
"can",
"generate",
"mips",
"for",
"the",
"given",
"internal",
"format",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L348-L357 | train |
greggman/twgl.js | src/textures.js | getTextureTypeForArrayType | function getTextureTypeForArrayType(gl, src, defaultType) {
if (isArrayBuffer(src)) {
return typedArrays.getGLTypeForTypedArray(src);
}
return defaultType || gl.UNSIGNED_BYTE;
} | javascript | function getTextureTypeForArrayType(gl, src, defaultType) {
if (isArrayBuffer(src)) {
return typedArrays.getGLTypeForTypedArray(src);
}
return defaultType || gl.UNSIGNED_BYTE;
} | [
"function",
"getTextureTypeForArrayType",
"(",
"gl",
",",
"src",
",",
"defaultType",
")",
"{",
"if",
"(",
"isArrayBuffer",
"(",
"src",
")",
")",
"{",
"return",
"typedArrays",
".",
"getGLTypeForTypedArray",
"(",
"src",
")",
";",
"}",
"return",
"defaultType",
... | Gets the texture type for a given array type.
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@return {number} the gl texture type
@private | [
"Gets",
"the",
"texture",
"type",
"for",
"a",
"given",
"array",
"type",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L394-L399 | train |
greggman/twgl.js | src/textures.js | savePackState | function savePackState(gl, options) {
if (options.colorspaceConversion !== undefined) {
lastPackState.colorspaceConversion = gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL);
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, options.colorspaceConversion);
}
if (options.premultiplyAlpha !== undef... | javascript | function savePackState(gl, options) {
if (options.colorspaceConversion !== undefined) {
lastPackState.colorspaceConversion = gl.getParameter(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL);
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, options.colorspaceConversion);
}
if (options.premultiplyAlpha !== undef... | [
"function",
"savePackState",
"(",
"gl",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"colorspaceConversion",
"!==",
"undefined",
")",
"{",
"lastPackState",
".",
"colorspaceConversion",
"=",
"gl",
".",
"getParameter",
"(",
"gl",
".",
"UNPACK_COLORSPACE_CO... | Saves any packing state that will be set based on the options.
@param {module:twgl.TextureOptions} options A TextureOptions object with whatever parameters you want set.
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@private | [
"Saves",
"any",
"packing",
"state",
"that",
"will",
"be",
"set",
"based",
"on",
"the",
"options",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L574-L587 | train |
greggman/twgl.js | src/textures.js | restorePackState | function restorePackState(gl, options) {
if (options.colorspaceConversion !== undefined) {
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, lastPackState.colorspaceConversion);
}
if (options.premultiplyAlpha !== undefined) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, lastPackState.premultiplyA... | javascript | function restorePackState(gl, options) {
if (options.colorspaceConversion !== undefined) {
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, lastPackState.colorspaceConversion);
}
if (options.premultiplyAlpha !== undefined) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, lastPackState.premultiplyA... | [
"function",
"restorePackState",
"(",
"gl",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"colorspaceConversion",
"!==",
"undefined",
")",
"{",
"gl",
".",
"pixelStorei",
"(",
"gl",
".",
"UNPACK_COLORSPACE_CONVERSION_WEBGL",
",",
"lastPackState",
".",
"colo... | Restores any packing state that was set based on the options.
@param {module:twgl.TextureOptions} options A TextureOptions object with whatever parameters you want set.
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@private | [
"Restores",
"any",
"packing",
"state",
"that",
"was",
"set",
"based",
"on",
"the",
"options",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L595-L605 | train |
greggman/twgl.js | src/textures.js | saveSkipState | function saveSkipState(gl) {
lastPackState.unpackAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);
if (utils.isWebGL2(gl)) {
lastPackState.unpackRowLength = gl.getParameter(gl.UNPACK_ROW_LENGTH);
lastPackState.unpackImageHeight = gl.getParameter(gl.UNPACK_IMAGE_HEIGHT);
lastPackState.unpackSkipPixel... | javascript | function saveSkipState(gl) {
lastPackState.unpackAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);
if (utils.isWebGL2(gl)) {
lastPackState.unpackRowLength = gl.getParameter(gl.UNPACK_ROW_LENGTH);
lastPackState.unpackImageHeight = gl.getParameter(gl.UNPACK_IMAGE_HEIGHT);
lastPackState.unpackSkipPixel... | [
"function",
"saveSkipState",
"(",
"gl",
")",
"{",
"lastPackState",
".",
"unpackAlignment",
"=",
"gl",
".",
"getParameter",
"(",
"gl",
".",
"UNPACK_ALIGNMENT",
")",
";",
"if",
"(",
"utils",
".",
"isWebGL2",
"(",
"gl",
")",
")",
"{",
"lastPackState",
".",
... | Saves state related to data size
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@private | [
"Saves",
"state",
"related",
"to",
"data",
"size"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L612-L621 | train |
greggman/twgl.js | src/textures.js | setTextureSamplerParameters | function setTextureSamplerParameters(gl, target, parameteriFn, options) {
if (options.minMag) {
parameteriFn.call(gl, target, gl.TEXTURE_MIN_FILTER, options.minMag);
parameteriFn.call(gl, target, gl.TEXTURE_MAG_FILTER, options.minMag);
}
if (options.min) {
parameteriFn.call(gl, target, gl.TEXTURE_MIN_... | javascript | function setTextureSamplerParameters(gl, target, parameteriFn, options) {
if (options.minMag) {
parameteriFn.call(gl, target, gl.TEXTURE_MIN_FILTER, options.minMag);
parameteriFn.call(gl, target, gl.TEXTURE_MAG_FILTER, options.minMag);
}
if (options.min) {
parameteriFn.call(gl, target, gl.TEXTURE_MIN_... | [
"function",
"setTextureSamplerParameters",
"(",
"gl",
",",
"target",
",",
"parameteriFn",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"minMag",
")",
"{",
"parameteriFn",
".",
"call",
"(",
"gl",
",",
"target",
",",
"gl",
".",
"TEXTURE_MIN_FILTER",
... | Sets the parameters of a texture or sampler
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@param {number|WebGLSampler} target texture target or sampler
@param {function()} parameteriFn texParamteri or samplerParameteri fn
@param {WebGLTexture} tex the WebGLTexture to set parameters for
@param {module:twgl... | [
"Sets",
"the",
"parameters",
"of",
"a",
"texture",
"or",
"sampler"
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L650-L689 | train |
greggman/twgl.js | src/textures.js | setTextureParameters | function setTextureParameters(gl, tex, options) {
const target = options.target || gl.TEXTURE_2D;
gl.bindTexture(target, tex);
setTextureSamplerParameters(gl, target, gl.texParameteri, options);
} | javascript | function setTextureParameters(gl, tex, options) {
const target = options.target || gl.TEXTURE_2D;
gl.bindTexture(target, tex);
setTextureSamplerParameters(gl, target, gl.texParameteri, options);
} | [
"function",
"setTextureParameters",
"(",
"gl",
",",
"tex",
",",
"options",
")",
"{",
"const",
"target",
"=",
"options",
".",
"target",
"||",
"gl",
".",
"TEXTURE_2D",
";",
"gl",
".",
"bindTexture",
"(",
"target",
",",
"tex",
")",
";",
"setTextureSamplerPara... | Sets the texture parameters of a texture.
@param {WebGLRenderingContext} gl the WebGLRenderingContext
@param {WebGLTexture} tex the WebGLTexture to set parameters for
@param {module:twgl.TextureOptions} options A TextureOptions object with whatever parameters you want set.
This is often the same options you passed in w... | [
"Sets",
"the",
"texture",
"parameters",
"of",
"a",
"texture",
"."
] | ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd | https://github.com/greggman/twgl.js/blob/ae88dfe4d7a7d44a5b739fcbe50bccccd0e1a1fd/src/textures.js#L699-L703 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.