id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1,600 | aframevr/aframe | src/components/camera.js | 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 | 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... | [
"function",
"(",
"oldData",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"camera",
"=",
"this",
".",
"camera",
";",
"// Update properties.",
"camera",
".",
"aspect",
"=",
"data",
".",
"aspect",
"||",
"(",
"window",
".",
"innerWidth",
... | Update three.js camera. | [
"Update",
"three",
".",
"js",
"camera",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/camera.js#L34-L48 | |
1,601 | aframevr/aframe | src/components/animation.js | 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 | 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... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"this",
".",
"updateConfig",
"(",
")",
";",
"this",
".",
"animationIsPlaying",
"=",
"false",
";",
"this",
".",
"animation",
"=",
"anime",
"(",
"this",
".",
"config",
")",
";",
... | Start animation from scratch. | [
"Start",
"animation",
"from",
"scratch",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L162-L184 | |
1,602 | aframevr/aframe | src/components/animation.js | 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 | 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... | [
"function",
"(",
")",
"{",
"var",
"config",
"=",
"this",
".",
"config",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"from",
";",
"var",
"isBoolean",
";",
"var",
"isNumber",
";",
"var",
"to",... | Stuff property into generic `property` key. | [
"Stuff",
"property",
"into",
"generic",
"property",
"key",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L273-L340 | |
1,603 | aframevr/aframe | src/components/animation.js | 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 | 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... | [
"function",
"(",
")",
"{",
"var",
"propType",
";",
"// Route config type.",
"propType",
"=",
"getPropertyType",
"(",
"this",
".",
"el",
",",
"this",
".",
"data",
".",
"property",
")",
";",
"if",
"(",
"isRawProperty",
"(",
"this",
".",
"data",
")",
"&&",
... | Update the config before each run. | [
"Update",
"the",
"config",
"before",
"each",
"run",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L422-L434 | |
1,604 | aframevr/aframe | src/components/animation.js | 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 | 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... | [
"function",
"(",
"cb",
")",
"{",
"var",
"componentName",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"data",
".",
"from",
"!==",
"''",
")",
"{",
"retur... | Wait for component to initialize. | [
"Wait",
"for",
"component",
"to",
"initialize",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L439-L461 | |
1,605 | aframevr/aframe | src/components/animation.js | getPropertyType | 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 | 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... | [
"function",
"getPropertyType",
"(",
"el",
",",
"property",
")",
"{",
"var",
"component",
";",
"var",
"componentName",
";",
"var",
"split",
";",
"var",
"propertyName",
";",
"split",
"=",
"property",
".",
"split",
"(",
"'.'",
")",
";",
"componentName",
"=",
... | Given property name, check schema to see what type we are animating.
We just care whether the property is a vector. | [
"Given",
"property",
"name",
"check",
"schema",
"to",
"see",
"what",
"type",
"we",
"are",
"animating",
".",
"We",
"just",
"care",
"whether",
"the",
"property",
"is",
"a",
"vector",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L515-L537 |
1,606 | aframevr/aframe | src/components/animation.js | toRadians | 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 | function toRadians (obj) {
obj.x = THREE.Math.degToRad(obj.x);
obj.y = THREE.Math.degToRad(obj.y);
obj.z = THREE.Math.degToRad(obj.z);
} | [
"function",
"toRadians",
"(",
"obj",
")",
"{",
"obj",
".",
"x",
"=",
"THREE",
".",
"Math",
".",
"degToRad",
"(",
"obj",
".",
"x",
")",
";",
"obj",
".",
"y",
"=",
"THREE",
".",
"Math",
".",
"degToRad",
"(",
"obj",
".",
"y",
")",
";",
"obj",
".... | Convert object to radians. | [
"Convert",
"object",
"to",
"radians",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L542-L546 |
1,607 | aframevr/aframe | src/components/obj-model.js | 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 | function () {
var material = this.el.components.material;
if (!material) { return; }
this.model.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material = material.material;
}
});
} | [
"function",
"(",
")",
"{",
"var",
"material",
"=",
"this",
".",
"el",
".",
"components",
".",
"material",
";",
"if",
"(",
"!",
"material",
")",
"{",
"return",
";",
"}",
"this",
".",
"model",
".",
"traverse",
"(",
"function",
"(",
"child",
")",
"{",... | Apply material from material component recursively. | [
"Apply",
"material",
"from",
"material",
"component",
"recursively",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/obj-model.js#L92-L100 | |
1,608 | aframevr/aframe | vendor/wakelock/wakelock.js | AndroidWakeLock | 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 | 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... | [
"function",
"AndroidWakeLock",
"(",
")",
"{",
"var",
"video",
"=",
"document",
".",
"createElement",
"(",
"'video'",
")",
";",
"video",
".",
"addEventListener",
"(",
"'ended'",
",",
"function",
"(",
")",
"{",
"video",
".",
"play",
"(",
")",
";",
"}",
"... | Android and iOS compatible wakelock implementation.
Refactored thanks to dkovalev@. | [
"Android",
"and",
"iOS",
"compatible",
"wakelock",
"implementation",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/vendor/wakelock/wakelock.js#L23-L42 |
1,609 | aframevr/aframe | src/components/hand-controls.js | 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 | 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'... | [
"function",
"(",
"previousHand",
")",
"{",
"var",
"controlConfiguration",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"hand",
"=",
"this",
".",
"data",
";",
"var",
"self",
"=",
"this",
";",
"// Get common configuration to abstract different vendor cont... | Update handler. More like the `init` handler since the only property is the hand, and
that won't be changing much. | [
"Update",
"handler",
".",
"More",
"like",
"the",
"init",
"handler",
"since",
"the",
"only",
"property",
"is",
"the",
"hand",
"and",
"that",
"won",
"t",
"be",
"changing",
"much",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L165-L192 | |
1,610 | aframevr/aframe | src/components/hand-controls.js | 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 | 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... | [
"function",
"(",
"button",
",",
"evt",
")",
"{",
"var",
"lastGesture",
";",
"var",
"isPressed",
"=",
"evt",
"===",
"'down'",
";",
"var",
"isTouched",
"=",
"evt",
"===",
"'touchstart'",
";",
"// Update objects.",
"if",
"(",
"evt",
".",
"indexOf",
"(",
"'t... | Play model animation, based on which button was pressed and which kind of event.
1. Process buttons.
2. Determine gesture (this.determineGesture()).
3. Animation gesture (this.animationGesture()).
4. Emit gesture events (this.emitGestureEvents()).
@param {string} button - Name of the button.
@param {string} evt - Typ... | [
"Play",
"model",
"animation",
"based",
"on",
"which",
"button",
"was",
"pressed",
"and",
"which",
"kind",
"of",
"event",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L209-L236 | |
1,611 | aframevr/aframe | src/components/hand-controls.js | 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 | 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... | [
"function",
"(",
")",
"{",
"var",
"gesture",
";",
"var",
"isGripActive",
"=",
"this",
".",
"pressedButtons",
"[",
"'grip'",
"]",
";",
"var",
"isSurfaceActive",
"=",
"this",
".",
"pressedButtons",
"[",
"'surface'",
"]",
"||",
"this",
".",
"touchedButtons",
... | Determine which pose hand should be in considering active and touched buttons. | [
"Determine",
"which",
"pose",
"hand",
"should",
"be",
"in",
"considering",
"active",
"and",
"touched",
"buttons",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L241-L270 | |
1,612 | aframevr/aframe | src/components/hand-controls.js | 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 | 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;
}
} | [
"function",
"(",
"gesture",
")",
"{",
"var",
"clip",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"clips",
".",
"length",
";",
"i",
"++",
")",
"{",
"clip",
"=",
"this",
".",
"clips",
"[",
"i",
"]",
";",
"if",... | Play corresponding clip to a gesture | [
"Play",
"corresponding",
"clip",
"to",
"a",
"gesture"
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L275-L283 | |
1,613 | aframevr/aframe | src/components/hand-controls.js | 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 | 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);
} | [
"function",
"(",
"gesture",
",",
"lastGesture",
")",
"{",
"if",
"(",
"gesture",
")",
"{",
"this",
".",
"playAnimation",
"(",
"gesture",
"||",
"ANIMATIONS",
".",
"open",
",",
"lastGesture",
",",
"false",
")",
";",
"return",
";",
"}",
"// If no gesture, then... | Play gesture animation.
@param {string} gesture - Which pose to animate to. If absent, then animate to open.
@param {string} lastGesture - Previous gesture, to reverse back to open if needed. | [
"Play",
"gesture",
"animation",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L291-L299 | |
1,614 | aframevr/aframe | src/components/hand-controls.js | 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 | 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.... | [
"function",
"(",
"gesture",
",",
"lastGesture",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"eventName",
";",
"if",
"(",
"lastGesture",
"===",
"gesture",
")",
"{",
"return",
";",
"}",
"// Emit event for lastGesture not inactive.",
"eventName",
... | Emit `hand-controls`-specific events. | [
"Emit",
"hand",
"-",
"controls",
"-",
"specific",
"events",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L304-L317 | |
1,615 | aframevr/aframe | src/components/hand-controls.js | 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 | 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... | [
"function",
"(",
"gesture",
",",
"lastGesture",
",",
"reverse",
")",
"{",
"var",
"clip",
";",
"var",
"fromAction",
";",
"var",
"mesh",
"=",
"this",
".",
"el",
".",
"getObject3D",
"(",
"'mesh'",
")",
";",
"var",
"toAction",
";",
"if",
"(",
"!",
"mesh"... | Play hand animation based on button state.
@param {string} gesture - Name of the animation as specified by the model.
@param {string} lastGesture - Previous pose.
@param {boolean} reverse - Whether animation should play in reverse. | [
"Play",
"hand",
"animation",
"based",
"on",
"button",
"state",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L326-L363 | |
1,616 | aframevr/aframe | src/components/scene/fog.js | getFog | 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 | 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;
} | [
"function",
"getFog",
"(",
"data",
")",
"{",
"var",
"fog",
";",
"if",
"(",
"data",
".",
"type",
"===",
"'exponential'",
")",
"{",
"fog",
"=",
"new",
"THREE",
".",
"FogExp2",
"(",
"data",
".",
"color",
",",
"data",
".",
"density",
")",
";",
"}",
"... | Creates a fog object. Sets fog.name to be able to detect fog type changes.
@param {object} data - Fog data.
@returns {object} fog | [
"Creates",
"a",
"fog",
"object",
".",
"Sets",
"fog",
".",
"name",
"to",
"be",
"able",
"to",
"detect",
"fog",
"type",
"changes",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/fog.js#L62-L71 |
1,617 | aframevr/aframe | src/components/raycaster.js | 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 | 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... | [
"function",
"(",
")",
"{",
"var",
"clearedIntersectedEls",
"=",
"this",
".",
"clearedIntersectedEls",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"i",
";",
"var",
"intersectedEls",
"=",
"this",
".... | Raycast for intersections and emit events for current and cleared inersections. | [
"Raycast",
"for",
"intersections",
"and",
"emit",
"events",
"for",
"current",
"and",
"cleared",
"inersections",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/raycaster.js#L204-L279 | |
1,618 | aframevr/aframe | src/components/raycaster.js | 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 | 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;
} | [
"function",
"(",
"el",
")",
"{",
"var",
"i",
";",
"var",
"intersection",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"intersections",
".",
"length",
";",
"i",
"++",
")",
"{",
"intersection",
"=",
"this",
".",
"intersections",
"[",
... | Return the most recent intersection details for a given entity, if any.
@param {AEntity} el
@return {Object} | [
"Return",
"the",
"most",
"recent",
"intersection",
"details",
"for",
"a",
"given",
"entity",
"if",
"any",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/raycaster.js#L303-L311 | |
1,619 | aframevr/aframe | src/components/raycaster.js | function (length) {
var data = this.data;
var el = this.el;
var endVec3;
// Switch each time vector so line update triggered and to avoid unnecessary vector clone.
endVec3 = this.lineData.end === this.lineEndVec3
? this.otherLineEndVec3
: this.lineEndVec3;
// Treat Infinity as 1000... | javascript | function (length) {
var data = this.data;
var el = this.el;
var endVec3;
// Switch each time vector so line update triggered and to avoid unnecessary vector clone.
endVec3 = this.lineData.end === this.lineEndVec3
? this.otherLineEndVec3
: this.lineEndVec3;
// Treat Infinity as 1000... | [
"function",
"(",
"length",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"endVec3",
";",
"// Switch each time vector so line update triggered and to avoid unnecessary vector clone.",
"endVec3",
"=",
"this",
... | Create or update line to give raycaster visual representation.
Customize the line through through line component.
We draw the line in the raycaster component to customize the line to the
raycaster's origin, direction, and far.
Unlike the raycaster, we create the line as a child of the object. The line will
be affected... | [
"Create",
"or",
"update",
"line",
"to",
"give",
"raycaster",
"visual",
"representation",
".",
"Customize",
"the",
"line",
"through",
"through",
"line",
"component",
".",
"We",
"draw",
"the",
"line",
"in",
"the",
"raycaster",
"component",
"to",
"customize",
"th... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/raycaster.js#L362-L382 | |
1,620 | aframevr/aframe | src/core/schema.js | processPropertyDefinition | function processPropertyDefinition (propDefinition, componentName) {
var defaultVal = propDefinition.default;
var isCustomType;
var propType;
var typeName = propDefinition.type;
// Type inference.
if (!propDefinition.type) {
if (defaultVal !== undefined &&
(typeof defaultVal === 'boolean' || ty... | javascript | function processPropertyDefinition (propDefinition, componentName) {
var defaultVal = propDefinition.default;
var isCustomType;
var propType;
var typeName = propDefinition.type;
// Type inference.
if (!propDefinition.type) {
if (defaultVal !== undefined &&
(typeof defaultVal === 'boolean' || ty... | [
"function",
"processPropertyDefinition",
"(",
"propDefinition",
",",
"componentName",
")",
"{",
"var",
"defaultVal",
"=",
"propDefinition",
".",
"default",
";",
"var",
"isCustomType",
";",
"var",
"propType",
";",
"var",
"typeName",
"=",
"propDefinition",
".",
"typ... | Inject default value, parser, stringifier for single property.
@param {object} propDefinition
@param {string} componentName | [
"Inject",
"default",
"value",
"parser",
"stringifier",
"for",
"single",
"property",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/schema.js#L52-L102 |
1,621 | aframevr/aframe | src/core/schema.js | parseProperty | function parseProperty (value, propDefinition) {
// Use default value if value is falsy.
if (value === undefined || value === null || value === '') {
value = propDefinition.default;
if (Array.isArray(value)) { value = value.slice(); }
}
// Invoke property type parser.
return propDefinition.parse(value... | javascript | function parseProperty (value, propDefinition) {
// Use default value if value is falsy.
if (value === undefined || value === null || value === '') {
value = propDefinition.default;
if (Array.isArray(value)) { value = value.slice(); }
}
// Invoke property type parser.
return propDefinition.parse(value... | [
"function",
"parseProperty",
"(",
"value",
",",
"propDefinition",
")",
"{",
"// Use default value if value is falsy.",
"if",
"(",
"value",
"===",
"undefined",
"||",
"value",
"===",
"null",
"||",
"value",
"===",
"''",
")",
"{",
"value",
"=",
"propDefinition",
"."... | Deserialize a single property. | [
"Deserialize",
"a",
"single",
"property",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/schema.js#L155-L163 |
1,622 | aframevr/aframe | src/core/schema.js | stringifyProperty | function stringifyProperty (value, propDefinition) {
// This function stringifies but it's used in a context where
// there's always second stringification pass. By returning the original
// value when it's not an object we save one unnecessary call
// to JSON.stringify.
if (typeof value !== 'object') { retur... | javascript | function stringifyProperty (value, propDefinition) {
// This function stringifies but it's used in a context where
// there's always second stringification pass. By returning the original
// value when it's not an object we save one unnecessary call
// to JSON.stringify.
if (typeof value !== 'object') { retur... | [
"function",
"stringifyProperty",
"(",
"value",
",",
"propDefinition",
")",
"{",
"// This function stringifies but it's used in a context where",
"// there's always second stringification pass. By returning the original",
"// value when it's not an object we save one unnecessary call",
"// to J... | Serialize a single property. | [
"Serialize",
"a",
"single",
"property",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/schema.js#L192-L201 |
1,623 | aframevr/aframe | src/core/a-assets.js | mediaElementLoaded | function mediaElementLoaded (el) {
if (!el.hasAttribute('autoplay') && el.getAttribute('preload') !== 'auto') {
return;
}
// If media specifies autoplay or preload, wait until media is completely buffered.
return new Promise(function (resolve, reject) {
if (el.readyState === 4) { return resolve(); } /... | javascript | function mediaElementLoaded (el) {
if (!el.hasAttribute('autoplay') && el.getAttribute('preload') !== 'auto') {
return;
}
// If media specifies autoplay or preload, wait until media is completely buffered.
return new Promise(function (resolve, reject) {
if (el.readyState === 4) { return resolve(); } /... | [
"function",
"mediaElementLoaded",
"(",
"el",
")",
"{",
"if",
"(",
"!",
"el",
".",
"hasAttribute",
"(",
"'autoplay'",
")",
"&&",
"el",
".",
"getAttribute",
"(",
"'preload'",
")",
"!==",
"'auto'",
")",
"{",
"return",
";",
"}",
"// If media specifies autoplay o... | Create a Promise that resolves once the media element has finished buffering.
@param {Element} el - HTMLMediaElement.
@returns {Promise} | [
"Create",
"a",
"Promise",
"that",
"resolves",
"once",
"the",
"media",
"element",
"has",
"finished",
"buffering",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-assets.js#L140-L174 |
1,624 | aframevr/aframe | src/core/a-assets.js | fixUpMediaElement | function fixUpMediaElement (mediaEl) {
// Cross-origin.
var newMediaEl = setCrossOrigin(mediaEl);
// Plays inline for mobile.
if (newMediaEl.tagName && newMediaEl.tagName.toLowerCase() === 'video') {
newMediaEl.setAttribute('playsinline', '');
newMediaEl.setAttribute('webkit-playsinline', '');
}
i... | javascript | function fixUpMediaElement (mediaEl) {
// Cross-origin.
var newMediaEl = setCrossOrigin(mediaEl);
// Plays inline for mobile.
if (newMediaEl.tagName && newMediaEl.tagName.toLowerCase() === 'video') {
newMediaEl.setAttribute('playsinline', '');
newMediaEl.setAttribute('webkit-playsinline', '');
}
i... | [
"function",
"fixUpMediaElement",
"(",
"mediaEl",
")",
"{",
"// Cross-origin.",
"var",
"newMediaEl",
"=",
"setCrossOrigin",
"(",
"mediaEl",
")",
";",
"// Plays inline for mobile.",
"if",
"(",
"newMediaEl",
".",
"tagName",
"&&",
"newMediaEl",
".",
"tagName",
".",
"t... | Automatically add attributes to media elements where convenient.
crossorigin, playsinline. | [
"Automatically",
"add",
"attributes",
"to",
"media",
"elements",
"where",
"convenient",
".",
"crossorigin",
"playsinline",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-assets.js#L180-L195 |
1,625 | aframevr/aframe | src/core/a-assets.js | extractDomain | function extractDomain (url) {
// Find and remove protocol (e.g., http, ftp, etc.) to get domain.
var domain = url.indexOf('://') > -1 ? url.split('/')[2] : url.split('/')[0];
// Find and remove port number.
return domain.substring(0, domain.indexOf(':'));
} | javascript | function extractDomain (url) {
// Find and remove protocol (e.g., http, ftp, etc.) to get domain.
var domain = url.indexOf('://') > -1 ? url.split('/')[2] : url.split('/')[0];
// Find and remove port number.
return domain.substring(0, domain.indexOf(':'));
} | [
"function",
"extractDomain",
"(",
"url",
")",
"{",
"// Find and remove protocol (e.g., http, ftp, etc.) to get domain.",
"var",
"domain",
"=",
"url",
".",
"indexOf",
"(",
"'://'",
")",
">",
"-",
"1",
"?",
"url",
".",
"split",
"(",
"'/'",
")",
"[",
"2",
"]",
... | Extract domain out of URL.
@param {string} url
@returns {string} | [
"Extract",
"domain",
"out",
"of",
"URL",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-assets.js#L236-L242 |
1,626 | aframevr/aframe | src/components/cursor.js | function (evt) {
// Raycast again for touch.
if (this.data.rayOrigin === 'mouse' && evt.type === 'touchstart') {
this.onMouseMove(evt);
this.el.components.raycaster.checkIntersections();
evt.preventDefault();
}
this.twoWayEmit(EVENTS.MOUSEDOWN);
this.cursorDownEl = this.intersecte... | javascript | function (evt) {
// Raycast again for touch.
if (this.data.rayOrigin === 'mouse' && evt.type === 'touchstart') {
this.onMouseMove(evt);
this.el.components.raycaster.checkIntersections();
evt.preventDefault();
}
this.twoWayEmit(EVENTS.MOUSEDOWN);
this.cursorDownEl = this.intersecte... | [
"function",
"(",
"evt",
")",
"{",
"// Raycast again for touch.",
"if",
"(",
"this",
".",
"data",
".",
"rayOrigin",
"===",
"'mouse'",
"&&",
"evt",
".",
"type",
"===",
"'touchstart'",
")",
"{",
"this",
".",
"onMouseMove",
"(",
"evt",
")",
";",
"this",
".",... | Trigger mousedown and keep track of the mousedowned entity. | [
"Trigger",
"mousedown",
"and",
"keep",
"track",
"of",
"the",
"mousedowned",
"entity",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/cursor.js#L225-L235 | |
1,627 | aframevr/aframe | src/components/cursor.js | function (evt) {
var currentIntersection;
var cursorEl = this.el;
var index;
var intersectedEl;
var intersection;
// Select closest object, excluding the cursor.
index = evt.detail.els[0] === cursorEl ? 1 : 0;
intersection = evt.detail.intersections[index];
intersectedEl = evt.detai... | javascript | function (evt) {
var currentIntersection;
var cursorEl = this.el;
var index;
var intersectedEl;
var intersection;
// Select closest object, excluding the cursor.
index = evt.detail.els[0] === cursorEl ? 1 : 0;
intersection = evt.detail.intersections[index];
intersectedEl = evt.detai... | [
"function",
"(",
"evt",
")",
"{",
"var",
"currentIntersection",
";",
"var",
"cursorEl",
"=",
"this",
".",
"el",
";",
"var",
"index",
";",
"var",
"intersectedEl",
";",
"var",
"intersection",
";",
"// Select closest object, excluding the cursor.",
"index",
"=",
"e... | Handle intersection. | [
"Handle",
"intersection",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/cursor.js#L267-L295 | |
1,628 | aframevr/aframe | src/core/shader.js | function (data) {
this.attributes = this.initVariables(data, 'attribute');
this.uniforms = this.initVariables(data, 'uniform');
this.material = new (this.raw ? THREE.RawShaderMaterial : THREE.ShaderMaterial)({
// attributes: this.attributes,
uniforms: this.uniforms,
vertexShader: this.vert... | javascript | function (data) {
this.attributes = this.initVariables(data, 'attribute');
this.uniforms = this.initVariables(data, 'uniform');
this.material = new (this.raw ? THREE.RawShaderMaterial : THREE.ShaderMaterial)({
// attributes: this.attributes,
uniforms: this.uniforms,
vertexShader: this.vert... | [
"function",
"(",
"data",
")",
"{",
"this",
".",
"attributes",
"=",
"this",
".",
"initVariables",
"(",
"data",
",",
"'attribute'",
")",
";",
"this",
".",
"uniforms",
"=",
"this",
".",
"initVariables",
"(",
"data",
",",
"'uniform'",
")",
";",
"this",
"."... | Init handler. Similar to attachedCallback.
Called during shader initialization and is only run once. | [
"Init",
"handler",
".",
"Similar",
"to",
"attachedCallback",
".",
"Called",
"during",
"shader",
"initialization",
"and",
"is",
"only",
"run",
"once",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/shader.js#L52-L62 | |
1,629 | aframevr/aframe | src/extras/primitives/primitives.js | extend | function extend (base, extension) {
if (isUndefined(base)) {
return copy(extension);
}
if (isUndefined(extension)) {
return copy(base);
}
if (isPureObject(base) && isPureObject(extension)) {
return utils.extendDeep(bas... | javascript | function extend (base, extension) {
if (isUndefined(base)) {
return copy(extension);
}
if (isUndefined(extension)) {
return copy(base);
}
if (isPureObject(base) && isPureObject(extension)) {
return utils.extendDeep(bas... | [
"function",
"extend",
"(",
"base",
",",
"extension",
")",
"{",
"if",
"(",
"isUndefined",
"(",
"base",
")",
")",
"{",
"return",
"copy",
"(",
"extension",
")",
";",
"}",
"if",
"(",
"isUndefined",
"(",
"extension",
")",
")",
"{",
"return",
"copy",
"(",
... | For the base to be extensible, both objects must be pure JavaScript objects.
The function assumes that base is undefined, or null or a pure object. | [
"For",
"the",
"base",
"to",
"be",
"extensible",
"both",
"objects",
"must",
"be",
"pure",
"JavaScript",
"objects",
".",
"The",
"function",
"assumes",
"that",
"base",
"is",
"undefined",
"or",
"null",
"or",
"a",
"pure",
"object",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/extras/primitives/primitives.js#L108-L119 |
1,630 | aframevr/aframe | src/extras/primitives/primitives.js | addComponentMapping | function addComponentMapping (componentName, mappings) {
var schema = components[componentName].schema;
Object.keys(schema).map(function (prop) {
// Hyphenate where there is camelCase.
var attrName = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
// If there is a mapping collision, prefix with ... | javascript | function addComponentMapping (componentName, mappings) {
var schema = components[componentName].schema;
Object.keys(schema).map(function (prop) {
// Hyphenate where there is camelCase.
var attrName = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
// If there is a mapping collision, prefix with ... | [
"function",
"addComponentMapping",
"(",
"componentName",
",",
"mappings",
")",
"{",
"var",
"schema",
"=",
"components",
"[",
"componentName",
"]",
".",
"schema",
";",
"Object",
".",
"keys",
"(",
"schema",
")",
".",
"map",
"(",
"function",
"(",
"prop",
")",... | Add component mappings using schema. | [
"Add",
"component",
"mappings",
"using",
"schema",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/extras/primitives/primitives.js#L168-L177 |
1,631 | aframevr/aframe | src/extras/primitives/primitives.js | definePrimitive | function definePrimitive (tagName, defaultComponents, mappings) {
// If no initial mappings provided, start from empty map.
mappings = mappings || {};
// From the default components, add mapping automagically.
Object.keys(defaultComponents).map(function buildMappings (componentName) {
addComponentMapping(c... | javascript | function definePrimitive (tagName, defaultComponents, mappings) {
// If no initial mappings provided, start from empty map.
mappings = mappings || {};
// From the default components, add mapping automagically.
Object.keys(defaultComponents).map(function buildMappings (componentName) {
addComponentMapping(c... | [
"function",
"definePrimitive",
"(",
"tagName",
",",
"defaultComponents",
",",
"mappings",
")",
"{",
"// If no initial mappings provided, start from empty map.",
"mappings",
"=",
"mappings",
"||",
"{",
"}",
";",
"// From the default components, add mapping automagically.",
"Obje... | Helper to define a primitive, building mappings using a component schema. | [
"Helper",
"to",
"define",
"a",
"primitive",
"building",
"mappings",
"using",
"a",
"component",
"schema",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/extras/primitives/primitives.js#L182-L196 |
1,632 | aframevr/aframe | src/core/propertyTypes.js | registerPropertyType | function registerPropertyType (type, defaultValue, parse, stringify) {
if ('type' in propertyTypes) {
error('Property type ' + type + ' is already registered.');
return;
}
propertyTypes[type] = {
default: defaultValue,
parse: parse || defaultParse,
stringify: stringify || defaultStringify
}... | javascript | function registerPropertyType (type, defaultValue, parse, stringify) {
if ('type' in propertyTypes) {
error('Property type ' + type + ' is already registered.');
return;
}
propertyTypes[type] = {
default: defaultValue,
parse: parse || defaultParse,
stringify: stringify || defaultStringify
}... | [
"function",
"registerPropertyType",
"(",
"type",
",",
"defaultValue",
",",
"parse",
",",
"stringify",
")",
"{",
"if",
"(",
"'type'",
"in",
"propertyTypes",
")",
"{",
"error",
"(",
"'Property type '",
"+",
"type",
"+",
"' is already registered.'",
")",
";",
"re... | Register a parser for re-use such that when someone uses `type` in the schema,
`schema.process` will set the property `parse` and `stringify`.
@param {string} type - Type name.
@param [defaultValue=null] -
Default value to use if component does not define default value.
@param {function} [parse=defaultParse] - Parse s... | [
"Register",
"a",
"parser",
"for",
"re",
"-",
"use",
"such",
"that",
"when",
"someone",
"uses",
"type",
"in",
"the",
"schema",
"schema",
".",
"process",
"will",
"set",
"the",
"property",
"parse",
"and",
"stringify",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/propertyTypes.js#L40-L51 |
1,633 | aframevr/aframe | src/core/propertyTypes.js | assetParse | function assetParse (value) {
var el;
var parsedUrl;
// If an element was provided (e.g. canvas or video), just return it.
if (typeof value !== 'string') { return value; }
// Wrapped `url()` in case of data URI.
parsedUrl = value.match(urlRegex);
if (parsedUrl) { return parsedUrl[1]; }
// ID.
if (v... | javascript | function assetParse (value) {
var el;
var parsedUrl;
// If an element was provided (e.g. canvas or video), just return it.
if (typeof value !== 'string') { return value; }
// Wrapped `url()` in case of data URI.
parsedUrl = value.match(urlRegex);
if (parsedUrl) { return parsedUrl[1]; }
// ID.
if (v... | [
"function",
"assetParse",
"(",
"value",
")",
"{",
"var",
"el",
";",
"var",
"parsedUrl",
";",
"// If an element was provided (e.g. canvas or video), just return it.",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"{",
"return",
"value",
";",
"}",
"// Wrapped ... | For general assets.
@param {string} value - Can either be `url(<value>)`, an ID selector to an asset, or
just string.
@returns {string} Parsed value from `url(<value>)`, src from `<someasset src>`, or
just string. | [
"For",
"general",
"assets",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/propertyTypes.js#L73-L101 |
1,634 | aframevr/aframe | src/core/propertyTypes.js | isValidDefaultValue | function isValidDefaultValue (type, defaultVal) {
if (type === 'audio' && typeof defaultVal !== 'string') { return false; }
if (type === 'array' && !Array.isArray(defaultVal)) { return false; }
if (type === 'asset' && typeof defaultVal !== 'string') { return false; }
if (type === 'boolean' && typeof defaultVal ... | javascript | function isValidDefaultValue (type, defaultVal) {
if (type === 'audio' && typeof defaultVal !== 'string') { return false; }
if (type === 'array' && !Array.isArray(defaultVal)) { return false; }
if (type === 'asset' && typeof defaultVal !== 'string') { return false; }
if (type === 'boolean' && typeof defaultVal ... | [
"function",
"isValidDefaultValue",
"(",
"type",
",",
"defaultVal",
")",
"{",
"if",
"(",
"type",
"===",
"'audio'",
"&&",
"typeof",
"defaultVal",
"!==",
"'string'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"type",
"===",
"'array'",
"&&",
"!",
"Arr... | Validate the default values in a schema to match their type.
@param {string} type - Property type name.
@param defaultVal - Property type default value.
@returns {boolean} Whether default value is accurate given the type. | [
"Validate",
"the",
"default",
"values",
"in",
"a",
"schema",
"to",
"match",
"their",
"type",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/propertyTypes.js#L173-L194 |
1,635 | aframevr/aframe | src/core/propertyTypes.js | isValidDefaultCoordinate | function isValidDefaultCoordinate (possibleCoordinates, dimensions) {
if (possibleCoordinates === null) { return true; }
if (typeof possibleCoordinates !== 'object') { return false; }
if (Object.keys(possibleCoordinates).length !== dimensions) {
return false;
} else {
var x = possibleCoordinates.x;
... | javascript | function isValidDefaultCoordinate (possibleCoordinates, dimensions) {
if (possibleCoordinates === null) { return true; }
if (typeof possibleCoordinates !== 'object') { return false; }
if (Object.keys(possibleCoordinates).length !== dimensions) {
return false;
} else {
var x = possibleCoordinates.x;
... | [
"function",
"isValidDefaultCoordinate",
"(",
"possibleCoordinates",
",",
"dimensions",
")",
"{",
"if",
"(",
"possibleCoordinates",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"typeof",
"possibleCoordinates",
"!==",
"'object'",
")",
"{",
"retu... | Checks if default coordinates are valid.
@param possibleCoordinates
@param {number} dimensions - 2 for 2D Vector, 3 for 3D vector.
@returns {boolean} Whether coordinates are parsed correctly. | [
"Checks",
"if",
"default",
"coordinates",
"are",
"valid",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/propertyTypes.js#L204-L222 |
1,636 | aframevr/aframe | src/systems/tracked-controls-webvr.js | function () {
var controllers = this.controllers;
var gamepad;
var gamepads;
var i;
var prevCount;
gamepads = navigator.getGamepads && navigator.getGamepads();
if (!gamepads) { return; }
prevCount = controllers.length;
controllers.length = 0;
for (i = 0; i < gamepads.length; ++... | javascript | function () {
var controllers = this.controllers;
var gamepad;
var gamepads;
var i;
var prevCount;
gamepads = navigator.getGamepads && navigator.getGamepads();
if (!gamepads) { return; }
prevCount = controllers.length;
controllers.length = 0;
for (i = 0; i < gamepads.length; ++... | [
"function",
"(",
")",
"{",
"var",
"controllers",
"=",
"this",
".",
"controllers",
";",
"var",
"gamepad",
";",
"var",
"gamepads",
";",
"var",
"i",
";",
"var",
"prevCount",
";",
"gamepads",
"=",
"navigator",
".",
"getGamepads",
"&&",
"navigator",
".",
"get... | Update controller list. | [
"Update",
"controller",
"list",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/tracked-controls-webvr.js#L39-L61 | |
1,637 | aframevr/aframe | src/utils/src-loader.js | validateSrc | function validateSrc (src, isImageCb, isVideoCb) {
checkIsImage(src, function isAnImageUrl (isImage) {
if (isImage) {
isImageCb(src);
return;
}
isVideoCb(src);
});
} | javascript | function validateSrc (src, isImageCb, isVideoCb) {
checkIsImage(src, function isAnImageUrl (isImage) {
if (isImage) {
isImageCb(src);
return;
}
isVideoCb(src);
});
} | [
"function",
"validateSrc",
"(",
"src",
",",
"isImageCb",
",",
"isVideoCb",
")",
"{",
"checkIsImage",
"(",
"src",
",",
"function",
"isAnImageUrl",
"(",
"isImage",
")",
"{",
"if",
"(",
"isImage",
")",
"{",
"isImageCb",
"(",
"src",
")",
";",
"return",
";",
... | Validate a texture, either as a selector or as a URL.
Detects whether `src` is pointing to an image or video and invokes the appropriate
callback.
`src` will be passed into the callback
@params {string|Element} src - URL or media element.
@params {function} isImageCb - callback if texture is an image.
@params {functi... | [
"Validate",
"a",
"texture",
"either",
"as",
"a",
"selector",
"or",
"as",
"a",
"URL",
".",
"Detects",
"whether",
"src",
"is",
"pointing",
"to",
"an",
"image",
"or",
"video",
"and",
"invokes",
"the",
"appropriate",
"callback",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/src-loader.js#L17-L25 |
1,638 | aframevr/aframe | src/utils/src-loader.js | validateCubemapSrc | function validateCubemapSrc (src, cb) {
var aCubemap;
var cubemapSrcRegex = '';
var i;
var urls;
var validatedUrls = [];
for (i = 0; i < 5; i++) {
cubemapSrcRegex += '(url\\((?:[^\\)]+)\\),\\s*)';
}
cubemapSrcRegex += '(url\\((?:[^\\)]+)\\)\\s*)';
urls = src.match(new RegExp(cubemapSrcRegex));
... | javascript | function validateCubemapSrc (src, cb) {
var aCubemap;
var cubemapSrcRegex = '';
var i;
var urls;
var validatedUrls = [];
for (i = 0; i < 5; i++) {
cubemapSrcRegex += '(url\\((?:[^\\)]+)\\),\\s*)';
}
cubemapSrcRegex += '(url\\((?:[^\\)]+)\\)\\s*)';
urls = src.match(new RegExp(cubemapSrcRegex));
... | [
"function",
"validateCubemapSrc",
"(",
"src",
",",
"cb",
")",
"{",
"var",
"aCubemap",
";",
"var",
"cubemapSrcRegex",
"=",
"''",
";",
"var",
"i",
";",
"var",
"urls",
";",
"var",
"validatedUrls",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i... | Validates six images as a cubemap, either as selector or comma-separated
URLs.
@param {string} src - A selector or comma-separated image URLs. Image URLs
must be wrapped by `url()`.
@param {string} src - A selector or comma-separated image URLs. Image URLs
must be wrapped by `url()`. | [
"Validates",
"six",
"images",
"as",
"a",
"cubemap",
"either",
"as",
"selector",
"or",
"comma",
"-",
"separated",
"URLs",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/src-loader.js#L36-L72 |
1,639 | aframevr/aframe | src/utils/src-loader.js | checkIsImage | function checkIsImage (src, onResult) {
var request;
if (src.tagName) {
onResult(src.tagName === 'IMG');
return;
}
request = new XMLHttpRequest();
// Try to send HEAD request to check if image first.
request.open('HEAD', src);
request.addEventListener('load', function (event) {
var contentTy... | javascript | function checkIsImage (src, onResult) {
var request;
if (src.tagName) {
onResult(src.tagName === 'IMG');
return;
}
request = new XMLHttpRequest();
// Try to send HEAD request to check if image first.
request.open('HEAD', src);
request.addEventListener('load', function (event) {
var contentTy... | [
"function",
"checkIsImage",
"(",
"src",
",",
"onResult",
")",
"{",
"var",
"request",
";",
"if",
"(",
"src",
".",
"tagName",
")",
"{",
"onResult",
"(",
"src",
".",
"tagName",
"===",
"'IMG'",
")",
";",
"return",
";",
"}",
"request",
"=",
"new",
"XMLHtt... | Call back whether `src` is an image.
@param {string|Element} src - URL or element that will be tested.
@param {function} onResult - Callback with whether `src` is an image. | [
"Call",
"back",
"whether",
"src",
"is",
"an",
"image",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/src-loader.js#L91-L121 |
1,640 | aframevr/aframe | src/utils/src-loader.js | validateAndGetQuerySelector | function validateAndGetQuerySelector (selector) {
try {
var el = document.querySelector(selector);
if (!el) {
warn('No element was found matching the selector: "%s"', selector);
}
return el;
} catch (e) { // Capture exception if it's not a valid selector.
warn('"%s" is not a valid selecto... | javascript | function validateAndGetQuerySelector (selector) {
try {
var el = document.querySelector(selector);
if (!el) {
warn('No element was found matching the selector: "%s"', selector);
}
return el;
} catch (e) { // Capture exception if it's not a valid selector.
warn('"%s" is not a valid selecto... | [
"function",
"validateAndGetQuerySelector",
"(",
"selector",
")",
"{",
"try",
"{",
"var",
"el",
"=",
"document",
".",
"querySelector",
"(",
"selector",
")",
";",
"if",
"(",
"!",
"el",
")",
"{",
"warn",
"(",
"'No element was found matching the selector: \"%s\"'",
... | Query and validate a query selector,
@param {string} selector - DOM selector.
@return {object|null|undefined} Selected DOM element if exists.
null if query yields no results.
undefined if `selector` is not a valid selector. | [
"Query",
"and",
"validate",
"a",
"query",
"selector"
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/src-loader.js#L140-L151 |
1,641 | aframevr/aframe | src/systems/material.js | function (src, data, cb) {
var self = this;
// Canvas.
if (src.tagName === 'CANVAS') {
this.loadCanvas(src, data, cb);
return;
}
// Video element.
if (src.tagName === 'VIDEO') {
if (!src.src && !src.srcObject && !src.childElementCount) {
warn('Video element was define... | javascript | function (src, data, cb) {
var self = this;
// Canvas.
if (src.tagName === 'CANVAS') {
this.loadCanvas(src, data, cb);
return;
}
// Video element.
if (src.tagName === 'VIDEO') {
if (!src.src && !src.srcObject && !src.childElementCount) {
warn('Video element was define... | [
"function",
"(",
"src",
",",
"data",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Canvas.",
"if",
"(",
"src",
".",
"tagName",
"===",
"'CANVAS'",
")",
"{",
"this",
".",
"loadCanvas",
"(",
"src",
",",
"data",
",",
"cb",
")",
";",
"retu... | Determine whether `src` is a image or video. Then try to load the asset, then call back.
@param {string, or element} src - Texture URL or element.
@param {string} data - Relevant texture data used for caching.
@param {function} cb - Callback to pass texture to. | [
"Determine",
"whether",
"src",
"is",
"a",
"image",
"or",
"video",
".",
"Then",
"try",
"to",
"load",
"the",
"asset",
"then",
"call",
"back",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L49-L70 | |
1,642 | aframevr/aframe | src/systems/material.js | function (data) {
if (data.src.tagName) {
// Since `data.src` can be an element, parse out the string if necessary for the hash.
data = utils.extendDeep({}, data);
data.src = data.src.src;
}
return JSON.stringify(data);
} | javascript | function (data) {
if (data.src.tagName) {
// Since `data.src` can be an element, parse out the string if necessary for the hash.
data = utils.extendDeep({}, data);
data.src = data.src.src;
}
return JSON.stringify(data);
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
".",
"src",
".",
"tagName",
")",
"{",
"// Since `data.src` can be an element, parse out the string if necessary for the hash.",
"data",
"=",
"utils",
".",
"extendDeep",
"(",
"{",
"}",
",",
"data",
")",
";",
"... | Create a hash of the material properties for texture cache key. | [
"Create",
"a",
"hash",
"of",
"the",
"material",
"properties",
"for",
"texture",
"cache",
"key",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L179-L186 | |
1,643 | aframevr/aframe | src/systems/material.js | function (material) {
delete this.materials[material.uuid];
// If any textures on this material are no longer in use, dispose of them.
var textureCounts = this.textureCounts;
Object.keys(material)
.filter(function (propName) {
return material[propName] && material[propName].isTexture;
... | javascript | function (material) {
delete this.materials[material.uuid];
// If any textures on this material are no longer in use, dispose of them.
var textureCounts = this.textureCounts;
Object.keys(material)
.filter(function (propName) {
return material[propName] && material[propName].isTexture;
... | [
"function",
"(",
"material",
")",
"{",
"delete",
"this",
".",
"materials",
"[",
"material",
".",
"uuid",
"]",
";",
"// If any textures on this material are no longer in use, dispose of them.",
"var",
"textureCounts",
"=",
"this",
".",
"textureCounts",
";",
"Object",
"... | Stop tracking material, and dispose of any textures not being used by
another material component.
@param {object} material | [
"Stop",
"tracking",
"material",
"and",
"dispose",
"of",
"any",
"textures",
"not",
"being",
"used",
"by",
"another",
"material",
"component",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L207-L222 | |
1,644 | aframevr/aframe | src/systems/material.js | function (material) {
var materials = this.materials;
Object.keys(materials).forEach(function (uuid) {
materials[uuid].needsUpdate = true;
});
} | javascript | function (material) {
var materials = this.materials;
Object.keys(materials).forEach(function (uuid) {
materials[uuid].needsUpdate = true;
});
} | [
"function",
"(",
"material",
")",
"{",
"var",
"materials",
"=",
"this",
".",
"materials",
";",
"Object",
".",
"keys",
"(",
"materials",
")",
".",
"forEach",
"(",
"function",
"(",
"uuid",
")",
"{",
"materials",
"[",
"uuid",
"]",
".",
"needsUpdate",
"=",... | Trigger update to all registered materials. | [
"Trigger",
"update",
"to",
"all",
"registered",
"materials",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L227-L232 | |
1,645 | aframevr/aframe | src/systems/material.js | loadImageTexture | function loadImageTexture (src, data) {
return new Promise(doLoadImageTexture);
function doLoadImageTexture (resolve, reject) {
var isEl = typeof src !== 'string';
function resolveTexture (texture) {
setTextureProperties(texture, data);
texture.needsUpdate = true;
resolve(texture);
}... | javascript | function loadImageTexture (src, data) {
return new Promise(doLoadImageTexture);
function doLoadImageTexture (resolve, reject) {
var isEl = typeof src !== 'string';
function resolveTexture (texture) {
setTextureProperties(texture, data);
texture.needsUpdate = true;
resolve(texture);
}... | [
"function",
"loadImageTexture",
"(",
"src",
",",
"data",
")",
"{",
"return",
"new",
"Promise",
"(",
"doLoadImageTexture",
")",
";",
"function",
"doLoadImageTexture",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"isEl",
"=",
"typeof",
"src",
"!==",
"'strin... | Load image texture.
@private
@param {string|object} src - An <img> element or url to an image file.
@param {object} data - Data to set texture properties like `repeat`.
@returns {Promise} Resolves once texture is loaded. | [
"Load",
"image",
"texture",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L288-L318 |
1,646 | aframevr/aframe | src/systems/material.js | setTextureProperties | function setTextureProperties (texture, data) {
var offset = data.offset || {x: 0, y: 0};
var repeat = data.repeat || {x: 1, y: 1};
var npot = data.npot || false;
// To support NPOT textures, wrap must be ClampToEdge (not Repeat),
// and filters must not use mipmaps (i.e. Nearest or Linear).
if (npot) {
... | javascript | function setTextureProperties (texture, data) {
var offset = data.offset || {x: 0, y: 0};
var repeat = data.repeat || {x: 1, y: 1};
var npot = data.npot || false;
// To support NPOT textures, wrap must be ClampToEdge (not Repeat),
// and filters must not use mipmaps (i.e. Nearest or Linear).
if (npot) {
... | [
"function",
"setTextureProperties",
"(",
"texture",
",",
"data",
")",
"{",
"var",
"offset",
"=",
"data",
".",
"offset",
"||",
"{",
"x",
":",
"0",
",",
"y",
":",
"0",
"}",
";",
"var",
"repeat",
"=",
"data",
".",
"repeat",
"||",
"{",
"x",
":",
"1",... | Set texture properties such as repeat and offset.
@param {object} data - With keys like `repeat`. | [
"Set",
"texture",
"properties",
"such",
"as",
"repeat",
"and",
"offset",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L325-L349 |
1,647 | aframevr/aframe | src/systems/material.js | createVideoEl | function createVideoEl (src, width, height) {
var videoEl = document.createElement('video');
videoEl.width = width;
videoEl.height = height;
// Support inline videos for iOS webviews.
videoEl.setAttribute('playsinline', '');
videoEl.setAttribute('webkit-playsinline', '');
videoEl.autoplay = true;
videoE... | javascript | function createVideoEl (src, width, height) {
var videoEl = document.createElement('video');
videoEl.width = width;
videoEl.height = height;
// Support inline videos for iOS webviews.
videoEl.setAttribute('playsinline', '');
videoEl.setAttribute('webkit-playsinline', '');
videoEl.autoplay = true;
videoE... | [
"function",
"createVideoEl",
"(",
"src",
",",
"width",
",",
"height",
")",
"{",
"var",
"videoEl",
"=",
"document",
".",
"createElement",
"(",
"'video'",
")",
";",
"videoEl",
".",
"width",
"=",
"width",
";",
"videoEl",
".",
"height",
"=",
"height",
";",
... | Create video element to be used as a texture.
@param {string} src - Url to a video file.
@param {number} width - Width of the video.
@param {number} height - Height of the video.
@returns {Element} Video element. | [
"Create",
"video",
"element",
"to",
"be",
"used",
"as",
"a",
"texture",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L359-L374 |
1,648 | aframevr/aframe | src/systems/material.js | fixVideoAttributes | function fixVideoAttributes (videoEl) {
videoEl.autoplay = videoEl.hasAttribute('autoplay') && videoEl.getAttribute('autoplay') !== 'false';
videoEl.controls = videoEl.hasAttribute('controls') && videoEl.getAttribute('controls') !== 'false';
if (videoEl.getAttribute('loop') === 'false') {
videoEl.removeAttrib... | javascript | function fixVideoAttributes (videoEl) {
videoEl.autoplay = videoEl.hasAttribute('autoplay') && videoEl.getAttribute('autoplay') !== 'false';
videoEl.controls = videoEl.hasAttribute('controls') && videoEl.getAttribute('controls') !== 'false';
if (videoEl.getAttribute('loop') === 'false') {
videoEl.removeAttrib... | [
"function",
"fixVideoAttributes",
"(",
"videoEl",
")",
"{",
"videoEl",
".",
"autoplay",
"=",
"videoEl",
".",
"hasAttribute",
"(",
"'autoplay'",
")",
"&&",
"videoEl",
".",
"getAttribute",
"(",
"'autoplay'",
")",
"!==",
"'false'",
";",
"videoEl",
".",
"controls"... | Fixes a video element's attributes to prevent developers from accidentally passing the
wrong attribute values to commonly misused video attributes.
<video> does not treat `autoplay`, `controls`, `crossorigin`, `loop`, and `preload` as
as booleans. Existence of those attributes will mean truthy.
For example, translate... | [
"Fixes",
"a",
"video",
"element",
"s",
"attributes",
"to",
"prevent",
"developers",
"from",
"accidentally",
"passing",
"the",
"wrong",
"attribute",
"values",
"to",
"commonly",
"misused",
"video",
"attributes",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L389-L403 |
1,649 | aframevr/aframe | src/components/sound.js | function (oldEvt) {
var el = this.el;
if (oldEvt) { el.removeEventListener(oldEvt, this.playSoundBound); }
el.addEventListener(this.data.on, this.playSoundBound);
} | javascript | function (oldEvt) {
var el = this.el;
if (oldEvt) { el.removeEventListener(oldEvt, this.playSoundBound); }
el.addEventListener(this.data.on, this.playSoundBound);
} | [
"function",
"(",
"oldEvt",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"if",
"(",
"oldEvt",
")",
"{",
"el",
".",
"removeEventListener",
"(",
"oldEvt",
",",
"this",
".",
"playSoundBound",
")",
";",
"}",
"el",
".",
"addEventListener",
"(",
"thi... | Update listener attached to the user defined on event. | [
"Update",
"listener",
"attached",
"to",
"the",
"user",
"defined",
"on",
"event",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L123-L127 | |
1,650 | aframevr/aframe | src/components/sound.js | function () {
var el = this.el;
var i;
var sceneEl = el.sceneEl;
var self = this;
var sound;
if (this.pool.children.length > 0) {
this.stopSound();
el.removeObject3D('sound');
}
// Only want one AudioListener. Cache it on the scene.
var listener = this.listener = sceneE... | javascript | function () {
var el = this.el;
var i;
var sceneEl = el.sceneEl;
var self = this;
var sound;
if (this.pool.children.length > 0) {
this.stopSound();
el.removeObject3D('sound');
}
// Only want one AudioListener. Cache it on the scene.
var listener = this.listener = sceneE... | [
"function",
"(",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"i",
";",
"var",
"sceneEl",
"=",
"el",
".",
"sceneEl",
";",
"var",
"self",
"=",
"this",
";",
"var",
"sound",
";",
"if",
"(",
"this",
".",
"pool",
".",
"children",
".",
... | Removes current sound object, creates new sound object, adds to entity.
@returns {object} sound | [
"Removes",
"current",
"sound",
"object",
"creates",
"new",
"sound",
"object",
"adds",
"to",
"entity",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L138-L180 | |
1,651 | aframevr/aframe | src/components/sound.js | function () {
var i;
var sound;
this.isPlaying = false;
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
if (!sound.source || !sound.source.buffer || !sound.isPlaying || sound.isPaused) {
continue;
}
sound.isPaused = true;
sound.paus... | javascript | function () {
var i;
var sound;
this.isPlaying = false;
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
if (!sound.source || !sound.source.buffer || !sound.isPlaying || sound.isPaused) {
continue;
}
sound.isPaused = true;
sound.paus... | [
"function",
"(",
")",
"{",
"var",
"i",
";",
"var",
"sound",
";",
"this",
".",
"isPlaying",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"pool",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"sound",
"=... | Pause all the sounds in the pool. | [
"Pause",
"all",
"the",
"sounds",
"in",
"the",
"pool",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L185-L198 | |
1,652 | aframevr/aframe | src/components/sound.js | function (processSound) {
var found;
var i;
var sound;
if (!this.loaded) {
warn('Sound not loaded yet. It will be played once it finished loading');
this.mustPlay = true;
return;
}
found = false;
this.isPlaying = true;
for (i = 0; i < this.pool.children.length; i++) {... | javascript | function (processSound) {
var found;
var i;
var sound;
if (!this.loaded) {
warn('Sound not loaded yet. It will be played once it finished loading');
this.mustPlay = true;
return;
}
found = false;
this.isPlaying = true;
for (i = 0; i < this.pool.children.length; i++) {... | [
"function",
"(",
"processSound",
")",
"{",
"var",
"found",
";",
"var",
"i",
";",
"var",
"sound",
";",
"if",
"(",
"!",
"this",
".",
"loaded",
")",
"{",
"warn",
"(",
"'Sound not loaded yet. It will be played once it finished loading'",
")",
";",
"this",
".",
"... | Look for an unused sound in the pool and play it if found. | [
"Look",
"for",
"an",
"unused",
"sound",
"in",
"the",
"pool",
"and",
"play",
"it",
"if",
"found",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L203-L234 | |
1,653 | aframevr/aframe | src/components/sound.js | function () {
var i;
var sound;
this.isPlaying = false;
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
if (!sound.source || !sound.source.buffer) { return; }
sound.stop();
}
} | javascript | function () {
var i;
var sound;
this.isPlaying = false;
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
if (!sound.source || !sound.source.buffer) { return; }
sound.stop();
}
} | [
"function",
"(",
")",
"{",
"var",
"i",
";",
"var",
"sound",
";",
"this",
".",
"isPlaying",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"pool",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"sound",
"=... | Stop all the sounds in the pool. | [
"Stop",
"all",
"the",
"sounds",
"in",
"the",
"pool",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L239-L248 | |
1,654 | aframevr/aframe | src/components/vive-controls.js | function (evt) {
var button = this.mapping.buttons[evt.detail.id];
var buttonMeshes = this.buttonMeshes;
var analogValue;
if (!button) { return; }
if (button === 'trigger') {
analogValue = evt.detail.state.value;
// Update trigger rotation depending on button value.
if (buttonMes... | javascript | function (evt) {
var button = this.mapping.buttons[evt.detail.id];
var buttonMeshes = this.buttonMeshes;
var analogValue;
if (!button) { return; }
if (button === 'trigger') {
analogValue = evt.detail.state.value;
// Update trigger rotation depending on button value.
if (buttonMes... | [
"function",
"(",
"evt",
")",
"{",
"var",
"button",
"=",
"this",
".",
"mapping",
".",
"buttons",
"[",
"evt",
".",
"detail",
".",
"id",
"]",
";",
"var",
"buttonMeshes",
"=",
"this",
".",
"buttonMeshes",
";",
"var",
"analogValue",
";",
"if",
"(",
"!",
... | Rotate the trigger button based on how hard the trigger is pressed. | [
"Rotate",
"the",
"trigger",
"button",
"based",
"on",
"how",
"hard",
"the",
"trigger",
"is",
"pressed",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/vive-controls.js#L146-L163 | |
1,655 | aframevr/aframe | src/core/a-register-element.js | wrapANodeMethods | function wrapANodeMethods (obj) {
var newObj = {};
var ANodeMethods = [
'attachedCallback',
'attributeChangedCallback',
'createdCallback',
'detachedCallback'
];
wrapMethods(newObj, ANodeMethods, obj, ANode.prototype);
copyProperties(obj, newObj);
return newObj;
} | javascript | function wrapANodeMethods (obj) {
var newObj = {};
var ANodeMethods = [
'attachedCallback',
'attributeChangedCallback',
'createdCallback',
'detachedCallback'
];
wrapMethods(newObj, ANodeMethods, obj, ANode.prototype);
copyProperties(obj, newObj);
return newObj;
} | [
"function",
"wrapANodeMethods",
"(",
"obj",
")",
"{",
"var",
"newObj",
"=",
"{",
"}",
";",
"var",
"ANodeMethods",
"=",
"[",
"'attachedCallback'",
",",
"'attributeChangedCallback'",
",",
"'createdCallback'",
",",
"'detachedCallback'",
"]",
";",
"wrapMethods",
"(",
... | Wrap some obj methods to call those on `ANode` base prototype.
@param {object} obj - Object that contains the methods that will be wrapped.
@return {object} An object with the same properties as the input parameter but
with some of methods wrapped. | [
"Wrap",
"some",
"obj",
"methods",
"to",
"call",
"those",
"on",
"ANode",
"base",
"prototype",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-register-element.js#L79-L90 |
1,656 | aframevr/aframe | src/core/a-register-element.js | wrapAEntityMethods | function wrapAEntityMethods (obj) {
var newObj = {};
var ANodeMethods = [
'attachedCallback',
'attributeChangedCallback',
'createdCallback',
'detachedCallback'
];
var AEntityMethods = [
'attachedCallback',
'attributeChangedCallback',
'createdCallback',
'detachedCallback'
];
... | javascript | function wrapAEntityMethods (obj) {
var newObj = {};
var ANodeMethods = [
'attachedCallback',
'attributeChangedCallback',
'createdCallback',
'detachedCallback'
];
var AEntityMethods = [
'attachedCallback',
'attributeChangedCallback',
'createdCallback',
'detachedCallback'
];
... | [
"function",
"wrapAEntityMethods",
"(",
"obj",
")",
"{",
"var",
"newObj",
"=",
"{",
"}",
";",
"var",
"ANodeMethods",
"=",
"[",
"'attachedCallback'",
",",
"'attributeChangedCallback'",
",",
"'createdCallback'",
",",
"'detachedCallback'",
"]",
";",
"var",
"AEntityMet... | This wraps some of the obj methods to call those on `AEntity` base prototype.
@param {object} obj - The objects that contains the methods that will be wrapped.
@return {object} - An object with the same properties as the input parameter but
with some of methods wrapped. | [
"This",
"wraps",
"some",
"of",
"the",
"obj",
"methods",
"to",
"call",
"those",
"on",
"AEntity",
"base",
"prototype",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-register-element.js#L99-L119 |
1,657 | aframevr/aframe | src/core/a-register-element.js | wrapMethods | function wrapMethods (targetObj, methodList, derivedObj, baseObj) {
methodList.forEach(function (methodName) {
wrapMethod(targetObj, methodName, derivedObj, baseObj);
});
} | javascript | function wrapMethods (targetObj, methodList, derivedObj, baseObj) {
methodList.forEach(function (methodName) {
wrapMethod(targetObj, methodName, derivedObj, baseObj);
});
} | [
"function",
"wrapMethods",
"(",
"targetObj",
",",
"methodList",
",",
"derivedObj",
",",
"baseObj",
")",
"{",
"methodList",
".",
"forEach",
"(",
"function",
"(",
"methodName",
")",
"{",
"wrapMethod",
"(",
"targetObj",
",",
"methodName",
",",
"derivedObj",
",",
... | Wrap a list a methods to ensure that those in the base prototype are called
before the derived one.
@param {object} targetObj - Object that will contain the wrapped methods.
@param {array} methodList - List of methods from the derivedObj that will be wrapped.
@param {object} derivedObject - Object that inherits from t... | [
"Wrap",
"a",
"list",
"a",
"methods",
"to",
"ensure",
"that",
"those",
"in",
"the",
"base",
"prototype",
"are",
"called",
"before",
"the",
"derived",
"one",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-register-element.js#L130-L134 |
1,658 | aframevr/aframe | src/core/a-register-element.js | wrapMethod | function wrapMethod (obj, methodName, derivedObj, baseObj) {
var derivedMethod = derivedObj[methodName];
var baseMethod = baseObj[methodName];
// Derived prototype does not define method, no need to wrap.
if (!derivedMethod || !baseMethod) { return; }
// Derived prototype doesn't override the one in the bas... | javascript | function wrapMethod (obj, methodName, derivedObj, baseObj) {
var derivedMethod = derivedObj[methodName];
var baseMethod = baseObj[methodName];
// Derived prototype does not define method, no need to wrap.
if (!derivedMethod || !baseMethod) { return; }
// Derived prototype doesn't override the one in the bas... | [
"function",
"wrapMethod",
"(",
"obj",
",",
"methodName",
",",
"derivedObj",
",",
"baseObj",
")",
"{",
"var",
"derivedMethod",
"=",
"derivedObj",
"[",
"methodName",
"]",
";",
"var",
"baseMethod",
"=",
"baseObj",
"[",
"methodName",
"]",
";",
"// Derived prototyp... | Wrap one method to ensure that the one in the base prototype is called before
the one in the derived one.
@param {object} obj - Object that will contain the wrapped method.
@param {string} methodName - The name of the method that will be wrapped.
@param {object} derivedObject - Object that inherits from the baseObj.
@... | [
"Wrap",
"one",
"method",
"to",
"ensure",
"that",
"the",
"one",
"in",
"the",
"base",
"prototype",
"is",
"called",
"before",
"the",
"one",
"in",
"the",
"derived",
"one",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-register-element.js#L146-L164 |
1,659 | aframevr/aframe | src/core/a-register-element.js | copyProperties | function copyProperties (source, destination) {
var props = Object.getOwnPropertyNames(source);
props.forEach(function (prop) {
var desc;
if (!destination[prop]) {
desc = Object.getOwnPropertyDescriptor(source, prop);
destination[prop] = {value: source[prop], writable: desc.writable};
}
})... | javascript | function copyProperties (source, destination) {
var props = Object.getOwnPropertyNames(source);
props.forEach(function (prop) {
var desc;
if (!destination[prop]) {
desc = Object.getOwnPropertyDescriptor(source, prop);
destination[prop] = {value: source[prop], writable: desc.writable};
}
})... | [
"function",
"copyProperties",
"(",
"source",
",",
"destination",
")",
"{",
"var",
"props",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"source",
")",
";",
"props",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"var",
"desc",
";",
"if",
"(",... | It copies the properties from source to destination object if they don't
exist already.
@param {object} source - The object where properties are copied from.
@param {type} destination - The object where properties are copied to. | [
"It",
"copies",
"the",
"properties",
"from",
"source",
"to",
"destination",
"object",
"if",
"they",
"don",
"t",
"exist",
"already",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-register-element.js#L173-L182 |
1,660 | aframevr/aframe | src/systems/camera.js | function () {
var cameraEls;
var i;
var sceneEl = this.sceneEl;
var self = this;
// Camera already defined or the one defined it is an spectator one.
if (sceneEl.camera && !sceneEl.camera.el.getAttribute('camera').spectator) {
sceneEl.emit('cameraready', {cameraEl: sceneEl.camera.el});
... | javascript | function () {
var cameraEls;
var i;
var sceneEl = this.sceneEl;
var self = this;
// Camera already defined or the one defined it is an spectator one.
if (sceneEl.camera && !sceneEl.camera.el.getAttribute('camera').spectator) {
sceneEl.emit('cameraready', {cameraEl: sceneEl.camera.el});
... | [
"function",
"(",
")",
"{",
"var",
"cameraEls",
";",
"var",
"i",
";",
"var",
"sceneEl",
"=",
"this",
".",
"sceneEl",
";",
"var",
"self",
"=",
"this",
";",
"// Camera already defined or the one defined it is an spectator one.",
"if",
"(",
"sceneEl",
".",
"camera",... | Setup initial camera, either searching for camera or
creating a default camera if user has not added one during the initial scene traversal.
We want sceneEl.camera to be ready, set, and initialized before the rest of the scene
loads.
Default camera offset height is at average eye level (~1.6m). | [
"Setup",
"initial",
"camera",
"either",
"searching",
"for",
"camera",
"or",
"creating",
"a",
"default",
"camera",
"if",
"user",
"has",
"not",
"added",
"one",
"during",
"the",
"initial",
"scene",
"traversal",
".",
"We",
"want",
"sceneEl",
".",
"camera",
"to",... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/camera.js#L33-L70 | |
1,661 | aframevr/aframe | src/systems/camera.js | function (newCameraEl) {
var newCamera;
var previousCamera = this.spectatorCameraEl;
var sceneEl = this.sceneEl;
var spectatorCameraEl;
// Same camera.
newCamera = newCameraEl.getObject3D('camera');
if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }
// Disable curren... | javascript | function (newCameraEl) {
var newCamera;
var previousCamera = this.spectatorCameraEl;
var sceneEl = this.sceneEl;
var spectatorCameraEl;
// Same camera.
newCamera = newCameraEl.getObject3D('camera');
if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }
// Disable curren... | [
"function",
"(",
"newCameraEl",
")",
"{",
"var",
"newCamera",
";",
"var",
"previousCamera",
"=",
"this",
".",
"spectatorCameraEl",
";",
"var",
"sceneEl",
"=",
"this",
".",
"sceneEl",
";",
"var",
"spectatorCameraEl",
";",
"// Same camera.",
"newCamera",
"=",
"n... | Set spectator camera to render the scene on a 2D display.
@param {Element} newCameraEl - Entity with camera component. | [
"Set",
"spectator",
"camera",
"to",
"render",
"the",
"scene",
"on",
"a",
"2D",
"display",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/camera.js#L193-L217 | |
1,662 | aframevr/aframe | src/systems/camera.js | removeDefaultCamera | function removeDefaultCamera (sceneEl) {
var defaultCamera;
var camera = sceneEl.camera;
if (!camera) { return; }
// Remove default camera if present.
defaultCamera = sceneEl.querySelector('[' + DEFAULT_CAMERA_ATTR + ']');
if (!defaultCamera) { return; }
sceneEl.removeChild(defaultCamera);
} | javascript | function removeDefaultCamera (sceneEl) {
var defaultCamera;
var camera = sceneEl.camera;
if (!camera) { return; }
// Remove default camera if present.
defaultCamera = sceneEl.querySelector('[' + DEFAULT_CAMERA_ATTR + ']');
if (!defaultCamera) { return; }
sceneEl.removeChild(defaultCamera);
} | [
"function",
"removeDefaultCamera",
"(",
"sceneEl",
")",
"{",
"var",
"defaultCamera",
";",
"var",
"camera",
"=",
"sceneEl",
".",
"camera",
";",
"if",
"(",
"!",
"camera",
")",
"{",
"return",
";",
"}",
"// Remove default camera if present.",
"defaultCamera",
"=",
... | Remove injected default camera from scene, if present.
@param {Element} sceneEl | [
"Remove",
"injected",
"default",
"camera",
"from",
"scene",
"if",
"present",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/camera.js#L262-L271 |
1,663 | aframevr/aframe | src/components/look-controls.js | function () {
this.mouseDown = false;
this.pitchObject = new THREE.Object3D();
this.yawObject = new THREE.Object3D();
this.yawObject.position.y = 10;
this.yawObject.add(this.pitchObject);
} | javascript | function () {
this.mouseDown = false;
this.pitchObject = new THREE.Object3D();
this.yawObject = new THREE.Object3D();
this.yawObject.position.y = 10;
this.yawObject.add(this.pitchObject);
} | [
"function",
"(",
")",
"{",
"this",
".",
"mouseDown",
"=",
"false",
";",
"this",
".",
"pitchObject",
"=",
"new",
"THREE",
".",
"Object3D",
"(",
")",
";",
"this",
".",
"yawObject",
"=",
"new",
"THREE",
".",
"Object3D",
"(",
")",
";",
"this",
".",
"ya... | Set up states and Object3Ds needed to store rotation data. | [
"Set",
"up",
"states",
"and",
"Object3Ds",
"needed",
"to",
"store",
"rotation",
"data",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L110-L116 | |
1,664 | aframevr/aframe | src/components/look-controls.js | function () {
var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl.canvas;
// Wait for canvas to load.
if (!canvasEl) {
sceneEl.addEventListener('render-target-loaded', bind(this.addEventListeners, this));
return;
}
// Mouse events.
canvasEl.addEventListener('mousedown', this.... | javascript | function () {
var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl.canvas;
// Wait for canvas to load.
if (!canvasEl) {
sceneEl.addEventListener('render-target-loaded', bind(this.addEventListeners, this));
return;
}
// Mouse events.
canvasEl.addEventListener('mousedown', this.... | [
"function",
"(",
")",
"{",
"var",
"sceneEl",
"=",
"this",
".",
"el",
".",
"sceneEl",
";",
"var",
"canvasEl",
"=",
"sceneEl",
".",
"canvas",
";",
"// Wait for canvas to load.",
"if",
"(",
"!",
"canvasEl",
")",
"{",
"sceneEl",
".",
"addEventListener",
"(",
... | Add mouse and touch event listeners to canvas. | [
"Add",
"mouse",
"and",
"touch",
"event",
"listeners",
"to",
"canvas",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L121-L151 | |
1,665 | aframevr/aframe | src/components/look-controls.js | function () {
var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl && sceneEl.canvas;
if (!canvasEl) { return; }
// Mouse events.
canvasEl.removeEventListener('mousedown', this.onMouseDown);
window.removeEventListener('mousemove', this.onMouseMove);
window.removeEventListener('mouseup', t... | javascript | function () {
var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl && sceneEl.canvas;
if (!canvasEl) { return; }
// Mouse events.
canvasEl.removeEventListener('mousedown', this.onMouseDown);
window.removeEventListener('mousemove', this.onMouseMove);
window.removeEventListener('mouseup', t... | [
"function",
"(",
")",
"{",
"var",
"sceneEl",
"=",
"this",
".",
"el",
".",
"sceneEl",
";",
"var",
"canvasEl",
"=",
"sceneEl",
"&&",
"sceneEl",
".",
"canvas",
";",
"if",
"(",
"!",
"canvasEl",
")",
"{",
"return",
";",
"}",
"// Mouse events.",
"canvasEl",
... | Remove mouse and touch event listeners from canvas. | [
"Remove",
"mouse",
"and",
"touch",
"event",
"listeners",
"from",
"canvas",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L156-L180 | |
1,666 | aframevr/aframe | src/components/look-controls.js | function (event) {
var direction;
var movementX;
var movementY;
var pitchObject = this.pitchObject;
var previousMouseEvent = this.previousMouseEvent;
var yawObject = this.yawObject;
// Not dragging or not enabled.
if (!this.data.enabled || (!this.mouseDown && !this.pointerLocked)) { ret... | javascript | function (event) {
var direction;
var movementX;
var movementY;
var pitchObject = this.pitchObject;
var previousMouseEvent = this.previousMouseEvent;
var yawObject = this.yawObject;
// Not dragging or not enabled.
if (!this.data.enabled || (!this.mouseDown && !this.pointerLocked)) { ret... | [
"function",
"(",
"event",
")",
"{",
"var",
"direction",
";",
"var",
"movementX",
";",
"var",
"movementY",
";",
"var",
"pitchObject",
"=",
"this",
".",
"pitchObject",
";",
"var",
"previousMouseEvent",
"=",
"this",
".",
"previousMouseEvent",
";",
"var",
"yawOb... | Translate mouse drag into rotation.
Dragging up and down rotates the camera around the X-axis (yaw).
Dragging left and right rotates the camera around the Y-axis (pitch). | [
"Translate",
"mouse",
"drag",
"into",
"rotation",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L227-L253 | |
1,667 | aframevr/aframe | src/components/look-controls.js | function (evt) {
if (!this.data.enabled) { return; }
// Handle only primary button.
if (evt.button !== 0) { return; }
var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl && sceneEl.canvas;
this.mouseDown = true;
this.previousMouseEvent = evt;
this.showGrabbingCursor();
if (this.... | javascript | function (evt) {
if (!this.data.enabled) { return; }
// Handle only primary button.
if (evt.button !== 0) { return; }
var sceneEl = this.el.sceneEl;
var canvasEl = sceneEl && sceneEl.canvas;
this.mouseDown = true;
this.previousMouseEvent = evt;
this.showGrabbingCursor();
if (this.... | [
"function",
"(",
"evt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"data",
".",
"enabled",
")",
"{",
"return",
";",
"}",
"// Handle only primary button.",
"if",
"(",
"evt",
".",
"button",
"!==",
"0",
")",
"{",
"return",
";",
"}",
"var",
"sceneEl",
"=",
... | Register mouse down to detect mouse drag. | [
"Register",
"mouse",
"down",
"to",
"detect",
"mouse",
"drag",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L258-L277 | |
1,668 | aframevr/aframe | src/components/look-controls.js | function (evt) {
if (evt.touches.length !== 1 || !this.data.touchEnabled) { return; }
this.touchStart = {
x: evt.touches[0].pageX,
y: evt.touches[0].pageY
};
this.touchStarted = true;
} | javascript | function (evt) {
if (evt.touches.length !== 1 || !this.data.touchEnabled) { return; }
this.touchStart = {
x: evt.touches[0].pageX,
y: evt.touches[0].pageY
};
this.touchStarted = true;
} | [
"function",
"(",
"evt",
")",
"{",
"if",
"(",
"evt",
".",
"touches",
".",
"length",
"!==",
"1",
"||",
"!",
"this",
".",
"data",
".",
"touchEnabled",
")",
"{",
"return",
";",
"}",
"this",
".",
"touchStart",
"=",
"{",
"x",
":",
"evt",
".",
"touches"... | Register touch down to detect touch drag. | [
"Register",
"touch",
"down",
"to",
"detect",
"touch",
"drag",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L304-L311 | |
1,669 | aframevr/aframe | src/components/look-controls.js | function (evt) {
var direction;
var canvas = this.el.sceneEl.canvas;
var deltaY;
var yawObject = this.yawObject;
if (!this.touchStarted || !this.data.touchEnabled) { return; }
deltaY = 2 * Math.PI * (evt.touches[0].pageX - this.touchStart.x) / canvas.clientWidth;
direction = this.data.rev... | javascript | function (evt) {
var direction;
var canvas = this.el.sceneEl.canvas;
var deltaY;
var yawObject = this.yawObject;
if (!this.touchStarted || !this.data.touchEnabled) { return; }
deltaY = 2 * Math.PI * (evt.touches[0].pageX - this.touchStart.x) / canvas.clientWidth;
direction = this.data.rev... | [
"function",
"(",
"evt",
")",
"{",
"var",
"direction",
";",
"var",
"canvas",
"=",
"this",
".",
"el",
".",
"sceneEl",
".",
"canvas",
";",
"var",
"deltaY",
";",
"var",
"yawObject",
"=",
"this",
".",
"yawObject",
";",
"if",
"(",
"!",
"this",
".",
"touc... | Translate touch move to Y-axis rotation. | [
"Translate",
"touch",
"move",
"to",
"Y",
"-",
"axis",
"rotation",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L316-L333 | |
1,670 | aframevr/aframe | src/components/look-controls.js | function () {
if (!this.el.sceneEl.checkHeadsetConnected()) { return; }
this.saveCameraPose();
this.el.object3D.position.set(0, 0, 0);
this.el.object3D.updateMatrix();
} | javascript | function () {
if (!this.el.sceneEl.checkHeadsetConnected()) { return; }
this.saveCameraPose();
this.el.object3D.position.set(0, 0, 0);
this.el.object3D.updateMatrix();
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"el",
".",
"sceneEl",
".",
"checkHeadsetConnected",
"(",
")",
")",
"{",
"return",
";",
"}",
"this",
".",
"saveCameraPose",
"(",
")",
";",
"this",
".",
"el",
".",
"object3D",
".",
"position",
"... | Save pose. | [
"Save",
"pose",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L345-L350 | |
1,671 | aframevr/aframe | src/components/look-controls.js | function () {
var el = this.el;
this.savedPose.position.copy(el.object3D.position);
this.savedPose.rotation.copy(el.object3D.rotation);
this.hasSavedPose = true;
} | javascript | function () {
var el = this.el;
this.savedPose.position.copy(el.object3D.position);
this.savedPose.rotation.copy(el.object3D.rotation);
this.hasSavedPose = true;
} | [
"function",
"(",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"this",
".",
"savedPose",
".",
"position",
".",
"copy",
"(",
"el",
".",
"object3D",
".",
"position",
")",
";",
"this",
".",
"savedPose",
".",
"rotation",
".",
"copy",
"(",
"el",
... | Save camera pose before entering VR to restore later if exiting. | [
"Save",
"camera",
"pose",
"before",
"entering",
"VR",
"to",
"restore",
"later",
"if",
"exiting",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L409-L415 | |
1,672 | aframevr/aframe | src/components/look-controls.js | function () {
var el = this.el;
var savedPose = this.savedPose;
if (!this.hasSavedPose) { return; }
// Reset camera orientation.
el.object3D.position.copy(savedPose.position);
el.object3D.rotation.copy(savedPose.rotation);
this.hasSavedPose = false;
} | javascript | function () {
var el = this.el;
var savedPose = this.savedPose;
if (!this.hasSavedPose) { return; }
// Reset camera orientation.
el.object3D.position.copy(savedPose.position);
el.object3D.rotation.copy(savedPose.rotation);
this.hasSavedPose = false;
} | [
"function",
"(",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"savedPose",
"=",
"this",
".",
"savedPose",
";",
"if",
"(",
"!",
"this",
".",
"hasSavedPose",
")",
"{",
"return",
";",
"}",
"// Reset camera orientation.",
"el",
".",
"object3D... | Reset camera pose to before entering VR. | [
"Reset",
"camera",
"pose",
"to",
"before",
"entering",
"VR",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L420-L430 | |
1,673 | aframevr/aframe | src/components/scene/vr-mode-ui.js | createEnterVRButton | function createEnterVRButton (onClick) {
var vrButton;
var wrapper;
// Create elements.
wrapper = document.createElement('div');
wrapper.classList.add(ENTER_VR_CLASS);
wrapper.setAttribute(constants.AFRAME_INJECTED, '');
vrButton = document.createElement('button');
vrButton.className = ENTER_VR_BTN_CLA... | javascript | function createEnterVRButton (onClick) {
var vrButton;
var wrapper;
// Create elements.
wrapper = document.createElement('div');
wrapper.classList.add(ENTER_VR_CLASS);
wrapper.setAttribute(constants.AFRAME_INJECTED, '');
vrButton = document.createElement('button');
vrButton.className = ENTER_VR_BTN_CLA... | [
"function",
"createEnterVRButton",
"(",
"onClick",
")",
"{",
"var",
"vrButton",
";",
"var",
"wrapper",
";",
"// Create elements.",
"wrapper",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"wrapper",
".",
"classList",
".",
"add",
"(",
"ENTER_VR... | Create a button that when clicked will enter into stereo-rendering mode for VR.
Structure: <div><button></div>
@param {function} onClick - click event handler
@returns {Element} Wrapper <div>. | [
"Create",
"a",
"button",
"that",
"when",
"clicked",
"will",
"enter",
"into",
"stereo",
"-",
"rendering",
"mode",
"for",
"VR",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/vr-mode-ui.js#L138-L160 |
1,674 | aframevr/aframe | src/components/scene/vr-mode-ui.js | createOrientationModal | function createOrientationModal (onClick) {
var modal = document.createElement('div');
modal.className = ORIENTATION_MODAL_CLASS;
modal.classList.add(HIDDEN_CLASS);
modal.setAttribute(constants.AFRAME_INJECTED, '');
var exit = document.createElement('button');
exit.setAttribute(constants.AFRAME_INJECTED, '... | javascript | function createOrientationModal (onClick) {
var modal = document.createElement('div');
modal.className = ORIENTATION_MODAL_CLASS;
modal.classList.add(HIDDEN_CLASS);
modal.setAttribute(constants.AFRAME_INJECTED, '');
var exit = document.createElement('button');
exit.setAttribute(constants.AFRAME_INJECTED, '... | [
"function",
"createOrientationModal",
"(",
"onClick",
")",
"{",
"var",
"modal",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"modal",
".",
"className",
"=",
"ORIENTATION_MODAL_CLASS",
";",
"modal",
".",
"classList",
".",
"add",
"(",
"HIDDEN_C... | Creates a modal dialog to request the user to switch to landscape orientation.
@param {function} onClick - click event handler
@returns {Element} Wrapper <div>. | [
"Creates",
"a",
"modal",
"dialog",
"to",
"request",
"the",
"user",
"to",
"switch",
"to",
"landscape",
"orientation",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/vr-mode-ui.js#L168-L184 |
1,675 | aframevr/aframe | src/components/text.js | function () {
this.geometry.dispose();
this.geometry = null;
this.el.removeObject3D(this.attrName);
this.material.dispose();
this.material = null;
this.texture.dispose();
this.texture = null;
if (this.shaderObject) {
delete this.shaderObject;
}
} | javascript | function () {
this.geometry.dispose();
this.geometry = null;
this.el.removeObject3D(this.attrName);
this.material.dispose();
this.material = null;
this.texture.dispose();
this.texture = null;
if (this.shaderObject) {
delete this.shaderObject;
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"geometry",
".",
"dispose",
"(",
")",
";",
"this",
".",
"geometry",
"=",
"null",
";",
"this",
".",
"el",
".",
"removeObject3D",
"(",
"this",
".",
"attrName",
")",
";",
"this",
".",
"material",
".",
"dispose",
... | Clean up geometry, material, texture, mesh, objects. | [
"Clean",
"up",
"geometry",
"material",
"texture",
"mesh",
"objects",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L129-L140 | |
1,676 | aframevr/aframe | src/components/text.js | function () {
var data = this.data;
var hasChangedShader;
var material = this.material;
var NewShader;
var shaderData = this.shaderData;
var shaderName;
// Infer shader if using a stock font (or from `-msdf` filename convention).
shaderName = data.shader;
if (MSDF_FONTS.indexOf(data... | javascript | function () {
var data = this.data;
var hasChangedShader;
var material = this.material;
var NewShader;
var shaderData = this.shaderData;
var shaderName;
// Infer shader if using a stock font (or from `-msdf` filename convention).
shaderName = data.shader;
if (MSDF_FONTS.indexOf(data... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"hasChangedShader",
";",
"var",
"material",
"=",
"this",
".",
"material",
";",
"var",
"NewShader",
";",
"var",
"shaderData",
"=",
"this",
".",
"shaderData",
";",
"var",
"sh... | Update the shader of the material. | [
"Update",
"the",
"shader",
"of",
"the",
"material",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L145-L189 | |
1,677 | aframevr/aframe | src/components/text.js | function () {
var data = this.data;
var el = this.el;
var fontSrc;
var geometry = this.geometry;
var self = this;
if (!data.font) { warn('No font specified. Using the default font.'); }
// Make invisible during font swap.
this.mesh.visible = false;
// Look up font URL to use, and ... | javascript | function () {
var data = this.data;
var el = this.el;
var fontSrc;
var geometry = this.geometry;
var self = this;
if (!data.font) { warn('No font specified. Using the default font.'); }
// Make invisible during font swap.
this.mesh.visible = false;
// Look up font URL to use, and ... | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"fontSrc",
";",
"var",
"geometry",
"=",
"this",
".",
"geometry",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"da... | Load font for geometry, load font image for material, and apply. | [
"Load",
"font",
"for",
"geometry",
"load",
"font",
"image",
"for",
"material",
"and",
"apply",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L194-L249 | |
1,678 | aframevr/aframe | src/components/text.js | function () {
var anchor;
var baseline;
var el = this.el;
var data = this.data;
var geometry = this.geometry;
var geometryComponent;
var height;
var layout;
var mesh = this.mesh;
var textRenderWidth;
var textScale;
var width;
var x;
var y;
if (!geometry.layou... | javascript | function () {
var anchor;
var baseline;
var el = this.el;
var data = this.data;
var geometry = this.geometry;
var geometryComponent;
var height;
var layout;
var mesh = this.mesh;
var textRenderWidth;
var textScale;
var width;
var x;
var y;
if (!geometry.layou... | [
"function",
"(",
")",
"{",
"var",
"anchor",
";",
"var",
"baseline",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"geometry",
"=",
"this",
".",
"geometry",
";",
"var",
"geometryComponent",
";",
... | Update layout with anchor, alignment, baseline, and considering any meshes. | [
"Update",
"layout",
"with",
"anchor",
"alignment",
"baseline",
"and",
"considering",
"any",
"meshes",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L266-L335 | |
1,679 | aframevr/aframe | src/components/text.js | computeFontWidthFactor | function computeFontWidthFactor (font) {
var sum = 0;
var digitsum = 0;
var digits = 0;
font.chars.map(function (ch) {
sum += ch.xadvance;
if (ch.id >= 48 && ch.id <= 57) {
digits++;
digitsum += ch.xadvance;
}
});
return digits ? digitsum / digits : sum / font.chars.length;
} | javascript | function computeFontWidthFactor (font) {
var sum = 0;
var digitsum = 0;
var digits = 0;
font.chars.map(function (ch) {
sum += ch.xadvance;
if (ch.id >= 48 && ch.id <= 57) {
digits++;
digitsum += ch.xadvance;
}
});
return digits ? digitsum / digits : sum / font.chars.length;
} | [
"function",
"computeFontWidthFactor",
"(",
"font",
")",
"{",
"var",
"sum",
"=",
"0",
";",
"var",
"digitsum",
"=",
"0",
";",
"var",
"digits",
"=",
"0",
";",
"font",
".",
"chars",
".",
"map",
"(",
"function",
"(",
"ch",
")",
"{",
"sum",
"+=",
"ch",
... | Compute default font width factor to use. | [
"Compute",
"default",
"font",
"width",
"factor",
"to",
"use",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L455-L467 |
1,680 | aframevr/aframe | src/components/text.js | PromiseCache | function PromiseCache () {
var cache = this.cache = {};
this.get = function (key, promiseGenerator) {
if (key in cache) {
return cache[key];
}
cache[key] = promiseGenerator();
return cache[key];
};
} | javascript | function PromiseCache () {
var cache = this.cache = {};
this.get = function (key, promiseGenerator) {
if (key in cache) {
return cache[key];
}
cache[key] = promiseGenerator();
return cache[key];
};
} | [
"function",
"PromiseCache",
"(",
")",
"{",
"var",
"cache",
"=",
"this",
".",
"cache",
"=",
"{",
"}",
";",
"this",
".",
"get",
"=",
"function",
"(",
"key",
",",
"promiseGenerator",
")",
"{",
"if",
"(",
"key",
"in",
"cache",
")",
"{",
"return",
"cach... | Get or create a promise given a key and promise generator.
@todo Move to a utility and use in other parts of A-Frame. | [
"Get",
"or",
"create",
"a",
"promise",
"given",
"a",
"key",
"and",
"promise",
"generator",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L473-L483 |
1,681 | aframevr/aframe | src/utils/tracked-controls.js | findMatchingControllerWebVR | function findMatchingControllerWebVR (controllers, filterIdExact, filterIdPrefix, filterHand,
filterControllerIndex) {
var controller;
var i;
var matchingControllerOccurence = 0;
var targetControllerMatch = filterControllerIndex || 0;
for (i = 0; i < controllers.length; i++) ... | javascript | function findMatchingControllerWebVR (controllers, filterIdExact, filterIdPrefix, filterHand,
filterControllerIndex) {
var controller;
var i;
var matchingControllerOccurence = 0;
var targetControllerMatch = filterControllerIndex || 0;
for (i = 0; i < controllers.length; i++) ... | [
"function",
"findMatchingControllerWebVR",
"(",
"controllers",
",",
"filterIdExact",
",",
"filterIdPrefix",
",",
"filterHand",
",",
"filterControllerIndex",
")",
"{",
"var",
"controller",
";",
"var",
"i",
";",
"var",
"matchingControllerOccurence",
"=",
"0",
";",
"va... | Walk through the given controllers to find any where the device ID equals
filterIdExact, or startsWith filterIdPrefix.
A controller where this considered true is considered a 'match'.
For each matching controller:
If filterHand is set, and the controller:
is handed, we further verify that controller.hand equals filter... | [
"Walk",
"through",
"the",
"given",
"controllers",
"to",
"find",
"any",
"where",
"the",
"device",
"ID",
"equals",
"filterIdExact",
"or",
"startsWith",
"filterIdPrefix",
".",
"A",
"controller",
"where",
"this",
"considered",
"true",
"is",
"considered",
"a",
"match... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/tracked-controls.js#L115-L149 |
1,682 | aframevr/aframe | src/components/tracked-controls-webvr.js | function (controllerPosition) {
// Use controllerPosition and deltaControllerPosition to avoid creating variables.
var controller = this.controller;
var controllerEuler = this.controllerEuler;
var controllerQuaternion = this.controllerQuaternion;
var deltaControllerPosition = this.deltaControllerPos... | javascript | function (controllerPosition) {
// Use controllerPosition and deltaControllerPosition to avoid creating variables.
var controller = this.controller;
var controllerEuler = this.controllerEuler;
var controllerQuaternion = this.controllerQuaternion;
var deltaControllerPosition = this.deltaControllerPos... | [
"function",
"(",
"controllerPosition",
")",
"{",
"// Use controllerPosition and deltaControllerPosition to avoid creating variables.",
"var",
"controller",
"=",
"this",
".",
"controller",
";",
"var",
"controllerEuler",
"=",
"this",
".",
"controllerEuler",
";",
"var",
"contr... | Applies an artificial arm model to simulate elbow to wrist positioning
based on the orientation of the controller.
@param {object} controllerPosition - Existing vector to update with controller position. | [
"Applies",
"an",
"artificial",
"arm",
"model",
"to",
"simulate",
"elbow",
"to",
"wrist",
"positioning",
"based",
"on",
"the",
"orientation",
"of",
"the",
"controller",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/tracked-controls-webvr.js#L116-L164 | |
1,683 | aframevr/aframe | src/components/tracked-controls-webvr.js | function () {
var buttonState;
var controller = this.controller;
var id;
if (!controller) { return; }
// Check every button.
for (id = 0; id < controller.buttons.length; ++id) {
// Initialize button state.
if (!this.buttonStates[id]) {
this.buttonStates[id] = {pressed: fals... | javascript | function () {
var buttonState;
var controller = this.controller;
var id;
if (!controller) { return; }
// Check every button.
for (id = 0; id < controller.buttons.length; ++id) {
// Initialize button state.
if (!this.buttonStates[id]) {
this.buttonStates[id] = {pressed: fals... | [
"function",
"(",
")",
"{",
"var",
"buttonState",
";",
"var",
"controller",
"=",
"this",
".",
"controller",
";",
"var",
"id",
";",
"if",
"(",
"!",
"controller",
")",
"{",
"return",
";",
"}",
"// Check every button.",
"for",
"(",
"id",
"=",
"0",
";",
"... | Handle button changes including axes, presses, touches, values. | [
"Handle",
"button",
"changes",
"including",
"axes",
"presses",
"touches",
"values",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/tracked-controls-webvr.js#L209-L231 | |
1,684 | aframevr/aframe | src/components/tracked-controls-webvr.js | function (id, buttonState) {
var changed;
changed = this.handlePress(id, buttonState) |
this.handleTouch(id, buttonState) |
this.handleValue(id, buttonState);
if (!changed) { return false; }
this.el.emit(EVENTS.BUTTONCHANGED, this.buttonEventDetails[id], false);
return tr... | javascript | function (id, buttonState) {
var changed;
changed = this.handlePress(id, buttonState) |
this.handleTouch(id, buttonState) |
this.handleValue(id, buttonState);
if (!changed) { return false; }
this.el.emit(EVENTS.BUTTONCHANGED, this.buttonEventDetails[id], false);
return tr... | [
"function",
"(",
"id",
",",
"buttonState",
")",
"{",
"var",
"changed",
";",
"changed",
"=",
"this",
".",
"handlePress",
"(",
"id",
",",
"buttonState",
")",
"|",
"this",
".",
"handleTouch",
"(",
"id",
",",
"buttonState",
")",
"|",
"this",
".",
"handleVa... | Handle presses and touches for a single button.
@param {number} id - Index of button in Gamepad button array.
@param {number} buttonState - Value of button state from 0 to 1.
@returns {boolean} Whether button has changed in any way. | [
"Handle",
"presses",
"and",
"touches",
"for",
"a",
"single",
"button",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/tracked-controls-webvr.js#L240-L248 | |
1,685 | aframevr/aframe | src/components/scene/screenshot.js | function (projection) {
var el = this.el;
var size;
var camera;
var cubeCamera;
// Configure camera.
if (projection === 'perspective') {
// Quad is only used in equirectangular mode. Hide it in this case.
this.quad.visible = false;
// Use scene camera.
camera = (this.data... | javascript | function (projection) {
var el = this.el;
var size;
var camera;
var cubeCamera;
// Configure camera.
if (projection === 'perspective') {
// Quad is only used in equirectangular mode. Hide it in this case.
this.quad.visible = false;
// Use scene camera.
camera = (this.data... | [
"function",
"(",
"projection",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"size",
";",
"var",
"camera",
";",
"var",
"cubeCamera",
";",
"// Configure camera.",
"if",
"(",
"projection",
"===",
"'perspective'",
")",
"{",
"// Quad is only used in... | Capture a screenshot of the scene.
@param {string} projection - Screenshot projection (equirectangular or perspective). | [
"Capture",
"a",
"screenshot",
"of",
"the",
"scene",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/screenshot.js#L133-L166 | |
1,686 | aframevr/aframe | src/components/scene/screenshot.js | function (projection) {
var isVREnabled = this.el.renderer.vr.enabled;
var renderer = this.el.renderer;
var params;
// Disable VR.
renderer.vr.enabled = false;
params = this.setCapture(projection);
this.renderCapture(params.camera, params.size, params.projection);
// Trigger file downloa... | javascript | function (projection) {
var isVREnabled = this.el.renderer.vr.enabled;
var renderer = this.el.renderer;
var params;
// Disable VR.
renderer.vr.enabled = false;
params = this.setCapture(projection);
this.renderCapture(params.camera, params.size, params.projection);
// Trigger file downloa... | [
"function",
"(",
"projection",
")",
"{",
"var",
"isVREnabled",
"=",
"this",
".",
"el",
".",
"renderer",
".",
"vr",
".",
"enabled",
";",
"var",
"renderer",
"=",
"this",
".",
"el",
".",
"renderer",
";",
"var",
"params",
";",
"// Disable VR.",
"renderer",
... | Maintained for backwards compatibility. | [
"Maintained",
"for",
"backwards",
"compatibility",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/screenshot.js#L171-L183 | |
1,687 | aframevr/aframe | src/components/scene/screenshot.js | function () {
this.canvas.toBlob(function (blob) {
var fileName = 'screenshot-' + document.title.toLowerCase() + '-' + Date.now() + '.png';
var linkEl = document.createElement('a');
var url = URL.createObjectURL(blob);
linkEl.href = url;
linkEl.setAttribute('download', fileName);
... | javascript | function () {
this.canvas.toBlob(function (blob) {
var fileName = 'screenshot-' + document.title.toLowerCase() + '-' + Date.now() + '.png';
var linkEl = document.createElement('a');
var url = URL.createObjectURL(blob);
linkEl.href = url;
linkEl.setAttribute('download', fileName);
... | [
"function",
"(",
")",
"{",
"this",
".",
"canvas",
".",
"toBlob",
"(",
"function",
"(",
"blob",
")",
"{",
"var",
"fileName",
"=",
"'screenshot-'",
"+",
"document",
".",
"title",
".",
"toLowerCase",
"(",
")",
"+",
"'-'",
"+",
"Date",
".",
"now",
"(",
... | Download capture to file. | [
"Download",
"capture",
"to",
"file",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/screenshot.js#L238-L253 | |
1,688 | aframevr/aframe | src/utils/styleParser.js | styleParse | function styleParse (str, obj) {
var chunks;
var i;
var item;
var pos;
var key;
var val;
obj = obj || {};
chunks = getKeyValueChunks(str);
for (i = 0; i < chunks.length; i++) {
item = chunks[i];
if (!item) { continue; }
// Split with `.indexOf` rather than `.split` because the value may ... | javascript | function styleParse (str, obj) {
var chunks;
var i;
var item;
var pos;
var key;
var val;
obj = obj || {};
chunks = getKeyValueChunks(str);
for (i = 0; i < chunks.length; i++) {
item = chunks[i];
if (!item) { continue; }
// Split with `.indexOf` rather than `.split` because the value may ... | [
"function",
"styleParse",
"(",
"str",
",",
"obj",
")",
"{",
"var",
"chunks",
";",
"var",
"i",
";",
"var",
"item",
";",
"var",
"pos",
";",
"var",
"key",
";",
"var",
"val",
";",
"obj",
"=",
"obj",
"||",
"{",
"}",
";",
"chunks",
"=",
"getKeyValueChu... | Convert a style attribute string to an object.
@param {object} str - Attribute string.
@param {object} obj - Object to reuse as a base, else a new one will be allocated. | [
"Convert",
"a",
"style",
"attribute",
"string",
"to",
"an",
"object",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/styleParser.js#L109-L130 |
1,689 | aframevr/aframe | src/utils/styleParser.js | styleStringify | function styleStringify (obj) {
var key;
var keyCount = 0;
var i = 0;
var str = '';
for (key in obj) { keyCount++; }
for (key in obj) {
str += (key + ': ' + obj[key]);
if (i < keyCount - 1) { str += '; '; }
i++;
}
return str;
} | javascript | function styleStringify (obj) {
var key;
var keyCount = 0;
var i = 0;
var str = '';
for (key in obj) { keyCount++; }
for (key in obj) {
str += (key + ': ' + obj[key]);
if (i < keyCount - 1) { str += '; '; }
i++;
}
return str;
} | [
"function",
"styleStringify",
"(",
"obj",
")",
"{",
"var",
"key",
";",
"var",
"keyCount",
"=",
"0",
";",
"var",
"i",
"=",
"0",
";",
"var",
"str",
"=",
"''",
";",
"for",
"(",
"key",
"in",
"obj",
")",
"{",
"keyCount",
"++",
";",
"}",
"for",
"(",
... | Convert an object into an attribute string | [
"Convert",
"an",
"object",
"into",
"an",
"attribute",
"string"
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/styleParser.js#L135-L149 |
1,690 | naptha/tesseract.js | src/common/dump.js | deindent | function deindent(html){
var lines = html.split('\n')
if(lines[0].substring(0, 2) === " "){
for (var i = 0; i < lines.length; i++) {
if (lines[i].substring(0,2) === " ") {
lines[i] = lines[i].slice(2)
}
};
}
return lines.join('\n')
} | javascript | function deindent(html){
var lines = html.split('\n')
if(lines[0].substring(0, 2) === " "){
for (var i = 0; i < lines.length; i++) {
if (lines[i].substring(0,2) === " ") {
lines[i] = lines[i].slice(2)
}
};
}
return lines.join('\n')
} | [
"function",
"deindent",
"(",
"html",
")",
"{",
"var",
"lines",
"=",
"html",
".",
"split",
"(",
"'\\n'",
")",
"if",
"(",
"lines",
"[",
"0",
"]",
".",
"substring",
"(",
"0",
",",
"2",
")",
"===",
"\" \"",
")",
"{",
"for",
"(",
"var",
"i",
"=",
... | the generated HOCR is excessively indented, so we get rid of that indentation | [
"the",
"generated",
"HOCR",
"is",
"excessively",
"indented",
"so",
"we",
"get",
"rid",
"of",
"that",
"indentation"
] | 613a19c7e1b61f26014dd3310fca5391423dd65d | https://github.com/naptha/tesseract.js/blob/613a19c7e1b61f26014dd3310fca5391423dd65d/src/common/dump.js#L154-L164 |
1,691 | nozzle/react-static | packages/react-static/src/browser/index.js | init | function init() {
// In development, we need to open a socket to listen for changes to data
if (process.env.REACT_STATIC_ENV === 'development') {
const io = require('socket.io-client')
const run = async () => {
try {
const {
data: { port },
} = await axios.get('/__react-stati... | javascript | function init() {
// In development, we need to open a socket to listen for changes to data
if (process.env.REACT_STATIC_ENV === 'development') {
const io = require('socket.io-client')
const run = async () => {
try {
const {
data: { port },
} = await axios.get('/__react-stati... | [
"function",
"init",
"(",
")",
"{",
"// In development, we need to open a socket to listen for changes to data",
"if",
"(",
"process",
".",
"env",
".",
"REACT_STATIC_ENV",
"===",
"'development'",
")",
"{",
"const",
"io",
"=",
"require",
"(",
"'socket.io-client'",
")",
... | When in development, init a socket to listen for data changes When the data changes, we invalidate and reload all of the route data | [
"When",
"in",
"development",
"init",
"a",
"socket",
"to",
"listen",
"for",
"data",
"changes",
"When",
"the",
"data",
"changes",
"we",
"invalidate",
"and",
"reload",
"all",
"of",
"the",
"route",
"data"
] | 045a0e119974f46f68c633ff65116f9d74807caf | https://github.com/nozzle/react-static/blob/045a0e119974f46f68c633ff65116f9d74807caf/packages/react-static/src/browser/index.js#L106-L137 |
1,692 | verdaccio/verdaccio | src/lib/logger.js | pad | function pad(str) {
if (str.length < max) {
return str + ' '.repeat(max - str.length);
}
return str;
} | javascript | function pad(str) {
if (str.length < max) {
return str + ' '.repeat(max - str.length);
}
return str;
} | [
"function",
"pad",
"(",
"str",
")",
"{",
"if",
"(",
"str",
".",
"length",
"<",
"max",
")",
"{",
"return",
"str",
"+",
"' '",
".",
"repeat",
"(",
"max",
"-",
"str",
".",
"length",
")",
";",
"}",
"return",
"str",
";",
"}"
] | Apply whitespaces based on the length
@param {*} str the log message
@return {String} | [
"Apply",
"whitespaces",
"based",
"on",
"the",
"length"
] | daa7e897b6d093bf8282ff12df3f450bcd73476c | https://github.com/verdaccio/verdaccio/blob/daa7e897b6d093bf8282ff12df3f450bcd73476c/src/lib/logger.js#L179-L184 |
1,693 | verdaccio/verdaccio | src/lib/logger.js | print | function print(type, msg, obj, colors) {
if (typeof type === 'number') {
type = calculateLevel(type);
}
const finalMessage = fillInMsgTemplate(msg, obj, colors);
const subsystems = [
{
in: green('<--'),
out: yellow('-->'),
fs: black('-=-'),
default: blue('---'),
},
{
... | javascript | function print(type, msg, obj, colors) {
if (typeof type === 'number') {
type = calculateLevel(type);
}
const finalMessage = fillInMsgTemplate(msg, obj, colors);
const subsystems = [
{
in: green('<--'),
out: yellow('-->'),
fs: black('-=-'),
default: blue('---'),
},
{
... | [
"function",
"print",
"(",
"type",
",",
"msg",
",",
"obj",
",",
"colors",
")",
"{",
"if",
"(",
"typeof",
"type",
"===",
"'number'",
")",
"{",
"type",
"=",
"calculateLevel",
"(",
"type",
")",
";",
"}",
"const",
"finalMessage",
"=",
"fillInMsgTemplate",
"... | Apply colors to a string based on level parameters.
@param {*} type
@param {*} msg
@param {*} obj
@param {*} colors
@return {String} | [
"Apply",
"colors",
"to",
"a",
"string",
"based",
"on",
"level",
"parameters",
"."
] | daa7e897b6d093bf8282ff12df3f450bcd73476c | https://github.com/verdaccio/verdaccio/blob/daa7e897b6d093bf8282ff12df3f450bcd73476c/src/lib/logger.js#L227-L254 |
1,694 | Shopify/draggable | src/Plugins/SwapAnimation/SwapAnimation.js | animate | function animate(from, to, {duration, easingFunction, horizontal}) {
for (const element of [from, to]) {
element.style.pointerEvents = 'none';
}
if (horizontal) {
const width = from.offsetWidth;
from.style.transform = `translate3d(${width}px, 0, 0)`;
to.style.transform = `translate3d(-${width}px,... | javascript | function animate(from, to, {duration, easingFunction, horizontal}) {
for (const element of [from, to]) {
element.style.pointerEvents = 'none';
}
if (horizontal) {
const width = from.offsetWidth;
from.style.transform = `translate3d(${width}px, 0, 0)`;
to.style.transform = `translate3d(-${width}px,... | [
"function",
"animate",
"(",
"from",
",",
"to",
",",
"{",
"duration",
",",
"easingFunction",
",",
"horizontal",
"}",
")",
"{",
"for",
"(",
"const",
"element",
"of",
"[",
"from",
",",
"to",
"]",
")",
"{",
"element",
".",
"style",
".",
"pointerEvents",
... | Animates two elements
@param {HTMLElement} from
@param {HTMLElement} to
@param {Object} options
@param {Number} options.duration
@param {String} options.easingFunction
@param {String} options.horizontal
@private | [
"Animates",
"two",
"elements"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Plugins/SwapAnimation/SwapAnimation.js#L109-L131 |
1,695 | Shopify/draggable | src/Plugins/SwapAnimation/SwapAnimation.js | resetElementOnTransitionEnd | function resetElementOnTransitionEnd(event) {
event.target.style.transition = '';
event.target.style.pointerEvents = '';
event.target.removeEventListener('transitionend', resetElementOnTransitionEnd);
} | javascript | function resetElementOnTransitionEnd(event) {
event.target.style.transition = '';
event.target.style.pointerEvents = '';
event.target.removeEventListener('transitionend', resetElementOnTransitionEnd);
} | [
"function",
"resetElementOnTransitionEnd",
"(",
"event",
")",
"{",
"event",
".",
"target",
".",
"style",
".",
"transition",
"=",
"''",
";",
"event",
".",
"target",
".",
"style",
".",
"pointerEvents",
"=",
"''",
";",
"event",
".",
"target",
".",
"removeEven... | Resets animation style properties after animation has completed
@param {Event} event
@private | [
"Resets",
"animation",
"style",
"properties",
"after",
"animation",
"has",
"completed"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Plugins/SwapAnimation/SwapAnimation.js#L138-L142 |
1,696 | Shopify/draggable | src/Droppable/Droppable.js | onDroppableReturnedDefaultAnnouncement | function onDroppableReturnedDefaultAnnouncement({dragEvent, dropzone}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'draggable element';
const dropzoneText = dropzone.textContent.trim() || dropzone.id || 'droppable element';
return `Returned ${sourceText} from ${dropzoneText... | javascript | function onDroppableReturnedDefaultAnnouncement({dragEvent, dropzone}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'draggable element';
const dropzoneText = dropzone.textContent.trim() || dropzone.id || 'droppable element';
return `Returned ${sourceText} from ${dropzoneText... | [
"function",
"onDroppableReturnedDefaultAnnouncement",
"(",
"{",
"dragEvent",
",",
"dropzone",
"}",
")",
"{",
"const",
"sourceText",
"=",
"dragEvent",
".",
"source",
".",
"textContent",
".",
"trim",
"(",
")",
"||",
"dragEvent",
".",
"source",
".",
"id",
"||",
... | Returns an announcement message when the Draggable element has returned to its original dropzone element
@param {DroppableReturnedEvent} droppableEvent
@return {String} | [
"Returns",
"an",
"announcement",
"message",
"when",
"the",
"Draggable",
"element",
"has",
"returned",
"to",
"its",
"original",
"dropzone",
"element"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Droppable/Droppable.js#L31-L36 |
1,697 | Shopify/draggable | src/Sortable/Sortable.js | onSortableSortedDefaultAnnouncement | function onSortableSortedDefaultAnnouncement({dragEvent}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'sortable element';
if (dragEvent.over) {
const overText = dragEvent.over.textContent.trim() || dragEvent.over.id || 'sortable element';
const isFollowing = dragEvent... | javascript | function onSortableSortedDefaultAnnouncement({dragEvent}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'sortable element';
if (dragEvent.over) {
const overText = dragEvent.over.textContent.trim() || dragEvent.over.id || 'sortable element';
const isFollowing = dragEvent... | [
"function",
"onSortableSortedDefaultAnnouncement",
"(",
"{",
"dragEvent",
"}",
")",
"{",
"const",
"sourceText",
"=",
"dragEvent",
".",
"source",
".",
"textContent",
".",
"trim",
"(",
")",
"||",
"dragEvent",
".",
"source",
".",
"id",
"||",
"'sortable element'",
... | Returns announcement message when a Draggable element has been sorted with another Draggable element
or moved into a new container
@param {SortableSortedEvent} sortableEvent
@return {String} | [
"Returns",
"announcement",
"message",
"when",
"a",
"Draggable",
"element",
"has",
"been",
"sorted",
"with",
"another",
"Draggable",
"element",
"or",
"moved",
"into",
"a",
"new",
"container"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Sortable/Sortable.js#L15-L31 |
1,698 | Shopify/draggable | src/Draggable/Plugins/Scrollable/Scrollable.js | hasOverflow | function hasOverflow(element) {
const overflowRegex = /(auto|scroll)/;
const computedStyles = getComputedStyle(element, null);
const overflow =
computedStyles.getPropertyValue('overflow') +
computedStyles.getPropertyValue('overflow-y') +
computedStyles.getPropertyValue('overflow-x');
return overfl... | javascript | function hasOverflow(element) {
const overflowRegex = /(auto|scroll)/;
const computedStyles = getComputedStyle(element, null);
const overflow =
computedStyles.getPropertyValue('overflow') +
computedStyles.getPropertyValue('overflow-y') +
computedStyles.getPropertyValue('overflow-x');
return overfl... | [
"function",
"hasOverflow",
"(",
"element",
")",
"{",
"const",
"overflowRegex",
"=",
"/",
"(auto|scroll)",
"/",
";",
"const",
"computedStyles",
"=",
"getComputedStyle",
"(",
"element",
",",
"null",
")",
";",
"const",
"overflow",
"=",
"computedStyles",
".",
"get... | Returns true if the passed element has overflow
@param {HTMLElement} element
@return {Boolean}
@private | [
"Returns",
"true",
"if",
"the",
"passed",
"element",
"has",
"overflow"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Draggable/Plugins/Scrollable/Scrollable.js#L255-L265 |
1,699 | Shopify/draggable | src/Draggable/Plugins/Scrollable/Scrollable.js | closestScrollableElement | function closestScrollableElement(element) {
if (!element) {
return getDocumentScrollingElement();
}
const position = getComputedStyle(element).getPropertyValue('position');
const excludeStaticParents = position === 'absolute';
const scrollableElement = closest(element, (parent) => {
if (excludeStat... | javascript | function closestScrollableElement(element) {
if (!element) {
return getDocumentScrollingElement();
}
const position = getComputedStyle(element).getPropertyValue('position');
const excludeStaticParents = position === 'absolute';
const scrollableElement = closest(element, (parent) => {
if (excludeStat... | [
"function",
"closestScrollableElement",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
")",
"{",
"return",
"getDocumentScrollingElement",
"(",
")",
";",
"}",
"const",
"position",
"=",
"getComputedStyle",
"(",
"element",
")",
".",
"getPropertyValue",
"(",
... | Finds closest scrollable element
@param {HTMLElement} element
@return {HTMLElement}
@private | [
"Finds",
"closest",
"scrollable",
"element"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Draggable/Plugins/Scrollable/Scrollable.js#L284-L304 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.