GitHub PullRequestReviewCommentEvent at 2014-09-25 09:39:42
Repository: engine
Actor: vkalpias
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/playcanvas/engine/pulls/comments/18022991","id":18022991,"diff_hunk":"@@ -0,0 +1,963 @@\n+// Mr F\n+pc.extend(pc.scene, function() {\n+    // TODO: carrying graphicsDevice everywhere around isn't good, should be able to globally address it\n+\n+    var particleVerts = [\n+        [-1, -1],\n+        [1, -1],\n+        [1, 1],\n+        [-1, 1]\n+    ];\n+\n+    var modeGPU = 0;\n+    var modeCPU = 1;\n+\n+    var _createTexture = function(device, width, height, pixelData, is8Bit, mult8Bit) {\n+        var texture = new pc.gfx.Texture(device, {\n+            width: width,\n+            height: height,\n+            format: (is8Bit == true ? pc.gfx.PIXELFORMAT_R8_G8_B8_A8 : pc.gfx.PIXELFORMAT_RGBA32F),\n+            cubemap: false,\n+            autoMipmap: false\n+        });\n+        var pixels = texture.lock();\n+\n+        if (is8Bit) {\n+            var temp = new Uint8Array(pixelData.length);\n+            for (var i = 0; i < pixelData.length; i++) {\n+                temp[i] = pixelData[i] * mult8Bit * 255;\n+            }\n+            pixelData = temp;\n+        }\n+\n+        pixels.set(pixelData);\n+\n+        texture.unlock();\n+\n+        texture.addressU = pc.gfx.ADDRESS_CLAMP_TO_EDGE;\n+        texture.addressV = pc.gfx.ADDRESS_CLAMP_TO_EDGE;\n+        texture.minFilter = pc.gfx.FILTER_NEAREST;\n+        texture.magFilter = pc.gfx.FILTER_NEAREST;\n+\n+        return texture;\n+    };\n+\n+\n+    function saturate(x) {\n+        return Math.max(Math.min(x, 1), 0);\n+    }\n+\n+    function glMod(x, y) {\n+        return x - y * Math.floor(x / y);\n+    }\n+\n+    function tex1D(arr, u, chans, outArr, test) {\n+        if ((chans == undefined) || (chans < 2)) {\n+            u *= arr.length - 1;\n+            var A = arr[Math.floor(u)];\n+            var B = arr[Math.ceil(u)];\n+            var C = u % 1;\n+            return pc.math.lerp(A, B, C);\n+        }\n+\n+        u *= arr.length / chans - 1;\n+        if (outArr == undefined) outArr = [];\n+        for (var i = 0; i < chans; i++) {\n+            var A = arr[Math.floor(u) * chans + i];\n+            var B = arr[Math.ceil(u) * chans + i];\n+            var C = u % 1;\n+            outArr[i] = pc.math.lerp(A, B, C);\n+        }\n+        return outArr;\n+    }\n+\n+\n+    // Linearly interpolated values container\n+    var LinearGraph = function LinearGraph(numValues) {\n+        this.keys = [];\n+        this.dirty = true;\n+        this.numVals = numValues == undefined ? 1 : numValues;\n+        this.smoothstep = true;\n+\n+        this.AddKey = function(time, value) { // time is supposed to be normalized\n+            this.keys.push([time, value]);\n+            this.dirty = true;\n+        }\n+\n+        this.prepare = function() {\n+            this.keys.sort(function(a, b) {\n+                return a[0] - b[0];\n+            });\n+            this.dirty = false;\n+        }\n+\n+        this.GetValue = function(time) {\n+            if (this.dirty) this.prepare();\n+            for (var i = 0; i < this.keys.length; i++) {\n+                var keyTime = this.keys[i][0];\n+                if (keyTime == time) {\n+                    return this.keys[i][1];\n+                } else if (keyTime < time) {\n+                    var keyTimeNext = this.keys[i + 1][0];\n+                    if (keyTimeNext > time) {\n+                        var keyValA = this.keys[i][1];\n+                        var keyValB = this.keys[i + 1][1];\n+                        var interpolation = (time - keyTime) / (keyTimeNext - keyTime);\n+\n+                        if (this.smoothstep) interpolation = ((interpolation) * (interpolation) * (3 - 2 * (interpolation))); // smoothstep\n+\n+                        if (keyValA instanceof Array) {\n+                            var interpolated = new Array(keyValA.length);\n+                            for (var v = 0; v < keyValA.length; v++) interpolated[v] = pc.math.lerp(keyValA[v], keyValB[v], interpolation);\n+                            return interpolated;\n+                        } else {\n+                            return pc.math.lerp(keyValA, keyValB, interpolation);\n+                        }\n+\n+                    }\n+                }\n+            }\n+            return null;\n+        }\n+\n+        this.Quantize = function(precision, blur) {\n+            precision = Math.max(precision, 2);\n+            var colors = new Float32Array(precision * this.numVals);\n+            var step = 1.0 / (precision - 1);\n+            for (var i = 0; i < precision; i++) // quantize graph to table of interpolated values\n+            {\n+                var color = this.GetValue(step * i);\n+                if (this.numVals == 1) {\n+                    colors[i] = color;\n+                } else {\n+                    for (var j = 0; j < this.numVals; j++) colors[i * this.numVals + j] = color[j]\n+                }\n+            }\n+\n+            if (blur > 0) {\n+                var colors2 = new Float32Array(precision * this.numVals);\n+                var numSamples = blur * 2 + 1;\n+                for (var i = 0; i < precision; i++) {\n+                    if (this.numVals == 1) {\n+                        colors2[i] = 0;\n+                        for (var sample = -blur; sample <= blur; sample++) {\n+                            var sampleAddr = Math.max(Math.min(i + sample, precision - 1), 0);\n+                            colors2[i] += colors[sampleAddr];\n+                        }\n+                        colors2[i] /= numSamples;\n+                    } else {\n+                        for (var chan = 0; chan < this.numVals; chan++) colors2[i * this.numVals + chan] = 0;\n+                        for (var sample = -blur; sample <= blur; sample++) {\n+                            var sampleAddr = Math.max(Math.min(i + sample, precision - 1), 0);\n+                            for (var chan = 0; chan < this.numVals; chan++) colors2[i * this.numVals + chan] += colors[sampleAddr * this.numVals + chan];\n+                        }\n+                        for (var chan = 0; chan < this.numVals; chan++) colors2[i * this.numVals + chan] /= numSamples;\n+                    }\n+                }\n+                colors = colors2;\n+            }\n+\n+            return colors;\n+        }\n+    };\n+\n+    var defaultLinearGraph = new LinearGraph();\n+    defaultLinearGraph.AddKey(0, 0);\n+    defaultLinearGraph.AddKey(1, 0);\n+\n+    var defaultLinearGraph3 = new LinearGraph(3);\n+    defaultLinearGraph3.AddKey(0, [0, 0, 0]);\n+    defaultLinearGraph3.AddKey(1, [0, 0, 0]);\n+\n+    var defaultParamTex = null;\n+\n+    var localOffsetVec = new pc.Vec3();\n+    var worldOffsetVec = new pc.Vec3();\n+    var rotMat = new pc.Mat4();\n+\n+    var setPropertyTarget;\n+    var setPropertyOptions;\n+\n+    function setProperty(pName, defaultVal) {\n+        setPropertyTarget[pName] = typeof setPropertyOptions[pName] !== 'undefined' ? setPropertyOptions[pName] : defaultVal;\n+    }\n+\n+    function Pack3NFloats(a, b, c) {\n+        var packed = ((a * 255) << 16) | ((b * 255) << 8) | (c * 255);\n+        return (packed) / (1 << 24);\n+    }\n+","path":"src/scene/scene_particleemitter2.js","position":189,"original_position":189,"commit_id":"b9c59b8a9e102a22e0a10636644f99da3ac994c1","original_commit_id":"b9c59b8a9e102a22e0a10636644f99da3ac994c1","user":{"login":"vkalpias","id":850969,"avatar_url":"https://avatars.githubusercontent.com/u/850969?v=2","gravatar_id":"","url":"https://api.github.com/users/vkalpias","html_url":"https://github.com/vkalpias","followers_url":"https://api.github.com/users/vkalpias/followers","following_url":"https://api.github.com/users/vkalpias/following{/other_user}","gists_url":"https://api.github.com/users/vkalpias/gists{/gist_id}","starred_url":"https://api.github.com/users/vkalpias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkalpias/subscriptions","organizations_url":"https://api.github.com/users/vkalpias/orgs","repos_url":"https://api.github.com/users/vkalpias/repos","events_url":"https://api.github.com/users/vkalpias/events{/privacy}","received_events_url":"https://api.github.com/users/vkalpias/received_events","type":"User","site_admin":false},"body":"[coding standards] method should start with lower case letter","created_at":"2014-09-25T09:39:42Z","updated_at":"2014-09-25T09:39:42Z","html_url":"https://github.com/playcanvas/engine/pull/42#discussion_r18022991","pull_request_url":"https://api.github.com/repos/playcanvas/engine/pulls/42","_links":{"self":{"href":"https://api.github.com/repos/playcanvas/engine/pulls/comments/18022991"},"html":{"href":"https://github.com/playcanvas/engine/pull/42#discussion_r18022991"},"pull_request":{"href":"https://api.github.com/repos/playcanvas/engine/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/playcanvas/engine/pulls/42","id":21737399,"html_url":"https://github.com/playcanvas/engine/pull/42","diff_url":"https://github.com/playcanvas/engine/pull/42.diff","patch_url":"https://github.com/playcanvas/engine/pull/42.patch","issue_url":"https://api.github.com/repos/playcanvas/engine/issues/42","number":42,"state":"open","locked":false,"title":"New particle system","user":{"login":"guycalledfrank","id":7008423,"avatar_url":"https://avatars.githubusercontent.com/u/7008423?v=2","gravatar_id":"","url":"https://api.github.com/users/guycalledfrank","html_url":"https://github.com/guycalledfrank","followers_url":"https://api.github.com/users/guycalledfrank/followers","following_url":"https://api.github.com/users/guycalledfrank/following{/other_user}","gists_url":"https://api.github.com/users/guycalledfrank/gists{/gist_id}","starred_url":"https://api.github.com/users/guycalledfrank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guycalledfrank/subscriptions","organizations_url":"https://api.github.com/users/guycalledfrank/orgs","repos_url":"https://api.github.com/users/guycalledfrank/repos","events_url":"https://api.github.com/users/guycalledfrank/events{/privacy}","received_events_url":"https://api.github.com/users/guycalledfrank/received_events","type":"User","site_admin":false},"body":"yay","created_at":"2014-09-24T19:14:11Z","updated_at":"2014-09-25T09:39:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66ce62e31e653986062c5621b578b8f1674092d6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/playcanvas/engine/pulls/42/commits","review_comments_url":"https://api.github.com/repos/playcanvas/engine/pulls/42/comments","review_comment_url":"https://api.github.com/repos/playcanvas/engine/pulls/comments/{number}","comments_url":"https://api.github.com/repos/playcanvas/engine/issues/42/comments","statuses_url":"https://api.github.com/repos/playcanvas/engine/statuses/b9c59b8a9e102a22e0a10636644f99da3ac994c1","head":{"label":"guycalledfrank:particle-system2","ref":"particle-system2","sha":"b9c59b8a9e102a22e0a10636644f99da3ac994c1","user":{"login":"guycalledfrank","id":7008423,"avatar_url":"https://avatars.githubusercontent.com/u/7008423?v=2","gravatar_id":"","url":"https://api.github.com/users/guycalledfrank","html_url":"https://github.com/guycalledfrank","followers_url":"https://api.github.com/users/guycalledfrank/followers","following_url":"https://api.github.com/users/guycalledfrank/following{/other_user}","gists_url":"https://api.github.com/users/guycalledfrank/gists{/gist_id}","starred_url":"https://api.github.com/users/guycalledfrank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guycalledfrank/subscriptions","organizations_url":"https://api.github.com/users/guycalledfrank/orgs","repos_url":"https://api.github.com/users/guycalledfrank/repos","events_url":"https://api.github.com/users/guycalledfrank/events{/privacy}","received_events_url":"https://api.github.com/users/guycalledfrank/received_events","type":"User","site_admin":false},"repo":{"id":24428576,"name":"engine","full_name":"guycalledfrank/engine","owner":{"login":"guycalledfrank","id":7008423,"avatar_url":"https://avatars.githubusercontent.com/u/7008423?v=2","gravatar_id":"","url":"https://api.github.com/users/guycalledfrank","html_url":"https://github.com/guycalledfrank","followers_url":"https://api.github.com/users/guycalledfrank/followers","following_url":"https://api.github.com/users/guycalledfrank/following{/other_user}","gists_url":"https://api.github.com/users/guycalledfrank/gists{/gist_id}","starred_url":"https://api.github.com/users/guycalledfrank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guycalledfrank/subscriptions","organizations_url":"https://api.github.com/users/guycalledfrank/orgs","repos_url":"https://api.github.com/users/guycalledfrank/repos","events_url":"https://api.github.com/users/guycalledfrank/events{/privacy}","received_events_url":"https://api.github.com/users/guycalledfrank/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/guycalledfrank/engine","description":"3D WebGL game engine with online toolset.","fork":true,"url":"https://api.github.com/repos/guycalledfrank/engine","forks_url":"https://api.github.com/repos/guycalledfrank/engine/forks","keys_url":"https://api.github.com/repos/guycalledfrank/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guycalledfrank/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guycalledfrank/engine/teams","hooks_url":"https://api.github.com/repos/guycalledfrank/engine/hooks","issue_events_url":"https://api.github.com/repos/guycalledfrank/engine/issues/events{/number}","events_url":"https://api.github.com/repos/guycalledfrank/engine/events","assignees_url":"https://api.github.com/repos/guycalledfrank/engine/assignees{/user}","branches_url":"https://api.github.com/repos/guycalledfrank/engine/branches{/branch}","tags_url":"https://api.github.com/repos/guycalledfrank/engine/tags","blobs_url":"https://api.github.com/repos/guycalledfrank/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guycalledfrank/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guycalledfrank/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/guycalledfrank/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guycalledfrank/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/guycalledfrank/engine/languages","stargazers_url":"https://api.github.com/repos/guycalledfrank/engine/stargazers","contributors_url":"https://api.github.com/repos/guycalledfrank/engine/contributors","subscribers_url":"https://api.github.com/repos/guycalledfrank/engine/subscribers","subscription_url":"https://api.github.com/repos/guycalledfrank/engine/subscription","commits_url":"https://api.github.com/repos/guycalledfrank/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/guycalledfrank/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/guycalledfrank/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/guycalledfrank/engine/issues/comments/{number}","contents_url":"https://api.github.com/repos/guycalledfrank/engine/contents/{+path}","compare_url":"https://api.github.com/repos/guycalledfrank/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guycalledfrank/engine/merges","archive_url":"https://api.github.com/repos/guycalledfrank/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guycalledfrank/engine/downloads","issues_url":"https://api.github.com/repos/guycalledfrank/engine/issues{/number}","pulls_url":"https://api.github.com/repos/guycalledfrank/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/guycalledfrank/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/guycalledfrank/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guycalledfrank/engine/labels{/name}","releases_url":"https://api.github.com/repos/guycalledfrank/engine/releases{/id}","created_at":"2014-09-24T19:04:22Z","updated_at":"2014-09-24T17:31:49Z","pushed_at":"2014-09-24T20:10:51Z","git_url":"git://github.com/guycalledfrank/engine.git","ssh_url":"git@github.com:guycalledfrank/engine.git","clone_url":"https://github.com/guycalledfrank/engine.git","svn_url":"https://github.com/guycalledfrank/engine","homepage":"https://playcanvas.com/","size":55339,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"playcanvas:master","ref":"master","sha":"1bf101f4aa16a76d599794a37229f0ca0dd2fc36","user":{"login":"playcanvas","id":1030579,"avatar_url":"https://avatars.githubusercontent.com/u/1030579?v=2","gravatar_id":"","url":"https://api.github.com/users/playcanvas","html_url":"https://github.com/playcanvas","followers_url":"https://api.github.com/users/playcanvas/followers","following_url":"https://api.github.com/users/playcanvas/following{/other_user}","gists_url":"https://api.github.com/users/playcanvas/gists{/gist_id}","starred_url":"https://api.github.com/users/playcanvas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/playcanvas/subscriptions","organizations_url":"https://api.github.com/users/playcanvas/orgs","repos_url":"https://api.github.com/users/playcanvas/repos","events_url":"https://api.github.com/users/playcanvas/events{/privacy}","received_events_url":"https://api.github.com/users/playcanvas/received_events","type":"Organization","site_admin":false},"repo":{"id":19696006,"name":"engine","full_name":"playcanvas/engine","owner":{"login":"playcanvas","id":1030579,"avatar_url":"https://avatars.githubusercontent.com/u/1030579?v=2","gravatar_id":"","url":"https://api.github.com/users/playcanvas","html_url":"https://github.com/playcanvas","followers_url":"https://api.github.com/users/playcanvas/followers","following_url":"https://api.github.com/users/playcanvas/following{/other_user}","gists_url":"https://api.github.com/users/playcanvas/gists{/gist_id}","starred_url":"https://api.github.com/users/playcanvas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/playcanvas/subscriptions","organizations_url":"https://api.github.com/users/playcanvas/orgs","repos_url":"https://api.github.com/users/playcanvas/repos","events_url":"https://api.github.com/users/playcanvas/events{/privacy}","received_events_url":"https://api.github.com/users/playcanvas/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/playcanvas/engine","description":"3D WebGL game engine with online toolset.","fork":false,"url":"https://api.github.com/repos/playcanvas/engine","forks_url":"https://api.github.com/repos/playcanvas/engine/forks","keys_url":"https://api.github.com/repos/playcanvas/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/playcanvas/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/playcanvas/engine/teams","hooks_url":"https://api.github.com/repos/playcanvas/engine/hooks","issue_events_url":"https://api.github.com/repos/playcanvas/engine/issues/events{/number}","events_url":"https://api.github.com/repos/playcanvas/engine/events","assignees_url":"https://api.github.com/repos/playcanvas/engine/assignees{/user}","branches_url":"https://api.github.com/repos/playcanvas/engine/branches{/branch}","tags_url":"https://api.github.com/repos/playcanvas/engine/tags","blobs_url":"https://api.github.com/repos/playcanvas/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/playcanvas/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/playcanvas/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/playcanvas/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/playcanvas/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/playcanvas/engine/languages","stargazers_url":"https://api.github.com/repos/playcanvas/engine/stargazers","contributors_url":"https://api.github.com/repos/playcanvas/engine/contributors","subscribers_url":"https://api.github.com/repos/playcanvas/engine/subscribers","subscription_url":"https://api.github.com/repos/playcanvas/engine/subscription","commits_url":"https://api.github.com/repos/playcanvas/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/playcanvas/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/playcanvas/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/playcanvas/engine/issues/comments/{number}","contents_url":"https://api.github.com/repos/playcanvas/engine/contents/{+path}","compare_url":"https://api.github.com/repos/playcanvas/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/playcanvas/engine/merges","archive_url":"https://api.github.com/repos/playcanvas/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/playcanvas/engine/downloads","issues_url":"https://api.github.com/repos/playcanvas/engine/issues{/number}","pulls_url":"https://api.github.com/repos/playcanvas/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/playcanvas/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/playcanvas/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/playcanvas/engine/labels{/name}","releases_url":"https://api.github.com/repos/playcanvas/engine/releases{/id}","created_at":"2014-05-12T11:24:30Z","updated_at":"2014-09-25T03:22:56Z","pushed_at":"2014-09-24T15:49:47Z","git_url":"git://github.com/playcanvas/engine.git","ssh_url":"git@github.com:playcanvas/engine.git","clone_url":"https://github.com/playcanvas/engine.git","svn_url":"https://github.com/playcanvas/engine","homepage":"https://playcanvas.com/","size":55339,"stargazers_count":799,"watchers_count":799,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":124,"mirror_url":null,"open_issues_count":13,"forks":124,"open_issues":13,"watchers":799,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/playcanvas/engine/pulls/42"},"html":{"href":"https://github.com/playcanvas/engine/pull/42"},"issue":{"href":"https://api.github.com/repos/playcanvas/engine/issues/42"},"comments":{"href":"https://api.github.com/repos/playcanvas/engine/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/playcanvas/engine/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/playcanvas/engine/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/playcanvas/engine/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/playcanvas/engine/statuses/b9c59b8a9e102a22e0a10636644f99da3ac994c1"}}}}