Socket
Socket
Sign inDemoInstall

aframe-text-sprite

Package Overview
Dependencies
34
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.3 to 2.1.0

2

index.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("aframe"),require("@seregpie/three.text-sprite")):"function"==typeof define&&define.amd?define(["aframe","@seregpie/three.text-sprite"],e):e((t=t||self).AFRAME,t.THREE.TextSprite)}(this,(function(t,e){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;var n="text-sprite";t.registerComponent(n,{schema:{align:{type:"string",default:"center"},fillStyle:{type:"string",default:"#fff"},fog:{type:"boolean",default:!1},fontFamily:{type:"string",default:"sans-serif"},fontSize:{type:"number",default:1},fontStyle:{type:"string",default:"normal"},fontVariant:{type:"string",default:"normal"},fontWeight:{type:"string",default:"normal"},lineGap:{type:"number",default:.15},opacity:{type:"number",default:1},padding:{type:"number",default:.25},strokeStyle:{type:"string",default:"#000"},strokeWidth:{type:"number",default:0},text:{type:"string",default:""},transparent:{type:"boolean",default:!0}},init:function(){var t=this.data,i=this.el,a=t.align,f=t.fillStyle,l=t.fontFamily,r=t.fontSize,o=t.fontStyle,s=t.fontVariant,p=t.fontWeight,d=t.lineGap,y=t.padding,u=t.strokeStyle,g=t.strokeWidth,h=t.text,m=new e({align:a,fillStyle:f,fontFamily:l,fontSize:r,fontStyle:o,fontVariant:s,fontWeight:p,lineGap:d,padding:y,strokeStyle:u,strokeWidth:g,text:h});i.setObject3D(n,m)},update:function(t){var e=this.data,i=this.el,a=e.align,f=e.fillStyle,l=e.fog,r=e.fontFamily,o=e.fontSize,s=e.fontStyle,p=e.fontVariant,d=e.fontWeight,y=e.lineGap,u=e.opacity,g=e.padding,h=e.strokeStyle,m=e.strokeWidth,S=e.text,c=e.transparent,b=i.getObject3D(n);Object.keys(t).length&&Object.assign(b,{align:a,fillStyle:f,fontFamily:r,fontSize:o,fontStyle:s,fontVariant:p,fontWeight:d,lineGap:y,padding:g,strokeStyle:h,strokeWidth:m,text:S});var k=b.material;Object.assign(k,{fog:l,opacity:u,transparent:c})},remove:function(){var t=this.el;t.getObject3D(n).dispose(),t.removeObject3D(n)}})}));
!function(t,e){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function n(t,e){return t(e={exports:{}},e.exports),e.exports}var i=n((function(t,n){t.exports=function(t){function e(){}function n(t){return new Promise((function(e){setTimeout(e,t)}))}function i(t){return new Promise((function(e){e(t())}))}function o(){return document.createElement("canvas")}function r(t,e,n,i,o){return[n,i,o,e+"px",t].join(" ")}function a(t,e,n,i){var o=r(t,1,e,n,i);return document.fonts.load(o)}function l(){var t=this;return i((function(){if(t.needsRedraw){var e=t.image;if(e){var n=t,o=n.align,a=n.fillStyle,l=n.fontFamily,f=n.fontSize,s=n.fontStyle,u=n.fontVariant,d=n.fontWeight,c=n.height,p=n.lineGap,h=n.lines,y=n.loadFontFace,g=n.padding,v=n.strokeStyle,m=n.strokeWidth;return i((function(){return y(l,s,u,d)})).then((function(){var n=e.getContext("2d");n.clearRect(0,0,e.width,e.height),c*=f,p*=f,g*=f,g+=(m*=f)/2;var i=r(l,f,s,u,d),y=2*g;if(h.length&&(n.font=i,y+=h.map((function(t){return n.measureText(t).width})).reduce((function(t,e){return Math.max(t,e)}))),y&&c){var S;switch(e.width=y,e.height=c,n.font=i,o){case"left":n.textAlign="left",S=g;break;case"right":n.textAlign="right",S=y-g;break;case"center":n.textAlign="center",S=y/2}n.textBaseline="top";var w=g;n.fillStyle=a,n.miterLimit=1,n.lineWidth=m,n.strokeStyle=v,h.forEach((function(t){m&&n.strokeText(t,S,w),n.fillText(t,S,w),w+=f+p}))}else e.width=e.height=1;t.needsRedraw=!1,t.needsUpdate=!0}))}}}))}var f=function(r){function f(f){void 0===f&&(f={});var s=f.align;void 0===s&&(s="center");var u=f.createCanvas;void 0===u&&(u=o);var d=f.fillStyle;void 0===d&&(d="#fff");var c=f.fontFamily;void 0===c&&(c="sans-serif");var p=f.fontSize;void 0===p&&(p=16);var h=f.fontStyle;void 0===h&&(h="normal");var y=f.fontVariant;void 0===y&&(y="normal");var g=f.fontWeight;void 0===g&&(g="normal");var v=f.lineGap;void 0===v&&(v=.15);var m=f.loadFontFace;void 0===m&&(m=a);var S=f.padding;void 0===S&&(S=.25);var w=f.strokeStyle;void 0===w&&(w="#000");var b=f.strokeWidth;void 0===b&&(b=0);var x,_,k,O,W,F=f.text;void 0===F&&(F=""),r.call(this,u(),void 0,void 0,void 0,t.LinearFilter,t.LinearFilter),Object.assign(this,{_align:s,_fillStyle:d,_fontFamily:c,_fontSize:p,_fontStyle:h,_fontVariant:y,_fontWeight:g,_lineGap:v,_padding:S,_strokeStyle:w,_strokeWidth:b,_text:F,createCanvas:u,loadFontFace:m,needsRedraw:!0,redraw:(x=l,W=Promise.resolve(),function(){for(var t=arguments,o=this,r=[],a=arguments.length;a--;)r[a]=t[a];return i((function(){return k=o,O=r,_||(_=new Promise((function(t){W=W.then((function(){return n(1)})).then((function(){try{var e=x.apply(k,O);return t(e),e}finally{_=null}})).catch(e)}))),_}))})}),this.redraw()}r&&(f.__proto__=r),f.prototype=Object.create(r&&r.prototype),f.prototype.constructor=f;var s={lines:{configurable:!0},height:{configurable:!0}};return s.lines.get=function(){var t=this.text;return t?t.split("\n"):[]},s.height.get=function(){var t=this.lineGap,e=this.lines,n=this.padding,i=2*(n+=this.strokeWidth/2);return e.length&&(i+=e.length+t*(e.length-1)),i},Object.defineProperties(f.prototype,s),f}(t.Texture),s=new t.Vector3,u=new t.Vector3,d=new t.Vector3,c={computeOptimalFontSize:function(e,n,i){var o=this.height;if(o){var r=e.getWorldPosition(u).distanceTo(i.getWorldPosition(s));if(i.isPerspectiveCamera&&(r*=2*Math.tan(t.Math.degToRad(i.fov)/2)),(i.isPerspectiveCamera||i.isOrthographicCamera)&&(r/=i.zoom),r)return Math.round(e.getWorldScale(d).y*n.domElement.offsetHeight/r/o)}return 0},isTextTexture:!0},p=f.prototype;return Object.entries({_align:"align",_fillStyle:"fillStyle",_fontFamily:"fontFamily",_fontSize:"fontSize",_fontStyle:"fontStyle",_fontVariant:"fontVariant",_fontWeight:"fontWeight",_lineGap:"lineGap",_padding:"padding",_strokeStyle:"strokeStyle",_strokeWidth:"strokeWidth",_text:"text"}).forEach((function(t){var e=t[0],n=t[1];Object.defineProperty(p,n,{get:function(){return this[e]},set:function(t){this[e]!==t&&(this[e]=t,this.needsRedraw=!0,this.redraw())}})})),Object.assign(p,c),f}(e)})),o=n((function(t,n){t.exports=function(t,e){function n(){}function i(t){return new Promise((function(e){setTimeout(e,t)}))}function o(t){return new Promise((function(e){e(t())}))}function r(){var t=this;return o((function(){var e=t,n=e.fontSize,i=e.material,o=e.scale,r=i.map,a=r.height,l=r.image;return a*=n,r.redraw().then((function(){o.set(l.width/l.height,1,1).multiplyScalar(a)}))}))}function a(e,n){var i=this.material.map;i.fontSize=t.Math.ceilPowerOfTwo(i.computeOptimalFontSize(this,e,n)),this.updateScale()}e=e&&e.hasOwnProperty("default")?e.default:e;var l=function(l){function f(f){void 0===f&&(f={});var s=f.fontSize;void 0===s&&(s=1);var u,d,c,p,h,y=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&-1===e.indexOf(i)&&(n[i]=t[i]);return n}(f,["fontSize"]);l.call(this,new t.SpriteMaterial({depthWrite:!1,map:new e(Object.assign({},y,{fontSize:0}))})),Object.assign(this,{fontSize:s,updateScale:r,updateTextureFontSize:(u=a,h=Promise.resolve(),function(){for(var t=arguments,e=this,r=[],a=arguments.length;a--;)r[a]=t[a];return o((function(){return c=e,p=r,d||(d=new Promise((function(t){h=h.then((function(){try{var e=u.apply(c,p);return t(e),e}finally{d=null}})).catch(n).then((function(){return i(1)}))}))),d}))})})}return l&&(f.__proto__=l),f.prototype=Object.create(l&&l.prototype),f.prototype.constructor=f,f.prototype.onBeforeRender=function(t,e,n){this.updateTextureFontSize(t,n)},f.prototype.dispose=function(){var t=this.material;t.map.dispose(),t.dispose()},f}(t.Sprite),f=l.prototype;return["align","fillStyle","fontFamily","fontStyle","fontVariant","fontWeight","lineGap","padding","strokeStyle","strokeWidth","text"].forEach((function(t){Object.defineProperty(f,t,{get:function(){return this.material.map[t]},set:function(e){this.material.map[t]=e,this.updateScale()}})})),Object.assign(f,{isTextSprite:!0}),l}(e,i)})),r="text-sprite";t.registerComponent(r,{init:function(){var t=this.data,e=this.el,n=t.align,i=t.fillStyle,a=t.fontFamily,l=t.fontSize,f=t.fontStyle,s=t.fontVariant,u=t.fontWeight,d=t.lineGap,c=t.padding,p=t.strokeStyle,h=t.strokeWidth,y=t.text,g=new o({align:n,fillStyle:i,fontFamily:a,fontSize:l,fontStyle:f,fontVariant:s,fontWeight:u,lineGap:d,padding:c,strokeStyle:p,strokeWidth:h,text:y});e.setObject3D(r,g)},remove:function(){var t=this.el;t.getObject3D(r).dispose(),t.removeObject3D(r)},schema:{align:{type:"string",default:"center"},fillStyle:{type:"color",default:"#fff"},fog:{type:"boolean",default:!1},fontFamily:{type:"string",default:"sans-serif"},fontSize:{type:"number",default:1},fontStyle:{type:"string",default:"normal"},fontVariant:{type:"string",default:"normal"},fontWeight:{type:"string",default:"normal"},lineGap:{type:"number",default:.15},opacity:{type:"number",default:1},padding:{type:"number",default:.25},strokeStyle:{type:"color",default:"#000"},strokeWidth:{type:"number",default:0},text:{type:"string",default:""},transparent:{type:"boolean",default:!0}},update:function(t){var e=this.data,n=this.el,i=e.align,o=e.fillStyle,a=e.fog,l=e.fontFamily,f=e.fontSize,s=e.fontStyle,u=e.fontVariant,d=e.fontWeight,c=e.lineGap,p=e.opacity,h=e.padding,y=e.strokeStyle,g=e.strokeWidth,v=e.text,m=e.transparent,S=n.getObject3D(r);Object.keys(t).length&&Object.assign(S,{align:i,fillStyle:o,fontFamily:l,fontSize:f,fontStyle:s,fontVariant:u,fontWeight:d,lineGap:c,padding:h,strokeStyle:y,strokeWidth:g,text:v});var w=S.material;Object.assign(w,{fog:a,opacity:p,transparent:m})}})}(AFRAME,THREE);
{
"name": "aframe-text-sprite",
"version": "2.0.3",
"version": "2.1.0",
"description": "A wrapper for THREE.TextSprite.",

@@ -19,13 +19,13 @@ "keywords": [

},
"dependencies": {
"@seregpie/three.text-sprite": "^1.0.0"
},
"devDependencies": {
"rollup": "^1.22.0",
"@seregpie/three.text-sprite": "^1.1.0",
"rollup": "^1.23.1",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.2"
},
"peerDependencies": {
"aframe": "^0.9.2"
"aframe": ">=0.8"
}
}

