id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
6,800
google/marzipano
src/stages/Stage.js
Stage
function Stage(opts) { this._progressive = !!(opts && opts.progressive); // The list of layers in display order (background to foreground). this._layers = []; // The list of renderers; the i-th renderer is for the i-th layer. this._renderers = []; // The lists of tiles to load and render, populated during render(). this._tilesToLoad = []; this._tilesToRender = []; // Temporary tile lists. this._tmpVisible = []; this._tmpChildren = []; // Cached stage dimensions. // Start with zero, which inhibits rendering until setSize() is called. this._width = 0; this._height = 0; // Temporary variable for rect. this._tmpRect = {}; // Temporary variable for size. this._tmpSize = {}; // Work queue for createTexture. this._createTextureWorkQueue = new WorkQueue(); // Function to emit event when render parameters have changed. this._emitRenderInvalid = this._emitRenderInvalid.bind(this); // The renderer registry maps each geometry/view pair into the respective // Renderer class. this._rendererRegistry = new RendererRegistry(); }
javascript
function Stage(opts) { this._progressive = !!(opts && opts.progressive); // The list of layers in display order (background to foreground). this._layers = []; // The list of renderers; the i-th renderer is for the i-th layer. this._renderers = []; // The lists of tiles to load and render, populated during render(). this._tilesToLoad = []; this._tilesToRender = []; // Temporary tile lists. this._tmpVisible = []; this._tmpChildren = []; // Cached stage dimensions. // Start with zero, which inhibits rendering until setSize() is called. this._width = 0; this._height = 0; // Temporary variable for rect. this._tmpRect = {}; // Temporary variable for size. this._tmpSize = {}; // Work queue for createTexture. this._createTextureWorkQueue = new WorkQueue(); // Function to emit event when render parameters have changed. this._emitRenderInvalid = this._emitRenderInvalid.bind(this); // The renderer registry maps each geometry/view pair into the respective // Renderer class. this._rendererRegistry = new RendererRegistry(); }
[ "function", "Stage", "(", "opts", ")", "{", "this", ".", "_progressive", "=", "!", "!", "(", "opts", "&&", "opts", ".", "progressive", ")", ";", "// The list of layers in display order (background to foreground).", "this", ".", "_layers", "=", "[", "]", ";", "...
Signals that the contents of the stage have been invalidated and must be rendered again. This is used by the {@link RenderLoop} implementation. @event Stage#renderInvalid @interface Stage @classdesc A Stage is a container with the ability to render a stack of {@link Layer layers}. This is a superclass containing logic that is common to all implementations; it should never be instantiated directly. Instead, use one of the subclasses: {@link WebGlStage}, {@link CssStage} or {@link FlashStage}. @param {Object} opts @param {boolean} [opts.progressive=false] Options listed here may be passed into the `opts` constructor argument of subclasses. The `progressive` option controls whether resolution levels are loaded in order, from lowest to highest. This results in a more pleasing effect when zooming past several levels in a large panoramas, but consumes additional bandwidth.
[ "Signals", "that", "the", "contents", "of", "the", "stage", "have", "been", "invalidated", "and", "must", "be", "rendered", "again", "." ]
e3e21b2c1992708992dfeab5970b0f5a3f8f98e0
https://github.com/google/marzipano/blob/e3e21b2c1992708992dfeab5970b0f5a3f8f98e0/src/stages/Stage.js#L74-L111
6,801
google/marzipano
demos/transitions/index.js
nextScene
function nextScene() { switch (currentScene) { case scene1: return (currentScene = scene2); case scene2: return (currentScene = scene1); default: return (currentScene = scene1); } }
javascript
function nextScene() { switch (currentScene) { case scene1: return (currentScene = scene2); case scene2: return (currentScene = scene1); default: return (currentScene = scene1); } }
[ "function", "nextScene", "(", ")", "{", "switch", "(", "currentScene", ")", "{", "case", "scene1", ":", "return", "(", "currentScene", "=", "scene2", ")", ";", "case", "scene2", ":", "return", "(", "currentScene", "=", "scene1", ")", ";", "default", ":",...
Return the next scene to be displayed.
[ "Return", "the", "next", "scene", "to", "be", "displayed", "." ]
e3e21b2c1992708992dfeab5970b0f5a3f8f98e0
https://github.com/google/marzipano/blob/e3e21b2c1992708992dfeab5970b0f5a3f8f98e0/demos/transitions/index.js#L65-L71
6,802
google/marzipano
demos/video/index.js
tryStart
function tryStart() { if (started) { return; } started = true; var video = document.createElement('video'); video.src = '//www.marzipano.net/media/video/mercedes-f1-1280x640.mp4'; video.crossOrigin = 'anonymous'; video.autoplay = true; video.loop = true; // Prevent the video from going full screen on iOS. video.playsInline = true; video.webkitPlaysInline = true; video.play(); waitForReadyState(video, video.HAVE_METADATA, 100, function() { waitForReadyState(video, video.HAVE_ENOUGH_DATA, 100, function() { asset.setVideo(video); }); }); }
javascript
function tryStart() { if (started) { return; } started = true; var video = document.createElement('video'); video.src = '//www.marzipano.net/media/video/mercedes-f1-1280x640.mp4'; video.crossOrigin = 'anonymous'; video.autoplay = true; video.loop = true; // Prevent the video from going full screen on iOS. video.playsInline = true; video.webkitPlaysInline = true; video.play(); waitForReadyState(video, video.HAVE_METADATA, 100, function() { waitForReadyState(video, video.HAVE_ENOUGH_DATA, 100, function() { asset.setVideo(video); }); }); }
[ "function", "tryStart", "(", ")", "{", "if", "(", "started", ")", "{", "return", ";", "}", "started", "=", "true", ";", "var", "video", "=", "document", ".", "createElement", "(", "'video'", ")", ";", "video", ".", "src", "=", "'//www.marzipano.net/media...
Try to start playback.
[ "Try", "to", "start", "playback", "." ]
e3e21b2c1992708992dfeab5970b0f5a3f8f98e0
https://github.com/google/marzipano/blob/e3e21b2c1992708992dfeab5970b0f5a3f8f98e0/demos/video/index.js#L59-L83
6,803
google/marzipano
demos/video/index.js
waitForReadyState
function waitForReadyState(element, readyState, interval, done) { var timer = setInterval(function() { if (element.readyState >= readyState) { clearInterval(timer); done(null, true); } }, interval); }
javascript
function waitForReadyState(element, readyState, interval, done) { var timer = setInterval(function() { if (element.readyState >= readyState) { clearInterval(timer); done(null, true); } }, interval); }
[ "function", "waitForReadyState", "(", "element", ",", "readyState", ",", "interval", ",", "done", ")", "{", "var", "timer", "=", "setInterval", "(", "function", "(", ")", "{", "if", "(", "element", ".", "readyState", ">=", "readyState", ")", "{", "clearInt...
Wait for an element to reach the given readyState by polling. The HTML5 video element exposes a `readystatechange` event that could be listened for instead, but it seems to be unreliable on some browsers.
[ "Wait", "for", "an", "element", "to", "reach", "the", "given", "readyState", "by", "polling", ".", "The", "HTML5", "video", "element", "exposes", "a", "readystatechange", "event", "that", "could", "be", "listened", "for", "instead", "but", "it", "seems", "to...
e3e21b2c1992708992dfeab5970b0f5a3f8f98e0
https://github.com/google/marzipano/blob/e3e21b2c1992708992dfeab5970b0f5a3f8f98e0/demos/video/index.js#L88-L95
6,804
google/marzipano
src/util/clearOwnProperties.js
clearOwnProperties
function clearOwnProperties(obj) { for (var prop in obj) { if (obj.hasOwnProperty(prop)) { obj[prop] = undefined; } } }
javascript
function clearOwnProperties(obj) { for (var prop in obj) { if (obj.hasOwnProperty(prop)) { obj[prop] = undefined; } } }
[ "function", "clearOwnProperties", "(", "obj", ")", "{", "for", "(", "var", "prop", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "prop", ")", ")", "{", "obj", "[", "prop", "]", "=", "undefined", ";", "}", "}", "}" ]
Sets an object's own properties to undefined. This may be called by destructors to avoid retaining references and help detect incorrect use of destroyed instances.
[ "Sets", "an", "object", "s", "own", "properties", "to", "undefined", ".", "This", "may", "be", "called", "by", "destructors", "to", "avoid", "retaining", "references", "and", "help", "detect", "incorrect", "use", "of", "destroyed", "instances", "." ]
e3e21b2c1992708992dfeab5970b0f5a3f8f98e0
https://github.com/google/marzipano/blob/e3e21b2c1992708992dfeab5970b0f5a3f8f98e0/src/util/clearOwnProperties.js#L21-L27
6,805
haraka/Haraka
plugins/data.uribl.js
do_replyto_header
function do_replyto_header (cb) { const replyto = trans.header.get('reply-to'); const rmatch = email_re.exec(replyto); if (rmatch) { return plugin.do_lookups(connection, cb, rmatch[1], 'replyto'); } cb(); }
javascript
function do_replyto_header (cb) { const replyto = trans.header.get('reply-to'); const rmatch = email_re.exec(replyto); if (rmatch) { return plugin.do_lookups(connection, cb, rmatch[1], 'replyto'); } cb(); }
[ "function", "do_replyto_header", "(", "cb", ")", "{", "const", "replyto", "=", "trans", ".", "header", ".", "get", "(", "'reply-to'", ")", ";", "const", "rmatch", "=", "email_re", ".", "exec", "(", "replyto", ")", ";", "if", "(", "rmatch", ")", "{", ...
Reply-To header
[ "Reply", "-", "To", "header" ]
4aea44d56834a1a4be78c56b646a6c266aa7d7b5
https://github.com/haraka/Haraka/blob/4aea44d56834a1a4be78c56b646a6c266aa7d7b5/plugins/data.uribl.js#L332-L339
6,806
haraka/Haraka
plugins/data.uribl.js
do_msgid_header
function do_msgid_header (cb) { const msgid = trans.header.get('message-id'); const mmatch = /@([^>]+)>/.exec(msgid); if (mmatch) { return plugin.do_lookups(connection, cb, mmatch[1], 'msgid'); } cb(); }
javascript
function do_msgid_header (cb) { const msgid = trans.header.get('message-id'); const mmatch = /@([^>]+)>/.exec(msgid); if (mmatch) { return plugin.do_lookups(connection, cb, mmatch[1], 'msgid'); } cb(); }
[ "function", "do_msgid_header", "(", "cb", ")", "{", "const", "msgid", "=", "trans", ".", "header", ".", "get", "(", "'message-id'", ")", ";", "const", "mmatch", "=", "/", "@([^>]+)>", "/", ".", "exec", "(", "msgid", ")", ";", "if", "(", "mmatch", ")"...
Message-Id header
[ "Message", "-", "Id", "header" ]
4aea44d56834a1a4be78c56b646a6c266aa7d7b5
https://github.com/haraka/Haraka/blob/4aea44d56834a1a4be78c56b646a6c266aa7d7b5/plugins/data.uribl.js#L342-L349
6,807
haraka/Haraka
outbound/client_pool.js
get_pool
function get_pool (port, host, local_addr, is_unix_socket, max) { port = port || 25; host = host || 'localhost'; const name = `outbound::${port}:${host}:${local_addr}:${cfg.pool_timeout}`; if (!server.notes.pool) server.notes.pool = {}; if (server.notes.pool[name]) return server.notes.pool[name]; const pool = generic_pool.Pool({ name, create: function (done) { _create_socket(this.name, port, host, local_addr, is_unix_socket, done); }, validate: socket => socket.__fromPool && socket.writable, destroy: socket => { logger.logdebug(`[outbound] destroying pool entry ${socket.__uuid} for ${host}:${port}`); socket.removeAllListeners(); socket.__fromPool = false; socket.on('line', line => { // Just assume this is a valid response logger.logprotocol(`[outbound] S: ${line}`); }); socket.once('error', err => { logger.logwarn(`[outbound] Socket got an error while shutting down: ${err}`); }); socket.once('end', () => { logger.loginfo("[outbound] Remote end half closed during destroy()"); socket.destroy(); }) if (socket.writable) { logger.logprotocol(`[outbound] [${socket.__uuid}] C: QUIT`); socket.write("QUIT\r\n"); } socket.end(); // half close }, max: max || 10, idleTimeoutMillis: cfg.pool_timeout * 1000, log: (str, level) => { if (/this._availableObjects.length=/.test(str)) return; level = (level === 'verbose') ? 'debug' : level; logger[`log${level}`](`[outbound] [${name}] ${str}`); } }); server.notes.pool[name] = pool; return pool; }
javascript
function get_pool (port, host, local_addr, is_unix_socket, max) { port = port || 25; host = host || 'localhost'; const name = `outbound::${port}:${host}:${local_addr}:${cfg.pool_timeout}`; if (!server.notes.pool) server.notes.pool = {}; if (server.notes.pool[name]) return server.notes.pool[name]; const pool = generic_pool.Pool({ name, create: function (done) { _create_socket(this.name, port, host, local_addr, is_unix_socket, done); }, validate: socket => socket.__fromPool && socket.writable, destroy: socket => { logger.logdebug(`[outbound] destroying pool entry ${socket.__uuid} for ${host}:${port}`); socket.removeAllListeners(); socket.__fromPool = false; socket.on('line', line => { // Just assume this is a valid response logger.logprotocol(`[outbound] S: ${line}`); }); socket.once('error', err => { logger.logwarn(`[outbound] Socket got an error while shutting down: ${err}`); }); socket.once('end', () => { logger.loginfo("[outbound] Remote end half closed during destroy()"); socket.destroy(); }) if (socket.writable) { logger.logprotocol(`[outbound] [${socket.__uuid}] C: QUIT`); socket.write("QUIT\r\n"); } socket.end(); // half close }, max: max || 10, idleTimeoutMillis: cfg.pool_timeout * 1000, log: (str, level) => { if (/this._availableObjects.length=/.test(str)) return; level = (level === 'verbose') ? 'debug' : level; logger[`log${level}`](`[outbound] [${name}] ${str}`); } }); server.notes.pool[name] = pool; return pool; }
[ "function", "get_pool", "(", "port", ",", "host", ",", "local_addr", ",", "is_unix_socket", ",", "max", ")", "{", "port", "=", "port", "||", "25", ";", "host", "=", "host", "||", "'localhost'", ";", "const", "name", "=", "`", "${", "port", "}", "${",...
Separate pools are kept for each set of server attributes.
[ "Separate", "pools", "are", "kept", "for", "each", "set", "of", "server", "attributes", "." ]
4aea44d56834a1a4be78c56b646a6c266aa7d7b5
https://github.com/haraka/Haraka/blob/4aea44d56834a1a4be78c56b646a6c266aa7d7b5/outbound/client_pool.js#L47-L92
6,808
haraka/Haraka
outbound/hmail.js
sort_mx
function sort_mx (mx_list) { const sorted = mx_list.sort((a,b) => a.priority - b.priority); // This isn't a very good shuffle but it'll do for now. for (let i=0,l=sorted.length-1; i<l; i++) { if (sorted[i].priority === sorted[i+1].priority) { if (Math.round(Math.random())) { // 0 or 1 const j = sorted[i]; sorted[i] = sorted[i+1]; sorted[i+1] = j; } } } return sorted; }
javascript
function sort_mx (mx_list) { const sorted = mx_list.sort((a,b) => a.priority - b.priority); // This isn't a very good shuffle but it'll do for now. for (let i=0,l=sorted.length-1; i<l; i++) { if (sorted[i].priority === sorted[i+1].priority) { if (Math.round(Math.random())) { // 0 or 1 const j = sorted[i]; sorted[i] = sorted[i+1]; sorted[i+1] = j; } } } return sorted; }
[ "function", "sort_mx", "(", "mx_list", ")", "{", "const", "sorted", "=", "mx_list", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "a", ".", "priority", "-", "b", ".", "priority", ")", ";", "// This isn't a very good shuffle but it'll do for now.", "for", ...
MXs must be sorted by priority order, but matched priorities must be randomly shuffled in that list, so this is a bit complex.
[ "MXs", "must", "be", "sorted", "by", "priority", "order", "but", "matched", "priorities", "must", "be", "randomly", "shuffled", "in", "that", "list", "so", "this", "is", "a", "bit", "complex", "." ]
4aea44d56834a1a4be78c56b646a6c266aa7d7b5
https://github.com/haraka/Haraka/blob/4aea44d56834a1a4be78c56b646a6c266aa7d7b5/outbound/hmail.js#L1458-L1472
6,809
haraka/Haraka
server.js
setupListener
function setupListener (host_port, listenerDone) { const hp = /^\[?([^\]]+)\]?:(\d+)$/.exec(host_port); if (!hp) return listenerDone( new Error('Invalid "listen" format in smtp.ini')); const host = hp[1]; const port = parseInt(hp[2], 10); Server.get_smtp_server(host, port, inactivity_timeout, (server) => { if (!server) return listenerDone(); server.notes = Server.notes; if (Server.cluster) server.cluster = Server.cluster; server .on('listening', function () { const addr = this.address(); logger.lognotice(`Listening on ${addr.address}:${addr.port}`); listenerDone(); }) .on('close', () => { logger.loginfo(`Listener ${host}:${port} stopped`); }) .on('error', e => { if (e.code !== 'EAFNOSUPPORT') return listenerDone(e); // Fallback from IPv6 to IPv4 if not supported // But only if we supplied the default of [::0]:25 if (/^::0/.test(host) && Server.default_host) { server.listen(port, '0.0.0.0', 0); return; } // Pass error to callback listenerDone(e); }) .listen(port, host, 0); }); }
javascript
function setupListener (host_port, listenerDone) { const hp = /^\[?([^\]]+)\]?:(\d+)$/.exec(host_port); if (!hp) return listenerDone( new Error('Invalid "listen" format in smtp.ini')); const host = hp[1]; const port = parseInt(hp[2], 10); Server.get_smtp_server(host, port, inactivity_timeout, (server) => { if (!server) return listenerDone(); server.notes = Server.notes; if (Server.cluster) server.cluster = Server.cluster; server .on('listening', function () { const addr = this.address(); logger.lognotice(`Listening on ${addr.address}:${addr.port}`); listenerDone(); }) .on('close', () => { logger.loginfo(`Listener ${host}:${port} stopped`); }) .on('error', e => { if (e.code !== 'EAFNOSUPPORT') return listenerDone(e); // Fallback from IPv6 to IPv4 if not supported // But only if we supplied the default of [::0]:25 if (/^::0/.test(host) && Server.default_host) { server.listen(port, '0.0.0.0', 0); return; } // Pass error to callback listenerDone(e); }) .listen(port, host, 0); }); }
[ "function", "setupListener", "(", "host_port", ",", "listenerDone", ")", "{", "const", "hp", "=", "/", "^\\[?([^\\]]+)\\]?:(\\d+)$", "/", ".", "exec", "(", "host_port", ")", ";", "if", "(", "!", "hp", ")", "return", "listenerDone", "(", "new", "Error", "("...
array of listeners
[ "array", "of", "listeners" ]
4aea44d56834a1a4be78c56b646a6c266aa7d7b5
https://github.com/haraka/Haraka/blob/4aea44d56834a1a4be78c56b646a6c266aa7d7b5/server.js#L388-L425
6,810
aspnet/SignalR
clients/cpp/samples/SignalRServer/Scripts/jquery.signalR-2.2.0.js
map
function map(arr, fun, thisp) { var i, length = arr.length, result = []; for (i = 0; i < length; i += 1) { if (arr.hasOwnProperty(i)) { result[i] = fun.call(thisp, arr[i], i, arr); } } return result; }
javascript
function map(arr, fun, thisp) { var i, length = arr.length, result = []; for (i = 0; i < length; i += 1) { if (arr.hasOwnProperty(i)) { result[i] = fun.call(thisp, arr[i], i, arr); } } return result; }
[ "function", "map", "(", "arr", ",", "fun", ",", "thisp", ")", "{", "var", "i", ",", "length", "=", "arr", ".", "length", ",", "result", "=", "[", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "length", ";", "i", "+=", "1", ")", "{", ...
Equivalent to Array.prototype.map
[ "Equivalent", "to", "Array", ".", "prototype", ".", "map" ]
8c6ed160d84f58ce8edf06a1c74221ddc8983ee9
https://github.com/aspnet/SignalR/blob/8c6ed160d84f58ce8edf06a1c74221ddc8983ee9/clients/cpp/samples/SignalRServer/Scripts/jquery.signalR-2.2.0.js#L2518-L2528
6,811
eKoopmans/html2pdf.js
dist/html2pdf.js
unitConvert
function unitConvert(obj, k) { if (objType(obj) === 'number') { return obj * 72 / 96 / k; } else { var newObj = {}; for (var key in obj) { newObj[key] = obj[key] * 72 / 96 / k; } return newObj; } }
javascript
function unitConvert(obj, k) { if (objType(obj) === 'number') { return obj * 72 / 96 / k; } else { var newObj = {}; for (var key in obj) { newObj[key] = obj[key] * 72 / 96 / k; } return newObj; } }
[ "function", "unitConvert", "(", "obj", ",", "k", ")", "{", "if", "(", "objType", "(", "obj", ")", "===", "'number'", ")", "{", "return", "obj", "*", "72", "/", "96", "/", "k", ";", "}", "else", "{", "var", "newObj", "=", "{", "}", ";", "for", ...
Convert units from px using the conversion value 'k' from jsPDF.
[ "Convert", "units", "from", "px", "using", "the", "conversion", "value", "k", "from", "jsPDF", "." ]
9bbe4b35b76896a78a428a62af553c633040ad90
https://github.com/eKoopmans/html2pdf.js/blob/9bbe4b35b76896a78a428a62af553c633040ad90/dist/html2pdf.js#L110-L120
6,812
eKoopmans/html2pdf.js
dist/html2pdf.js
html2pdf
function html2pdf(src, opt) { // Create a new worker with the given options. var worker = new html2pdf.Worker(opt); if (src) { // If src is specified, perform the traditional 'simple' operation. return worker.from(src).save(); } else { // Otherwise, return the worker for new Promise-based operation. return worker; } }
javascript
function html2pdf(src, opt) { // Create a new worker with the given options. var worker = new html2pdf.Worker(opt); if (src) { // If src is specified, perform the traditional 'simple' operation. return worker.from(src).save(); } else { // Otherwise, return the worker for new Promise-based operation. return worker; } }
[ "function", "html2pdf", "(", "src", ",", "opt", ")", "{", "// Create a new worker with the given options.", "var", "worker", "=", "new", "html2pdf", ".", "Worker", "(", "opt", ")", ";", "if", "(", "src", ")", "{", "// If src is specified, perform the traditional 'si...
Generate a PDF from an HTML element or string using html2canvas and jsPDF. @param {Element|string} source The source element or HTML string. @param {Object=} opt An object of optional settings: 'margin', 'filename', 'image' ('type' and 'quality'), and 'html2canvas' / 'jspdf', which are sent as settings to their corresponding functions.
[ "Generate", "a", "PDF", "from", "an", "HTML", "element", "or", "string", "using", "html2canvas", "and", "jsPDF", "." ]
9bbe4b35b76896a78a428a62af553c633040ad90
https://github.com/eKoopmans/html2pdf.js/blob/9bbe4b35b76896a78a428a62af553c633040ad90/dist/html2pdf.js#L906-L917
6,813
eKoopmans/html2pdf.js
gulpfile.js
mergeBranch
function mergeBranch(branch) { var mergeCmd = 'git merge --no-ff --no-edit ' + branch; console.log('Merging release into master.') return exec('git checkout master && ' + mergeCmd).then(function() { console.log('Merging release into develop.') return exec('git checkout develop && ' + mergeCmd); }); }
javascript
function mergeBranch(branch) { var mergeCmd = 'git merge --no-ff --no-edit ' + branch; console.log('Merging release into master.') return exec('git checkout master && ' + mergeCmd).then(function() { console.log('Merging release into develop.') return exec('git checkout develop && ' + mergeCmd); }); }
[ "function", "mergeBranch", "(", "branch", ")", "{", "var", "mergeCmd", "=", "'git merge --no-ff --no-edit '", "+", "branch", ";", "console", ".", "log", "(", "'Merging release into master.'", ")", "return", "exec", "(", "'git checkout master && '", "+", "mergeCmd", ...
Merge the specified branch back into master and develop.
[ "Merge", "the", "specified", "branch", "back", "into", "master", "and", "develop", "." ]
9bbe4b35b76896a78a428a62af553c633040ad90
https://github.com/eKoopmans/html2pdf.js/blob/9bbe4b35b76896a78a428a62af553c633040ad90/gulpfile.js#L28-L36
6,814
davidmerfield/randomColor
randomColor.js
getRealHueRange
function getRealHueRange(colorHue) { if (!isNaN(colorHue)) { var number = parseInt(colorHue); if (number < 360 && number > 0) { return getColorInfo(colorHue).hueRange } } else if (typeof colorHue === 'string') { if (colorDictionary[colorHue]) { var color = colorDictionary[colorHue]; if (color.hueRange) { return color.hueRange } } else if (colorHue.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) { var hue = HexToHSB(colorHue)[0] return getColorInfo(hue).hueRange } } return [0,360] }
javascript
function getRealHueRange(colorHue) { if (!isNaN(colorHue)) { var number = parseInt(colorHue); if (number < 360 && number > 0) { return getColorInfo(colorHue).hueRange } } else if (typeof colorHue === 'string') { if (colorDictionary[colorHue]) { var color = colorDictionary[colorHue]; if (color.hueRange) { return color.hueRange } } else if (colorHue.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) { var hue = HexToHSB(colorHue)[0] return getColorInfo(hue).hueRange } } return [0,360] }
[ "function", "getRealHueRange", "(", "colorHue", ")", "{", "if", "(", "!", "isNaN", "(", "colorHue", ")", ")", "{", "var", "number", "=", "parseInt", "(", "colorHue", ")", ";", "if", "(", "number", "<", "360", "&&", "number", ">", "0", ")", "{", "re...
get The range of given hue when options.count!=0
[ "get", "The", "range", "of", "given", "hue", "when", "options", ".", "count!", "=", "0" ]
5e0cdb4d84a214ccc10e4ad3c2308ed09549bede
https://github.com/davidmerfield/randomColor/blob/5e0cdb4d84a214ccc10e4ad3c2308ed09549bede/randomColor.js#L494-L517
6,815
abouolia/sticky-sidebar
src/jquery.sticky-sidebar.js
_jQueryPlugin
function _jQueryPlugin(config){ return this.each(function(){ var $this = plugin(this), data = plugin(this).data(DATA_NAMESPACE); if( ! data ){ data = new StickySidebar(this, typeof config == 'object' && config); $this.data(DATA_NAMESPACE, data); } if( 'string' === typeof config){ if (data[config] === undefined && ['destroy', 'updateSticky'].indexOf(config) === -1) throw new Error('No method named "'+ config +'"'); data[config](); } }); }
javascript
function _jQueryPlugin(config){ return this.each(function(){ var $this = plugin(this), data = plugin(this).data(DATA_NAMESPACE); if( ! data ){ data = new StickySidebar(this, typeof config == 'object' && config); $this.data(DATA_NAMESPACE, data); } if( 'string' === typeof config){ if (data[config] === undefined && ['destroy', 'updateSticky'].indexOf(config) === -1) throw new Error('No method named "'+ config +'"'); data[config](); } }); }
[ "function", "_jQueryPlugin", "(", "config", ")", "{", "return", "this", ".", "each", "(", "function", "(", ")", "{", "var", "$this", "=", "plugin", "(", "this", ")", ",", "data", "=", "plugin", "(", "this", ")", ".", "data", "(", "DATA_NAMESPACE", ")...
Sticky Sidebar Plugin Defintion. @param {Object|String} - config
[ "Sticky", "Sidebar", "Plugin", "Defintion", "." ]
bcd40bbf95e84b75916bc3535d7475447f9383f8
https://github.com/abouolia/sticky-sidebar/blob/bcd40bbf95e84b75916bc3535d7475447f9383f8/src/jquery.sticky-sidebar.js#L15-L32
6,816
pissang/claygl
src/util/sh.js
projectEnvironmentMapGPU
function projectEnvironmentMapGPU(renderer, envMap) { var shTexture = new Texture2D({ width: 9, height: 1, type: Texture.FLOAT }); var pass = new Pass({ fragment: projectEnvMapShaderCode }); pass.material.define('fragment', 'TEXTURE_SIZE', envMap.width); pass.setUniform('environmentMap', envMap); var framebuffer = new FrameBuffer(); framebuffer.attach(shTexture); pass.render(renderer, framebuffer); framebuffer.bind(renderer); // TODO Only chrome and firefox support Float32Array var pixels = new vendor.Float32Array(9 * 4); renderer.gl.readPixels(0, 0, 9, 1, Texture.RGBA, Texture.FLOAT, pixels); var coeff = new vendor.Float32Array(9 * 3); for (var i = 0; i < 9; i++) { coeff[i * 3] = pixels[i * 4]; coeff[i * 3 + 1] = pixels[i * 4 + 1]; coeff[i * 3 + 2] = pixels[i * 4 + 2]; } framebuffer.unbind(renderer); framebuffer.dispose(renderer); pass.dispose(renderer); return coeff; }
javascript
function projectEnvironmentMapGPU(renderer, envMap) { var shTexture = new Texture2D({ width: 9, height: 1, type: Texture.FLOAT }); var pass = new Pass({ fragment: projectEnvMapShaderCode }); pass.material.define('fragment', 'TEXTURE_SIZE', envMap.width); pass.setUniform('environmentMap', envMap); var framebuffer = new FrameBuffer(); framebuffer.attach(shTexture); pass.render(renderer, framebuffer); framebuffer.bind(renderer); // TODO Only chrome and firefox support Float32Array var pixels = new vendor.Float32Array(9 * 4); renderer.gl.readPixels(0, 0, 9, 1, Texture.RGBA, Texture.FLOAT, pixels); var coeff = new vendor.Float32Array(9 * 3); for (var i = 0; i < 9; i++) { coeff[i * 3] = pixels[i * 4]; coeff[i * 3 + 1] = pixels[i * 4 + 1]; coeff[i * 3 + 2] = pixels[i * 4 + 2]; } framebuffer.unbind(renderer); framebuffer.dispose(renderer); pass.dispose(renderer); return coeff; }
[ "function", "projectEnvironmentMapGPU", "(", "renderer", ",", "envMap", ")", "{", "var", "shTexture", "=", "new", "Texture2D", "(", "{", "width", ":", "9", ",", "height", ":", "1", ",", "type", ":", "Texture", ".", "FLOAT", "}", ")", ";", "var", "pass"...
Project on gpu, but needs browser to support readPixels as Float32Array.
[ "Project", "on", "gpu", "but", "needs", "browser", "to", "support", "readPixels", "as", "Float32Array", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/util/sh.js#L19-L51
6,817
pissang/claygl
src/util/sh.js
projectEnvironmentMapCPU
function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { var coeff = new vendor.Float32Array(9 * 3); var normal = vec3.create(); var texel = vec3.create(); var fetchNormal = vec3.create(); for (var m = 0; m < 9; m++) { var result = vec3.create(); for (var k = 0; k < targets.length; k++) { var pixels = cubePixels[targets[k]]; var sideResult = vec3.create(); var divider = 0; var i = 0; var transform = normalTransform[targets[k]]; for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { normal[0] = x / (width - 1.0) * 2.0 - 1.0; // TODO Flip y? normal[1] = y / (height - 1.0) * 2.0 - 1.0; normal[2] = -1.0; vec3.normalize(normal, normal); fetchNormal[0] = normal[transform[0]] * transform[3]; fetchNormal[1] = normal[transform[1]] * transform[4]; fetchNormal[2] = normal[transform[2]] * transform[5]; texel[0] = pixels[i++] / 255; texel[1] = pixels[i++] / 255; texel[2] = pixels[i++] / 255; // RGBM Decode var scale = pixels[i++] / 255 * 8.12; texel[0] *= scale; texel[1] *= scale; texel[2] *= scale; vec3.scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]); // -normal.z equals cos(theta) of Lambertian divider += -normal[2]; } } vec3.scaleAndAdd(result, result, sideResult, 1 / divider); } coeff[m * 3] = result[0] / 6.0; coeff[m * 3 + 1] = result[1] / 6.0; coeff[m * 3 + 2] = result[2] / 6.0; } return coeff; }
javascript
function projectEnvironmentMapCPU(renderer, cubePixels, width, height) { var coeff = new vendor.Float32Array(9 * 3); var normal = vec3.create(); var texel = vec3.create(); var fetchNormal = vec3.create(); for (var m = 0; m < 9; m++) { var result = vec3.create(); for (var k = 0; k < targets.length; k++) { var pixels = cubePixels[targets[k]]; var sideResult = vec3.create(); var divider = 0; var i = 0; var transform = normalTransform[targets[k]]; for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { normal[0] = x / (width - 1.0) * 2.0 - 1.0; // TODO Flip y? normal[1] = y / (height - 1.0) * 2.0 - 1.0; normal[2] = -1.0; vec3.normalize(normal, normal); fetchNormal[0] = normal[transform[0]] * transform[3]; fetchNormal[1] = normal[transform[1]] * transform[4]; fetchNormal[2] = normal[transform[2]] * transform[5]; texel[0] = pixels[i++] / 255; texel[1] = pixels[i++] / 255; texel[2] = pixels[i++] / 255; // RGBM Decode var scale = pixels[i++] / 255 * 8.12; texel[0] *= scale; texel[1] *= scale; texel[2] *= scale; vec3.scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]); // -normal.z equals cos(theta) of Lambertian divider += -normal[2]; } } vec3.scaleAndAdd(result, result, sideResult, 1 / divider); } coeff[m * 3] = result[0] / 6.0; coeff[m * 3 + 1] = result[1] / 6.0; coeff[m * 3 + 2] = result[2] / 6.0; } return coeff; }
[ "function", "projectEnvironmentMapCPU", "(", "renderer", ",", "cubePixels", ",", "width", ",", "height", ")", "{", "var", "coeff", "=", "new", "vendor", ".", "Float32Array", "(", "9", "*", "3", ")", ";", "var", "normal", "=", "vec3", ".", "create", "(", ...
Project on cpu.
[ "Project", "on", "cpu", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/util/sh.js#L97-L146
6,818
pissang/claygl
src/GeometryBase.js
function () { var enabledAttributes = this.getEnabledAttributes(); for (var i = 0; i < enabledAttributes.length; i++) { this.dirtyAttribute(enabledAttributes[i]); } this.dirtyIndices(); this._enabledAttributes = null; this._cache.dirty('any'); }
javascript
function () { var enabledAttributes = this.getEnabledAttributes(); for (var i = 0; i < enabledAttributes.length; i++) { this.dirtyAttribute(enabledAttributes[i]); } this.dirtyIndices(); this._enabledAttributes = null; this._cache.dirty('any'); }
[ "function", "(", ")", "{", "var", "enabledAttributes", "=", "this", ".", "getEnabledAttributes", "(", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "enabledAttributes", ".", "length", ";", "i", "++", ")", "{", "this", ".", "dirtyAttribute"...
Mark attributes and indices in geometry needs to update. Usually called after you change the data in attributes.
[ "Mark", "attributes", "and", "indices", "in", "geometry", "needs", "to", "update", ".", "Usually", "called", "after", "you", "change", "the", "data", "in", "attributes", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/GeometryBase.js#L327-L336
6,819
pissang/claygl
src/GeometryBase.js
function (idx, out) { if (idx < this.triangleCount && idx >= 0) { if (!out) { out = []; } var indices = this.indices; out[0] = indices[idx * 3]; out[1] = indices[idx * 3 + 1]; out[2] = indices[idx * 3 + 2]; return out; } }
javascript
function (idx, out) { if (idx < this.triangleCount && idx >= 0) { if (!out) { out = []; } var indices = this.indices; out[0] = indices[idx * 3]; out[1] = indices[idx * 3 + 1]; out[2] = indices[idx * 3 + 2]; return out; } }
[ "function", "(", "idx", ",", "out", ")", "{", "if", "(", "idx", "<", "this", ".", "triangleCount", "&&", "idx", ">=", "0", ")", "{", "if", "(", "!", "out", ")", "{", "out", "=", "[", "]", ";", "}", "var", "indices", "=", "this", ".", "indices...
Get indices of triangle at given index. @param {number} idx @param {Array.<number>} out @return {Array.<number>}
[ "Get", "indices", "of", "triangle", "at", "given", "index", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/GeometryBase.js#L357-L368
6,820
pissang/claygl
src/GeometryBase.js
function (idx, arr) { var indices = this.indices; indices[idx * 3] = arr[0]; indices[idx * 3 + 1] = arr[1]; indices[idx * 3 + 2] = arr[2]; }
javascript
function (idx, arr) { var indices = this.indices; indices[idx * 3] = arr[0]; indices[idx * 3 + 1] = arr[1]; indices[idx * 3 + 2] = arr[2]; }
[ "function", "(", "idx", ",", "arr", ")", "{", "var", "indices", "=", "this", ".", "indices", ";", "indices", "[", "idx", "*", "3", "]", "=", "arr", "[", "0", "]", ";", "indices", "[", "idx", "*", "3", "+", "1", "]", "=", "arr", "[", "1", "]...
Set indices of triangle at given index. @param {number} idx @param {Array.<number>} arr
[ "Set", "indices", "of", "triangle", "at", "given", "index", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/GeometryBase.js#L375-L380
6,821
pissang/claygl
src/GeometryBase.js
function (array) { var value; var ArrayConstructor = this.vertexCount > 0xffff ? vendor.Uint32Array : vendor.Uint16Array; // Convert 2d array to flat if (array[0] && (array[0].length)) { var n = 0; var size = 3; value = new ArrayConstructor(array.length * size); for (var i = 0; i < array.length; i++) { for (var j = 0; j < size; j++) { value[n++] = array[i][j]; } } } else { value = new ArrayConstructor(array); } this.indices = value; }
javascript
function (array) { var value; var ArrayConstructor = this.vertexCount > 0xffff ? vendor.Uint32Array : vendor.Uint16Array; // Convert 2d array to flat if (array[0] && (array[0].length)) { var n = 0; var size = 3; value = new ArrayConstructor(array.length * size); for (var i = 0; i < array.length; i++) { for (var j = 0; j < size; j++) { value[n++] = array[i][j]; } } } else { value = new ArrayConstructor(array); } this.indices = value; }
[ "function", "(", "array", ")", "{", "var", "value", ";", "var", "ArrayConstructor", "=", "this", ".", "vertexCount", ">", "0xffff", "?", "vendor", ".", "Uint32Array", ":", "vendor", ".", "Uint16Array", ";", "// Convert 2d array to flat", "if", "(", "array", ...
Initialize indices from an array. @param {Array} array
[ "Initialize", "indices", "from", "an", "array", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/GeometryBase.js#L390-L411
6,822
pissang/claygl
src/GeometryBase.js
function () { var enabledAttributes = this._enabledAttributes; var attributeList = this._attributeList; // Cache if (enabledAttributes) { return enabledAttributes; } var result = []; var nVertex = this.vertexCount; for (var i = 0; i < attributeList.length; i++) { var name = attributeList[i]; var attrib = this.attributes[name]; if (attrib.value) { if (attrib.value.length === nVertex * attrib.size) { result.push(name); } } } this._enabledAttributes = result; return result; }
javascript
function () { var enabledAttributes = this._enabledAttributes; var attributeList = this._attributeList; // Cache if (enabledAttributes) { return enabledAttributes; } var result = []; var nVertex = this.vertexCount; for (var i = 0; i < attributeList.length; i++) { var name = attributeList[i]; var attrib = this.attributes[name]; if (attrib.value) { if (attrib.value.length === nVertex * attrib.size) { result.push(name); } } } this._enabledAttributes = result; return result; }
[ "function", "(", ")", "{", "var", "enabledAttributes", "=", "this", ".", "_enabledAttributes", ";", "var", "attributeList", "=", "this", ".", "_attributeList", ";", "// Cache", "if", "(", "enabledAttributes", ")", "{", "return", "enabledAttributes", ";", "}", ...
Get enabled attributes name list Attribute which has the same vertex number with position is treated as a enabled attribute @return {string[]}
[ "Get", "enabled", "attributes", "name", "list", "Attribute", "which", "has", "the", "same", "vertex", "number", "with", "position", "is", "treated", "as", "a", "enabled", "attribute" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/GeometryBase.js#L457-L481
6,823
pissang/claygl
src/GeometryBase.js
function (renderer) { var cache = this._cache; cache.use(renderer.__uid__); var chunks = cache.get('chunks'); if (chunks) { for (var c = 0; c < chunks.length; c++) { var chunk = chunks[c]; for (var k = 0; k < chunk.attributeBuffers.length; k++) { var attribs = chunk.attributeBuffers[k]; renderer.gl.deleteBuffer(attribs.buffer); } if (chunk.indicesBuffer) { renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer); } } } if (this.__vaoCache) { var vaoExt = renderer.getGLExtension('OES_vertex_array_object'); for (var id in this.__vaoCache) { var vao = this.__vaoCache[id].vao; if (vao) { vaoExt.deleteVertexArrayOES(vao); } } } this.__vaoCache = {}; cache.deleteContext(renderer.__uid__); }
javascript
function (renderer) { var cache = this._cache; cache.use(renderer.__uid__); var chunks = cache.get('chunks'); if (chunks) { for (var c = 0; c < chunks.length; c++) { var chunk = chunks[c]; for (var k = 0; k < chunk.attributeBuffers.length; k++) { var attribs = chunk.attributeBuffers[k]; renderer.gl.deleteBuffer(attribs.buffer); } if (chunk.indicesBuffer) { renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer); } } } if (this.__vaoCache) { var vaoExt = renderer.getGLExtension('OES_vertex_array_object'); for (var id in this.__vaoCache) { var vao = this.__vaoCache[id].vao; if (vao) { vaoExt.deleteVertexArrayOES(vao); } } } this.__vaoCache = {}; cache.deleteContext(renderer.__uid__); }
[ "function", "(", "renderer", ")", "{", "var", "cache", "=", "this", ".", "_cache", ";", "cache", ".", "use", "(", "renderer", ".", "__uid__", ")", ";", "var", "chunks", "=", "cache", ".", "get", "(", "'chunks'", ")", ";", "if", "(", "chunks", ")", ...
Dispose geometry data in GL context. @param {clay.Renderer} renderer
[ "Dispose", "geometry", "data", "in", "GL", "context", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/src/GeometryBase.js#L579-L610
6,824
pissang/claygl
dist/claygl.es.js
function (globalEasing) { var self = this; var clipCount = 0; var oneTrackDone = function() { clipCount--; if (clipCount === 0) { self._doneCallback(); } }; var lastClip; for (var propName in this._tracks) { var clip = createTrackClip( this, globalEasing, oneTrackDone, this._tracks[propName], propName, self._interpolater, self._maxTime ); if (clip) { this._clipList.push(clip); clipCount++; // If start after added to animation if (this.animation) { this.animation.addClip(clip); } lastClip = clip; } } // Add during callback on the last clip if (lastClip) { var oldOnFrame = lastClip.onframe; lastClip.onframe = function (target, percent) { oldOnFrame(target, percent); for (var i = 0; i < self._onframeList.length; i++) { self._onframeList[i](target, percent); } }; } if (!clipCount) { this._doneCallback(); } return this; }
javascript
function (globalEasing) { var self = this; var clipCount = 0; var oneTrackDone = function() { clipCount--; if (clipCount === 0) { self._doneCallback(); } }; var lastClip; for (var propName in this._tracks) { var clip = createTrackClip( this, globalEasing, oneTrackDone, this._tracks[propName], propName, self._interpolater, self._maxTime ); if (clip) { this._clipList.push(clip); clipCount++; // If start after added to animation if (this.animation) { this.animation.addClip(clip); } lastClip = clip; } } // Add during callback on the last clip if (lastClip) { var oldOnFrame = lastClip.onframe; lastClip.onframe = function (target, percent) { oldOnFrame(target, percent); for (var i = 0; i < self._onframeList.length; i++) { self._onframeList[i](target, percent); } }; } if (!clipCount) { this._doneCallback(); } return this; }
[ "function", "(", "globalEasing", ")", "{", "var", "self", "=", "this", ";", "var", "clipCount", "=", "0", ";", "var", "oneTrackDone", "=", "function", "(", ")", "{", "clipCount", "--", ";", "if", "(", "clipCount", "===", "0", ")", "{", "self", ".", ...
Start the animation @param {string|Function} easing @return {clay.animation.Animator} @memberOf clay.animation.Animator.prototype
[ "Start", "the", "animation" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L1064-L1111
6,825
pissang/claygl
dist/claygl.es.js
function () { for (var i = 0; i < this._clipList.length; i++) { var clip = this._clipList[i]; this.animation.removeClip(clip); } this._clipList = []; }
javascript
function () { for (var i = 0; i < this._clipList.length; i++) { var clip = this._clipList[i]; this.animation.removeClip(clip); } this._clipList = []; }
[ "function", "(", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "_clipList", ".", "length", ";", "i", "++", ")", "{", "var", "clip", "=", "this", ".", "_clipList", "[", "i", "]", ";", "this", ".", "animation", ".", "r...
Stop the animation @memberOf clay.animation.Animator.prototype
[ "Stop", "the", "animation" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L1117-L1123
6,826
pissang/claygl
dist/claygl.es.js
vec3lerp
function vec3lerp(out, a, b, t, oa, ob) { var ax = a[oa]; var ay = a[oa + 1]; var az = a[oa + 2]; out[0] = ax + t * (b[ob] - ax); out[1] = ay + t * (b[ob + 1] - ay); out[2] = az + t * (b[ob + 2] - az); return out; }
javascript
function vec3lerp(out, a, b, t, oa, ob) { var ax = a[oa]; var ay = a[oa + 1]; var az = a[oa + 2]; out[0] = ax + t * (b[ob] - ax); out[1] = ay + t * (b[ob + 1] - ay); out[2] = az + t * (b[ob + 2] - az); return out; }
[ "function", "vec3lerp", "(", "out", ",", "a", ",", "b", ",", "t", ",", "oa", ",", "ob", ")", "{", "var", "ax", "=", "a", "[", "oa", "]", ";", "var", "ay", "=", "a", "[", "oa", "+", "1", "]", ";", "var", "az", "=", "a", "[", "oa", "+", ...
Sampler clip is especially for the animation sampler in glTF Use Typed Array can reduce a lot of heap memory lerp function with offset in large array
[ "Sampler", "clip", "is", "especially", "for", "the", "animation", "sampler", "in", "glTF", "Use", "Typed", "Array", "can", "reduce", "a", "lot", "of", "heap", "memory", "lerp", "function", "with", "offset", "in", "large", "array" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5168-L5177
6,827
pissang/claygl
dist/claygl.es.js
function (opts) { opts = opts || {}; this.name = opts.name || ''; /** * @param {clay.Node} */ this.target = opts.target || null; /** * @type {Array} */ this.position = vec3.create(); /** * Rotation is represented by a quaternion * @type {Array} */ this.rotation = quat.create(); /** * @type {Array} */ this.scale = vec3.fromValues(1, 1, 1); this.channels = { time: null, position: null, rotation: null, scale: null }; this._cacheKey = 0; this._cacheTime = 0; }
javascript
function (opts) { opts = opts || {}; this.name = opts.name || ''; /** * @param {clay.Node} */ this.target = opts.target || null; /** * @type {Array} */ this.position = vec3.create(); /** * Rotation is represented by a quaternion * @type {Array} */ this.rotation = quat.create(); /** * @type {Array} */ this.scale = vec3.fromValues(1, 1, 1); this.channels = { time: null, position: null, rotation: null, scale: null }; this._cacheKey = 0; this._cacheTime = 0; }
[ "function", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "name", "=", "opts", ".", "name", "||", "''", ";", "/**\n * @param {clay.Node}\n */", "this", ".", "target", "=", "opts", ".", "target", "||", "null", ";"...
SamplerTrack manages `position`, `rotation`, `scale` tracks in animation of single scene node. @constructor @alias clay.animation.SamplerTrack @param {Object} [opts] @param {string} [opts.name] Track name @param {clay.Node} [opts.target] Target node's transform will updated automatically
[ "SamplerTrack", "manages", "position", "rotation", "scale", "tracks", "in", "animation", "of", "single", "scene", "node", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5229-L5260
6,828
pissang/claygl
dist/claygl.es.js
derive
function derive(makeDefaultOpt, initialize/*optional*/, proto/*optional*/) { if (typeof initialize == 'object') { proto = initialize; initialize = null; } var _super = this; var propList; if (!(makeDefaultOpt instanceof Function)) { // Optimize the property iterate if it have been fixed propList = []; for (var propName in makeDefaultOpt) { if (makeDefaultOpt.hasOwnProperty(propName)) { propList.push(propName); } } } var sub = function(options) { // call super constructor _super.apply(this, arguments); if (makeDefaultOpt instanceof Function) { // Invoke makeDefaultOpt each time if it is a function, So we can make sure each // property in the object will not be shared by mutiple instances extend(this, makeDefaultOpt.call(this, options)); } else { extendWithPropList(this, makeDefaultOpt, propList); } if (this.constructor === sub) { // Initialize function will be called in the order of inherit var initializers = sub.__initializers__; for (var i = 0; i < initializers.length; i++) { initializers[i].apply(this, arguments); } } }; // save super constructor sub.__super__ = _super; // Initialize function will be called after all the super constructor is called if (!_super.__initializers__) { sub.__initializers__ = []; } else { sub.__initializers__ = _super.__initializers__.slice(); } if (initialize) { sub.__initializers__.push(initialize); } var Ctor = function() {}; Ctor.prototype = _super.prototype; sub.prototype = new Ctor(); sub.prototype.constructor = sub; extend(sub.prototype, proto); // extend the derive method as a static method; sub.extend = _super.extend; // DEPCRATED sub.derive = _super.extend; return sub; }
javascript
function derive(makeDefaultOpt, initialize/*optional*/, proto/*optional*/) { if (typeof initialize == 'object') { proto = initialize; initialize = null; } var _super = this; var propList; if (!(makeDefaultOpt instanceof Function)) { // Optimize the property iterate if it have been fixed propList = []; for (var propName in makeDefaultOpt) { if (makeDefaultOpt.hasOwnProperty(propName)) { propList.push(propName); } } } var sub = function(options) { // call super constructor _super.apply(this, arguments); if (makeDefaultOpt instanceof Function) { // Invoke makeDefaultOpt each time if it is a function, So we can make sure each // property in the object will not be shared by mutiple instances extend(this, makeDefaultOpt.call(this, options)); } else { extendWithPropList(this, makeDefaultOpt, propList); } if (this.constructor === sub) { // Initialize function will be called in the order of inherit var initializers = sub.__initializers__; for (var i = 0; i < initializers.length; i++) { initializers[i].apply(this, arguments); } } }; // save super constructor sub.__super__ = _super; // Initialize function will be called after all the super constructor is called if (!_super.__initializers__) { sub.__initializers__ = []; } else { sub.__initializers__ = _super.__initializers__.slice(); } if (initialize) { sub.__initializers__.push(initialize); } var Ctor = function() {}; Ctor.prototype = _super.prototype; sub.prototype = new Ctor(); sub.prototype.constructor = sub; extend(sub.prototype, proto); // extend the derive method as a static method; sub.extend = _super.extend; // DEPCRATED sub.derive = _super.extend; return sub; }
[ "function", "derive", "(", "makeDefaultOpt", ",", "initialize", "/*optional*/", ",", "proto", "/*optional*/", ")", "{", "if", "(", "typeof", "initialize", "==", "'object'", ")", "{", "proto", "=", "initialize", ";", "initialize", "=", "null", ";", "}", "var"...
Extend a sub class from base class @param {object|Function} makeDefaultOpt default option of this sub class, method of the sub can use this.xxx to access this option @param {Function} [initialize] Initialize after the sub class is instantiated @param {Object} [proto] Prototype methods/properties of the sub class @memberOf clay.core.mixin.extend @return {Function}
[ "Extend", "a", "sub", "class", "from", "base", "class" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5556-L5623
6,829
pissang/claygl
dist/claygl.es.js
function(name, action, context) { if (!name || !action) { return; } var handlers = this.__handlers__ || (this.__handlers__={}); if (!handlers[name]) { handlers[name] = []; } else { if (this.has(name, action)) { return; } } var handler = new Handler(action, context || this); handlers[name].push(handler); return this; }
javascript
function(name, action, context) { if (!name || !action) { return; } var handlers = this.__handlers__ || (this.__handlers__={}); if (!handlers[name]) { handlers[name] = []; } else { if (this.has(name, action)) { return; } } var handler = new Handler(action, context || this); handlers[name].push(handler); return this; }
[ "function", "(", "name", ",", "action", ",", "context", ")", "{", "if", "(", "!", "name", "||", "!", "action", ")", "{", "return", ";", "}", "var", "handlers", "=", "this", ".", "__handlers__", "||", "(", "this", ".", "__handlers__", "=", "{", "}",...
Register event handler @param {string} name @param {Function} action @param {Object} [context] @chainable
[ "Register", "event", "handler" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5719-L5736
6,830
pissang/claygl
dist/claygl.es.js
function(name, action, context) { if (!name || !action) { return; } var self = this; function wrapper() { self.off(name, wrapper); action.apply(this, arguments); } return this.on(name, wrapper, context); }
javascript
function(name, action, context) { if (!name || !action) { return; } var self = this; function wrapper() { self.off(name, wrapper); action.apply(this, arguments); } return this.on(name, wrapper, context); }
[ "function", "(", "name", ",", "action", ",", "context", ")", "{", "if", "(", "!", "name", "||", "!", "action", ")", "{", "return", ";", "}", "var", "self", "=", "this", ";", "function", "wrapper", "(", ")", "{", "self", ".", "off", "(", "name", ...
Register event, event will only be triggered once and then removed @param {string} name @param {Function} action @param {Object} [context] @chainable
[ "Register", "event", "event", "will", "only", "be", "triggered", "once", "and", "then", "removed" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5745-L5755
6,831
pissang/claygl
dist/claygl.es.js
function(name, action) { var handlers = this.__handlers__; if (! handlers || ! handlers[name]) { return false; } var hdls = handlers[name]; for (var i = 0; i < hdls.length; i++) { if (hdls[i].action === action) { return true; } } }
javascript
function(name, action) { var handlers = this.__handlers__; if (! handlers || ! handlers[name]) { return false; } var hdls = handlers[name]; for (var i = 0; i < hdls.length; i++) { if (hdls[i].action === action) { return true; } } }
[ "function", "(", "name", ",", "action", ")", "{", "var", "handlers", "=", "this", ".", "__handlers__", ";", "if", "(", "!", "handlers", "||", "!", "handlers", "[", "name", "]", ")", "{", "return", "false", ";", "}", "var", "hdls", "=", "handlers", ...
If registered the event handler @param {string} name @param {Function} action @return {boolean}
[ "If", "registered", "the", "event", "handler" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5841-L5854
6,832
pissang/claygl
dist/claygl.es.js
function (path, basePath) { if (!basePath || path.match(/^\//)) { return path; } var pathParts = path.split('/'); var basePathParts = basePath.split('/'); var item = pathParts[0]; while(item === '.' || item === '..') { if (item === '..') { basePathParts.pop(); } pathParts.shift(); item = pathParts[0]; } return basePathParts.join('/') + '/' + pathParts.join('/'); }
javascript
function (path, basePath) { if (!basePath || path.match(/^\//)) { return path; } var pathParts = path.split('/'); var basePathParts = basePath.split('/'); var item = pathParts[0]; while(item === '.' || item === '..') { if (item === '..') { basePathParts.pop(); } pathParts.shift(); item = pathParts[0]; } return basePathParts.join('/') + '/' + pathParts.join('/'); }
[ "function", "(", "path", ",", "basePath", ")", "{", "if", "(", "!", "basePath", "||", "path", ".", "match", "(", "/", "^\\/", "/", ")", ")", "{", "return", "path", ";", "}", "var", "pathParts", "=", "path", ".", "split", "(", "'/'", ")", ";", "...
Relative path to absolute path @param {string} path @param {string} basePath @return {string} @memberOf clay.core.util
[ "Relative", "path", "to", "absolute", "path" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5883-L5899
6,833
pissang/claygl
dist/claygl.es.js
function (target, source) { if (source) { for (var propName in source) { if (target[propName] === undefined) { target[propName] = source[propName]; } } } return target; }
javascript
function (target, source) { if (source) { for (var propName in source) { if (target[propName] === undefined) { target[propName] = source[propName]; } } } return target; }
[ "function", "(", "target", ",", "source", ")", "{", "if", "(", "source", ")", "{", "for", "(", "var", "propName", "in", "source", ")", "{", "if", "(", "target", "[", "propName", "]", "===", "undefined", ")", "{", "target", "[", "propName", "]", "="...
Extend properties to target if not exist. @param {Object} target @param {Object} source @return {Object} @memberOf clay.core.util
[ "Extend", "properties", "to", "target", "if", "not", "exist", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L5926-L5935
6,834
pissang/claygl
dist/claygl.es.js
function () { var self = this; this._running = true; this._time = Date.now(); this._pausedTime = 0; var requestAnimationFrame = vendor.requestAnimationFrame; function step() { if (self._running) { requestAnimationFrame(step); if (!self._paused) { self._update(); } } } requestAnimationFrame(step); }
javascript
function () { var self = this; this._running = true; this._time = Date.now(); this._pausedTime = 0; var requestAnimationFrame = vendor.requestAnimationFrame; function step() { if (self._running) { requestAnimationFrame(step); if (!self._paused) { self._update(); } } } requestAnimationFrame(step); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "this", ".", "_running", "=", "true", ";", "this", ".", "_time", "=", "Date", ".", "now", "(", ")", ";", "this", ".", "_pausedTime", "=", "0", ";", "var", "requestAnimationFrame", "=", "ve...
Start running animation
[ "Start", "running", "animation" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L6330-L6353
6,835
pissang/claygl
dist/claygl.es.js
function (target, options) { options = options || {}; var animator = new Animator( target, options.loop, options.getter, options.setter, options.interpolater ); animator.animation = this; return animator; }
javascript
function (target, options) { options = options || {}; var animator = new Animator( target, options.loop, options.getter, options.setter, options.interpolater ); animator.animation = this; return animator; }
[ "function", "(", "target", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "animator", "=", "new", "Animator", "(", "target", ",", "options", ".", "loop", ",", "options", ".", "getter", ",", "options", ".", "setter", ...
Create an animator @param {Object} target @param {Object} [options] @param {boolean} [options.loop] @param {Function} [options.getter] @param {Function} [options.setter] @param {Function} [options.interpolater] @return {clay.animation.Animator}
[ "Create", "an", "animator" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L6397-L6408
6,836
pissang/claygl
dist/claygl.es.js
function (symbol, value) { if (value === undefined) { console.warn('Uniform value "' + symbol + '" is undefined'); } var uniform = this.uniforms[symbol]; if (uniform) { if (typeof value === 'string') { // Try to parse as a color. Invalid color string will return null. value = parseColor$1(value) || value; } uniform.value = value; if (this.autoUpdateTextureStatus && uniform.type === 't') { if (value) { this.enableTexture(symbol); } else { this.disableTexture(symbol); } } } }
javascript
function (symbol, value) { if (value === undefined) { console.warn('Uniform value "' + symbol + '" is undefined'); } var uniform = this.uniforms[symbol]; if (uniform) { if (typeof value === 'string') { // Try to parse as a color. Invalid color string will return null. value = parseColor$1(value) || value; } uniform.value = value; if (this.autoUpdateTextureStatus && uniform.type === 't') { if (value) { this.enableTexture(symbol); } else { this.disableTexture(symbol); } } } }
[ "function", "(", "symbol", ",", "value", ")", "{", "if", "(", "value", "===", "undefined", ")", "{", "console", ".", "warn", "(", "'Uniform value \"'", "+", "symbol", "+", "'\" is undefined'", ")", ";", "}", "var", "uniform", "=", "this", ".", "uniforms"...
Set material uniform @example mat.setUniform('color', [1, 1, 1, 1]); @param {string} symbol @param {number|array|clay.Texture|ArrayBufferView} value
[ "Set", "material", "uniform" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L8133-L8156
6,837
pissang/claygl
dist/claygl.es.js
function (symbol, value) { if (typeof(symbol) === 'object') { for (var key in symbol) { var val = symbol[key]; this.setUniform(key, val); } } else { this.setUniform(symbol, value); } }
javascript
function (symbol, value) { if (typeof(symbol) === 'object') { for (var key in symbol) { var val = symbol[key]; this.setUniform(key, val); } } else { this.setUniform(symbol, value); } }
[ "function", "(", "symbol", ",", "value", ")", "{", "if", "(", "typeof", "(", "symbol", ")", "===", "'object'", ")", "{", "for", "(", "var", "key", "in", "symbol", ")", "{", "var", "val", "=", "symbol", "[", "key", "]", ";", "this", ".", "setUnifo...
Alias of setUniform and setUniforms @param {object|string} symbol @param {number|array|clay.Texture|ArrayBufferView} [value]
[ "Alias", "of", "setUniform", "and", "setUniforms" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L8188-L8198
6,838
pissang/claygl
dist/claygl.es.js
function(shader, keepStatus) { var originalUniforms = this.uniforms; // Ignore if uniform can use in shader. this.uniforms = shader.createUniforms(); this.shader = shader; var uniforms = this.uniforms; this._enabledUniforms = Object.keys(uniforms); // Make sure uniforms are set in same order to avoid texture slot wrong this._enabledUniforms.sort(); this._textureUniforms = this._enabledUniforms.filter(function (uniformName) { var type = this.uniforms[uniformName].type; return type === 't' || type === 'tv'; }, this); var originalVertexDefines = this.vertexDefines; var originalFragmentDefines = this.fragmentDefines; this.vertexDefines = util$1.clone(shader.vertexDefines); this.fragmentDefines = util$1.clone(shader.fragmentDefines); if (keepStatus) { for (var symbol in originalUniforms) { if (uniforms[symbol]) { uniforms[symbol].value = originalUniforms[symbol].value; } } util$1.defaults(this.vertexDefines, originalVertexDefines); util$1.defaults(this.fragmentDefines, originalFragmentDefines); } var textureStatus = {}; for (var key in shader.textures) { textureStatus[key] = { shaderType: shader.textures[key].shaderType, type: shader.textures[key].type, enabled: (keepStatus && this._textureStatus[key]) ? this._textureStatus[key].enabled : false }; } this._textureStatus = textureStatus; this._programKey = ''; }
javascript
function(shader, keepStatus) { var originalUniforms = this.uniforms; // Ignore if uniform can use in shader. this.uniforms = shader.createUniforms(); this.shader = shader; var uniforms = this.uniforms; this._enabledUniforms = Object.keys(uniforms); // Make sure uniforms are set in same order to avoid texture slot wrong this._enabledUniforms.sort(); this._textureUniforms = this._enabledUniforms.filter(function (uniformName) { var type = this.uniforms[uniformName].type; return type === 't' || type === 'tv'; }, this); var originalVertexDefines = this.vertexDefines; var originalFragmentDefines = this.fragmentDefines; this.vertexDefines = util$1.clone(shader.vertexDefines); this.fragmentDefines = util$1.clone(shader.fragmentDefines); if (keepStatus) { for (var symbol in originalUniforms) { if (uniforms[symbol]) { uniforms[symbol].value = originalUniforms[symbol].value; } } util$1.defaults(this.vertexDefines, originalVertexDefines); util$1.defaults(this.fragmentDefines, originalFragmentDefines); } var textureStatus = {}; for (var key in shader.textures) { textureStatus[key] = { shaderType: shader.textures[key].shaderType, type: shader.textures[key].type, enabled: (keepStatus && this._textureStatus[key]) ? this._textureStatus[key].enabled : false }; } this._textureStatus = textureStatus; this._programKey = ''; }
[ "function", "(", "shader", ",", "keepStatus", ")", "{", "var", "originalUniforms", "=", "this", ".", "uniforms", ";", "// Ignore if uniform can use in shader.", "this", ".", "uniforms", "=", "shader", ".", "createUniforms", "(", ")", ";", "this", ".", "shader", ...
Attach a shader instance @param {clay.Shader} shader @param {boolean} keepStatus If try to keep uniform and texture
[ "Attach", "a", "shader", "instance" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L8215-L8260
6,839
pissang/claygl
dist/claygl.es.js
function () { var material = new this.constructor({ name: this.name, shader: this.shader }); for (var symbol in this.uniforms) { material.uniforms[symbol].value = this.uniforms[symbol].value; } material.depthTest = this.depthTest; material.depthMask = this.depthMask; material.transparent = this.transparent; material.blend = this.blend; material.vertexDefines = util$1.clone(this.vertexDefines); material.fragmentDefines = util$1.clone(this.fragmentDefines); material.enableTexture(this.getEnabledTextures()); material.precision = this.precision; return material; }
javascript
function () { var material = new this.constructor({ name: this.name, shader: this.shader }); for (var symbol in this.uniforms) { material.uniforms[symbol].value = this.uniforms[symbol].value; } material.depthTest = this.depthTest; material.depthMask = this.depthMask; material.transparent = this.transparent; material.blend = this.blend; material.vertexDefines = util$1.clone(this.vertexDefines); material.fragmentDefines = util$1.clone(this.fragmentDefines); material.enableTexture(this.getEnabledTextures()); material.precision = this.precision; return material; }
[ "function", "(", ")", "{", "var", "material", "=", "new", "this", ".", "constructor", "(", "{", "name", ":", "this", ".", "name", ",", "shader", ":", "this", ".", "shader", "}", ")", ";", "for", "(", "var", "symbol", "in", "this", ".", "uniforms", ...
Clone a new material and keep uniforms, shader will not be cloned @return {clay.Material}
[ "Clone", "a", "new", "material", "and", "keep", "uniforms", "shader", "will", "not", "be", "cloned" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L8266-L8285
6,840
pissang/claygl
dist/claygl.es.js
function () { var enabledTextures = []; var textureStatus = this._textureStatus; for (var symbol in textureStatus) { if (textureStatus[symbol].enabled) { enabledTextures.push(symbol); } } return enabledTextures; }
javascript
function () { var enabledTextures = []; var textureStatus = this._textureStatus; for (var symbol in textureStatus) { if (textureStatus[symbol].enabled) { enabledTextures.push(symbol); } } return enabledTextures; }
[ "function", "(", ")", "{", "var", "enabledTextures", "=", "[", "]", ";", "var", "textureStatus", "=", "this", ".", "_textureStatus", ";", "for", "(", "var", "symbol", "in", "textureStatus", ")", "{", "if", "(", "textureStatus", "[", "symbol", "]", ".", ...
Get all enabled textures @return {string[]}
[ "Get", "all", "enabled", "textures" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L8459-L8468
6,841
pissang/claygl
dist/claygl.es.js
checkShaderErrorMsg
function checkShaderErrorMsg(_gl, shader, shaderString) { if (!_gl.getShaderParameter(shader, _gl.COMPILE_STATUS)) { return [_gl.getShaderInfoLog(shader), addLineNumbers(shaderString)].join('\n'); } }
javascript
function checkShaderErrorMsg(_gl, shader, shaderString) { if (!_gl.getShaderParameter(shader, _gl.COMPILE_STATUS)) { return [_gl.getShaderInfoLog(shader), addLineNumbers(shaderString)].join('\n'); } }
[ "function", "checkShaderErrorMsg", "(", "_gl", ",", "shader", ",", "shaderString", ")", "{", "if", "(", "!", "_gl", ".", "getShaderParameter", "(", "shader", ",", "_gl", ".", "COMPILE_STATUS", ")", ")", "{", "return", "[", "_gl", ".", "getShaderInfoLog", "...
Return true or error msg if error happened
[ "Return", "true", "or", "error", "msg", "if", "error", "happened" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L8508-L8512
6,842
pissang/claygl
dist/claygl.es.js
function () { var uniforms = {}; for (var symbol in this.uniformTemplates){ var uniformTpl = this.uniformTemplates[symbol]; uniforms[symbol] = { type: uniformTpl.type, value: uniformTpl.value() }; } return uniforms; }
javascript
function () { var uniforms = {}; for (var symbol in this.uniformTemplates){ var uniformTpl = this.uniformTemplates[symbol]; uniforms[symbol] = { type: uniformTpl.type, value: uniformTpl.value() }; } return uniforms; }
[ "function", "(", ")", "{", "var", "uniforms", "=", "{", "}", ";", "for", "(", "var", "symbol", "in", "this", ".", "uniformTemplates", ")", "{", "var", "uniformTpl", "=", "this", ".", "uniformTemplates", "[", "symbol", "]", ";", "uniforms", "[", "symbol...
Create a new uniform instance for material
[ "Create", "a", "new", "uniform", "instance", "for", "material" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L9386-L9398
6,843
pissang/claygl
dist/claygl.es.js
function () { var code = shaderCodeCache[this._shaderID]; var shader = new Shader(code.vertex, code.fragment); return shader; }
javascript
function () { var code = shaderCodeCache[this._shaderID]; var shader = new Shader(code.vertex, code.fragment); return shader; }
[ "function", "(", ")", "{", "var", "code", "=", "shaderCodeCache", "[", "this", ".", "_shaderID", "]", ";", "var", "shader", "=", "new", "Shader", "(", "code", ".", "vertex", ",", "code", ".", "fragment", ")", ";", "return", "shader", ";", "}" ]
Clone a new shader @return {clay.Shader}
[ "Clone", "a", "new", "shader" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L9577-L9581
6,844
pissang/claygl
dist/claygl.es.js
function () { if (this._clearStack.length > 0) { var opt = this._clearStack.pop(); this.clearColor = opt.clearColor; this.clearBit = opt.clearBit; } }
javascript
function () { if (this._clearStack.length > 0) { var opt = this._clearStack.pop(); this.clearColor = opt.clearColor; this.clearBit = opt.clearBit; } }
[ "function", "(", ")", "{", "if", "(", "this", ".", "_clearStack", ".", "length", ">", "0", ")", "{", "var", "opt", "=", "this", ".", "_clearStack", ".", "pop", "(", ")", ";", "this", ".", "clearColor", "=", "opt", ".", "clearColor", ";", "this", ...
Pop clear from stack, restore in the renderer
[ "Pop", "clear", "from", "stack", "restore", "in", "the", "renderer" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L11011-L11017
6,845
pissang/claygl
dist/claygl.es.js
function(root, disposeGeometry, disposeTexture) { // Dettached from parent if (root.getParent()) { root.getParent().remove(root); } var disposedMap = {}; root.traverse(function(node) { var material = node.material; if (node.geometry && disposeGeometry) { node.geometry.dispose(this); } if (disposeTexture && material && !disposedMap[material.__uid__]) { var textureUniforms = material.getTextureUniforms(); for (var u = 0; u < textureUniforms.length; u++) { var uniformName = textureUniforms[u]; var val = material.uniforms[uniformName].value; var uniformType = material.uniforms[uniformName].type; if (!val) { continue; } if (uniformType === 't') { val.dispose && val.dispose(this); } else if (uniformType === 'tv') { for (var k = 0; k < val.length; k++) { if (val[k]) { val[k].dispose && val[k].dispose(this); } } } } disposedMap[material.__uid__] = true; } // Particle system and AmbientCubemap light need to dispose if (node.dispose) { node.dispose(this); } }, this); }
javascript
function(root, disposeGeometry, disposeTexture) { // Dettached from parent if (root.getParent()) { root.getParent().remove(root); } var disposedMap = {}; root.traverse(function(node) { var material = node.material; if (node.geometry && disposeGeometry) { node.geometry.dispose(this); } if (disposeTexture && material && !disposedMap[material.__uid__]) { var textureUniforms = material.getTextureUniforms(); for (var u = 0; u < textureUniforms.length; u++) { var uniformName = textureUniforms[u]; var val = material.uniforms[uniformName].value; var uniformType = material.uniforms[uniformName].type; if (!val) { continue; } if (uniformType === 't') { val.dispose && val.dispose(this); } else if (uniformType === 'tv') { for (var k = 0; k < val.length; k++) { if (val[k]) { val[k].dispose && val[k].dispose(this); } } } } disposedMap[material.__uid__] = true; } // Particle system and AmbientCubemap light need to dispose if (node.dispose) { node.dispose(this); } }, this); }
[ "function", "(", "root", ",", "disposeGeometry", ",", "disposeTexture", ")", "{", "// Dettached from parent", "if", "(", "root", ".", "getParent", "(", ")", ")", "{", "root", ".", "getParent", "(", ")", ".", "remove", "(", "root", ")", ";", "}", "var", ...
Dispose given node, including all geometries, textures and shaders attached on it or its descendant @param {clay.Node} node @param {boolean} [disposeGeometry=false] If dispose the geometries used in the descendant mesh @param {boolean} [disposeTexture=false] If dispose the textures used in the descendant mesh
[ "Dispose", "given", "node", "including", "all", "geometries", "textures", "and", "shaders", "attached", "on", "it", "or", "its", "descendant" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L11816-L11854
6,846
pissang/claygl
dist/claygl.es.js
function (m) { var v = this.array; m = m.array; // Perspective projection if (m[15] === 0) { var w = -1 / v[2]; v[0] = m[0] * v[0] * w; v[1] = m[5] * v[1] * w; v[2] = (m[10] * v[2] + m[14]) * w; } else { v[0] = m[0] * v[0] + m[12]; v[1] = m[5] * v[1] + m[13]; v[2] = m[10] * v[2] + m[14]; } this._dirty = true; return this; }
javascript
function (m) { var v = this.array; m = m.array; // Perspective projection if (m[15] === 0) { var w = -1 / v[2]; v[0] = m[0] * v[0] * w; v[1] = m[5] * v[1] * w; v[2] = (m[10] * v[2] + m[14]) * w; } else { v[0] = m[0] * v[0] + m[12]; v[1] = m[5] * v[1] + m[13]; v[2] = m[10] * v[2] + m[14]; } this._dirty = true; return this; }
[ "function", "(", "m", ")", "{", "var", "v", "=", "this", ".", "array", ";", "m", "=", "m", ".", "array", ";", "// Perspective projection", "if", "(", "m", "[", "15", "]", "===", "0", ")", "{", "var", "w", "=", "-", "1", "/", "v", "[", "2", ...
Trasnform self into projection space with m @param {clay.Matrix4} m @return {clay.Vector3}
[ "Trasnform", "self", "into", "projection", "space", "with", "m" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L12390-L12409
6,847
pissang/claygl
dist/claygl.es.js
function (x, y, z, w) { this.array[0] = x; this.array[1] = y; this.array[2] = z; this.array[3] = w; this._dirty = true; return this; }
javascript
function (x, y, z, w) { this.array[0] = x; this.array[1] = y; this.array[2] = z; this.array[3] = w; this._dirty = true; return this; }
[ "function", "(", "x", ",", "y", ",", "z", ",", "w", ")", "{", "this", ".", "array", "[", "0", "]", "=", "x", ";", "this", ".", "array", "[", "1", "]", "=", "y", ";", "this", ".", "array", "[", "2", "]", "=", "z", ";", "this", ".", "arra...
Set x, y and z components @param {number} x @param {number} y @param {number} z @param {number} w @return {clay.Quaternion}
[ "Set", "x", "y", "and", "z", "components" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L13079-L13086
6,848
pissang/claygl
dist/claygl.es.js
function (arr) { this.array[0] = arr[0]; this.array[1] = arr[1]; this.array[2] = arr[2]; this.array[3] = arr[3]; this._dirty = true; return this; }
javascript
function (arr) { this.array[0] = arr[0]; this.array[1] = arr[1]; this.array[2] = arr[2]; this.array[3] = arr[3]; this._dirty = true; return this; }
[ "function", "(", "arr", ")", "{", "this", ".", "array", "[", "0", "]", "=", "arr", "[", "0", "]", ";", "this", ".", "array", "[", "1", "]", "=", "arr", "[", "1", "]", ";", "this", ".", "array", "[", "2", "]", "=", "arr", "[", "2", "]", ...
Set x, y, z and w components from array @param {Float32Array|number[]} arr @return {clay.Quaternion}
[ "Set", "x", "y", "z", "and", "w", "components", "from", "array" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L13093-L13101
6,849
pissang/claygl
dist/claygl.es.js
function (view, right, up) { quat.setAxes(this.array, view.array, right.array, up.array); this._dirty = true; return this; }
javascript
function (view, right, up) { quat.setAxes(this.array, view.array, right.array, up.array); this._dirty = true; return this; }
[ "function", "(", "view", ",", "right", ",", "up", ")", "{", "quat", ".", "setAxes", "(", "this", ".", "array", ",", "view", ".", "array", ",", "right", ".", "array", ",", "up", ".", "array", ")", ";", "this", ".", "_dirty", "=", "true", ";", "r...
Sets self with values corresponding to the given axes @param {clay.Vector3} view @param {clay.Vector3} right @param {clay.Vector3} up @return {clay.Quaternion}
[ "Sets", "self", "with", "values", "corresponding", "to", "the", "given", "axes" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L13326-L13330
6,850
pissang/claygl
dist/claygl.es.js
function (arr) { for (var i = 0; i < this.array.length; i++) { this.array[i] = arr[i]; } this._dirty = true; return this; }
javascript
function (arr) { for (var i = 0; i < this.array.length; i++) { this.array[i] = arr[i]; } this._dirty = true; return this; }
[ "function", "(", "arr", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "array", ".", "length", ";", "i", "++", ")", "{", "this", ".", "array", "[", "i", "]", "=", "arr", "[", "i", "]", ";", "}", "this", ".", "_dir...
Set components from array @param {Float32Array|number[]} arr
[ "Set", "components", "from", "array" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L13816-L13822
6,851
pissang/claygl
dist/claygl.es.js
function(q, v) { mat4.fromRotationTranslation(this.array, q.array, v.array); this._dirty = true; return this; }
javascript
function(q, v) { mat4.fromRotationTranslation(this.array, q.array, v.array); this._dirty = true; return this; }
[ "function", "(", "q", ",", "v", ")", "{", "mat4", ".", "fromRotationTranslation", "(", "this", ".", "array", ",", "q", ".", "array", ",", "v", ".", "array", ")", ";", "this", ".", "_dirty", "=", "true", ";", "return", "this", ";", "}" ]
Set from a quaternion rotation and a vector translation @param {clay.Quaternion} q @param {clay.Vector3} v @return {clay.Matrix4}
[ "Set", "from", "a", "quaternion", "rotation", "and", "a", "vector", "translation" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L13877-L13881
6,852
pissang/claygl
dist/claygl.es.js
function(rad, axis) { mat4.rotate(this.array, this.array, rad, axis.array); this._dirty = true; return this; }
javascript
function(rad, axis) { mat4.rotate(this.array, this.array, rad, axis.array); this._dirty = true; return this; }
[ "function", "(", "rad", ",", "axis", ")", "{", "mat4", ".", "rotate", "(", "this", ".", "array", ",", "this", ".", "array", ",", "rad", ",", "axis", ".", "array", ")", ";", "this", ".", "_dirty", "=", "true", ";", "return", "this", ";", "}" ]
Rotate self by rad about axis. Equal to right-multiply a rotaion matrix @param {number} rad @param {clay.Vector3} axis @return {clay.Matrix4}
[ "Rotate", "self", "by", "rad", "about", "axis", ".", "Equal", "to", "right", "-", "multiply", "a", "rotaion", "matrix" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14023-L14027
6,853
pissang/claygl
dist/claygl.es.js
function (min, max) { /** * Minimum coords of bounding box * @type {clay.Vector3} */ this.min = min || new Vector3(Infinity, Infinity, Infinity); /** * Maximum coords of bounding box * @type {clay.Vector3} */ this.max = max || new Vector3(-Infinity, -Infinity, -Infinity); this.vertices = null; }
javascript
function (min, max) { /** * Minimum coords of bounding box * @type {clay.Vector3} */ this.min = min || new Vector3(Infinity, Infinity, Infinity); /** * Maximum coords of bounding box * @type {clay.Vector3} */ this.max = max || new Vector3(-Infinity, -Infinity, -Infinity); this.vertices = null; }
[ "function", "(", "min", ",", "max", ")", "{", "/**\n * Minimum coords of bounding box\n * @type {clay.Vector3}\n */", "this", ".", "min", "=", "min", "||", "new", "Vector3", "(", "Infinity", ",", "Infinity", ",", "Infinity", ")", ";", "/**\n * Maximum ...
Axis aligned bounding box @constructor @alias clay.BoundingBox @param {clay.Vector3} [min] @param {clay.Vector3} [max]
[ "Axis", "aligned", "bounding", "box" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14504-L14519
6,854
pissang/claygl
dist/claygl.es.js
function (vertices) { if (vertices.length > 0) { var min = this.min; var max = this.max; var minArr = min.array; var maxArr = max.array; vec3Copy(minArr, vertices[0]); vec3Copy(maxArr, vertices[0]); for (var i = 1; i < vertices.length; i++) { var vertex = vertices[i]; if (vertex[0] < minArr[0]) { minArr[0] = vertex[0]; } if (vertex[1] < minArr[1]) { minArr[1] = vertex[1]; } if (vertex[2] < minArr[2]) { minArr[2] = vertex[2]; } if (vertex[0] > maxArr[0]) { maxArr[0] = vertex[0]; } if (vertex[1] > maxArr[1]) { maxArr[1] = vertex[1]; } if (vertex[2] > maxArr[2]) { maxArr[2] = vertex[2]; } } min._dirty = true; max._dirty = true; } }
javascript
function (vertices) { if (vertices.length > 0) { var min = this.min; var max = this.max; var minArr = min.array; var maxArr = max.array; vec3Copy(minArr, vertices[0]); vec3Copy(maxArr, vertices[0]); for (var i = 1; i < vertices.length; i++) { var vertex = vertices[i]; if (vertex[0] < minArr[0]) { minArr[0] = vertex[0]; } if (vertex[1] < minArr[1]) { minArr[1] = vertex[1]; } if (vertex[2] < minArr[2]) { minArr[2] = vertex[2]; } if (vertex[0] > maxArr[0]) { maxArr[0] = vertex[0]; } if (vertex[1] > maxArr[1]) { maxArr[1] = vertex[1]; } if (vertex[2] > maxArr[2]) { maxArr[2] = vertex[2]; } } min._dirty = true; max._dirty = true; } }
[ "function", "(", "vertices", ")", "{", "if", "(", "vertices", ".", "length", ">", "0", ")", "{", "var", "min", "=", "this", ".", "min", ";", "var", "max", "=", "this", ".", "max", ";", "var", "minArr", "=", "min", ".", "array", ";", "var", "max...
Update min and max coords from a vertices array @param {array} vertices
[ "Update", "min", "and", "max", "coords", "from", "a", "vertices", "array" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14528-L14550
6,855
pissang/claygl
dist/claygl.es.js
function (bbox) { var min = this.min; var max = this.max; vec3.min(min.array, min.array, bbox.min.array); vec3.max(max.array, max.array, bbox.max.array); min._dirty = true; max._dirty = true; return this; }
javascript
function (bbox) { var min = this.min; var max = this.max; vec3.min(min.array, min.array, bbox.min.array); vec3.max(max.array, max.array, bbox.max.array); min._dirty = true; max._dirty = true; return this; }
[ "function", "(", "bbox", ")", "{", "var", "min", "=", "this", ".", "min", ";", "var", "max", "=", "this", ".", "max", ";", "vec3", ".", "min", "(", "min", ".", "array", ",", "min", ".", "array", ",", "bbox", ".", "min", ".", "array", ")", ";"...
Union operation with another bounding box @param {clay.BoundingBox} bbox
[ "Union", "operation", "with", "another", "bounding", "box" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14556-L14564
6,856
pissang/claygl
dist/claygl.es.js
function (bbox) { var _min = this.min.array; var _max = this.max.array; var _min2 = bbox.min.array; var _max2 = bbox.max.array; return ! (_min[0] > _max2[0] || _min[1] > _max2[1] || _min[2] > _max2[2] || _max[0] < _min2[0] || _max[1] < _min2[1] || _max[2] < _min2[2]); }
javascript
function (bbox) { var _min = this.min.array; var _max = this.max.array; var _min2 = bbox.min.array; var _max2 = bbox.max.array; return ! (_min[0] > _max2[0] || _min[1] > _max2[1] || _min[2] > _max2[2] || _max[0] < _min2[0] || _max[1] < _min2[1] || _max[2] < _min2[2]); }
[ "function", "(", "bbox", ")", "{", "var", "_min", "=", "this", ".", "min", ".", "array", ";", "var", "_max", "=", "this", ".", "max", ".", "array", ";", "var", "_min2", "=", "bbox", ".", "min", ".", "array", ";", "var", "_max2", "=", "bbox", "....
If intersect with another bounding box @param {clay.BoundingBox} bbox @return {boolean}
[ "If", "intersect", "with", "another", "bounding", "box" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14585-L14594
6,857
pissang/claygl
dist/claygl.es.js
function (p) { var _min = this.min.array; var _max = this.max.array; var _p = p.array; return _min[0] <= _p[0] && _min[1] <= _p[1] && _min[2] <= _p[2] && _max[0] >= _p[0] && _max[1] >= _p[1] && _max[2] >= _p[2]; }
javascript
function (p) { var _min = this.min.array; var _max = this.max.array; var _p = p.array; return _min[0] <= _p[0] && _min[1] <= _p[1] && _min[2] <= _p[2] && _max[0] >= _p[0] && _max[1] >= _p[1] && _max[2] >= _p[2]; }
[ "function", "(", "p", ")", "{", "var", "_min", "=", "this", ".", "min", ".", "array", ";", "var", "_max", "=", "this", ".", "max", ".", "array", ";", "var", "_p", "=", "p", ".", "array", ";", "return", "_min", "[", "0", "]", "<=", "_p", "[", ...
If contain point entirely @param {clay.Vector3} point @return {boolean}
[ "If", "contain", "point", "entirely" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14618-L14626
6,858
pissang/claygl
dist/claygl.es.js
function () { var _min = this.min.array; var _max = this.max.array; return isFinite(_min[0]) && isFinite(_min[1]) && isFinite(_min[2]) && isFinite(_max[0]) && isFinite(_max[1]) && isFinite(_max[2]); }
javascript
function () { var _min = this.min.array; var _max = this.max.array; return isFinite(_min[0]) && isFinite(_min[1]) && isFinite(_min[2]) && isFinite(_max[0]) && isFinite(_max[1]) && isFinite(_max[2]); }
[ "function", "(", ")", "{", "var", "_min", "=", "this", ".", "min", ".", "array", ";", "var", "_max", "=", "this", ".", "max", ".", "array", ";", "return", "isFinite", "(", "_min", "[", "0", "]", ")", "&&", "isFinite", "(", "_min", "[", "1", "]"...
If bounding box is finite
[ "If", "bounding", "box", "is", "finite" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14631-L14636
6,859
pissang/claygl
dist/claygl.es.js
function (matrix) { var min = this.min.array; var max = this.max.array; var m = matrix.array; // min in min z var v10 = min[0]; var v11 = min[1]; var v12 = min[2]; // max in min z var v20 = max[0]; var v21 = max[1]; var v22 = min[2]; // max in max z var v30 = max[0]; var v31 = max[1]; var v32 = max[2]; if (m[15] === 1) { // Orthographic projection min[0] = m[0] * v10 + m[12]; min[1] = m[5] * v11 + m[13]; max[2] = m[10] * v12 + m[14]; max[0] = m[0] * v30 + m[12]; max[1] = m[5] * v31 + m[13]; min[2] = m[10] * v32 + m[14]; } else { var w = -1 / v12; min[0] = m[0] * v10 * w; min[1] = m[5] * v11 * w; max[2] = (m[10] * v12 + m[14]) * w; w = -1 / v22; max[0] = m[0] * v20 * w; max[1] = m[5] * v21 * w; w = -1 / v32; min[2] = (m[10] * v32 + m[14]) * w; } this.min._dirty = true; this.max._dirty = true; return this; }
javascript
function (matrix) { var min = this.min.array; var max = this.max.array; var m = matrix.array; // min in min z var v10 = min[0]; var v11 = min[1]; var v12 = min[2]; // max in min z var v20 = max[0]; var v21 = max[1]; var v22 = min[2]; // max in max z var v30 = max[0]; var v31 = max[1]; var v32 = max[2]; if (m[15] === 1) { // Orthographic projection min[0] = m[0] * v10 + m[12]; min[1] = m[5] * v11 + m[13]; max[2] = m[10] * v12 + m[14]; max[0] = m[0] * v30 + m[12]; max[1] = m[5] * v31 + m[13]; min[2] = m[10] * v32 + m[14]; } else { var w = -1 / v12; min[0] = m[0] * v10 * w; min[1] = m[5] * v11 * w; max[2] = (m[10] * v12 + m[14]) * w; w = -1 / v22; max[0] = m[0] * v20 * w; max[1] = m[5] * v21 * w; w = -1 / v32; min[2] = (m[10] * v32 + m[14]) * w; } this.min._dirty = true; this.max._dirty = true; return this; }
[ "function", "(", "matrix", ")", "{", "var", "min", "=", "this", ".", "min", ".", "array", ";", "var", "max", "=", "this", ".", "max", ".", "array", ";", "var", "m", "=", "matrix", ".", "array", ";", "// min in min z", "var", "v10", "=", "min", "[...
Apply a projection matrix to the bounding box @param {clay.Matrix4} matrix
[ "Apply", "a", "projection", "matrix", "to", "the", "bounding", "box" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14696-L14740
6,860
pissang/claygl
dist/claygl.es.js
function (bbox) { var min = this.min; var max = this.max; vec3Copy(min.array, bbox.min.array); vec3Copy(max.array, bbox.max.array); min._dirty = true; max._dirty = true; return this; }
javascript
function (bbox) { var min = this.min; var max = this.max; vec3Copy(min.array, bbox.min.array); vec3Copy(max.array, bbox.max.array); min._dirty = true; max._dirty = true; return this; }
[ "function", "(", "bbox", ")", "{", "var", "min", "=", "this", ".", "min", ";", "var", "max", "=", "this", ".", "max", ";", "vec3Copy", "(", "min", ".", "array", ",", "bbox", ".", "min", ".", "array", ")", ";", "vec3Copy", "(", "max", ".", "arra...
Copy values from another bounding box @param {clay.BoundingBox} bbox
[ "Copy", "values", "from", "another", "bounding", "box" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14779-L14787
6,861
pissang/claygl
dist/claygl.es.js
function (name) { var scene = this._scene; if (scene) { var nodeRepository = scene._nodeRepository; delete nodeRepository[this.name]; nodeRepository[name] = this; } this.name = name; }
javascript
function (name) { var scene = this._scene; if (scene) { var nodeRepository = scene._nodeRepository; delete nodeRepository[this.name]; nodeRepository[name] = this; } this.name = name; }
[ "function", "(", "name", ")", "{", "var", "scene", "=", "this", ".", "_scene", ";", "if", "(", "scene", ")", "{", "var", "nodeRepository", "=", "scene", ".", "_nodeRepository", ";", "delete", "nodeRepository", "[", "this", ".", "name", "]", ";", "nodeR...
Set the name of the scene node @param {string} name
[ "Set", "the", "name", "of", "the", "scene", "node" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14932-L14940
6,862
pissang/claygl
dist/claygl.es.js
function (node) { var originalParent = node._parent; if (originalParent === this) { return; } if (originalParent) { originalParent.remove(node); } node._parent = this; this._children.push(node); var scene = this._scene; if (scene && scene !== node.scene) { node.traverse(this._addSelfToScene, this); } // Mark children needs update transform // In case child are remove and added again after parent moved node._needsUpdateWorldTransform = true; }
javascript
function (node) { var originalParent = node._parent; if (originalParent === this) { return; } if (originalParent) { originalParent.remove(node); } node._parent = this; this._children.push(node); var scene = this._scene; if (scene && scene !== node.scene) { node.traverse(this._addSelfToScene, this); } // Mark children needs update transform // In case child are remove and added again after parent moved node._needsUpdateWorldTransform = true; }
[ "function", "(", "node", ")", "{", "var", "originalParent", "=", "node", ".", "_parent", ";", "if", "(", "originalParent", "===", "this", ")", "{", "return", ";", "}", "if", "(", "originalParent", ")", "{", "originalParent", ".", "remove", "(", "node", ...
Add a child node @param {clay.Node} node
[ "Add", "a", "child", "node" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14946-L14964
6,863
pissang/claygl
dist/claygl.es.js
function (node) { var children = this._children; var idx = children.indexOf(node); if (idx < 0) { return; } children.splice(idx, 1); node._parent = null; if (this._scene) { node.traverse(this._removeSelfFromScene, this); } }
javascript
function (node) { var children = this._children; var idx = children.indexOf(node); if (idx < 0) { return; } children.splice(idx, 1); node._parent = null; if (this._scene) { node.traverse(this._removeSelfFromScene, this); } }
[ "function", "(", "node", ")", "{", "var", "children", "=", "this", ".", "_children", ";", "var", "idx", "=", "children", ".", "indexOf", "(", "node", ")", ";", "if", "(", "idx", "<", "0", ")", "{", "return", ";", "}", "children", ".", "splice", "...
Remove the given child scene node @param {clay.Node} node
[ "Remove", "the", "given", "child", "scene", "node" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14970-L14983
6,864
pissang/claygl
dist/claygl.es.js
function () { var children = this._children; for (var idx = 0; idx < children.length; idx++) { children[idx]._parent = null; if (this._scene) { children[idx].traverse(this._removeSelfFromScene, this); } } this._children = []; }
javascript
function () { var children = this._children; for (var idx = 0; idx < children.length; idx++) { children[idx]._parent = null; if (this._scene) { children[idx].traverse(this._removeSelfFromScene, this); } } this._children = []; }
[ "function", "(", ")", "{", "var", "children", "=", "this", ".", "_children", ";", "for", "(", "var", "idx", "=", "0", ";", "idx", "<", "children", ".", "length", ";", "idx", "++", ")", "{", "children", "[", "idx", "]", ".", "_parent", "=", "null"...
Remove all children
[ "Remove", "all", "children" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L14988-L15000
6,865
pissang/claygl
dist/claygl.es.js
function (node) { var parent = node._parent; while(parent) { if (parent === this) { return true; } parent = parent._parent; } return false; }
javascript
function (node) { var parent = node._parent; while(parent) { if (parent === this) { return true; } parent = parent._parent; } return false; }
[ "function", "(", "node", ")", "{", "var", "parent", "=", "node", ".", "_parent", ";", "while", "(", "parent", ")", "{", "if", "(", "parent", "===", "this", ")", "{", "return", "true", ";", "}", "parent", "=", "parent", ".", "_parent", ";", "}", "...
Return true if it is ancestor of the given scene node @param {clay.Node} node
[ "Return", "true", "if", "it", "is", "ancestor", "of", "the", "given", "scene", "node" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15032-L15041
6,866
pissang/claygl
dist/claygl.es.js
function (name) { var children = this._children; for (var i = 0; i < children.length; i++) { if (children[i].name === name) { return children[i]; } } }
javascript
function (name) { var children = this._children; for (var i = 0; i < children.length; i++) { if (children[i].name === name) { return children[i]; } } }
[ "function", "(", "name", ")", "{", "var", "children", "=", "this", ".", "_children", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "children", ".", "length", ";", "i", "++", ")", "{", "if", "(", "children", "[", "i", "]", ".", "name", ...
Get first child with the given name @param {string} name @return {clay.Node}
[ "Get", "first", "child", "with", "the", "given", "name" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15065-L15072
6,867
pissang/claygl
dist/claygl.es.js
function (name) { var children = this._children; for (var i = 0; i < children.length; i++) { var child = children[i]; if (child.name === name) { return child; } else { var res = child.getDescendantByName(name); if (res) { return res; } } } }
javascript
function (name) { var children = this._children; for (var i = 0; i < children.length; i++) { var child = children[i]; if (child.name === name) { return child; } else { var res = child.getDescendantByName(name); if (res) { return res; } } } }
[ "function", "(", "name", ")", "{", "var", "children", "=", "this", ".", "_children", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "children", ".", "length", ";", "i", "++", ")", "{", "var", "child", "=", "children", "[", "i", "]", ";",...
Get first descendant have the given name @param {string} name @return {clay.Node}
[ "Get", "first", "descendant", "have", "the", "given", "name" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15079-L15092
6,868
pissang/claygl
dist/claygl.es.js
function (path) { if (!path) { return; } // TODO Name have slash ? var pathArr = path.split('/'); var current = this; for (var i = 0; i < pathArr.length; i++) { var name = pathArr[i]; // Skip empty if (!name) { continue; } var found = false; var children = current._children; for (var j = 0; j < children.length; j++) { var child = children[j]; if (child.name === name) { current = child; found = true; break; } } // Early return if not found if (!found) { return; } } return current; }
javascript
function (path) { if (!path) { return; } // TODO Name have slash ? var pathArr = path.split('/'); var current = this; for (var i = 0; i < pathArr.length; i++) { var name = pathArr[i]; // Skip empty if (!name) { continue; } var found = false; var children = current._children; for (var j = 0; j < children.length; j++) { var child = children[j]; if (child.name === name) { current = child; found = true; break; } } // Early return if not found if (!found) { return; } } return current; }
[ "function", "(", "path", ")", "{", "if", "(", "!", "path", ")", "{", "return", ";", "}", "// TODO Name have slash ?", "var", "pathArr", "=", "path", ".", "split", "(", "'/'", ")", ";", "var", "current", "=", "this", ";", "for", "(", "var", "i", "="...
Query descendant node by path @param {string} path @return {clay.Node} @example node.queryNode('root/parent/child');
[ "Query", "descendant", "node", "by", "path" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15101-L15131
6,869
pissang/claygl
dist/claygl.es.js
function (callback, context) { callback.call(context, this); var _children = this._children; for(var i = 0, len = _children.length; i < len; i++) { _children[i].traverse(callback, context); } }
javascript
function (callback, context) { callback.call(context, this); var _children = this._children; for(var i = 0, len = _children.length; i < len; i++) { _children[i].traverse(callback, context); } }
[ "function", "(", "callback", ",", "context", ")", "{", "callback", ".", "call", "(", "context", ",", "this", ")", ";", "var", "_children", "=", "this", ".", "_children", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "_children", ".", "len...
Depth first traverse all its descendant scene nodes. **WARN** Don't do `add`, `remove` operation in the callback during traverse. @param {Function} callback @param {Node} [context]
[ "Depth", "first", "traverse", "all", "its", "descendant", "scene", "nodes", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15165-L15171
6,870
pissang/claygl
dist/claygl.es.js
function (callback, context) { var _children = this._children; for(var i = 0, len = _children.length; i < len; i++) { var child = _children[i]; callback.call(context, child, i); } }
javascript
function (callback, context) { var _children = this._children; for(var i = 0, len = _children.length; i < len; i++) { var child = _children[i]; callback.call(context, child, i); } }
[ "function", "(", "callback", ",", "context", ")", "{", "var", "_children", "=", "this", ".", "_children", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "_children", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", ...
Traverse all children nodes. **WARN** DON'T do `add`, `remove` operation in the callback during iteration. @param {Function} callback @param {Node} [context]
[ "Traverse", "all", "children", "nodes", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15181-L15187
6,871
pissang/claygl
dist/claygl.es.js
function (keepScale) { var scale = !keepScale ? this.scale: null; this.localTransform.decomposeMatrix(scale, this.rotation, this.position); }
javascript
function (keepScale) { var scale = !keepScale ? this.scale: null; this.localTransform.decomposeMatrix(scale, this.rotation, this.position); }
[ "function", "(", "keepScale", ")", "{", "var", "scale", "=", "!", "keepScale", "?", "this", ".", "scale", ":", "null", ";", "this", ".", "localTransform", ".", "decomposeMatrix", "(", "scale", ",", "this", ".", "rotation", ",", "this", ".", "position", ...
Decompose the local transform to SRT
[ "Decompose", "the", "local", "transform", "to", "SRT" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15201-L15204
6,872
pissang/claygl
dist/claygl.es.js
function () { var position = this.position; var rotation = this.rotation; var scale = this.scale; if (this.transformNeedsUpdate()) { var m = this.localTransform.array; // Transform order, scale->rotation->position mat4.fromRotationTranslation(m, rotation.array, position.array); mat4.scale(m, m, scale.array); rotation._dirty = false; scale._dirty = false; position._dirty = false; this._needsUpdateWorldTransform = true; } }
javascript
function () { var position = this.position; var rotation = this.rotation; var scale = this.scale; if (this.transformNeedsUpdate()) { var m = this.localTransform.array; // Transform order, scale->rotation->position mat4.fromRotationTranslation(m, rotation.array, position.array); mat4.scale(m, m, scale.array); rotation._dirty = false; scale._dirty = false; position._dirty = false; this._needsUpdateWorldTransform = true; } }
[ "function", "(", ")", "{", "var", "position", "=", "this", ".", "position", ";", "var", "rotation", "=", "this", ".", "rotation", ";", "var", "scale", "=", "this", ".", "scale", ";", "if", "(", "this", ".", "transformNeedsUpdate", "(", ")", ")", "{",...
Update local transform from SRT Notice that local transform will not be updated if _dirty mark of position, rotation, scale is all false
[ "Update", "local", "transform", "from", "SRT", "Notice", "that", "local", "transform", "will", "not", "be", "updated", "if", "_dirty", "mark", "of", "position", "rotation", "scale", "is", "all", "false" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15248-L15267
6,873
pissang/claygl
dist/claygl.es.js
function () { var localTransform = this.localTransform.array; var worldTransform = this.worldTransform.array; if (this._parent) { mat4.multiplyAffine( worldTransform, this._parent.worldTransform.array, localTransform ); } else { mat4.copy(worldTransform, localTransform); } }
javascript
function () { var localTransform = this.localTransform.array; var worldTransform = this.worldTransform.array; if (this._parent) { mat4.multiplyAffine( worldTransform, this._parent.worldTransform.array, localTransform ); } else { mat4.copy(worldTransform, localTransform); } }
[ "function", "(", ")", "{", "var", "localTransform", "=", "this", ".", "localTransform", ".", "array", ";", "var", "worldTransform", "=", "this", ".", "worldTransform", ".", "array", ";", "if", "(", "this", ".", "_parent", ")", "{", "mat4", ".", "multiply...
Update world transform, assume its parent world transform have been updated @private
[ "Update", "world", "transform", "assume", "its", "parent", "world", "transform", "have", "been", "updated" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15273-L15286
6,874
pissang/claygl
dist/claygl.es.js
function () { // Find the root node which transform needs update; var rootNodeIsDirty = this; while (rootNodeIsDirty && rootNodeIsDirty.getParent() && rootNodeIsDirty.getParent().transformNeedsUpdate() ) { rootNodeIsDirty = rootNodeIsDirty.getParent(); } rootNodeIsDirty.update(); }
javascript
function () { // Find the root node which transform needs update; var rootNodeIsDirty = this; while (rootNodeIsDirty && rootNodeIsDirty.getParent() && rootNodeIsDirty.getParent().transformNeedsUpdate() ) { rootNodeIsDirty = rootNodeIsDirty.getParent(); } rootNodeIsDirty.update(); }
[ "function", "(", ")", "{", "// Find the root node which transform needs update;", "var", "rootNodeIsDirty", "=", "this", ";", "while", "(", "rootNodeIsDirty", "&&", "rootNodeIsDirty", ".", "getParent", "(", ")", "&&", "rootNodeIsDirty", ".", "getParent", "(", ")", "...
Update world transform before whole scene is updated.
[ "Update", "world", "transform", "before", "whole", "scene", "is", "updated", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15291-L15300
6,875
pissang/claygl
dist/claygl.es.js
function (forceUpdateWorld) { if (this.autoUpdateLocalTransform) { this.updateLocalTransform(); } else { // Transform is manually setted forceUpdateWorld = true; } if (forceUpdateWorld || this._needsUpdateWorldTransform) { this._updateWorldTransformTopDown(); forceUpdateWorld = true; this._needsUpdateWorldTransform = false; } var children = this._children; for(var i = 0, len = children.length; i < len; i++) { children[i].update(forceUpdateWorld); } }
javascript
function (forceUpdateWorld) { if (this.autoUpdateLocalTransform) { this.updateLocalTransform(); } else { // Transform is manually setted forceUpdateWorld = true; } if (forceUpdateWorld || this._needsUpdateWorldTransform) { this._updateWorldTransformTopDown(); forceUpdateWorld = true; this._needsUpdateWorldTransform = false; } var children = this._children; for(var i = 0, len = children.length; i < len; i++) { children[i].update(forceUpdateWorld); } }
[ "function", "(", "forceUpdateWorld", ")", "{", "if", "(", "this", ".", "autoUpdateLocalTransform", ")", "{", "this", ".", "updateLocalTransform", "(", ")", ";", "}", "else", "{", "// Transform is manually setted", "forceUpdateWorld", "=", "true", ";", "}", "if",...
Update local transform and world transform recursively @param {boolean} forceUpdateWorld
[ "Update", "local", "transform", "and", "world", "transform", "recursively" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15306-L15325
6,876
pissang/claygl
dist/claygl.es.js
function (out) { // PENDING if (this.transformNeedsUpdate()) { this.updateWorldTransform(); } var m = this.worldTransform.array; if (out) { var arr = out.array; arr[0] = m[12]; arr[1] = m[13]; arr[2] = m[14]; return out; } else { return new Vector3(m[12], m[13], m[14]); } }
javascript
function (out) { // PENDING if (this.transformNeedsUpdate()) { this.updateWorldTransform(); } var m = this.worldTransform.array; if (out) { var arr = out.array; arr[0] = m[12]; arr[1] = m[13]; arr[2] = m[14]; return out; } else { return new Vector3(m[12], m[13], m[14]); } }
[ "function", "(", "out", ")", "{", "// PENDING", "if", "(", "this", ".", "transformNeedsUpdate", "(", ")", ")", "{", "this", ".", "updateWorldTransform", "(", ")", ";", "}", "var", "m", "=", "this", ".", "worldTransform", ".", "array", ";", "if", "(", ...
Get world position, extracted from world transform @param {clay.Vector3} [out] @return {clay.Vector3}
[ "Get", "world", "position", "extracted", "from", "world", "transform" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15370-L15386
6,877
pissang/claygl
dist/claygl.es.js
function () { var node = new this.constructor(); var children = this._children; node.setName(this.name); node.position.copy(this.position); node.rotation.copy(this.rotation); node.scale.copy(this.scale); for (var i = 0; i < children.length; i++) { node.add(children[i].clone()); } return node; }
javascript
function () { var node = new this.constructor(); var children = this._children; node.setName(this.name); node.position.copy(this.position); node.rotation.copy(this.rotation); node.scale.copy(this.scale); for (var i = 0; i < children.length; i++) { node.add(children[i].clone()); } return node; }
[ "function", "(", ")", "{", "var", "node", "=", "new", "this", ".", "constructor", "(", ")", ";", "var", "children", "=", "this", ".", "_children", ";", "node", ".", "setName", "(", "this", ".", "name", ")", ";", "node", ".", "position", ".", "copy"...
Clone a new node @return {Node}
[ "Clone", "a", "new", "node" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15392-L15407
6,878
pissang/claygl
dist/claygl.es.js
function(point, out) { if (!out) { out = new Vector3(); } var d = this.distanceToPoint(point); vec3.scaleAndAdd(out.array, point.array, this.normal.array, -d); out._dirty = true; return out; }
javascript
function(point, out) { if (!out) { out = new Vector3(); } var d = this.distanceToPoint(point); vec3.scaleAndAdd(out.array, point.array, this.normal.array, -d); out._dirty = true; return out; }
[ "function", "(", "point", ",", "out", ")", "{", "if", "(", "!", "out", ")", "{", "out", "=", "new", "Vector3", "(", ")", ";", "}", "var", "d", "=", "this", ".", "distanceToPoint", "(", "point", ")", ";", "vec3", ".", "scaleAndAdd", "(", "out", ...
Calculate the projection point on the plane @param {clay.Vector3} point @param {clay.Vector3} out @return {clay.Vector3}
[ "Calculate", "the", "projection", "point", "on", "the", "plane" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15609-L15617
6,879
pissang/claygl
dist/claygl.es.js
function() { var invLen = 1 / vec3.len(this.normal.array); vec3.scale(this.normal.array, invLen); this.distance *= invLen; }
javascript
function() { var invLen = 1 / vec3.len(this.normal.array); vec3.scale(this.normal.array, invLen); this.distance *= invLen; }
[ "function", "(", ")", "{", "var", "invLen", "=", "1", "/", "vec3", ".", "len", "(", "this", ".", "normal", ".", "array", ")", ";", "vec3", ".", "scale", "(", "this", ".", "normal", ".", "array", ",", "invLen", ")", ";", "this", ".", "distance", ...
Normalize the plane's normal and calculate the distance
[ "Normalize", "the", "plane", "s", "normal", "and", "calculate", "the", "distance" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15622-L15626
6,880
pissang/claygl
dist/claygl.es.js
function(frustum) { // Check if all coords of frustum is on plane all under plane var coords = frustum.vertices; var normal = this.normal.array; var onPlane = vec3.dot(coords[0].array, normal) > this.distance; for (var i = 1; i < 8; i++) { if ((vec3.dot(coords[i].array, normal) > this.distance) != onPlane) { return true; } } }
javascript
function(frustum) { // Check if all coords of frustum is on plane all under plane var coords = frustum.vertices; var normal = this.normal.array; var onPlane = vec3.dot(coords[0].array, normal) > this.distance; for (var i = 1; i < 8; i++) { if ((vec3.dot(coords[i].array, normal) > this.distance) != onPlane) { return true; } } }
[ "function", "(", "frustum", ")", "{", "// Check if all coords of frustum is on plane all under plane", "var", "coords", "=", "frustum", ".", "vertices", ";", "var", "normal", "=", "this", ".", "normal", ".", "array", ";", "var", "onPlane", "=", "vec3", ".", "dot...
If the plane intersect a frustum @param {clay.Frustum} Frustum @return {boolean}
[ "If", "the", "plane", "intersect", "a", "frustum" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15633-L15643
6,881
pissang/claygl
dist/claygl.es.js
function(plane) { vec3.copy(this.normal.array, plane.normal.array); this.normal._dirty = true; this.distance = plane.distance; }
javascript
function(plane) { vec3.copy(this.normal.array, plane.normal.array); this.normal._dirty = true; this.distance = plane.distance; }
[ "function", "(", "plane", ")", "{", "vec3", ".", "copy", "(", "this", ".", "normal", ".", "array", ",", "plane", ".", "normal", ".", "array", ")", ";", "this", ".", "normal", ".", "_dirty", "=", "true", ";", "this", ".", "distance", "=", "plane", ...
Copy from another plane @param {clay.Vector3} plane
[ "Copy", "from", "another", "plane" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15714-L15718
6,882
pissang/claygl
dist/claygl.es.js
function (plane) { // Distance to plane var d = vec3.dot(plane.normal.array, this.direction.array); vec3.scaleAndAdd(this.direction.array, this.direction.array, plane.normal.array, -d * 2); this.direction._dirty = true; }
javascript
function (plane) { // Distance to plane var d = vec3.dot(plane.normal.array, this.direction.array); vec3.scaleAndAdd(this.direction.array, this.direction.array, plane.normal.array, -d * 2); this.direction._dirty = true; }
[ "function", "(", "plane", ")", "{", "// Distance to plane", "var", "d", "=", "vec3", ".", "dot", "(", "plane", ".", "normal", ".", "array", ",", "this", ".", "direction", ".", "array", ")", ";", "vec3", ".", "scaleAndAdd", "(", "this", ".", "direction"...
Mirror the ray against plane @param {clay.Plane} plane
[ "Mirror", "the", "ray", "against", "plane" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L15963-L15968
6,883
pissang/claygl
dist/claygl.es.js
function (matrix) { Vector3.add(this.direction, this.direction, this.origin); Vector3.transformMat4(this.origin, this.origin, matrix); Vector3.transformMat4(this.direction, this.direction, matrix); Vector3.sub(this.direction, this.direction, this.origin); Vector3.normalize(this.direction, this.direction); }
javascript
function (matrix) { Vector3.add(this.direction, this.direction, this.origin); Vector3.transformMat4(this.origin, this.origin, matrix); Vector3.transformMat4(this.direction, this.direction, matrix); Vector3.sub(this.direction, this.direction, this.origin); Vector3.normalize(this.direction, this.direction); }
[ "function", "(", "matrix", ")", "{", "Vector3", ".", "add", "(", "this", ".", "direction", ",", "this", ".", "direction", ",", "this", ".", "origin", ")", ";", "Vector3", ".", "transformMat4", "(", "this", ".", "origin", ",", "this", ".", "origin", "...
Apply an affine transform matrix to the ray @return {clay.Matrix4} matrix
[ "Apply", "an", "affine", "transform", "matrix", "to", "the", "ray" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16195-L16202
6,884
pissang/claygl
dist/claygl.es.js
function (ray) { Vector3.copy(this.origin, ray.origin); Vector3.copy(this.direction, ray.direction); }
javascript
function (ray) { Vector3.copy(this.origin, ray.origin); Vector3.copy(this.direction, ray.direction); }
[ "function", "(", "ray", ")", "{", "Vector3", ".", "copy", "(", "this", ".", "origin", ",", "ray", ".", "origin", ")", ";", "Vector3", ".", "copy", "(", "this", ".", "direction", ",", "ray", ".", "direction", ")", ";", "}" ]
Copy values from another ray @param {clay.Ray} ray
[ "Copy", "values", "from", "another", "ray" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16208-L16211
6,885
pissang/claygl
dist/claygl.es.js
function (viewMatrix) { Matrix4.copy(this.viewMatrix, viewMatrix); Matrix4.invert(this.worldTransform, viewMatrix); this.decomposeWorldTransform(); }
javascript
function (viewMatrix) { Matrix4.copy(this.viewMatrix, viewMatrix); Matrix4.invert(this.worldTransform, viewMatrix); this.decomposeWorldTransform(); }
[ "function", "(", "viewMatrix", ")", "{", "Matrix4", ".", "copy", "(", "this", ".", "viewMatrix", ",", "viewMatrix", ")", ";", "Matrix4", ".", "invert", "(", "this", ".", "worldTransform", ",", "viewMatrix", ")", ";", "this", ".", "decomposeWorldTransform", ...
Set camera view matrix
[ "Set", "camera", "view", "matrix" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16273-L16277
6,886
pissang/claygl
dist/claygl.es.js
function (projectionMatrix) { Matrix4.copy(this.projectionMatrix, projectionMatrix); Matrix4.invert(this.invProjectionMatrix, projectionMatrix); this.decomposeProjectionMatrix(); }
javascript
function (projectionMatrix) { Matrix4.copy(this.projectionMatrix, projectionMatrix); Matrix4.invert(this.invProjectionMatrix, projectionMatrix); this.decomposeProjectionMatrix(); }
[ "function", "(", "projectionMatrix", ")", "{", "Matrix4", ".", "copy", "(", "this", ".", "projectionMatrix", ",", "projectionMatrix", ")", ";", "Matrix4", ".", "invert", "(", "this", ".", "invProjectionMatrix", ",", "projectionMatrix", ")", ";", "this", ".", ...
Set camera projection matrix @param {clay.Matrix4} projectionMatrix
[ "Set", "camera", "projection", "matrix" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16288-L16292
6,887
pissang/claygl
dist/claygl.es.js
function (node) { if (node instanceof Camera) { if (this._cameraList.length > 0) { console.warn('Found multiple camera in one scene. Use the fist one.'); } this._cameraList.push(node); } else if (node instanceof Light) { this.lights.push(node); } if (node.name) { this._nodeRepository[node.name] = node; } }
javascript
function (node) { if (node instanceof Camera) { if (this._cameraList.length > 0) { console.warn('Found multiple camera in one scene. Use the fist one.'); } this._cameraList.push(node); } else if (node instanceof Light) { this.lights.push(node); } if (node.name) { this._nodeRepository[node.name] = node; } }
[ "function", "(", "node", ")", "{", "if", "(", "node", "instanceof", "Camera", ")", "{", "if", "(", "this", ".", "_cameraList", ".", "length", ">", "0", ")", "{", "console", ".", "warn", "(", "'Found multiple camera in one scene. Use the fist one.'", ")", ";"...
Add node to scene
[ "Add", "node", "to", "scene" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16456-L16469
6,888
pissang/claygl
dist/claygl.es.js
function (node) { var idx; if (node instanceof Camera) { idx = this._cameraList.indexOf(node); if (idx >= 0) { this._cameraList.splice(idx, 1); } } else if (node instanceof Light) { idx = this.lights.indexOf(node); if (idx >= 0) { this.lights.splice(idx, 1); } } if (node.name) { delete this._nodeRepository[node.name]; } }
javascript
function (node) { var idx; if (node instanceof Camera) { idx = this._cameraList.indexOf(node); if (idx >= 0) { this._cameraList.splice(idx, 1); } } else if (node instanceof Light) { idx = this.lights.indexOf(node); if (idx >= 0) { this.lights.splice(idx, 1); } } if (node.name) { delete this._nodeRepository[node.name]; } }
[ "function", "(", "node", ")", "{", "var", "idx", ";", "if", "(", "node", "instanceof", "Camera", ")", "{", "idx", "=", "this", ".", "_cameraList", ".", "indexOf", "(", "node", ")", ";", "if", "(", "idx", ">=", "0", ")", "{", "this", ".", "_camera...
Remove node from scene
[ "Remove", "node", "from", "scene" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16472-L16489
6,889
pissang/claygl
dist/claygl.es.js
function (camera) { var idx = this._cameraList.indexOf(camera); if (idx >= 0) { this._cameraList.splice(idx, 1); } this._cameraList.unshift(camera); }
javascript
function (camera) { var idx = this._cameraList.indexOf(camera); if (idx >= 0) { this._cameraList.splice(idx, 1); } this._cameraList.unshift(camera); }
[ "function", "(", "camera", ")", "{", "var", "idx", "=", "this", ".", "_cameraList", ".", "indexOf", "(", "camera", ")", ";", "if", "(", "idx", ">=", "0", ")", "{", "this", ".", "_cameraList", ".", "splice", "(", "idx", ",", "1", ")", ";", "}", ...
Set main camera of the scene. @param {claygl.Camera} camera
[ "Set", "main", "camera", "of", "the", "scene", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16505-L16511
6,890
pissang/claygl
dist/claygl.es.js
function (camera, updateSceneBoundingBox) { var id = camera.__uid__; var renderList = this._renderLists.get(id); if (!renderList) { renderList = new RenderList(); this._renderLists.put(id, renderList); } renderList.startCount(); if (updateSceneBoundingBox) { this.viewBoundingBoxLastFrame.min.set(Infinity, Infinity, Infinity); this.viewBoundingBoxLastFrame.max.set(-Infinity, -Infinity, -Infinity); } var sceneMaterialTransparent = this.material && this.material.transparent || false; this._doUpdateRenderList(this, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox); renderList.endCount(); return renderList; }
javascript
function (camera, updateSceneBoundingBox) { var id = camera.__uid__; var renderList = this._renderLists.get(id); if (!renderList) { renderList = new RenderList(); this._renderLists.put(id, renderList); } renderList.startCount(); if (updateSceneBoundingBox) { this.viewBoundingBoxLastFrame.min.set(Infinity, Infinity, Infinity); this.viewBoundingBoxLastFrame.max.set(-Infinity, -Infinity, -Infinity); } var sceneMaterialTransparent = this.material && this.material.transparent || false; this._doUpdateRenderList(this, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox); renderList.endCount(); return renderList; }
[ "function", "(", "camera", ",", "updateSceneBoundingBox", ")", "{", "var", "id", "=", "camera", ".", "__uid__", ";", "var", "renderList", "=", "this", ".", "_renderLists", ".", "get", "(", "id", ")", ";", "if", "(", "!", "renderList", ")", "{", "render...
Traverse the scene and add the renderable object to the render list. It needs camera for the frustum culling. @param {clay.Camera} camera @param {boolean} updateSceneBoundingBox @return {clay.Scene.RenderList}
[ "Traverse", "the", "scene", "and", "add", "the", "renderable", "object", "to", "the", "render", "list", ".", "It", "needs", "camera", "for", "the", "frustum", "culling", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16591-L16611
6,891
pissang/claygl
dist/claygl.es.js
function (lightGroup) { var prevLightNumber = this._previousLightNumber; var currentLightNumber = this._lightNumber; // PENDING Performance for (var type in currentLightNumber[lightGroup]) { if (!prevLightNumber[lightGroup]) { return true; } if (currentLightNumber[lightGroup][type] !== prevLightNumber[lightGroup][type]) { return true; } } for (var type in prevLightNumber[lightGroup]) { if (!currentLightNumber[lightGroup]) { return true; } if (currentLightNumber[lightGroup][type] !== prevLightNumber[lightGroup][type]) { return true; } } return false; }
javascript
function (lightGroup) { var prevLightNumber = this._previousLightNumber; var currentLightNumber = this._lightNumber; // PENDING Performance for (var type in currentLightNumber[lightGroup]) { if (!prevLightNumber[lightGroup]) { return true; } if (currentLightNumber[lightGroup][type] !== prevLightNumber[lightGroup][type]) { return true; } } for (var type in prevLightNumber[lightGroup]) { if (!currentLightNumber[lightGroup]) { return true; } if (currentLightNumber[lightGroup][type] !== prevLightNumber[lightGroup][type]) { return true; } } return false; }
[ "function", "(", "lightGroup", ")", "{", "var", "prevLightNumber", "=", "this", ".", "_previousLightNumber", ";", "var", "currentLightNumber", "=", "this", ".", "_lightNumber", ";", "// PENDING Performance", "for", "(", "var", "type", "in", "currentLightNumber", "...
Determine if light group is different with since last frame Used to determine whether to update shader and scene's uniforms in Renderer.render
[ "Determine", "if", "light", "group", "is", "different", "with", "since", "last", "frame", "Used", "to", "determine", "whether", "to", "update", "shader", "and", "scene", "s", "uniforms", "in", "Renderer", ".", "render" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L16800-L16821
6,892
pissang/claygl
dist/claygl.es.js
function (name, type, size, semantic) { var attrib = new Attribute$1(name, type, size, semantic); if (this.attributes[name]) { this.removeAttribute(name); } this.attributes[name] = attrib; this._attributeList.push(name); return attrib; }
javascript
function (name, type, size, semantic) { var attrib = new Attribute$1(name, type, size, semantic); if (this.attributes[name]) { this.removeAttribute(name); } this.attributes[name] = attrib; this._attributeList.push(name); return attrib; }
[ "function", "(", "name", ",", "type", ",", "size", ",", "semantic", ")", "{", "var", "attrib", "=", "new", "Attribute$1", "(", "name", ",", "type", ",", "size", ",", "semantic", ")", ";", "if", "(", "this", ".", "attributes", "[", "name", "]", ")",...
Create a new attribute @param {string} name @param {string} type @param {number} size @param {string} [semantic]
[ "Create", "a", "new", "attribute" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L17406-L17414
6,893
pissang/claygl
dist/claygl.es.js
function () { var bbox = this.boundingBox; if (!bbox) { bbox = this.boundingBox = new BoundingBox(); } var posArr = this.attributes.position.value; if (posArr && posArr.length) { var min = bbox.min; var max = bbox.max; var minArr = min.array; var maxArr = max.array; vec3.set(minArr, posArr[0], posArr[1], posArr[2]); vec3.set(maxArr, posArr[0], posArr[1], posArr[2]); for (var i = 3; i < posArr.length;) { var x = posArr[i++]; var y = posArr[i++]; var z = posArr[i++]; if (x < minArr[0]) { minArr[0] = x; } if (y < minArr[1]) { minArr[1] = y; } if (z < minArr[2]) { minArr[2] = z; } if (x > maxArr[0]) { maxArr[0] = x; } if (y > maxArr[1]) { maxArr[1] = y; } if (z > maxArr[2]) { maxArr[2] = z; } } min._dirty = true; max._dirty = true; } }
javascript
function () { var bbox = this.boundingBox; if (!bbox) { bbox = this.boundingBox = new BoundingBox(); } var posArr = this.attributes.position.value; if (posArr && posArr.length) { var min = bbox.min; var max = bbox.max; var minArr = min.array; var maxArr = max.array; vec3.set(minArr, posArr[0], posArr[1], posArr[2]); vec3.set(maxArr, posArr[0], posArr[1], posArr[2]); for (var i = 3; i < posArr.length;) { var x = posArr[i++]; var y = posArr[i++]; var z = posArr[i++]; if (x < minArr[0]) { minArr[0] = x; } if (y < minArr[1]) { minArr[1] = y; } if (z < minArr[2]) { minArr[2] = z; } if (x > maxArr[0]) { maxArr[0] = x; } if (y > maxArr[1]) { maxArr[1] = y; } if (z > maxArr[2]) { maxArr[2] = z; } } min._dirty = true; max._dirty = true; } }
[ "function", "(", ")", "{", "var", "bbox", "=", "this", ".", "boundingBox", ";", "if", "(", "!", "bbox", ")", "{", "bbox", "=", "this", ".", "boundingBox", "=", "new", "BoundingBox", "(", ")", ";", "}", "var", "posArr", "=", "this", ".", "attributes...
Update boundingBox of Geometry
[ "Update", "boundingBox", "of", "Geometry" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L17778-L17806
6,894
pissang/claygl
dist/claygl.es.js
function () { if (!this.vertexCount || !this.indices) { return; } if (this.indices.length > 0xffff) { this.indices = new vendor.Uint32Array(this.indices); } var attributes = this.attributes; var indices = this.indices; var attributeNameList = this.getEnabledAttributes(); var oldAttrValues = {}; for (var a = 0; a < attributeNameList.length; a++) { var name = attributeNameList[a]; oldAttrValues[name] = attributes[name].value; attributes[name].init(this.indices.length); } var cursor = 0; for (var i = 0; i < indices.length; i++) { var ii = indices[i]; for (var a = 0; a < attributeNameList.length; a++) { var name = attributeNameList[a]; var array = attributes[name].value; var size = attributes[name].size; for (var k = 0; k < size; k++) { array[cursor * size + k] = oldAttrValues[name][ii * size + k]; } } indices[i] = cursor; cursor++; } this.dirty(); }
javascript
function () { if (!this.vertexCount || !this.indices) { return; } if (this.indices.length > 0xffff) { this.indices = new vendor.Uint32Array(this.indices); } var attributes = this.attributes; var indices = this.indices; var attributeNameList = this.getEnabledAttributes(); var oldAttrValues = {}; for (var a = 0; a < attributeNameList.length; a++) { var name = attributeNameList[a]; oldAttrValues[name] = attributes[name].value; attributes[name].init(this.indices.length); } var cursor = 0; for (var i = 0; i < indices.length; i++) { var ii = indices[i]; for (var a = 0; a < attributeNameList.length; a++) { var name = attributeNameList[a]; var array = attributes[name].value; var size = attributes[name].size; for (var k = 0; k < size; k++) { array[cursor * size + k] = oldAttrValues[name][ii * size + k]; } } indices[i] = cursor; cursor++; } this.dirty(); }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "vertexCount", "||", "!", "this", ".", "indices", ")", "{", "return", ";", "}", "if", "(", "this", ".", "indices", ".", "length", ">", "0xffff", ")", "{", "this", ".", "indices", "=", "new",...
Create a unique vertex for each index.
[ "Create", "a", "unique", "vertex", "for", "each", "index", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L18071-L18109
6,895
pissang/claygl
dist/claygl.es.js
function () { if (!this.vertexCount) { return; } if (!this.isUniqueVertex()) { this.generateUniqueVertex(); } var attributes = this.attributes; var array = attributes.barycentric.value; var indices = this.indices; // Already existed; if (array && array.length === indices.length * 3) { return; } array = attributes.barycentric.value = new Float32Array(indices.length * 3); for (var i = 0; i < (indices ? indices.length : this.vertexCount / 3);) { for (var j = 0; j < 3; j++) { var ii = indices ? indices[i++] : (i * 3 + j); array[ii * 3 + j] = 1; } } this.dirty(); }
javascript
function () { if (!this.vertexCount) { return; } if (!this.isUniqueVertex()) { this.generateUniqueVertex(); } var attributes = this.attributes; var array = attributes.barycentric.value; var indices = this.indices; // Already existed; if (array && array.length === indices.length * 3) { return; } array = attributes.barycentric.value = new Float32Array(indices.length * 3); for (var i = 0; i < (indices ? indices.length : this.vertexCount / 3);) { for (var j = 0; j < 3; j++) { var ii = indices ? indices[i++] : (i * 3 + j); array[ii * 3 + j] = 1; } } this.dirty(); }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "vertexCount", ")", "{", "return", ";", "}", "if", "(", "!", "this", ".", "isUniqueVertex", "(", ")", ")", "{", "this", ".", "generateUniqueVertex", "(", ")", ";", "}", "var", "attributes", "=...
Generate barycentric coordinates for wireframe draw.
[ "Generate", "barycentric", "coordinates", "for", "wireframe", "draw", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L18114-L18139
6,896
pissang/claygl
dist/claygl.es.js
function (matrix) { var attributes = this.attributes; var positions = attributes.position.value; var normals = attributes.normal.value; var tangents = attributes.tangent.value; matrix = matrix.array; // Normal Matrix var inverseTransposeMatrix = mat4.create(); mat4.invert(inverseTransposeMatrix, matrix); mat4.transpose(inverseTransposeMatrix, inverseTransposeMatrix); var vec3TransformMat4 = vec3.transformMat4; var vec3ForEach = vec3.forEach; vec3ForEach(positions, 3, 0, null, vec3TransformMat4, matrix); if (normals) { vec3ForEach(normals, 3, 0, null, vec3TransformMat4, inverseTransposeMatrix); } if (tangents) { vec3ForEach(tangents, 4, 0, null, vec3TransformMat4, inverseTransposeMatrix); } if (this.boundingBox) { this.updateBoundingBox(); } }
javascript
function (matrix) { var attributes = this.attributes; var positions = attributes.position.value; var normals = attributes.normal.value; var tangents = attributes.tangent.value; matrix = matrix.array; // Normal Matrix var inverseTransposeMatrix = mat4.create(); mat4.invert(inverseTransposeMatrix, matrix); mat4.transpose(inverseTransposeMatrix, inverseTransposeMatrix); var vec3TransformMat4 = vec3.transformMat4; var vec3ForEach = vec3.forEach; vec3ForEach(positions, 3, 0, null, vec3TransformMat4, matrix); if (normals) { vec3ForEach(normals, 3, 0, null, vec3TransformMat4, inverseTransposeMatrix); } if (tangents) { vec3ForEach(tangents, 4, 0, null, vec3TransformMat4, inverseTransposeMatrix); } if (this.boundingBox) { this.updateBoundingBox(); } }
[ "function", "(", "matrix", ")", "{", "var", "attributes", "=", "this", ".", "attributes", ";", "var", "positions", "=", "attributes", ".", "position", ".", "value", ";", "var", "normals", "=", "attributes", ".", "normal", ".", "value", ";", "var", "tange...
Apply transform to geometry attributes. @param {clay.Matrix4} matrix
[ "Apply", "transform", "to", "geometry", "attributes", "." ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L18145-L18171
6,897
pissang/claygl
dist/claygl.es.js
function() { var heightSegments = this.heightSegments; var widthSegments = this.widthSegments; var attributes = this.attributes; var positions = []; var texcoords = []; var normals = []; var faces = []; for (var y = 0; y <= heightSegments; y++) { var t = y / heightSegments; for (var x = 0; x <= widthSegments; x++) { var s = x / widthSegments; positions.push([2 * s - 1, 2 * t - 1, 0]); if (texcoords) { texcoords.push([s, t]); } if (normals) { normals.push([0, 0, 1]); } if (x < widthSegments && y < heightSegments) { var i = x + y * (widthSegments + 1); faces.push([i, i + 1, i + widthSegments + 1]); faces.push([i + widthSegments + 1, i + 1, i + widthSegments + 2]); } } } attributes.position.fromArray(positions); attributes.texcoord0.fromArray(texcoords); attributes.normal.fromArray(normals); this.initIndicesFromArray(faces); this.boundingBox = new BoundingBox(); this.boundingBox.min.set(-1, -1, 0); this.boundingBox.max.set(1, 1, 0); }
javascript
function() { var heightSegments = this.heightSegments; var widthSegments = this.widthSegments; var attributes = this.attributes; var positions = []; var texcoords = []; var normals = []; var faces = []; for (var y = 0; y <= heightSegments; y++) { var t = y / heightSegments; for (var x = 0; x <= widthSegments; x++) { var s = x / widthSegments; positions.push([2 * s - 1, 2 * t - 1, 0]); if (texcoords) { texcoords.push([s, t]); } if (normals) { normals.push([0, 0, 1]); } if (x < widthSegments && y < heightSegments) { var i = x + y * (widthSegments + 1); faces.push([i, i + 1, i + widthSegments + 1]); faces.push([i + widthSegments + 1, i + 1, i + widthSegments + 2]); } } } attributes.position.fromArray(positions); attributes.texcoord0.fromArray(texcoords); attributes.normal.fromArray(normals); this.initIndicesFromArray(faces); this.boundingBox = new BoundingBox(); this.boundingBox.min.set(-1, -1, 0); this.boundingBox.max.set(1, 1, 0); }
[ "function", "(", ")", "{", "var", "heightSegments", "=", "this", ".", "heightSegments", ";", "var", "widthSegments", "=", "this", ".", "widthSegments", ";", "var", "attributes", "=", "this", ".", "attributes", ";", "var", "positions", "=", "[", "]", ";", ...
Build plane geometry
[ "Build", "plane", "geometry" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L18247-L18285
6,898
pissang/claygl
dist/claygl.es.js
function() { var planes = { 'px': createPlane('px', this.depthSegments, this.heightSegments), 'nx': createPlane('nx', this.depthSegments, this.heightSegments), 'py': createPlane('py', this.widthSegments, this.depthSegments), 'ny': createPlane('ny', this.widthSegments, this.depthSegments), 'pz': createPlane('pz', this.widthSegments, this.heightSegments), 'nz': createPlane('nz', this.widthSegments, this.heightSegments), }; var attrList = ['position', 'texcoord0', 'normal']; var vertexNumber = 0; var faceNumber = 0; for (var pos in planes) { vertexNumber += planes[pos].vertexCount; faceNumber += planes[pos].indices.length; } for (var k = 0; k < attrList.length; k++) { this.attributes[attrList[k]].init(vertexNumber); } this.indices = new vendor.Uint16Array(faceNumber); var faceOffset = 0; var vertexOffset = 0; for (var pos in planes) { var plane = planes[pos]; for (var k = 0; k < attrList.length; k++) { var attrName = attrList[k]; var attrArray = plane.attributes[attrName].value; var attrSize = plane.attributes[attrName].size; var isNormal = attrName === 'normal'; for (var i = 0; i < attrArray.length; i++) { var value = attrArray[i]; if (this.inside && isNormal) { value = -value; } this.attributes[attrName].value[i + attrSize * vertexOffset] = value; } } var len = plane.indices.length; for (var i = 0; i < plane.indices.length; i++) { this.indices[i + faceOffset] = vertexOffset + plane.indices[this.inside ? (len - i - 1) : i]; } faceOffset += plane.indices.length; vertexOffset += plane.vertexCount; } this.boundingBox = new BoundingBox(); this.boundingBox.max.set(1, 1, 1); this.boundingBox.min.set(-1, -1, -1); }
javascript
function() { var planes = { 'px': createPlane('px', this.depthSegments, this.heightSegments), 'nx': createPlane('nx', this.depthSegments, this.heightSegments), 'py': createPlane('py', this.widthSegments, this.depthSegments), 'ny': createPlane('ny', this.widthSegments, this.depthSegments), 'pz': createPlane('pz', this.widthSegments, this.heightSegments), 'nz': createPlane('nz', this.widthSegments, this.heightSegments), }; var attrList = ['position', 'texcoord0', 'normal']; var vertexNumber = 0; var faceNumber = 0; for (var pos in planes) { vertexNumber += planes[pos].vertexCount; faceNumber += planes[pos].indices.length; } for (var k = 0; k < attrList.length; k++) { this.attributes[attrList[k]].init(vertexNumber); } this.indices = new vendor.Uint16Array(faceNumber); var faceOffset = 0; var vertexOffset = 0; for (var pos in planes) { var plane = planes[pos]; for (var k = 0; k < attrList.length; k++) { var attrName = attrList[k]; var attrArray = plane.attributes[attrName].value; var attrSize = plane.attributes[attrName].size; var isNormal = attrName === 'normal'; for (var i = 0; i < attrArray.length; i++) { var value = attrArray[i]; if (this.inside && isNormal) { value = -value; } this.attributes[attrName].value[i + attrSize * vertexOffset] = value; } } var len = plane.indices.length; for (var i = 0; i < plane.indices.length; i++) { this.indices[i + faceOffset] = vertexOffset + plane.indices[this.inside ? (len - i - 1) : i]; } faceOffset += plane.indices.length; vertexOffset += plane.vertexCount; } this.boundingBox = new BoundingBox(); this.boundingBox.max.set(1, 1, 1); this.boundingBox.min.set(-1, -1, -1); }
[ "function", "(", ")", "{", "var", "planes", "=", "{", "'px'", ":", "createPlane", "(", "'px'", ",", "this", ".", "depthSegments", ",", "this", ".", "heightSegments", ")", ",", "'nx'", ":", "createPlane", "(", "'nx'", ",", "this", ".", "depthSegments", ...
Build cube geometry
[ "Build", "cube", "geometry" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L18327-L18377
6,899
pissang/claygl
dist/claygl.es.js
function (renderer) { var _gl = renderer.gl; _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, this.flipY); _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, this.unpackAlignment); // Use of none-power of two texture // http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences if (this.format === glenum.DEPTH_COMPONENT) { this.useMipmap = false; } var sRGBExt = renderer.getGLExtension('EXT_sRGB'); // Fallback if (this.format === Texture.SRGB && !sRGBExt) { this.format = Texture.RGB; } if (this.format === Texture.SRGB_ALPHA && !sRGBExt) { this.format = Texture.RGBA; } this.NPOT = !this.isPowerOfTwo(); }
javascript
function (renderer) { var _gl = renderer.gl; _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, this.flipY); _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, this.unpackAlignment); // Use of none-power of two texture // http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences if (this.format === glenum.DEPTH_COMPONENT) { this.useMipmap = false; } var sRGBExt = renderer.getGLExtension('EXT_sRGB'); // Fallback if (this.format === Texture.SRGB && !sRGBExt) { this.format = Texture.RGB; } if (this.format === Texture.SRGB_ALPHA && !sRGBExt) { this.format = Texture.RGBA; } this.NPOT = !this.isPowerOfTwo(); }
[ "function", "(", "renderer", ")", "{", "var", "_gl", "=", "renderer", ".", "gl", ";", "_gl", ".", "pixelStorei", "(", "_gl", ".", "UNPACK_FLIP_Y_WEBGL", ",", "this", ".", "flipY", ")", ";", "_gl", ".", "pixelStorei", "(", "_gl", ".", "UNPACK_PREMULTIPLY_...
Update the common parameters of texture
[ "Update", "the", "common", "parameters", "of", "texture" ]
b157bb50cf8c725fa20f90ebb55481352777f0a7
https://github.com/pissang/claygl/blob/b157bb50cf8c725fa20f90ebb55481352777f0a7/dist/claygl.es.js#L18816-L18838