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.8.6 to 17.9.10

4

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

@@ -31,4 +31,4 @@ "main": "THREE.TextTexture.js",

"dependencies": {
"three": "^0.86.0"
"three": "^0.87.1"
}
}

@@ -15,9 +15,9 @@ # THREE.TextTexture

## installation
## setup
Install the [package](https://www.npmjs.com/package/three.texttexture) via npm.
```
```sh
$ npm install three.texttexture
npm install three.texttexture

@@ -28,3 +28,3 @@ ```

If you prefer, you can include the code directly in your project.
Include the code in your page via a CDN.

@@ -63,4 +63,2 @@ ```html

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -80,4 +78,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -89,4 +85,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -98,4 +92,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -107,4 +99,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -116,4 +106,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -133,4 +121,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -142,4 +128,2 @@

Changing the value will redraw the canvas, if `autoRedraw` is `true`.
---

@@ -151,2 +135,6 @@

---
`.text` • `.fontStyle` • `.fontVariant` • `.fontWeight` • `.fontSize` • `.fontFamily` • `.textAlign` • `.lineHeight` • `.padding`
Changing the value will redraw the canvas, if `autoRedraw` is `true`.

@@ -153,0 +141,0 @@

@@ -278,2 +278,2 @@ (function(THREE) {

}).call(this, THREE);
})(THREE);

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

