{"action":"created","comment":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/comments/59993511","id":59993511,"diff_hunk":"@@ -2806,8 +2812,6 @@ THREE.WebGLRenderer = function ( parameters ) {\n \n \tfunction setTexture2D( texture, slot ) {\n \n-\t\tif ( texture instanceof THREE.WebGLRenderTarget ) texture = texture.texture;","path":"src/renderers/WebGLRenderer.js","position":67,"original_position":67,"commit_id":"4c4a9501a88f1e4d08fbd59306faeb18c769e890","original_commit_id":"4c4a9501a88f1e4d08fbd59306faeb18c769e890","user":{"login":"tschw","id":3916357,"avatar_url":"https://avatars.githubusercontent.com/u/3916357?v=3","gravatar_id":"","url":"https://api.github.com/users/tschw","html_url":"https://github.com/tschw","followers_url":"https://api.github.com/users/tschw/followers","following_url":"https://api.github.com/users/tschw/following{/other_user}","gists_url":"https://api.github.com/users/tschw/gists{/gist_id}","starred_url":"https://api.github.com/users/tschw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschw/subscriptions","organizations_url":"https://api.github.com/users/tschw/orgs","repos_url":"https://api.github.com/users/tschw/repos","events_url":"https://api.github.com/users/tschw/events{/privacy}","received_events_url":"https://api.github.com/users/tschw/received_events","type":"User","site_admin":false},"body":"Where did this check (2D case) go? Also should warn, I guess?","created_at":"2016-04-17T21:37:09Z","updated_at":"2016-04-17T21:37:09Z","html_url":"https://github.com/mrdoob/three.js/pull/8658#discussion_r59993511","pull_request_url":"https://api.github.com/repos/mrdoob/three.js/pulls/8658","_links":{"self":{"href":"https://api.github.com/repos/mrdoob/three.js/pulls/comments/59993511"},"html":{"href":"https://github.com/mrdoob/three.js/pull/8658#discussion_r59993511"},"pull_request":{"href":"https://api.github.com/repos/mrdoob/three.js/pulls/8658"}}},"pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/8658","id":66781219,"html_url":"https://github.com/mrdoob/three.js/pull/8658","diff_url":"https://github.com/mrdoob/three.js/pull/8658.diff","patch_url":"https://github.com/mrdoob/three.js/pull/8658.patch","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/8658","number":8658,"state":"open","locked":false,"title":"Don't treat render targets like textures.","user":{"login":"vanruesc","id":9214917,"avatar_url":"https://avatars.githubusercontent.com/u/9214917?v=3","gravatar_id":"","url":"https://api.github.com/users/vanruesc","html_url":"https://github.com/vanruesc","followers_url":"https://api.github.com/users/vanruesc/followers","following_url":"https://api.github.com/users/vanruesc/following{/other_user}","gists_url":"https://api.github.com/users/vanruesc/gists{/gist_id}","starred_url":"https://api.github.com/users/vanruesc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanruesc/subscriptions","organizations_url":"https://api.github.com/users/vanruesc/orgs","repos_url":"https://api.github.com/users/vanruesc/repos","events_url":"https://api.github.com/users/vanruesc/events{/privacy}","received_events_url":"https://api.github.com/users/vanruesc/received_events","type":"User","site_admin":false},"body":"Hi,\r\n\r\nin #8615 I outlined some difficulties that arised during an attempt to move away from treating render targets like textures. @tschw informed me about relevant changes that paved the way for a straight-forward solution to all this.\r\n\r\nIn #8417 I stated that I'd start with refactoring the examples, but it turned out that this doesn't work anymore because of [this line](https://github.com/mrdoob/three.js/pull/8606/commits/3c354341e14d6ba8e04b6ee2698a6b613453bd70#diff-c0e88b98497597a015ecf238e91ac3a0R3042). If you use the `texture` property of a `CubeCamera`'s `renderTarget` as a map right now, it will break things. So I chose to do it the other way around and started with refactoring the library.\r\n\r\nWarnings regarding the use of render targets as textures won't be spammed. I used IIFEs for better encapsulation for the backwards compatibility code and marked the code that might not be easily identified as back-compat code.\r\n\r\nIn an earlier [diff comment](https://github.com/mrdoob/three.js/pull/8417/files#r57252265) @mrdoob suggested to use `material.envMap instanceof THREE.CubeTexture` instead of a dynamic flag and I replied that the CubeTexture wasn't involved in the respective logic. However, after thinking about alternatives for a while I eventually realised that I was wrong. It's possible to just use the fact that the CubeTexture is not involved directly, because it's involved indirectly. I'm not too familiar with the codebase and that got in my way of thinking.\r\n\r\n```js\r\nuniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : - 1;\r\n``` \r\ncan be replicated as\r\n```js\r\nuniforms.flipEnvMap.value = ( ! ( material.envMap instanceof THREE.CubeTexture ) ) ? 1 : - 1;\r\n```\r\nWith this, `WebGLRenderTargetCube` and `Texture` can be left untouched.\r\n\r\nI made sure that all the examples work with these changes. I also refactored and checked them again for a seperate PR in case this one gets merged.\r\n","created_at":"2016-04-17T21:00:16Z","updated_at":"2016-04-17T21:37:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c349afc8def85880e2eb88f41b981a77e85056f3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mrdoob/three.js/pulls/8658/commits","review_comments_url":"https://api.github.com/repos/mrdoob/three.js/pulls/8658/comments","review_comment_url":"https://api.github.com/repos/mrdoob/three.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/8658/comments","statuses_url":"https://api.github.com/repos/mrdoob/three.js/statuses/4c4a9501a88f1e4d08fbd59306faeb18c769e890","head":{"label":"vanruesc:dev","ref":"dev","sha":"4c4a9501a88f1e4d08fbd59306faeb18c769e890","user":{"login":"vanruesc","id":9214917,"avatar_url":"https://avatars.githubusercontent.com/u/9214917?v=3","gravatar_id":"","url":"https://api.github.com/users/vanruesc","html_url":"https://github.com/vanruesc","followers_url":"https://api.github.com/users/vanruesc/followers","following_url":"https://api.github.com/users/vanruesc/following{/other_user}","gists_url":"https://api.github.com/users/vanruesc/gists{/gist_id}","starred_url":"https://api.github.com/users/vanruesc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanruesc/subscriptions","organizations_url":"https://api.github.com/users/vanruesc/orgs","repos_url":"https://api.github.com/users/vanruesc/repos","events_url":"https://api.github.com/users/vanruesc/events{/privacy}","received_events_url":"https://api.github.com/users/vanruesc/received_events","type":"User","site_admin":false},"repo":{"id":56447236,"name":"three.js","full_name":"vanruesc/three.js","owner":{"login":"vanruesc","id":9214917,"avatar_url":"https://avatars.githubusercontent.com/u/9214917?v=3","gravatar_id":"","url":"https://api.github.com/users/vanruesc","html_url":"https://github.com/vanruesc","followers_url":"https://api.github.com/users/vanruesc/followers","following_url":"https://api.github.com/users/vanruesc/following{/other_user}","gists_url":"https://api.github.com/users/vanruesc/gists{/gist_id}","starred_url":"https://api.github.com/users/vanruesc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanruesc/subscriptions","organizations_url":"https://api.github.com/users/vanruesc/orgs","repos_url":"https://api.github.com/users/vanruesc/repos","events_url":"https://api.github.com/users/vanruesc/events{/privacy}","received_events_url":"https://api.github.com/users/vanruesc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vanruesc/three.js","description":"JavaScript 3D library.","fork":true,"url":"https://api.github.com/repos/vanruesc/three.js","forks_url":"https://api.github.com/repos/vanruesc/three.js/forks","keys_url":"https://api.github.com/repos/vanruesc/three.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanruesc/three.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanruesc/three.js/teams","hooks_url":"https://api.github.com/repos/vanruesc/three.js/hooks","issue_events_url":"https://api.github.com/repos/vanruesc/three.js/issues/events{/number}","events_url":"https://api.github.com/repos/vanruesc/three.js/events","assignees_url":"https://api.github.com/repos/vanruesc/three.js/assignees{/user}","branches_url":"https://api.github.com/repos/vanruesc/three.js/branches{/branch}","tags_url":"https://api.github.com/repos/vanruesc/three.js/tags","blobs_url":"https://api.github.com/repos/vanruesc/three.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanruesc/three.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanruesc/three.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanruesc/three.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanruesc/three.js/statuses/{sha}","languages_url":"https://api.github.com/repos/vanruesc/three.js/languages","stargazers_url":"https://api.github.com/repos/vanruesc/three.js/stargazers","contributors_url":"https://api.github.com/repos/vanruesc/three.js/contributors","subscribers_url":"https://api.github.com/repos/vanruesc/three.js/subscribers","subscription_url":"https://api.github.com/repos/vanruesc/three.js/subscription","commits_url":"https://api.github.com/repos/vanruesc/three.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanruesc/three.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanruesc/three.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanruesc/three.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanruesc/three.js/contents/{+path}","compare_url":"https://api.github.com/repos/vanruesc/three.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanruesc/three.js/merges","archive_url":"https://api.github.com/repos/vanruesc/three.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanruesc/three.js/downloads","issues_url":"https://api.github.com/repos/vanruesc/three.js/issues{/number}","pulls_url":"https://api.github.com/repos/vanruesc/three.js/pulls{/number}","milestones_url":"https://api.github.com/repos/vanruesc/three.js/milestones{/number}","notifications_url":"https://api.github.com/repos/vanruesc/three.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanruesc/three.js/labels{/name}","releases_url":"https://api.github.com/repos/vanruesc/three.js/releases{/id}","deployments_url":"https://api.github.com/repos/vanruesc/three.js/deployments","created_at":"2016-04-17T16:41:18Z","updated_at":"2016-04-17T16:41:23Z","pushed_at":"2016-04-17T19:40:35Z","git_url":"git://github.com/vanruesc/three.js.git","ssh_url":"git@github.com:vanruesc/three.js.git","clone_url":"https://github.com/vanruesc/three.js.git","svn_url":"https://github.com/vanruesc/three.js","homepage":"http://threejs.org/","size":373454,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"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":"mrdoob:dev","ref":"dev","sha":"5e9d77b753207bbe8f7d69268e514cb719ac6a21","user":{"login":"mrdoob","id":97088,"avatar_url":"https://avatars.githubusercontent.com/u/97088?v=3","gravatar_id":"","url":"https://api.github.com/users/mrdoob","html_url":"https://github.com/mrdoob","followers_url":"https://api.github.com/users/mrdoob/followers","following_url":"https://api.github.com/users/mrdoob/following{/other_user}","gists_url":"https://api.github.com/users/mrdoob/gists{/gist_id}","starred_url":"https://api.github.com/users/mrdoob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrdoob/subscriptions","organizations_url":"https://api.github.com/users/mrdoob/orgs","repos_url":"https://api.github.com/users/mrdoob/repos","events_url":"https://api.github.com/users/mrdoob/events{/privacy}","received_events_url":"https://api.github.com/users/mrdoob/received_events","type":"User","site_admin":false},"repo":{"id":576201,"name":"three.js","full_name":"mrdoob/three.js","owner":{"login":"mrdoob","id":97088,"avatar_url":"https://avatars.githubusercontent.com/u/97088?v=3","gravatar_id":"","url":"https://api.github.com/users/mrdoob","html_url":"https://github.com/mrdoob","followers_url":"https://api.github.com/users/mrdoob/followers","following_url":"https://api.github.com/users/mrdoob/following{/other_user}","gists_url":"https://api.github.com/users/mrdoob/gists{/gist_id}","starred_url":"https://api.github.com/users/mrdoob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrdoob/subscriptions","organizations_url":"https://api.github.com/users/mrdoob/orgs","repos_url":"https://api.github.com/users/mrdoob/repos","events_url":"https://api.github.com/users/mrdoob/events{/privacy}","received_events_url":"https://api.github.com/users/mrdoob/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrdoob/three.js","description":"JavaScript 3D library.","fork":false,"url":"https://api.github.com/repos/mrdoob/three.js","forks_url":"https://api.github.com/repos/mrdoob/three.js/forks","keys_url":"https://api.github.com/repos/mrdoob/three.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrdoob/three.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrdoob/three.js/teams","hooks_url":"https://api.github.com/repos/mrdoob/three.js/hooks","issue_events_url":"https://api.github.com/repos/mrdoob/three.js/issues/events{/number}","events_url":"https://api.github.com/repos/mrdoob/three.js/events","assignees_url":"https://api.github.com/repos/mrdoob/three.js/assignees{/user}","branches_url":"https://api.github.com/repos/mrdoob/three.js/branches{/branch}","tags_url":"https://api.github.com/repos/mrdoob/three.js/tags","blobs_url":"https://api.github.com/repos/mrdoob/three.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrdoob/three.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrdoob/three.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrdoob/three.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrdoob/three.js/statuses/{sha}","languages_url":"https://api.github.com/repos/mrdoob/three.js/languages","stargazers_url":"https://api.github.com/repos/mrdoob/three.js/stargazers","contributors_url":"https://api.github.com/repos/mrdoob/three.js/contributors","subscribers_url":"https://api.github.com/repos/mrdoob/three.js/subscribers","subscription_url":"https://api.github.com/repos/mrdoob/three.js/subscription","commits_url":"https://api.github.com/repos/mrdoob/three.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrdoob/three.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrdoob/three.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrdoob/three.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrdoob/three.js/contents/{+path}","compare_url":"https://api.github.com/repos/mrdoob/three.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrdoob/three.js/merges","archive_url":"https://api.github.com/repos/mrdoob/three.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrdoob/three.js/downloads","issues_url":"https://api.github.com/repos/mrdoob/three.js/issues{/number}","pulls_url":"https://api.github.com/repos/mrdoob/three.js/pulls{/number}","milestones_url":"https://api.github.com/repos/mrdoob/three.js/milestones{/number}","notifications_url":"https://api.github.com/repos/mrdoob/three.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrdoob/three.js/labels{/name}","releases_url":"https://api.github.com/repos/mrdoob/three.js/releases{/id}","deployments_url":"https://api.github.com/repos/mrdoob/three.js/deployments","created_at":"2010-03-23T18:58:01Z","updated_at":"2016-04-17T21:06:26Z","pushed_at":"2016-04-17T21:00:16Z","git_url":"git://github.com/mrdoob/three.js.git","ssh_url":"git@github.com:mrdoob/three.js.git","clone_url":"https://github.com/mrdoob/three.js.git","svn_url":"https://github.com/mrdoob/three.js","homepage":"http://threejs.org/","size":576102,"stargazers_count":24426,"watchers_count":24426,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":8023,"mirror_url":null,"open_issues_count":628,"forks":8023,"open_issues":628,"watchers":24426,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mrdoob/three.js/pulls/8658"},"html":{"href":"https://github.com/mrdoob/three.js/pull/8658"},"issue":{"href":"https://api.github.com/repos/mrdoob/three.js/issues/8658"},"comments":{"href":"https://api.github.com/repos/mrdoob/three.js/issues/8658/comments"},"review_comments":{"href":"https://api.github.com/repos/mrdoob/three.js/pulls/8658/comments"},"review_comment":{"href":"https://api.github.com/repos/mrdoob/three.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mrdoob/three.js/pulls/8658/commits"},"statuses":{"href":"https://api.github.com/repos/mrdoob/three.js/statuses/4c4a9501a88f1e4d08fbd59306faeb18c769e890"}}}}