{"action":"created","comment":{"url":"https://api.github.com/repos/calder-gl/calder/pulls/comments/221474652","pull_request_review_id":160129833,"id":221474652,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTQ3NDY1Mg==","diff_hunk":"@@ -253,6 +253,102 @@ export class GeneratorInstance {\n     }\n }\n \n+type SOSMCParams = {\n+    start: string;\n+    sosmcDepth?: number;\n+    samples?: number | ((generation: number) => number);\n+    costFn: CostFn;\n+    heuristicScale?: number | ((generation: number) => number);\n+\n+    /**\n+     * For debugging, a callback can be passed in so that every sample in the final\n+     * generation can be examined.\n+     */\n+    iterationHook?: (instances: GeneratorInstance[]) => void;\n+\n+    timeBudget?: number;\n+};\n+\n+export type GeneratorStats = {\n+    realTime: number;\n+    cpuTime: number;\n+};\n+\n+/**\n+ * A class that controls the generation of a model using SOSMC. It schedules the optimization\n+ * to be broken up into chunks that run within a given time budget per frame, allowing the UI\n+ * to update. It can also be cancelled.\n+ */\n+export class GeneratorTask {\n+    private result: Model | undefined;\n+    private cancelled: boolean = false;\n+    private onComplete: ((model: Model, stats: GeneratorStats) => void) | undefined;\n+    private timeBudget: number = Infinity;\n+    private startTime: number = new Date().getTime();\n+    private cpuTime: number = 0;\n+\n+    /**\n+     * @param {number} timeBudget How much time in seconds can be spent per frame before the rest\n+     * of the work is deferred to the next frame. Note that it will only stop once it has gone OVER\n+     * this time budget (hopefully just by a little bit) so it is not a hard limit.\n+     */\n+    constructor(iterator: IterableIterator<Model | undefined>, timeBudget?: number) {","path":"src/armature/Generator.ts","position":43,"original_position":43,"commit_id":"63b421ccd7d8167d2fada41deae57eb45c84a030","original_commit_id":"63b421ccd7d8167d2fada41deae57eb45c84a030","user":{"login":"AndrewMcBurney","id":8942499,"node_id":"MDQ6VXNlcjg5NDI0OTk=","avatar_url":"https://avatars3.githubusercontent.com/u/8942499?v=4","gravatar_id":"","url":"https://api.github.com/users/AndrewMcBurney","html_url":"https://github.com/AndrewMcBurney","followers_url":"https://api.github.com/users/AndrewMcBurney/followers","following_url":"https://api.github.com/users/AndrewMcBurney/following{/other_user}","gists_url":"https://api.github.com/users/AndrewMcBurney/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewMcBurney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewMcBurney/subscriptions","organizations_url":"https://api.github.com/users/AndrewMcBurney/orgs","repos_url":"https://api.github.com/users/AndrewMcBurney/repos","events_url":"https://api.github.com/users/AndrewMcBurney/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewMcBurney/received_events","type":"User","site_admin":false},"body":"Could you add documentation for the iterator please too. If I'm being too nitty, just ignore me lol.","created_at":"2018-09-30T21:47:18Z","updated_at":"2018-09-30T21:47:18Z","html_url":"https://github.com/calder-gl/calder/pull/156#discussion_r221474652","pull_request_url":"https://api.github.com/repos/calder-gl/calder/pulls/156","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/calder-gl/calder/pulls/comments/221474652"},"html":{"href":"https://github.com/calder-gl/calder/pull/156#discussion_r221474652"},"pull_request":{"href":"https://api.github.com/repos/calder-gl/calder/pulls/156"}}},"pull_request":{"url":"https://api.github.com/repos/calder-gl/calder/pulls/156","id":219225839,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5MjI1ODM5","html_url":"https://github.com/calder-gl/calder/pull/156","diff_url":"https://github.com/calder-gl/calder/pull/156.diff","patch_url":"https://github.com/calder-gl/calder/pull/156.patch","issue_url":"https://api.github.com/repos/calder-gl/calder/issues/156","number":156,"state":"open","locked":false,"title":"Put SOSMC optimization in a coroutine so we can pause it","user":{"login":"davepagurek","id":5315059,"node_id":"MDQ6VXNlcjUzMTUwNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/5315059?v=4","gravatar_id":"","url":"https://api.github.com/users/davepagurek","html_url":"https://github.com/davepagurek","followers_url":"https://api.github.com/users/davepagurek/followers","following_url":"https://api.github.com/users/davepagurek/following{/other_user}","gists_url":"https://api.github.com/users/davepagurek/gists{/gist_id}","starred_url":"https://api.github.com/users/davepagurek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davepagurek/subscriptions","organizations_url":"https://api.github.com/users/davepagurek/orgs","repos_url":"https://api.github.com/users/davepagurek/repos","events_url":"https://api.github.com/users/davepagurek/events{/privacy}","received_events_url":"https://api.github.com/users/davepagurek/received_events","type":"User","site_admin":false},"body":"This changes the `generateSOSMC` method to return a task instead of running the whole thing synchronously. Now, we can do a `.then()` callback to get the model when the optimization is complete, and `.cancel()` if we want to stop it before it's done. This should let us do things in the editor like adjust Bezier paths and start rerunning SOSMC without entirely blocking the UI.\r\n\r\nFor the editor, we want a time budget that's closer to out frame rate (I use 1/30, but probably we actually want something slightly less than 1/30 if we want to not go lower than 30fps.) For actual timing analysis, use `Infinity` so that we don't spend extra time interrupting the coroutine.\r\n\r\nHere's what the example file looks like now. Note how it still animates the camera rotation while optimization is running.\r\n![async](https://user-images.githubusercontent.com/5315059/46262354-da465580-c4b4-11e8-967a-f0cce9a83da2.gif)\r\n","created_at":"2018-09-30T20:30:13Z","updated_at":"2018-09-30T21:47:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8854e79495790d53c4fdbcf706237bf70b1df969","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/calder-gl/calder/pulls/156/commits","review_comments_url":"https://api.github.com/repos/calder-gl/calder/pulls/156/comments","review_comment_url":"https://api.github.com/repos/calder-gl/calder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/calder-gl/calder/issues/156/comments","statuses_url":"https://api.github.com/repos/calder-gl/calder/statuses/63b421ccd7d8167d2fada41deae57eb45c84a030","head":{"label":"calder-gl:coroutine","ref":"coroutine","sha":"63b421ccd7d8167d2fada41deae57eb45c84a030","user":{"login":"calder-gl","id":32965382,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTY1Mzgy","avatar_url":"https://avatars1.githubusercontent.com/u/32965382?v=4","gravatar_id":"","url":"https://api.github.com/users/calder-gl","html_url":"https://github.com/calder-gl","followers_url":"https://api.github.com/users/calder-gl/followers","following_url":"https://api.github.com/users/calder-gl/following{/other_user}","gists_url":"https://api.github.com/users/calder-gl/gists{/gist_id}","starred_url":"https://api.github.com/users/calder-gl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calder-gl/subscriptions","organizations_url":"https://api.github.com/users/calder-gl/orgs","repos_url":"https://api.github.com/users/calder-gl/repos","events_url":"https://api.github.com/users/calder-gl/events{/privacy}","received_events_url":"https://api.github.com/users/calder-gl/received_events","type":"Organization","site_admin":false},"repo":{"id":130310539,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAzMTA1Mzk=","name":"calder","full_name":"calder-gl/calder","private":false,"owner":{"login":"calder-gl","id":32965382,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTY1Mzgy","avatar_url":"https://avatars1.githubusercontent.com/u/32965382?v=4","gravatar_id":"","url":"https://api.github.com/users/calder-gl","html_url":"https://github.com/calder-gl","followers_url":"https://api.github.com/users/calder-gl/followers","following_url":"https://api.github.com/users/calder-gl/following{/other_user}","gists_url":"https://api.github.com/users/calder-gl/gists{/gist_id}","starred_url":"https://api.github.com/users/calder-gl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calder-gl/subscriptions","organizations_url":"https://api.github.com/users/calder-gl/orgs","repos_url":"https://api.github.com/users/calder-gl/repos","events_url":"https://api.github.com/users/calder-gl/events{/privacy}","received_events_url":"https://api.github.com/users/calder-gl/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/calder-gl/calder","description":"A library for sculpting and manipulating complex 3D structures for the web.","fork":false,"url":"https://api.github.com/repos/calder-gl/calder","forks_url":"https://api.github.com/repos/calder-gl/calder/forks","keys_url":"https://api.github.com/repos/calder-gl/calder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/calder-gl/calder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/calder-gl/calder/teams","hooks_url":"https://api.github.com/repos/calder-gl/calder/hooks","issue_events_url":"https://api.github.com/repos/calder-gl/calder/issues/events{/number}","events_url":"https://api.github.com/repos/calder-gl/calder/events","assignees_url":"https://api.github.com/repos/calder-gl/calder/assignees{/user}","branches_url":"https://api.github.com/repos/calder-gl/calder/branches{/branch}","tags_url":"https://api.github.com/repos/calder-gl/calder/tags","blobs_url":"https://api.github.com/repos/calder-gl/calder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/calder-gl/calder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/calder-gl/calder/git/refs{/sha}","trees_url":"https://api.github.com/repos/calder-gl/calder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/calder-gl/calder/statuses/{sha}","languages_url":"https://api.github.com/repos/calder-gl/calder/languages","stargazers_url":"https://api.github.com/repos/calder-gl/calder/stargazers","contributors_url":"https://api.github.com/repos/calder-gl/calder/contributors","subscribers_url":"https://api.github.com/repos/calder-gl/calder/subscribers","subscription_url":"https://api.github.com/repos/calder-gl/calder/subscription","commits_url":"https://api.github.com/repos/calder-gl/calder/commits{/sha}","git_commits_url":"https://api.github.com/repos/calder-gl/calder/git/commits{/sha}","comments_url":"https://api.github.com/repos/calder-gl/calder/comments{/number}","issue_comment_url":"https://api.github.com/repos/calder-gl/calder/issues/comments{/number}","contents_url":"https://api.github.com/repos/calder-gl/calder/contents/{+path}","compare_url":"https://api.github.com/repos/calder-gl/calder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/calder-gl/calder/merges","archive_url":"https://api.github.com/repos/calder-gl/calder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/calder-gl/calder/downloads","issues_url":"https://api.github.com/repos/calder-gl/calder/issues{/number}","pulls_url":"https://api.github.com/repos/calder-gl/calder/pulls{/number}","milestones_url":"https://api.github.com/repos/calder-gl/calder/milestones{/number}","notifications_url":"https://api.github.com/repos/calder-gl/calder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/calder-gl/calder/labels{/name}","releases_url":"https://api.github.com/repos/calder-gl/calder/releases{/id}","deployments_url":"https://api.github.com/repos/calder-gl/calder/deployments","created_at":"2018-04-20T04:51:29Z","updated_at":"2018-09-29T18:19:54Z","pushed_at":"2018-09-30T20:30:14Z","git_url":"git://github.com/calder-gl/calder.git","ssh_url":"git@github.com:calder-gl/calder.git","clone_url":"https://github.com/calder-gl/calder.git","svn_url":"https://github.com/calder-gl/calder","homepage":"","size":562,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":33,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":33,"watchers":3,"default_branch":"master"}},"base":{"label":"calder-gl:master","ref":"master","sha":"5ceedab9a815f7f8f5563e4679160bf24770dfa3","user":{"login":"calder-gl","id":32965382,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTY1Mzgy","avatar_url":"https://avatars1.githubusercontent.com/u/32965382?v=4","gravatar_id":"","url":"https://api.github.com/users/calder-gl","html_url":"https://github.com/calder-gl","followers_url":"https://api.github.com/users/calder-gl/followers","following_url":"https://api.github.com/users/calder-gl/following{/other_user}","gists_url":"https://api.github.com/users/calder-gl/gists{/gist_id}","starred_url":"https://api.github.com/users/calder-gl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calder-gl/subscriptions","organizations_url":"https://api.github.com/users/calder-gl/orgs","repos_url":"https://api.github.com/users/calder-gl/repos","events_url":"https://api.github.com/users/calder-gl/events{/privacy}","received_events_url":"https://api.github.com/users/calder-gl/received_events","type":"Organization","site_admin":false},"repo":{"id":130310539,"node_id":"MDEwOlJlcG9zaXRvcnkxMzAzMTA1Mzk=","name":"calder","full_name":"calder-gl/calder","private":false,"owner":{"login":"calder-gl","id":32965382,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTY1Mzgy","avatar_url":"https://avatars1.githubusercontent.com/u/32965382?v=4","gravatar_id":"","url":"https://api.github.com/users/calder-gl","html_url":"https://github.com/calder-gl","followers_url":"https://api.github.com/users/calder-gl/followers","following_url":"https://api.github.com/users/calder-gl/following{/other_user}","gists_url":"https://api.github.com/users/calder-gl/gists{/gist_id}","starred_url":"https://api.github.com/users/calder-gl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calder-gl/subscriptions","organizations_url":"https://api.github.com/users/calder-gl/orgs","repos_url":"https://api.github.com/users/calder-gl/repos","events_url":"https://api.github.com/users/calder-gl/events{/privacy}","received_events_url":"https://api.github.com/users/calder-gl/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/calder-gl/calder","description":"A library for sculpting and manipulating complex 3D structures for the web.","fork":false,"url":"https://api.github.com/repos/calder-gl/calder","forks_url":"https://api.github.com/repos/calder-gl/calder/forks","keys_url":"https://api.github.com/repos/calder-gl/calder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/calder-gl/calder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/calder-gl/calder/teams","hooks_url":"https://api.github.com/repos/calder-gl/calder/hooks","issue_events_url":"https://api.github.com/repos/calder-gl/calder/issues/events{/number}","events_url":"https://api.github.com/repos/calder-gl/calder/events","assignees_url":"https://api.github.com/repos/calder-gl/calder/assignees{/user}","branches_url":"https://api.github.com/repos/calder-gl/calder/branches{/branch}","tags_url":"https://api.github.com/repos/calder-gl/calder/tags","blobs_url":"https://api.github.com/repos/calder-gl/calder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/calder-gl/calder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/calder-gl/calder/git/refs{/sha}","trees_url":"https://api.github.com/repos/calder-gl/calder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/calder-gl/calder/statuses/{sha}","languages_url":"https://api.github.com/repos/calder-gl/calder/languages","stargazers_url":"https://api.github.com/repos/calder-gl/calder/stargazers","contributors_url":"https://api.github.com/repos/calder-gl/calder/contributors","subscribers_url":"https://api.github.com/repos/calder-gl/calder/subscribers","subscription_url":"https://api.github.com/repos/calder-gl/calder/subscription","commits_url":"https://api.github.com/repos/calder-gl/calder/commits{/sha}","git_commits_url":"https://api.github.com/repos/calder-gl/calder/git/commits{/sha}","comments_url":"https://api.github.com/repos/calder-gl/calder/comments{/number}","issue_comment_url":"https://api.github.com/repos/calder-gl/calder/issues/comments{/number}","contents_url":"https://api.github.com/repos/calder-gl/calder/contents/{+path}","compare_url":"https://api.github.com/repos/calder-gl/calder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/calder-gl/calder/merges","archive_url":"https://api.github.com/repos/calder-gl/calder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/calder-gl/calder/downloads","issues_url":"https://api.github.com/repos/calder-gl/calder/issues{/number}","pulls_url":"https://api.github.com/repos/calder-gl/calder/pulls{/number}","milestones_url":"https://api.github.com/repos/calder-gl/calder/milestones{/number}","notifications_url":"https://api.github.com/repos/calder-gl/calder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/calder-gl/calder/labels{/name}","releases_url":"https://api.github.com/repos/calder-gl/calder/releases{/id}","deployments_url":"https://api.github.com/repos/calder-gl/calder/deployments","created_at":"2018-04-20T04:51:29Z","updated_at":"2018-09-29T18:19:54Z","pushed_at":"2018-09-30T20:30:14Z","git_url":"git://github.com/calder-gl/calder.git","ssh_url":"git@github.com:calder-gl/calder.git","clone_url":"https://github.com/calder-gl/calder.git","svn_url":"https://github.com/calder-gl/calder","homepage":"","size":562,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":33,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":33,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/calder-gl/calder/pulls/156"},"html":{"href":"https://github.com/calder-gl/calder/pull/156"},"issue":{"href":"https://api.github.com/repos/calder-gl/calder/issues/156"},"comments":{"href":"https://api.github.com/repos/calder-gl/calder/issues/156/comments"},"review_comments":{"href":"https://api.github.com/repos/calder-gl/calder/pulls/156/comments"},"review_comment":{"href":"https://api.github.com/repos/calder-gl/calder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/calder-gl/calder/pulls/156/commits"},"statuses":{"href":"https://api.github.com/repos/calder-gl/calder/statuses/63b421ccd7d8167d2fada41deae57eb45c84a030"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"AndrewMcBurney"}}