code stringlengths 28 313k | docstring stringlengths 25 85.3k | func_name stringlengths 1 74 | language stringclasses 1
value | repo stringlengths 5 60 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function Cylinder( radiusTop, radiusBottom, height , numSegments ) {
var N = numSegments,
verts = [],
axes = [],
faces = [],
bottomface = [],
topface = [],
cos = Math.cos,
sin = Math.sin;
// First bottom point
verts.push(new Vec3(radiusBottom*cos(0),
... | @class Cylinder
@constructor
@extends ConvexPolyhedron
@author schteppe / https://github.com/schteppe
@param {Number} radiusTop
@param {Number} radiusBottom
@param {Number} height
@param {Number} numSegments The number of segments to build the cylinder out of | Cylinder | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Heightfield(data, options){
options = Utils.defaults(options, {
maxValue : null,
minValue : null,
elementSize : 1
});
/**
* An array of numbers, or height values, that are spread out along the x axis.
* @property {array} data
*/
this.data = data;
/**... | Heightfield shape class. Height data is given as an array. These data points are spread out evenly with a given distance.
@class Heightfield
@extends Shape
@constructor
@param {Array} data An array of Y values that will be used to construct the terrain.
@param {object} options
@param {Number} [options.minValue] Minimum... | Heightfield | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Particle(){
Shape.call(this);
this.type = Shape.types.PARTICLE;
} | Particle shape.
@class Particle
@constructor
@author schteppe
@extends Shape | Particle | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Plane(){
Shape.call(this);
this.type = Shape.types.PLANE;
// World oriented normal
this.worldNormal = new Vec3();
this.worldNormalNeedsUpdate = true;
this.boundingSphereRadius = Number.MAX_VALUE;
} | A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a RigidBody and rotate that body. See the demos.
@class Plane
@constructor
@extends Shape
@author schteppe | Plane | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Shape(){
/**
* Identifyer of the Shape.
* @property {number} id
*/
this.id = Shape.idCounter++;
/**
* The type of this shape. Must be set to an int > 0 by subclasses.
* @property type
* @type {Number}
* @see Shape.types
*/
this.type = 0;
/**
*... | Base class for shapes
@class Shape
@constructor
@author schteppe
@todo Should have a mechanism for caching bounding sphere radius instead of calculating it each time | Shape | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Sphere(radius){
Shape.call(this);
/**
* @property {Number} radius
*/
this.radius = radius!==undefined ? Number(radius) : 1.0;
this.type = Shape.types.SPHERE;
if(this.radius < 0){
throw new Error('The sphere radius cannot be negative.');
}
this.updateBoundingSphe... | Spherical shape
@class Sphere
@constructor
@extends Shape
@param {Number} radius The radius of the sphere, a non-negative number.
@author schteppe / http://github.com/schteppe | Sphere | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Trimesh(vertices, indices) {
Shape.call(this);
this.type = Shape.types.TRIMESH;
/**
* @property vertices
* @type {Array}
*/
this.vertices = new Float32Array(vertices);
/**
* Array of integers, indicating which vertices each triangle consists of. The length of this arra... | @class Trimesh
@constructor
@param {array} vertices
@param {array} indices
@extends Shape
@example
// How to make a mesh with a single triangle
var vertices = [
0, 0, 0, // vertex 0
1, 0, 0, // vertex 1
0, 1, 0 // vertex 2
];
var indices = [
0, 1, 2 // triangle 0
];... | Trimesh | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
add = function(indexA, indexB){
var key = a < b ? a + '_' + b : b + '_' + a;
edges[key] = true;
} | Update the .edges property
@method updateEdges | add | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function GSSolver(){
Solver.call(this);
/**
* The number of solver iterations determines quality of the constraints in the world. The more iterations, the more correct simulation. More iterations need more computations though. If you have a large gravity force in your world, you will need more iterations.... | Constraint equation Gauss-Seidel solver.
@class GSSolver
@constructor
@todo The spook parameters should be specified for each constraint, not globally.
@author schteppe / https://github.com/schteppe
@see https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf
@extends Solver | GSSolver | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Solver(){
/**
* All equations to be solved
* @property {Array} equations
*/
this.equations = [];
} | Constraint equation solver base class.
@class Solver
@constructor
@author schteppe / https://github.com/schteppe | Solver | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function SplitSolver(subsolver){
Solver.call(this);
this.iterations = 10;
this.tolerance = 1e-7;
this.subsolver = subsolver;
this.nodes = [];
this.nodePool = [];
// Create needed nodes, reuse if possible
while(this.nodePool.length < 128){
this.nodePool.push(this.createNode());
... | Splits the equations into islands and solves them independently. Can improve performance.
@class SplitSolver
@constructor
@extends Solver
@param {Solver} subsolver | SplitSolver | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function sortById(a, b){
return b.id - a.id;
} | Solve the subsystems
@method solve
@param {Number} dt
@param {World} world | sortById | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function OctreeNode(options){
options = options || {};
/**
* The root node
* @property {OctreeNode} root
*/
this.root = options.root || null;
/**
* Boundary of this node
* @property {AABB} aabb
*/
this.aabb = options.aabb ? options.aabb.clone() : new AABB();
/**
... | @class OctreeNode
@param {object} [options]
@param {Octree} [options.root]
@param {AABB} [options.aabb] | OctreeNode | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Octree(aabb, options){
options = options || {};
options.root = null;
options.aabb = aabb;
OctreeNode.call(this, options);
/**
* Maximum subdivision depth
* @property {number} maxDepth
*/
this.maxDepth = typeof(options.maxDepth) !== 'undefined' ? options.maxDepth : 8;
} | @class Octree
@param {AABB} aabb The total AABB of the tree
@param {object} [options]
@param {number} [options.maxDepth=8]
@extends OctreeNode | Octree | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Pool(){
/**
* The pooled objects
* @property {Array} objects
*/
this.objects = [];
/**
* Constructor of the objects
* @property {mixed} type
*/
this.type = Object;
} | For pooling objects that can be reused.
@class Pool
@constructor | Pool | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function Narrowphase(world){
/**
* Internal storage of pooled contact points.
* @property {Array} contactPointPool
*/
this.contactPointPool = [];
this.frictionEquationPool = [];
this.result = [];
this.frictionResult = [];
/**
* Pooled vectors.
* @property {Vec3Pool} ... | Helper class for the World. Generates ContactEquations.
@class Narrowphase
@constructor
@todo Sphere-ConvexPolyhedron contacts
@todo Contact reduction
@todo should move methods to prototype | Narrowphase | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function warn(msg){
if(numWarnings > maxWarnings){
return;
}
numWarnings++;
console.warn(msg);
} | Generate all contacts between a list of body pairs
@method getContacts
@param {array} p1 Array of body indices
@param {array} p2 Array of body indices
@param {World} world
@param {array} result Array to store generated contacts
@param {array} oldcontacts Optional. Array of reusable contact objects | warn | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function pointInPolygon(verts, normal, p){
var positiveResult = null;
var N = verts.length;
for(var i=0; i!==N; i++){
var v = verts[i];
// Get edge to the next vertex
var edge = pointInPolygon_edge;
verts[(i+1) % (N)].vsub(v,edge);
// Get cross product between polyg... | @method spherePlane
@param {Shape} si
@param {Shape} sj
@param {Vec3} xi
@param {Vec3} xj
@param {Quaternion} qi
@param {Quaternion} qj
@param {Body} bi
@param {Body} bj | pointInPolygon | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
function World(){
EventTarget.apply(this);
/**
* Currently / last used timestep. Is set to -1 if not available. This value is updated before each internal step, which means that it is "fresh" inside event callbacks.
* @property {Number} dt
*/
this.dt = -1;
/**
* Makes bodies go to ... | The physics world
@class World
@constructor
@extends EventTarget | World | javascript | schteppe/cannon.js | build/cannon.js | https://github.com/schteppe/cannon.js/blob/master/build/cannon.js | MIT |
PointerLockControls = function ( camera, cannonBody ) {
var eyeYPos = 2; // eyes are 2 meters above the ground
var velocityFactor = 0.2;
var jumpVelocity = 20;
var scope = this;
var pitchObject = new THREE.Object3D();
pitchObject.add( camera );
var yawObject = new THREE.Object3D();
ya... | @author mrdoob / http://mrdoob.com/
@author schteppe / https://github.com/schteppe | PointerLockControls | javascript | schteppe/cannon.js | examples/js/PointerLockControls.js | https://github.com/schteppe/cannon.js/blob/master/examples/js/PointerLockControls.js | MIT |
VoxelLandscape = function ( world, nx, ny, nz, sx, sy, sz ) {
this.nx = nx;
this.ny = ny;
this.nz = nz;
this.sx = sx;
this.sy = sy;
this.sz = sz;
this.world = world;
this.map = [];
this.boxified = [];
this.boxes = [];
this.boxShape = new CANNON.Box(new CANNON.Vec3(sx*0.5,sy... | @author schteppe / https://github.com/schteppe | VoxelLandscape | javascript | schteppe/cannon.js | examples/js/VoxelLandscape.js | https://github.com/schteppe/cannon.js/blob/master/examples/js/VoxelLandscape.js | MIT |
function addPoint( vertexId ) {
var vertex = vertices[ vertexId ].clone();
var mag = vertex.length();
vertex.x += mag * randomOffset();
vertex.y += mag * randomOffset();
vertex.z += mag * randomOffset();
var hole = [];
for ( var f = 0; f < faces.length; ) {
... | @author qiao / https://github.com/qiao
@fileoverview This is a convex hull generator using the incremental method.
The complexity is O(n^2) where n is the number of vertices.
O(nlogn) algorithms do exist, but they are much more complicated.
Benchmark:
Platform: CPU: P7350 @2.00GHz Engine: V8
Num Vertices Time(m... | addPoint | javascript | schteppe/cannon.js | libs/ConvexGeometry.js | https://github.com/schteppe/cannon.js/blob/master/libs/ConvexGeometry.js | MIT |
SceneJS_Map = function() {
this.items = [];
this.lastUniqueId = 0;
this.addItem = function() {
var item;
if (arguments.length == 2) {
var id = arguments[0];
item = arguments[1];
if (this.items[id]) { // Won't happen if given ID is string
t... | Generic map of IDs to items - can generate own IDs or accept given IDs.
Given IDs should be strings in order to not clash with internally generated IDs, which are numbers. | SceneJS_Map | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
nodeType = function() { // Create class
supa.apply(this, arguments);
this.attr.type = type;
} | Extension point to create a new node type.
@param {string} type Name of new subtype
@param {string} superType Optional name of super-type - {@link SceneJS_node} by default
@return {class} New node class | nodeType | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_State = function(cfg) {
this.core = cfg.core || {};
this.state = cfg.state || {};
if (cfg.parent) {
cfg.parent.addChild(this);
}
this.children = [];
this.dirty = true;
this._cleanFunc = cfg.cleanFunc;
} | Returns an object containing the attributes that were given when creating the node. Obviously, the map will have
the current values, plus any attributes that were later added through set/add methods on the node | SceneJS_State | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
NodeSelector = function(node) {
this._targetNode = node;
this._methods = {
};
} | Loads node and attaches to parent | NodeSelector | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function createNodes(scene, target, nodes) {
var node;
var targetNode;
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
if (target) {
targetNode = scene.findNode(target);
if (!targetNode) {
continue;
... | Given an attribute name of the form "alpha.beta" and a value, returns this sort of thing:
{
"alpha": {
"beta": value
}
} | createNodes | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_divVec3 = function(u, v, dest) {
if (!dest) {
dest = u;
}
dest[0] = u[0] / v[0];
dest[1] = u[1] / v[1];
dest[2] = u[2] / v[2];
return dest;
} | @param u vec3
@param v vec3
@param dest vec3 - optional destination
@return {vec3} dest if specified, u otherwise
@private | SceneJS_math_divVec3 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_negateVector4 = function(v, dest) {
if (!dest) {
dest = v;
}
dest[0] = -v[0];
dest[1] = -v[1];
dest[2] = -v[2];
dest[3] = -v[3];
return dest;
} | @param v vec4
@param dest vec4 - optional destination
@return {vec4} dest if specified, v otherwise
@private | SceneJS_math_negateVector4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_addVec4 = function(u, v, dest) {
if (!dest) {
dest = u;
}
dest[0] = u[0] + v[0];
dest[1] = u[1] + v[1];
dest[2] = u[2] + v[2];
dest[3] = u[3] + v[3];
return dest;
} | @param u vec4
@param v vec4
@param dest vec4 - optional destination
@return {vec4} dest if specified, u otherwise
@private | SceneJS_math_addVec4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_addVec4s = function(v, s, dest) {
if (!dest) {
dest = v;
}
dest[0] = v[0] + s;
dest[1] = v[1] + s;
dest[2] = v[2] + s;
dest[3] = v[3] + s;
return dest;
} | @param v vec4
@param s scalar
@param dest vec4 - optional destination
@return {vec4} dest if specified, v otherwise
@private | SceneJS_math_addVec4s | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_addVec3s = function(v, s, dest) {
if (!dest) {
dest = v;
}
dest[0] = v[0] + s;
dest[1] = v[1] + s;
dest[2] = v[2] + s;
return dest;
} | @param v vec3
@param s scalar
@param dest vec3 - optional destination
@return {vec3} dest if specified, v otherwise
@private | SceneJS_math_addVec3s | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_subVec3 = function(u, v, dest) {
if (!dest) {
dest = u;
}
dest[0] = u[0] - v[0];
dest[1] = u[1] - v[1];
dest[2] = u[2] - v[2];
return dest;
} | @param u vec3
@param v vec3
@param dest vec3 - optional destination
@return {vec3} dest if specified, v otherwise
@private | SceneJS_math_subVec3 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_subVec2 = function(u, v, dest) {
if (!dest) {
dest = u;
}
dest[0] = u[0] - v[0];
dest[1] = u[1] - v[1];
return dest;
} | @param u vec2
@param v vec2
@param dest vec2 - optional destination
@return {vec2} dest if specified, u otherwise
@private | SceneJS_math_subVec2 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_mulVec2Scalar = function(v, s, dest) {
if (!dest) {
dest = v;
}
dest[0] = v[0] * s;
dest[1] = v[1] * s;
return dest;
} | @param v vec2
@param s scalar
@param dest vec2 - optional destination
@return {vec2} dest if specified, v otherwise
@private | SceneJS_math_mulVec2Scalar | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_divScalarVec4 = function(s, v, dest) {
if (!dest) {
dest = v;
}
dest[0] = s / v[0];
dest[1] = s / v[1];
dest[2] = s / v[2];
dest[3] = s / v[3];
return dest;
} | @param s scalar
@param v vec4
@param dest vec4 - optional destination
@return {vec4} dest if specified, v otherwise
@private | SceneJS_math_divScalarVec4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_rcpVec3 = function(v, dest) {
return SceneJS_math_divScalarVec3(1.0, v, dest);
} | @param v vec3
@param dest vec3 - optional destination
@return {vec3} dest if specified, v otherwise
@private | SceneJS_math_rcpVec3 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_negateMat4 = function(m, dest) {
if (!dest) {
dest = m;
}
dest[0] = -m[0];
dest[1] = -m[1];
dest[2] = -m[2];
dest[3] = -m[3];
dest[4] = -m[4];
dest[5] = -m[5];
dest[6] = -m[6];
dest[7] = -m[7];
dest[8] = -m[8];
dest[9] = -m[9];
dest[10] = -m[10];... | @param m mat4
@param dest mat4 - optional destination
@return {mat4} dest if specified, m otherwise
@private | SceneJS_math_negateMat4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_addMat4 = function(a, b, dest) {
if (!dest) {
dest = a;
}
dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2];
dest[3] = a[3] + b[3];
dest[4] = a[4] + b[4];
dest[5] = a[5] + b[5];
dest[6] = a[6] + b[6];
dest[7] = a[7] + b[7];
dest[8] = a[... | @param a mat4
@param b mat4
@param dest mat4 - optional destination
@return {mat4} dest if specified, a otherwise
@private | SceneJS_math_addMat4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_addMat4Scalar = function(m, s, dest) {
if (!dest) {
dest = m;
}
dest[0] = m[0] + s;
dest[1] = m[1] + s;
dest[2] = m[2] + s;
dest[3] = m[3] + s;
dest[4] = m[4] + s;
dest[5] = m[5] + s;
dest[6] = m[6] + s;
dest[7] = m[7] + s;
dest[8] = m[8] + s;
dest[9... | @param m mat4
@param s scalar
@param dest mat4 - optional destination
@return {mat4} dest if specified, m otherwise
@private | SceneJS_math_addMat4Scalar | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_subScalarMat4 = function(s, m, dest) {
if (!dest) {
dest = m;
}
dest[0] = s - m[0];
dest[1] = s - m[1];
dest[2] = s - m[2];
dest[3] = s - m[3];
dest[4] = s - m[4];
dest[5] = s - m[5];
dest[6] = s - m[6];
dest[7] = s - m[7];
dest[8] = s - m[8];
dest[9... | @param s scalar
@param m mat4
@param dest mat4 - optional destination
@return {mat4} dest if specified, m otherwise
@private | SceneJS_math_subScalarMat4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_transposeMat4 = function(mat, dest) {
// If we are transposing ourselves we can skip a few steps but have to cache some values
var m4 = mat[4], m14 = mat[14], m8 = mat[8];
var m13 = mat[13], m12 = mat[12], m9 = mat[9];
if (!dest || mat == dest) {
var a01 = mat[1], a02 = mat[2], a03 ... | @param mat mat4
@param dest mat4 - optional destination
@return {mat4} dest if specified, mat otherwise
@private | SceneJS_math_transposeMat4 | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_lookAtMat4v = function(pos, target, up, dest) {
if (!dest) {
dest = SceneJS_math_mat4();
}
var posx = pos[0],
posy = pos[1],
posz = pos[2],
upx = up[0],
upy = up[1],
upz = up[2],
targetx = target[0],
ta... | @param pos vec3 position of the viewer
@param target vec3 point the viewer is looking at
@param up vec3 pointing "up"
@param dest mat4 Optional, mat4 frustum matrix will be written into
@return {mat4} dest if specified, a new mat4 otherwise | SceneJS_math_lookAtMat4v | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_math_billboardMat = function(viewMatrix) {
var rotVec = [
SceneJS_math_getColMat4(viewMatrix, 0),
SceneJS_math_getColMat4(viewMatrix, 1),
SceneJS_math_getColMat4(viewMatrix, 2)
];
var scaleVec = [
SceneJS_math_lenVec4(rotVec[0]),
SceneJS_math_lenVec4(rotVec[1... | Creates billboard matrix from given view matrix
@private | SceneJS_math_billboardMat | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_webgl_ProgramUniform = function(context, program, name, type, size, location, logging) {
var func = null;
if (type == context.BOOL) {
func = function (v) {
context.uniform1i(location, v);
};
} else if (type == context.BOOL_VEC2) {
func = function (v) {
... | Maps SceneJS node parameter names to WebGL enum names
@private | SceneJS_webgl_ProgramUniform | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_webgl_Shader = function(context, type, source, logging) {
this.handle = context.createShader(type);
// logging.debug("Creating " + ((type == context.VERTEX_SHADER) ? "vertex" : "fragment") + " shader");
this.valid = true;
context.shaderSource(this.handle, source);
context.compileShader(th... | A vertex/fragment shader in a program
@private
@param context WebGL context
@param gl.VERTEX_SHADER | gl.FRAGMENT_SHADER
@param source Source code for shader
@param logging Shader will write logging's debug channel as it compiles | SceneJS_webgl_Shader | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_webgl_Program = function(hash, context, vertexSources, fragmentSources, logging) {
var a, i, u, u_name, location, shader;
this.hash = hash;
/* Create shaders from sources
*/
var shaders = [];
for (i = 0; i < vertexSources.length; i++) {
shaders.push(new SceneJS_webgl_... | A program on an active WebGL context
@private
@param hash SceneJS-managed ID for program
@param context WebGL context
@param vertexSources Source codes for vertex shaders
@param fragmentSources Source codes for fragment shaders
@param logging Program and shaders will write to logging's debug channel as they compile an... | SceneJS_webgl_Program | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function mightBeValidEnum(fname, i, value) {
if (!mightBeEnum(value)) return false;
return (fname in glValidEnumContexts) && (i in glValidEnumContexts[fname]);
} | Returns true if 'value' matches any WebGL enum, and the i'th parameter
of the WebGL function 'fname' is expected to be (any) enum. Does not
check that 'value' is actually a valid i'th parameter to 'fname', as
that will be checked by the WebGL implementation itself.
@param {string} fname the GL function to use for scre... | mightBeValidEnum | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function makeDebugContext(ctx, opt_onErrorFunc) {
init(ctx);
function formatFunctionCall(functionName, args) {
// apparently we can't do args.join(",");
var argStr = "";
for (var ii = 0; ii < args.length; ++ii) {
argStr += ((ii == 0) ? '' : ', ') +
(mightBeEnum(args[i... | Given a WebGL context returns a wrapped context that calls
gl.getError after every command and calls a function if the
result is not gl.NO_ERROR.
@param {!WebGLRenderingContext} ctx The webgl context to
wrap.
@param {!function(err, funcName, args): void} opt_onErrorFunc
The function to call when gl.getEr... | makeDebugContext | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
CompilationQueue = function() {
this._bins = [];
this.size = 0;
this.insert = function(level, node) {
var bin = this._bins[level];
if (!bin) {
bin = this._bins[level] = [];
bin.numNodes = 0;
}
var compilation = bin[... | Tracks compilation states for each scene | CompilationQueue | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function findLoggingElement(loggingElementId) {
var element;
if (!loggingElementId) {
element = document.getElementById(Scene.DEFAULT_LOGGING_ELEMENT_ID);
if (!element) {
SceneJS_loggingModule.info("SceneJS.Scene config 'loggingElementId' omitted and failed to fin... | Backend module that provides single point through which exceptions may be raised
@private | findLoggingElement | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function findCanvas(canvasId, contextAttr) {
var canvas;
if (!canvasId) {
SceneJS_loggingModule.info("Scene attribute 'canvasId' omitted - looking for default canvas with ID '"
+ Scene.DEFAULT_CANVAS_ID + "'");
canvasId = Scene.DEFAULT_CANVAS_ID;
c... | Locates canvas in DOM, finds WebGL context on it, sets some default state on the context, then returns
canvas, canvas ID and context wrapped up in an object.
If canvasId is null, will fall back on Scene.DEFAULT_CANVAS_ID | findCanvas | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
SceneJS_PickBuffer = function(cfg) {
var canvas = cfg.canvas;
var gl = canvas.context;
var pickBuf;
this.bound = false;
this._touch = function() {
var width = canvas.canvas.width;
var height = canvas.canvas.height;
if (pickBuf) { // Currently have a pick buffer
... | Returns the current status of this scene.
When the scene has been destroyed, the returned status will be a map like this:
{
destroyed: true
}
Otherwise, the status will be:
{
numLoading: Number // Number of asset loads (eg. texture, geometry stream etc.) currently in progress
} | SceneJS_PickBuffer | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
glEnum = function(context, name) {
if (!name) {
throw SceneJS_errorModule.fatalError(
SceneJS.errors.ILLEGAL_NODE_CONFIG,
"Null SceneJS.renderer node config: \"" + name + "\"");
}
var result = SceneJS_webgl_enumMap[name];
if (!result) {... | Track IDs of bound states as we build call list | glEnum | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function createProps(props) {
var restore;
if (stackLen > 0) { // can't restore when no previous props set
restore = {};
for (var name in props) {
if (props.hasOwnProperty(name)) {
if (!(props[name] == undefined)) {
res... | Called after all nodes rendered for the current frame | createProps | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
restoreProperties = function(context, props) {
var value;
for (var key in props) { // Set order-insensitive properties (modes)
if (props.hasOwnProperty(key)) {
value = props[key];
if (value != undefined && value != null) {
var se... | Restores previous renderer properties, except for clear - that's the reason we
have a seperate set and restore semantic - we don't want to keep clearing the buffer. | restoreProperties | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
glEnum = function(context, name) {
if (!name) {
throw SceneJS_errorModule.fatalError(
SceneJS.errors.ILLEGAL_NODE_CONFIG,
"Null SceneJS.renderer node config: \"" + name + "\"");
}
var result = SceneJS_webgl_enumMap[name];
if (!result) {... | Maps renderer node properties to WebGL context enums
@private | glEnum | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function popProps() {
var oldProps = propStack[stackLen - 1];
stackLen--;
var newProps = propStack[stackLen - 1];
dirty = true;
} | Clears buffers on the given context as specified in mask | popProps | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function destroyVBOs(geo) {
if (document.getElementById(geo.canvas.canvasId)) { // Context won't exist if canvas has disappeared
if (geo.vertexBuf) {
geo.vertexBuf.destroy();
}
if (geo.normalBuf) {
geo.normalBuf.destroy();
}
... | Backend that tracks statistics on loading states of nodes during scene traversal.
This supports the "loading-status" events that we can listen for on scene nodes.
When a node with that listener is pre-visited, it will call getStatus on this module to
save a copy of the status. Then when it is post-visited, it will ca... | destroyVBOs | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function create() {
var positions = [
[-3.000000, 1.650000, 0.000000],
[-2.987110, 1.650000, -0.098438],
[-2.987110, 1.650000, 0.098438],
[-2.985380, 1.567320, -0.049219],
[-2.985380, 1.567320, 0.049219],
[-2.983500, 1.483080, 0.000000],
... | @class A scene node that defines the geometry of the venerable OpenGL teapot.
<p><b>Example Usage</b></p><p>Definition of teapot:</b></p><pre><code>
var c = new SceneJS_teapot(); // Requires no parameters
</pre></code>
@extends SceneJS.Geometry
@since Version 0.7.4
@constructor
Create a new SceneJS_teapot
@param {Objec... | create | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function letter(ch) {
return letters[ch];
} | Backend module that creates vector geometry repreentations of text
@private | letter | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function getHMTLColor(color) {
if (color.length != 4) {
return color;
}
for (var i = 0; i < color.length; i++) {
color[i] *= 255;
}
return 'rgba(' + color.join(',') + ')';
} | Backend module that creates bitmapp text textures
@private | getHMTLColor | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function loadTransform() {
if (dirty) {
if (stackLen > 0) {
var t = self.transform;
if (!t.matrixAsArray) {
t.matrixAsArray = new Float32Array(t.matrix);
t.normalMatrixAsArray = new Float32Array(
Scen... | Returns a copy of the matrix as a 1D array of 16 elements
@returns {Number[16]} The matrix elements | loadTransform | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function createTexture(scene, cfg, onComplete) {
var context = scene.canvas.context;
var textureId = SceneJS._createUUID();
var update;
try {
if (cfg.autoUpdate) {
update = function() {
//TODO: fix this when minefield is upto spec
... | Creates texture from either image URL or image object | createTexture | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function destroyMorph(morph) {
if (document.getElementById(morph.canvas.canvasId)) { // Context won't exist if canvas has disappeared
var target;
for (var i = 0, len = morph.targets.length; i < len; i++) {
target = morph.targets[i];
if (target.vertexBuf) {... | Destroys morph, returning true if memory freed, else false
where canvas not found and morph was implicitly destroyed | destroyMorph | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function createFrameBuffer(scene, bufId) {
var canvas = scene.canvas;
var gl = canvas.context;
var width = canvas.canvas.width;
var height = canvas.canvas.height;
var frameBuf = gl.createFramebuffer();
var renderBuf = gl.createRenderbuffer();
var texture = gl.cre... | Creates image buffer, registers it under the given ID | createFrameBuffer | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function combineMapStack(maps) {
var map1;
var map2 = {};
var name;
for (var i = 0; i < stackLen; i++) {
map1 = maps[i];
for (name in map1) {
if (map1.hasOwnProperty(name)) {
map2[name] = map1[name];
}
... | Gets the texture from this image buffer | combineMapStack | javascript | schteppe/cannon.js | libs/scenejs.js | https://github.com/schteppe/cannon.js/blob/master/libs/scenejs.js | MIT |
function Heightfield(data, options){
options = Utils.defaults(options, {
maxValue : null,
minValue : null,
elementSize : 1
});
/**
* An array of numbers, or height values, that are spread out along the x axis.
* @property {array} data
*/
this.data = data;
/**... | Heightfield shape class. Height data is given as an array. These data points are spread out evenly with a given distance.
@class Heightfield
@extends Shape
@constructor
@param {Array} data An array of Y values that will be used to construct the terrain.
@param {object} options
@param {Number} [options.minValue] Minimum... | Heightfield | javascript | schteppe/cannon.js | src/shapes/Heightfield.js | https://github.com/schteppe/cannon.js/blob/master/src/shapes/Heightfield.js | MIT |
function barycentricWeights(x, y, ax, ay, bx, by, cx, cy, result){
result.x = ((by - cy) * (x - cx) + (cx - bx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy));
result.y = ((cy - ay) * (x - cx) + (ax - cx) * (y - cy)) / ((by - cy) * (ax - cx) + (cx - bx) * (ay - cy));
result.z = 1 - result.x -... | Get the height in the heightfield at a given position
@param {number} x
@param {number} y
@param {boolean} edgeClamp
@return {number} | barycentricWeights | javascript | schteppe/cannon.js | src/shapes/Heightfield.js | https://github.com/schteppe/cannon.js/blob/master/src/shapes/Heightfield.js | MIT |
function Plane(){
Shape.call(this, {
type: Shape.types.PLANE
});
// World oriented normal
this.worldNormal = new Vec3();
this.worldNormalNeedsUpdate = true;
this.boundingSphereRadius = Number.MAX_VALUE;
} | A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a Body and rotate that body. See the demos.
@class Plane
@constructor
@extends Shape
@author schteppe | Plane | javascript | schteppe/cannon.js | src/shapes/Plane.js | https://github.com/schteppe/cannon.js/blob/master/src/shapes/Plane.js | MIT |
function Shape(options){
options = options || {};
/**
* Identifyer of the Shape.
* @property {number} id
*/
this.id = Shape.idCounter++;
/**
* The type of this shape. Must be set to an int > 0 by subclasses.
* @property type
* @type {Number}
* @see Shape.types
*... | Base class for shapes
@class Shape
@constructor
@param {object} [options]
@param {number} [options.collisionFilterGroup=1]
@param {number} [options.collisionFilterMask=-1]
@param {number} [options.collisionResponse=true]
@param {number} [options.material=null]
@author schteppe | Shape | javascript | schteppe/cannon.js | src/shapes/Shape.js | https://github.com/schteppe/cannon.js/blob/master/src/shapes/Shape.js | MIT |
function World(options){
options = options || {};
EventTarget.apply(this);
/**
* Currently / last used timestep. Is set to -1 if not available. This value is updated before each internal step, which means that it is "fresh" inside event callbacks.
* @property {Number} dt
*/
this.dt = -1;... | The physics world
@class World
@constructor
@extends EventTarget
@param {object} [options]
@param {Vec3} [options.gravity]
@param {boolean} [options.allowSleep]
@param {Broadphase} [options.broadphase]
@param {Solver} [options.solver]
@param {boolean} [options.quatNormalizeFast]
@param {number} [options.quatNormalizeSk... | World | javascript | schteppe/cannon.js | src/world/World.js | https://github.com/schteppe/cannon.js/blob/master/src/world/World.js | MIT |
function useUpdateEffect(effect, deps = []) {
const initialMount = useRef(true);
useEffect(() => {
if (initialMount.current) {
initialMount.current = false;
} else {
effect();
}
}, deps);
} | A custom useEffect hook that only triggers on updates, not on initial mount
@param {Function} effect | useUpdateEffect | javascript | jossmac/react-toast-notifications | examples/src/ConnectivityListener.js | https://github.com/jossmac/react-toast-notifications/blob/master/examples/src/ConnectivityListener.js | MIT |
init(options) {
this.options = options;
this._args = [...options.args];
} | @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options | init | javascript | webpack/tapable | lib/HookCodeFactory.js | https://github.com/webpack/tapable/blob/master/lib/HookCodeFactory.js | MIT |
function setTheme(theme) {
Object.keys(images).forEach(function(name) {
var img = images[name];
if (img.themeable) {
svgThemer.setImgSvgProps.call(img, theme, img.setSvgProps);
}
if (img.themeableRules) {
img.themeableRules.forEach(function(themeable) {
... | @param {object} theme
@memberOf module:images | setTheme | javascript | fin-hypergrid/core | images/index.js | https://github.com/fin-hypergrid/core/blob/master/images/index.js | MIT |
function checkbox(state) {
return images[state ? 'checked' : 'unchecked'];
} | Convenience function.
@param {boolean} state
@returns {HTMLImageElement} {@link module:images.checked|checked} when `state` is truthy or {@link module:images.unchecked|unchecked} otherwise.
@memberOf module:images | checkbox | javascript | fin-hypergrid/core | images/index.js | https://github.com/fin-hypergrid/core/blob/master/images/index.js | MIT |
function filter(state) {
return images[state ? 'filter-on' : 'filter-off'];
} | Convenience function.
@param {boolean} state
@returns {HTMLImageElement} {@link module:images.filter-off|filter-off} when `state` is truthy or {@link module:images.filter-on|filter-on} otherwise.
@memberOf module:images | filter | javascript | fin-hypergrid/core | images/index.js | https://github.com/fin-hypergrid/core/blob/master/images/index.js | MIT |
function rowPropertiesDeprecationWarning() {
if (!warned.rowProperties) {
warned.rowProperties = true;
console.warn('The `rowProperties` property has been deprecated as of v2.1.0 in favor of `rowStripes`. (Will be removed in a future release.)');
}
} | @summary How to truncate text.
@desc A "quaternary" value, one of:
* `undefined` - Text is not truncated.
* `true` (default) - Truncate sufficient characters to fit ellipsis if possible. Most acceptable option that avoids need for clipping.
* `false` - Truncate *before* last partially visible character. Visibly annoyin... | rowPropertiesDeprecationWarning | javascript | fin-hypergrid/core | src/defaults.js | https://github.com/fin-hypergrid/core/blob/master/src/defaults.js | MIT |
function navKey(keyChar, ctrlKey) {
var result;
if (keyChar.length > 1 || !this.editOnKeydown || ctrlKey) {
result = keyChar; // return the mapped value
}
return result;
} | Returns any value of `keyChar` that passes the following logic test:
1. If a non-printable, white-space character, then nav key.
2. If not (i.e., a normal character), can still be a nav key if not editing on key down.
3. If not, can still be a nav key if CTRL key is down.
Note: Callers are typcially only interested in... | navKey | javascript | fin-hypergrid/core | src/defaults.js | https://github.com/fin-hypergrid/core/blob/master/src/defaults.js | MIT |
function mappedNavKey(keyChar, ctrlKey) {
keyChar = this.navKeyMap[keyChar];
return keyChar && this.navKey(keyChar);
} | Returns only values of `keyChar` that, when run through {@link module:defaults.navKeyMap|navKeyMap}, pass the {@link module:defaults.navKey|navKey} logic test.
@param {string} keyChar - A value from Canvas's `charMap`, to be remapped through {@link module:defaults.navKeyMap|navKeyMap}.
@param {boolean} [ctrlKey=false]... | mappedNavKey | javascript | fin-hypergrid/core | src/defaults.js | https://github.com/fin-hypergrid/core/blob/master/src/defaults.js | MIT |
function deleteProp(propName) {
var descriptor = Object.getOwnPropertyDescriptor(this, propName);
if (!descriptor) {
return false; // own property not found
} else if (!descriptor.get) {
return delete this[propName]; // non-accessor property found (returns !descriptor.configurable)
} els... | @summary Reapply cell properties after `getCell`.
@type {boolean}
@default
@memberOf module:defaults | deleteProp | javascript | fin-hypergrid/core | src/defaults.js | https://github.com/fin-hypergrid/core/blob/master/src/defaults.js | MIT |
function exec(vf) {
if (this.dataRow) {
var calculator = (typeof vf)[0] === 'f' && vf || this.calculator;
if (calculator) {
vf = calculator(this.dataRow, this.name, this.subrow);
}
}
return vf;
} | @summary Execute value if "calculator" (function) or if column has calculator.
@desc This function is referenced here so:
1. It will be available to the cell renderers
2. Its context will naturally be the `config` object
@default {@link module:defaults.exec|exec}
@method
@param vf - Value or function.
@memberOf module:... | exec | javascript | fin-hypergrid/core | src/defaults.js | https://github.com/fin-hypergrid/core/blob/master/src/defaults.js | MIT |
set cellPropertiesPrePaintNotification(cell) {
throw new this.HypergridError('cellPropertiesPrePaintNotification has been deprecated as of v3.0.0. Code to inspect or mutate the render config object should be moved to the getCell hook.');
} | @memberOf Behavior#
@desc this function is a hook and is called just before the painting of a cell occurs
@param {Point} cell | cellPropertiesPrePaintNotification | javascript | fin-hypergrid/core | src/behaviors/Behavior.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Behavior.js | MIT |
function warnBehaviorFeaturesDeprecation() {
var featureNames = [], unregisteredFeatures = [], n = 0;
this.features.forEach(function(FeatureConstructor) {
var className = FeatureConstructor.prototype.$$CLASS_NAME || FeatureConstructor.name,
featureName = className || 'feature' + n++;
... | @memberOf Behavior#
@desc swap src and tar columns
@param {number} src - column index
@param {number} tar - column index | warnBehaviorFeaturesDeprecation | javascript | fin-hypergrid/core | src/behaviors/Behavior.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Behavior.js | MIT |
function getCellPropertiesObject(rowIndex, dataModel) {
return this.getCellOwnProperties(rowIndex, dataModel) || newCellPropertiesObject.call(this, rowIndex, dataModel);
} | @todo: Theoretically setData should call this method to ensure each cell's persisted properties object is properly recreated with prototype set to its column's properties object.
@this {Column}
@param {number} rowIndex - Data row coordinate.
@param {DataModel} [dataModel=this.dataModel]
@returns {object}
@private | getCellPropertiesObject | javascript | fin-hypergrid/core | src/behaviors/cellProperties.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/cellProperties.js | MIT |
function newCellPropertiesObject(rowIndex, dataModel) {
var metadata = (dataModel || this.dataModel).getRowMetadata(rowIndex, null),
props = this.properties;
switch (this.index) {
case this.behavior.treeColumnIndex:
props = props.treeHeader;
break;
case this.beha... | @this {Column}
@param {number} rowIndex - Data row coordinate.
@param {DataModel} [dataModel=this.dataModel]
@returns {object}
@private | newCellPropertiesObject | javascript | fin-hypergrid/core | src/behaviors/cellProperties.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/cellProperties.js | MIT |
function Column(behavior, columnSchema) {
switch (typeof columnSchema) {
case 'number':
if (!warned.number) {
console.warn('Column(behavior: object, index: number) overload has been deprecated as of v2.1.6 in favor of Column(behavior: object, columnSchema: object) overload with d... | @summary Create a new `Column` object.
@mixes cellProperties.columnMixin
@mixes columnProperties.mixin
@constructor
@param {Behavior} behavior
@param {object} columnSchema
@param {number} columnSchema.index
@param {string} columnSchema.name
@param {string} [columnSchema.header] - Displayed in column headers. If not def... | Column | javascript | fin-hypergrid/core | src/behaviors/Column.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Column.js | MIT |
set header(header) {
this.schema.header = header;
} | @summary Get or set the text of the column's header.
@desc The _header_ is the label at the top of the column.
Setting the header updates both:
* the `schema` (aka, header) array in the underlying data source; and
* the filter.
@type {string} | header | javascript | fin-hypergrid/core | src/behaviors/Column.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Column.js | MIT |
set calculator(calculator) {
calculator = resolveCalculator.call(this, calculator);
if (calculator !== this.schema.calculator) {
this.schema.calculator = calculator;
this.behavior.grid.reindex();
}
} | @summary Get or set the computed column's calculator function.
@desc Setting the value here updates the calculator in the data model schema.
The results of the new calculations will appear in the column cells on the next repaint.
@type {string} | calculator | javascript | fin-hypergrid/core | src/behaviors/Column.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Column.js | MIT |
set type(type) {
this.schema.type = type;
this.behavior.reindex();
} | @summary Get or set the type of the column's header.
@desc Setting the type updates the filter which typically uses this information for proper collation.
@todo: Instead of using `this._type`, put on data source like the other essential properties. In this case, sorter could use the info to choose a comparator more in... | type | javascript | fin-hypergrid/core | src/behaviors/Column.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Column.js | MIT |
function createColumnProperties() {
var column = this,
tableState = column.behavior.grid.properties,
properties;
properties = Object.create(tableState, {
index: { // read-only (no setter)
get: function() {
return column.index;
}
},
... | @this {Column}
@returns {object}
@memberOf Column# | createColumnProperties | javascript | fin-hypergrid/core | src/behaviors/columnProperties.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/columnProperties.js | MIT |
set subgrids(subgridSpecs) {
var subgrids = this._subgrids = [];
subgrids.lookup = {};
subgridSpecs.forEach(function(spec) {
if (spec) {
subgrids.push(this.createSubgrid(spec));
}
}, this);
this.shapeChanged();
} | An array where each element represents a subgrid to be rendered in the hypergrid.
The list should always include at least one "data" subgrid, typically {@link Behavior#dataModel|dataModel}.
It may also include zero or more other types of subgrids such as header, filter, and summary subgrids.
This object also sports a... | subgrids | javascript | fin-hypergrid/core | src/behaviors/subgrids.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/subgrids.js | MIT |
function derefSubgridRef(ref) {
var Constructor;
switch (typeof ref) {
case 'string':
Constructor = dataModels.get(ref);
break;
case 'function':
Constructor = ref;
break;
default:
throw new this.HypergridError('Expected subgrid ... | @summary Resolves a subgrid constructor reference.
@desc The ref is resolved to a data model constructor.
@this {Behavior}
@param {subgridConstructorRef} ref
@returns {DataModel} A data model constructor.
@memberOf Behavior~ | derefSubgridRef | javascript | fin-hypergrid/core | src/behaviors/subgrids.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/subgrids.js | MIT |
function injectPolyfills(dataModel) {
Object.keys(polyfills).forEach(function(key) {
if (!dataModel[key]) {
dataModel[key] = polyfills[key];
}
});
} | Injects missing utility functions into the data model.
Typically, data models are extended from `datasaur-base` which supplies the utility functions. However, extending from `datasaur-base` is not a requirement and for those data models that do not, the necessary utility functions are injected here.
The only utility ... | injectPolyfills | javascript | fin-hypergrid/core | src/behaviors/Local/decorators.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Local/decorators.js | MIT |
function injectCode(dataModel) {
dataModel.install(fallbacks, { inject: true });
} | Inject fallback methods into data model when not implemented by data model.
@this {Local}
@param {DataModel} dataModel
@memberOf module:decorators | injectCode | javascript | fin-hypergrid/core | src/behaviors/Local/decorators.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Local/decorators.js | MIT |
function injectDefaulthooks(dataModel) {
dataModel.install(hooks, { inject: true });
} | @param {DataModel} dataModel
@this {Local}
@memberOf module:decorators | injectDefaulthooks | javascript | fin-hypergrid/core | src/behaviors/Local/decorators.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Local/decorators.js | MIT |
function addDeprecationWarnings() {
var grid = this.grid;
Object.defineProperties(this.dataModel, {
grid: {
configurable: true,
enumerable: false,
get: function() {
if (!warned.grid) {
console.warn('dataModel.grid has been depreca... | @summary Add deprecation warnings for deprecated legacy data model properties.
@desc This method may be removed in a future version whence all deprecations are removed.
@this {Local}
@memberOf module:decorators | addDeprecationWarnings | javascript | fin-hypergrid/core | src/behaviors/Local/decorators.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Local/decorators.js | MIT |
get schema() {
return this.dataModel.getSchema();
} | @summary Convenience getter/setter.
@desc Calls the data model's `getSchema`/`setSchema` methods.
@see {@link https://fin-hypergrid.github.io/doc/DataModel.html#getSchema|getSchema}
@see {@link https://fin-hypergrid.github.io/doc/DataModel.html#setSchema|setSchema}
@type {Array}
@memberOf Local# | schema | javascript | fin-hypergrid/core | src/behaviors/Local/index.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Local/index.js | MIT |
get charMap() {
return this.dataModel.drillDownCharMap;
} | @summary Map of drill down characters used by the data model.
@see {@link https://fin-hypergrid.github.io/doc/DataModel.html#charMap|charMap}
@type {{OPEN:string, CLOSE:string, INDENT:string}}
@memberOf Local# | charMap | javascript | fin-hypergrid/core | src/behaviors/Local/index.js | https://github.com/fin-hypergrid/core/blob/master/src/behaviors/Local/index.js | MIT |
function renderMultiLineText(gc, config, val, leftPadding, rightPadding) {
var x = config.bounds.x,
y = config.bounds.y,
width = config.bounds.width,
height = config.bounds.height,
cleanVal = (val + '').trim().replace(WHITESPACE, ' '), // trim and squeeze whitespace
lines = f... | @summary Renders single line text.
@param {CanvasRenderingContext2D} gc
@param {object} config
@param {Rectangle} config.bounds - The clipping rect of the cell to be rendered.
@param {*} val - The text to render in the cell.
@memberOf SimpleCell.prototype | renderMultiLineText | javascript | fin-hypergrid/core | src/cellRenderers/SimpleCell.js | https://github.com/fin-hypergrid/core/blob/master/src/cellRenderers/SimpleCell.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.