antosdk-apps/ShaderPlayground/build/debug/main.js

1 line
7.0 KiB
JavaScript
Raw Normal View History

var OS;!function(e){let t,i;!function(e){let t;!function(e){class t extends e.ListViewItemTag{itemlayout(){return{el:"div",children:[{el:"img",ref:"img"},{el:"p",ref:"name"}]}}ondatachange(){const e=this.data,t=this.refs.img,i=e.path.asFileHandle().getlink();t.src=i,$(this.refs.name).text(e.name)}init(){this.closable=!0}reload(e){}}e.define("afx-shader-texture-item",t)}(t=e.tag||(e.tag={}))}(t=e.GUI||(e.GUI={})),function(e){class i extends t.BasicDialog{constructor(){super("AddTextureDialog",i.scheme)}main(){super.main();const e=$("input",this.scheme);this.find("btnOk").onbtclick=t=>{let i={};for(const t of e){let e=t;if(""==e.value.trim())return this.notify(__("All fields should be filled"));i[e.name]=e.value.trim()}this.handle&&this.handle(i),this.quit()},this.find("btnFile").onbtclick=e=>{this.openDialog("FileDialog",{title:__("Select image file"),type:"file",mimes:["image/.*"]}).then(e=>{this.find("txtPath").value=e.file.path})}}}i.scheme='<afx-app-window width=\'250\' height=\'170\'>\n <afx-hbox>\n <div data-width="5"></div>\n <afx-vbox>\n <div data-height="5"></div>\n <afx-label text="__(Name)" data-height="25"></afx-label>\n <input type="text" data-height="25" name="name"> </input>\n <div data-height="5"></div>\n <afx-label text="__(Path/URL)" data-height="25"></afx-label>\n <afx-hbox data-height="26">\n <input type="text" name="path" data-id="txtPath"> </input>\n <afx-button data-id="btnFile" iconclass = "bi bi-folder2-open" data-width="25"></afx-button>\n </afx-hbox>\n <div data-height="5"></div>\n <div style="text-align:right;">\n <afx-button text="__(Ok)" data-id="btnOk"></afx-button>\n </div>\n <div data-height="5"></div>\n </afx-vbox>\n <div data-width="5"></div>\n </afx-hbox>\n</afx-app-window>';class s{constructor(e,t){this.renderer=t,this.ums=[new ace.UndoManager,new ace.UndoManager],this.current_idx=-1,this.glsl_values=["void main(){}",""],ace.require("ace/ext/language_tools"),this.editor=ace.edit(e),this.editor.setOptions({enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,highlightActiveLine:!0}),this.editor.getSession().setUseWrapMode(!0),this.editor.session.setMode("ace/mode/glsl"),this.editor.setTheme("ace/theme/monokai"),this.cursors=[this.editor.getCursorPosition(),this.editor.getCursorPosition()],this.editor.on("input",e=>{const t=this.editor.getValue(),i=GLSLX.compile(t,{format:"json"});if(i.output)this.editor.getSession().setAnnotations([]),this.glsl_values[this.current_idx]=t,this.renderer.apply_mat(this.glsl_values[0],this.glsl_values[1]);else{const e="<stdin>:([0-9]+):([0-9]+):\\s*error:\\s*(.*)\\n",t=i.log.match(new RegExp(e,"g"));t&&this.editor.getSession().setAnnotations(t.map(t=>{const i=t.match(new RegExp(e));let s={};return i&&(s={row:parseInt(i[1])-1,column:parseInt(i[2]),text:i[3],type:"error"}),s}))}})}edit(e){if(e<0)return;if(2!=e&&2!=this.current_idx)0===e?(this.glsl_values[1]=this.editor.getValue(),this.cursors[1]=this.editor.getCursorPosition()):(this.glsl_values[0]=this.editor.getValue(),this.cursors[0]=this.editor.getCursorPosition());else if(2==e)return this.glsl_values[this.current_idx]=this.editor.getValue(),this.cursors[this.current_idx]=this.editor.getCursorPosition(),void(this.current_idx=e);this.current_idx=e,this.editor.getSession().setUndoManager(new ace.UndoManager),this.editor.setValue(this.glsl_values[e]),this.editor.getSession().setUndoManager(this.ums[e]);const t=this.cursors[e];this.editor.renderer.scrollCursorIntoView({row:t.row,column:t.column},.5),this.editor.selection.moveTo(t.row,t.column),this.editor.focus()}cleanup(){this.renderer.cleanup()}resize(){this.editor.resize(),this.renderer.viewport_resize()}}class r{constructor(e){this.textures=[],this.renderer=new THREE.WebGLRenderer({canvas:e}),this.renderer.autoClearColor=!1,this.clock=new THREE.Clock,this.camera=new THREE.OrthographicCamera(-1,1,1,-1,-1,1),this.scene=new THREE.Scene;con