Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

troika-3d-text

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

troika-3d-text - npm Package Compare versions

Comparing version 0.38.0 to 0.38.1

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [0.38.1](https://github.com/protectwise/troika/compare/v0.38.0...v0.38.1) (2021-02-03)
### Bug Fixes
* update to support up to Three r125 ([4edff04](https://github.com/protectwise/troika/commit/4edff042d13dec49377d18baf4f958de285a3f2a))
# [0.38.0](https://github.com/protectwise/troika/compare/v0.37.0...v0.38.0) (2021-01-24)

@@ -8,0 +19,0 @@

5

dist/troika-3d-text.esm.js

@@ -5,2 +5,3 @@ import { getSelectionRects, getCaretAtPoint, Text } from 'troika-three-text';

import { Vector4, Color, MeshBasicMaterial, Mesh, BoxBufferGeometry, Matrix4, Plane, Vector3 } from 'three';
import { invertMatrix4 } from 'troika-three-utils';

@@ -101,3 +102,3 @@ const tempVec4 = new Vector4();

if (textRenderInfo) {
const localPoint = e.intersection.point.clone().applyMatrix4(tempMat4.getInverse(textMesh.matrixWorld));
const localPoint = e.intersection.point.clone().applyMatrix4(invertMatrix4(textMesh.matrixWorld, tempMat4));
const caret = getCaretAtPoint(textRenderInfo, localPoint.x, localPoint.y);

@@ -117,3 +118,3 @@ if (caret) {

// Raycast to an infinite plane so dragging outside the text bounds will work
const ray = e.ray.clone().applyMatrix4(tempMat4.getInverse(textMesh.matrixWorld));
const ray = e.ray.clone().applyMatrix4(invertMatrix4(textMesh.matrixWorld, tempMat4));
const localPoint = ray.intersectPlane(tempPlane.setComponents(0, 0, 1, 0), tempVec3);

@@ -120,0 +121,0 @@ if (localPoint) {

12

dist/troika-3d-text.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('troika-three-text'), require('troika-3d'), require('three')) :
typeof define === 'function' && define.amd ? define(['exports', 'troika-three-text', 'troika-3d', 'three'], factory) :
(global = global || self, factory(global.troika_3d_text = {}, global.troika_three_text, global.troika_3d, global.THREE));
}(this, (function (exports, troikaThreeText, troika3d, three) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('troika-three-text'), require('troika-3d'), require('three'), require('troika-three-utils')) :
typeof define === 'function' && define.amd ? define(['exports', 'troika-three-text', 'troika-3d', 'three', 'troika-three-utils'], factory) :
(global = global || self, factory(global.troika_3d_text = {}, global.troika_three_text, global.troika_3d, global.THREE, global.troika_three_utils));
}(this, (function (exports, troikaThreeText, troika3d, three, troikaThreeUtils) { 'use strict';

@@ -111,3 +111,3 @@ var tempVec4 = new three.Vector4();

if (textRenderInfo) {
var localPoint = e.intersection.point.clone().applyMatrix4(tempMat4.getInverse(textMesh.matrixWorld));
var localPoint = e.intersection.point.clone().applyMatrix4(troikaThreeUtils.invertMatrix4(textMesh.matrixWorld, tempMat4));
var caret = troikaThreeText.getCaretAtPoint(textRenderInfo, localPoint.x, localPoint.y);

@@ -127,3 +127,3 @@ if (caret) {

// Raycast to an infinite plane so dragging outside the text bounds will work
var ray = e.ray.clone().applyMatrix4(tempMat4.getInverse(textMesh.matrixWorld));
var ray = e.ray.clone().applyMatrix4(troikaThreeUtils.invertMatrix4(textMesh.matrixWorld, tempMat4));
var localPoint = ray.intersectPlane(tempPlane.setComponents(0, 0, 1, 0), tempVec3);

@@ -130,0 +130,0 @@ if (localPoint) {

@@ -1,13 +0,14 @@

'use strict';(function(b,f){"object"===typeof exports&&"undefined"!==typeof module?f(exports,require("troika-three-text"),require("troika-3d"),require("three")):"function"===typeof define&&define.amd?define(["exports","troika-three-text","troika-3d","three"],f):(b=b||self,f(b.troika_3d_text={},b.troika_three_text,b.troika_3d,b.THREE))})(this,function(b,f,k,g){function m(){var c=k.createDerivedMaterial(new g.MeshBasicMaterial({transparent:!0,opacity:.3,depthWrite:!1}),{uniforms:{rect:{value:new g.Vector4}},
vertexDefs:"uniform vec4 rect;",vertexTransform:"\n position.x = position.x < 0.0 ? rect.x : rect.z;\n position.y = position.y < 0.0 ? rect.w : rect.y;\n "});c.instanceUniforms=["rect","diffuse"];var a=new g.Mesh((new g.BoxBufferGeometry).translate(0,0,-.5),c);return(m=function(){return a})()}var n=new g.Vector4,t=function(c){function a(a){c.call(this,a);this.instancedThreeObject=m();this._color=new g.Color;this._rect=new g.Vector4}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=
a;a.prototype.afterUpdate=function(){var a=this.top,l=this.right,h=this.bottom,e=this.left,b=this.color;this._color.equals(b)||this.setInstanceUniform("diffuse",this._color=new g.Color(b));this._rect.equals(n.set(e,a,l,h))||this.setInstanceUniform("rect",n.clone());c.prototype.afterUpdate.call(this)};a.prototype.getBoundingSphere=function(){return null};return a}(k.Instanceable3DFacade),p=new g.Matrix4,u=new g.Plane,v=new g.Vector3,q=Object.freeze([-Infinity,-Infinity,Infinity,Infinity]),w=function(c){function a(a,
b){var e=this;c.call(this,a);var h=a.threeObject;this.rangeColor=52479;this.clipRect=q;this.template={key:function(a,b){return"rect"+b},facade:t,top:function(a){return Math.min(e.clipRect[3],Math.max(e.clipRect[1],a.top))},right:function(a){return Math.min(e.clipRect[2],Math.max(e.clipRect[0],a.right))},bottom:function(a){return Math.min(e.clipRect[3],Math.max(e.clipRect[1],a.bottom))},left:function(a){return Math.min(e.clipRect[2],Math.max(e.clipRect[0],a.left))},z:function(a){return.25*(a.top-a.bottom)/
2},scaleZ:function(a){return.25*(a.top-a.bottom)},color:function(a){return e.rangeColor},visible:function(a){var b=e.clipRect;return a.right>b[0]&&a.top>b[1]&&a.left<b[2]&&a.bottom<b[3]},renderOrder:function(a){return e.renderOrder||0}};var d=function(c){var d=e.textRenderInfo;if(d){var r=c.intersection.point.clone().applyMatrix4(p.getInverse(h.matrixWorld));if(d=f.getCaretAtPoint(d,r.x,r.y))b(d.charIndex,d.charIndex),a.addEventListener("drag",l),a.addEventListener("dragend",g);c.preventDefault()}},
l=function(a){var c=h.textRenderInfo;if(a.ray&&c){var d=a.ray.clone().applyMatrix4(p.getInverse(h.matrixWorld)).intersectPlane(u.setComponents(0,0,1,0),v);d&&(c=f.getCaretAtPoint(c,d.x,d.y))&&b(e.selectionStart,c.charIndex);a.preventDefault()}},g=function(b){a.removeEventListener("drag",l);a.removeEventListener("dragend",g)};a.addEventListener("dragstart",d);a.addEventListener("mousedown",d);this._cleanupEvents=function(){g();a.removeEventListener("dragstart",d);a.removeEventListener("mousedown",
d)}}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;var b={clipRect:{configurable:!0}};a.prototype.afterUpdate=function(){this.data=f.getSelectionRects(this.textRenderInfo,this.selectionStart,this.selectionEnd);c.prototype.afterUpdate.call(this)};b.clipRect.set=function(a){this._clipRect=a&&Array.isArray(a)&&4===a.length?a:q};b.clipRect.get=function(){return this._clipRect};a.prototype.destructor=function(){this._cleanupEvents();c.prototype.destructor.call(this)};
Object.defineProperties(a.prototype,b);return a}(k.ListFacade),x="text anchorX anchorY font fontSize letterSpacing lineHeight maxWidth overflowWrap textAlign textIndent whiteSpace material color colorRanges fillOpacity outlineOpacity outlineColor outlineWidth outlineOffsetX outlineOffsetY outlineBlur strokeColor strokeWidth strokeOpacity depthOffset clipRect orientation glyphGeometryDetail sdfGlyphSize debugSDF".split(" "),y=function(b){function a(a){var c=this,e=new f.Text;e.geometry.boundingSphere.version=
0;b.call(this,a,e);this.selectable=!1;this.selectionStart=this.selectionEnd=-1;this.onSyncComplete=this.onSyncStart=null;e.addEventListener("syncstart",function(a){c.notifyWorld("text3DSyncStart");if(c.onSyncStart)c.onSyncStart()});e.addEventListener("synccomplete",function(a){if(!c.isDestroying&&(e.geometry.boundingSphere.version++,c.afterUpdate(),c.notifyWorld("text3DSyncComplete"),c.notifyWorld("needsRender"),c.onSyncComplete))c.onSyncComplete()})}b&&(a.__proto__=b);a.prototype=Object.create(b&&
b.prototype);a.prototype.constructor=a;var c={textRenderInfo:{configurable:!0}};c.textRenderInfo.get=function(){return this.threeObject.textRenderInfo};a.prototype.afterUpdate=function(){var a=this,c=this.threeObject;x.forEach(function(b){c[b]=a[b]});c.sync();b.prototype.afterUpdate.call(this);this.text!==this._prevText&&(this.selectionStart=this.selectionEnd=-1,this._prevText=this.text);this._updateSelection()};a.prototype._updateSelection=function(){var a=this,b=this.selectable,c=this.selectionStart,
f=this.selectionEnd,d=this._selectionFacade;b!==this._selectable&&((this._selectable=b)?d=this._selectionFacade=new w(this,function(b,c){a.selectionStart=b;a.selectionEnd=c;a._updateSelection();a.notifyWorld("needsRender")}):(d&&(d.destructor(),d=this._selectionFacade=null),this.selectionStart=this.selectionEnd=-1));d&&(d.textRenderInfo=this.threeObject.textRenderInfo,d.selectionStart=c,d.selectionEnd=f,d.clipRect=this.clipRect,d.renderOrder=this.renderOrder,d.afterUpdate())};a.prototype.destructor=
function(){this.threeObject.dispose();this._selectionFacade&&this._selectionFacade.destructor();b.prototype.destructor.call(this)};Object.defineProperties(a.prototype,c);return a}(k.Object3DFacade);Object.defineProperty(b,"GlyphsGeometry",{enumerable:!0,get:function(){return f.GlyphsGeometry}});Object.defineProperty(b,"TextMesh",{enumerable:!0,get:function(){return f.Text}});Object.defineProperty(b,"configureTextBuilder",{enumerable:!0,get:function(){return f.configureTextBuilder}});Object.defineProperty(b,
"fontProcessorWorkerModule",{enumerable:!0,get:function(){return f.fontProcessorWorkerModule}});Object.defineProperty(b,"getCaretAtPoint",{enumerable:!0,get:function(){return f.getCaretAtPoint}});Object.defineProperty(b,"getSelectionRects",{enumerable:!0,get:function(){return f.getSelectionRects}});Object.defineProperty(b,"preloadFont",{enumerable:!0,get:function(){return f.preloadFont}});b.Text3DFacade=y;Object.defineProperty(b,"__esModule",{value:!0})})
'use strict';(function(b,f){"object"===typeof exports&&"undefined"!==typeof module?f(exports,require("troika-three-text"),require("troika-3d"),require("three"),require("troika-three-utils")):"function"===typeof define&&define.amd?define(["exports","troika-three-text","troika-3d","three","troika-three-utils"],f):(b=b||self,f(b.troika_3d_text={},b.troika_three_text,b.troika_3d,b.THREE,b.troika_three_utils))})(this,function(b,f,k,g,m){function n(){var c=k.createDerivedMaterial(new g.MeshBasicMaterial({transparent:!0,
opacity:.3,depthWrite:!1}),{uniforms:{rect:{value:new g.Vector4}},vertexDefs:"uniform vec4 rect;",vertexTransform:"\n position.x = position.x < 0.0 ? rect.x : rect.z;\n position.y = position.y < 0.0 ? rect.w : rect.y;\n "});c.instanceUniforms=["rect","diffuse"];var a=new g.Mesh((new g.BoxBufferGeometry).translate(0,0,-.5),c);return(n=function(){return a})()}var p=new g.Vector4,u=function(c){function a(a){c.call(this,a);this.instancedThreeObject=n();this._color=new g.Color;this._rect=new g.Vector4}
c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;a.prototype.afterUpdate=function(){var a=this.top,l=this.right,h=this.bottom,e=this.left,b=this.color;this._color.equals(b)||this.setInstanceUniform("diffuse",this._color=new g.Color(b));this._rect.equals(p.set(e,a,l,h))||this.setInstanceUniform("rect",p.clone());c.prototype.afterUpdate.call(this)};a.prototype.getBoundingSphere=function(){return null};return a}(k.Instanceable3DFacade),q=new g.Matrix4,v=new g.Plane,
w=new g.Vector3,r=Object.freeze([-Infinity,-Infinity,Infinity,Infinity]),x=function(c){function a(a,b){var e=this;c.call(this,a);var h=a.threeObject;this.rangeColor=52479;this.clipRect=r;this.template={key:function(a,b){return"rect"+b},facade:u,top:function(a){return Math.min(e.clipRect[3],Math.max(e.clipRect[1],a.top))},right:function(a){return Math.min(e.clipRect[2],Math.max(e.clipRect[0],a.right))},bottom:function(a){return Math.min(e.clipRect[3],Math.max(e.clipRect[1],a.bottom))},left:function(a){return Math.min(e.clipRect[2],
Math.max(e.clipRect[0],a.left))},z:function(a){return.25*(a.top-a.bottom)/2},scaleZ:function(a){return.25*(a.top-a.bottom)},color:function(a){return e.rangeColor},visible:function(a){var b=e.clipRect;return a.right>b[0]&&a.top>b[1]&&a.left<b[2]&&a.bottom<b[3]},renderOrder:function(a){return e.renderOrder||0}};var d=function(c){var d=e.textRenderInfo;if(d){var t=c.intersection.point.clone().applyMatrix4(m.invertMatrix4(h.matrixWorld,q));if(d=f.getCaretAtPoint(d,t.x,t.y))b(d.charIndex,d.charIndex),
a.addEventListener("drag",l),a.addEventListener("dragend",g);c.preventDefault()}},l=function(a){var c=h.textRenderInfo;if(a.ray&&c){var d=a.ray.clone().applyMatrix4(m.invertMatrix4(h.matrixWorld,q)).intersectPlane(v.setComponents(0,0,1,0),w);d&&(c=f.getCaretAtPoint(c,d.x,d.y))&&b(e.selectionStart,c.charIndex);a.preventDefault()}},g=function(b){a.removeEventListener("drag",l);a.removeEventListener("dragend",g)};a.addEventListener("dragstart",d);a.addEventListener("mousedown",d);this._cleanupEvents=
function(){g();a.removeEventListener("dragstart",d);a.removeEventListener("mousedown",d)}}c&&(a.__proto__=c);a.prototype=Object.create(c&&c.prototype);a.prototype.constructor=a;var b={clipRect:{configurable:!0}};a.prototype.afterUpdate=function(){this.data=f.getSelectionRects(this.textRenderInfo,this.selectionStart,this.selectionEnd);c.prototype.afterUpdate.call(this)};b.clipRect.set=function(a){this._clipRect=a&&Array.isArray(a)&&4===a.length?a:r};b.clipRect.get=function(){return this._clipRect};
a.prototype.destructor=function(){this._cleanupEvents();c.prototype.destructor.call(this)};Object.defineProperties(a.prototype,b);return a}(k.ListFacade),y="text anchorX anchorY font fontSize letterSpacing lineHeight maxWidth overflowWrap textAlign textIndent whiteSpace material color colorRanges fillOpacity outlineOpacity outlineColor outlineWidth outlineOffsetX outlineOffsetY outlineBlur strokeColor strokeWidth strokeOpacity depthOffset clipRect orientation glyphGeometryDetail sdfGlyphSize debugSDF".split(" "),
z=function(b){function a(a){var c=this,e=new f.Text;e.geometry.boundingSphere.version=0;b.call(this,a,e);this.selectable=!1;this.selectionStart=this.selectionEnd=-1;this.onSyncComplete=this.onSyncStart=null;e.addEventListener("syncstart",function(a){c.notifyWorld("text3DSyncStart");if(c.onSyncStart)c.onSyncStart()});e.addEventListener("synccomplete",function(a){if(!c.isDestroying&&(e.geometry.boundingSphere.version++,c.afterUpdate(),c.notifyWorld("text3DSyncComplete"),c.notifyWorld("needsRender"),
c.onSyncComplete))c.onSyncComplete()})}b&&(a.__proto__=b);a.prototype=Object.create(b&&b.prototype);a.prototype.constructor=a;var c={textRenderInfo:{configurable:!0}};c.textRenderInfo.get=function(){return this.threeObject.textRenderInfo};a.prototype.afterUpdate=function(){var a=this,c=this.threeObject;y.forEach(function(b){c[b]=a[b]});c.sync();b.prototype.afterUpdate.call(this);this.text!==this._prevText&&(this.selectionStart=this.selectionEnd=-1,this._prevText=this.text);this._updateSelection()};
a.prototype._updateSelection=function(){var a=this,b=this.selectable,c=this.selectionStart,f=this.selectionEnd,d=this._selectionFacade;b!==this._selectable&&((this._selectable=b)?d=this._selectionFacade=new x(this,function(b,c){a.selectionStart=b;a.selectionEnd=c;a._updateSelection();a.notifyWorld("needsRender")}):(d&&(d.destructor(),d=this._selectionFacade=null),this.selectionStart=this.selectionEnd=-1));d&&(d.textRenderInfo=this.threeObject.textRenderInfo,d.selectionStart=c,d.selectionEnd=f,d.clipRect=
this.clipRect,d.renderOrder=this.renderOrder,d.afterUpdate())};a.prototype.destructor=function(){this.threeObject.dispose();this._selectionFacade&&this._selectionFacade.destructor();b.prototype.destructor.call(this)};Object.defineProperties(a.prototype,c);return a}(k.Object3DFacade);Object.defineProperty(b,"GlyphsGeometry",{enumerable:!0,get:function(){return f.GlyphsGeometry}});Object.defineProperty(b,"TextMesh",{enumerable:!0,get:function(){return f.Text}});Object.defineProperty(b,"configureTextBuilder",
{enumerable:!0,get:function(){return f.configureTextBuilder}});Object.defineProperty(b,"fontProcessorWorkerModule",{enumerable:!0,get:function(){return f.fontProcessorWorkerModule}});Object.defineProperty(b,"getCaretAtPoint",{enumerable:!0,get:function(){return f.getCaretAtPoint}});Object.defineProperty(b,"getSelectionRects",{enumerable:!0,get:function(){return f.getSelectionRects}});Object.defineProperty(b,"preloadFont",{enumerable:!0,get:function(){return f.preloadFont}});b.Text3DFacade=z;Object.defineProperty(b,
"__esModule",{value:!0})})
{
"name": "troika-3d-text",
"version": "0.38.0",
"version": "0.38.1",
"description": "SDF text for the Troika 3D scene management framework",

@@ -17,6 +17,7 @@ "author": "Jason Johnston <jason.johnston@protectwise.com>",

"dependencies": {
"troika-3d": "^0.38.0",
"troika-three-text": "^0.38.0"
"troika-3d": "^0.38.1",
"troika-three-text": "^0.38.1",
"troika-three-utils": "^0.38.1"
},
"gitHead": "d48144bf99a2eaf2089c0cd2a8065506161dfdf4"
"gitHead": "b54fd6f27b4d95190747ff94cf4e101239447fea"
}
import { ListFacade } from 'troika-3d'
import { Matrix4, Plane, Vector3 } from 'three'
import { getCaretAtPoint, getSelectionRects } from 'troika-three-text'
import { invertMatrix4 } from 'troika-three-utils'
import SelectionRangeRect from './SelectionRangeRect.js'

@@ -44,3 +45,3 @@

if (textRenderInfo) {
const localPoint = e.intersection.point.clone().applyMatrix4(tempMat4.getInverse(textMesh.matrixWorld))
const localPoint = e.intersection.point.clone().applyMatrix4(invertMatrix4(textMesh.matrixWorld, tempMat4))
const caret = getCaretAtPoint(textRenderInfo, localPoint.x, localPoint.y)

@@ -60,3 +61,3 @@ if (caret) {

// Raycast to an infinite plane so dragging outside the text bounds will work
const ray = e.ray.clone().applyMatrix4(tempMat4.getInverse(textMesh.matrixWorld))
const ray = e.ray.clone().applyMatrix4(invertMatrix4(textMesh.matrixWorld, tempMat4))
const localPoint = ray.intersectPlane(tempPlane.setComponents(0, 0, 1, 0), tempVec3)

@@ -63,0 +64,0 @@ if (localPoint) {

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