{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/6419","repository_url":"https://api.github.com/repos/mrdoob/three.js","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/6419/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/6419/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/6419/events","html_url":"https://github.com/mrdoob/three.js/issues/6419","id":68988827,"number":6419,"title":"Adopt some ES6 features","user":{"login":"lmcd","id":363540,"avatar_url":"https://avatars.githubusercontent.com/u/363540?v=3","gravatar_id":"","url":"https://api.github.com/users/lmcd","html_url":"https://github.com/lmcd","followers_url":"https://api.github.com/users/lmcd/followers","following_url":"https://api.github.com/users/lmcd/following{/other_user}","gists_url":"https://api.github.com/users/lmcd/gists{/gist_id}","starred_url":"https://api.github.com/users/lmcd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmcd/subscriptions","organizations_url":"https://api.github.com/users/lmcd/orgs","repos_url":"https://api.github.com/users/lmcd/repos","events_url":"https://api.github.com/users/lmcd/events{/privacy}","received_events_url":"https://api.github.com/users/lmcd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mrdoob/three.js/labels/Suggestion","name":"Suggestion","color":"ffffcf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":35,"created_at":"2015-04-16T19:02:47Z","updated_at":"2016-03-09T23:45:33Z","closed_at":null,"body":"ES6 is coming, with browsers and tools now rapidly gaining support. I think THREE.js could benefit enormously from some of the new features brought by ES6.\r\n\r\nFor fun and to encourage debate surrounding a possible migration of the project, I've created this issue and created some code examples.\r\n\r\nFeatures demonstrated in the below examples:\r\n* Default parameters\r\n* Block-scoped `let` keyword\r\n* Iterators + For..Of\r\n* Classes\r\n* Arrow Functions\r\n* Generators\r\n* Modules\r\n\r\n#### Class Example\r\n````\r\nimport Object3D from '../core/Object3D';\r\nimport Geometry from '../core/Geometry';\r\nimport MeshBasicMaterial from '../materials/MeshBasicMaterial';\r\n\r\nclass Mesh extends Object3D {\r\n\tconstructor(\r\n\t\tgeometry = new Geometry(),\r\n\t\tmaterial = new MeshBasicMaterial({color: Math.random() * 0xffffff}\r\n\t) {\r\n\t\tsuper();\r\n\r\n\t\tthis.geometry = geometry;\r\n\t\tthis.material = material;\r\n\r\n\t\tthis.updateMorphTargets();\r\n\t}\r\n}\r\n\r\nexport default Mesh;\r\n````\r\n\r\n#### Traversal Generator Example\r\n\r\n    class Object3D {\r\n        constructor() {\r\n            ...\r\n        }\r\n\r\n        traverse(callback) {\r\n            callback(this);\r\n\r\n            for (let object of this.children) {\r\n                object.traverse(callback);\r\n            }\r\n        },\r\n\r\n        *traversalGenerator() {\r\n            this.traverse(object => yield object);\r\n        }\r\n\r\n        ...\r\n    }\r\n\r\nGenerator in use:\r\n\r\n    for (let object of scene.traversalGenerator()) {\r\n        if (object.name === 'Blah') {\r\n            break;\r\n        }\r\n    }\r\n\r\nNote: I haven't tested any of this"},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/194570385","html_url":"https://github.com/mrdoob/three.js/issues/6419#issuecomment-194570385","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/6419","id":194570385,"user":{"login":"zz85","id":314997,"avatar_url":"https://avatars.githubusercontent.com/u/314997?v=3","gravatar_id":"","url":"https://api.github.com/users/zz85","html_url":"https://github.com/zz85","followers_url":"https://api.github.com/users/zz85/followers","following_url":"https://api.github.com/users/zz85/following{/other_user}","gists_url":"https://api.github.com/users/zz85/gists{/gist_id}","starred_url":"https://api.github.com/users/zz85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zz85/subscriptions","organizations_url":"https://api.github.com/users/zz85/orgs","repos_url":"https://api.github.com/users/zz85/repos","events_url":"https://api.github.com/users/zz85/events{/privacy}","received_events_url":"https://api.github.com/users/zz85/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T23:45:33Z","updated_at":"2016-03-09T23:45:33Z","body":"Some cents on working on ES2015 (mainly in node)\r\n\r\n- there are places Javascript engines (eg. V8) needs to play catch up optimizing ES6 features\r\n- from my experience code like `let x = 1, y = 2` would deoptimize v8 although I would expect v8 to be supporting it eventually\r\n- transpiled code to ES5 can be run slower than ES6 code (which is why I prefer to use only supported ES6 features in >node 4, that is almost everything except the import export system)\r\n- Maps and Sets are performance wins\r\n- Classes are nice\r\n- Using Babel can be a pain to your workflow, probably not worth the effort if using ES6 purely for syntax sugar"}}