Socket
Socket
Sign inDemoInstall

three.texttexture

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three.texttexture - npm Package Compare versions

Comparing version 17.10.21 to 17.10.22

6

package.json
{
"name": "three.texttexture",
"version": "17.10.21",
"version": "17.10.22",
"description": "A texture for writing text on its canvas.",

@@ -41,3 +41,3 @@ "main": "THREE.TextTexture.js",

"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-env": "^1.6.1",
"babel-runtime": "^6.26.0",

@@ -48,5 +48,5 @@ "eslint": "^4.9.0",

"rollup-plugin-babel-minify": "^3.1.2",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-commonjs": "^8.2.4",
"rollup-plugin-node-resolve": "^3.0.0"
}
}

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

(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b(require('three')):'function'==typeof define&&define.amd?define(['three'],b):(a.THREE=a.THREE||{},a.THREE.TextTexture=b(a.THREE))})(this,function(a){'use strict';function b(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function c(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function d(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}a=a&&a.hasOwnProperty('default')?a['default']:a;var e=document.createElement('canvas').getContext('2d'),f=function(a,b){return e.font=a,e.measureText(b)},g=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=function(e){function h(){var d=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=d.autoRedraw,f=d.text,g=void 0===f?'':f,i=d.fontStyle,j=void 0===i?'normal':i,k=d.fontVariant,l=void 0===k?'normal':k,m=d.fontWeight,n=void 0===m?'normal':m,o=d.fontSize,p=void 0===o?16:o,q=d.fontFamily,r=void 0===q?'sans-serif':q,s=d.textAlign,t=void 0===s?'center':s,u=d.lineHeight,v=void 0===u?1:u,w=d.padding,x=void 0===w?1/4:w,y=d.magFilter,z=void 0===y?a.LinearFilter:y,A=d.minFilter,B=void 0===A?a.LinearFilter:A,C=d.mapping,D=d.wrapS,E=d.wrapT,F=d.format,G=d.type,H=d.anisotropy;b(this,h);var I=c(this,(h.__proto__||Object.getPrototypeOf(h)).call(this,document.createElement('canvas'),C,D,E,z,B,F,G,H));return I.autoRedraw=void 0===e||e,I._text=g,I._fontStyle=j,I._fontVariant=l,I._fontWeight=n,I._fontSize=p,I._fontFamily=r,I._textAlign=t,I._lineHeight=v,I._padding=x,I.redraw(),I}return d(h,e),g(h,[{key:'redraw',value:function(){var a=this.image.getContext('2d');if(a.clearRect(0,0,a.canvas.width,a.canvas.height),this.textWidthInPixels&&this.textHeightInPixels){a.canvas.width=this.imageWidthInPixels,a.canvas.height=this.imageHeightInPixels,a.font=this.font,a.textBaseline='middle',a.fillStyle='white';var b;switch(this.textAlign){case'left':a.textAlign='left',b=this.paddingInPixels;break;case'right':a.textAlign='right',b=this.paddingInPixels+this.textWidthInPixels;break;case'center':a.textAlign='center',b=this.paddingInPixels+this.textWidthInPixels/2;}var c,d=this.paddingInPixels+this.fontSize/2,e=!0,f=!1;try{for(var g,h,i=this.lines[Symbol.iterator]();!(e=(g=i.next()).done);e=!0)h=g.value,a.fillText(h,b,d),d+=this.lineHeightInPixels}catch(a){f=!0,c=a}finally{try{!e&&i.return&&i.return()}finally{if(f)throw c}}}else a.canvas.width=a.canvas.height=1;this.needsUpdate=!0}},{key:'_redrawIfAuto',value:function(){this.autoRedraw&&this.redraw()}},{key:'_computeLines',value:function(){return this.text?this.text.split('\n'):[]}},{key:'_computeFont',value:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize+'px',this.fontFamily].join(' ')}},{key:'_computeTextWidthInPixels',value:function(){var a,b=0,c=!0,d=!1;try{for(var e,g,h=this.lines[Symbol.iterator]();!(c=(e=h.next()).done);c=!0)g=e.value,b=Math.max(f(this.font,g).width,b)}catch(b){d=!0,a=b}finally{try{!c&&h.return&&h.return()}finally{if(d)throw a}}return b}},{key:'_computeTextHeight',value:function(){return this.lineHeight*(this.linesCount-1)+1}},{key:'text',get:function(){return this._text},set:function(a){this._text!==a&&(this._text=a,this._lines=void 0,this._textWidth=void 0,this._textHeight=void 0,this._redrawIfAuto())}},{key:'lines',get:function(){return void 0===this._lines&&(this._lines=this._computeLines()),this._lines}},{key:'linesCount',get:function(){return this.lines.length}},{key:'fontStyle',get:function(){return this._fontStyle},set:function(a){this._fontStyle!==a&&(this._fontStyle=a,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}},{key:'fontVariant',get:function(){return this._fontVariant},set:function(a){this._fontVariant!==a&&(this._fontVariant=a,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}},{key:'fontWeight',get:function(){return this._fontWeight},set:function(a){this._fontWeight!==a&&(this._fontWeight=a,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}},{key:'fontSize',get:function(){return this._fontSize},set:function(a){this._fontSize!==a&&(this._fontSize=a,this._font=void 0,this._textWidth=void 0,this._textHeight=void 0,this._redrawIfAuto())}},{key:'fontFamily',get:function(){return this._fontFamily},set:function(a){this._fontFamily!==a&&(this._fontFamily=a,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}},{key:'font',get:function(){return void 0===this._font&&(this._font=this._computeFont()),this._font}},{key:'textAlign',get:function(){return this._textAlign},set:function(a){this._textAlign!==a&&(this._textAlign=a,this._redrawIfAuto())}},{key:'lineHeight',get:function(){return this._lineHeight},set:function(a){this._lineHeight!==a&&(this._lineHeight=a,this._textHeight=void 0,this._redrawIfAuto())}},{key:'lineHeightInPixels',get:function(){return this.fontSize*this.lineHeight}},{key:'textWidthInPixels',get:function(){return void 0===this._textWidth&&(this._textWidth=this._computeTextWidthInPixels()),this._textWidth}},{key:'textHeight',get:function(){return void 0===this._textHeight&&(this._textHeight=this._computeTextHeight()),this._textHeight}},{key:'textHeightInPixels',get:function(){return this.fontSize*this.textHeight}},{key:'padding',get:function(){return this._padding},set:function(a){this._padding!==a&&(this._padding=a,this._redrawIfAuto())}},{key:'paddingInPixels',get:function(){return this.fontSize*this.padding}},{key:'imageWidthInPixels',get:function(){return this.textWidthInPixels+2*this.paddingInPixels}},{key:'imageHeight',get:function(){return this.textHeight+2*this.padding}},{key:'imageHeightInPixels',get:function(){return this.textHeightInPixels+2*this.paddingInPixels}},{key:'aspect',get:function(){return this.image.width&&this.image.height?this.image.width/this.image.height:1}}]),h}(a.Texture);return Object.assign(a,{TextTexture:h}),h});
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b(require('three')):'function'==typeof define&&define.amd?define(['three'],b):(a.THREE=a.THREE||{},a.THREE.TextTexture=b(a.THREE))})(this,function(a){'use strict';function b(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function c(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function d(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}a=a&&a.hasOwnProperty('default')?a['default']:a;var e=document.createElement('canvas').getContext('2d'),f=function(a,b){return e.font=a,e.measureText(b)},g=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=function(e){function h(){var d=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=d.autoRedraw,f=d.text,g=void 0===f?'':f,i=d.fontStyle,j=void 0===i?'normal':i,k=d.fontVariant,l=void 0===k?'normal':k,m=d.fontWeight,n=void 0===m?'normal':m,o=d.fontSize,p=void 0===o?16:o,q=d.fontFamily,r=void 0===q?'sans-serif':q,s=d.textAlign,t=void 0===s?'center':s,u=d.lineHeight,v=void 0===u?1:u,w=d.padding,x=void 0===w?1/4:w,y=d.magFilter,z=void 0===y?a.LinearFilter:y,A=d.minFilter,B=void 0===A?a.LinearFilter:A,C=d.mapping,D=d.wrapS,E=d.wrapT,F=d.format,G=d.type,H=d.anisotropy;b(this,h);var I=c(this,(h.__proto__||Object.getPrototypeOf(h)).call(this,document.createElement('canvas'),C,D,E,z,B,F,G,H));return I.autoRedraw=void 0===e||e,I._text=g,I._fontStyle=j,I._fontVariant=l,I._fontWeight=n,I._fontSize=p,I._fontFamily=r,I._textAlign=t,I._lineHeight=v,I._padding=x,I.redraw(),I}return d(h,e),g(h,[{key:'redraw',value:function(){var a=this.image.getContext('2d');if(a.clearRect(0,0,a.canvas.width,a.canvas.height),this.textBoxWidthInPixels&&this.textBoxHeightInPixels){a.canvas.width=this.paddingBoxWidthInPixels,a.canvas.height=this.paddingBoxHeightInPixels,a.font=this.font,a.textBaseline='middle',a.fillStyle='white';var b;switch(this.textAlign){case'left':a.textAlign='left',b=this.paddingInPixels;break;case'right':a.textAlign='right',b=this.paddingInPixels+this.textBoxWidthInPixels;break;case'center':a.textAlign='center',b=this.paddingInPixels+this.textBoxWidthInPixels/2;}var c,d=this.paddingInPixels+this.fontSize/2,e=!0,f=!1;try{for(var g,h,i=this.lines[Symbol.iterator]();!(e=(g=i.next()).done);e=!0)h=g.value,a.fillText(h,b,d),d+=this.lineHeightInPixels}catch(a){f=!0,c=a}finally{try{!e&&i.return&&i.return()}finally{if(f)throw c}}}else a.canvas.width=a.canvas.height=1;this.needsUpdate=!0}},{key:'_redrawIfAuto',value:function(){this.autoRedraw&&this.redraw()}},{key:'_computeLines',value:function(){return this.text?this.text.split('\n'):[]}},{key:'_computeFont',value:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize+'px',this.fontFamily].join(' ')}},{key:'_computeTextWidthInPixels',value:function(){var a,b=0,c=!0,d=!1;try{for(var e,g,h=this.lines[Symbol.iterator]();!(c=(e=h.next()).done);c=!0)g=e.value,b=Math.max(f(this.font,g).width,b)}catch(b){d=!0,a=b}finally{try{!c&&h.return&&h.return()}finally{if(d)throw a}}return b}},{key:'text',get:function(){return this._text},set:function(a){this._text!==a&&(this._text=a,this._lines=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())}},{key:'lines',get:function(){return void 0===this._lines&&(this._lines=this._computeLines()),this._lines}},{key:'linesCount',get:function(){return this.lines.length}},{key:'fontStyle',get:function(){return this._fontStyle},set:function(a){this._fontStyle!==a&&(this._fontStyle=a,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())}},{key:'fontVariant',get:function(){return this._fontVariant},set:function(a){this._fontVariant!==a&&(this._fontVariant=a,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())}},{key:'fontWeight',get:function(){return this._fontWeight},set:function(a){this._fontWeight!==a&&(this._fontWeight=a,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())}},{key:'fontSize',get:function(){return this._fontSize},set:function(a){this._fontSize!==a&&(this._fontSize=a,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())}},{key:'fontFamily',get:function(){return this._fontFamily},set:function(a){this._fontFamily!==a&&(this._fontFamily=a,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())}},{key:'font',get:function(){return void 0===this._font&&(this._font=this._computeFont()),this._font}},{key:'textAlign',get:function(){return this._textAlign},set:function(a){this._textAlign!==a&&(this._textAlign=a,this._redrawIfAuto())}},{key:'lineHeight',get:function(){return this._lineHeight},set:function(a){this._lineHeight!==a&&(this._lineHeight=a,this._redrawIfAuto())}},{key:'lineHeightInPixels',get:function(){return this.fontSize*this.lineHeight}},{key:'textBoxWidthInPixels',get:function(){return void 0===this._textBoxWidth&&(this._textBoxWidth=this._computeTextWidthInPixels()),this._textBoxWidth}},{key:'textBoxHeight',get:function(){return this.lineHeight*(this.linesCount-1)+1}},{key:'textBoxHeightInPixels',get:function(){return this.fontSize*this.textBoxHeight}},{key:'padding',get:function(){return this._padding},set:function(a){this._padding!==a&&(this._padding=a,this._redrawIfAuto())}},{key:'paddingInPixels',get:function(){return this.fontSize*this.padding}},{key:'paddingBoxWidthInPixels',get:function(){return this.textBoxWidthInPixels+2*this.paddingInPixels}},{key:'paddingBoxHeight',get:function(){return this.textBoxHeight+2*this.padding}},{key:'paddingBoxHeightInPixels',get:function(){return this.textBoxHeightInPixels+2*this.paddingInPixels}},{key:'aspect',get:function(){return this.image.width&&this.image.height?this.image.width/this.image.height:1}}]),h}(a.Texture);return Object.assign(a,{TextTexture:h}),h});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc