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.1.0 to 2.1.1

2

index.js

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

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

@@ -25,3 +25,4 @@ "keywords": [

"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.2"
"rollup-plugin-terser": "^5.1.2",
"three": "file:THREE"
},

@@ -28,0 +29,0 @@ "peerDependencies": {

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