{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/8459","repository_url":"https://api.github.com/repos/mrdoob/three.js","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/8459/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/8459/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/8459/events","html_url":"https://github.com/mrdoob/three.js/issues/8459","id":143204891,"number":8459,"title":"X, Y and Z axes as default values in three.js core","user":{"login":"Wilt","id":2419627,"avatar_url":"https://avatars.githubusercontent.com/u/2419627?v=3","gravatar_id":"","url":"https://api.github.com/users/Wilt","html_url":"https://github.com/Wilt","followers_url":"https://api.github.com/users/Wilt/followers","following_url":"https://api.github.com/users/Wilt/following{/other_user}","gists_url":"https://api.github.com/users/Wilt/gists{/gist_id}","starred_url":"https://api.github.com/users/Wilt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wilt/subscriptions","organizations_url":"https://api.github.com/users/Wilt/orgs","repos_url":"https://api.github.com/users/Wilt/repos","events_url":"https://api.github.com/users/Wilt/events{/privacy}","received_events_url":"https://api.github.com/users/Wilt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-24T10:04:30Z","updated_at":"2016-03-24T20:31:16Z","closed_at":null,"body":"##### Description of the feature request/enhancement\r\n\r\nI notice that I often have to use xAxis, yAxis and zAxis in my three.js application.\r\nBecause of this I repeatingly end up creating new `Vector3` objects whenever I need these axes, which seems a bit unnecessary. Would it be possible to make default axes part of the core?\r\nSomething like:\r\n\r\n    THREE.Default.XAxis = new THREE.Vector3( 1, 0, 0 );\r\n    THREE.Default.YAxis = new THREE.Vector3( 0, 1, 0 );\r\n    THREE.Default.ZAxis = new THREE.Vector3( 0, 0, 1 );\r\n\r\nOr alternatively: \r\n\r\n    THREE.Axes.X = new THREE.Vector3( 1, 0, 0 );\r\n    THREE.Axes.Y = new THREE.Vector3( 0, 1, 0 );\r\n    THREE.Axes.Z = new THREE.Vector3( 0, 0, 1 );\r\n\r\nSimilarly there is the `THREE.Object3D.DefaultUp = new THREE.Vector3( 0, 1, 0 );`\r\nthis could then maybe be replaced with:\r\n\r\n    THREE.Default.Up = THREE.Default.YAxis\r\n\r\nI can make a pull request, but I just need some guidance on where to put them.\r\n\r\nThey could immediately be used in the three js code. For example in the `THREE.Object3D` methods `rotateX`, `rotateY` and `rotateZ`:\r\n\r\n\trotateX: function () {\r\n\t\tvar v1 = THREE.Default.XAxis;\r\n\t\treturn function ( angle ) {\r\n\t\t\treturn this.rotateOnAxis( v1, angle );\r\n\t\t};\r\n\t}(),\r\n\r\n\trotateY: function () {\r\n\t\tvar v1 = THREE.Default.YAxis;\r\n\t\treturn function ( angle ) {\r\n\t\t\treturn this.rotateOnAxis( v1, angle );\r\n\t\t};\r\n\t}(),\r\n\r\n\trotateZ: function () {\r\n\t\tvar v1 = THREE.Default.ZAxis;\r\n\t\treturn function ( angle ) {\r\n\t\t\treturn this.rotateOnAxis( v1, angle );\r\n\t\t};\r\n\t}(),\r\n\r\nAnd probably on more places."},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/201006046","html_url":"https://github.com/mrdoob/three.js/issues/8459#issuecomment-201006046","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/8459","id":201006046,"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},"created_at":"2016-03-24T20:31:16Z","updated_at":"2016-03-24T20:31:16Z","body":"Useful suggestion IMO, I frequently end up defining those constant somewhere in user code :+1:\r\n\r\n@bhouston \r\n> I've done this pattern before. I usually put these on the Vector3 class or what ever class type the consts are\r\n\r\nYes, better place.\r\n\r\n> But with JavaScript this is all fairly dangerous to do because these values are not truly const, so I am not sure this is a great idea.\r\n\r\nCould [`Object.freeze`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) them. In this case, a failed attempt to modify the objects throws in strict mode. Would still yield confusing behavior when embedded by reference in relaxed mode. \r\n\r\nSomething like this might work to detect misuse from inside the library\r\n\r\n```javascript\r\nTHREE.Box = ( function() {\r\n    'use strict'; // to report misuse of frozen objects\r\n\r\n    var Box = function Box( ... ) { \r\n        // ...\r\n    };\r\n\r\n    Box.prototype = {\r\n        // ...\r\n    };\r\n\r\n    Box.Empty = Object.freeze( new Box() );\r\n    return Object.freeze( Box );\r\n} )();\r\n```\r\n\r\nor going for strict mode globally altogether. It might save us from a bunch of bugs, after all. "}}