New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

troika-three-text

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

troika-three-text - npm Package Compare versions

Comparing version 0.34.0-textoutline.6 to 0.34.0-textoutline.8

4

package.json
{
"name": "troika-three-text",
"version": "0.34.0-textoutline.6+ecfee22",
"version": "0.34.0-textoutline.8+f398aa3",
"description": "SDF-based text rendering for Three.js",

@@ -28,3 +28,3 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>",

},
"gitHead": "ecfee226bb6c33b169fddb27ecee13853c8e2a1c"
"gitHead": "f398aa3ee5376d012c63cb9206acb6efe654aefe"
}

@@ -178,9 +178,9 @@ import { Color, DataTexture, LinearFilter, LuminanceFormat } from 'three'

const cols = texImg.width / sdfGlyphSize
const baseStartIndex = texImg.width * sdfGlyphSize * Math.floor(atlasIndex / cols) //full rows
+ (atlasIndex % cols) * sdfGlyphSize //partial row
for (let y = 0; y < sdfGlyphSize; y++) {
const srcStartIndex = y * sdfGlyphSize
const tgtStartIndex = texImg.width * sdfGlyphSize * Math.floor(atlasIndex / cols) //full rows
+ (atlasIndex % cols) * sdfGlyphSize //partial row
+ (y * texImg.width) //row within glyph
const rowStartIndex = baseStartIndex + (y * texImg.width)
for (let x = 0; x < sdfGlyphSize; x++) {
texImg.data[tgtStartIndex + x] = textureData[srcStartIndex + x]
texImg.data[rowStartIndex + x] = textureData[srcStartIndex + x]
}

@@ -187,0 +187,0 @@ }

@@ -16,4 +16,4 @@ import { createDerivedMaterial, voidMainRegExp } from 'troika-three-utils'

attribute vec3 aTroikaGlyphColor;
varying float vTroikaGlyphIndex;
varying vec2 vTroikaGlyphUV;
varying vec4 vTroikaTextureUVBounds;
varying vec3 vTroikaGlyphColor;

@@ -40,5 +40,16 @@ varying vec2 vTroikaGlyphDimensions;

vTroikaGlyphIndex = aTroikaGlyphIndex;
vTroikaGlyphUV = clippedXY.xy;
vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);
${''/* NOTE: it seems important to calculate the glyph's bounding texture UVs here in the
vertex shader, rather than in the fragment shader, as the latter gives strange artifacts
on some glyphs (those in the leftmost texture column) on some systems. The exact reason
isn't understood but doing this here, then mix()-ing in the fragment shader, seems to work. */}
float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;
vec2 txUvPerGlyph = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;
vec2 txStartUV = txUvPerGlyph * vec2(
mod(aTroikaGlyphIndex, txCols),
floor(aTroikaGlyphIndex / txCols)
);
vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerGlyph);
`

@@ -55,3 +66,3 @@

varying vec2 vTroikaGlyphUV;
varying float vTroikaGlyphIndex;
varying vec4 vTroikaTextureUVBounds;
varying vec2 vTroikaGlyphDimensions;

@@ -71,8 +82,4 @@

float troikaGlyphUvToSdfValue(vec2 uv) {
float cols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;
vec2 textureUV = vec2(
mod(vTroikaGlyphIndex, cols) + uv.x,
floor(vTroikaGlyphIndex / cols) + uv.y
) * uTroikaSDFGlyphSize / uTroikaSDFTextureSize;
float troikaGlyphUvToSdfValue(vec2 glyphUV) {
vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);
return texture2D(uTroikaSDFTexture, textureUV).r;

@@ -79,0 +86,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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