├── .eslintrc.json ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── DejaVu-sdf.fnt └── DejaVu-sdf.png ├── dist ├── .gitkeep ├── aframe-bmfont-text-component.js ├── aframe-bmfont-text-component.min.js └── old │ ├── aframe-bmfont-text-component-no-prim.js │ ├── aframe-bmfont-text-component-no-prim.min.js │ ├── aframe-bmfont-text-component-v0.1.0.js │ └── aframe-bmfont-text-component-v0.1.0.min.js ├── docs ├── basic │ └── index.html ├── build.js ├── colors │ └── index.html ├── index.html ├── line-break │ └── index.html ├── line-height │ └── index.html ├── main.js ├── opacity │ └── index.html ├── pre-mode │ └── index.html ├── primitive │ └── index.html ├── sizes │ └── index.html ├── text-align │ └── index.html └── width-wrap │ └── index.html ├── extras └── text-primitive.js ├── index.js ├── lib └── shaders │ ├── basic.js │ ├── multipage.js │ └── sdf.js └── package.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "semistandard", 3 | "installedESLint": true, 4 | "env": { 5 | "commonjs": true 6 | } 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .sw[ponm] 2 | node_modules/ 3 | npm-debug.log 4 | debug.log 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ben Pyrik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **This is an old component!** A-Frame 0.5.0 and up includes SDF text as [a standard component](https://aframe.io/docs/0.5.0/components/text.html). Use that instead! 2 | 3 |
4 | 5 | ## aframe-bmfont-text-component 6 | 7 | **Works with A-Frame version 0.3.0.** 8 | 9 | This component is useful for rendering bitmap and signed distance field font text in [A-Frame](https://aframe.io). Basically, it wraps Matt DesLauriers' [three-bmfont-text](https://github.com/Jam3/three-bmfont-text) and [load-bmfont](https://github.com/Jam3/load-bmfont). 10 | 11 | ![screenshot](http://i.imgur.com/pDDlzAX.png) 12 | 13 | ## Properties 14 | 15 | | Property | Description | Default Value | 16 | |:-------------:|:----------------------------:|:---------------------:| 17 | | text | the text you want to appear | None | 18 | | width | width of the text box | None | 19 | | align | 'left', 'center', 'right' | left | 20 | | letterSpacing | the letter spacing in pixels | 0 | 21 | | lineHeight | the line height in pixels | 38 | 22 | | fnt | path to 'fnt' file | https://... | 23 | | fntImage | path to font image file | https://... | 24 | | mode | 'pre' and 'nowrap' | 'normal' | 25 | | color | by RGB, hex, or name | #000 | 26 | | opacity | Extent of transparency. | 1.0 | 27 | 28 | More details on these properties [here](https://github.com/Jam3/three-bmfont-text#usage). 29 | 30 | Explanation of 'mode' property [here](https://github.com/mattdesl/word-wrapper). 31 | 32 | ## Usage 33 | 34 | Write some text: 35 | 36 | ```html 37 | 38 | ``` 39 | 40 | To change the size of the text, use the [scale](https://aframe.io/docs/0.2.0/components/scale.html) component or position the text closer or further away. 41 | 42 | Text can be wrapped by specifying width, but I'm not sure what units three-bmfont-text uses. You will have to play around a bit. 43 | 44 | ## Custom Fonts 45 | 46 | A guide for generating SDF fonts can be found [here](https://github.com/libgdx/libgdx/wiki/Distance-field-fonts); here is an example comparing [Arial Black and DejaVu](http://i.imgur.com/iWtXHm5.png). Bitmap fonts also work, but do not look nearly as good. 47 | 48 | Different fonts can be specified with the 'fnt' and 'fntImage' properties. 49 | 50 | ```html 51 | 52 | 53 | ``` 54 | 55 | Thanks to [jsDelivr](https://www.jsdelivr.com), these default to hosted "DejaVu-sdf.fnt" and "DejaVu-sdf.png" files. 56 | 57 | ## Limitations 58 | 59 | This component does not make use of all of the features of [three-bmfont-text](https://github.com/Jam3/three-bmfont-text) and its sister modules, if you require more advanced functionality such as tabSize and start and end indices, I recommend forking this component and modifying it. Pull requests are welcome, but please include a test example. 60 | 61 | Bitmap font rendering limits you to the characters included in the font (Unicode this is not). SDF font (in particular) tends to smooth sharp edges though [there are ways around this](https://lambdacube3d.wordpress.com/2014/11/12/playing-around-with-font-rendering/). 62 | 63 | #### Additional Information 64 | 65 | If you are interested in text rendering in WebGL/ThreeJS/A-Frame and want to learn more, I recommend reading the documentation for [three-bmfont-text](https://github.com/Jam3/three-bmfont-text). 66 | 67 | Here are some additional resources: 68 | 69 | - ['It’s 2015 and drawing text is still hard (WebGL, ThreeJS)' by Parris Khachi](https://www.eventbrite.com/engineering/its-2015-and-drawing-text-is-still-hard-webgl-threejs/) 70 | - [Valve's original paper](http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf) 71 | - ['Hacking with THREE.js' by Matt DesLauriers](http://slides.com/mattdeslauriers/hacking-with-three-js#/13) 72 | 73 | ## Installation 74 | 75 | #### Browser 76 | 77 | Install and use by directly including the [browser files](dist): 78 | 79 | ```html 80 | 81 | My A-Frame Scene 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | ``` 92 | 93 | #### NPM 94 | 95 | Install via NPM: 96 | 97 | ```bash 98 | npm install aframe-bmfont-text-component 99 | ``` 100 | 101 | Then register and use. 102 | 103 | ```js 104 | require('aframe'); 105 | require('aframe-bmfont-text-component'); 106 | ``` 107 | -------------------------------------------------------------------------------- /assets/DejaVu-sdf.fnt: -------------------------------------------------------------------------------- 1 | info face="DejaVu Sans Mono" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=4,4,4,4 spacing=-8,-8 2 | common lineHeight=38 base=30 scaleW=512 scaleH=512 pages=1 packed=0 3 | page id=0 file="DejaVu.png" 4 | chars count=95 5 | char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=30 xadvance=19 page=0 chnl=0 6 | char id=124 x=0 y=0 width=13 height=42 xoffset=4 yoffset=1 xadvance=19 page=0 chnl=0 7 | char id=106 x=13 y=0 width=19 height=41 xoffset=-1 yoffset=1 xadvance=19 page=0 chnl=0 8 | char id=36 x=32 y=0 width=25 height=40 xoffset=-1 yoffset=0 xadvance=19 page=0 chnl=0 9 | char id=125 x=57 y=0 width=23 height=40 xoffset=-1 yoffset=1 xadvance=19 page=0 chnl=0 10 | char id=123 x=80 y=0 width=23 height=40 xoffset=-1 yoffset=1 xadvance=19 page=0 chnl=0 11 | char id=93 x=103 y=0 width=17 height=39 xoffset=1 yoffset=1 xadvance=19 page=0 chnl=0 12 | char id=91 x=120 y=0 width=17 height=39 xoffset=3 yoffset=1 xadvance=19 page=0 chnl=0 13 | char id=41 x=137 y=0 width=17 height=39 xoffset=2 yoffset=1 xadvance=19 page=0 chnl=0 14 | char id=40 x=154 y=0 width=16 height=39 xoffset=3 yoffset=1 xadvance=19 page=0 chnl=0 15 | char id=127 x=170 y=0 width=26 height=38 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 16 | char id=64 x=196 y=0 width=28 height=37 xoffset=-3 yoffset=3 xadvance=19 page=0 chnl=0 17 | char id=81 x=224 y=0 width=26 height=37 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 18 | char id=92 x=250 y=0 width=24 height=36 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 19 | char id=47 x=274 y=0 width=24 height=36 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 20 | char id=121 x=298 y=0 width=25 height=35 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 21 | char id=113 x=323 y=0 width=25 height=35 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 22 | char id=112 x=348 y=0 width=25 height=35 xoffset=-1 yoffset=7 xadvance=19 page=0 chnl=0 23 | char id=103 x=373 y=0 width=25 height=35 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 24 | char id=108 x=398 y=0 width=25 height=34 xoffset=-3 yoffset=1 xadvance=19 page=0 chnl=0 25 | char id=107 x=423 y=0 width=24 height=34 xoffset=0 yoffset=1 xadvance=19 page=0 chnl=0 26 | char id=105 x=447 y=0 width=25 height=34 xoffset=-2 yoffset=1 xadvance=19 page=0 chnl=0 27 | char id=104 x=472 y=0 width=23 height=34 xoffset=-1 yoffset=1 xadvance=19 page=0 chnl=0 28 | char id=102 x=0 y=42 width=24 height=34 xoffset=-1 yoffset=1 xadvance=19 page=0 chnl=0 29 | char id=100 x=24 y=42 width=25 height=34 xoffset=-2 yoffset=1 xadvance=19 page=0 chnl=0 30 | char id=98 x=49 y=42 width=25 height=34 xoffset=-1 yoffset=1 xadvance=19 page=0 chnl=0 31 | char id=38 x=74 y=42 width=28 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 32 | char id=35 x=102 y=42 width=29 height=33 xoffset=-4 yoffset=2 xadvance=19 page=0 chnl=0 33 | char id=63 x=131 y=42 width=22 height=33 xoffset=0 yoffset=2 xadvance=19 page=0 chnl=0 34 | char id=33 x=153 y=42 width=13 height=33 xoffset=4 yoffset=2 xadvance=19 page=0 chnl=0 35 | char id=48 x=166 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 36 | char id=57 x=191 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 37 | char id=56 x=216 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 38 | char id=55 x=241 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 39 | char id=54 x=266 y=42 width=24 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 40 | char id=53 x=290 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 41 | char id=52 x=315 y=42 width=26 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 42 | char id=51 x=341 y=42 width=24 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 43 | char id=50 x=365 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 44 | char id=49 x=390 y=42 width=23 height=33 xoffset=0 yoffset=2 xadvance=19 page=0 chnl=0 45 | char id=116 x=413 y=42 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 46 | char id=90 x=438 y=42 width=26 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 47 | char id=89 x=464 y=42 width=26 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 48 | char id=88 x=0 y=76 width=28 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 49 | char id=87 x=28 y=76 width=28 height=33 xoffset=-4 yoffset=2 xadvance=19 page=0 chnl=0 50 | char id=86 x=56 y=76 width=26 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 51 | char id=85 x=82 y=76 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 52 | char id=84 x=107 y=76 width=27 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 53 | char id=83 x=134 y=76 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 54 | char id=82 x=159 y=76 width=26 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 55 | char id=80 x=185 y=76 width=24 height=33 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 56 | char id=79 x=209 y=76 width=26 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 57 | char id=78 x=235 y=76 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 58 | char id=77 x=260 y=76 width=27 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 59 | char id=76 x=287 y=76 width=24 height=33 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 60 | char id=75 x=311 y=76 width=26 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 61 | char id=74 x=337 y=76 width=23 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 62 | char id=73 x=360 y=76 width=23 height=33 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 63 | char id=72 x=383 y=76 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 64 | char id=71 x=408 y=76 width=26 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 65 | char id=70 x=434 y=76 width=24 height=33 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 66 | char id=69 x=458 y=76 width=24 height=33 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 67 | char id=68 x=482 y=76 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 68 | char id=67 x=0 y=109 width=25 height=33 xoffset=-2 yoffset=2 xadvance=19 page=0 chnl=0 69 | char id=66 x=25 y=109 width=25 height=33 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 70 | char id=65 x=50 y=109 width=27 height=33 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 71 | char id=37 x=77 y=109 width=27 height=32 xoffset=-3 yoffset=3 xadvance=19 page=0 chnl=0 72 | char id=59 x=104 y=109 width=16 height=31 xoffset=2 yoffset=8 xadvance=19 page=0 chnl=0 73 | char id=122 x=120 y=109 width=23 height=28 xoffset=-1 yoffset=7 xadvance=19 page=0 chnl=0 74 | char id=120 x=143 y=109 width=26 height=28 xoffset=-3 yoffset=7 xadvance=19 page=0 chnl=0 75 | char id=119 x=169 y=109 width=28 height=28 xoffset=-4 yoffset=7 xadvance=19 page=0 chnl=0 76 | char id=118 x=197 y=109 width=25 height=28 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 77 | char id=117 x=222 y=109 width=23 height=28 xoffset=-1 yoffset=7 xadvance=19 page=0 chnl=0 78 | char id=115 x=245 y=109 width=23 height=28 xoffset=-1 yoffset=7 xadvance=19 page=0 chnl=0 79 | char id=114 x=268 y=109 width=22 height=28 xoffset=2 yoffset=7 xadvance=19 page=0 chnl=0 80 | char id=111 x=290 y=109 width=25 height=28 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 81 | char id=110 x=315 y=109 width=23 height=28 xoffset=-1 yoffset=7 xadvance=19 page=0 chnl=0 82 | char id=109 x=338 y=109 width=27 height=28 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 83 | char id=99 x=365 y=109 width=24 height=28 xoffset=-1 yoffset=7 xadvance=19 page=0 chnl=0 84 | char id=97 x=389 y=109 width=25 height=28 xoffset=-2 yoffset=7 xadvance=19 page=0 chnl=0 85 | char id=43 x=414 y=109 width=27 height=27 xoffset=-3 yoffset=6 xadvance=19 page=0 chnl=0 86 | char id=58 x=441 y=109 width=14 height=27 xoffset=4 yoffset=8 xadvance=19 page=0 chnl=0 87 | char id=101 x=455 y=109 width=25 height=27 xoffset=-2 yoffset=8 xadvance=19 page=0 chnl=0 88 | char id=62 x=480 y=109 width=27 height=25 xoffset=-3 yoffset=8 xadvance=19 page=0 chnl=0 89 | char id=60 x=0 y=142 width=27 height=25 xoffset=-3 yoffset=8 xadvance=19 page=0 chnl=0 90 | char id=42 x=27 y=142 width=23 height=24 xoffset=-1 yoffset=2 xadvance=19 page=0 chnl=0 91 | char id=61 x=50 y=142 width=27 height=20 xoffset=-3 yoffset=10 xadvance=19 page=0 chnl=0 92 | char id=94 x=77 y=142 width=26 height=19 xoffset=-3 yoffset=2 xadvance=19 page=0 chnl=0 93 | char id=44 x=103 y=142 width=16 height=19 xoffset=2 yoffset=20 xadvance=19 page=0 chnl=0 94 | char id=39 x=119 y=142 width=13 height=19 xoffset=4 yoffset=2 xadvance=19 page=0 chnl=0 95 | char id=34 x=132 y=142 width=19 height=19 xoffset=1 yoffset=2 xadvance=19 page=0 chnl=0 96 | char id=96 x=151 y=142 width=16 height=16 xoffset=0 yoffset=-1 xadvance=19 page=0 chnl=0 97 | char id=126 x=167 y=142 width=27 height=15 xoffset=-3 yoffset=12 xadvance=19 page=0 chnl=0 98 | char id=46 x=194 y=142 width=14 height=15 xoffset=4 yoffset=20 xadvance=19 page=0 chnl=0 99 | char id=95 x=208 y=142 width=29 height=13 xoffset=-4 yoffset=30 xadvance=19 page=0 chnl=0 100 | char id=45 x=237 y=142 width=18 height=13 xoffset=2 yoffset=15 xadvance=19 page=0 chnl=0 101 | kernings count=-1 102 | -------------------------------------------------------------------------------- /assets/DejaVu-sdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bryik/aframe-bmfont-text-component/9b4d5384f63e499caaf1c0ca69f7de486452f268/assets/DejaVu-sdf.png -------------------------------------------------------------------------------- /dist/.gitkeep: -------------------------------------------------------------------------------- 1 | `npm run dist` to generate browser files. 2 | -------------------------------------------------------------------------------- /dist/aframe-bmfont-text-component.min.js: -------------------------------------------------------------------------------- 1 | !function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(t,e){o(t.font,function(r,n){if(r)throw r;var i=new THREE.TextureLoader;i.load(t.image,function(t){e(n,t)})})}if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");var i=r(29),o=r(21),a=r(7);r(6),AFRAME.registerComponent("bmfont-text",{schema:{text:{type:"string"},width:{type:"number","default":1e3},align:{type:"string","default":"left"},letterSpacing:{type:"number","default":0},lineHeight:{type:"number","default":38},fnt:{type:"string","default":"https://cdn.rawgit.com/bryik/aframe-bmfont-text-component/aa0655cf90f646e12c40ab4708ea90b4686cfb45/assets/DejaVu-sdf.fnt"},fntImage:{type:"string","default":"https://cdn.rawgit.com/bryik/aframe-bmfont-text-component/aa0655cf90f646e12c40ab4708ea90b4686cfb45/assets/DejaVu-sdf.png"},mode:{type:"string","default":"normal"},color:{type:"color","default":"#000"},opacity:{type:"number","default":"1.0"}},update:function(t){function e(t,e){e.needsUpdate=!0,e.anisotropy=16;var n={font:t,text:o.text,width:o.width,align:o.align,letterSpacing:o.letterSpacing,lineHeight:o.lineHeight,mode:o.mode},u=i(n),s=new THREE.RawShaderMaterial(a({map:e,side:THREE.DoubleSide,transparent:!0,color:o.color,opacity:o.opacity})),f=new THREE.Mesh(u,s);f.rotation.y=Math.PI,f.scale.multiplyScalar(-.005),r.setObject3D("bmfont-text",f)}var r=this.el,o=this.data;n({font:o.fnt,image:o.fntImage},e)},remove:function(){this.el.removeObject3D("bmfont-text")}})},function(t,e,r){(function(t,n){/*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */ 7 | "use strict";function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,r){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function y(e){return+e!=e&&(e=0),t.alloc(+e)}function v(e,r){if(t.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(i)return G(e).length;r=(""+r).toLowerCase(),i=!0}}function w(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(e,r,n,i,o){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=t.from(r,i)),t.isBuffer(r))return 0===r.length?-1:E(e,r,n,i,o);if("number"==typeof r)return r=255&r,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):E(e,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){function o(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,u=t.length,s=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,r/=2}var f;if(i){var h=-1;for(f=r;fu&&(r=u-s),f=r;f>=0;f--){for(var c=!0,p=0;pi&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+u<=r){var s,f,h,c;switch(u){case 1:o<128&&(a=o);break;case 2:s=t[i+1],128===(192&s)&&(c=(31&o)<<6|63&s,c>127&&(a=c));break;case 3:s=t[i+1],f=t[i+2],128===(192&s)&&128===(192&f)&&(c=(15&o)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:s=t[i+1],f=t[i+2],h=t[i+3],128===(192&s)&&128===(192&f)&&128===(192&h)&&(c=(15&o)<<18|(63&s)<<12|(63&f)<<6|63&h,c>65535&&c<1114112&&(a=c))}}null===a?(a=65533,u=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=u}return I(n)}function I(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function k(e,r,n,i,o,a){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||re.length)throw new RangeError("Index out of range")}function j(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function H(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function Y(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,i){return i||Y(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return i||Y(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,r,n,52,8),r+8}function F(t){if(t=X(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function X(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return t<16?"0"+t.toString(16):t.toString(16)}function G(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function J(t){return Z.toByteArray(F(t))}function W(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function $(t){return t!==t}var Z=r(10),K=r(16),Q=r(12);e.Buffer=t,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==n.TYPED_ARRAY_SUPPORT?n.TYPED_ARRAY_SUPPORT:i(),e.kMaxLength=o(),t.poolSize=8192,t._augment=function(e){return e.__proto__=t.prototype,e},t.from=function(t,e,r){return u(null,t,e,r)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,e,r){return f(null,t,e,r)},t.allocUnsafe=function(t){return h(null,t)},t.allocUnsafeSlow=function(t){return h(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,o=0,a=Math.min(n,i);o0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},t.prototype.compare=function(e,r,n,i,o){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var a=o-i,u=n-r,s=Math.min(a,u),f=this.slice(i,o),h=e.slice(r,n),c=0;ci)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return A(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return R(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r0&&(i*=256);)n+=this[t+--e]*i;return n},t.prototype.readUInt8=function(t,e){return e||C(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||C(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||C(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||C(t,e,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*e)),n},t.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||C(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||C(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||C(t,4,this.length),K.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||C(t,4,this.length),K.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||C(t,8,this.length),K.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||C(t,8,this.length),K.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;k(this,t,e,r,i,0)}var o=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+o]=t/a&255;return e+r},t.prototype.writeUInt8=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=255&e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):j(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):j(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=255&e):H(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):H(this,e,r,!1),r+4},t.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=0,a=1,u=0;for(this[e]=255&t;++o>0)-u&255;return e+r},t.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=r-1,a=1,u=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/a>>0)-u&255;return e+r},t.prototype.writeInt8=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=255&e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):j(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):j(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):H(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):H(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r=0;--o)e[o+r]=this[o+n];else if(a<1e3||!t.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=r;a0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[u-2]?2:"="===t[u-1]?1:0,a=new f(3*u/4-o),n=o>0?u-4:u;var h=0;for(e=0,r=0;e>16&255,a[h++]=i>>8&255,a[h++]=255&i;return 2===o?(i=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,a[h++]=255&i):1===o&&(i=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,a[h++]=i>>8&255,a[h++]=255&i),a}function i(t){return u[t>>18&63]+u[t>>12&63]+u[t>>6&63]+u[63&t]}function o(t,e,r){for(var n,o=[],a=e;ah?h:f+s));return 1===n?(e=t[r-1],i+=u[e>>2],i+=u[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=u[e>>10],i+=u[e>>4&63],i+=u[e<<2&63],i+="="),a.push(i),a.join("")}e.toByteArray=n,e.fromByteArray=a;var u=[],s=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},function(t,e,r){var n=r(1).Buffer;t.exports=function(t,e){if(n.isBuffer(t)&&n.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var r=0;r>1,h=-7,c=r?i-1:0,p=r?-1:1,l=t[e+c];for(c+=p,o=l&(1<<-h)-1,l>>=-h,h+=u;h>0;o=256*o+t[e+c],c+=p,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+c],c+=p,h-=8);if(0===o)o=1-f;else{if(o===s)return a?NaN:(l?-1:1)*(1/0);a+=Math.pow(2,n),o-=f}return(l?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,u,s,f=8*o-i-1,h=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),e+=a+c>=1?p/s:p*Math.pow(2,1-c),e*s>=2&&(a++,s/=2),a+c>=h?(u=0,a=h):a+c>=1?(u=(e*s-1)*Math.pow(2,i),a+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;t[r+l]=255&u,l+=d,u/=256,i-=8);for(a=a<0;t[r+l]=255&a,l+=d,a/=256,f-=8);t[r+l-d]|=128*g}},function(t,e){t.exports=function(t){if(!t||"string"!=typeof t)throw new Error("must specify property for indexof search");return new Function("array","value","start",["start = start || 0","for (var i=start; i 11 | * @license MIT 12 | */ 13 | t.exports=function(t){return null!=t&&(r(t)||n(t)||!!t._isBuffer)}},function(t,e,r){function n(t){this.glyphs=[],this._measure=this.computeMetrics.bind(this),this.update(t)}function i(t){Object.defineProperty(n.prototype,t,{get:o(t),configurable:!0})}function o(t){return new Function(["return function "+t+"() {"," return this._"+t,"}"].join("\n"))()}function a(t,e){if(!t.chars||0===t.chars.length)return null;var r=d(t.chars,e);return r>=0?t.chars[r]:null}function u(t){for(var e=0;e=0)return t.chars[n].height}return 0}function s(t){for(var e=0;e=0)return t.chars[n]}return 0}function f(t){for(var e=0;e=0)return t.chars[n].height}return 0}function h(t,e,r){if(!t.kernings||0===t.kernings.length)return 0;for(var n=t.kernings,i=0;i=n||g>=n)break;s=g,f=y,o=i}c++}return o&&(f+=o.xoffset),{start:e,end:e+c,width:f}},["width","height","descender","ascender","xHeight","baseline","capHeight","lineHeight"].forEach(i)},function(t,e,r){(function(e){function n(t){var e=Object.prototype.toString;return"[object ArrayBuffer]"===e.call(t)}function i(t){if(p)return c(t,{responseType:"arraybuffer"});if("undefined"==typeof window.XMLHttpRequest)throw new Error("your browser does not support XHR loading");var e=new window.XMLHttpRequest;return e.overrideMimeType("text/plain; charset=x-user-defined"),c({xhr:e},t)}var o=r(35),a=function(){},u=r(23),s=r(25),f=r(24),h=r(22),c=r(2),p=function(){return window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}();t.exports=function(t,r){r="function"==typeof r?r:a,"string"==typeof t?t={uri:t}:t||(t={});var c=t.binary;c&&(t=i(t)),o(t,function(i,o,c){if(i)return r(i);if(!/^2/.test(o.statusCode))return r(new Error("http status code: "+o.statusCode));if(!c)return r(new Error("no body result"));var p=!1;if(n(c)){var l=new Uint8Array(c);c=new e(l,"binary")}h(c)&&(p=!0,"string"==typeof c&&(c=new e(c,"binary"))),p||(e.isBuffer(c)&&(c=c.toString(t.encoding)),c=c.trim());var d;try{var g=o.headers["content-type"];d=p?f(c):/json/.test(g)||"{"===c.charAt(0)?JSON.parse(c):/xml/.test(g)||"<"===c.charAt(0)?s(c):u(c)}catch(y){r(new Error("error parsing font "+y.message)),r=a}r(null,d)})}}).call(e,r(1).Buffer)},function(t,e,r){(function(e){var n=r(11),i=new e([66,77,70,3]);t.exports=function(t){return"string"==typeof t?"BMF"===t.substring(0,3):t.length>4&&n(t.slice(0,4),i)}}).call(e,r(1).Buffer)},function(t,e){function r(t,e){if(t=t.replace(/\t+/g," ").trim(),!t)return null;var r=t.indexOf(" ");if(r===-1)throw new Error("no named row at line "+e);var i=t.substring(0,r);t=t.substring(r+1),t=t.replace(/letter=[\'\"]\S+[\'\"]/gi,""),t=t.split("="),t=t.map(function(t){return t.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)});for(var o=[],a=0;ae.length-1)return 0;var s=e.readUInt8(r++),f=e.readInt32LE(r);switch(r+=4,s){case 1:t.info=n(e,r);break;case 2:t.common=i(e,r);break;case 3:t.pages=o(e,r,f);break;case 4:t.chars=a(e,r,f);break;case 5:t.kernings=u(e,r,f)}return 5+f}function n(t,e){var r={};r.size=t.readInt16LE(e);var n=t.readUInt8(e+2);return r.smooth=n>>7&1,r.unicode=n>>6&1,r.italic=n>>5&1,r.bold=n>>4&1,n>>3&1&&(r.fixedHeight=1),r.charset=t.readUInt8(e+3)||"",r.stretchH=t.readUInt16LE(e+4),r.aa=t.readUInt8(e+6),r.padding=[t.readInt8(e+7),t.readInt8(e+8),t.readInt8(e+9),t.readInt8(e+10)],r.spacing=[t.readInt8(e+11),t.readInt8(e+12)],r.outline=t.readUInt8(e+13),r.face=f(t,e+14),r}function i(t,e){var r={};r.lineHeight=t.readUInt16LE(e),r.base=t.readUInt16LE(e+2),r.scaleW=t.readUInt16LE(e+4),r.scaleH=t.readUInt16LE(e+6),r.pages=t.readUInt16LE(e+8);t.readUInt8(e+10);return r.packed=0,r.alphaChnl=t.readUInt8(e+11),r.redChnl=t.readUInt8(e+12),r.greenChnl=t.readUInt8(e+13),r.blueChnl=t.readUInt8(e+14),r}function o(t,e,r){for(var n=[],i=s(t,e),o=i.length+1,a=r/o,u=0;u3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var o={kernings:[],chars:[]},a=0;a<5;a++)n+=r(o,t,n);return o}},function(t,e,r){function n(t){var e=i(t);return e.reduce(function(t,e){var r=o(e.nodeName);return t[r]=e.nodeValue,t},{})}function i(t){for(var e=[],r=0;r element");for(var o=i.getElementsByTagName("page"),s=0;s0});this.visibleGlyphs=h;var c=f.positions(h),p=f.uvs(h,n,o,e),l=a({clockwise:!0,type:"uint16",count:h.length});if(u.index(this,l,1,"uint16"),u.attr(this,"position",c,2),u.attr(this,"uv",p,2),!t.multipage&&"page"in this.attributes)this.removeAttribute("page");else if(t.multipage){var d=f.pages(h);u.attr(this,"page",d,1)}},n.prototype.computeBoundingSphere=function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var t=this.attributes.position.array,e=this.attributes.position.itemSize;return!t||!e||t.length<2?(this.boundingSphere.radius=0,void this.boundingSphere.center.set(0,0,0)):(h.computeSphere(t,this.boundingSphere),void(isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')))},n.prototype.computeBoundingBox=function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var t=this.boundingBox,e=this.attributes.position.array,r=this.attributes.position.itemSize;return!e||!r||e.length<2?void t.makeEmpty():void h.computeBox(e,t)}},function(t,e){function r(t){var e=t.length/n;i.min[0]=t[0],i.min[1]=t[1],i.max[0]=t[0],i.max[1]=t[1];for(var r=0;rn?n:i}function n(t){return f.test(t)}function i(t,e,r,n,i){for(var o=[],a=r,s=r;si&&!n(e.charAt(l));)l--;if(l===i)d>i+s.length&&d--,l=d;else for(d=l;l>i&&n(e.charAt(l-s.length));)l--}if(l>=i){var g=t(e,i,l,h);f.push(g)}i=d}return f}function a(t,e,r,n){var i=Math.min(n,r-e);return{start:e,end:e+i}}var u=/\n/,s="\n",f=/\s/;t.exports=function(e,r){var n=t.exports.lines(e,r);return n.map(function(t){return e.substring(t.start,t.end)}).join("\n")},t.exports.lines=function(t,e){if(e=e||{},0===e.width&&"nowrap"!==e.mode)return[];t=t||"";var r="number"==typeof e.width?e.width:Number.MAX_VALUE,n=Math.max(0,e.start||0),u="number"==typeof e.end?e.end:t.length,s=e.mode,f=e.measure||a;return"pre"===s?i(f,t,n,u,r):o(f,t,n,u,r,s)}},function(t,e,r){"use strict";function n(t,e){for(var r=0;r0&&(g=setTimeout(function(){d=!0,c.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",n(t)},t.timeout)),c.setRequestHeader)for(l in m)m.hasOwnProperty(l)&&c.setRequestHeader(l,m[l]);else if(t.headers&&!i(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(c.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(c),c.send(w),c}function s(t){if("document"===t.responseType)return t.responseXML;var e=204===t.status&&t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;return""!==t.responseType||e?null:t.responseXML}function f(){}var h=r(15),c=r(4),p=r(27),l=r(2);t.exports=a,a.XMLHttpRequest=h.XMLHttpRequest||f,a.XDomainRequest="withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:h.XDomainRequest,n(["get","put","post","patch","head","delete"],function(t){a["delete"===t?"del":t]=function(e,r,n){return r=o(e,r,n),r.method=t.toUpperCase(),u(r)}})},function(t,e){t.exports=function(){return"undefined"!=typeof window.DOMParser?function(t){var e=new window.DOMParser;return e.parseFromString(t,"application/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")?function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}:function(t){var e=document.createElement("div");return e.innerHTML=t,e}}()}]); -------------------------------------------------------------------------------- /dist/old/aframe-bmfont-text-component-no-prim.min.js: -------------------------------------------------------------------------------- 1 | !function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(t,e){o(t.font,function(r,n){if(r)throw r;var i=new THREE.TextureLoader;i.load(t.image,function(t){e(n,t)})})}if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");var i=r(28),o=r(20),a=r(6);AFRAME.registerComponent("bmfont-text",{schema:{text:{type:"string"},width:{type:"number","default":1e3},align:{type:"string","default":"left"},letterSpacing:{type:"number","default":0},lineHeight:{type:"number","default":38},fnt:{type:"string","default":"https://cdn.rawgit.com/bryik/aframe-bmfont-text-component/aa0655cf90f646e12c40ab4708ea90b4686cfb45/assets/DejaVu-sdf.fnt"},fntImage:{type:"string","default":"https://cdn.rawgit.com/bryik/aframe-bmfont-text-component/aa0655cf90f646e12c40ab4708ea90b4686cfb45/assets/DejaVu-sdf.png"},mode:{type:"string","default":"normal"},color:{type:"color","default":"#000"},opacity:{type:"number","default":"1.0"}},update:function(t){function e(t,e){e.needsUpdate=!0,e.anisotropy=16;var n={font:t,text:o.text,width:o.width,align:o.align,letterSpacing:o.letterSpacing,lineHeight:o.lineHeight,mode:o.mode},u=i(n),s=new THREE.RawShaderMaterial(a({map:e,side:THREE.DoubleSide,transparent:!0,color:o.color,opacity:o.opacity})),f=new THREE.Mesh(u,s);f.rotation.y=Math.PI,f.scale.multiplyScalar(-.005),r.setObject3D("bmfont-text",f)}var r=this.el,o=this.data;n({font:o.fnt,image:o.fntImage},e)},remove:function(){this.el.removeObject3D("bmfont-text")}})},function(t,e,r){(function(t,n){/*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */ 7 | "use strict";function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,r){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function y(e){return+e!=e&&(e=0),t.alloc(+e)}function v(e,r){if(t.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(i)return G(e).length;r=(""+r).toLowerCase(),i=!0}}function w(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(e,r,n,i,o){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof r&&(r=t.from(r,i)),t.isBuffer(r))return 0===r.length?-1:E(e,r,n,i,o);if("number"==typeof r)return r=255&r,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):E(e,[r],n,i,o);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){function o(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}var a=1,u=t.length,s=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,r/=2}var f;if(i){var h=-1;for(f=r;fu&&(r=u-s),f=r;f>=0;f--){for(var c=!0,p=0;pi&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+u<=r){var s,f,h,c;switch(u){case 1:o<128&&(a=o);break;case 2:s=t[i+1],128===(192&s)&&(c=(31&o)<<6|63&s,c>127&&(a=c));break;case 3:s=t[i+1],f=t[i+2],128===(192&s)&&128===(192&f)&&(c=(15&o)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:s=t[i+1],f=t[i+2],h=t[i+3],128===(192&s)&&128===(192&f)&&128===(192&h)&&(c=(15&o)<<18|(63&s)<<12|(63&f)<<6|63&h,c>65535&&c<1114112&&(a=c))}}null===a?(a=65533,u=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=u}return I(n)}function I(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function k(e,r,n,i,o,a){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||re.length)throw new RangeError("Index out of range")}function j(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function H(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function Y(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,i){return i||Y(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return i||Y(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,r,n,52,8),r+8}function X(t){if(t=F(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function F(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return t<16?"0"+t.toString(16):t.toString(16)}function G(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function z(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function J(t){return Z.toByteArray(X(t))}function W(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function $(t){return t!==t}var Z=r(9),K=r(15),Q=r(11);e.Buffer=t,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==n.TYPED_ARRAY_SUPPORT?n.TYPED_ARRAY_SUPPORT:i(),e.kMaxLength=o(),t.poolSize=8192,t._augment=function(e){return e.__proto__=t.prototype,e},t.from=function(t,e,r){return u(null,t,e,r)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,e,r){return f(null,t,e,r)},t.allocUnsafe=function(t){return h(null,t)},t.allocUnsafeSlow=function(t){return h(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,o=0,a=Math.min(n,i);o0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},t.prototype.compare=function(e,r,n,i,o){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var a=o-i,u=n-r,s=Math.min(a,u),f=this.slice(i,o),h=e.slice(r,n),c=0;ci)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return A(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return R(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r0&&(i*=256);)n+=this[t+--e]*i;return n},t.prototype.readUInt8=function(t,e){return e||C(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||C(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||C(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||C(t,e,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*e)),n},t.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||C(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||C(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||C(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||C(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||C(t,4,this.length),K.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||C(t,4,this.length),K.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||C(t,8,this.length),K.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||C(t,8,this.length),K.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;k(this,t,e,r,i,0)}var o=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+o]=t/a&255;return e+r},t.prototype.writeUInt8=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=255&e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):j(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):j(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=255&e):H(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):H(this,e,r,!1),r+4},t.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=0,a=1,u=0;for(this[e]=255&t;++o>0)-u&255;return e+r},t.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=r-1,a=1,u=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/a>>0)-u&255;return e+r},t.prototype.writeInt8=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=255&e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):j(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):j(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):H(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r=0|r,n||k(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):H(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r=0;--o)e[o+r]=this[o+n];else if(a<1e3||!t.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=r;a0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[u-2]?2:"="===t[u-1]?1:0,a=new f(3*u/4-o),n=o>0?u-4:u;var h=0;for(e=0,r=0;e>16&255,a[h++]=i>>8&255,a[h++]=255&i;return 2===o?(i=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,a[h++]=255&i):1===o&&(i=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,a[h++]=i>>8&255,a[h++]=255&i),a}function i(t){return u[t>>18&63]+u[t>>12&63]+u[t>>6&63]+u[63&t]}function o(t,e,r){for(var n,o=[],a=e;ah?h:f+s));return 1===n?(e=t[r-1],i+=u[e>>2],i+=u[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=u[e>>10],i+=u[e>>4&63],i+=u[e<<2&63],i+="="),a.push(i),a.join("")}e.toByteArray=n,e.fromByteArray=a;var u=[],s=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},function(t,e,r){var n=r(1).Buffer;t.exports=function(t,e){if(n.isBuffer(t)&&n.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var r=0;r>1,h=-7,c=r?i-1:0,p=r?-1:1,l=t[e+c];for(c+=p,o=l&(1<<-h)-1,l>>=-h,h+=u;h>0;o=256*o+t[e+c],c+=p,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+c],c+=p,h-=8);if(0===o)o=1-f;else{if(o===s)return a?NaN:(l?-1:1)*(1/0);a+=Math.pow(2,n),o-=f}return(l?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,u,s,f=8*o-i-1,h=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),e+=a+c>=1?p/s:p*Math.pow(2,1-c),e*s>=2&&(a++,s/=2),a+c>=h?(u=0,a=h):a+c>=1?(u=(e*s-1)*Math.pow(2,i),a+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;t[r+l]=255&u,l+=d,u/=256,i-=8);for(a=a<0;t[r+l]=255&a,l+=d,a/=256,f-=8);t[r+l-d]|=128*g}},function(t,e){t.exports=function(t){if(!t||"string"!=typeof t)throw new Error("must specify property for indexof search");return new Function("array","value","start",["start = start || 0","for (var i=start; i 11 | * @license MIT 12 | */ 13 | t.exports=function(t){return null!=t&&(r(t)||n(t)||!!t._isBuffer)}},function(t,e,r){function n(t){this.glyphs=[],this._measure=this.computeMetrics.bind(this),this.update(t)}function i(t){Object.defineProperty(n.prototype,t,{get:o(t),configurable:!0})}function o(t){return new Function(["return function "+t+"() {"," return this._"+t,"}"].join("\n"))()}function a(t,e){if(!t.chars||0===t.chars.length)return null;var r=d(t.chars,e);return r>=0?t.chars[r]:null}function u(t){for(var e=0;e=0)return t.chars[n].height}return 0}function s(t){for(var e=0;e=0)return t.chars[n]}return 0}function f(t){for(var e=0;e=0)return t.chars[n].height}return 0}function h(t,e,r){if(!t.kernings||0===t.kernings.length)return 0;for(var n=t.kernings,i=0;i=n||g>=n)break;s=g,f=y,o=i}c++}return o&&(f+=o.xoffset),{start:e,end:e+c,width:f}},["width","height","descender","ascender","xHeight","baseline","capHeight","lineHeight"].forEach(i)},function(t,e,r){(function(e){function n(t){var e=Object.prototype.toString;return"[object ArrayBuffer]"===e.call(t)}function i(t){if(p)return c(t,{responseType:"arraybuffer"});if("undefined"==typeof window.XMLHttpRequest)throw new Error("your browser does not support XHR loading");var e=new window.XMLHttpRequest;return e.overrideMimeType("text/plain; charset=x-user-defined"),c({xhr:e},t)}var o=r(34),a=function(){},u=r(22),s=r(24),f=r(23),h=r(21),c=r(2),p=function(){return window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}();t.exports=function(t,r){r="function"==typeof r?r:a,"string"==typeof t?t={uri:t}:t||(t={});var c=t.binary;c&&(t=i(t)),o(t,function(i,o,c){if(i)return r(i);if(!/^2/.test(o.statusCode))return r(new Error("http status code: "+o.statusCode));if(!c)return r(new Error("no body result"));var p=!1;if(n(c)){var l=new Uint8Array(c);c=new e(l,"binary")}h(c)&&(p=!0,"string"==typeof c&&(c=new e(c,"binary"))),p||(e.isBuffer(c)&&(c=c.toString(t.encoding)),c=c.trim());var d;try{var g=o.headers["content-type"];d=p?f(c):/json/.test(g)||"{"===c.charAt(0)?JSON.parse(c):/xml/.test(g)||"<"===c.charAt(0)?s(c):u(c)}catch(y){r(new Error("error parsing font "+y.message)),r=a}r(null,d)})}}).call(e,r(1).Buffer)},function(t,e,r){(function(e){var n=r(10),i=new e([66,77,70,3]);t.exports=function(t){return"string"==typeof t?"BMF"===t.substring(0,3):t.length>4&&n(t.slice(0,4),i)}}).call(e,r(1).Buffer)},function(t,e){function r(t,e){if(t=t.replace(/\t+/g," ").trim(),!t)return null;var r=t.indexOf(" ");if(r===-1)throw new Error("no named row at line "+e);var i=t.substring(0,r);t=t.substring(r+1),t=t.replace(/letter=[\'\"]\S+[\'\"]/gi,""),t=t.split("="),t=t.map(function(t){return t.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)});for(var o=[],a=0;ae.length-1)return 0;var s=e.readUInt8(r++),f=e.readInt32LE(r);switch(r+=4,s){case 1:t.info=n(e,r);break;case 2:t.common=i(e,r);break;case 3:t.pages=o(e,r,f);break;case 4:t.chars=a(e,r,f);break;case 5:t.kernings=u(e,r,f)}return 5+f}function n(t,e){var r={};r.size=t.readInt16LE(e);var n=t.readUInt8(e+2);return r.smooth=n>>7&1,r.unicode=n>>6&1,r.italic=n>>5&1,r.bold=n>>4&1,n>>3&1&&(r.fixedHeight=1),r.charset=t.readUInt8(e+3)||"",r.stretchH=t.readUInt16LE(e+4),r.aa=t.readUInt8(e+6),r.padding=[t.readInt8(e+7),t.readInt8(e+8),t.readInt8(e+9),t.readInt8(e+10)],r.spacing=[t.readInt8(e+11),t.readInt8(e+12)],r.outline=t.readUInt8(e+13),r.face=f(t,e+14),r}function i(t,e){var r={};r.lineHeight=t.readUInt16LE(e),r.base=t.readUInt16LE(e+2),r.scaleW=t.readUInt16LE(e+4),r.scaleH=t.readUInt16LE(e+6),r.pages=t.readUInt16LE(e+8);t.readUInt8(e+10);return r.packed=0,r.alphaChnl=t.readUInt8(e+11),r.redChnl=t.readUInt8(e+12),r.greenChnl=t.readUInt8(e+13),r.blueChnl=t.readUInt8(e+14),r}function o(t,e,r){for(var n=[],i=s(t,e),o=i.length+1,a=r/o,u=0;u3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var o={kernings:[],chars:[]},a=0;a<5;a++)n+=r(o,t,n);return o}},function(t,e,r){function n(t){var e=i(t);return e.reduce(function(t,e){var r=o(e.nodeName);return t[r]=e.nodeValue,t},{})}function i(t){for(var e=[],r=0;r element");for(var o=i.getElementsByTagName("page"),s=0;s0});this.visibleGlyphs=h;var c=f.positions(h),p=f.uvs(h,n,o,e),l=a({clockwise:!0,type:"uint16",count:h.length});if(u.index(this,l,1,"uint16"),u.attr(this,"position",c,2),u.attr(this,"uv",p,2),!t.multipage&&"page"in this.attributes)this.removeAttribute("page");else if(t.multipage){var d=f.pages(h);u.attr(this,"page",d,1)}},n.prototype.computeBoundingSphere=function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var t=this.attributes.position.array,e=this.attributes.position.itemSize;return!t||!e||t.length<2?(this.boundingSphere.radius=0,void this.boundingSphere.center.set(0,0,0)):(h.computeSphere(t,this.boundingSphere),void(isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')))},n.prototype.computeBoundingBox=function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var t=this.boundingBox,e=this.attributes.position.array,r=this.attributes.position.itemSize;return!e||!r||e.length<2?void t.makeEmpty():void h.computeBox(e,t)}},function(t,e){function r(t){var e=t.length/n;i.min[0]=t[0],i.min[1]=t[1],i.max[0]=t[0],i.max[1]=t[1];for(var r=0;rn?n:i}function n(t){return f.test(t)}function i(t,e,r,n,i){for(var o=[],a=r,s=r;si&&!n(e.charAt(l));)l--;if(l===i)d>i+s.length&&d--,l=d;else for(d=l;l>i&&n(e.charAt(l-s.length));)l--}if(l>=i){var g=t(e,i,l,h);f.push(g)}i=d}return f}function a(t,e,r,n){var i=Math.min(n,r-e);return{start:e,end:e+i}}var u=/\n/,s="\n",f=/\s/;t.exports=function(e,r){var n=t.exports.lines(e,r);return n.map(function(t){return e.substring(t.start,t.end)}).join("\n")},t.exports.lines=function(t,e){if(e=e||{},0===e.width&&"nowrap"!==e.mode)return[];t=t||"";var r="number"==typeof e.width?e.width:Number.MAX_VALUE,n=Math.max(0,e.start||0),u="number"==typeof e.end?e.end:t.length,s=e.mode,f=e.measure||a;return"pre"===s?i(f,t,n,u,r):o(f,t,n,u,r,s)}},function(t,e,r){"use strict";function n(t,e){for(var r=0;r0&&(g=setTimeout(function(){d=!0,c.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",n(t)},t.timeout)),c.setRequestHeader)for(l in m)m.hasOwnProperty(l)&&c.setRequestHeader(l,m[l]);else if(t.headers&&!i(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(c.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(c),c.send(w),c}function s(t){if("document"===t.responseType)return t.responseXML;var e=204===t.status&&t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;return""!==t.responseType||e?null:t.responseXML}function f(){}var h=r(14),c=r(4),p=r(26),l=r(2);t.exports=a,a.XMLHttpRequest=h.XMLHttpRequest||f,a.XDomainRequest="withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:h.XDomainRequest,n(["get","put","post","patch","head","delete"],function(t){a["delete"===t?"del":t]=function(e,r,n){return r=o(e,r,n),r.method=t.toUpperCase(),u(r)}})},function(t,e){t.exports=function(){return"undefined"!=typeof window.DOMParser?function(t){var e=new window.DOMParser;return e.parseFromString(t,"application/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")?function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}:function(t){var e=document.createElement("div");return e.innerHTML=t,e}}()}]); -------------------------------------------------------------------------------- /dist/old/aframe-bmfont-text-component-v0.1.0.min.js: -------------------------------------------------------------------------------- 1 | !function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(t,e){o(t.font,function(r,n){if(r)throw r;var i=new THREE.TextureLoader;i.load(t.image,function(t){e(n,t)})})}if("undefined"==typeof AFRAME)throw new Error("Component attempted to register before AFRAME was available.");var i=r(29),o=r(20),a=r(6);AFRAME.registerComponent("bmfont-text",{schema:{text:{type:"string"},width:{type:"number","default":1e3},align:{type:"string","default":"left"},letterSpacing:{type:"number","default":0},fnt:{type:"string","default":"../fonts/DejaVu-sdf.fnt"},fntImage:{type:"string","default":"../fonts/DejaVu-sdf.png"},mode:{type:"string","default":"normal"},color:{type:"color","default":"#000"}},update:function(t){function e(t,e){e.needsUpdate=!0,e.anisotropy=16;var r={font:t,text:u.text,width:u.width,align:u.left,letterSpacing:u.letterSpacing,mode:u.mode},n=i(r),s=new THREE.RawShaderMaterial(a({map:e,side:THREE.DoubleSide,transparent:!0,color:u.color})),f=new THREE.Mesh(n,s);f.rotation.y=Math.PI,f.scale.multiplyScalar(-.005),o.add(f)}var r=this.el,o=r.object3D,u=this.data;n({font:u.fnt,image:u.fntImage},e)}})},function(t,e,r){(function(t,n){/*! 2 | * The buffer module from node.js, for the browser. 3 | * 4 | * @author Feross Aboukhadijeh 5 | * @license MIT 6 | */ 7 | "use strict";function i(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(r){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function t(e){return this instanceof t?(t.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?a(this,e):"string"==typeof e?u(this,e,arguments.length>1?arguments[1]:"utf8"):s(this,e)):arguments.length>1?new t(e,arguments[1]):new t(e)}function a(e,r){if(e=g(e,r<0?0:0|y(r)),!t.TYPED_ARRAY_SUPPORT)for(var n=0;n>>1;return n&&(e.parent=Z),e}function y(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function w(e,r){if(!(this instanceof w))return new w(e,r);var n=new t(e,r);return delete n.parent,n}function v(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return X(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return z(t).length;default:if(n)return X(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),e<0&&(e=0),r>this.length&&(r=this.length),r<=e)return"";for(;;)switch(t){case"hex":return L(this,e,r);case"utf8":case"utf-8":return B(this,e,r);case"ascii":return S(this,e,r);case"binary":return T(this,e,r);case"base64":return U(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function E(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a239?4:o>223?3:o>191?2:1;if(i+u<=r){var s,f,h,c;switch(u){case 1:o<128&&(a=o);break;case 2:s=t[i+1],128===(192&s)&&(c=(31&o)<<6|63&s,c>127&&(a=c));break;case 3:s=t[i+1],f=t[i+2],128===(192&s)&&128===(192&f)&&(c=(15&o)<<12|(63&s)<<6|63&f,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:s=t[i+1],f=t[i+2],h=t[i+3],128===(192&s)&&128===(192&f)&&128===(192&h)&&(c=(15&o)<<18|(63&s)<<12|(63&f)<<6|63&h,c>65535&&c<1114112&&(a=c))}}null===a?(a=65533,u=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=u}return _(n)}function _(t){var e=t.length;if(e<=K)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function O(e,r,n,i,o,a){if(!t.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(r>o||re.length)throw new RangeError("index out of range")}function C(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function j(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function k(t,e,r,n,i,o){if(e>i||et.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function D(t,e,r,n,i){return i||k(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),W.write(t,e,r,n,23,4),r+4}function Y(t,e,r,n,i){return i||k(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),W.write(t,e,r,n,52,8),r+8}function H(t){if(t=N(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function N(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function X(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(t){for(var e=[],r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function z(t){return J.toByteArray(H(t))}function V(t,e,r,n){for(var i=0;i=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var J=r(9),W=r(15),$=r(11);e.Buffer=t,e.SlowBuffer=w,e.INSPECT_MAX_BYTES=50,t.poolSize=8192;var Z={};t.TYPED_ARRAY_SUPPORT=void 0!==n.TYPED_ARRAY_SUPPORT?n.TYPED_ARRAY_SUPPORT:i(),t.TYPED_ARRAY_SUPPORT?(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array):(t.prototype.length=void 0,t.prototype.parent=void 0),t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,r){if(!t.isBuffer(e)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,o=0,a=Math.min(n,i);o0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},t.prototype.compare=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:t.compare(this,e)},t.prototype.indexOf=function(e,r){function n(t,e,r){for(var n=-1,i=0;r+i2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(r<0&&(r=Math.max(this.length+r,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,r);if(t.isBuffer(e))return n(this,e,r);if("number"==typeof e)return t.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,r):n(this,[e],r);throw new TypeError("val must be string, number or Buffer")},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},t.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return A(this,t,e,r);case"binary":return x(this,t,e,r);case"base64":return I(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;t.prototype.slice=function(e,r){var n=this.length;e=~~e,r=void 0===r?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r0&&(i*=256);)n+=this[t+--e]*i;return n},t.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||M(t,e,this.length);for(var n=this[t],i=1,o=0;++o=i&&(n-=Math.pow(2,8*e)),n},t.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||M(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),W.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),W.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),W.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),W.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+r},t.prototype.writeUInt8=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=255&e,r+1},t.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):C(this,e,r,!0),r+2},t.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):C(this,e,r,!1),r+2},t.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=255&e):j(this,e,r,!0),r+4},t.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):j(this,e,r,!1),r+4},t.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,u=t<0?1:0;for(this[e]=255&t;++o>0)-u&255;return e+r},t.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,u=t<0?1:0;for(this[e+o]=255&t;--o>=0&&(a*=256);)this[e+o]=(t/a>>0)-u&255;return e+r},t.prototype.writeInt8=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=255&e,r+1},t.prototype.writeInt16LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8):C(this,e,r,!0),r+2},t.prototype.writeInt16BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=255&e):C(this,e,r,!1),r+2},t.prototype.writeInt32LE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=255&e,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):j(this,e,r,!0),r+4},t.prototype.writeInt32BE=function(e,r,n){return e=+e,r=0|r,n||O(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=255&e):j(this,e,r,!1),r+4},t.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},t.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},t.prototype.writeDoubleLE=function(t,e,r){return Y(this,t,e,!0,r)},t.prototype.writeDoubleBE=function(t,e,r){return Y(this,t,e,!1,r)},t.prototype.copy=function(e,r,n,i){if(n||(n=0),i||0===i||(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r=0;o--)e[o+r]=this[o+n];else if(a<1e3||!t.TYPED_ARRAY_SUPPORT)for(o=0;o=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;n0)throw new Error("Invalid string. Length must be a multiple of 4");var h=t.length;s="="===t.charAt(h-2)?2:"="===t.charAt(h-1)?1:0,f=new o(3*t.length/4-s),a=s>0?t.length-4:t.length;var c=0;for(n=0,i=0;n>16),r((65280&u)>>8),r(255&u);return 2===s?(u=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&u)):1===s&&(u=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(u>>8&255),r(255&u)),f}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,a,u=t.length%3,s="";for(i=0,a=t.length-u;i>2),s+=e(o<<4&63),s+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],s+=e(o>>10),s+=e(o>>4&63),s+=e(o<<2&63),s+="="}return s}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),u="/".charCodeAt(0),s="0".charCodeAt(0),f="a".charCodeAt(0),h="A".charCodeAt(0),c="-".charCodeAt(0),p="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}(e)},function(t,e,r){var n=r(1).Buffer;t.exports=function(t,e){if(n.isBuffer(t)&&n.isBuffer(e)){if("function"==typeof t.equals)return t.equals(e);if(t.length!==e.length)return!1;for(var r=0;r>1,h=-7,c=r?i-1:0,p=r?-1:1,l=t[e+c];for(c+=p,o=l&(1<<-h)-1,l>>=-h,h+=u;h>0;o=256*o+t[e+c],c+=p,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+c],c+=p,h-=8);if(0===o)o=1-f;else{if(o===s)return a?NaN:(l?-1:1)*(1/0);a+=Math.pow(2,n),o-=f}return(l?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,u,s,f=8*o-i-1,h=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),e+=a+c>=1?p/s:p*Math.pow(2,1-c),e*s>=2&&(a++,s/=2),a+c>=h?(u=0,a=h):a+c>=1?(u=(e*s-1)*Math.pow(2,i),a+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;t[r+l]=255&u,l+=d,u/=256,i-=8);for(a=a<0;t[r+l]=255&a,l+=d,a/=256,f-=8);t[r+l-d]|=128*g}},function(t,e){t.exports=function(t){if(!t||"string"!=typeof t)throw new Error("must specify property for indexof search");return new Function("array","value","start",["start = start || 0","for (var i=start; i=0?t.chars[r]:null}function u(t){for(var e=0;e=0)return t.chars[n].height}return 0}function s(t){for(var e=0;e=0)return t.chars[n]}return 0}function f(t){for(var e=0;e=0)return t.chars[n].height}return 0}function h(t,e,r){if(!t.kernings||0===t.kernings.length)return 0;for(var n=t.kernings,i=0;i=n||g>=n)break;s=g,f=y,o=i}c++}return o&&(f+=o.xoffset),{start:e,end:e+c,width:f}},["width","height","descender","ascender","xHeight","baseline","capHeight","lineHeight"].forEach(i)},function(t,e,r){(function(e){function n(t){var e=Object.prototype.toString;return"[object ArrayBuffer]"===e.call(t)}function i(t){if(p)return c(t,{responseType:"arraybuffer"});if("undefined"==typeof window.XMLHttpRequest)throw new Error("your browser does not support XHR loading");var e=new window.XMLHttpRequest;return e.overrideMimeType("text/plain; charset=x-user-defined"),c({xhr:e},t)}var o=r(35),a=function(){},u=r(23),s=r(25),f=r(24),h=r(21),c=r(2),p=function(){return window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}();t.exports=function(t,r){r="function"==typeof r?r:a,"string"==typeof t?t={uri:t}:t||(t={});var c=t.binary;c&&(t=i(t)),o(t,function(i,o,c){if(i)return r(i);if(!/^2/.test(o.statusCode))return r(new Error("http status code: "+o.statusCode));if(!c)return r(new Error("no body result"));var p=!1;if(n(c)){var l=new Uint8Array(c);c=new e(l,"binary")}h(c)&&(p=!0,"string"==typeof c&&(c=new e(c,"binary"))),p||(e.isBuffer(c)&&(c=c.toString(t.encoding)),c=c.trim());var d;try{var g=o.headers["content-type"];d=p?f(c):/json/.test(g)||"{"===c.charAt(0)?JSON.parse(c):/xml/.test(g)||"<"===c.charAt(0)?s(c):u(c)}catch(y){r(new Error("error parsing font "+y.message)),r=a}r(null,d)})}}).call(e,r(1).Buffer)},function(t,e,r){(function(e){var n=r(10),i=new e([66,77,70,3]);t.exports=function(t){return"string"==typeof t?"BMF"===t.substring(0,3):t.length>4&&n(t.slice(0,4),i)}}).call(e,r(1).Buffer)},function(t,e){function r(t){var e=!1;return function(){if(!e)return e=!0,t.apply(this,arguments)}}t.exports=r,r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0})})},function(t,e){function r(t,e){if(t=t.replace(/\t+/g," ").trim(),!t)return null;var r=t.indexOf(" ");if(r===-1)throw new Error("no named row at line "+e);var i=t.substring(0,r);t=t.substring(r+1),t=t.replace(/letter=[\'\"]\S+[\'\"]/gi,""),t=t.split("="),t=t.map(function(t){return t.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)});for(var o=[],a=0;ae.length-1)return 0;var s=e.readUInt8(r++),f=e.readInt32LE(r);switch(r+=4,s){case 1:t.info=n(e,r);break;case 2:t.common=i(e,r);break;case 3:t.pages=o(e,r,f);break;case 4:t.chars=a(e,r,f);break;case 5:t.kernings=u(e,r,f)}return 5+f}function n(t,e){var r={};r.size=t.readInt16LE(e);var n=t.readUInt8(e+2);return r.smooth=n>>7&1,r.unicode=n>>6&1,r.italic=n>>5&1,r.bold=n>>4&1,n>>3&1&&(r.fixedHeight=1),r.charset=t.readUInt8(e+3)||"",r.stretchH=t.readUInt16LE(e+4),r.aa=t.readUInt8(e+6),r.padding=[t.readInt8(e+7),t.readInt8(e+8),t.readInt8(e+9),t.readInt8(e+10)],r.spacing=[t.readInt8(e+11),t.readInt8(e+12)],r.outline=t.readUInt8(e+13),r.face=f(t,e+14),r}function i(t,e){var r={};r.lineHeight=t.readUInt16LE(e),r.base=t.readUInt16LE(e+2),r.scaleW=t.readUInt16LE(e+4),r.scaleH=t.readUInt16LE(e+6),r.pages=t.readUInt16LE(e+8);t.readUInt8(e+10);return r.packed=0,r.alphaChnl=t.readUInt8(e+11),r.redChnl=t.readUInt8(e+12),r.greenChnl=t.readUInt8(e+13),r.blueChnl=t.readUInt8(e+14),r}function o(t,e,r){for(var n=[],i=s(t,e),o=i.length+1,a=r/o,u=0;u3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var o={kernings:[],chars:[]},a=0;a<5;a++)n+=r(o,t,n);return o}},function(t,e,r){function n(t){var e=i(t);return e.reduce(function(t,e){var r=o(e.nodeName);return t[r]=e.nodeValue,t},{})}function i(t){for(var e=[],r=0;r element");for(var o=i.getElementsByTagName("page"),s=0;s0});this.visibleGlyphs=h;var c=f.positions(h),p=f.uvs(h,n,o,e),l=a({clockwise:!0,type:"uint16",count:h.length});if(u.index(this,l,1,"uint16"),u.attr(this,"position",c,2),u.attr(this,"uv",p,2),!t.multipage&&"page"in this.attributes)this.removeAttribute("page");else if(t.multipage){var d=f.pages(h);u.attr(this,"page",d,1)}},n.prototype.computeBoundingSphere=function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var t=this.attributes.position.array,e=this.attributes.position.itemSize;return!t||!e||t.length<2?(this.boundingSphere.radius=0,void this.boundingSphere.center.set(0,0,0)):(h.computeSphere(t,this.boundingSphere),void(isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')))},n.prototype.computeBoundingBox=function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var t=this.boundingBox,e=this.attributes.position.array,r=this.attributes.position.itemSize;return!e||!r||e.length<2?void t.makeEmpty():void h.computeBox(e,t)}},function(t,e){function r(t){var e=t.length/n;i.min[0]=t[0],i.min[1]=t[1],i.max[0]=t[0],i.max[1]=t[1];for(var r=0;rn?n:i}function n(t){return f.test(t)}function i(t,e,r,n,i){for(var o=[],a=r,s=r;si&&!n(e.charAt(l));)l--;if(l===i)d>i+s.length&&d--,l=d;else for(d=l;l>i&&n(e.charAt(l-s.length));)l--}if(l>=i){var g=t(e,i,l,h);f.push(g)}i=d}return f}function a(t,e,r,n){var i=Math.min(n,r-e);return{start:e,end:e+i}}var u=/\n/,s="\n",f=/\s/;t.exports=function(e,r){var n=t.exports.lines(e,r);return n.map(function(t){return e.substring(t.start,t.end)}).join("\n")},t.exports.lines=function(t,e){if(e=e||{},0===e.width&&"nowrap"!==e.mode)return[];t=t||"";var r="number"==typeof e.width?e.width:Number.MAX_VALUE,n=Math.max(0,e.start||0),u="number"==typeof e.end?e.end:t.length,s=e.mode,f=e.measure||a;return"pre"===s?i(f,t,n,u,r):o(f,t,n,u,r,s)}},function(t,e,r){"use strict";function n(t,e){for(var r=0;r0&&(d=setTimeout(function(){l=!0,f.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",n(t)},t.timeout)),f.setRequestHeader)for(c in v)v.hasOwnProperty(c)&&f.setRequestHeader(c,v[c]);else if(t.headers&&!i(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(f.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(f),f.send(w),f}function s(){}var f=r(14),h=r(22),c=r(4),p=r(27),l=r(2);t.exports=a,a.XMLHttpRequest=f.XMLHttpRequest||s,a.XDomainRequest="withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:f.XDomainRequest,n(["get","put","post","patch","head","delete"],function(t){a["delete"===t?"del":t]=function(e,r,n){return r=o(e,r,n),r.method=t.toUpperCase(),u(r)}})},function(t,e){t.exports=function(){return"undefined"!=typeof window.DOMParser?function(t){var e=new window.DOMParser;return e.parseFromString(t,"application/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")?function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}:function(t){var e=document.createElement("div");return e.innerHTML=t,e}}()}]); -------------------------------------------------------------------------------- /docs/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Basic 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/colors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Different sizes 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 22 | 23 | 24 | 27 | 28 | 29 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component 4 | 5 | 22 | 23 | 24 |

A-Frame BMFont Text Component

25 |

Examples

26 | Basic 27 | 'pre' mode 28 | Colors 29 |

Tests

30 | Different sizes 31 | Align 32 | Text wrapping (by specifying width) 33 | Line breaks 34 | Line height 35 | Opacity transition 36 | Text primitive 37 | 38 |
39 |
40 | Fork me on GitHub 41 |
42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/line-break/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Line breaks 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/line-height/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Different sizes 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/main.js: -------------------------------------------------------------------------------- 1 | require('aframe'); 2 | require('../index.js'); 3 | -------------------------------------------------------------------------------- /docs/opacity/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Opacity 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/pre-mode/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - 'pre' mode 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/primitive/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Primitive 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /docs/sizes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Different sizes 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/text-align/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Line breaks 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/width-wrap/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | A-Frame BMFont Text Component - Width wrap 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /extras/text-primitive.js: -------------------------------------------------------------------------------- 1 | /* global AFRAME */ 2 | 3 | /* Experimental text primitive. 4 | * Issues: color not changing, removeAttribute() not working, mixing primitive with regular entities fails 5 | * Color issue relates to: https://github.com/donmccurdy/aframe-extras/blob/master/src/primitives/a-ocean.js#L44 6 | */ 7 | 8 | var extendDeep = AFRAME.utils.extendDeep; 9 | var meshMixin = AFRAME.primitives.getMeshMixin(); 10 | 11 | AFRAME.registerPrimitive('a-text', extendDeep({}, meshMixin, { 12 | defaultComponents: { 13 | 'bmfont-text': {} 14 | }, 15 | mappings: { 16 | text: 'bmfont-text.text', 17 | width: 'bmfont-text.width', 18 | align: 'bmfont-text.align', 19 | letterSpacing: 'bmfont-text.letterSpacing', 20 | lineHeight: 'bmfont-text.lineHeight', 21 | fnt: 'bmfont-text.fnt', 22 | fntImage: 'bmfont-text.fntImage', 23 | mode: 'bmfont-text.mode', 24 | color: 'bmfont-text.color', 25 | opacity: 'bmfont-text.opacity' 26 | } 27 | })); 28 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* global AFRAME, THREE */ 2 | if (typeof AFRAME === 'undefined') { 3 | throw new Error('Component attempted to register before AFRAME was available.'); 4 | } 5 | 6 | var createText = require('three-bmfont-text'); 7 | var loadFont = require('load-bmfont'); 8 | var SDFShader = require('./lib/shaders/sdf'); 9 | 10 | require('./extras/text-primitive.js'); // Register experimental text primitive 11 | 12 | /** 13 | * bmfont text component for A-Frame. 14 | */ 15 | AFRAME.registerComponent('bmfont-text', { 16 | schema: { 17 | text: { 18 | type: 'string' 19 | }, 20 | width: { 21 | type: 'number', 22 | default: 1000 23 | }, 24 | align: { 25 | type: 'string', 26 | default: 'left' 27 | }, 28 | letterSpacing: { 29 | type: 'number', 30 | default: 0 31 | }, 32 | lineHeight: { 33 | type: 'number', 34 | default: 38 35 | }, 36 | fnt: { 37 | type: 'string', 38 | default: 'https://cdn.jsdelivr.net/gh/bryik/aframe-bmfont-text-component@aa0655cf90f646e12c40ab4708ea90b4686cfb45/assets/DejaVu-sdf.fnt' 39 | }, 40 | fntImage: { 41 | type: 'string', 42 | default: 'https://cdn.jsdelivr.net/gh/bryik/aframe-bmfont-text-component@aa0655cf90f646e12c40ab4708ea90b4686cfb45/assets/DejaVu-sdf.png' 43 | }, 44 | mode: { 45 | type: 'string', 46 | default: 'normal' 47 | }, 48 | color: { 49 | type: 'color', 50 | default: '#000' 51 | }, 52 | opacity: { 53 | type: 'number', 54 | default: '1.0' 55 | } 56 | }, 57 | 58 | /** 59 | * Called when component is attached and when component data changes. 60 | * Generally modifies the entity based on the data. 61 | */ 62 | update: function (oldData) { 63 | // Entity data 64 | var el = this.el; 65 | var data = this.data; 66 | 67 | // Use fontLoader utility to load 'fnt' and texture 68 | fontLoader({ 69 | font: data.fnt, 70 | image: data.fntImage 71 | }, start); 72 | 73 | function start (font, texture) { 74 | // Setup texture, should set anisotropy to user maximum... 75 | texture.needsUpdate = true; 76 | texture.anisotropy = 16; 77 | 78 | var options = { 79 | font: font, // the bitmap font definition 80 | text: data.text, // the string to render 81 | width: data.width, 82 | align: data.align, 83 | letterSpacing: data.letterSpacing, 84 | lineHeight: data.lineHeight, 85 | mode: data.mode 86 | }; 87 | 88 | // Create text geometry 89 | var geometry = createText(options); 90 | 91 | // Use './lib/shaders/sdf' to help build a shader material 92 | var material = new THREE.RawShaderMaterial(SDFShader({ 93 | map: texture, 94 | side: THREE.DoubleSide, 95 | transparent: true, 96 | color: data.color, 97 | opacity: data.opacity 98 | })); 99 | 100 | var text = new THREE.Mesh(geometry, material); 101 | 102 | // Rotate so text faces the camera 103 | text.rotation.y = Math.PI; 104 | 105 | // Scale text down 106 | text.scale.multiplyScalar(-0.005); 107 | 108 | // Register text mesh under entity's object3DMap 109 | el.setObject3D('bmfont-text', text); 110 | } 111 | }, 112 | 113 | /** 114 | * Called when a component is removed (e.g., via removeAttribute). 115 | * Generally undoes all modifications to the entity. 116 | */ 117 | remove: function () { 118 | this.el.removeObject3D('bmfont-text'); 119 | } 120 | }); 121 | 122 | /** 123 | * A utility to load a font with bmfont-load 124 | * and a texture with Three.TextureLoader() 125 | */ 126 | function fontLoader (opt, cb) { 127 | loadFont(opt.font, function (err, font) { 128 | if (err) { 129 | throw err; 130 | } 131 | 132 | var textureLoader = new THREE.TextureLoader(); 133 | textureLoader.load(opt.image, function (texture) { 134 | cb(font, texture); 135 | }); 136 | }); 137 | } 138 | -------------------------------------------------------------------------------- /lib/shaders/basic.js: -------------------------------------------------------------------------------- 1 | var assign = require('object-assign') 2 | 3 | module.exports = function createBasicShader (opt) { 4 | opt = opt || {} 5 | var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1 6 | var alphaTest = typeof opt.alphaTest === 'number' ? opt.alphaTest : 0.0001 7 | var precision = opt.precision || 'highp' 8 | var color = opt.color 9 | var map = opt.map 10 | 11 | // remove to satisfy r73 12 | delete opt.map 13 | delete opt.color 14 | delete opt.precision 15 | delete opt.opacity 16 | 17 | return assign({ 18 | uniforms: { 19 | opacity: { type: 'f', value: opacity }, 20 | map: { type: 't', value: map || new THREE.Texture() }, 21 | color: { type: 'c', value: new THREE.Color(color) } 22 | }, 23 | vertexShader: [ 24 | 'attribute vec2 uv;', 25 | 'attribute vec4 position;', 26 | 'uniform mat4 projectionMatrix;', 27 | 'uniform mat4 modelViewMatrix;', 28 | 'varying vec2 vUv;', 29 | 'void main() {', 30 | 'vUv = uv;', 31 | 'gl_Position = projectionMatrix * modelViewMatrix * position;', 32 | '}' 33 | ].join('\n'), 34 | fragmentShader: [ 35 | 'precision ' + precision + ' float;', 36 | 'uniform float opacity;', 37 | 'uniform vec3 color;', 38 | 'uniform sampler2D map;', 39 | 'varying vec2 vUv;', 40 | 41 | 'void main() {', 42 | ' gl_FragColor = texture2D(map, vUv) * vec4(color, opacity);', 43 | alphaTest === 0 44 | ? '' 45 | : ' if (gl_FragColor.a < ' + alphaTest + ') discard;', 46 | '}' 47 | ].join('\n') 48 | }, opt) 49 | } 50 | -------------------------------------------------------------------------------- /lib/shaders/multipage.js: -------------------------------------------------------------------------------- 1 | var assign = require('object-assign') 2 | 3 | module.exports = function createMultipageShader (opt) { 4 | opt = opt || {} 5 | var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1 6 | var precision = opt.precision || 'highp' 7 | var alphaTest = typeof opt.alphaTest === 'number' ? opt.alphaTest : 0.0001 8 | 9 | var textures = opt.textures || [] 10 | textures = Array.isArray(textures) ? textures : [ textures ] 11 | 12 | var baseUniforms = {} 13 | textures.forEach(function (tex, i) { 14 | baseUniforms['texture' + i] = { 15 | type: 't', 16 | value: tex 17 | } 18 | }) 19 | 20 | var samplers = textures.map(function (tex, i) { 21 | return 'uniform sampler2D texture' + i + ';' 22 | }).join('\n') 23 | 24 | var body = textures.map(function (tex, i) { 25 | var cond = i === 0 ? 'if' : 'else if' 26 | return [ 27 | cond + ' (vPage == ' + i + '.0) {', 28 | 'sampleColor = texture2D(texture' + i + ', vUv);', 29 | '}' 30 | ].join('\n') 31 | }).join('\n') 32 | 33 | var color = opt.color 34 | 35 | // remove to satisfy r73 36 | delete opt.textures 37 | delete opt.color 38 | delete opt.precision 39 | delete opt.opacity 40 | 41 | var attributes = { 42 | attributes: { page: { type: 'f', value: 0 } } 43 | } 44 | 45 | var threeVers = (parseInt(THREE.REVISION, 10) || 0) | 0 46 | if (threeVers >= 72) { 47 | attributes = undefined 48 | } 49 | 50 | return assign({ 51 | uniforms: assign({}, baseUniforms, { 52 | opacity: { type: 'f', value: opacity }, 53 | color: { type: 'c', value: new THREE.Color(color) } 54 | }), 55 | vertexShader: [ 56 | 'attribute vec4 position;', 57 | 'attribute vec2 uv;', 58 | 'attribute float page;', 59 | 'uniform mat4 projectionMatrix;', 60 | 'uniform mat4 modelViewMatrix;', 61 | 'varying vec2 vUv;', 62 | 'varying float vPage;', 63 | 'void main() {', 64 | 'vUv = uv;', 65 | 'vPage = page;', 66 | 'gl_Position = projectionMatrix * modelViewMatrix * position;', 67 | '}' 68 | ].join('\n'), 69 | fragmentShader: [ 70 | 'precision ' + precision + ' float;', 71 | 'uniform float opacity;', 72 | 'uniform vec3 color;', 73 | samplers, 74 | 'varying float vPage;', 75 | 'varying vec2 vUv;', 76 | 'void main() {', 77 | 'vec4 sampleColor = vec4(0.0);', 78 | body, 79 | 'gl_FragColor = sampleColor * vec4(color, opacity);', 80 | alphaTest === 0 81 | ? '' 82 | : ' if (gl_FragColor.a < ' + alphaTest + ') discard;', 83 | '}' 84 | ].join('\n') 85 | }, attributes, opt) 86 | } 87 | -------------------------------------------------------------------------------- /lib/shaders/sdf.js: -------------------------------------------------------------------------------- 1 | var assign = require('object-assign') 2 | 3 | module.exports = function createSDFShader (opt) { 4 | opt = opt || {} 5 | var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1 6 | var alphaTest = typeof opt.alphaTest === 'number' ? opt.alphaTest : 0.0001 7 | var precision = opt.precision || 'highp' 8 | var color = opt.color 9 | var map = opt.map 10 | 11 | // remove to satisfy r73 12 | delete opt.map 13 | delete opt.color 14 | delete opt.precision 15 | delete opt.opacity 16 | 17 | return assign({ 18 | uniforms: { 19 | opacity: { type: 'f', value: opacity }, 20 | map: { type: 't', value: map || new THREE.Texture() }, 21 | color: { type: 'c', value: new THREE.Color(color) } 22 | }, 23 | vertexShader: [ 24 | 'attribute vec2 uv;', 25 | 'attribute vec4 position;', 26 | 'uniform mat4 projectionMatrix;', 27 | 'uniform mat4 modelViewMatrix;', 28 | 'varying vec2 vUv;', 29 | 'void main() {', 30 | 'vUv = uv;', 31 | 'gl_Position = projectionMatrix * modelViewMatrix * position;', 32 | '}' 33 | ].join('\n'), 34 | fragmentShader: [ 35 | '#ifdef GL_OES_standard_derivatives', 36 | '#extension GL_OES_standard_derivatives : enable', 37 | '#endif', 38 | 'precision ' + precision + ' float;', 39 | 'uniform float opacity;', 40 | 'uniform vec3 color;', 41 | 'uniform sampler2D map;', 42 | 'varying vec2 vUv;', 43 | 44 | 'float aastep(float value) {', 45 | ' #ifdef GL_OES_standard_derivatives', 46 | ' float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;', 47 | ' #else', 48 | ' float afwidth = (1.0 / 32.0) * (1.4142135623730951 / (2.0 * gl_FragCoord.w));', 49 | ' #endif', 50 | ' return smoothstep(0.5 - afwidth, 0.5 + afwidth, value);', 51 | '}', 52 | 53 | 'void main() {', 54 | ' vec4 texColor = texture2D(map, vUv);', 55 | ' float alpha = aastep(texColor.a);', 56 | ' gl_FragColor = vec4(color, opacity * alpha);', 57 | alphaTest === 0 58 | ? '' 59 | : ' if (gl_FragColor.a < ' + alphaTest + ') discard;', 60 | '}' 61 | ].join('\n') 62 | }, opt) 63 | } 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aframe-bmfont-text-component", 3 | "version": "0.1.4", 4 | "description": "BMFont Text component for A-Frame.", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "browserify docs/main.js -o docs/build.js", 8 | "dev": "budo docs/main.js:build.js --dir docs --port 8000 --live --open", 9 | "dist": "webpack index.js dist/aframe-bmfont-text-component.js && webpack -p index.js dist/aframe-bmfont-text-component.min.js", 10 | "postpublish": "npm run dist", 11 | "start": "npm run dev" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/bryik/aframe-bmfont-text-component.git" 16 | }, 17 | "keywords": [ 18 | "aframe", 19 | "aframe-component", 20 | "aframe-vr", 21 | "vr", 22 | "mozvr", 23 | "webvr" 24 | ], 25 | "author": "Ben Pyrik ", 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/bryik/aframe-bmfont-text-component/issues" 29 | }, 30 | "homepage": "https://github.com/bryik/aframe-bmfont-text-component#readme", 31 | "devDependencies": { 32 | "aframe": "^0.3.1", 33 | "browserify": "^13.1.0", 34 | "browserify-css": "^0.9.1", 35 | "budo": "^9.0.0", 36 | "eslint": "^3.3.1", 37 | "eslint-config-semistandard": "^6.0.2", 38 | "eslint-config-standard": "^5.3.1", 39 | "eslint-plugin-promise": "^1.3.2", 40 | "eslint-plugin-react": "^5.2.2", 41 | "eslint-plugin-standard": "^1.3.2", 42 | "inquirer": "^1.1.2", 43 | "shelljs": "^0.7.3", 44 | "webpack": "^1.13.2" 45 | }, 46 | "dependencies": { 47 | "load-bmfont": "^1.2.3", 48 | "object-assign": "^4.1.0", 49 | "three-bmfont-text": "^2.1.0" 50 | } 51 | } 52 | --------------------------------------------------------------------------------