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

troika-3d-ui

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

troika-3d-ui - npm Package Compare versions

Comparing version 0.46.4 to 0.47.0

7

CHANGELOG.md

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

## [0.46.4](https://github.com/protectwise/troika/compare/v0.46.3...v0.46.4) (2022-03-30)
# [0.47.0](https://github.com/protectwise/troika/compare/v0.46.3...v0.47.0) (2022-12-15)
**Note:** Version bump only for package troika-3d-ui
### Features
* raise three min version to r125 and fix BufferGeometry references ([#225](https://github.com/protectwise/troika/issues/225)) ([f2ef803](https://github.com/protectwise/troika/commit/f2ef803db7ab3d9d03de2719a2781c1c3f5122cf))
## [0.46.3](https://github.com/protectwise/troika/compare/v0.46.2...v0.46.3) (2022-03-11)

@@ -16,0 +19,0 @@

@@ -18,28 +18,28 @@ 'use strict';(function(n,z){"object"===typeof exports&&"undefined"!==typeof module?z(exports,require("troika-flex-layout"),require("troika-core"),require("three"),require("troika-3d"),require("troika-3d-text"),require("troika-three-utils"),require("object-path")):"function"===typeof define&&define.amd?define("exports troika-flex-layout troika-core three troika-3d troika-3d-text troika-three-utils object-path".split(" "),z):(n="undefined"!==typeof globalThis?globalThis:n||self,z(n.troika_3d_ui={},

this;if(null!==c){var d=this.parentFlexNode;this.x=a-d.scrollLeft;this.y=-(b-d.scrollTop);d=this.clipRect||(this.clipRect=[0,0,0,0]);d[0]=this.clipLeft;d[1]=-this.clipBottom;d[2]=this.clipRight;d[3]=-this.clipTop;this.threeObject.visible=!this.isFullyClipped}d=this._flexStyles;for(let a=0,b=R.length;a<b;a++){let b=R[a];("text"===b?this.text:w(this,b))!==d[b]&&(d[b]=this[b],this.needsFlexLayout=!0)}super.afterUpdate()}onAfterFlexLayoutApplied(){this.threeObject.maxWidth=this.offsetWidth;this.threeObject._actuallySync(this._afterSync)}getBoundingSphere(){return null}}
x=v(x);Q.forEach(a=>{x.prototype[a]="inherit"});Object.defineProperty(x.prototype,"maxWidth",{value:Infinity,enumerable:!0,writable:!0});var na=x;let oa=(new e.PlaneBufferGeometry(1,1)).translate(.5,-.5,0),S=new e.MeshBasicMaterial({color:0}),pa=Object.freeze(new e.Vector2),T=Object.freeze(new e.Vector4(0,0,0,0)),qa={customDepthMaterial:{get(){return this.material.getDepthMaterial()}},customDistanceMaterial:{get(){return this.material.getDistanceMaterial()}}},U=new Map;class V extends t.Instanceable3DFacade{constructor(a){super(a);
x=v(x);Q.forEach(a=>{x.prototype[a]="inherit"});Object.defineProperty(x.prototype,"maxWidth",{value:Infinity,enumerable:!0,writable:!0});var na=x;let oa=(new e.PlaneGeometry(1,1)).translate(.5,-.5,0),S=new e.MeshBasicMaterial({color:0}),pa=Object.freeze(new e.Vector2),T=Object.freeze(new e.Vector4(0,0,0,0)),qa={customDepthMaterial:{get(){return this.material.getDepthMaterial()}},customDistanceMaterial:{get(){return this.material.getDistanceMaterial()}}},U=new Map;class V extends t.Instanceable3DFacade{constructor(a){super(a);
this._colorObj=new e.Color;this.size=pa;this.borderWidth=this.borderRadius=T;this.color=0;this.isBorder=!1;this.material=S}afterUpdate(){let {material:a,depthOffset:b,castShadow:c,receiveShadow:d,color:f,renderOrder:r}=this;a||(a=S);let g=`${a.id}|${r}|${b}|${c}|${d}`;if(g!==this._prevMeshKey){let b=U.get(g);if(!b){let f=ea(a);f.polygonOffset=!!this.depthOffset;f.polygonOffsetFactor=f.polygonOffsetUnits=this.depthOffset||0;a.addEventListener("dispose",function C(){a.removeEventListener("dispose",
C);f.dispose()});b=new e.Mesh(oa,f);b._instanceKey=g;b.castShadow=c;b.receiveShadow=d;b.renderOrder=r;Object.defineProperties(b,qa);U.set(g,b)}this.instancedThreeObject=b;this._prevMeshKey=g}this.setInstanceUniform("uTroikaBlockSize",this.size);this.setInstanceUniform("uTroikaCornerRadii",this.borderRadius);this.setInstanceUniform("uTroikaClipRect",this.clipRect);this.setInstanceUniform("uTroikaBorderWidth",this.isBorder?this.borderWidth:T);f!==this._lastColor&&(this._lastColor=f,this.setInstanceUniform("diffuse",
new e.Color(f)));super.afterUpdate()}getBoundingSphere(){return null}}let W;class X extends t.Object3DFacade{constructor(a){let b=new e.Mesh(W||(W=(new e.CylinderBufferGeometry(.5,.5,1,8)).translate(0,-.5,0)),new e.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0}));super(a,b);this.length=this.girth=0}afterUpdate(){this.scaleX=this.scaleZ=this.girth;this.scaleY=this.length;this.rotateZ=this.horizontal?Math.PI/2:0;this.threeObject.material.opacity=this.opacity;super.afterUpdate()}}let M=
new WeakMap,Y={opacity:{duration:300}};class ra extends t.ParentFacade{constructor(a){super(a);this._onOver=a=>{this.hovering=!0;this.afterUpdate()};this._onOut=a=>{this.hovering=!1;this.afterUpdate()}}set target(a){let b=M.get(this);a!==b&&(b&&(b.removeEventListener("mouseover",this._onOver),b.removeEventListener("mouseout",this._onOut)),a&&(a.addEventListener("mouseover",this._onOver),a.addEventListener("mouseout",this._onOut)),M.set(this,a))}get target(){return M.get(this)}describeChildren(){let {target:a}=
new e.Color(f)));super.afterUpdate()}getBoundingSphere(){return null}}let W;class X extends t.Object3DFacade{constructor(a){let b=new e.Mesh(W||(W=(new e.CylinderGeometry(.5,.5,1,8)).translate(0,-.5,0)),new e.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0}));super(a,b);this.length=this.girth=0}afterUpdate(){this.scaleX=this.scaleZ=this.girth;this.scaleY=this.length;this.rotateZ=this.horizontal?Math.PI/2:0;this.threeObject.material.opacity=this.opacity;super.afterUpdate()}}let M=new WeakMap,
Y={opacity:{duration:300}};class ra extends t.ParentFacade{constructor(a){super(a);this._onOver=a=>{this.hovering=!0;this.afterUpdate()};this._onOut=a=>{this.hovering=!1;this.afterUpdate()}}set target(a){let b=M.get(this);a!==b&&(b&&(b.removeEventListener("mouseover",this._onOver),b.removeEventListener("mouseout",this._onOut)),a&&(a.addEventListener("mouseover",this._onOver),a.addEventListener("mouseout",this._onOut)),M.set(this,a))}get target(){return M.get(this)}describeChildren(){let {target:a}=
this,b=this._childArr||(this._childArr=[]);b.length=0;if(a){let {offsetWidth:d,offsetHeight:f,scrollHeight:e,scrollWidth:g,clientWidth:h,clientHeight:k}=a,m=a.getComputedFontSize();if(g>h){var c=this._hDef||(this._hDef={key:"h",facade:X,horizontal:!0,transition:Y});c.girth=Math.min(m/4,f/10);c.length=Math.max(h*h/g,m);c.x=a.clientLeft+a.scrollLeft/(g-h)*(h-c.length);c.y=-f;c.opacity=this.hovering?.5:0;c.renderOrder=this.renderOrder;b.push(c)}e>k&&(c=this._vDef||(this._vDef={key:"v",facade:X,transition:Y}),
c.girth=Math.min(m/4,d/10),c.length=Math.max(k*k/e,m),c.x=d,c.y=-(a.clientTop+a.scrollTop/(e-k)*(k-c.length)),c.opacity=this.hovering?.5:0,c.renderOrder=this.renderOrder,b.push(c))}return b}destructor(){this.target=null;super.destructor()}}let Z=new e.Mesh((new e.PlaneBufferGeometry(1,1)).translate(.5,-.5,0)),O=new e.Matrix4,A=new e.Vector4(0,0,0,0),sa=Object.freeze(new e.Vector4(0,0,0,0)),ha=new e.Plane,ta={get(){return!this._priv_hidden&&!this.$facade.isFullyClipped},set(a){this._priv_hidden=!a}};
class G extends t.Group3DFacade{constructor(a){super(a);Object.defineProperty(this.threeObject,"visible",ta);this.layers=new t.Group3DFacade(this);this.layers.children=[null,null,null];this._sizeVec2=Object.freeze(new e.Vector2);this._borderRadiiVec4=this._borderWidthVec4=this._clipRectVec4=sa;(this._geomBoundingSphere=new e.Sphere).version=0;this._wasFullyClipped=!0}updateChildren(a){this.isFullyClipped&&this._wasFullyClipped||super.updateChildren(a)}updateMatrices(){super.updateMatrices();this.layers.traverse(ia)}afterUpdate(){let {layers:a,
backgroundColor:b,backgroundMaterial:c,borderWidth:d,borderColor:f,borderMaterial:r,text:g,offsetLeft:h,offsetTop:k,offsetWidth:m,offsetHeight:n,parentFlexNode:t,flexNodeDepth:q,isFullyClipped:p,_wasFullyClipped:v,_borderWidthVec4:z,_clipRectVec4:x,_sizeVec2:D}=this;var y=!(!m||!n),u=y&&!p&&(null!=b||null!=c),l=y&&!p&&(null!=f||null!=r)&&0<Math.max(...d);y=y&&("scroll"===this.overflow||"auto"===this.overflow)&&(this.scrollHeight>this.clientHeight||this.scrollWidth>this.clientWidth);if(null!==m){if(t){var B=
"absolute"===this.position;this.x=h-(B?0:t.scrollLeft);this.y=-(k-(B?0:t.scrollTop))}if(m!==D.x||n!==D.y)D=this._sizeVec2=Object.freeze(new e.Vector2(m,n)),B=this._geomBoundingSphere,B.radius=Math.sqrt(m*m/4+n*n/4),B.center.set(m/2,-n/2,0),B.version++}if(!p||!v){B=u||l?this._normalizeBorderRadius():null;A.fromArray(d);A.equals(z)||(z=this._borderWidthVec4=Object.freeze(A.clone()));A.set(Math.max(this.clipLeft,0),Math.max(this.clipTop,0),Math.min(this.clipRight,m),Math.min(this.clipBottom,n));A.equals(x)||
(x=this._clipRectVec4=Object.freeze(A.clone()));let e=null;u&&(e=this._bgLayerDef||(this._bgLayerDef={key:"bg",facade:V}),e.size=D,e.color=b,e.borderRadius=B,e.material=c,e.clipRect=x,e.depthOffset=-q,e.renderOrder=q,e.castShadow=this.castShadow,e.receiveShadow=this.receiveShadow);a.children[0]=e;u=null;l&&(u=this._borderLayerDef||(this._borderLayerDef={key:"border",facade:V,isBorder:!0}),u.size=D,u.color=f,u.borderWidth=z,u.borderRadius=B,u.material=r,u.clipRect=x,u.depthOffset=-q-1,u.renderOrder=
q+1,u.castShadow=this.castShadow,u.receiveShadow=this.receiveShadow);a.children[1]=u;l=null;y&&(l=this._scrollbarsDef||(this._scrollbarsDef={key:"sb",facade:ra,target:this}),l.renderOrder=q+2);a.children[2]=l;!g&&L(this.children)&&(g=""+this.children);if(g)l=this._textChildDef||(this._textChildDef={key:"text",facade:na}),l.text=g,l.font=w(this,"font"),l.fontSize=this.getComputedFontSize(),l.textAlign=w(this,"textAlign"),l.textIndent=w(this,"textIndent"),l.lineHeight=w(this,"lineHeight","normal"),
l.letterSpacing=w(this,"letterSpacing",0),l.whiteSpace=w(this,"whiteSpace"),l.overflowWrap=w(this,"overflowWrap"),l.color=w(this,"color"),l.colorRanges=this.colorRanges,l.outlineWidth=this.textOutlineWidth||0,l.outlineColor=this.textOutlineColor,l.outlineOpacity=this.textOutlineOpacity,l.outlineBlur=this.textOutlineBlur||0,l.outlineOffsetX=this.textOutlineOffsetX||0,l.outlineOffsetY=this.textOutlineOffsetY||0,l.strokeWidth=this.textStrokeWidth||0,l.strokeColor=this.textStrokeColor,l.strokeOpacity=
this.textStrokeOpacity,l.fillOpacity=this.textFillOpacity,l.material=this.textMaterial,l.depthOffset=-q-1,l.renderOrder=q+1,l.castShadow=this.castShadow,l.receiveShadow=this.receiveShadow,this._actualChildren=l;else{l=this.children;if(Array.isArray(l))for(let a=0,b=l.length;a<b;a++)if(L(l[a])){for(l=l.slice();a<b;a++)L(l[a])&&(l[a]={facade:ua,text:""+l[a],textMaterial:this.textMaterial});break}this._actualChildren=l}}y!==this._couldScroll&&(this._couldScroll=y,this[`${y?"add":"remove"}EventListener`]("wheel",
fa),this[`${y?"add":"remove"}EventListener`]("dragstart",N),this[`${y?"add":"remove"}EventListener`]("drag",N));super.afterUpdate();p&&v||a.afterUpdate();this._wasFullyClipped=p}describeChildren(){return this._actualChildren}getComputedFontSize(){return F(this,16)}_normalizeBorderRadius(){let {borderRadius:a,offsetWidth:b=0,offsetHeight:c=0,_borderRadiiVec4:d}=this,f,e,g;if(Array.isArray(a)){var h=a.length;f=a[0]||0;e=(1<h?a[1]:a[0])||0;g=(2<h?a[2]:a[0])||0;h=(3<h?a[3]:1<h?a[1]:a[0])||0}else f=e=
g=h=a||0;if(0!==f||0!==e||0!==g||0!==h){var k=Math.min(b,c);"string"===typeof f&&/%$/.test(f)&&(f=parseInt(f,10)/100*k);"string"===typeof e&&/%$/.test(e)&&(e=parseInt(e,10)/100*k);"string"===typeof h&&/%$/.test(h)&&(h=parseInt(h,10)/100*k);"string"===typeof g&&/%$/.test(g)&&(g=parseInt(g,10)/100*k);k=Math.min(b/(f+e),c/(e+g),b/(g+h),c/(h+f));1>k&&(f*=k,e*=k,h*=k,g*=k)}A.set(f,e,g,h);A.equals(d)||(d=this._borderRadiiVec4=Object.freeze(A.clone()));return d}_getGeometryBoundingSphere(){return this._geomBoundingSphere.radius&&
!this.isFullyClipped?this._geomBoundingSphere:null}raycast(a){let {offsetWidth:b,offsetHeight:c,clipTop:d,clipRight:f,clipBottom:e,clipLeft:g}=this,h=null;b&&c&&(Z.matrixWorld.multiplyMatrices(this.threeObject.matrixWorld,O.makeScale(b,c,1)),h=this._raycastObject(Z,a))&&(h=h.filter(a=>{let k=a.uv.x*b;a=(1-a.uv.y)*c;return k>g&&k<f&&a>d&&a<e}),h.forEach(a=>{a.distance=parseFloat(a.distance.toFixed(12));a.distanceBias=-this.flexNodeDepth}));return h&&h.length?h:null}destructor(){this.layers.destructor();
super.destructor()}}let ua=G=v(G);Q.forEach(a=>{G.prototype[a]="inherit"});var m=G;let va=(new e.PlaneBufferGeometry(1,1)).translate(.5,-.5,0),wa=new e.MeshBasicMaterial,xa=new e.TextureLoader;class ya extends t.Object3DFacade{constructor(a,b){b=new e.Mesh(va,wa.clone());b.visible=!1;super(a,b)}afterUpdate(){let {offsetLeft:a,offsetTop:b,offsetWidth:c,offsetHeight:d,src:f,threeObject:e}=this,g=e.material,h=!(!c||!d);if(h){this.x=a;this.y=-b;this.scaleX=c;this.scaleY=d;let f=this.flexNodeDepth;g.polygonOffset=
!!f;g.polygonOffsetFactor=g.polygonOffsetUnits=-f||0;e.renderOrder=f}f!==this._lastSrc&&(xa.load(f,a=>{g.map&&g.map.dispose();g.map=a;this.aspectRatio=a.image.width/a.image.height;this.afterUpdate();this.requestRender()}),this._lastSrc=f);e.visible=!!(h&&g.map&&g.map.image.complete);super.afterUpdate()}destructor(){let a=this.threeObject.material.map;a&&a.dispose();super.destructor()}}J=v(ya);class aa extends m{constructor(a){super(a);this.font="https://fonts.gstatic.com/s/materialicons/v36/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.woff"}set icon(a){this.text=
c.girth=Math.min(m/4,d/10),c.length=Math.max(k*k/e,m),c.x=d,c.y=-(a.clientTop+a.scrollTop/(e-k)*(k-c.length)),c.opacity=this.hovering?.5:0,c.renderOrder=this.renderOrder,b.push(c))}return b}destructor(){this.target=null;super.destructor()}}let Z=new e.Mesh((new e.PlaneGeometry(1,1)).translate(.5,-.5,0)),O=new e.Matrix4,A=new e.Vector4(0,0,0,0),sa=Object.freeze(new e.Vector4(0,0,0,0)),ha=new e.Plane,ta={get(){return!this._priv_hidden&&!this.$facade.isFullyClipped},set(a){this._priv_hidden=!a}};class G extends t.Group3DFacade{constructor(a){super(a);
Object.defineProperty(this.threeObject,"visible",ta);this.layers=new t.Group3DFacade(this);this.layers.children=[null,null,null];this._sizeVec2=Object.freeze(new e.Vector2);this._borderRadiiVec4=this._borderWidthVec4=this._clipRectVec4=sa;(this._geomBoundingSphere=new e.Sphere).version=0;this._wasFullyClipped=!0}updateChildren(a){this.isFullyClipped&&this._wasFullyClipped||super.updateChildren(a)}updateMatrices(){super.updateMatrices();this.layers.traverse(ia)}afterUpdate(){let {layers:a,backgroundColor:b,
backgroundMaterial:c,borderWidth:d,borderColor:f,borderMaterial:r,text:g,offsetLeft:h,offsetTop:k,offsetWidth:m,offsetHeight:n,parentFlexNode:t,flexNodeDepth:q,isFullyClipped:p,_wasFullyClipped:v,_borderWidthVec4:z,_clipRectVec4:x,_sizeVec2:D}=this;var y=!(!m||!n),u=y&&!p&&(null!=b||null!=c),l=y&&!p&&(null!=f||null!=r)&&0<Math.max(...d);y=y&&("scroll"===this.overflow||"auto"===this.overflow)&&(this.scrollHeight>this.clientHeight||this.scrollWidth>this.clientWidth);if(null!==m){if(t){var B="absolute"===
this.position;this.x=h-(B?0:t.scrollLeft);this.y=-(k-(B?0:t.scrollTop))}if(m!==D.x||n!==D.y)D=this._sizeVec2=Object.freeze(new e.Vector2(m,n)),B=this._geomBoundingSphere,B.radius=Math.sqrt(m*m/4+n*n/4),B.center.set(m/2,-n/2,0),B.version++}if(!p||!v){B=u||l?this._normalizeBorderRadius():null;A.fromArray(d);A.equals(z)||(z=this._borderWidthVec4=Object.freeze(A.clone()));A.set(Math.max(this.clipLeft,0),Math.max(this.clipTop,0),Math.min(this.clipRight,m),Math.min(this.clipBottom,n));A.equals(x)||(x=this._clipRectVec4=
Object.freeze(A.clone()));let e=null;u&&(e=this._bgLayerDef||(this._bgLayerDef={key:"bg",facade:V}),e.size=D,e.color=b,e.borderRadius=B,e.material=c,e.clipRect=x,e.depthOffset=-q,e.renderOrder=q,e.castShadow=this.castShadow,e.receiveShadow=this.receiveShadow);a.children[0]=e;u=null;l&&(u=this._borderLayerDef||(this._borderLayerDef={key:"border",facade:V,isBorder:!0}),u.size=D,u.color=f,u.borderWidth=z,u.borderRadius=B,u.material=r,u.clipRect=x,u.depthOffset=-q-1,u.renderOrder=q+1,u.castShadow=this.castShadow,
u.receiveShadow=this.receiveShadow);a.children[1]=u;l=null;y&&(l=this._scrollbarsDef||(this._scrollbarsDef={key:"sb",facade:ra,target:this}),l.renderOrder=q+2);a.children[2]=l;!g&&L(this.children)&&(g=""+this.children);if(g)l=this._textChildDef||(this._textChildDef={key:"text",facade:na}),l.text=g,l.font=w(this,"font"),l.fontSize=this.getComputedFontSize(),l.textAlign=w(this,"textAlign"),l.textIndent=w(this,"textIndent"),l.lineHeight=w(this,"lineHeight","normal"),l.letterSpacing=w(this,"letterSpacing",
0),l.whiteSpace=w(this,"whiteSpace"),l.overflowWrap=w(this,"overflowWrap"),l.color=w(this,"color"),l.colorRanges=this.colorRanges,l.outlineWidth=this.textOutlineWidth||0,l.outlineColor=this.textOutlineColor,l.outlineOpacity=this.textOutlineOpacity,l.outlineBlur=this.textOutlineBlur||0,l.outlineOffsetX=this.textOutlineOffsetX||0,l.outlineOffsetY=this.textOutlineOffsetY||0,l.strokeWidth=this.textStrokeWidth||0,l.strokeColor=this.textStrokeColor,l.strokeOpacity=this.textStrokeOpacity,l.fillOpacity=this.textFillOpacity,
l.material=this.textMaterial,l.depthOffset=-q-1,l.renderOrder=q+1,l.castShadow=this.castShadow,l.receiveShadow=this.receiveShadow,this._actualChildren=l;else{l=this.children;if(Array.isArray(l))for(let a=0,b=l.length;a<b;a++)if(L(l[a])){for(l=l.slice();a<b;a++)L(l[a])&&(l[a]={facade:ua,text:""+l[a],textMaterial:this.textMaterial});break}this._actualChildren=l}}y!==this._couldScroll&&(this._couldScroll=y,this[`${y?"add":"remove"}EventListener`]("wheel",fa),this[`${y?"add":"remove"}EventListener`]("dragstart",
N),this[`${y?"add":"remove"}EventListener`]("drag",N));super.afterUpdate();p&&v||a.afterUpdate();this._wasFullyClipped=p}describeChildren(){return this._actualChildren}getComputedFontSize(){return F(this,16)}_normalizeBorderRadius(){let {borderRadius:a,offsetWidth:b=0,offsetHeight:c=0,_borderRadiiVec4:d}=this,f,e,g;if(Array.isArray(a)){var h=a.length;f=a[0]||0;e=(1<h?a[1]:a[0])||0;g=(2<h?a[2]:a[0])||0;h=(3<h?a[3]:1<h?a[1]:a[0])||0}else f=e=g=h=a||0;if(0!==f||0!==e||0!==g||0!==h){var k=Math.min(b,
c);"string"===typeof f&&/%$/.test(f)&&(f=parseInt(f,10)/100*k);"string"===typeof e&&/%$/.test(e)&&(e=parseInt(e,10)/100*k);"string"===typeof h&&/%$/.test(h)&&(h=parseInt(h,10)/100*k);"string"===typeof g&&/%$/.test(g)&&(g=parseInt(g,10)/100*k);k=Math.min(b/(f+e),c/(e+g),b/(g+h),c/(h+f));1>k&&(f*=k,e*=k,h*=k,g*=k)}A.set(f,e,g,h);A.equals(d)||(d=this._borderRadiiVec4=Object.freeze(A.clone()));return d}_getGeometryBoundingSphere(){return this._geomBoundingSphere.radius&&!this.isFullyClipped?this._geomBoundingSphere:
null}raycast(a){let {offsetWidth:b,offsetHeight:c,clipTop:d,clipRight:f,clipBottom:e,clipLeft:g}=this,h=null;b&&c&&(Z.matrixWorld.multiplyMatrices(this.threeObject.matrixWorld,O.makeScale(b,c,1)),h=this._raycastObject(Z,a))&&(h=h.filter(a=>{let k=a.uv.x*b;a=(1-a.uv.y)*c;return k>g&&k<f&&a>d&&a<e}),h.forEach(a=>{a.distance=parseFloat(a.distance.toFixed(12));a.distanceBias=-this.flexNodeDepth}));return h&&h.length?h:null}destructor(){this.layers.destructor();super.destructor()}}let ua=G=v(G);Q.forEach(a=>
{G.prototype[a]="inherit"});var m=G;let va=(new e.PlaneGeometry(1,1)).translate(.5,-.5,0),wa=new e.MeshBasicMaterial,xa=new e.TextureLoader;class ya extends t.Object3DFacade{constructor(a,b){b=new e.Mesh(va,wa.clone());b.visible=!1;super(a,b)}afterUpdate(){let {offsetLeft:a,offsetTop:b,offsetWidth:c,offsetHeight:d,src:f,threeObject:e}=this,g=e.material,h=!(!c||!d);if(h){this.x=a;this.y=-b;this.scaleX=c;this.scaleY=d;let f=this.flexNodeDepth;g.polygonOffset=!!f;g.polygonOffsetFactor=g.polygonOffsetUnits=
-f||0;e.renderOrder=f}f!==this._lastSrc&&(xa.load(f,a=>{g.map&&g.map.dispose();g.map=a;this.aspectRatio=a.image.width/a.image.height;this.afterUpdate();this.requestRender()}),this._lastSrc=f);e.visible=!!(h&&g.map&&g.map.image.complete);super.afterUpdate()}destructor(){let a=this.threeObject.material.map;a&&a.dispose();super.destructor()}}J=v(ya);class aa extends m{constructor(a){super(a);this.font="https://fonts.gstatic.com/s/materialicons/v36/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.woff"}set icon(a){this.text=
a}set size(a){this.fontSize=a}}class za extends aa{constructor(a){super(a);this.justifyContent="center";this.fontSize="150%";this.onClick=a=>{this.onUpdate(!this.value)}}afterUpdate(){this.icon=this.value?"check_box":"check_box_outline_blank";super.afterUpdate()}}class Aa extends m{constructor(a){super(a);this.children={facade:m,borderRadius:"10%",backgroundColor:3355545,height:"100%",padding:[0,.02],alignItems:"center",justifyContent:"center",pointerStates:{hover:{backgroundColor:6710988}}}}afterUpdate(){this.children.text=
this.label||"Missing label";super.afterUpdate()}}let q=new e.Color,H=new e.Plane,ba=(new e.CylinderBufferGeometry(.5,.5,1,45)).translate(0,.5,0).rotateX(Math.PI/2).rotateZ(Math.PI/2),ca=K.createDerivedMaterial(new e.MeshBasicMaterial({side:2}),{uniforms:{maxValue:{value:1}},vertexDefs:"\nvarying vec3 vPos;\n",vertexMainIntro:"\nvPos = position;\n",fragmentDefs:"\nuniform float maxValue;\nvarying vec3 vPos;\n\n// From https://github.com/hughsk/glsl-hsv2rgb\nvec3 hsv2rgb(vec3 c) {\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\n",
this.label||"Missing label";super.afterUpdate()}}let q=new e.Color,H=new e.Plane,ba=(new e.CylinderGeometry(.5,.5,1,45)).translate(0,.5,0).rotateX(Math.PI/2).rotateZ(Math.PI/2),ca=K.createDerivedMaterial(new e.MeshBasicMaterial({side:2}),{uniforms:{maxValue:{value:1}},vertexDefs:"\nvarying vec3 vPos;\n",vertexMainIntro:"\nvPos = position;\n",fragmentDefs:"\nuniform float maxValue;\nvarying vec3 vPos;\n\n// From https://github.com/hughsk/glsl-hsv2rgb\nvec3 hsv2rgb(vec3 c) {\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n\n",
fragmentColorTransform:"\nfloat angle = atan(vPos.y, vPos.x) / PI2;\nfloat radius = length(vPos.xy) * 2.0;\nfloat value = vPos.z * maxValue;\nvec3 hsv = vec3(angle, radius, value);\nvec3 rgb = hsv2rgb(hsv);\ngl_FragColor.xyz = rgb;\n"});class Ba extends t.Object3DFacade{constructor(a){super(a,new e.Mesh(ba,ca.clone()));this.maxValue=1}afterUpdate(){this.threeObject.material.uniforms.maxValue.value=this.maxValue;super.afterUpdate()}}class Ca extends t.Object3DFacade{constructor(a){let b=ca.clone();
b.transparent=!0;b.opacity=.5;b.side=e.BackSide;super(a,new e.Mesh(ba,b))}}class Da extends t.Object3DFacade{constructor(a){var b=(new e.SphereBufferGeometry(.05,16,12)).translate(0,0,.5);let c=(new e.CylinderBufferGeometry(.005,.005,.5,6)).translate(0,.25,0).rotateX(Math.PI/2),d=new e.MeshBasicMaterial;b=new e.Mesh(b,d);b.add(new e.Mesh(c,new e.MeshBasicMaterial({color:13421772})));super(a,b)}afterUpdate(){this.threeObject.material.color.set(this.color);super.afterUpdate()}}class Ea extends t.Object3DFacade{constructor(a){let b=
K.createDerivedMaterial(new e.MeshBasicMaterial({transparent:!0,color:16777215,polygonOffset:!0,polygonOffsetFactor:1}),{vertexDefs:"varying vec2 vUV;",vertexMainIntro:"vUV = uv;",fragmentDefs:"varying vec2 vUV;",fragmentColorTransform:"\n float dist = min(min(vUV.x, 1.0 - vUV.x), min(vUV.y, 1.0 - vUV.y));\n gl_FragColor.w *= 1.0 - 0.5 * smoothstep(0.0, 0.1, dist);\n "});super(a,new e.Mesh(new e.PlaneBufferGeometry,b))}afterUpdate(){this.threeObject.material.opacity=this.opacity;
super.afterUpdate()}}class Fa extends t.Group3DFacade{constructor(a){super(a);this.cylinderHeight=.5;this.cylinderDiameter=.75;this.rotateX=-Math.PI/4;a=a=>{var b=a.currentTarget.threeObject,d=a.ray;H.normal.set(0,0,-1);H.constant=1;H.applyMatrix4(b.matrixWorld);var f=d.intersectPlane(H,new e.Vector3);if(f){b.worldToLocal(f);d=2*f.x;f=2*f.y;for(b=Math.atan2(f,d)/Math.PI/2;0>b;)b+=1;d=Math.min(1,Math.sqrt(d*d+f*f));f=this._getHSV();f[0]=b;f[1]=d;this._updateHSV(f,a.shiftKey)}};this.onWheel=a=>{let b=
this._getHSV();b[2]=Math.max(0,Math.min(1,b[2]+a.nativeEvent.deltaY/100));this._updateHSV(b,!1)};this.children=[this.cylinderDef={key:"disc",facade:Ba,onMouseDown:a,onDragStart:a,onDrag:a},this.cylinderBgDef={facade:Ca,renderOrder:9},this.planeDef={facade:Ea,renderOrder:10,opacity:.3,pointerStates:{hover:{opacity:.4}},transition:{opacity:!0},onDragStart:a=>{this._dragData={plane:(new e.Plane).setFromNormalAndCoplanarPoint((new e.Vector3(0,1,0)).transformDirection(this.threeObject.matrixWorld),a.intersection.point)}},
b.transparent=!0;b.opacity=.5;b.side=e.BackSide;super(a,new e.Mesh(ba,b))}}class Da extends t.Object3DFacade{constructor(a){var b=(new e.SphereGeometry(.05,16,12)).translate(0,0,.5);let c=(new e.CylinderGeometry(.005,.005,.5,6)).translate(0,.25,0).rotateX(Math.PI/2),d=new e.MeshBasicMaterial;b=new e.Mesh(b,d);b.add(new e.Mesh(c,new e.MeshBasicMaterial({color:13421772})));super(a,b)}afterUpdate(){this.threeObject.material.color.set(this.color);super.afterUpdate()}}class Ea extends t.Object3DFacade{constructor(a){let b=
K.createDerivedMaterial(new e.MeshBasicMaterial({transparent:!0,color:16777215,polygonOffset:!0,polygonOffsetFactor:1}),{vertexDefs:"varying vec2 vUV;",vertexMainIntro:"vUV = uv;",fragmentDefs:"varying vec2 vUV;",fragmentColorTransform:"\n float dist = min(min(vUV.x, 1.0 - vUV.x), min(vUV.y, 1.0 - vUV.y));\n gl_FragColor.w *= 1.0 - 0.5 * smoothstep(0.0, 0.1, dist);\n "});super(a,new e.Mesh(new e.PlaneGeometry,b))}afterUpdate(){this.threeObject.material.opacity=this.opacity;super.afterUpdate()}}
class Fa extends t.Group3DFacade{constructor(a){super(a);this.cylinderHeight=.5;this.cylinderDiameter=.75;this.rotateX=-Math.PI/4;a=a=>{var b=a.currentTarget.threeObject,d=a.ray;H.normal.set(0,0,-1);H.constant=1;H.applyMatrix4(b.matrixWorld);var f=d.intersectPlane(H,new e.Vector3);if(f){b.worldToLocal(f);d=2*f.x;f=2*f.y;for(b=Math.atan2(f,d)/Math.PI/2;0>b;)b+=1;d=Math.min(1,Math.sqrt(d*d+f*f));f=this._getHSV();f[0]=b;f[1]=d;this._updateHSV(f,a.shiftKey)}};this.onWheel=a=>{let b=this._getHSV();b[2]=
Math.max(0,Math.min(1,b[2]+a.nativeEvent.deltaY/100));this._updateHSV(b,!1)};this.children=[this.cylinderDef={key:"disc",facade:Ba,onMouseDown:a,onDragStart:a,onDrag:a},this.cylinderBgDef={facade:Ca,renderOrder:9},this.planeDef={facade:Ea,renderOrder:10,opacity:.3,pointerStates:{hover:{opacity:.4}},transition:{opacity:!0},onDragStart:a=>{this._dragData={plane:(new e.Plane).setFromNormalAndCoplanarPoint((new e.Vector3(0,1,0)).transformDirection(this.threeObject.matrixWorld),a.intersection.point)}},
onDrag:a=>{var {plane:b}=this._dragData;b=a.ray.intersectPlane(b,new e.Vector3);this.threeObject.worldToLocal(b);let d=this._getHSV();d[2]=Math.max(0,Math.min(1,b.z/this.cylinderHeight));this._updateHSV(d,a.shiftKey)},onDragEnd:a=>{this._dragData=null}},this.stickDef={facade:Da}]}_getHSV(){var a=[0,0,0];if(null!=this.value){q.set(this.value);{a=q.r;var b=q.g,c=q.b;let f,e;let g,h,k=Math.max(a,b,c);var d=k-Math.min(a,b,c);0===d?h=g=0:(h=d/k,f=(k-a)/6/d+.5,e=(k-b)/6/d+.5,d=(k-c)/6/d+.5,a===k?g=d-e:

@@ -46,0 +46,0 @@ b===k?g=1/3+f-d:c===k&&(g=2/3+e-f),0>g?g+=1:1<g&&--g);a=[g,h,k]}}return a}_updateHSV(a,b){a=ja(...a);q.setRGB(...a);b&&(q.r=Math.round(5*q.r)/5,q.g=Math.round(5*q.g)/5,q.b=Math.round(5*q.b)/5);this.onChange(q.getHex())}afterUpdate(){let {stickDef:a,cylinderDef:b,cylinderBgDef:c,planeDef:d,cylinderHeight:f,cylinderDiameter:e}=this,g=this._getHSV(),h=g[0]*Math.PI*2,k=g[1]/2*e,m=Math.sin(h)*k;a.x=Math.cos(h)*k;a.y=m;a.z=g[2]*f;a.color=this.value;b.maxValue=g[2];b.scale=e;b.scaleZ=g[2]*f+1E-5;c.scale=

{
"name": "troika-3d-ui",
"version": "0.46.4",
"version": "0.47.0",
"description": "Troika 3D User Interface Toolkit",

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

"object-path": "^0.11.4",
"troika-3d": "^0.46.0",
"troika-3d-text": "^0.46.4",
"troika-core": "^0.46.0",
"troika-flex-layout": "^0.46.4",
"troika-three-utils": "^0.46.0"
"troika-3d": "^0.47.0",
"troika-3d-text": "^0.47.0",
"troika-core": "^0.47.0",
"troika-flex-layout": "^0.47.0",
"troika-three-utils": "^0.47.0"
},
"peerDependencies": {
"three": ">=0.103.0"
"three": ">=0.125.0"
},
"gitHead": "b19170a9d8e1223138a2be7633eb8bf22eb6ff8f"
"gitHead": "f20187dfa6a07de046b4e6a3948e75483b8e2ee5"
}
import { Object3DFacade, ParentFacade } from 'troika-3d'
import { CylinderBufferGeometry, Mesh, MeshBasicMaterial } from 'three'
import { CylinderGeometry, Mesh, MeshBasicMaterial } from 'three'

@@ -11,3 +11,3 @@ let barGeometry

barGeometry || (barGeometry =
new CylinderBufferGeometry(0.5, 0.5, 1, 8).translate(0, -0.5, 0)
new CylinderGeometry(0.5, 0.5, 1, 8).translate(0, -0.5, 0)
),

@@ -14,0 +14,0 @@ // TODO allow overriding material

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

import { Mesh, Vector2, Vector3, Vector4, PlaneBufferGeometry, Sphere, Matrix4, Plane } from 'three'
import { Mesh, Vector2, Vector3, Vector4, PlaneGeometry, Sphere, Matrix4, Plane } from 'three'
import { Group3DFacade } from 'troika-3d'

@@ -10,3 +10,3 @@ import UITextNode3DFacade from './UITextNode3DFacade.js'

const raycastMesh = new Mesh(new PlaneBufferGeometry(1, 1).translate(0.5, -0.5, 0))
const raycastMesh = new Mesh(new PlaneGeometry(1, 1).translate(0.5, -0.5, 0))
const tempMat4 = new Matrix4()

@@ -13,0 +13,0 @@ const tempVec4 = new Vector4(0,0,0,0)

import { Instanceable3DFacade } from 'troika-3d'
import { Color, Mesh, MeshBasicMaterial, PlaneBufferGeometry, Vector2, Vector4 } from 'three'
import { Color, Mesh, MeshBasicMaterial, PlaneGeometry, Vector2, Vector4 } from 'three'
import { createUIBlockLayerDerivedMaterial } from './UIBlockLayerDerivedMaterial.js'
const geometry = new PlaneBufferGeometry(1, 1).translate(0.5, -0.5, 0)
const geometry = new PlaneGeometry(1, 1).translate(0.5, -0.5, 0)
const defaultMaterial = new MeshBasicMaterial({color: 0})

@@ -7,0 +7,0 @@ const emptyVec2 = Object.freeze(new Vector2())

import { extendAsFlexNode } from '../flex-layout/FlexNode.js'
import { Mesh, MeshBasicMaterial, PlaneBufferGeometry, TextureLoader } from 'three'
import { Mesh, MeshBasicMaterial, PlaneGeometry, TextureLoader } from 'three'
import { Object3DFacade } from 'troika-3d'
const geometry = new PlaneBufferGeometry(1, 1).translate(0.5, -0.5, 0)
const geometry = new PlaneGeometry(1, 1).translate(0.5, -0.5, 0)
const defaultMaterial = new MeshBasicMaterial()

@@ -8,0 +8,0 @@ const loader = new TextureLoader()

@@ -5,8 +5,8 @@ import { Group3DFacade, Object3DFacade } from 'troika-3d'

Color,
CylinderBufferGeometry,
CylinderGeometry,
Mesh,
MeshBasicMaterial,
Plane,
PlaneBufferGeometry,
SphereBufferGeometry,
PlaneGeometry,
SphereGeometry,
Vector3

@@ -76,3 +76,3 @@ } from 'three'

const cylinderGeometry = new CylinderBufferGeometry(0.5, 0.5, 1, 45)
const cylinderGeometry = new CylinderGeometry(0.5, 0.5, 1, 45)
.translate(0, 0.5, 0)

@@ -150,5 +150,5 @@ .rotateX(Math.PI / 2)

constructor (parent) {
const ballGeom = new SphereBufferGeometry(0.05, 16, 12)
const ballGeom = new SphereGeometry(0.05, 16, 12)
.translate(0, 0, 0.5)
const stickGeom = new CylinderBufferGeometry(0.005, 0.005, 0.5, 6)
const stickGeom = new CylinderGeometry(0.005, 0.005, 0.5, 6)
.translate(0, 0.25, 0).rotateX(Math.PI / 2)

@@ -186,3 +186,3 @@

super(parent, new Mesh(
new PlaneBufferGeometry(),
new PlaneGeometry(),
material

@@ -189,0 +189,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 not supported yet

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