ui.three.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import * as THREE from '../../../build/three.module.js';
  5. import { RGBELoader } from '../../../examples/jsm/loaders/RGBELoader.js';
  6. import { TGALoader } from '../../../examples/jsm/loaders/TGALoader.js';
  7. import { UIElement, UISpan, UIDiv, UIRow, UIButton, UICheckbox, UIText, UINumber } from './ui.js';
  8. import { MoveObjectCommand } from '../commands/MoveObjectCommand.js';
  9. /**
  10. * @author mrdoob / http://mrdoob.com/
  11. */
  12. function UITexture( mapping ) {
  13. UIElement.call( this );
  14. var scope = this;
  15. var dom = document.createElement( 'span' );
  16. var form = document.createElement( 'form' );
  17. var input = document.createElement( 'input' );
  18. input.type = 'file';
  19. input.addEventListener( 'change', function ( event ) {
  20. loadFile( event.target.files[ 0 ] );
  21. } );
  22. form.appendChild( input );
  23. var canvas = document.createElement( 'canvas' );
  24. canvas.width = 32;
  25. canvas.height = 16;
  26. canvas.style.cursor = 'pointer';
  27. canvas.style.marginRight = '5px';
  28. canvas.style.border = '1px solid #888';
  29. canvas.addEventListener( 'click', function () {
  30. input.click();
  31. }, false );
  32. canvas.addEventListener( 'drop', function () {
  33. event.preventDefault();
  34. event.stopPropagation();
  35. loadFile( event.dataTransfer.files[ 0 ] );
  36. }, false );
  37. dom.appendChild( canvas );
  38. function loadFile( file ) {
  39. if ( file.type.match( 'image.*' ) ) {
  40. var reader = new FileReader();
  41. if ( file.type === 'image/targa' ) {
  42. reader.addEventListener( 'load', function ( event ) {
  43. var canvas = new TGALoader().parse( event.target.result );
  44. var texture = new THREE.CanvasTexture( canvas, mapping );
  45. texture.sourceFile = file.name;
  46. scope.setValue( texture );
  47. if ( scope.onChangeCallback ) scope.onChangeCallback( texture );
  48. }, false );
  49. reader.readAsArrayBuffer( file );
  50. } else {
  51. reader.addEventListener( 'load', function ( event ) {
  52. var image = document.createElement( 'img' );
  53. image.addEventListener( 'load', function () {
  54. var texture = new THREE.Texture( this, mapping );
  55. texture.sourceFile = file.name;
  56. texture.format = file.type === 'image/jpeg' ? THREE.RGBFormat : THREE.RGBAFormat;
  57. texture.needsUpdate = true;
  58. scope.setValue( texture );
  59. if ( scope.onChangeCallback ) scope.onChangeCallback( texture );
  60. }, false );
  61. image.src = event.target.result;
  62. }, false );
  63. reader.readAsDataURL( file );
  64. }
  65. } else {
  66. var reader = new FileReader();
  67. reader.addEventListener( 'load', function ( event ) {
  68. if ( file.name.split( '.' ).pop() === 'hdr' ) {
  69. // assuming RGBE/Radiance HDR iamge format
  70. var loader = new RGBELoader().setDataType( THREE.UnsignedByteType );
  71. loader.load( event.target.result, function ( hdrTexture ) {
  72. hdrTexture.sourceFile = file.name;
  73. hdrTexture.isHDRTexture = true;
  74. scope.setValue( hdrTexture );
  75. if ( scope.onChangeCallback ) scope.onChangeCallback( hdrTexture );
  76. } );
  77. }
  78. } );
  79. reader.readAsDataURL( file );
  80. }
  81. form.reset();
  82. }
  83. this.dom = dom;
  84. this.texture = null;
  85. this.onChangeCallback = null;
  86. return this;
  87. }
  88. UITexture.prototype = Object.create( UIElement.prototype );
  89. UITexture.prototype.constructor = UITexture;
  90. UITexture.prototype.getValue = function () {
  91. return this.texture;
  92. };
  93. UITexture.prototype.setValue = function ( texture ) {
  94. var canvas = this.dom.children[ 0 ];
  95. var context = canvas.getContext( '2d' );
  96. if ( texture !== null ) {
  97. var image = texture.image;
  98. if ( image !== undefined && image.width > 0 ) {
  99. canvas.title = texture.sourceFile;
  100. var scale = canvas.width / image.width;
  101. if ( image.data === undefined ) {
  102. context.drawImage( image, 0, 0, image.width * scale, image.height * scale );
  103. } else {
  104. var canvas2 = renderToCanvas( texture );
  105. context.drawImage( canvas2, 0, 0, image.width * scale, image.height * scale );
  106. }
  107. } else {
  108. canvas.title = texture.sourceFile + ' (error)';
  109. context.clearRect( 0, 0, canvas.width, canvas.height );
  110. }
  111. } else {
  112. canvas.title = 'empty';
  113. if ( context !== null ) {
  114. // Seems like context can be null if the canvas is not visible
  115. context.clearRect( 0, 0, canvas.width, canvas.height );
  116. }
  117. }
  118. this.texture = texture;
  119. };
  120. UITexture.prototype.setEncoding = function ( encoding ) {
  121. var texture = this.getValue();
  122. if ( texture !== null ) {
  123. texture.encoding = encoding;
  124. }
  125. return this;
  126. };
  127. UITexture.prototype.onChange = function ( callback ) {
  128. this.onChangeCallback = callback;
  129. return this;
  130. };
  131. // UICubeTexture
  132. function UICubeTexture() {
  133. UIElement.call( this );
  134. var container = new UIDiv();
  135. this.cubeTexture = null;
  136. this.onChangeCallback = null;
  137. this.dom = container.dom;
  138. this.textures = [];
  139. var scope = this;
  140. var pRow = new UIRow();
  141. var nRow = new UIRow();
  142. pRow.add( new UIText( 'P:' ).setWidth( '35px' ) );
  143. nRow.add( new UIText( 'N:' ).setWidth( '35px' ) );
  144. var posXTexture = new UITexture().onChange( onTextureChanged );
  145. var negXTexture = new UITexture().onChange( onTextureChanged );
  146. var posYTexture = new UITexture().onChange( onTextureChanged );
  147. var negYTexture = new UITexture().onChange( onTextureChanged );
  148. var posZTexture = new UITexture().onChange( onTextureChanged );
  149. var negZTexture = new UITexture().onChange( onTextureChanged );
  150. this.textures.push( posXTexture, negXTexture, posYTexture, negYTexture, posZTexture, negZTexture );
  151. pRow.add( posXTexture );
  152. pRow.add( posYTexture );
  153. pRow.add( posZTexture );
  154. nRow.add( negXTexture );
  155. nRow.add( negYTexture );
  156. nRow.add( negZTexture );
  157. container.add( pRow, nRow );
  158. function onTextureChanged() {
  159. var images = [];
  160. for ( var i = 0; i < scope.textures.length; i ++ ) {
  161. var texture = scope.textures[ i ].getValue();
  162. if ( texture !== null ) {
  163. images.push( texture.isHDRTexture ? texture : texture.image );
  164. }
  165. }
  166. if ( images.length === 6 ) {
  167. var cubeTexture = new THREE.CubeTexture( images );
  168. cubeTexture.needsUpdate = true;
  169. if ( images[ 0 ].isHDRTexture ) cubeTexture.isHDRTexture = true;
  170. scope.cubeTexture = cubeTexture;
  171. if ( scope.onChangeCallback ) scope.onChangeCallback( cubeTexture );
  172. }
  173. }
  174. }
  175. UICubeTexture.prototype = Object.create( UIElement.prototype );
  176. UICubeTexture.prototype.constructor = UICubeTexture;
  177. UICubeTexture.prototype.setEncoding = function ( encoding ) {
  178. var cubeTexture = this.getValue();
  179. if ( cubeTexture !== null ) {
  180. cubeTexture.encoding = encoding;
  181. }
  182. return this;
  183. };
  184. UICubeTexture.prototype.getValue = function () {
  185. return this.cubeTexture;
  186. };
  187. UICubeTexture.prototype.setValue = function ( cubeTexture ) {
  188. this.cubeTexture = cubeTexture;
  189. if ( cubeTexture !== null ) {
  190. var images = cubeTexture.image;
  191. if ( Array.isArray( images ) === true && images.length === 6 ) {
  192. for ( var i = 0; i < images.length; i ++ ) {
  193. var image = images[ i ];
  194. var texture = new THREE.Texture( image );
  195. this.textures[ i ].setValue( texture );
  196. }
  197. }
  198. } else {
  199. var textures = this.textures;
  200. for ( var i = 0; i < textures.length; i ++ ) {
  201. textures[ i ].setValue( null );
  202. }
  203. }
  204. return this;
  205. };
  206. UICubeTexture.prototype.onChange = function ( callback ) {
  207. this.onChangeCallback = callback;
  208. return this;
  209. };
  210. // UIOutliner
  211. function UIOutliner( editor ) {
  212. UIElement.call( this );
  213. var scope = this;
  214. var dom = document.createElement( 'div' );
  215. dom.className = 'Outliner';
  216. dom.tabIndex = 0; // keyup event is ignored without setting tabIndex
  217. // hack
  218. this.scene = editor.scene;
  219. // Prevent native scroll behavior
  220. dom.addEventListener( 'keydown', function ( event ) {
  221. switch ( event.keyCode ) {
  222. case 38: // up
  223. case 40: // down
  224. event.preventDefault();
  225. event.stopPropagation();
  226. break;
  227. }
  228. }, false );
  229. // Keybindings to support arrow navigation
  230. dom.addEventListener( 'keyup', function ( event ) {
  231. switch ( event.keyCode ) {
  232. case 38: // up
  233. scope.selectIndex( scope.selectedIndex - 1 );
  234. break;
  235. case 40: // down
  236. scope.selectIndex( scope.selectedIndex + 1 );
  237. break;
  238. }
  239. }, false );
  240. this.dom = dom;
  241. this.editor = editor;
  242. this.options = [];
  243. this.selectedIndex = - 1;
  244. this.selectedValue = null;
  245. return this;
  246. }
  247. UIOutliner.prototype = Object.create( UIElement.prototype );
  248. UIOutliner.prototype.constructor = UIOutliner;
  249. UIOutliner.prototype.selectIndex = function ( index ) {
  250. if ( index >= 0 && index < this.options.length ) {
  251. this.setValue( this.options[ index ].value );
  252. var changeEvent = document.createEvent( 'HTMLEvents' );
  253. changeEvent.initEvent( 'change', true, true );
  254. this.dom.dispatchEvent( changeEvent );
  255. }
  256. };
  257. UIOutliner.prototype.setOptions = function ( options ) {
  258. var scope = this;
  259. while ( scope.dom.children.length > 0 ) {
  260. scope.dom.removeChild( scope.dom.firstChild );
  261. }
  262. function onClick() {
  263. scope.setValue( this.value );
  264. var changeEvent = document.createEvent( 'HTMLEvents' );
  265. changeEvent.initEvent( 'change', true, true );
  266. scope.dom.dispatchEvent( changeEvent );
  267. }
  268. // Drag
  269. var currentDrag;
  270. function onDrag() {
  271. currentDrag = this;
  272. }
  273. function onDragStart( event ) {
  274. event.dataTransfer.setData( 'text', 'foo' );
  275. }
  276. function onDragOver( event ) {
  277. if ( this === currentDrag ) return;
  278. var area = event.offsetY / this.clientHeight;
  279. if ( area < 0.25 ) {
  280. this.className = 'option dragTop';
  281. } else if ( area > 0.75 ) {
  282. this.className = 'option dragBottom';
  283. } else {
  284. this.className = 'option drag';
  285. }
  286. }
  287. function onDragLeave() {
  288. if ( this === currentDrag ) return;
  289. this.className = 'option';
  290. }
  291. function onDrop( event ) {
  292. if ( this === currentDrag || currentDrag === undefined ) return;
  293. this.className = 'option';
  294. var scene = scope.scene;
  295. var object = scene.getObjectById( currentDrag.value );
  296. var area = event.offsetY / this.clientHeight;
  297. if ( area < 0.25 ) {
  298. var nextObject = scene.getObjectById( this.value );
  299. moveObject( object, nextObject.parent, nextObject );
  300. } else if ( area > 0.75 ) {
  301. var nextObject, parent;
  302. if ( this.nextSibling !== null ) {
  303. nextObject = scene.getObjectById( this.nextSibling.value );
  304. parent = nextObject.parent;
  305. } else {
  306. // end of list (no next object)
  307. nextObject = null;
  308. parent = scene.getObjectById( this.value ).parent;
  309. }
  310. moveObject( object, parent, nextObject );
  311. } else {
  312. var parentObject = scene.getObjectById( this.value );
  313. moveObject( object, parentObject );
  314. }
  315. }
  316. function moveObject( object, newParent, nextObject ) {
  317. if ( nextObject === null ) nextObject = undefined;
  318. var newParentIsChild = false;
  319. object.traverse( function ( child ) {
  320. if ( child === newParent ) newParentIsChild = true;
  321. } );
  322. if ( newParentIsChild ) return;
  323. var editor = scope.editor;
  324. editor.execute( new MoveObjectCommand( editor, object, newParent, nextObject ) );
  325. var changeEvent = document.createEvent( 'HTMLEvents' );
  326. changeEvent.initEvent( 'change', true, true );
  327. scope.dom.dispatchEvent( changeEvent );
  328. }
  329. //
  330. scope.options = [];
  331. for ( var i = 0; i < options.length; i ++ ) {
  332. var div = options[ i ];
  333. div.className = 'option';
  334. scope.dom.appendChild( div );
  335. scope.options.push( div );
  336. div.addEventListener( 'click', onClick );
  337. if ( div.draggable === true ) {
  338. div.addEventListener( 'drag', onDrag );
  339. div.addEventListener( 'dragstart', onDragStart ); // Firefox needs this
  340. div.addEventListener( 'dragover', onDragOver );
  341. div.addEventListener( 'dragleave', onDragLeave );
  342. div.addEventListener( 'drop', onDrop );
  343. }
  344. }
  345. return scope;
  346. };
  347. UIOutliner.prototype.getValue = function () {
  348. return this.selectedValue;
  349. };
  350. UIOutliner.prototype.setValue = function ( value ) {
  351. for ( var i = 0; i < this.options.length; i ++ ) {
  352. var element = this.options[ i ];
  353. if ( element.value === value ) {
  354. element.classList.add( 'active' );
  355. // scroll into view
  356. var y = element.offsetTop - this.dom.offsetTop;
  357. var bottomY = y + element.offsetHeight;
  358. var minScroll = bottomY - this.dom.offsetHeight;
  359. if ( this.dom.scrollTop > y ) {
  360. this.dom.scrollTop = y;
  361. } else if ( this.dom.scrollTop < minScroll ) {
  362. this.dom.scrollTop = minScroll;
  363. }
  364. this.selectedIndex = i;
  365. } else {
  366. element.classList.remove( 'active' );
  367. }
  368. }
  369. this.selectedValue = value;
  370. return this;
  371. };
  372. function UIPoints( onAddClicked ) {
  373. UIElement.call( this );
  374. var span = new UISpan().setDisplay( 'inline-block' );
  375. this.pointsList = new UIDiv();
  376. span.add( this.pointsList );
  377. var row = new UIRow();
  378. span.add( row );
  379. var addPointButton = new UIButton( '+' ).onClick( onAddClicked );
  380. row.add( addPointButton );
  381. this.update = function () {
  382. if ( this.onChangeCallback !== null ) {
  383. this.onChangeCallback();
  384. }
  385. }.bind( this );
  386. this.dom = span.dom;
  387. this.pointsUI = [];
  388. this.lastPointIdx = 0;
  389. this.onChangeCallback = null;
  390. return this;
  391. }
  392. UIPoints.prototype = Object.create( UIElement.prototype );
  393. UIPoints.prototype.constructor = UIPoints;
  394. UIPoints.prototype.onChange = function ( callback ) {
  395. this.onChangeCallback = callback;
  396. return this;
  397. };
  398. UIPoints.prototype.clear = function () {
  399. for ( var i = 0; i < this.pointsUI.length; ++ i ) {
  400. if ( this.pointsUI[ i ] ) {
  401. this.deletePointRow( i, true );
  402. }
  403. }
  404. this.lastPointIdx = 0;
  405. };
  406. UIPoints.prototype.deletePointRow = function ( idx, dontUpdate ) {
  407. if ( ! this.pointsUI[ idx ] ) return;
  408. this.pointsList.remove( this.pointsUI[ idx ].row );
  409. this.pointsUI[ idx ] = null;
  410. if ( dontUpdate !== true ) {
  411. this.update();
  412. }
  413. };
  414. function UIPoints2() {
  415. UIPoints.call( this, UIPoints2.addRow.bind( this ) );
  416. return this;
  417. }
  418. UIPoints2.prototype = Object.create( UIPoints.prototype );
  419. UIPoints2.prototype.constructor = UIPoints2;
  420. UIPoints2.addRow = function () {
  421. if ( this.pointsUI.length === 0 ) {
  422. this.pointsList.add( this.createPointRow( 0, 0 ) );
  423. } else {
  424. var point = this.pointsUI[ this.pointsUI.length - 1 ];
  425. this.pointsList.add( this.createPointRow( point.x.getValue(), point.y.getValue() ) );
  426. }
  427. this.update();
  428. };
  429. UIPoints2.prototype.getValue = function () {
  430. var points = [];
  431. var count = 0;
  432. for ( var i = 0; i < this.pointsUI.length; i ++ ) {
  433. var pointUI = this.pointsUI[ i ];
  434. if ( ! pointUI ) continue;
  435. points.push( new THREE.Vector2( pointUI.x.getValue(), pointUI.y.getValue() ) );
  436. ++ count;
  437. pointUI.lbl.setValue( count );
  438. }
  439. return points;
  440. };
  441. UIPoints2.prototype.setValue = function ( points ) {
  442. this.clear();
  443. for ( var i = 0; i < points.length; i ++ ) {
  444. var point = points[ i ];
  445. this.pointsList.add( this.createPointRow( point.x, point.y ) );
  446. }
  447. this.update();
  448. return this;
  449. };
  450. UIPoints2.prototype.createPointRow = function ( x, y ) {
  451. var pointRow = new UIDiv();
  452. var lbl = new UIText( this.lastPointIdx + 1 ).setWidth( '20px' );
  453. var txtX = new UINumber( x ).setWidth( '30px' ).onChange( this.update );
  454. var txtY = new UINumber( y ).setWidth( '30px' ).onChange( this.update );
  455. var idx = this.lastPointIdx;
  456. var scope = this;
  457. var btn = new UIButton( '-' ).onClick( function () {
  458. if ( scope.isEditing ) return;
  459. scope.deletePointRow( idx );
  460. } );
  461. this.pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY } );
  462. ++ this.lastPointIdx;
  463. pointRow.add( lbl, txtX, txtY, btn );
  464. return pointRow;
  465. };
  466. function UIPoints3() {
  467. UIPoints.call( this, UIPoints3.addRow.bind( this ) );
  468. return this;
  469. }
  470. UIPoints3.prototype = Object.create( UIPoints.prototype );
  471. UIPoints3.prototype.constructor = UIPoints3;
  472. UIPoints3.addRow = function () {
  473. if ( this.pointsUI.length === 0 ) {
  474. this.pointsList.add( this.createPointRow( 0, 0, 0 ) );
  475. } else {
  476. var point = this.pointsUI[ this.pointsUI.length - 1 ];
  477. this.pointsList.add( this.createPointRow( point.x.getValue(), point.y.getValue(), point.z.getValue() ) );
  478. }
  479. this.update();
  480. };
  481. UIPoints3.prototype.getValue = function () {
  482. var points = [];
  483. var count = 0;
  484. for ( var i = 0; i < this.pointsUI.length; i ++ ) {
  485. var pointUI = this.pointsUI[ i ];
  486. if ( ! pointUI ) continue;
  487. points.push( new THREE.Vector3( pointUI.x.getValue(), pointUI.y.getValue(), pointUI.z.getValue() ) );
  488. ++ count;
  489. pointUI.lbl.setValue( count );
  490. }
  491. return points;
  492. };
  493. UIPoints3.prototype.setValue = function ( points ) {
  494. this.clear();
  495. for ( var i = 0; i < points.length; i ++ ) {
  496. var point = points[ i ];
  497. this.pointsList.add( this.createPointRow( point.x, point.y, point.z ) );
  498. }
  499. this.update();
  500. return this;
  501. };
  502. UIPoints3.prototype.createPointRow = function ( x, y, z ) {
  503. var pointRow = new UIDiv();
  504. var lbl = new UIText( this.lastPointIdx + 1 ).setWidth( '20px' );
  505. var txtX = new UINumber( x ).setWidth( '30px' ).onChange( this.update );
  506. var txtY = new UINumber( y ).setWidth( '30px' ).onChange( this.update );
  507. var txtZ = new UINumber( z ).setWidth( '30px' ).onChange( this.update );
  508. var idx = this.lastPointIdx;
  509. var scope = this;
  510. var btn = new UIButton( '-' ).onClick( function () {
  511. if ( scope.isEditing ) return;
  512. scope.deletePointRow( idx );
  513. } );
  514. this.pointsUI.push( { row: pointRow, lbl: lbl, x: txtX, y: txtY, z: txtZ } );
  515. ++ this.lastPointIdx;
  516. pointRow.add( lbl, txtX, txtY, txtZ, btn );
  517. return pointRow;
  518. };
  519. function UIBoolean( boolean, text ) {
  520. UISpan.call( this );
  521. this.setMarginRight( '10px' );
  522. this.checkbox = new UICheckbox( boolean );
  523. this.text = new UIText( text ).setMarginLeft( '3px' );
  524. this.add( this.checkbox );
  525. this.add( this.text );
  526. }
  527. UIBoolean.prototype = Object.create( UISpan.prototype );
  528. UIBoolean.prototype.constructor = UIBoolean;
  529. UIBoolean.prototype.getValue = function () {
  530. return this.checkbox.getValue();
  531. };
  532. UIBoolean.prototype.setValue = function ( value ) {
  533. return this.checkbox.setValue( value );
  534. };
  535. var renderer;
  536. function renderToCanvas( texture ) {
  537. if ( renderer === undefined ) {
  538. renderer = new THREE.WebGLRenderer();
  539. renderer.outputEncoding = THREE.sRGBEncoding;
  540. }
  541. var image = texture.image;
  542. renderer.setSize( image.width, image.height, false );
  543. var scene = new THREE.Scene();
  544. var camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
  545. var material = new THREE.MeshBasicMaterial( { map: texture } );
  546. var quad = new THREE.PlaneBufferGeometry( 2, 2 );
  547. var mesh = new THREE.Mesh( quad, material );
  548. scene.add( mesh );
  549. renderer.render( scene, camera );
  550. return renderer.domElement;
  551. }
  552. export { UITexture, UICubeTexture, UIOutliner, UIPoints, UIPoints2, UIPoints3, UIBoolean };