Socket
Socket
Sign inDemoInstall

three.texttexture

Package Overview
Dependencies
1
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 17.10.22 to 17.11.5

17

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

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

"dev": "rollup -c -w",
"prepublish": "npm run build"
"prepublishOnly": "npm run build"
},

@@ -39,14 +39,7 @@ "repository": {

"devDependencies": {
"babel-core": "^6.26.0",
"babel-minify": "^0.2.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-runtime": "^6.26.0",
"eslint": "^4.9.0",
"eslint": "^4.10.0",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-babel-minify": "^3.1.2",
"rollup-plugin-commonjs": "^8.2.4",
"rollup-plugin-node-resolve": "^3.0.0"
"rollup-plugin-buble": "^0.16.0",
"rollup-plugin-uglify": "^2.0.1"
}
}

@@ -36,2 +36,10 @@ # THREE.TextTexture

Include [polyfills](https://polyfill.io/) to support older browsers.
```html
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
```
## members

@@ -41,3 +49,3 @@

```javascript
```js

@@ -61,3 +69,3 @@ let texture = new THREE.TextTexture({

A string for the text to write on the canvas.
The text to write on the canvas.

@@ -70,3 +78,3 @@ ---

An array of the text split by the new line character.
The text split by the new line character.

@@ -77,3 +85,3 @@ ---

A string for the font style. Possible values are `'normal'`, `'italic'` and `'oblique'`.
The font style of the text. Possible values are `'normal'`, `'italic'` and `'oblique'`.

@@ -84,3 +92,3 @@ ---

A string for the font variant. Possible values are `'normal'` and `'small-caps'`.
The font variant of the text. Possible values are `'normal'` and `'small-caps'`.

@@ -91,3 +99,3 @@ ---

A string for the font weight. Possible values are `'normal'`, `'bold'`, `'bolder'`, `'lighter'` and `'100'` to `'900'`.
The font weight of the text. Possible values are `'normal'`, `'bold'`, `'bolder'`, `'lighter'` and `'100'` to `'900'`.

@@ -98,3 +106,3 @@ ---

A number for the font size in pixels.
The font size of the text in pixels.

@@ -105,3 +113,3 @@ ---

A string for the font family.
The font family of the text.

@@ -114,3 +122,3 @@ ---

A string for the combined font properties.
The combined font properties.

@@ -121,15 +129,15 @@ ---

A string for the horizontal alignment of the text lines. Possible values are `'center'`, `'left'` and `'right'`.
The horizontal alignment of the text lines. Possible values are `'center'`, `'left'` and `'right'`.
---
`.lineHeight = 1`
`.lineHeight = 1.15`
A number for the height of a text line. The pixels are calculated relative to the font size.
The height of a text line. The pixels are calculated relative to the font size.
---
`.padding = 1/4`
`.padding = 0.25`
A number for the space around the text of the canvas. The pixels are calculated relative to the font size.
The space around the text inside the canvas. The pixels are calculated relative to the font size.

@@ -164,3 +172,3 @@ ---

```javascript
```js

@@ -167,0 +175,0 @@ texture.autoRedraw = false;

@@ -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.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});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("three")):"function"==typeof define&&define.amd?define(["three"],i):i(t.THREE)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var i=document.createElement("canvas").getContext("2d"),e=function(e){function n(i){void 0===i&&(i={});var n=i.autoRedraw;void 0===n&&(n=!0);var o=i.text;void 0===o&&(o="");var h=i.fontStyle;void 0===h&&(h="normal");var s=i.fontVariant;void 0===s&&(s="normal");var r=i.fontWeight;void 0===r&&(r="normal");var a=i.fontSize;void 0===a&&(a=16);var f=i.fontFamily;void 0===f&&(f="sans-serif");var d=i.textAlign;void 0===d&&(d="center");var l=i.lineHeight;void 0===l&&(l=1.15);var g=i.padding;void 0===g&&(g=.25);var u=i.magFilter;void 0===u&&(u=t.LinearFilter);var x=i.minFilter;void 0===x&&(x=t.LinearFilter);var c=i.mapping,_=i.wrapS,p=i.wrapT,v=i.format,I=i.type,m=i.anisotropy;e.call(this,document.createElement("canvas"),c,_,p,u,x,v,I,m),this.autoRedraw=n,this._text=o,this._fontStyle=h,this._fontVariant=s,this._fontWeight=r,this._fontSize=a,this._fontFamily=f,this._textAlign=d,this._lineHeight=l,this._padding=g,this.redraw()}e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n;var o={text:{configurable:!0},lines:{configurable:!0},linesCount:{configurable:!0},fontStyle:{configurable:!0},fontVariant:{configurable:!0},fontWeight:{configurable:!0},fontSize:{configurable:!0},fontFamily:{configurable:!0},font:{configurable:!0},textAlign:{configurable:!0},lineHeight:{configurable:!0},lineHeightInPixels:{configurable:!0},textBoxWidthInPixels:{configurable:!0},textBoxHeight:{configurable:!0},textBoxHeightInPixels:{configurable:!0},padding:{configurable:!0},paddingInPixels:{configurable:!0},paddingBoxWidthInPixels:{configurable:!0},paddingBoxHeight:{configurable:!0},paddingBoxHeightInPixels:{configurable:!0},aspect:{configurable:!0}};return n.prototype.redraw=function(){var t=this,i=this.image.getContext("2d");if(i.clearRect(0,0,i.canvas.width,i.canvas.height),this.textBoxWidthInPixels&&this.textBoxHeightInPixels){i.canvas.width=this.paddingBoxWidthInPixels,i.canvas.height=this.paddingBoxHeightInPixels,i.font=this.font,i.textBaseline="middle",i.fillStyle="white";var e;switch(this.textAlign){case"left":i.textAlign="left",e=this.paddingInPixels;break;case"right":i.textAlign="right",e=this.paddingInPixels+this.textBoxWidthInPixels;break;case"center":i.textAlign="center",e=this.paddingInPixels+this.textBoxWidthInPixels/2}var n=this.paddingInPixels+this.fontSize/2;this.lines.forEach(function(o){i.fillText(o,e,n),n+=t.lineHeightInPixels})}else i.canvas.width=i.canvas.height=1;this.needsUpdate=!0},n.prototype._redrawIfAuto=function(){this.autoRedraw&&this.redraw()},o.text.get=function(){return this._text},o.text.set=function(t){this._text!==t&&(this._text=t,this._lines=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())},n.prototype._computeLines=function(){return this.text?this.text.split("\n"):[]},o.lines.get=function(){return void 0===this._lines&&(this._lines=this._computeLines()),this._lines},o.linesCount.get=function(){return this.lines.length},o.fontStyle.get=function(){return this._fontStyle},o.fontStyle.set=function(t){this._fontStyle!==t&&(this._fontStyle=t,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())},o.fontVariant.get=function(){return this._fontVariant},o.fontVariant.set=function(t){this._fontVariant!==t&&(this._fontVariant=t,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())},o.fontWeight.get=function(){return this._fontWeight},o.fontWeight.set=function(t){this._fontWeight!==t&&(this._fontWeight=t,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())},o.fontSize.get=function(){return this._fontSize},o.fontSize.set=function(t){this._fontSize!==t&&(this._fontSize=t,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())},o.fontFamily.get=function(){return this._fontFamily},o.fontFamily.set=function(t){this._fontFamily!==t&&(this._fontFamily=t,this._font=void 0,this._textBoxWidth=void 0,this._redrawIfAuto())},n.prototype._computeFont=function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize+"px",this.fontFamily].join(" ")},o.font.get=function(){return void 0===this._font&&(this._font=this._computeFont()),this._font},o.textAlign.get=function(){return this._textAlign},o.textAlign.set=function(t){this._textAlign!==t&&(this._textAlign=t,this._redrawIfAuto())},o.lineHeight.get=function(){return this._lineHeight},o.lineHeight.set=function(t){this._lineHeight!==t&&(this._lineHeight=t,this._redrawIfAuto())},o.lineHeightInPixels.get=function(){return this.fontSize*this.lineHeight},n.prototype._computeTextWidthInPixels=function(){var t=this;return this.lines.length?function(t,i){if(t.length>0)return t.map(i).reduce(function(t,i){return Math.max(t,i)})}(this.lines,function(e){return function(t,e){return i.font=t,i.measureText(e)}(t.font,e).width}):0},o.textBoxWidthInPixels.get=function(){return void 0===this._textBoxWidth&&(this._textBoxWidth=this._computeTextWidthInPixels()),this._textBoxWidth},o.textBoxHeight.get=function(){return this.lineHeight*(this.linesCount-1)+1},o.textBoxHeightInPixels.get=function(){return this.fontSize*this.textBoxHeight},o.padding.get=function(){return this._padding},o.padding.set=function(t){this._padding!==t&&(this._padding=t,this._redrawIfAuto())},o.paddingInPixels.get=function(){return this.fontSize*this.padding},o.paddingBoxWidthInPixels.get=function(){return this.textBoxWidthInPixels+2*this.paddingInPixels},o.paddingBoxHeight.get=function(){return this.textBoxHeight+2*this.padding},o.paddingBoxHeightInPixels.get=function(){return this.textBoxHeightInPixels+2*this.paddingInPixels},o.aspect.get=function(){return this.image.width&&this.image.height?this.image.width/this.image.height:1},Object.defineProperties(n.prototype,o),n}(t.Texture);t.TextTexture=e});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc