{"action":"created","comment":{"url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/comments/65794892","id":65794892,"diff_hunk":"@@ -190,6 +191,59 @@ function lightDefaults(gltf) {\n     }\n }\n \n+function checkIfFloatVec4(value) {\n+    if (defined(value) && value.length === 4) {\n+        if (typeof(value[0]) === 'number' &&\n+            typeof(value[1]) === 'number' &&\n+            typeof(value[2]) === 'number' &&\n+            typeof(value[3]) === 'number') return value;\n+    }\n+    else return [0, 0, 0, 1];\n+}\n+\n+function guessExtensionTechnique(material) {\n+    // Replaces the material technique, extension, and values with a close equivalent from KHR_materials_common.\n+    // If no equivalent can be found, defaults to blinn for specular materials and lambert otherwise\n+    var technique = 'LAMBERT';\n+    var useBlinn = false;\n+    var values = defined(material.values) ? material.values : {};\n+\n+    var ambient = checkIfFloatVec4(values.ambient);\n+    var diffuse = typeof(values.diffuse) === 'string' ? values.diffuse : checkIfFloatVec4(values.diffuse);\n+    var doubleSided = typeof(values.doubleSided) === 'boolean' ? values.doubleSided : false;\n+    var emission = typeof(values.emission) === 'string' ? values.emission : checkIfFloatVec4(values.emission);\n+    var specular = typeof(values.specular) === 'string' ? values.specular : checkIfFloatVec4(values.specular);\n+    var shininess = typeof(values.shininess) === 'number' ? values.shininess : 0.0;","path":"lib/addDefaults.js","position":34,"original_position":34,"commit_id":"1e68c45b6b81d3535aec36e800d060fc2c9942c9","original_commit_id":"1e68c45b6b81d3535aec36e800d060fc2c9942c9","user":{"login":"likangning93","id":5395255,"avatar_url":"https://avatars.githubusercontent.com/u/5395255?v=3","gravatar_id":"","url":"https://api.github.com/users/likangning93","html_url":"https://github.com/likangning93","followers_url":"https://api.github.com/users/likangning93/followers","following_url":"https://api.github.com/users/likangning93/following{/other_user}","gists_url":"https://api.github.com/users/likangning93/gists{/gist_id}","starred_url":"https://api.github.com/users/likangning93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/likangning93/subscriptions","organizations_url":"https://api.github.com/users/likangning93/orgs","repos_url":"https://api.github.com/users/likangning93/repos","events_url":"https://api.github.com/users/likangning93/events{/privacy}","received_events_url":"https://api.github.com/users/likangning93/received_events","type":"User","site_admin":false},"body":"We're keeping the `typeof` checks to make sure something like `shininess` as a texture map in a more customized gltf doesn't make its way into the `KHR_materials_common`.","created_at":"2016-06-04T01:36:07Z","updated_at":"2016-06-04T01:36:07Z","html_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/55#discussion_r65794892","pull_request_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55","_links":{"self":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/comments/65794892"},"html":{"href":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/55#discussion_r65794892"},"pull_request":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55"}}},"pull_request":{"url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55","id":72534320,"html_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/55","diff_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/55.diff","patch_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/55.patch","issue_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/55","number":55,"state":"open","locked":false,"title":"Added KHR_materials_common materials/techniques/shaders to addDefaults","user":{"login":"likangning93","id":5395255,"avatar_url":"https://avatars.githubusercontent.com/u/5395255?v=3","gravatar_id":"","url":"https://api.github.com/users/likangning93","html_url":"https://github.com/likangning93","followers_url":"https://api.github.com/users/likangning93/followers","following_url":"https://api.github.com/users/likangning93/following{/other_user}","gists_url":"https://api.github.com/users/likangning93/gists{/gist_id}","starred_url":"https://api.github.com/users/likangning93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/likangning93/subscriptions","organizations_url":"https://api.github.com/users/likangning93/orgs","repos_url":"https://api.github.com/users/likangning93/repos","events_url":"https://api.github.com/users/likangning93/events{/privacy}","received_events_url":"https://api.github.com/users/likangning93/received_events","type":"User","site_admin":false},"body":"@JoshuaStorm and I wrote this to have `defaultMaterials` try to match the existing gltf material values to one of the `KHR_materials_common` materials, apply the appropriate extension, and then pass the gltf to `modelMaterialsCommon` at the end of `addDefaults`.\r\n\r\nAlso added some tests to `addDefaultsSpec`.\r\n\r\nSee https://github.com/AnalyticalGraphicsInc/gltf-pipeline/issues/1","created_at":"2016-06-03T16:29:20Z","updated_at":"2016-06-04T01:36:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1048b4ce6967675b80df941582f3c08b108fef11","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55/commits","review_comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55/comments","review_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/55/comments","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/statuses/1e68c45b6b81d3535aec36e800d060fc2c9942c9","head":{"label":"AnalyticalGraphicsInc:materialsStageKHR","ref":"materialsStageKHR","sha":"1e68c45b6b81d3535aec36e800d060fc2c9942c9","user":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"repo":{"id":46226879,"name":"gltf-pipeline","full_name":"AnalyticalGraphicsInc/gltf-pipeline","owner":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline","description":"Content pipeline tools for optimizing glTF assets","fork":false,"url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline","forks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/forks","keys_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/teams","hooks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/hooks","issue_events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/events{/number}","events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/events","assignees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/assignees{/user}","branches_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/branches{/branch}","tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/tags","blobs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/statuses/{sha}","languages_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/languages","stargazers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/stargazers","contributors_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/contributors","subscribers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/subscribers","subscription_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/subscription","commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/contents/{+path}","compare_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/merges","archive_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/downloads","issues_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues{/number}","pulls_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls{/number}","milestones_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/milestones{/number}","notifications_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/labels{/name}","releases_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/releases{/id}","deployments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/deployments","created_at":"2015-11-15T17:00:20Z","updated_at":"2016-04-11T22:26:43Z","pushed_at":"2016-06-04T00:37:44Z","git_url":"git://github.com/AnalyticalGraphicsInc/gltf-pipeline.git","ssh_url":"git@github.com:AnalyticalGraphicsInc/gltf-pipeline.git","clone_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline.git","svn_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline","homepage":null,"size":518,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":13,"default_branch":"master"}},"base":{"label":"AnalyticalGraphicsInc:master","ref":"master","sha":"3db33068aa04e5b0b60b3324b8140156f4150f13","user":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"repo":{"id":46226879,"name":"gltf-pipeline","full_name":"AnalyticalGraphicsInc/gltf-pipeline","owner":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline","description":"Content pipeline tools for optimizing glTF assets","fork":false,"url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline","forks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/forks","keys_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/teams","hooks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/hooks","issue_events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/events{/number}","events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/events","assignees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/assignees{/user}","branches_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/branches{/branch}","tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/tags","blobs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/statuses/{sha}","languages_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/languages","stargazers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/stargazers","contributors_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/contributors","subscribers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/subscribers","subscription_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/subscription","commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/contents/{+path}","compare_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/merges","archive_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/downloads","issues_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues{/number}","pulls_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls{/number}","milestones_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/milestones{/number}","notifications_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/labels{/name}","releases_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/releases{/id}","deployments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/deployments","created_at":"2015-11-15T17:00:20Z","updated_at":"2016-04-11T22:26:43Z","pushed_at":"2016-06-04T00:37:44Z","git_url":"git://github.com/AnalyticalGraphicsInc/gltf-pipeline.git","ssh_url":"git@github.com:AnalyticalGraphicsInc/gltf-pipeline.git","clone_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline.git","svn_url":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline","homepage":null,"size":518,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55"},"html":{"href":"https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/55"},"issue":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/55"},"comments":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/issues/55/comments"},"review_comments":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55/comments"},"review_comment":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/pulls/55/commits"},"statuses":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/gltf-pipeline/statuses/1e68c45b6b81d3535aec36e800d060fc2c9942c9"}}}}
{"actor":{"display_login":"likangning93"}}