ui.three.js 18 KB

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