(function(a){let b=function(){let c=document.createElement('canvas').getContext('2d');return function(d,e){return c.font=d,c.measureText(e)}}();a.TextTexture=class extends a.Texture{constructor({autoRedraw:i=!0,text:j='',fontStyle:k='normal',fontVariant:l='normal',fontWeight:m='normal',fontSize:n=16,fontFamily:o='sans-serif',textAlign:p='center',lineHeight:q=1,padding:r=1/4,magFilter:s=a.LinearFilter,minFilter:t=a.LinearFilter,mapping:c,wrapS:d,wrapT:e,format:f,type:g,anisotropy:h}={}){super(document.createElement('canvas'),c,d,e,s,t,f,g,h),this.autoRedraw=i,this._text=j,this._fontStyle=k,this._fontVariant=l,this._fontWeight=m,this._fontSize=n,this._fontFamily=o,this._textAlign=p,this._lineHeight=q,this._padding=r,this.redraw()}redraw(){let c=this.image.getContext('2d');if(c.clearRect(0,0,c.canvas.width,c.canvas.height),this.textWidth&&this.textHeight){c.canvas.width=this.textWidth+2*this.paddingInPixels,c.canvas.height=this.textHeight+2*this.paddingInPixels,c.font=this.font,c.textAlign=this.textAlign,c.textBaseline='middle',c.fillStyle='white';let d=this.paddingInPixels+(()=>{switch(c.textAlign.toLowerCase()){case'left':return 0;case'right':return this.textWidth;case'center':return this.textWidth/2;}})(),e=this.paddingInPixels+this.fontSize/2;for(let f of this.lines)c.fillText(f,d,e),e+=this.lineHeightInPixels}else c.canvas.width=c.canvas.height=1;this.needsUpdate=!0}_redrawIfAuto(){this.autoRedraw&&this.redraw()}get text(){return this._text}set text(c){this._text!==c&&(this._text=c,this._lines=void 0,this._textWidth=void 0,this._textHeight=void 0,this._redrawIfAuto())}_computeLines(){return this.text?this.text.split('\n'):[]}get lines(){return void 0===this._lines&&(this._lines=this._computeLines()),this._lines}get linesCount(){return this.lines.length}get fontStyle(){return this._fontStyle}set fontStyle(c){this._fontStyle!==c&&(this._fontStyle=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}get fontVariant(){return this._fontVariant}set fontVariant(c){this._fontVariant!==c&&(this._fontVariant=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}get fontWeight(){return this._fontWeight}set fontWeight(c){this._fontWeight!==c&&(this._fontWeight=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}get fontSize(){return this._fontSize}set fontSize(c){this._fontSize!==c&&(this._fontSize=c,this._font=void 0,this._textWidth=void 0,this._textHeight=void 0,this._redrawIfAuto())}get fontFamily(){return this._fontFamily}set fontFamily(c){this._fontFamily!==c&&(this._fontFamily=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}_computeFont(){return[this.fontStyle,this.fontVariant,this.fontWeight,`${this.fontSize}px`,this.fontFamily].join(' ')}get font(){return void 0===this._font&&(this._font=this._computeFont()),this._font}get textAlign(){return this._textAlign}set textAlign(c){this._textAlign!==c&&(this._textAlign=c,this._redrawIfAuto())}get lineHeight(){return this._lineHeight}set lineHeight(c){this._lineHeight!==c&&(this._lineHeight=c,this._textHeight=void 0,this._redrawIfAuto())}get lineHeightInPixels(){return this.fontSize*this.lineHeight}_computeTextWidth(){let c=0;for(let d of this.lines)c=Math.max(b(this.font,d).width,c);return c}get textWidth(){return void 0===this._textWidth&&(this._textWidth=this._computeTextWidth()),this._textWidth}_computeTextHeight(){return this.fontSize*(this.lineHeight*(this.linesCount-1)+1)}get textHeight(){return void 0===this._textHeight&&(this._textHeight=this._computeTextHeight()),this._textHeight}get padding(){return this._padding}set padding(c){this._padding!==c&&(this._padding=c,this._redrawIfAuto())}get paddingInPixels(){return this.fontSize*this.padding}get aspect(){return this.image.width&&this.image.height?this.image.width/this.image.height:1}}}).call(this,THREE);
(function(a){let b=function(){let c=document.createElement('canvas').getContext('2d');return function(d,e){return c.font=d,c.measureText(e)}}();a.TextTexture=class extends a.Texture{constructor({autoRedraw:i=!0,text:j='',fontStyle:k='normal',fontVariant:l='normal',fontWeight:m='normal',fontSize:n=16,fontFamily:o='sans-serif',textAlign:p='center',lineHeight:q=1,padding:r=1/4,magFilter:s=a.LinearFilter,minFilter:t=a.LinearFilter,mapping:c,wrapS:d,wrapT:e,format:f,type:g,anisotropy:h}={}){super(document.createElement('canvas'),c,d,e,s,t,f,g,h),this.autoRedraw=i,this._text=j,this._fontStyle=k,this._fontVariant=l,this._fontWeight=m,this._fontSize=n,this._fontFamily=o,this._textAlign=p,this._lineHeight=q,this._padding=r,this.redraw()}redraw(){let c=this.image.getContext('2d');if(c.clearRect(0,0,c.canvas.width,c.canvas.height),this.textWidth&&this.textHeight){c.canvas.width=this.textWidth+2*this.paddingInPixels,c.canvas.height=this.textHeight+2*this.paddingInPixels,c.font=this.font,c.textAlign=this.textAlign,c.textBaseline='middle',c.fillStyle='white';let d=this.paddingInPixels+(()=>{switch(c.textAlign.toLowerCase()){case'left':return 0;case'right':return this.textWidth;case'center':return this.textWidth/2;}})(),e=this.paddingInPixels+this.fontSize/2;for(let f of this.lines)c.fillText(f,d,e),e+=this.lineHeightInPixels}else c.canvas.width=c.canvas.height=1;this.needsUpdate=!0}_redrawIfAuto(){this.autoRedraw&&this.redraw()}get text(){return this._text}set text(c){this._text!==c&&(this._text=c,this._lines=void 0,this._textWidth=void 0,this._textHeight=void 0,this._redrawIfAuto())}_computeLines(){return this.text?this.text.split('\n'):[]}get lines(){return void 0===this._lines&&(this._lines=this._computeLines()),this._lines}get linesCount(){return this.lines.length}get fontStyle(){return this._fontStyle}set fontStyle(c){this._fontStyle!==c&&(this._fontStyle=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}get fontVariant(){return this._fontVariant}set fontVariant(c){this._fontVariant!==c&&(this._fontVariant=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}get fontWeight(){return this._fontWeight}set fontWeight(c){this._fontWeight!==c&&(this._fontWeight=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}get fontSize(){return this._fontSize}set fontSize(c){this._fontSize!==c&&(this._fontSize=c,this._font=void 0,this._textWidth=void 0,this._textHeight=void 0,this._redrawIfAuto())}get fontFamily(){return this._fontFamily}set fontFamily(c){this._fontFamily!==c&&(this._fontFamily=c,this._font=void 0,this._textWidth=void 0,this._redrawIfAuto())}_computeFont(){return[this.fontStyle,this.fontVariant,this.fontWeight,`${this.fontSize}px`,this.fontFamily].join(' ')}get font(){return void 0===this._font&&(this._font=this._computeFont()),this._font}get textAlign(){return this._textAlign}set textAlign(c){this._textAlign!==c&&(this._textAlign=c,this._redrawIfAuto())}get lineHeight(){return this._lineHeight}set lineHeight(c){this._lineHeight!==c&&(this._lineHeight=c,this._textHeight=void 0,this._redrawIfAuto())}get lineHeightInPixels(){return this.fontSize*this.lineHeight}_computeTextWidth(){let c=0;for(let d of this.lines)c=Math.max(b(this.font,d).width,c);return c}get textWidth(){return void 0===this._textWidth&&(this._textWidth=this._computeTextWidth()),this._textWidth}_computeTextHeight(){return this.fontSize*(this.lineHeight*(this.linesCount-1)+1)}get textHeight(){return void 0===this._textHeight&&(this._textHeight=this._computeTextHeight()),this._textHeight}get padding(){return this._padding}set padding(c){this._padding!==c&&(this._padding=c,this._redrawIfAuto())}get paddingInPixels(){return this.fontSize*this.padding}get aspect(){return this.image.width&&this.image.height?this.image.width/this.image.height:1}}})(THREE);
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