ui.three.js 18 KB

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