_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q23700 | TokenRequest | train | 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 | {
"resource": ""
} |
q23701 | UserRealm | train | 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 | {
"resource": ""
} |
q23702 | WSTrustRequest | train | 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 | {
"resource": ""
} |
q23703 | _datePlusMinutes | train | function _datePlusMinutes(date, minutes) {
var minutesInMilliSeconds = minutes * 60 * 1000;
var epochTime = date.getTime() + minutesInMilliSeconds;
return new Date(epochTime);
} | javascript | {
"resource": ""
} |
q23704 | createRequestOptions | train | 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 | {
"resource": ""
} |
q23705 | scrubRSTRLogMessage | train | 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 | {
"resource": ""
} |
q23706 | WSTrustResponse | train | 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 | {
"resource": ""
} |
q23707 | CodeRequest | train | 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 | {
"resource": ""
} |
q23708 | Mex | train | 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 | {
"resource": ""
} |
q23709 | train | 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 | {
"resource": ""
} | |
q23710 | trap | train | 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 | {
"resource": ""
} |
q23711 | release | train | function release() {
if (this.isTrapped) {
this.restoreTrap = this.state.open;
screenReaderTrap.untrap(this.windowEl);
keyboardTrap.untrap(this.windowEl);
} else {
this.restoreTrap = false;
}
} | javascript | {
"resource": ""
} |
q23712 | handlePageClick | train | function handlePageClick(originalEvent) {
const target = originalEvent.target;
emitAndFire(this, 'pagination-select', {
originalEvent,
el: target,
value: target.innerText
});
} | javascript | {
"resource": ""
} |
q23713 | cancel | train | 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 | {
"resource": ""
} |
q23714 | listener | train | function listener({ target }) {
target.removeEventListener(TRANSITION_END, listener);
if (++ran === pending) {
ended = true;
classList.remove(className);
if (cb) {
cb();
}
}
} | javascript | {
"resource": ""
} |
q23715 | nextFrame | train | 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 | {
"resource": ""
} |
q23716 | processHtmlAttributes | train | 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 | {
"resource": ""
} |
q23717 | emitAndFire | train | 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 | {
"resource": ""
} |
q23718 | processStateChange | train | 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 | {
"resource": ""
} |
q23719 | getHeadingEl | train | 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 | {
"resource": ""
} |
q23720 | getElementIndex | train | function getElementIndex(headingEl) {
return Array.prototype.slice.call(headingEl.parentNode.children).indexOf(headingEl);
} | javascript | {
"resource": ""
} |
q23721 | handleItemClick | train | 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 | {
"resource": ""
} |
q23722 | setCheckedItem | train | 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 | {
"resource": ""
} |
q23723 | setCheckedList | train | function setCheckedList(indexArray) {
if (indexArray) {
this.state.items.forEach((item) => {
item.checked = false;
});
indexArray.forEach((index) => {
this.setCheckedItem(index);
});
this.processAfterStateChange(indexArray);
}
} | javascript | {
"resource": ""
} |
q23724 | transform | train | 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 | {
"resource": ""
} |
q23725 | handleMove | train | 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 | {
"resource": ""
} |
q23726 | handleDotClick | train | 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 | {
"resource": ""
} |
q23727 | togglePlay | train | 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 | {
"resource": ""
} |
q23728 | handleScroll | train | 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 | {
"resource": ""
} |
q23729 | move | train | 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 | {
"resource": ""
} |
q23730 | getOffset | train | function getOffset(state) {
const { items, index } = state;
if (!items.length) {
return 0;
}
return Math.min(items[index].left, getMaxOffset(state)) || 0;
} | javascript | {
"resource": ""
} |
q23731 | getMaxOffset | train | function getMaxOffset({ items, slideWidth }) {
if (!items.length) {
return 0;
}
return Math.max(items[items.length - 1].right - slideWidth, 0) || 0;
} | javascript | {
"resource": ""
} |
q23732 | getSlide | train | function getSlide({ index, itemsPerSlide }, i = index) {
if (!itemsPerSlide) {
return;
}
return Math.ceil(i / itemsPerSlide);
} | javascript | {
"resource": ""
} |
q23733 | normalizeIndex | train | 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 | {
"resource": ""
} |
q23734 | getNextIndex | train | 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 | {
"resource": ""
} |
q23735 | forEls | train | function forEls(parent, fn) {
let i = 0;
let child = parent.firstElementChild;
while (child) {
fn(child, i++);
child = child.nextElementSibling;
}
} | javascript | {
"resource": ""
} |
q23736 | observeRoot | train | function observeRoot(widget, attributes, callback, skipSetState) {
attributes.forEach(attribute => {
Object.defineProperty(widget.el, attribute, {
get() {
return widget.state[attribute];
},
set(value) {
if (!skipSetState) {
... | javascript | {
"resource": ""
} |
q23737 | observeInner | train | 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 | {
"resource": ""
} |
q23738 | scroll | train | 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 | {
"resource": ""
} |
q23739 | handleKeydown | train | function handleKeydown(keyCodes, e, callback) {
const keyCode = e.charCode || e.keyCode;
if (keyCodes.indexOf(keyCode) !== -1) {
callback();
}
} | javascript | {
"resource": ""
} |
q23740 | handleNotKeydown | train | function handleNotKeydown(keyCodes, e, callback) {
const keyCode = e.charCode || e.keyCode;
if (keyCodes.indexOf(keyCode) === -1) {
callback();
}
} | javascript | {
"resource": ""
} |
q23741 | isDirectory | train | function isDirectory(obj) {
return obj.sources.every(path => {
try {
return fs.lstatSync(path).isDirectory();
} catch (e) {
return false;
}
});
} | javascript | {
"resource": ""
} |
q23742 | handleOptionClick | train | 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 | {
"resource": ""
} |
q23743 | handleChannelConvertedEvent | train | 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 | {
"resource": ""
} |
q23744 | plural | train | function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
} | javascript | {
"resource": ""
} |
q23745 | getNativeConstructorFromType | train | function getNativeConstructorFromType(type) {
return {
string: String,
boolean: Boolean,
array: Array,
function: Function,
int: Number,
serverapi: Object,
object: Object
}[type];
} | javascript | {
"resource": ""
} |
q23746 | copyExistingProperties | train | function copyExistingProperties(src, dst) {
Object.keys(dst).forEach(function(key) {
if (dst.hasOwnProperty(key) && src.hasOwnProperty(key)) {
dst[key] = src[key];
}
});
} | javascript | {
"resource": ""
} |
q23747 | setDefaults | train | function setDefaults(newDefaults) {
helper.copyExistingProperties(newDefaults, defaults);
attributes.setAttributeDefaults_(newDefaults); // eslint-disable-line
textures.setTextureDefaults_(newDefaults); // eslint-disable-line
} | javascript | {
"resource": ""
} |
q23748 | addExtensionsToContext | train | function addExtensionsToContext(gl) {
for (let ii = 0; ii < supportedExtensions.length; ++ii) {
addExtensionToContext(gl, supportedExtensions[ii]);
}
} | javascript | {
"resource": ""
} |
q23749 | createContext | train | 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 | {
"resource": ""
} |
q23750 | drawBufferInfo | train | 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 | {
"resource": ""
} |
q23751 | getGLTypeForTypedArray | train | 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 | {
"resource": ""
} |
q23752 | getGLTypeForTypedArrayType | train | 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 | {
"resource": ""
} |
q23753 | negate | train | 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 | {
"resource": ""
} |
q23754 | copy | train | 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 | {
"resource": ""
} |
q23755 | identity | train | 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 | {
"resource": ""
} |
q23756 | transpose | train | 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 | {
"resource": ""
} |
q23757 | setTranslation | train | 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 | {
"resource": ""
} |
q23758 | getTranslation | train | function getTranslation(m, dst) {
dst = dst || v3.create();
dst[0] = m[12];
dst[1] = m[13];
dst[2] = m[14];
return dst;
} | javascript | {
"resource": ""
} |
q23759 | getAxis | train | 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 | {
"resource": ""
} |
q23760 | setAxis | train | 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 | {
"resource": ""
} |
q23761 | perspective | train | 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 | {
"resource": ""
} |
q23762 | ortho | train | 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 | {
"resource": ""
} |
q23763 | frustum | train | 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 | {
"resource": ""
} |
q23764 | lookAt | train | 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 | {
"resource": ""
} |
q23765 | translation | train | 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 | {
"resource": ""
} |
q23766 | translate | train | 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 | {
"resource": ""
} |
q23767 | rotateX | train | 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 | {
"resource": ""
} |
q23768 | rotateY | train | 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 | {
"resource": ""
} |
q23769 | rotationZ | train | 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 | {
"resource": ""
} |
q23770 | rotateZ | train | 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 | {
"resource": ""
} |
q23771 | axisRotation | train | 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 | {
"resource": ""
} |
q23772 | scaling | train | 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 | {
"resource": ""
} |
q23773 | scale | train | 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 | {
"resource": ""
} |
q23774 | transformPoint | train | 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 | {
"resource": ""
} |
q23775 | transformDirection | train | 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 | {
"resource": ""
} |
q23776 | createBufferFromTypedArray | train | 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 | {
"resource": ""
} |
q23777 | setAttribInfoBufferFromArray | train | 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 | {
"resource": ""
} |
q23778 | createBufferFromArray | train | 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 | {
"resource": ""
} |
q23779 | createBuffersFromArrays | train | 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 | {
"resource": ""
} |
q23780 | addLineNumbers | train | function addLineNumbers(src, lineOffset) {
lineOffset = lineOffset || 0;
++lineOffset;
return src.split("\n").map(function(line, ndx) {
return (ndx + lineOffset) + ": " + line;
}).join("\n");
} | javascript | {
"resource": ""
} |
q23781 | loadShader | train | 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 | {
"resource": ""
} |
q23782 | createUniformSetters | train | 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 | {
"resource": ""
} |
q23783 | createUniformSetter | train | 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 | {
"resource": ""
} |
q23784 | bindTransformFeedbackInfo | train | function bindTransformFeedbackInfo(gl, transformFeedbackInfo, bufferInfo) {
if (transformFeedbackInfo.transformFeedbackInfo) {
transformFeedbackInfo = transformFeedbackInfo.transformFeedbackInfo;
}
if (bufferInfo.attribs) {
bufferInfo = bufferInfo.attribs;
}
for (const name in bufferInfo) {
const ... | javascript | {
"resource": ""
} |
q23785 | createTransformFeedback | train | 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 | {
"resource": ""
} |
q23786 | createUniformBlockSpecFromProgram | train | 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 | {
"resource": ""
} |
q23787 | createUniformBlockInfoFromProgram | train | 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 | {
"resource": ""
} |
q23788 | createUniformBlockInfo | train | function createUniformBlockInfo(gl, programInfo, blockName) {
return createUniformBlockInfoFromProgram(gl, programInfo.program, programInfo.uniformBlockSpec, blockName);
} | javascript | {
"resource": ""
} |
q23789 | bindUniformBlock | train | 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 | {
"resource": ""
} |
q23790 | setUniformBlock | train | function setUniformBlock(gl, programInfo, uniformBlockInfo) {
if (bindUniformBlock(gl, programInfo, uniformBlockInfo)) {
gl.bufferData(gl.UNIFORM_BUFFER, uniformBlockInfo.array, gl.DYNAMIC_DRAW);
}
} | javascript | {
"resource": ""
} |
q23791 | setBlockUniforms | train | 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 | {
"resource": ""
} |
q23792 | createProgramInfo | train | 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 | {
"resource": ""
} |
q23793 | canGenerateMipmap | train | 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 | {
"resource": ""
} |
q23794 | getTextureTypeForArrayType | train | function getTextureTypeForArrayType(gl, src, defaultType) {
if (isArrayBuffer(src)) {
return typedArrays.getGLTypeForTypedArray(src);
}
return defaultType || gl.UNSIGNED_BYTE;
} | javascript | {
"resource": ""
} |
q23795 | savePackState | train | 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 | {
"resource": ""
} |
q23796 | restorePackState | train | 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 | {
"resource": ""
} |
q23797 | saveSkipState | train | 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 | {
"resource": ""
} |
q23798 | setTextureSamplerParameters | train | 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 | {
"resource": ""
} |
q23799 | setTextureParameters | train | function setTextureParameters(gl, tex, options) {
const target = options.target || gl.TEXTURE_2D;
gl.bindTexture(target, tex);
setTextureSamplerParameters(gl, target, gl.texParameteri, options);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.