_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q16500
cleanNode
train
function cleanNode(node) { var child = node.firstChild; while (child != null) { var next = child.nextSibling; cleanNode(child); child = next; } if ((node.nodeType != 1 || (node.nodeName !== 'BR' && node.firstChild == null)) && (node.nodeType != 3 || mxUtils.trim(mxUt...
javascript
{ "resource": "" }
q16501
createHint
train
function createHint() { var hint = document.createElement('div'); hint.className = 'geHint'; hint.style.whiteSpace = 'nowrap'; hint.style.position = 'absolute'; return hint; }
javascript
{ "resource": "" }
q16502
train
function(evt) { if (evt != null) { var source = mxEvent.getSource(evt); if (source.nodeName == 'A') { while (source != null) { if (source.className == 'geHint') { return true; } source = source.parentNode; } } } return textEditi...
javascript
{ "resource": "" }
q16503
isOrContains
train
function isOrContains(container, node) { while (node != null) { if (node === container) { return true; } node = node.parentNode; } return false; }
javascript
{ "resource": "" }
q16504
Menu
train
function Menu(funct, enabled) { mxEventSource.call(this); this.funct = funct; this.enabled = (enabled != null) ? enabled : true; }
javascript
{ "resource": "" }
q16505
preview
train
function preview(print) { var autoOrigin = onePageCheckBox.checked || pageCountCheckBox.checked; var printScale = parseInt(pageScaleInput.value) / 100; if (isNaN(printScale)) { printScale = 1; pageScaleInput.value = '100%'; } // Workaround to match available paper size in actual print output ...
javascript
{ "resource": "" }
q16506
snapX
train
function snapX(x, state) { x += this.graph.panDx; var override = false; if (Math.abs(x - center) < ttX) { dx = x - bounds.getCenterX(); ttX = Math.abs(x - center); override = true; } else if (Math.abs(x - left) < ttX) { dx = x - bounds.x; ttX = Math.abs(x - left); over...
javascript
{ "resource": "" }
q16507
snapY
train
function snapY(y, state) { y += this.graph.panDy; var override = false; if (Math.abs(y - middle) < ttY) { dy = y - bounds.getCenterY(); ttY = Math.abs(y - middle); override = true; } else if (Math.abs(y - top) < ttY) { dy = y - bounds.y; ttY = Math.abs(y - top); overr...
javascript
{ "resource": "" }
q16508
pushPoint
train
function pushPoint(pt) { if (lastPushed == null || Math.abs(lastPushed.x - pt.x) >= tol || Math.abs(lastPushed.y - pt.y) >= tol) { result.push(pt); lastPushed = pt; } return lastPushed; }
javascript
{ "resource": "" }
q16509
train
function(state, source, target, points, isSource) { var value = mxUtils.getValue(state.style, (isSource) ? mxConstants.STYLE_SOURCE_JETTY_SIZE : mxConstants.STYLE_TARGET_JETTY_SIZE, mxUtils.getValue(state.style, mxConstants.STYLE_JETTY_SIZE, mxEdgeStyle.orthBuffer)); if (value == 'auto') { // Compu...
javascript
{ "resource": "" }
q16510
train
function(evt) { var state = null; // Workaround for touch events which started on some DOM node // on top of the container, in which case the cells under the // mouse for the move and up events are not detected. if (mxClient.IS_TOUCH) { var x = mxEvent.getClientX(evt); var y = mxEvent.ge...
javascript
{ "resource": "" }
q16511
train
function(sender, evt) { var changes = evt.getProperty('edit').changes; graph.setSelectionCells(graph.getSelectionCellsForChanges(changes)); }
javascript
{ "resource": "" }
q16512
makeDiscordjsError
train
function makeDiscordjsError(Base) { return class DiscordjsError extends Base { constructor(key, ...args) { super(message(key, args)); this[kCode] = key; if (Error.captureStackTrace) Error.captureStackTrace(this, DiscordjsError); } get name() { return `${super.name} [${this[kCode]}...
javascript
{ "resource": "" }
q16513
message
train
function message(key, args) { if (typeof key !== 'string') throw new Error('Error message key must be a string'); const msg = messages.get(key); if (!msg) throw new Error(`An invalid error message key was used: ${key}.`); if (typeof msg === 'function') return msg(...args); if (args === undefined || args.lengt...
javascript
{ "resource": "" }
q16514
register
train
function register(sym, val) { messages.set(sym, typeof val === 'function' ? val : String(val)); }
javascript
{ "resource": "" }
q16515
train
function (fn, repeatTest = 0, args = []) { /** * if a new hook gets executed we can assume that all commands should have finised * with exception of timeouts where `commandIsRunning` will never be reset but here */ // commandIsRunning = false return new Promise((resolve, reject) => { ...
javascript
{ "resource": "" }
q16516
train
function (fn, repeatTest = 0, args = []) { let result, error /** * if a new hook gets executed we can assume that all commands should have finised * with exception of timeouts where `commandIsRunning` will never be reset but here */ // commandIsRunning = false try { result = fn....
javascript
{ "resource": "" }
q16517
runSync
train
function runSync (fn, repeatTest = 0, args = []) { return (resolve, reject) => Fiber(() => executeSync.call(this, fn, repeatTest, args).then(() => resolve(), reject)).run() }
javascript
{ "resource": "" }
q16518
train
function (testInterfaceFnNames, before, after, fnName, scope = global) { const origFn = scope[fnName] scope[fnName] = wrapTestFunction(fnName, origFn, testInterfaceFnNames, before, after) /** * support it.skip for the Mocha framework */ if (typeof origFn.skip === 'function') { scope[f...
javascript
{ "resource": "" }
q16519
getStyleComputedProperty
train
function getStyleComputedProperty(element, property) { if (element.nodeType !== 1) { return []; } // NOTE: 1 DOM access here var css = getComputedStyle(element, null); return property ? css[property] : css; }
javascript
{ "resource": "" }
q16520
getClientRect
train
function getClientRect(offsets) { return _extends({}, offsets, { right: offsets.left + offsets.width, bottom: offsets.top + offsets.height }); }
javascript
{ "resource": "" }
q16521
getFixedPositionOffsetParent
train
function getFixedPositionOffsetParent(element) { // This check is needed to avoid errors in case one of the elements isn't defined for any reason if (!element || !element.parentElement || isIE()) { return document.documentElement; } var el = element.parentElement; while (el && getStyleComputedProperty(el,...
javascript
{ "resource": "" }
q16522
find
train
function find(arr, check) { // use native find if supported if (Array.prototype.find) { return arr.find(check); } // use `filter` to obtain the same behavior of `find` return arr.filter(check)[0]; }
javascript
{ "resource": "" }
q16523
findIndex
train
function findIndex(arr, prop, value) { // use native findIndex if supported if (Array.prototype.findIndex) { return arr.findIndex(function (cur) { return cur[prop] === value; }); } // use `find` + `indexOf` if `findIndex` isn't supported var match = find(arr, function (obj) { return obj[pro...
javascript
{ "resource": "" }
q16524
runModifiers
train
function runModifiers(modifiers, data, ends) { var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends)); modifiersToRun.forEach(function (modifier) { if (modifier['function']) { // eslint-disable-line dot-notation console.warn('`modifier.function`...
javascript
{ "resource": "" }
q16525
updateModifiers
train
function updateModifiers() { if (this.state.isDestroyed) { return; } // Deep merge modifiers options let options = this.defaultOptions; this.options.modifiers = {}; const _this = this; Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) { _this.options.m...
javascript
{ "resource": "" }
q16526
setupEventListeners
train
function setupEventListeners(reference, options, state, updateBound) { // Resize event listener on window state.updateBound = updateBound; getWindow(reference).addEventListener('resize', state.updateBound, { passive: true }); // Scroll event listener on scroll parents var scrollElement = getScrollParent(refe...
javascript
{ "resource": "" }
q16527
removeEventListeners
train
function removeEventListeners(reference, state) { // Remove resize event listener on window getWindow(reference).removeEventListener('resize', state.updateBound); // Remove scroll event listener on scroll parents state.scrollParents.forEach(function (target) { target.removeEventListener('scroll', state.upd...
javascript
{ "resource": "" }
q16528
setStyles
train
function setStyles(element, styles) { Object.keys(styles).forEach(function (prop) { var unit = ''; // add unit if the value is numeric and is one of the following if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) { unit = 'px'; } eleme...
javascript
{ "resource": "" }
q16529
setAttributes
train
function setAttributes(element, attributes) { Object.keys(attributes).forEach(function (prop) { var value = attributes[prop]; if (value !== false) { element.setAttribute(prop, attributes[prop]); } else { element.removeAttribute(prop); } }); }
javascript
{ "resource": "" }
q16530
toValue
train
function toValue(str, measurement, popperOffsets, referenceOffsets) { // separate value from unit var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/); var value = +split[1]; var unit = split[2]; // If it's not a number it's an operator, I guess if (!value) { return str; } if (unit.indexOf('%') === ...
javascript
{ "resource": "" }
q16531
Popper
train
function Popper(reference, popper) { var _this = this; var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; classCallCheck(this, Popper); this.scheduleUpdate = function () { return requestAnimation(_this.update); }; // make update() debounced, so that it...
javascript
{ "resource": "" }
q16532
queryIndex
train
function queryIndex(query) { try { if (query.length) { var results = index.search(query); if (results.length === 0) { // Add a relaxed search in the title for the first word in the query // E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*" ...
javascript
{ "resource": "" }
q16533
runE2e
train
function runE2e() { if (argv.setup) { // Run setup. console.log('runE2e: setup boilerplate'); const installPackagesCommand = `example-use-${argv.local ? 'local' : 'npm'}`; const addBoilerplateCommand = 'boilerplate:add'; shelljs.exec(`yarn ${installPackagesCommand}`, { cwd: AIO_PATH }); shellj...
javascript
{ "resource": "" }
q16534
getE2eSpecsFor
train
function getE2eSpecsFor(basePath, specFile, filter) { // Only get spec file at the example root. const e2eSpecGlob = `${filter ? `*${filter}*` : '*'}/${specFile}`; return globby(e2eSpecGlob, { cwd: basePath, nodir: true }) .then(paths => paths .filter(file => !IGNORED_EXAMPLES.some(ignored => file.start...
javascript
{ "resource": "" }
q16535
watch
train
function watch() { gulp.watch(['src/**/*.js', '!src/**/README.md'], ['scripts', 'demos', 'components', reload]); gulp.watch(['src/**/*.{scss,css}'], ['styles', 'styles-grid', 'styletemplates', reload]); gulp.watch(['src/**/*.html'], ['pages', reload]); gulp.watch(['src/**/*.{svg,png,jpg}'], ['images', r...
javascript
{ "resource": "" }
q16536
mdlPublish
train
function mdlPublish(pubScope) { let cacheTtl = null; let src = null; let dest = null; if (pubScope === 'staging') { // Set staging specific vars here. cacheTtl = 0; src = 'dist/*'; dest = bucketStaging; } else if (pubScope === 'prod') { // Set prod specific vars here. cacheTtl = 60; ...
javascript
{ "resource": "" }
q16537
findRegisteredClass_
train
function findRegisteredClass_(name, optReplace) { for (var i = 0; i < registeredComponents_.length; i++) { if (registeredComponents_[i].className === name) { if (typeof optReplace !== 'undefined') { registeredComponents_[i] = optReplace; } return registeredComponents_[i]; ...
javascript
{ "resource": "" }
q16538
createEvent_
train
function createEvent_(eventType, bubbles, cancelable) { if ('CustomEvent' in window && typeof window.CustomEvent === 'function') { return new CustomEvent(eventType, { bubbles: bubbles, cancelable: cancelable }); } else { var ev = document.createEvent('Events'); ev.initEve...
javascript
{ "resource": "" }
q16539
upgradeDomInternal
train
function upgradeDomInternal(optJsClass, optCssClass) { if (typeof optJsClass === 'undefined' && typeof optCssClass === 'undefined') { for (var i = 0; i < registeredComponents_.length; i++) { upgradeDomInternal(registeredComponents_[i].className, registeredComponents_[i].cssClass); ...
javascript
{ "resource": "" }
q16540
upgradeElementsInternal
train
function upgradeElementsInternal(elements) { if (!Array.isArray(elements)) { if (elements instanceof Element) { elements = [elements]; } else { elements = Array.prototype.slice.call(elements); } } for (var i = 0, n = elements.length, element; i < n; i++) { element = e...
javascript
{ "resource": "" }
q16541
registerInternal
train
function registerInternal(config) { // In order to support both Closure-compiled and uncompiled code accessing // this method, we need to allow for both the dot and array syntax for // property access. You'll therefore see the `foo.bar || foo['bar']` // pattern repeated across this method. var widge...
javascript
{ "resource": "" }
q16542
registerUpgradedCallbackInternal
train
function registerUpgradedCallbackInternal(jsClass, callback) { var regClass = findRegisteredClass_(jsClass); if (regClass) { regClass.callbacks.push(callback); } }
javascript
{ "resource": "" }
q16543
upgradeAllRegisteredInternal
train
function upgradeAllRegisteredInternal() { for (var n = 0; n < registeredComponents_.length; n++) { upgradeDomInternal(registeredComponents_[n].className); } }
javascript
{ "resource": "" }
q16544
downgradeNodesInternal
train
function downgradeNodesInternal(nodes) { /** * Auxiliary function to downgrade a single node. * @param {!Node} node the node to be downgraded */ var downgradeNode = function(node) { createdComponents_.filter(function(item) { return item.element_ === node; }).forEach(deconstru...
javascript
{ "resource": "" }
q16545
MaterialComponentsNav
train
function MaterialComponentsNav() { 'use strict'; this.element_ = document.querySelector('.mdl-js-components'); if (this.element_) { this.componentLinks = this.element_.querySelectorAll('.mdl-components__link'); this.activeLink = null; this.activePage = null; this.init(); } }
javascript
{ "resource": "" }
q16546
train
function () { var el; el = document.createElement('a-entity'); el.play = this.wrapPlay(el.play); el.setAttribute('mixin', this.data.mixin); el.object3D.visible = false; el.pause(); this.container.appendChild(el); this.availableEls.push(el); }
javascript
{ "resource": "" }
q16547
train
function () { var el; if (this.availableEls.length === 0) { if (this.data.dynamic === false) { warn('Requested entity from empty pool: ' + this.attrName); return; } else { warn('Requested entity from empty pool. This pool is dynamic and will resize ' + 'automatic...
javascript
{ "resource": "" }
q16548
train
function (el) { var index = this.usedEls.indexOf(el); if (index === -1) { warn('The returned entity was not previously pooled from ' + this.attrName); return; } this.usedEls.splice(index, 1); this.availableEls.push(el); el.object3D.visible = false; el.pause(); return el; }
javascript
{ "resource": "" }
q16549
isComponentMixedIn
train
function isComponentMixedIn (name, mixinEls) { var i; var inMixin = false; for (i = 0; i < mixinEls.length; ++i) { inMixin = mixinEls[i].hasAttribute(name); if (inMixin) { break; } } return inMixin; }
javascript
{ "resource": "" }
q16550
mergeComponentData
train
function mergeComponentData (attrValue, extraData) { // Extra data not defined, just return attrValue. if (!extraData) { return attrValue; } // Merge multi-property data. if (extraData.constructor === Object) { return utils.extend(extraData, utils.styleParser.parse(attrValue || {})); } // Return data,...
javascript
{ "resource": "" }
q16551
train
function (value, silent) { var schema = this.schema; if (this.isSingleProperty) { return parseProperty(value, schema); } return parseProperties(styleParser.parse(value), schema, true, this.name, silent); }
javascript
{ "resource": "" }
q16552
train
function (data) { var schema = this.schema; if (typeof data === 'string') { return data; } if (this.isSingleProperty) { return stringifyProperty(data, schema); } data = stringifyProperties(data, schema); return styleParser.stringify(data); }
javascript
{ "resource": "" }
q16553
train
function (value, clobber) { var newAttrValue; var tempObject; var property; if (value === undefined) { return; } // If null value is the new attribute value, make the attribute value falsy. if (value === null) { if (this.isObjectBased && this.attrValue) { this.objectPool.recycle(...
javascript
{ "resource": "" }
q16554
train
function (value) { var parsedValue; if (typeof value !== 'string') { return value; } if (this.isSingleProperty) { parsedValue = this.schema.parse(value); /** * To avoid bogus double parsings. Cached values will be parsed when building * component data. For instance when parsing a s...
javascript
{ "resource": "" }
q16555
train
function (isDefault) { var attrValue = isDefault ? this.data : this.attrValue; if (attrValue === null || attrValue === undefined) { return; } window.HTMLElement.prototype.setAttribute.call(this.el, this.attrName, this.stringify(attrValue)); }
javascript
{ "resource": "" }
q16556
train
function () { var hasComponentChanged; // Store the previous old data before we calculate the new oldData. if (this.previousOldData instanceof Object) { utils.objectPool.clearObject(this.previousOldData); } if (this.isObjectBased) { copyData(this.previousOldData, this.oldData); } el...
javascript
{ "resource": "" }
q16557
train
function (propertyName) { if (this.isObjectBased) { if (!(propertyName in this.attrValue)) { return; } delete this.attrValue[propertyName]; this.data[propertyName] = this.schema[propertyName].default; } else { this.attrValue = this.schema.default; this.data = this.schema.default; ...
javascript
{ "resource": "" }
q16558
train
function (schemaAddon) { var extendedSchema; // Clone base schema. extendedSchema = utils.extend({}, components[this.name].schema); // Extend base schema with new schema chunk. utils.extend(extendedSchema, schemaAddon); this.schema = processSchema(extendedSchema); this.el.emit('schemachanged...
javascript
{ "resource": "" }
q16559
train
function (newData, clobber, silent) { var componentDefined; var data; var defaultValue; var key; var mixinData; var nextData = this.nextData; var schema = this.schema; var i; var mixinEls = this.el.mixinEls; var previousData; // Whether component has a defined value. For arr...
javascript
{ "resource": "" }
q16560
train
function () { this.objectPool.recycle(this.attrValue); this.objectPool.recycle(this.oldData); this.objectPool.recycle(this.parsingAttrValue); this.attrValue = this.oldData = this.parsingAttrValue = undefined; }
javascript
{ "resource": "" }
q16561
copyData
train
function copyData (dest, sourceData) { var parsedProperty; var key; for (key in sourceData) { if (sourceData[key] === undefined) { continue; } parsedProperty = sourceData[key]; dest[key] = isObjectOrArray(parsedProperty) ? utils.clone(parsedProperty) : parsedProperty; } return dest; }
javascript
{ "resource": "" }
q16562
extendProperties
train
function extendProperties (dest, source, isObjectBased) { var key; if (isObjectBased && source.constructor === Object) { for (key in source) { if (source[key] === undefined) { continue; } if (source[key] && source[key].constructor === Object) { dest[key] = utils.clone(source[key]); } e...
javascript
{ "resource": "" }
q16563
wrapPause
train
function wrapPause (pauseMethod) { return function pause () { var sceneEl = this.el.sceneEl; if (!this.isPlaying) { return; } pauseMethod.call(this); this.isPlaying = false; this.eventsDetach(); // Remove tick behavior. if (!hasBehavior(this)) { return; } sceneEl.removeBehavior(this); ...
javascript
{ "resource": "" }
q16564
wrapPlay
train
function wrapPlay (playMethod) { return function play () { var sceneEl = this.el.sceneEl; var shouldPlay = this.el.isPlaying && !this.isPlaying; if (!this.initialized || !shouldPlay) { return; } playMethod.call(this); this.isPlaying = true; this.eventsAttach(); // Add tick behavior. if...
javascript
{ "resource": "" }
q16565
train
function (data) { var cache = this.cache; var cachedGeometry; var hash; // Skip all caching logic. if (data.skipCache) { return createGeometry(data); } // Try to retrieve from cache first. hash = this.hash(data); cachedGeometry = cache[hash]; incrementCacheCount(this.cacheCount, ha...
javascript
{ "resource": "" }
q16566
train
function (data) { var cache = this.cache; var cacheCount = this.cacheCount; var geometry; var hash; if (data.skipCache) { return; } hash = this.hash(data); if (!cache[hash]) { return; } decrementCacheCount(cacheCount, hash); // Another entity is still using this geometry. No nee...
javascript
{ "resource": "" }
q16567
createGeometry
train
function createGeometry (data) { var geometryType = data.primitive; var GeometryClass = geometries[geometryType] && geometries[geometryType].Geometry; var geometryInstance = new GeometryClass(); if (!GeometryClass) { throw new Error('Unknown geometry `' + geometryType + '`'); } geometryInstance.init(data); ...
javascript
{ "resource": "" }
q16568
incrementCacheCount
train
function incrementCacheCount (cacheCount, hash) { cacheCount[hash] = cacheCount[hash] === undefined ? 1 : cacheCount[hash] + 1; }
javascript
{ "resource": "" }
q16569
toBufferGeometry
train
function toBufferGeometry (geometry, doBuffer) { var bufferGeometry; if (!doBuffer) { return geometry; } bufferGeometry = new THREE.BufferGeometry().fromGeometry(geometry); bufferGeometry.metadata = {type: geometry.type, parameters: geometry.parameters || {}}; geometry.dispose(); // Dispose no longer needed...
javascript
{ "resource": "" }
q16570
handleTextureEvents
train
function handleTextureEvents (el, texture) { if (!texture) { return; } el.emit('materialtextureloaded', {src: texture.image, texture: texture}); // Video events. if (!texture.image || texture.image.tagName !== 'VIDEO') { return; } texture.image.addEventListener('loadeddata', function emitVideoTextureLoaded...
javascript
{ "resource": "" }
q16571
isTablet
train
function isTablet (mockUserAgent) { var userAgent = mockUserAgent || window.navigator.userAgent; return /ipad|Nexus (7|9)|xoom|sch-i800|playbook|tablet|kindle/i.test(userAgent); }
javascript
{ "resource": "" }
q16572
train
function (data) { var self = this; var material = this.material; var envMap = data.envMap; var sphericalEnvMap = data.sphericalEnvMap; // No envMap defined or already loading. if ((!envMap && !sphericalEnvMap) || this.isLoadingEnvMap) { material.envMap = null; material.needsUpdate =...
javascript
{ "resource": "" }
q16573
train
function () { var el = this.el; var data = this.data; var light = this.light; light.castShadow = data.castShadow; // Shadow camera helper. var cameraHelper = el.getObject3D('cameraHelper'); if (data.shadowCameraVisible && !cameraHelper) { el.setObject3D('cameraHelper', new THREE.Came...
javascript
{ "resource": "" }
q16574
train
function (data) { var angle = data.angle; var color = new THREE.Color(data.color); this.rendererSystem.applyColorCorrection(color); color = color.getHex(); var decay = data.decay; var distance = data.distance; var groundColor = new THREE.Color(data.groundColor); this.rendererSystem.apply...
javascript
{ "resource": "" }
q16575
train
function (rawData) { var oldData = this.data; if (!Object.keys(schema).length) { return; } this.buildData(rawData); this.update(oldData); }
javascript
{ "resource": "" }
q16576
train
function () { var data = this.data; var object3D = this.el.object3D; object3D.rotation.set(degToRad(data.x), degToRad(data.y), degToRad(data.z)); object3D.rotation.order = 'YXZ'; }
javascript
{ "resource": "" }
q16577
train
function (oldData) { var data = this.data; if (!this.shader || data.shader !== oldData.shader) { this.updateShader(data.shader); } this.shader.update(this.data); this.updateMaterial(oldData); }
javascript
{ "resource": "" }
q16578
train
function (oldData) { var data = this.data; var material = this.material; var oldDataHasKeys; // Base material properties. material.alphaTest = data.alphaTest; material.depthTest = data.depthTest !== false; material.depthWrite = data.depthWrite !== false; material.opacity = data.opacity;...
javascript
{ "resource": "" }
q16579
parseBlending
train
function parseBlending (blending) { switch (blending) { case 'none': { return THREE.NoBlending; } case 'additive': { return THREE.AdditiveBlending; } case 'subtractive': { return THREE.SubtractiveBlending; } case 'multiply': { return THREE.MultiplyBlending; } ...
javascript
{ "resource": "" }
q16580
train
function () { var camera; var el = this.el; // Create camera. camera = this.camera = new THREE.PerspectiveCamera(); el.setObject3D('camera', camera); }
javascript
{ "resource": "" }
q16581
train
function (oldData) { var data = this.data; var camera = this.camera; // Update properties. camera.aspect = data.aspect || (window.innerWidth / window.innerHeight); camera.far = data.far; camera.fov = data.fov; camera.near = data.near; camera.zoom = data.zoom; camera.updateProjection...
javascript
{ "resource": "" }
q16582
train
function () { var data = this.data; this.updateConfig(); this.animationIsPlaying = false; this.animation = anime(this.config); this.animation.began = true; this.removeEventListeners(); this.addEventListeners(); // Wait for start events for animation. if (!data.autoplay || data.sta...
javascript
{ "resource": "" }
q16583
train
function () { var config = this.config; var data = this.data; var el = this.el; var from; var isBoolean; var isNumber; var to; if (this.waitComponentInitRawProperty(this.updateConfigForDefault)) { return; } if (data.from === '') { // Infer from. from = isRawPr...
javascript
{ "resource": "" }
q16584
train
function () { var propType; // Route config type. propType = getPropertyType(this.el, this.data.property); if (isRawProperty(this.data) && this.data.type === TYPE_COLOR) { this.updateConfigForRawColor(); } else if (propType === 'vec2' || propType === 'vec3' || propType === 'vec4') { thi...
javascript
{ "resource": "" }
q16585
train
function (cb) { var componentName; var data = this.data; var el = this.el; var self = this; if (data.from !== '') { return false; } if (!data.property.startsWith(STRING_COMPONENTS)) { return false; } componentName = splitDot(data.property)[1]; if (el.components[componentName]) { retur...
javascript
{ "resource": "" }
q16586
getPropertyType
train
function getPropertyType (el, property) { var component; var componentName; var split; var propertyName; split = property.split('.'); componentName = split[0]; propertyName = split[1]; component = el.components[componentName] || components[componentName]; // Primitives. if (!component) { return nu...
javascript
{ "resource": "" }
q16587
toRadians
train
function toRadians (obj) { obj.x = THREE.Math.degToRad(obj.x); obj.y = THREE.Math.degToRad(obj.y); obj.z = THREE.Math.degToRad(obj.z); }
javascript
{ "resource": "" }
q16588
train
function () { var material = this.el.components.material; if (!material) { return; } this.model.traverse(function (child) { if (child instanceof THREE.Mesh) { child.material = material.material; } }); }
javascript
{ "resource": "" }
q16589
AndroidWakeLock
train
function AndroidWakeLock() { var video = document.createElement('video'); video.addEventListener('ended', function() { video.play(); }); this.request = function() { if (video.paused) { // Base64 version of videos_src/no-sleep-60s.webm. video.src = Util.base64('video/webm', 'GkXfowEAAAAAAAA...
javascript
{ "resource": "" }
q16590
train
function (previousHand) { var controlConfiguration; var el = this.el; var hand = this.data; var self = this; // Get common configuration to abstract different vendor controls. controlConfiguration = { hand: hand, model: false, orientationOffset: {x: 0, y: 0, z: hand === 'left'...
javascript
{ "resource": "" }
q16591
train
function (button, evt) { var lastGesture; var isPressed = evt === 'down'; var isTouched = evt === 'touchstart'; // Update objects. if (evt.indexOf('touch') === 0) { // Update touch object. if (isTouched === this.touchedButtons[button]) { return; } this.touchedButtons[button] = isT...
javascript
{ "resource": "" }
q16592
train
function () { var gesture; var isGripActive = this.pressedButtons['grip']; var isSurfaceActive = this.pressedButtons['surface'] || this.touchedButtons['surface']; var isTrackpadActive = this.pressedButtons['trackpad'] || this.touchedButtons['trackpad']; var isTriggerActive = this.pressedButtons['tri...
javascript
{ "resource": "" }
q16593
train
function (gesture) { var clip; var i; for (i = 0; i < this.clips.length; i++) { clip = this.clips[i]; if (clip.name !== gesture) { continue; } return clip; } }
javascript
{ "resource": "" }
q16594
train
function (gesture, lastGesture) { if (gesture) { this.playAnimation(gesture || ANIMATIONS.open, lastGesture, false); return; } // If no gesture, then reverse the current gesture back to open pose. this.playAnimation(lastGesture, lastGesture, true); }
javascript
{ "resource": "" }
q16595
train
function (gesture, lastGesture) { var el = this.el; var eventName; if (lastGesture === gesture) { return; } // Emit event for lastGesture not inactive. eventName = getGestureEventName(lastGesture, false); if (eventName) { el.emit(eventName); } // Emit event for current gesture now active....
javascript
{ "resource": "" }
q16596
train
function (gesture, lastGesture, reverse) { var clip; var fromAction; var mesh = this.el.getObject3D('mesh'); var toAction; if (!mesh) { return; } // Stop all current animations. mesh.mixer.stopAllAction(); // Grab clip action. clip = this.getClip(gesture); toAction = mesh.mixe...
javascript
{ "resource": "" }
q16597
getFog
train
function getFog (data) { var fog; if (data.type === 'exponential') { fog = new THREE.FogExp2(data.color, data.density); } else { fog = new THREE.Fog(data.color, data.near, data.far); } fog.name = data.type; return fog; }
javascript
{ "resource": "" }
q16598
train
function () { var clearedIntersectedEls = this.clearedIntersectedEls; var el = this.el; var data = this.data; var i; var intersectedEls = this.intersectedEls; var intersection; var intersections = this.intersections; var newIntersectedEls = this.newIntersectedEls; var newIntersection...
javascript
{ "resource": "" }
q16599
train
function (el) { var i; var intersection; for (i = 0; i < this.intersections.length; i++) { intersection = this.intersections[i]; if (intersection.object.el === el) { return intersection; } } return null; }
javascript
{ "resource": "" }