diff --git a/editor/js/libs/ui.three.js b/editor/js/libs/ui.three.js index 394cfa4b7344a4f51fe60228e368ce29b6b9732d..fcd9c7874f1ce3ae8d3eae6b188b9412aa9f2477 100644 --- a/editor/js/libs/ui.three.js +++ b/editor/js/libs/ui.three.js @@ -10,6 +10,8 @@ UI.Texture = function ( mapping ) { var dom = document.createElement( 'span' ); + var form = document.createElement( 'form' ); + var input = document.createElement( 'input' ); input.type = 'file'; input.addEventListener( 'change', function ( event ) { @@ -17,6 +19,7 @@ UI.Texture = function ( mapping ) { loadFile( event.target.files[ 0 ] ); } ); + form.appendChild( input ); var canvas = document.createElement( 'canvas' ); canvas.width = 32; @@ -44,12 +47,7 @@ UI.Texture = function ( mapping ) { name.style.border = '1px solid #ccc'; dom.appendChild( name ); - var form = document.createElement( 'form' ); - form.appendChild( input ); - form.style.display = 'none'; - dom.appendChild( form ); - - var loadFile = function ( file ) { + function loadFile( file ) { if ( file.type.match( 'image.*' ) ) { @@ -63,7 +61,6 @@ UI.Texture = function ( mapping ) { var texture = new THREE.CanvasTexture( canvas, mapping ); texture.sourceFile = file.name; - form.reset(); scope.setValue( texture ); @@ -85,7 +82,6 @@ UI.Texture = function ( mapping ) { texture.needsUpdate = true; scope.setValue( texture ); - form.reset(); if ( scope.onChangeCallback ) scope.onChangeCallback(); @@ -101,7 +97,9 @@ UI.Texture = function ( mapping ) { } - }; + form.reset(); + + } this.dom = dom; this.texture = null;