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 getMissingScaleProps(props, data, attributes) { const result = {}; // Make sure that the domain is set pad it if specified attributes.forEach(attr => { if (!props[`get${toTitleCase(attr)}`]) { result[`get${toTitleCase(attr)}`] = d => d[attr]; } if (!props[`get${toTitleCase(attr)}0`]) { ...
Extract the missing scale props from the given data and return them as an object. @param {Object} props Props. @param {Array} data Array of all data. @param {Array<String>} attributes Array of attributes for the given components (for instance, `['x', 'y', 'color']`). @returns {Object} Collected props.
getMissingScaleProps
javascript
uber/react-vis
packages/react-vis/src/utils/scales-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/scales-utils.js
MIT
function literalScale(defaultValue) { function scale(d) { if (d === undefined) { return defaultValue; } return d; } function response() { return scale; } scale.domain = response; scale.range = response; scale.unknown = response; scale.copy = response; return scale; }
Return a d3 scale that returns the literal value that was given to it @returns {function} literal scale.
literalScale
javascript
uber/react-vis
packages/react-vis/src/utils/scales-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/scales-utils.js
MIT
function getXYPlotValues(props, children) { const XYPlotScales = XYPLOT_ATTR.reduce((prev, attr) => { const { [`${attr}Domain`]: domain, [`${attr}Range`]: range, [`${attr}Type`]: type } = props; if (domain && range && type) { return { ...prev, [attr]: SCALE_FUNCTIO...
Creates fallback values for series from scales defined at XYPlot level. @param {Object} props Props of the XYPlot object. @param {Array<Object>} children Array of components, children of XYPlot @returns {Array<Object>} Collected props.
getXYPlotValues
javascript
uber/react-vis
packages/react-vis/src/utils/scales-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/scales-utils.js
MIT
function getOptionalScaleProps(props) { return Object.keys(props).reduce((acc, prop) => { const propIsNotOptional = OPTIONAL_SCALE_PROPS_REGS.every( reg => !prop.match(reg) ); if (propIsNotOptional) { return acc; } acc[prop] = props[prop]; return acc; }, {}); }
Get the list of optional scale-related settings for XYPlot mostly just used to find padding properties @param {Object} props Object of props. @returns {Object} Optional Props. @private
getOptionalScaleProps
javascript
uber/react-vis
packages/react-vis/src/utils/scales-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/scales-utils.js
MIT
function isSeriesChild(child) { const {prototype} = child.type; return prototype instanceof AbstractSeries; }
Check if the component is series or not. @param {React.Component} child Component. @returns {boolean} True if the child is series, false otherwise.
isSeriesChild
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function getSeriesChildren(children) { return React.Children.toArray(children).filter( child => child && isSeriesChild(child) ); }
Get all series from the 'children' object of the component. @param {Object} children Children. @returns {Array} Array of children.
getSeriesChildren
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function collectSeriesTypesInfo(children) { const result = {}; children.filter(isSeriesChild).forEach(child => { const {displayName} = child.type; const {cluster} = child.props; if (!result[displayName]) { result[displayName] = { sameTypeTotal: 0, sameTypeIndex: 0, clusters...
Collect the map of repetitions of the series type for all children. @param {Array} children Array of children. @returns {{}} Map of repetitions where sameTypeTotal is the total amount and sameTypeIndex is always 0.
collectSeriesTypesInfo
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function seriesHasAngleRadius(data = []) { if (!data) { return false; } return data.some(row => row.radius && row.angle); }
Check series to see if it has angular data that needs to be converted @param {Array} data - an array of objects to check @returns {Boolean} whether or not this series contains polar configuration
seriesHasAngleRadius
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function prepareData(data) { if (!seriesHasAngleRadius(data)) { return data; } return data.map(row => ({ ...row, x: row.radius * Math.cos(row.angle), y: row.radius * Math.sin(row.angle) })); }
Possibly convert polar coordinates to x/y for computing domain @param {Array} data - an array of objects to check @param {String} attr - the property being checked @returns {Boolean} whether or not this series contains polar configuration
prepareData
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function getStackedData(children, attr) { const areSomeSeriesStacked = children.some( series => series && series.props.stack ); // It stores the last segment position added to each bar, separated by cluster. const latestAttrPositions = {}; return children.reduce((accumulator, series) => { // Skip the...
Collect the stacked data for all children in use. If the children don't have the data (e.g. the child is invalid series or something else), then the child is skipped. Each next value of attr is equal to the previous value plus the difference between attr0 and attr. @param {Array} children Array of children. @param {str...
getStackedData
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function getSeriesPropsFromChildren(children) { const result = []; const seriesTypesInfo = collectSeriesTypesInfo(children); let seriesIndex = 0; const _opacityValue = DEFAULT_OPACITY; children.forEach(child => { let props; if (isSeriesChild(child)) { const seriesTypeInfo = seriesTypesInfo[child...
Get the list of series props for a child. @param {Array} children Array of all children. @returns {Array} Array of series props for each child. If a child is not a series, than it's undefined.
getSeriesPropsFromChildren
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function getRadialDomain(data) { return data.reduce((res, row) => Math.max(row.radius, res), 0); }
Find the max radius value from the nodes to be rendered after they have been transformed into an array @param {Array} data - the tree data after it has been broken into a iterable it is an array of objects! @returns {number} the maximum value in coordinates for the radial variable
getRadialDomain
javascript
uber/react-vis
packages/react-vis/src/utils/series-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/series-utils.js
MIT
function getCombinedClassName(...classNames) { return classNames.filter(cn => cn && typeof cn === 'string').join(' '); }
Generates interpolated class names signature based on multiple class names ignoring the falsy and non-string values @param {...string} classNames CSS class signatures. @returns {string} Interpolated string containing all valid class names.
getCombinedClassName
javascript
uber/react-vis
packages/react-vis/src/utils/styling-utils.js
https://github.com/uber/react-vis/blob/master/packages/react-vis/src/utils/styling-utils.js
MIT
render() { return ( <XYPlot onMouseLeave={this._onMouseLeave} width={300} height={300}> <VerticalGridLines /> <HorizontalGridLines /> <XAxis /> <YAxis /> <LineSeries onNearestX={this._onNearestX} data={DATA[0]} /> <LineSeries data={DATA[1]} /> <Crosshair...
Event handler for onNearestX. @param {Object} value Selected value. @param {index} index Index of the value in the data array. @private
render
javascript
uber/react-vis
packages/showcase/axes/dynamic-crosshair.js
https://github.com/uber/react-vis/blob/master/packages/showcase/axes/dynamic-crosshair.js
MIT
function buildRandomBinnedData(total) { const result = Array(total) .fill(0) .map((x, i) => { const values = [ Math.random(), Math.random(), Math.random(), Math.random() ] .sort() .map(d => Math.floor(d * 100)); const y = (values[2] + values[1]...
Generate random random for candle stick chart @param {number} total - Total number of values. @returns {Array} Array of data.
buildRandomBinnedData
javascript
uber/react-vis
packages/showcase/examples/candlestick/candlestick-example.js
https://github.com/uber/react-vis/blob/master/packages/showcase/examples/candlestick/candlestick-example.js
MIT
function generateSimulation(props) { const {data, height, width, maxSteps, strength} = props; if (!data) { return {nodes: [], links: []}; } // copy the data const nodes = data.nodes.map(d => ({...d})); const links = data.links.map(d => ({...d})); // build the simulation const simulation = forceSimul...
Create the list of nodes to render. @returns {Array} Array of nodes.
generateSimulation
javascript
uber/react-vis
packages/showcase/examples/force-directed-graph/force-directed-graph.js
https://github.com/uber/react-vis/blob/master/packages/showcase/examples/force-directed-graph/force-directed-graph.js
MIT
function getRandomSeriesData(total) { const result = []; let lastY = seededRandom() * 40 - 20; let y; const firstY = lastY; for (let i = 0; i < total; i++) { y = seededRandom() * firstY - firstY / 2 + lastY; result.push({ x: i, y }); lastY = y; } return result; }
Get the array of x and y pairs. The function tries to avoid too large changes of the chart. @param {number} total Total number of values. @returns {Array} Array of data. @private
getRandomSeriesData
javascript
uber/react-vis
packages/showcase/misc/zoomable-chart-example.js
https://github.com/uber/react-vis/blob/master/packages/showcase/misc/zoomable-chart-example.js
MIT
render() { const {series, crosshairValues} = this.state; return ( <div className="example-with-click-me"> <div className="legend"> <DiscreteColorLegend onItemClick={this._legendClickHandler} width={180} items={series} /> </div> ...
Event handler for onNearestX. @param {Object} value Selected value. @param {number} index Index of the series. @private
render
javascript
uber/react-vis
packages/showcase/plot/complex-chart.js
https://github.com/uber/react-vis/blob/master/packages/showcase/plot/complex-chart.js
MIT
function getKeyPath(node) { if (!node.parent) { return ['root']; } return [(node.data && node.data.name) || node.name].concat( getKeyPath(node.parent) ); }
Recursively work backwards from highlighted node to find path of valud nodes @param {Object} node - the current node being considered @returns {Array} an array of strings describing the key route to the current node
getKeyPath
javascript
uber/react-vis
packages/showcase/sunbursts/basic-sunburst.js
https://github.com/uber/react-vis/blob/master/packages/showcase/sunbursts/basic-sunburst.js
MIT
function updateData(data, keyPath) { if (data.children) { data.children.map(child => updateData(child, keyPath)); } // add a fill to all the uncolored cells if (!data.hex) { data.style = { fill: EXTENDED_DISCRETE_COLOR_RANGE[5] }; } data.style = { ...data.style, fillOpacity: keyPat...
Recursively modify data depending on whether or not each cell has been selected by the hover/highlight @param {Object} data - the current node being considered @param {Object|Boolean} keyPath - a map of keys that are in the highlight path if this is false then all nodes are marked as selected @returns {Object} Updated ...
updateData
javascript
uber/react-vis
packages/showcase/sunbursts/basic-sunburst.js
https://github.com/uber/react-vis/blob/master/packages/showcase/sunbursts/basic-sunburst.js
MIT
function getHostname(method, methodDescriptor) { // method = hostname + methodDescriptor.name(relative path of this method) return method.substr(0, method.length - methodDescriptor.name.length); }
Get the hostname of the current request. @template REQUEST, RESPONSE @param {string} method @param {!MethodDescriptor<REQUEST,RESPONSE>} methodDescriptor @return {string}
getHostname
javascript
grpc/grpc-web
javascript/net/grpc/web/abstractclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/abstractclientbase.js
Apache-2.0
setOption(name, value) { this.properties_[name] = value; }
Add a new CallOption or override an existing one. @param {string} name name of the CallOption that should be added/overridden. @param {VALUE} value value of the CallOption @template VALUE
setOption
javascript
grpc/grpc-web
javascript/net/grpc/web/calloptions.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/calloptions.js
Apache-2.0
get(name) { return this.properties_[name]; }
Get the value of one CallOption. @param {string} name name of the CallOption. @return {!Object} value of the CallOption. If name doesn't exist, will return 'undefined'.
get
javascript
grpc/grpc-web
javascript/net/grpc/web/calloptions.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/calloptions.js
Apache-2.0
removeOption(name) { delete this.properties_[name]; }
Remove a CallOption. @param {string} name name of the CallOption that shoud be removed.
removeOption
javascript
grpc/grpc-web
javascript/net/grpc/web/calloptions.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/calloptions.js
Apache-2.0
constructor() { /** * Whether to use the HttpCors library to pack http headers into a special * url query param $httpHeaders= so that browsers can bypass CORS OPTIONS * requests. * @type {boolean|undefined} */ this.suppressCorsPreflight; /** * Whether to turn on XMLHttpRequest...
Options that are available during the client construction. @record
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/clientoptions.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/clientoptions.js
Apache-2.0
constructor(options = {}, xhrIo = undefined) { /** * @const * @private {string} */ this.format_ = options.format || goog.getObjectByName('format', options) || 'text'; /** * @const * @private {boolean} */ this.suppressCorsPreflight_ = options.suppressCorsPreflight |...
@param {!ClientOptions=} options @param {!XhrIo=} xhrIo
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
thenableCall( method, requestMessage, metadata, methodDescriptor, options = {}) { const hostname = getHostname(method, methodDescriptor); const signal = options && options.signal; const initialInvoker = (request) => new Promise((resolve, reject) => { // If the signal is already aborted, immediat...
@param {string} method The method to invoke @param {REQUEST} requestMessage The request proto @param {!Object<string, string>} metadata User defined call metadata @param {!MethodDescriptor<REQUEST, RESPONSE>} methodDescriptor @param {?PromiseCallOptions=} options Options for the call @return {!Promise<RESPONSE>} @templ...
thenableCall
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
unaryCall(method, requestMessage, metadata, methodDescriptor, options = {}) { return /** @type {!Promise<RESPONSE>}*/ (this.thenableCall( method, requestMessage, metadata, methodDescriptor, options)); }
@export @param {string} method The method to invoke @param {REQUEST} requestMessage The request proto @param {!Object<string, string>} metadata User defined call metadata @param {!MethodDescriptor<REQUEST, RESPONSE>} methodDescriptor Information of this RPC method @param {?PromiseCallOptions=} options Options for t...
unaryCall
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
startStream_(request, hostname) { const methodDescriptor = request.getMethodDescriptor(); let path = hostname + methodDescriptor.getName(); const xhr = this.xhrIo_ ? this.xhrIo_ : new XhrIo(); xhr.setWithCredentials(this.withCredentials_); const genericTransportInterface = { xhr: xhr, };...
@private @template REQUEST, RESPONSE @param {!Request<REQUEST, RESPONSE>} request @param {string} hostname @return {!ClientReadableStream<RESPONSE>}
startStream_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
static setCallback_(stream, callback, useUnaryResponse) { let isResponseReceived = false; let responseReceived = null; let errorEmitted = false; stream.on('data', function(response) { isResponseReceived = true; responseReceived = response; }); stream.on('error', function(error) { ...
@private @static @template RESPONSE @param {!ClientReadableStream<RESPONSE>} stream @param {function(?RpcError, ?RESPONSE, ?Status=, ?Object<string, string>=, ?boolean)| function(?RpcError,?RESPONSE)} callback @param {boolean} useUnaryResponse Pass true to have the client make multiple calls to the callback, using ...
setCallback_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
encodeRequest_(serialized) { let len = serialized.length; const bytesArray = [0, 0, 0, 0]; const payload = new Uint8Array(5 + len); for (let i = 3; i >= 0; i--) { bytesArray[i] = (len % 256); len = len >>> 8; } payload.set(new Uint8Array(bytesArray), 1); payload.set(serialized, 5...
Encode the grpc-web request @private @param {!Uint8Array} serialized The serialized proto payload @return {!Uint8Array} The application/grpc-web padded request
encodeRequest_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
processHeaders_(xhr) { if (this.format_ == 'text') { xhr.headers.set('Content-Type', 'application/grpc-web-text'); xhr.headers.set('Accept', 'application/grpc-web-text'); } else { xhr.headers.set('Content-Type', 'application/grpc-web+proto'); } xhr.headers.set('X-User-Agent', 'grpc-web...
@private @param {!XhrIo} xhr The xhr object
processHeaders_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
static setCorsOverride_(method, headerObject) { return /** @type {string} */ (HttpCors.setHttpHeadersWithOverwriteParam( method, HttpCors.HTTP_HEADERS_PARAM_NAME, headerObject)); }
@private @static @param {string} method The method to invoke @param {!Object<string,string>} headerObject The xhr headers @return {string} The URI object or a string path with headers
setCorsOverride_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
static runInterceptors_(invoker, interceptors) { return interceptors.reduce((accumulatedInvoker, interceptor) => { return (request) => interceptor.intercept(request, accumulatedInvoker); }, invoker); }
@private @static @template REQUEST, RESPONSE @param {function(!Request<REQUEST,RESPONSE>): (!Promise<RESPONSE>|!ClientReadableStream<RESPONSE>)} invoker @param {!Array<!UnaryInterceptor|!StreamInterceptor>} interceptors @return {function(!Request<REQUEST,RESPONSE>): (!Promise<RESPONSE>|!ClientReadableStream...
runInterceptors_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js
Apache-2.0
function createMethodDescriptor(responseDeSerializeFn) { return new MethodDescriptor( /* name= */ '', /* methodType= */ null, MockRequest, MockReply, (request) => [1, 2, 3], responseDeSerializeFn); }
@param {function(string): !AllowedResponseType} responseDeSerializeFn @return {!MethodDescriptor<!MockRequest, !AllowedResponseType>}
createMethodDescriptor
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase_test.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase_test.js
Apache-2.0
intercept(request, invoker) { return new InterceptedStream(invoker(request)); }
@override @template REQUEST, RESPONSE @param {!Request<REQUEST, RESPONSE>} request @param {function(!Request<REQUEST,RESPONSE>): !ClientReadableStream<RESPONSE>} invoker @return {!ClientReadableStream<RESPONSE>}
intercept
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase_test.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase_test.js
Apache-2.0
on(eventType, callback) { if (eventType == 'data') { const newCallback = (response) => { response.data = 'Intercepted ' + response.data; callback(response); }; this.stream.on(eventType, newCallback); } else { this.stream.on(eventType, callback); } return this; }
@override @param {string} eventType @param {function(?)} callback @return {!ClientReadableStream<RESPONSE>}
on
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientbase_test.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase_test.js
Apache-2.0
removeListenerFromCallbacks_(callbacks, callback) { const index = callbacks.indexOf(callback); if (index > -1) { callbacks.splice(index, 1); } }
@private @param {!Array<function(?)>} callbacks the internal list of callbacks @param {function(?)} callback the callback to remove
removeListenerFromCallbacks_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
setResponseDeserializeFn(responseDeserializeFn) { this.responseDeserializeFn_ = responseDeserializeFn; }
Register a callbackl to parse the response @param {function(?):!RESPONSE} responseDeserializeFn The deserialize function for the proto
setResponseDeserializeFn
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
parseHttp1Headers_(str) { const chunks = str.trim().split('\r\n'); const headers = {}; for (let i = 0; i < chunks.length; i++) { const pos = chunks[i].indexOf(':'); headers[chunks[i].substring(0, pos).trim()] = chunks[i].substring(pos + 1).trim(); } return headers; }
Parse HTTP headers @private @param {string} str The raw http header string @return {!Object} The header:value pairs
parseHttp1Headers_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
handleError_(error) { if (error.code != StatusCode.OK) { this.sendErrorCallbacks_(new RpcError( error.code, decodeURIComponent(error.message || ''), error.metadata)); } this.sendStatusCallbacks_(/** @type {!Status} */ ({ code: error.code, details: decodeURIComponent(error.message...
A central place to handle errors @private @param {!RpcError} error The error object
handleError_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
sendDataCallbacks_(data) { for (let i = 0; i < this.onDataCallbacks_.length; i++) { this.onDataCallbacks_[i](data); } }
@private @param {!RESPONSE} data The data to send back
sendDataCallbacks_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
sendStatusCallbacks_(status) { for (let i = 0; i < this.onStatusCallbacks_.length; i++) { this.onStatusCallbacks_[i](status); } }
@private @param {!Status} status The status to send back
sendStatusCallbacks_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
sendMetadataCallbacks_(metadata) { for (let i = 0; i < this.onMetadataCallbacks_.length; i++) { this.onMetadataCallbacks_[i](metadata); } }
@private @param {!Metadata} metadata The metadata to send back
sendMetadataCallbacks_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
sendErrorCallbacks_(error) { for (let i = 0; i < this.onErrorCallbacks_.length; i++) { this.onErrorCallbacks_[i](error); } }
@private @param {!RpcError} error The error to send back
sendErrorCallbacks_
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebclientreadablestream.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientreadablestream.js
Apache-2.0
constructor() { /** * The current error message, if any. * @private {?string} */ this.errorMessage_ = null; /** * The currently buffered result (parsed messages). * @private {!Array<!Object>} */ this.result_ = []; /** * The current position in the streamed data. ...
The default grpc-web stream parser. @implements {StreamParser} @final
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebstreamparser.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebstreamparser.js
Apache-2.0
parse(input) { asserts.assert( input instanceof Array || input instanceof ArrayBuffer || input instanceof Uint8Array); var parser = this; var inputBytes; var pos = 0; if (input instanceof Uint8Array || input instanceof Array) { inputBytes = input; } else { inputByte...
Parse the new input. Note that there is no Parser state to indicate the end of a stream. @param {string|!ArrayBuffer|!Uint8Array|!Array<number>} input The input data @throws {!Error} Throws an error message if the input is invalid. @return {?Array<string|!Object>} any parsed objects (atomic messages) in an arr...
parse
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebstreamparser.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebstreamparser.js
Apache-2.0
function processFrameByte(b) { if (b == FrameType.DATA) { parser.frame_ = b; } else if (b == FrameType.TRAILER) { parser.frame_ = b; } else { parser.error_(inputBytes, pos, 'invalid frame byte'); } parser.state_ = Parser.State_.LENGTH; parser.length_ = 0; ...
@param {number} b A frame byte to process
processFrameByte
javascript
grpc/grpc-web
javascript/net/grpc/web/grpcwebstreamparser.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebstreamparser.js
Apache-2.0
constructor( name, methodType, requestType, responseType, requestSerializeFn, responseDeserializeFn) { /** @const */ this.name = name; /** @const */ this.methodType = methodType; /** @const */ this.requestType = requestType; /** @const */ this.responseType = responseType; ...
@param {string} name @param {?MethodType} methodType @param {function(new: REQUEST, ...)} requestType @param {function(new: RESPONSE, ...)} responseType @param {function(REQUEST): ?} requestSerializeFn @param {function(?): RESPONSE} responseDeserializeFn
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/methoddescriptor.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/methoddescriptor.js
Apache-2.0
createRequest( requestMessage, metadata = {}, callOptions = new CallOptions()) { return new RequestInternal(requestMessage, this, metadata, callOptions); }
@override @param {REQUEST} requestMessage @param {!Metadata=} metadata @param {!CallOptions=} callOptions @return {!Request<REQUEST, RESPONSE>}
createRequest
javascript
grpc/grpc-web
javascript/net/grpc/web/methoddescriptor.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/methoddescriptor.js
Apache-2.0
createUnaryResponse(responseMessage, metadata = {}, status = null) { return new UnaryResponseInternal(responseMessage, this, metadata, status); }
@override @param {RESPONSE} responseMessage @param {!Metadata=} metadata @param {?Status=} status @return {!UnaryResponse<REQUEST, RESPONSE>}
createUnaryResponse
javascript
grpc/grpc-web
javascript/net/grpc/web/methoddescriptor.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/methoddescriptor.js
Apache-2.0
constructor(requestMessage, methodDescriptor, metadata, callOptions) { /** * @const {REQUEST} * @private */ this.requestMessage_ = requestMessage; /** * @const {!MethodDescriptor<REQUEST, RESPONSE>} * @private */ this.methodDescriptor_ = methodDescriptor; /** @const @...
@param {REQUEST} requestMessage @param {!MethodDescriptor<REQUEST, RESPONSE>} methodDescriptor @param {!Metadata} metadata @param {!CallOptions} callOptions
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/requestinternal.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/requestinternal.js
Apache-2.0
constructor(code, message, metadata = {}) { super(message); /** @type {!StatusCode} */ this.code = code; /** @type {!Metadata} */ this.metadata = metadata; }
@param {!StatusCode} code @param {string} message @param {!Metadata=} metadata
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/rpcerror.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/rpcerror.js
Apache-2.0
constructor(responseMessage, methodDescriptor, metadata = {}, status = null) { /** * @const {RESPONSE} * @private */ this.responseMessage_ = responseMessage; /** * @const {!Metadata} * @private */ this.metadata_ = metadata; /** * @const {!MethodDescriptor<REQUEST...
@param {RESPONSE} responseMessage @param {!MethodDescriptor<REQUEST, RESPONSE>} methodDescriptor @param {!Metadata=} metadata @param {?Status=} status
constructor
javascript
grpc/grpc-web
javascript/net/grpc/web/unaryresponseinternal.js
https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/unaryresponseinternal.js
Apache-2.0
InterceptedStream = function(stream) { this.stream = stream; }
@template REQUEST, RESPONSE @param {!Request<REQUEST, RESPONSE>} request @param {function(!Request<REQUEST,RESPONSE>):!ClientReadableStream<RESPONSE>} invoker @return {!ClientReadableStream<RESPONSE>}
InterceptedStream
javascript
grpc/grpc-web
net/grpc/gateway/examples/echo/commonjs-example/client.js
https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/commonjs-example/client.js
Apache-2.0
function copyMetadata(call) { var metadata = call.metadata.getMap(); var response_metadata = new grpc.Metadata(); for (var key in metadata) { response_metadata.set(key, metadata[key]); } return response_metadata; }
@param {!Object} call @return {!Object} metadata
copyMetadata
javascript
grpc/grpc-web
net/grpc/gateway/examples/echo/node-server/server.js
https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/node-server/server.js
Apache-2.0
function doEcho(call, callback) { callback(null, { message: call.request.message }, copyMetadata(call)); }
@param {!Object} call @param {function():?} callback
doEcho
javascript
grpc/grpc-web
net/grpc/gateway/examples/echo/node-server/server.js
https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/node-server/server.js
Apache-2.0
function getServer() { var server = new grpc.Server(); server.addService(echo.EchoService.service, { echo: doEcho, echoAbort: doEchoAbort, serverStreamingEcho: doServerStreamingEcho, }); return server; }
Get a new server with the handler functions in this file bound to the methods it serves. @return {!Server} The new server object
getServer
javascript
grpc/grpc-web
net/grpc/gateway/examples/echo/node-server/server.js
https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/node-server/server.js
Apache-2.0
function main() { async.series([ runSayHello, runSayRepeatHello, ]); }
Run all of the demos in order
main
javascript
grpc/grpc-web
net/grpc/gateway/examples/helloworld/debugging/node-client.js
https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/helloworld/debugging/node-client.js
Apache-2.0
waitForTest = function(done, fail) { // executeScript runs the passed method in the "window" context of // the current test. JSUnit exposes hooks into the test's status through // the "G_testRunner" global object. browser.executeScript(function() { if (window['G_testRunner'] && window['G_testRunne...
Waits for current tests to be executed. @param {function(!Object)} done The function called when the test is finished. @param {function(!Error)} fail The function called when an unrecoverable error happened during the test.
waitForTest
javascript
grpc/grpc-web
packages/grpc-web/protractor_spec.js
https://github.com/grpc/grpc-web/blob/master/packages/grpc-web/protractor_spec.js
Apache-2.0
runRoutine = function(done) { browser.navigate() .to(TEST_SERVER + '/' + testPath) .then(function() { waitForTest(function(status) { expect(status).toBeSuccess(); done(); }, function(err) { done.fail(err); ...
Runs the test routines for a given test path. @param {function()} done The function to run on completion.
runRoutine
javascript
grpc/grpc-web
packages/grpc-web/protractor_spec.js
https://github.com/grpc/grpc-web/blob/master/packages/grpc-web/protractor_spec.js
Apache-2.0
function restartGeometryCaches(){ contactMeshCache.restart(); contactMeshCache.hideCached(); cm2contactMeshCache.restart(); cm2contactMeshCache.hideCached(); distanceConstraintMeshCache.restart(); distanceConstraintMeshCache.hideCached(); normalMeshCache.restar...
Demo framework class. If you want to learn how to connect Cannon.js with Three.js, please look at the examples/ instead. @class Demo @constructor @param {Object} options
restartGeometryCaches
javascript
schteppe/cannon.js
build/cannon.demo.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.demo.js
MIT
function addScene(title,initfunc){ if(typeof(title) !== "string"){ throw new Error("1st argument of Demo.addScene(title,initfunc) must be a string!"); } if(typeof(initfunc)!=="function"){ throw new Error("2nd argument of Demo.addScene(title,initfunc) must be a function!")...
Add a scene to the demo app @method addScene @param {String} title Title of the scene @param {Function} initfunc A function that takes one argument, app, and initializes a physics scene. The function runs app.setWorld(body), app.addVisual(body), app.removeVisual(body) etc.
addScene
javascript
schteppe/cannon.js
build/cannon.demo.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.demo.js
MIT
function restartCurrentScene(){ var N = bodies.length; for(var i=0; i<N; i++){ var b = bodies[i]; b.position.copy(b.initPosition); b.velocity.copy(b.initVelocity); if(b.initAngularVelocity){ b.angularVelocity.copy(b.initAngularVelocity); ...
Restarts the current scene @method restartCurrentScene
restartCurrentScene
javascript
schteppe/cannon.js
build/cannon.demo.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.demo.js
MIT
function AABB(options){ options = options || {}; /** * The lower bound of the bounding box. * @property lowerBound * @type {Vec3} */ this.lowerBound = new Vec3(); if(options.lowerBound){ this.lowerBound.copy(options.lowerBound); } /** * The upper bound of the b...
Axis aligned bounding box class. @class AABB @constructor @param {Object} [options] @param {Vec3} [options.upperBound] @param {Vec3} [options.lowerBound]
AABB
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function ArrayCollisionMatrix() { /** * The matrix storage * @property matrix * @type {Array} */ this.matrix = []; }
Collision "matrix". It's actually a triangular-shaped array of whether two bodies are touching this step, for reference next step @class ArrayCollisionMatrix @constructor
ArrayCollisionMatrix
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Broadphase(){ /** * The world to search for collisions in. * @property world * @type {World} */ this.world = null; /** * If set to true, the broadphase uses bounding boxes for intersection test, else it uses bounding spheres. * @property useBoundingBoxes * @type {Boo...
Base class for broadphase implementations @class Broadphase @constructor @author schteppe
Broadphase
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function GridBroadphase(aabbMin,aabbMax,nx,ny,nz){ Broadphase.apply(this); this.nx = nx || 10; this.ny = ny || 10; this.nz = nz || 10; this.aabbMin = aabbMin || new Vec3(100,100,100); this.aabbMax = aabbMax || new Vec3(-100,-100,-100); var nbins = this.nx * this.ny * this.nz; if (nbins <= 0) {...
Axis aligned uniform grid broadphase. @class GridBroadphase @constructor @extends Broadphase @todo Needs support for more than just planes and spheres. @param {Vec3} aabbMin @param {Vec3} aabbMax @param {Number} nx Number of boxes along x @param {Number} ny Number of boxes along y @param {Number} nz Number of boxes alo...
GridBroadphase
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function addBoxToBins(x0,y0,z0,x1,y1,z1,bi) { var xoff0 = ((x0 - xmin) * xmult)|0, yoff0 = ((y0 - ymin) * ymult)|0, zoff0 = ((z0 - zmin) * zmult)|0, xoff1 = ceil((x1 - xmin) * xmult), yoff1 = ceil((y1 - ymin) * ymult), zoff1 = ceil((z1 - zmin) * zmult); if (xoff0 < 0) { xoff0 = 0; } else if (xoff0 >...
Get all the collision pairs in the physics world @method collisionPairs @param {World} world @param {Array} pairs1 @param {Array} pairs2
addBoxToBins
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function ObjectCollisionMatrix() { /** * The matrix storage * @property matrix * @type {Object} */ this.matrix = {}; }
Records what objects are colliding with each other @class ObjectCollisionMatrix @constructor
ObjectCollisionMatrix
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Ray(from, to){ /** * @property {Vec3} from */ this.from = from ? from.clone() : new Vec3(); /** * @property {Vec3} to */ this.to = to ? to.clone() : new Vec3(); /** * @private * @property {Vec3} _direction */ this._direction = new Vec3(); /** ...
A line in 3D space that intersects bodies and return points. @class Ray @constructor @param {Vec3} from @param {Vec3} to
Ray
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function pointInTriangle(p, a, b, c) { c.vsub(a,v0); b.vsub(a,v1); p.vsub(a,v2); var dot00 = v0.dot( v0 ); var dot01 = v0.dot( v1 ); var dot02 = v0.dot( v2 ); var dot11 = v1.dot( v1 ); var dot12 = v1.dot( v2 ); var u,v; return ( (u = dot11 * dot02 - dot01 * dot12) >= 0 ) && ...
Do itersection against all bodies in the given World. @method intersectWorld @param {World} world @param {object} options @return {Boolean} True if the ray hit anything, otherwise false.
pointInTriangle
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function distanceFromIntersection(from, direction, position) { // v0 is vector from from to position position.vsub(from,v0); var dot = v0.dot(direction); // intersect = direction*dot + from direction.mult(dot,intersect); intersect.vadd(from,intersect); var distance = position.distanceTo(i...
@method reportIntersection @private @param {Vec3} normal @param {Vec3} hitPointWorld @param {Shape} shape @param {Body} body @return {boolean} True if the intersections should continue
distanceFromIntersection
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function RaycastResult(){ /** * @property {Vec3} rayFromWorld */ this.rayFromWorld = new Vec3(); /** * @property {Vec3} rayToWorld */ this.rayToWorld = new Vec3(); /** * @property {Vec3} hitNormalWorld */ this.hitNormalWorld = new Vec3(); /** * @property {Vec3} hitPointWorld */ this.hitPoint...
Storage for Ray casting data. @class RaycastResult @constructor
RaycastResult
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function SAPBroadphase(world){ Broadphase.apply(this); /** * List of bodies currently in the broadphase. * @property axisList * @type {Array} */ this.axisList = []; /** * The world to search in. * @property world * @type {World} */ this.world = null; /*...
Sweep and prune broadphase along one axis. @class SAPBroadphase @constructor @param {World} [world] @extends Broadphase
SAPBroadphase
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function ConeTwistConstraint(bodyA, bodyB, options){ options = options || {}; var maxForce = typeof(options.maxForce) !== 'undefined' ? options.maxForce : 1e6; // Set pivot point in between var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3(); var pivotB = options.pivotB ? options.pivo...
@class ConeTwistConstraint @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {object} [options] @param {Vec3} [options.pivotA] @param {Vec3} [options.pivotB] @param {Vec3} [options.axisA] @param {Vec3} [options.axisB] @param {Number} [options.maxForce=1e6] @extends PointToPointConstraint
ConeTwistConstraint
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Constraint(bodyA, bodyB, options){ options = Utils.defaults(options,{ collideConnected : true, wakeUpBodies : true, }); /** * Equations to be solved in this constraint * @property equations * @type {Array} */ this.equations = []; /** * @property {B...
Constraint base class @class Constraint @author schteppe @constructor @param {Body} bodyA @param {Body} bodyB @param {object} [options] @param {boolean} [options.collideConnected=true] @param {boolean} [options.wakeUpBodies=true]
Constraint
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function DistanceConstraint(bodyA,bodyB,distance,maxForce){ Constraint.call(this,bodyA,bodyB); if(typeof(distance)==="undefined") { distance = bodyA.position.distanceTo(bodyB.position); } if(typeof(maxForce)==="undefined") { maxForce = 1e6; } /** * @property {number} dist...
Constrains two bodies to be at a constant distance from each others center of mass. @class DistanceConstraint @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {Number} [distance] The distance to keep. If undefined, it will be set to the current distance between bodyA and bodyB @param {Number...
DistanceConstraint
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function HingeConstraint(bodyA, bodyB, options){ options = options || {}; var maxForce = typeof(options.maxForce) !== 'undefined' ? options.maxForce : 1e6; var pivotA = options.pivotA ? options.pivotA.clone() : new Vec3(); var pivotB = options.pivotB ? options.pivotB.clone() : new Vec3(); PointToPo...
Hinge constraint. Think of it as a door hinge. It tries to keep the door in the correct place and with the correct orientation. @class HingeConstraint @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {object} [options] @param {Vec3} [options.pivotA] A point defined locally in bodyA. This def...
HingeConstraint
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function LockConstraint(bodyA, bodyB, options){ options = options || {}; var maxForce = typeof(options.maxForce) !== 'undefined' ? options.maxForce : 1e6; // Set pivot point in between var pivotA = new Vec3(); var pivotB = new Vec3(); var halfWay = new Vec3(); bodyA.position.vadd(bodyB.posi...
Lock constraint. Will remove all degrees of freedom between the bodies. @class LockConstraint @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {object} [options] @param {Number} [options.maxForce=1e6] @extends PointToPointConstraint
LockConstraint
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function PointToPointConstraint(bodyA,pivotA,bodyB,pivotB,maxForce){ Constraint.call(this,bodyA,bodyB); maxForce = typeof(maxForce) !== 'undefined' ? maxForce : 1e6; /** * Pivot, defined locally in bodyA. * @property {Vec3} pivotA */ this.pivotA = pivotA ? pivotA.clone() : new Vec3(); ...
Connects two bodies at given offset points. @class PointToPointConstraint @extends Constraint @constructor @param {Body} bodyA @param {Vec3} pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. @param {Body} bodyB Body that will be constrained in a similar way to the same point as bod...
PointToPointConstraint
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function ConeEquation(bodyA, bodyB, options){ options = options || {}; var maxForce = typeof(options.maxForce) !== 'undefined' ? options.maxForce : 1e6; Equation.call(this,bodyA,bodyB,-maxForce, maxForce); this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); this.axisB = options...
Cone equation. Works to keep the given body world vectors aligned, or tilted within a given angle from each other. @class ConeEquation @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {Vec3} [options.axisA] Local axis in A @param {Vec3} [options.axisB] Local axis in B @param {Vec3} [options....
ConeEquation
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function ContactEquation(bodyA, bodyB, maxForce){ maxForce = typeof(maxForce) !== 'undefined' ? maxForce : 1e6; Equation.call(this, bodyA, bodyB, 0, maxForce); /** * @property restitution * @type {Number} */ this.restitution = 0.0; // "bounciness": u1 = -e*u0 /** * World-orient...
Contact/non-penetration constraint equation @class ContactEquation @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @extends Equation
ContactEquation
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Equation(bi,bj,minForce,maxForce){ this.id = Equation.id++; /** * @property {number} minForce */ this.minForce = typeof(minForce)==="undefined" ? -1e6 : minForce; /** * @property {number} maxForce */ this.maxForce = typeof(maxForce)==="undefined" ? 1e6 : maxForce; ...
Equation base class @class Equation @constructor @author schteppe @param {Body} bi @param {Body} bj @param {Number} minForce Minimum (read: negative max) force to be applied by the constraint. @param {Number} maxForce Maximum (read: positive max) force to be applied by the constraint.
Equation
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function FrictionEquation(bodyA, bodyB, slipForce){ Equation.call(this,bodyA, bodyB, -slipForce, slipForce); this.ri = new Vec3(); this.rj = new Vec3(); this.t = new Vec3(); // tangent }
Constrains the slipping in a contact along a tangent @class FrictionEquation @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {Number} slipForce should be +-F_friction = +-mu * F_normal = +-mu * m * g @extends Equation
FrictionEquation
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function RotationalEquation(bodyA, bodyB, options){ options = options || {}; var maxForce = typeof(options.maxForce) !== 'undefined' ? options.maxForce : 1e6; Equation.call(this,bodyA,bodyB,-maxForce, maxForce); this.axisA = options.axisA ? options.axisA.clone() : new Vec3(1, 0, 0); this.axisB = o...
Rotational constraint. Works to keep the local vectors orthogonal to each other in world space. @class RotationalEquation @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {Vec3} [options.axisA] @param {Vec3} [options.axisB] @param {number} [options.maxForce] @extends Equation
RotationalEquation
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function RotationalMotorEquation(bodyA, bodyB, maxForce){ maxForce = typeof(maxForce)!=='undefined' ? maxForce : 1e6; Equation.call(this,bodyA,bodyB,-maxForce,maxForce); /** * World oriented rotational axis * @property {Vec3} axisA */ this.axisA = new Vec3(); /** * World orient...
Rotational motor constraint. Tries to keep the relative angular velocity of the bodies to a given value. @class RotationalMotorEquation @constructor @author schteppe @param {Body} bodyA @param {Body} bodyB @param {Number} maxForce @extends Equation
RotationalMotorEquation
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function ContactMaterial(m1, m2, options){ options = Utils.defaults(options, { friction: 0.3, restitution: 0.3, contactEquationStiffness: 1e7, contactEquationRelaxation: 3, frictionEquationStiffness: 1e7, frictionEquationRelaxation: 3 }); /** * Identifie...
Defines what happens when two materials meet. @class ContactMaterial @constructor @param {Material} m1 @param {Material} m2 @param {object} [options] @param {Number} [options.friction=0.3] @param {Number} [options.restitution=0.3] @param {number} [options.contactEquationStiffness=1e7] @param {number} [options.contactEq...
ContactMaterial
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Material(options){ var name = ''; options = options || {}; // Backwards compatibility fix if(typeof(options) === 'string'){ name = options; options = {}; } else if(typeof(options) === 'object') { name = ''; } /** * @property name * @type {String} ...
Defines a physics material. @class Material @constructor @param {object} [options] @author schteppe
Material
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function JacobianElement(){ /** * @property {Vec3} spatial */ this.spatial = new Vec3(); /** * @property {Vec3} rotational */ this.rotational = new Vec3(); }
An element containing 6 entries, 3 spatial and 3 rotational degrees of freedom. @class JacobianElement @constructor
JacobianElement
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Mat3(elements){ /** * A vector of length 9, containing all matrix elements * @property {Array} elements */ if(elements){ this.elements = elements; } else { this.elements = [0,0,0,0,0,0,0,0,0]; } }
A 3x3 matrix. @class Mat3 @constructor @param array elements Array of nine elements. Optional. @author schteppe / http://github.com/schteppe
Mat3
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Quaternion(x,y,z,w){ /** * @property {Number} x */ this.x = x!==undefined ? x : 0; /** * @property {Number} y */ this.y = y!==undefined ? y : 0; /** * @property {Number} z */ this.z = z!==undefined ? z : 0; /** * The multiplier of the real quate...
A Quaternion describes a rotation in 3D space. The Quaternion is mathematically defined as Q = x*i + y*j + z*k + w, where (i,j,k) are imaginary basis vectors. (x,y,z) can be seen as a vector related to the axis of rotation, while the real multiplier, w, is related to the amount of rotation. @class Quaternion @construct...
Quaternion
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Vec3(x,y,z){ /** * @property x * @type {Number} */ this.x = x||0.0; /** * @property y * @type {Number} */ this.y = y||0.0; /** * @property z * @type {Number} */ this.z = z||0.0; }
3-dimensional vector @class Vec3 @constructor @param {Number} x @param {Number} y @param {Number} z @author schteppe @example var v = new Vec3(1, 2, 3); console.log('x=' + v.x); // x=1
Vec3
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function RaycastVehicle(options){ /** * @property {Body} chassisBody */ this.chassisBody = options.chassisBody; /** * An array of WheelInfo objects. * @property {array} wheelInfos */ this.wheelInfos = []; /** * Will be set to true if the car is sliding. * @prope...
Vehicle helper class that casts rays from the wheel positions towards the ground and applies forces. @class RaycastVehicle @constructor @param {object} [options] @param {Body} [options.chassisBody] The car chassis body. @param {integer} [options.indexRightAxis] Axis to use for right. x=0, y=1, z=2 @param {integer} [opt...
RaycastVehicle
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function calcRollingFriction(body0, body1, frictionPosWorld, frictionDirectionWorld, maxImpulse) { var j1 = 0; var contactPosWorld = frictionPosWorld; // var rel_pos1 = new Vec3(); // var rel_pos2 = new Vec3(); var vel1 = calcRollingFriction_vel1; var vel2 = calcRollingFriction_vel2; var ve...
Get the world transform of one of the wheels @method getWheelTransformWorld @param {integer} wheelIndex @return {Transform}
calcRollingFriction
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function RigidVehicle(options){ this.wheelBodies = []; /** * @property coordinateSystem * @type {Vec3} */ this.coordinateSystem = typeof(options.coordinateSystem)==='undefined' ? new Vec3(1, 2, 3) : options.coordinateSystem.clone(); /** * @property {Body} chassisBody */ th...
Simple vehicle helper class with spherical rigid body wheels. @class RigidVehicle @constructor @param {Body} [options.chassisBody]
RigidVehicle
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function SPHSystem(){ this.particles = []; /** * Density of the system (kg/m3). * @property {number} density */ this.density = 1; /** * Distance below which two particles are considered to be neighbors. * It should be adjusted so there are about 15-20 neighbor particles with...
Smoothed-particle hydrodynamics system @class SPHSystem @constructor
SPHSystem
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Spring(bodyA,bodyB,options){ options = options || {}; /** * Rest length of the spring. * @property restLength * @type {number} */ this.restLength = typeof(options.restLength) === "number" ? options.restLength : 1; /** * Stiffness of the spring. * @property stiffn...
A spring, connecting two bodies. @class Spring @constructor @param {Body} bodyA @param {Body} bodyB @param {Object} [options] @param {number} [options.restLength] A number > 0. Default: 1 @param {number} [options.stiffness] A number >= 0. Default: 100 @param {number} [options.damping] A number >= 0. Default:...
Spring
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function WheelInfo(options){ options = Utils.defaults(options, { chassisConnectionPointLocal: new Vec3(), chassisConnectionPointWorld: new Vec3(), directionLocal: new Vec3(), directionWorld: new Vec3(), axleLocal: new Vec3(), axleWorld: new Vec3(), suspensionR...
@class WheelInfo @constructor @param {Object} [options] @param {Vec3} [options.chassisConnectionPointLocal] @param {Vec3} [options.chassisConnectionPointWorld] @param {Vec3} [options.directionLocal] @param {Vec3} [options.directionWorld] @param {Vec3} [options.axleLocal] @param {Vec3} [options.axleWorld] @param {numbe...
WheelInfo
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT
function Box(halfExtents){ Shape.call(this); this.type = Shape.types.BOX; /** * @property halfExtents * @type {Vec3} */ this.halfExtents = halfExtents; /** * Used by the contact generator to make contacts with other convex polyhedra for example * @property convexPolyhedro...
A 3d box shape. @class Box @constructor @param {Vec3} halfExtents @author schteppe @extends Shape
Box
javascript
schteppe/cannon.js
build/cannon.js
https://github.com/schteppe/cannon.js/blob/master/build/cannon.js
MIT