@@ -9,6 +9,2 @@ # aframe-text-sprite

## dependencies
- [THREE.TextSprite](https://github.com/SeregPie/THREE.TextSprite)
## setup

@@ -19,7 +15,6 @@

```shell
npm install SeregPie/aframe-three # to fix AFRAME.THREE issue
npm install aframe-text-sprite
npm i aframe-text-sprite
```
### es6
### ES module

@@ -34,5 +29,3 @@ ```javascript

```html
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="https://unpkg.com/@seregpie/three.text-texture"></script>
<script src="https://unpkg.com/@seregpie/three.text-sprite"></script>
<script src="https://unpkg.com/aframe/dist/aframe-master.min.js"></script>
<script src="https://unpkg.com/aframe-text-sprite"></script>

@@ -46,3 +39,3 @@ ```

| `align` | `'string'` | `'center'` |
| `fillStyle` | `'string'` | `'#fff'` |
| `fillStyle` | `'color'` | `'#fff'` |
| `fog` | `'boolean'` | `false` |

@@ -57,5 +50,5 @@ | `fontFamily` | `'string'` | `'sans-serif'` |

| `padding` | `'number'` | `0.25` |
| `strokeStyle` | `'string'` | `'#000'` |
| `strokeStyle` | `'color'` | `'#000'` |
| `strokeWidth` | `'number'` | `0` |
| `text` | `'string'` | `''` |
| `transparent` | `'boolean'` | `true` |
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc