@extrabinoss/three-plot 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -0
- package/dist/fonts/font.json +42988 -0
- package/dist/fonts/font.png +0 -0
- package/dist/three-plot.js +1527 -0
- package/dist/three-plot.umd.cjs +405 -0
- package/dist/vite.svg +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
(function(p,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],h):(p=typeof globalThis<"u"?globalThis:p||self,h(p.ThreePlot={},p.THREE))})(this,(function(p,h){"use strict";function Z(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const r=Z(h),L={type:"change"},S={type:"start"},U={type:"end"},v=new h.Ray,R=new h.Plane,q=Math.cos(70*h.MathUtils.DEG2RAD),d=new h.Vector3,g=2*Math.PI,c={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},M=1e-6;class K extends h.Controls{constructor(t,e=null){super(t,e),this.state=c.NONE,this.target=new h.Vector3,this.cursor=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(t.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=B.bind(this),this._onPointerDown=G.bind(this),this._onPointerUp=H.bind(this),this._onContextMenu=st.bind(this),this._onMouseWheel=J.bind(this),this._onKeyDown=tt.bind(this),this._onTouchStart=et.bind(this),this._onTouchMove=it.bind(this),this._onMouseDown=Q.bind(this),this._onMouseMove=$.bind(this),this._interceptControlDown=nt.bind(this),this._interceptControlUp=ot.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(L),this.update(),this.state=c.NONE}update(t=null){const e=this.object.position;d.copy(e).sub(this.target),d.applyQuaternion(this._quat),this._spherical.setFromVector3(d),this.autoRotate&&this.state===c.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=g:i>Math.PI&&(i-=g),s<-Math.PI?s+=g:s>Math.PI&&(s-=g),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let n=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),n=a!=this._spherical.radius}if(d.setFromSpherical(this._spherical),d.applyQuaternion(this._quatInverse),e.copy(this.target).add(d),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=d.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),n=!!u}else if(this.object.isOrthographicCamera){const l=new h.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),n=u!==this.object.zoom;const f=new h.Vector3(this._mouse.x,this._mouse.y,0);f.unproject(this.object),this.object.position.sub(f).add(l),this.object.updateMatrixWorld(),a=d.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(v.origin.copy(this.object.position),v.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(v.direction))<q?this.object.lookAt(this.target):(R.setFromNormalAndCoplanarPoint(this.object.up,this.target),v.intersectPlane(R,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),n=!0)}return this._scale=1,this._performCursorZoom=!1,n||this._lastPosition.distanceToSquared(this.object.position)>M||8*(1-this._lastQuaternion.dot(this.object.quaternion))>M||this._lastTargetPosition.distanceToSquared(this.target)>M?(this.dispatchEvent(L),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?g/60*this.autoRotateSpeed*t:g/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){d.setFromMatrixColumn(e,0),d.multiplyScalar(-t),this._panOffset.add(d)}_panUp(t,e){this.screenSpacePanning===!0?d.setFromMatrixColumn(e,1):(d.setFromMatrixColumn(e,0),d.crossVectors(this.object.up,d)),d.multiplyScalar(t),this._panOffset.add(d)}_pan(t,e){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;d.copy(s).sub(this.target);let n=d.length();n*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*n/i.clientHeight,this.object.matrix),this._panUp(2*e*n/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=t-i.left,n=e-i.top,a=i.width,l=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(n/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(g*this._rotateDelta.x/e.clientHeight),this._rotateUp(g*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(g*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-g*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(g*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-g*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(i,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,s=t.pageY-e.y,n=Math.sqrt(i*i+s*s);this._dollyStart.set(0,n)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const i=this._getSecondPointerPosition(t),s=.5*(t.pageX+i.x),n=.5*(t.pageY+i.y);this._rotateEnd.set(s,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(g*this._rotateDelta.x/e.clientHeight),this._rotateUp(g*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,s=t.pageY-e.y,n=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,n),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(t.pageX+e.x)*.5,l=(t.pageY+e.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new h.Vector2,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,i={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function G(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function B(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function H(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(U),this.state=c.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function Q(o){let t;switch(o.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=c.DOLLY;break;case h.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=c.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=c.ROTATE}break;case h.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=c.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=c.PAN}break;default:this.state=c.NONE}this.state!==c.NONE&&this.dispatchEvent(S)}function $(o){switch(this.state){case c.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case c.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case c.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function J(o){this.enabled===!1||this.enableZoom===!1||this.state!==c.NONE||(o.preventDefault(),this.dispatchEvent(S),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(U))}function tt(o){this.enabled!==!1&&this._handleKeyDown(o)}function et(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=c.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=c.TOUCH_PAN;break;default:this.state=c.NONE}break;case 2:switch(this.touches.TWO){case h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=c.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=c.TOUCH_DOLLY_ROTATE;break;default:this.state=c.NONE}break;default:this.state=c.NONE}this.state!==c.NONE&&this.dispatchEvent(S)}function it(o){switch(this._trackPointer(o),this.state){case c.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case c.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case c.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case c.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=c.NONE}}function st(o){this.enabled!==!1&&o.preventDefault()}function nt(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ot(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var I=`precision highp float;
|
|
2
|
+
|
|
3
|
+
attribute float instanceIndex;
|
|
4
|
+
|
|
5
|
+
uniform vec2 uResolution;
|
|
6
|
+
uniform float uLineWidth;
|
|
7
|
+
uniform float uTime;
|
|
8
|
+
uniform float uCount;
|
|
9
|
+
uniform float uFrequency;
|
|
10
|
+
uniform float uAmplitude;
|
|
11
|
+
uniform float uPlotWidth;
|
|
12
|
+
uniform float uPreset;
|
|
13
|
+
uniform float uLodFactor;
|
|
14
|
+
uniform vec2 uOffset;
|
|
15
|
+
|
|
16
|
+
varying float vVanish;
|
|
17
|
+
varying float vSide;
|
|
18
|
+
varying float vProgress;
|
|
19
|
+
varying float vSegmentIndex;
|
|
20
|
+
|
|
21
|
+
#define PI 3.14159265359
|
|
22
|
+
|
|
23
|
+
float hash(float n) { return fract(sin(n) * 1e4); }
|
|
24
|
+
float noise(float x) {
|
|
25
|
+
float i = floor(x);
|
|
26
|
+
float f = fract(x);
|
|
27
|
+
float u = f * f * (3.0 - 2.0 * f);
|
|
28
|
+
return mix(hash(i), hash(i + 1.0), u);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
float hash3(vec3 p3) {
|
|
32
|
+
p3 = fract(p3 * .1031);
|
|
33
|
+
p3 += dot(p3, p3.zyx + 31.32);
|
|
34
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
float noise3D(in vec3 x) {
|
|
38
|
+
vec3 i = floor(x);
|
|
39
|
+
vec3 f = fract(x);
|
|
40
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
41
|
+
return mix(mix(mix(hash3(i + vec3(0,0,0)), hash3(i + vec3(1,0,0)), f.x),
|
|
42
|
+
mix(hash3(i + vec3(0,1,0)), hash3(i + vec3(1,1,0)), f.x), f.y),
|
|
43
|
+
mix(mix(hash3(i + vec3(0,0,1)), hash3(i + vec3(1,0,1)), f.x),
|
|
44
|
+
mix(hash3(i + vec3(0,1,1)), hash3(i + vec3(1,1,1)), f.x), f.y), f.z);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
vec4 getPlotPos(float index) {
|
|
48
|
+
|
|
49
|
+
float halfW = uPlotWidth * 0.5;
|
|
50
|
+
float x = (index / max(uCount - 1.0, 1.0)) * uPlotWidth - halfW;
|
|
51
|
+
|
|
52
|
+
float t = x * uFrequency + uTime;
|
|
53
|
+
int preset = int(uPreset + 0.5);
|
|
54
|
+
float y = 0.0;
|
|
55
|
+
if (preset == 0) y = sin(t) * uAmplitude;
|
|
56
|
+
else if (preset == 1) y = (fract(t / (2.0 * PI)) * 2.0 - 1.0) * uAmplitude;
|
|
57
|
+
else if (preset == 2) y = (abs(fract(t / (2.0 * PI)) * 2.0 - 1.0) * 2.0 - 1.0) * uAmplitude;
|
|
58
|
+
else if (preset == 3) y = (step(0.5, fract(t / (2.0 * PI))) * 2.0 - 1.0) * uAmplitude;
|
|
59
|
+
else if (preset == 4) {
|
|
60
|
+
y = (sin(t) + sin(t * 2.1) * 0.5 + sin(t * 0.5) * 1.5) * uAmplitude * 0.5;
|
|
61
|
+
y += cos(t * 0.2) * uAmplitude * 0.3;
|
|
62
|
+
}
|
|
63
|
+
else if (preset == 5) {
|
|
64
|
+
y = (sin(t) * cos(t * 1.1 + uTime) * sin(t * 0.5 - uTime * 0.5)) * uAmplitude * 2.0;
|
|
65
|
+
}
|
|
66
|
+
else if (preset == 6) {
|
|
67
|
+
y = (noise(t) * 2.0 - 1.0) * uAmplitude;
|
|
68
|
+
}
|
|
69
|
+
else if (preset == 7) {
|
|
70
|
+
|
|
71
|
+
y = (noise3D(vec3(x * uFrequency * 0.5, 0.0, uTime * 0.5)) * 2.0 - 1.0) * uAmplitude;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
|
|
75
|
+
y = 0.0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return vec4(x + uOffset.x, y + uOffset.y, 0.0, 1.0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void main() {
|
|
82
|
+
vVanish = 0.0;
|
|
83
|
+
vSide = position.y;
|
|
84
|
+
|
|
85
|
+
if (instanceIndex >= uCount - 1.0 || instanceIndex > uCount * uLodFactor) {
|
|
86
|
+
vVanish = 1.0;
|
|
87
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
mat4 mvp = projectionMatrix * modelViewMatrix;
|
|
92
|
+
vec4 worldP0 = getPlotPos(instanceIndex);
|
|
93
|
+
vec4 worldP1 = getPlotPos(instanceIndex + 1.0);
|
|
94
|
+
|
|
95
|
+
vec4 clipP0 = mvp * worldP0;
|
|
96
|
+
vec4 clipP1 = mvp * worldP1;
|
|
97
|
+
|
|
98
|
+
vec2 screenP0 = (clipP0.xy / clipP0.w + 1.0) * 0.5 * uResolution;
|
|
99
|
+
vec2 screenP1 = (clipP1.xy / clipP1.w + 1.0) * 0.5 * uResolution;
|
|
100
|
+
|
|
101
|
+
vec2 dir = normalize(screenP1 - screenP0);
|
|
102
|
+
vec2 normal = vec2(-dir.y, dir.x);
|
|
103
|
+
|
|
104
|
+
vec4 clipAmp = mvp * vec4(0.0, uAmplitude, 0.0, 0.0);
|
|
105
|
+
float ampPixels = length((clipAmp.xy / clipAmp.w) * uResolution * 0.5);
|
|
106
|
+
float effectiveLineWidth = min(uLineWidth, max(ampPixels * 0.2, 0.5));
|
|
107
|
+
|
|
108
|
+
float t = position.x + 0.5;
|
|
109
|
+
vProgress = t;
|
|
110
|
+
vSegmentIndex = instanceIndex;
|
|
111
|
+
|
|
112
|
+
vec2 currentScreen = mix(screenP0, screenP1, t);
|
|
113
|
+
currentScreen += normal * position.y * effectiveLineWidth * 2.0;
|
|
114
|
+
|
|
115
|
+
gl_Position = vec4((currentScreen / uResolution * 2.0 - 1.0), 0.0, 1.0);
|
|
116
|
+
}`,at=`precision highp float;
|
|
117
|
+
uniform vec3 uColor;
|
|
118
|
+
uniform vec3 uOutlineColor;
|
|
119
|
+
uniform float uOutlineWidth;
|
|
120
|
+
uniform float uLineWidth;
|
|
121
|
+
uniform float uDashScale;
|
|
122
|
+
uniform float uTime;
|
|
123
|
+
|
|
124
|
+
varying float vVanish;
|
|
125
|
+
varying float vSide;
|
|
126
|
+
varying float vProgress;
|
|
127
|
+
varying float vSegmentIndex;
|
|
128
|
+
|
|
129
|
+
void main() {
|
|
130
|
+
if (vVanish > 0.5) discard;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if (uDashScale > 0.0) {
|
|
134
|
+
float dashPos = (vSegmentIndex + vProgress) * uDashScale;
|
|
135
|
+
if (fract(dashPos) > 0.5) discard;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
float dist = abs(vSide) * 2.0;
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
float blur = 1.5 / max(uLineWidth, 1.0);
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
float innerEdge = 1.0 - uOutlineWidth;
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
float alpha = smoothstep(1.0, 1.0 - blur, dist);
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
vec3 baseColor = uColor;
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
float innerAlpha = smoothstep(innerEdge, innerEdge - blur, dist);
|
|
158
|
+
vec3 color = mix(uOutlineColor, baseColor, innerAlpha);
|
|
159
|
+
|
|
160
|
+
gl_FragColor = vec4(color, alpha);
|
|
161
|
+
}`;class x{instancedMesh;geometry;material;params;static customInjection="";constructor(t,e=new r.Color(65416)){this.params={count:t,frequency:.1,amplitude:20,width:400,presetIndex:0,color:e.clone(),lodFactor:1,pointSize:2};const i=new r.PlaneGeometry(1,1);this.geometry=new r.InstancedBufferGeometry,this.geometry.index=i.index,i.attributes.position&&this.geometry.setAttribute("position",i.attributes.position);const s=new Float32Array(t);for(let u=0;u<t;u++)s[u]=u;this.geometry.setAttribute("instanceIndex",new r.InstancedBufferAttribute(s,1));const n=/else\s*{\s*y\s*=\s*0\.0;\s*}/g,a=I.replace(n,x.customInjection||"else { y = 0.0; }");this.material=new r.ShaderMaterial({uniforms:{uTime:{value:0},uCount:{value:Number(t)},uFrequency:{value:this.params.frequency},uAmplitude:{value:this.params.amplitude},uPlotWidth:{value:400},uPreset:{value:Number(this.params.presetIndex)},uColor:{value:e.clone()},uLodFactor:{value:1},uResolution:{value:new r.Vector2(100,100)},uLineWidth:{value:2},uOutlineColor:{value:new r.Color(0)},uOutlineWidth:{value:0},uDashScale:{value:0},uOffset:{value:new r.Vector2(0,0)}},vertexShader:a,fragmentShader:at,transparent:!1,depthWrite:!1,depthTest:!1,blending:r.AdditiveBlending}),this.instancedMesh=new r.InstancedMesh(this.geometry,this.material,t),this.instancedMesh.frustumCulled=!1;const l=new r.Object3D;l.updateMatrix();for(let u=0;u<t;u++)this.instancedMesh.setMatrixAt(u,l.matrix)}setParams(t){return this.params={...this.params,...t},this}color(t){return this.setParams({color:t})}amplitude(t){return this.setParams({amplitude:t})}frequency(t){return this.setParams({frequency:t})}width(t){return this.setParams({width:t})}offset(t,e){return this.setParams({offset:{x:t,y:e}})}preset(t){return this.setParams({presetIndex:t})}injectPresets(t){let e="",i=8;t.forEach((a,l)=>{e+=`else if (preset == ${i}) { // ${l}
|
|
162
|
+
y = ${a};
|
|
163
|
+
}
|
|
164
|
+
`,i++}),e+="else { y = 0.0; }",x.customInjection=e;const s=/else\s*{\s*y\s*=\s*0\.0;\s*}/g,n=I.replace(s,e);this.material.vertexShader!==n&&(this.material.vertexShader=n,this.material.needsUpdate=!0)}update(t,e){const i=this.material.uniforms;if(!i)return;e&&i.uResolution.value.set(e.pixelWidth,e.pixelHeight);const s=this.params,n=s.autoUpdate!==!1?t:0;this.updateUniform(i.uTime,n),this.updateUniform(i.uFrequency,s.frequency),this.updateUniform(i.uAmplitude,s.amplitude),this.updateUniform(i.uPlotWidth,s.width??400),this.updateUniform(i.uPreset,Number(s.presetIndex)),this.updateUniform(i.uLodFactor,s.lodFactor??1),this.updateUniform(i.uLineWidth,s.pointSize??2),s.color!==void 0&&i.uColor.value.set(s.color),s.borderColor!==void 0&&i.uOutlineColor.value.set(s.borderColor),this.updateUniform(i.uOutlineWidth,s.borderWidth??0),this.updateUniform(i.uDashScale,s.dashScale??0),s.offset&&i.uOffset.value.set(s.offset.x,s.offset.y);const a=this.calculateEffectiveCount(s,e);this.updateUniform(i.uCount,a),this.instancedMesh.count=Math.max(0,a)}updateUniform(t,e){t.value!==e&&(t.value=e)}calculateEffectiveCount(t,e){if(!e)return t.count;const n=(t.width??400)/Math.max(e.maxX-e.minX,.001),a=Math.ceil(e.pixelWidth*2*n);return Math.min(t.count,a)}get mesh(){return this.instancedMesh}getDrawStats(){return{total:this.params.count,visible:this.instancedMesh.count}}dispose(){this.geometry.dispose(),Array.isArray(this.material)?this.material.forEach(t=>t.dispose()):this.material.dispose()}}var W=`precision highp float;
|
|
165
|
+
attribute float pIndex;
|
|
166
|
+
uniform float uTime;
|
|
167
|
+
uniform float uCount;
|
|
168
|
+
uniform float uFrequency;
|
|
169
|
+
uniform float uAmplitude;
|
|
170
|
+
uniform float uPlotWidth;
|
|
171
|
+
uniform float uPreset;
|
|
172
|
+
uniform float uPointSize;
|
|
173
|
+
uniform float uLodFactor;
|
|
174
|
+
uniform float uAdaptive;
|
|
175
|
+
uniform vec2 uOffset;
|
|
176
|
+
|
|
177
|
+
#define PI 3.14159265359
|
|
178
|
+
|
|
179
|
+
float hash(float n) { return fract(sin(n) * 1e4); }
|
|
180
|
+
float noise(float x) {
|
|
181
|
+
float i = floor(x);
|
|
182
|
+
float f = fract(x);
|
|
183
|
+
float u = f * f * (3.0 - 2.0 * f);
|
|
184
|
+
return mix(hash(i), hash(i + 1.0), u);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
float hash3(vec3 p3) {
|
|
188
|
+
p3 = fract(p3 * .1031);
|
|
189
|
+
p3 += dot(p3, p3.zyx + 31.32);
|
|
190
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
float noise3D(in vec3 x) {
|
|
194
|
+
vec3 i = floor(x);
|
|
195
|
+
vec3 f = fract(x);
|
|
196
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
197
|
+
return mix(mix(mix(hash3(i + vec3(0,0,0)), hash3(i + vec3(1,0,0)), f.x),
|
|
198
|
+
mix(hash3(i + vec3(0,1,0)), hash3(i + vec3(1,1,0)), f.x), f.y),
|
|
199
|
+
mix(mix(hash3(i + vec3(0,0,1)), hash3(i + vec3(1,0,1)), f.x),
|
|
200
|
+
mix(hash3(i + vec3(0,1,1)), hash3(i + vec3(1,1,1)), f.x), f.y), f.z);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
void main() {
|
|
204
|
+
if (pIndex > uCount * uLodFactor) {
|
|
205
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
float halfW = uPlotWidth * 0.5;
|
|
210
|
+
float x = (pIndex / max(uCount - 1.0, 1.0)) * uPlotWidth - halfW;
|
|
211
|
+
float y = 0.0;
|
|
212
|
+
|
|
213
|
+
int preset = int(uPreset + 0.5);
|
|
214
|
+
float t = x * uFrequency + uTime;
|
|
215
|
+
|
|
216
|
+
if (preset == 0) y = sin(t) * uAmplitude;
|
|
217
|
+
else if (preset == 1) y = (fract(t / (2.0 * PI)) * 2.0 - 1.0) * uAmplitude;
|
|
218
|
+
else if (preset == 2) y = (abs(fract(t / (2.0 * PI)) * 2.0 - 1.0) * 2.0 - 1.0) * uAmplitude;
|
|
219
|
+
else if (preset == 3) y = (step(0.5, fract(t / (2.0 * PI))) * 2.0 - 1.0) * uAmplitude;
|
|
220
|
+
else if (preset == 4) {
|
|
221
|
+
y = (sin(t) + sin(t * 2.1) * 0.5 + sin(t * 0.5) * 1.5) * uAmplitude * 0.5;
|
|
222
|
+
y += cos(t * 0.2) * uAmplitude * 0.3;
|
|
223
|
+
}
|
|
224
|
+
else if (preset == 5) {
|
|
225
|
+
y = (sin(t) * cos(t * 1.1 + uTime) * sin(t * 0.5 - uTime * 0.5)) * uAmplitude * 2.0;
|
|
226
|
+
}
|
|
227
|
+
else if (preset == 6) {
|
|
228
|
+
y = (noise(t) * 2.0 - 1.0) * uAmplitude;
|
|
229
|
+
}
|
|
230
|
+
else if (preset == 7) {
|
|
231
|
+
y = (noise3D(vec3(x * uFrequency * 0.5, 0.0, uTime * 0.5)) * 2.0 - 1.0) * uAmplitude;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
y = 0.0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
vec4 worldPos = vec4(x + uOffset.x, y + uOffset.y, 0.0, 1.0);
|
|
238
|
+
vec4 mvPosition = modelViewMatrix * worldPos;
|
|
239
|
+
gl_PointSize = uPointSize;
|
|
240
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
241
|
+
}`,rt=`precision mediump float;
|
|
242
|
+
uniform vec3 uColor;
|
|
243
|
+
|
|
244
|
+
void main() {
|
|
245
|
+
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
|
|
246
|
+
float r = dot(cxy, cxy);
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
if (r > 1.0) discard;
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
float alpha = smoothstep(1.0, 0.5, r);
|
|
253
|
+
gl_FragColor = vec4(uColor, alpha);
|
|
254
|
+
}`;class b{points;geometry;material;params;static customInjection="";constructor(t,e=new r.Color(65416)){this.params={count:t,frequency:.1,amplitude:20,width:400,presetIndex:0,color:e.clone(),lodFactor:1,pointSize:5,adaptive:!0,autoSubsampling:!0,autoCulling:!0},this.geometry=this.initGeometry(t),this.material=this.initMaterial(t,e),this.points=new r.Points(this.geometry,this.material),this.points.frustumCulled=!1}initGeometry(t){const e=new r.BufferGeometry,i=new Float32Array(t);for(let s=0;s<t;s++)i[s]=s;return e.setAttribute("pIndex",new r.BufferAttribute(i,1)),e.setDrawRange(0,t),e}initMaterial(t,e){const i=/else\s*{\s*y\s*=\s*0\.0;\s*}/g,s=W.replace(i,b.customInjection||"else { y = 0.0; }");return new r.ShaderMaterial({uniforms:{uTime:{value:0},uCount:{value:Number(t)},uFrequency:{value:this.params.frequency},uAmplitude:{value:this.params.amplitude},uPlotWidth:{value:400},uPreset:{value:Number(this.params.presetIndex)},uPointSize:{value:this.params.pointSize},uColor:{value:e.clone()},uAdaptive:{value:1},uLodFactor:{value:1},uOffset:{value:new r.Vector2(0,0)}},vertexShader:s,fragmentShader:rt,transparent:!1,depthWrite:!1,depthTest:!1,blending:r.AdditiveBlending})}setParams(t){return this.params={...this.params,...t},this}color(t){return this.setParams({color:t})}amplitude(t){return this.setParams({amplitude:t})}frequency(t){return this.setParams({frequency:t})}width(t){return this.setParams({width:t})}offset(t,e){return this.setParams({offset:{x:t,y:e}})}preset(t){return this.setParams({presetIndex:t})}size(t){return this.setParams({pointSize:t})}adaptive(t){return this.setParams({adaptive:t})}injectPresets(t){let e="",i=8;t.forEach((a,l)=>{e+=`else if (preset == ${i}) { // ${l}
|
|
255
|
+
y = ${a};
|
|
256
|
+
}
|
|
257
|
+
`,i++}),e+="else { y = 0.0; }",b.customInjection=e;const s=/else\s*{\s*y\s*=\s*0\.0;\s*}/g,n=W.replace(s,e);this.material.vertexShader!==n&&(this.material.vertexShader=n,this.material.needsUpdate=!0)}update(t,e){const i=this.material.uniforms;if(!i)return;const s=this.params,n=s.autoUpdate!==!1?t:0;this.updateUniform(i.uTime,n),this.updateUniform(i.uFrequency,s.frequency),this.updateUniform(i.uAmplitude,s.amplitude),this.updateUniform(i.uPlotWidth,s.width??400),this.updateUniform(i.uPreset,Number(s.presetIndex)),this.updateUniform(i.uLodFactor,s.lodFactor??1),this.updateUniform(i.uAdaptive,s.adaptive?1:0),s.color!==void 0&&i.uColor.value.set(s.color),s.offset&&i.uOffset.value.set(s.offset.x,s.offset.y);const a=this.calculateEffectiveCount(s,e),{drawStart:l,drawCount:u}=this.calculateDrawRange(a,s,e),f=this.calculatePointSize(s.pointSize??5,s.count,s.adaptive??!0);this.updateUniform(i.uPointSize,f),this.updateUniform(i.uCount,a),this.geometry.setDrawRange(l,u)}updateUniform(t,e){t.value!==e&&(t.value=e)}calculateEffectiveCount(t,e){if(!(t.autoSubsampling??!0)||!e)return t.count;const i=t.pointsPerPixel||2,n=(t.width??400)/Math.max(e.maxX-e.minX,.001);return Math.min(t.count,Math.ceil(e.pixelWidth*i*n))}calculateDrawRange(t,e,i){if(!(e.autoCulling??!0)||!i)return{drawStart:0,drawCount:t};const s=e.width??400,n=-(s*.5),a=(i.minX-n)/s,l=(i.maxX-n)/s,u=Math.max(0,Math.floor(a*(t-1))),f=Math.min(t-1,Math.ceil(l*(t-1)));return{drawStart:u,drawCount:Math.max(1,f-u+1)}}calculatePointSize(t,e,i){return i?Math.max(.1,t*Math.sqrt(1e5/e)):t}get mesh(){return this.points}getDrawStats(){return{total:this.params.count,visible:this.geometry.drawRange.count}}dispose(){this.geometry.dispose(),Array.isArray(this.material)?this.material.forEach(t=>t.dispose()):this.material.dispose()}}var ht=`varying vec2 vUv;
|
|
258
|
+
varying vec3 vWorldPos;
|
|
259
|
+
|
|
260
|
+
void main() {
|
|
261
|
+
vUv = uv;
|
|
262
|
+
vWorldPos = (modelMatrix * vec4(position, 1.0)).xyz;
|
|
263
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
264
|
+
}`,lt=`precision highp float;
|
|
265
|
+
|
|
266
|
+
varying vec3 vWorldPos;
|
|
267
|
+
|
|
268
|
+
uniform vec3 uColor;
|
|
269
|
+
uniform vec2 uOffset;
|
|
270
|
+
uniform float uZoom;
|
|
271
|
+
uniform float uThickness;
|
|
272
|
+
uniform float uTickStep;
|
|
273
|
+
uniform float uTickSize;
|
|
274
|
+
uniform float uSubTicks;
|
|
275
|
+
uniform float uSubTickSize;
|
|
276
|
+
uniform vec2 uRangeX;
|
|
277
|
+
uniform vec2 uRangeY;
|
|
278
|
+
|
|
279
|
+
float getLine(float d, float width) {
|
|
280
|
+
float fw = fwidth(d);
|
|
281
|
+
return smoothstep(width + fw, width - fw, abs(d));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
float getPeriodicTicks(float pos, float step, float width) {
|
|
285
|
+
float fw = fwidth(pos);
|
|
286
|
+
float dist = abs(fract(pos / step + 0.5) - 0.5) * step;
|
|
287
|
+
return smoothstep(width + fw, width - fw, dist);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
void main() {
|
|
291
|
+
vec2 relPos = vWorldPos.xy - uOffset;
|
|
292
|
+
float plotHeight = uRangeY.y - uRangeY.x;
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
float pixelSize = 1.0 / uZoom;
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
float lineAlpha = clamp(uThickness, 0.0, 1.0);
|
|
300
|
+
float tickAlpha = clamp(uThickness * 0.8, 0.0, 1.0);
|
|
301
|
+
float subTickAlpha = clamp(uThickness * 0.5, 0.0, 1.0);
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
float lineW = max(uThickness, 1.0) * pixelSize * 0.5;
|
|
305
|
+
float tickW = max(uThickness * 0.8, 0.8) * pixelSize * 0.5;
|
|
306
|
+
float subTickW = max(uThickness * 0.5, 0.5) * pixelSize * 0.5;
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
float maxW = plotHeight * 0.05;
|
|
310
|
+
lineW = min(lineW, maxW);
|
|
311
|
+
tickW = min(tickW, maxW);
|
|
312
|
+
subTickW = min(subTickW, maxW);
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
float yAxis = 0.0;
|
|
316
|
+
if (relPos.y >= uRangeY.x - 1.0 && relPos.y <= uRangeY.y + 1.0) {
|
|
317
|
+
yAxis = getLine(relPos.x - uRangeX.x, lineW) * lineAlpha;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
float xAxis = 0.0;
|
|
321
|
+
if (relPos.x >= uRangeX.x - 1.0 && relPos.x <= uRangeX.y + 1.0) {
|
|
322
|
+
xAxis = getLine(relPos.y, lineW) * lineAlpha;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
float currentTickSize = min(uTickSize * pixelSize, plotHeight * 0.1);
|
|
327
|
+
float currentSubTickSize = min(uSubTickSize * pixelSize, plotHeight * 0.05);
|
|
328
|
+
|
|
329
|
+
float yTicks = 0.0;
|
|
330
|
+
float ySubTicks = 0.0;
|
|
331
|
+
if (relPos.y >= uRangeY.x && relPos.y <= uRangeY.y) {
|
|
332
|
+
|
|
333
|
+
if (relPos.x >= uRangeX.x && relPos.x <= uRangeX.x + currentTickSize) {
|
|
334
|
+
yTicks = getPeriodicTicks(relPos.y, uTickStep, tickW) * tickAlpha;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (uSubTicks > 1.0 && relPos.x >= uRangeX.x && relPos.x <= uRangeX.x + currentSubTickSize) {
|
|
338
|
+
ySubTicks = getPeriodicTicks(relPos.y, uTickStep / uSubTicks, subTickW) * 0.6 * subTickAlpha;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
float xTicks = 0.0;
|
|
343
|
+
float xSubTicks = 0.0;
|
|
344
|
+
if (relPos.x >= uRangeX.x && relPos.x <= uRangeX.y) {
|
|
345
|
+
|
|
346
|
+
if (abs(relPos.y) < currentTickSize) {
|
|
347
|
+
xTicks = getPeriodicTicks(relPos.x, uTickStep, tickW) * tickAlpha;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (uSubTicks > 1.0 && abs(relPos.y) < currentSubTickSize) {
|
|
351
|
+
xSubTicks = getPeriodicTicks(relPos.x, uTickStep / uSubTicks, subTickW) * 0.6 * subTickAlpha;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
float combinedTicks = max(max(xTicks, yTicks), max(xSubTicks, ySubTicks));
|
|
356
|
+
float finalAlpha = max(max(xAxis, yAxis), combinedTicks);
|
|
357
|
+
|
|
358
|
+
if (finalAlpha < 0.01) discard;
|
|
359
|
+
|
|
360
|
+
gl_FragColor = vec4(uColor, finalAlpha * 0.8);
|
|
361
|
+
}`;const ct=`
|
|
362
|
+
attribute vec4 aUvOffset;
|
|
363
|
+
attribute vec3 aColor;
|
|
364
|
+
varying vec2 vUv;
|
|
365
|
+
varying vec3 vColor;
|
|
366
|
+
|
|
367
|
+
void main() {
|
|
368
|
+
vUv = uv * aUvOffset.zw + aUvOffset.xy;
|
|
369
|
+
vColor = aColor;
|
|
370
|
+
gl_Position = projectionMatrix * modelViewMatrix * instanceMatrix * vec4(position, 1.0);
|
|
371
|
+
}
|
|
372
|
+
`,ut=`
|
|
373
|
+
varying vec2 vUv;
|
|
374
|
+
varying vec3 vColor;
|
|
375
|
+
uniform sampler2D uMap;
|
|
376
|
+
|
|
377
|
+
float median(float r, float g, float b) {
|
|
378
|
+
return max(min(r, g), min(max(r, g), b));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
float contour(in float d, in float w) {
|
|
382
|
+
return smoothstep(0.5 - w, 0.5 + w, d);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
float samp(in vec2 uv, float w) {
|
|
386
|
+
return contour(median(texture2D(uMap, uv).r, texture2D(uMap, uv).g, texture2D(uMap, uv).b), w);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
void main() {
|
|
390
|
+
vec3 msdfSample = texture2D(uMap, vUv).rgb;
|
|
391
|
+
float dist = median(msdfSample.r, msdfSample.g, msdfSample.b);
|
|
392
|
+
float width = fwidth(dist);
|
|
393
|
+
float alpha = contour(dist, width);
|
|
394
|
+
|
|
395
|
+
float dscale = 0.354;
|
|
396
|
+
vec2 duv = dscale * (dFdx(vUv) + dFdy(vUv));
|
|
397
|
+
vec4 box = vec4(vUv - duv, vUv + duv);
|
|
398
|
+
|
|
399
|
+
float asum = samp(box.xy, width) + samp(box.zw, width) + samp(box.xw, width) + samp(box.zy, width);
|
|
400
|
+
float opacity = (alpha + 0.5 * asum) / 3.0;
|
|
401
|
+
|
|
402
|
+
if (opacity < 0.01) discard;
|
|
403
|
+
gl_FragColor = vec4(vColor, opacity);
|
|
404
|
+
}
|
|
405
|
+
`;class Y{mesh;material;charMap=new Map;fontData=null;instances=[];capacity;constructor(t=100){this.capacity=t,this.material=new r.ShaderMaterial({vertexShader:ct,fragmentShader:ut,uniforms:{uMap:{value:null}},transparent:!0,side:r.DoubleSide,depthWrite:!1}),this.mesh=this.createMesh(this.capacity)}createMesh(t){const e=new r.PlaneGeometry(1,1);e.setAttribute("aUvOffset",new r.InstancedBufferAttribute(new Float32Array(t*4),4)),e.setAttribute("aColor",new r.InstancedBufferAttribute(new Float32Array(t*3),3));const i=new r.InstancedMesh(e,this.material,t);return i.count=0,i.frustumCulled=!1,i}grow(t){const e=Math.max(Math.ceil(t*1.05),t+10),i=this.mesh,s=this.createMesh(e);i.parent&&(i.parent.add(s),i.parent.remove(i)),i.geometry.dispose(),this.mesh=s,this.capacity=e}async load(t,e){const[i,s]=await Promise.all([fetch(t).then(n=>n.json()),new r.TextureLoader().loadAsync(e)]);this.fontData=i,this.fontData&&this.fontData.chars&&this.fontData.chars.forEach(n=>this.charMap.set(n.char,n)),s.minFilter=r.LinearFilter,s.magFilter=r.LinearFilter,s.generateMipmaps=!1,this.material.uniforms.uMap&&(this.material.uniforms.uMap.value=s)}addText(t,e,i,s=.1,n="#ffffff",a="left"){return this.instances.push({text:t,position:new r.Vector3(e,i,0),scale:s,color:new r.Color(n),align:a}),this}clear(){this.instances=[]}update(){if(!this.fontData)return;let t=0;for(const _ of this.instances)t+=_.text.length;t>this.capacity&&this.grow(t);let e=0;const i=this.mesh.instanceMatrix.array,s=this.mesh.geometry.getAttribute("aUvOffset"),n=s.array,a=this.mesh.geometry.getAttribute("aColor"),l=a.array,u=this.fontData.common.scaleW,f=this.fontData.common.scaleH,mt=this.charMap;for(const _ of this.instances){const D=_.text,ft=D.length,P=_.scale,A=_.position,k=_.color;let O=0;const V=this.calculateWidth(D)*P;let C=0;_.align==="center"?C=-V/2:_.align==="right"&&(C=-V);for(let z=0;z<ft&&!(e>=this.capacity);z++){const j=D[z];if(j===void 0)continue;const y=mt.get(j);if(!y){j===" "&&(O+=20);continue}const m=e*16,pt=y.width*P,gt=y.height*P,yt=A.x+C+(O+y.xoffset+y.width/2)*P,_t=A.y-(y.yoffset+y.height/2)*P;i[m+0]=pt,i[m+1]=0,i[m+2]=0,i[m+3]=0,i[m+4]=0,i[m+5]=gt,i[m+6]=0,i[m+7]=0,i[m+8]=0,i[m+9]=0,i[m+10]=1,i[m+11]=0,i[m+12]=yt,i[m+13]=_t,i[m+14]=A.z,i[m+15]=1;const w=e*4;n[w+0]=y.x/u,n[w+1]=1-(y.y+y.height)/f,n[w+2]=y.width/u,n[w+3]=y.height/f;const E=e*3;l[E+0]=k.r,l[E+1]=k.g,l[E+2]=k.b,O+=y.xadvance,e++}}this.mesh.count=e,this.mesh.instanceMatrix.needsUpdate=!0,s.needsUpdate=!0,a.needsUpdate=!0}calculateWidth(t){if(!this.fontData)return 0;let e=0;const i=this.charMap;for(let s=0;s<t.length;s++){const n=t[s];n!==void 0&&(e+=i.get(n)?.xadvance??20)}return e}getStats(){return{count:this.mesh.count,capacity:this.capacity}}get meshObj(){return this.mesh}}class T{engine;params={offset:{x:0,y:0}};constructor(t=100){this.engine=new Y(t)}async load(t,e){await this.engine.load(t,e)}add(t,e,i,s=.1,n="#ffffff",a="left"){return this.engine.addText(t,e,i,s,n,a),this}setParams(t){return this.params={...this.params,...t},this}update(t,e){this.engine.update()}get mesh(){return this.engine.meshObj}getDrawStats(){const t=this.engine.getStats();return{total:t.capacity,visible:t.count}}clear(){return this.engine.clear(),this}dispose(){this.engine.meshObj.geometry.dispose(),Array.isArray(this.engine.meshObj.material)?this.engine.meshObj.material.forEach(t=>t.dispose()):this.engine.meshObj.material.dispose()}}class X{meshObj;geometry;material;params;textEngine;constructor(t="#ffffff"){this.params={color:new r.Color(t),offset:{x:0,y:0},tickStep:50,tickSize:8,subTicks:0,subTickSize:4,minX:-200,maxX:200,minY:-50,maxY:50,labelSize:.06,labelColor:"#888888",showLabels:!1,labelPrecision:0,thickness:1.5},this.geometry=new r.PlaneGeometry(4e3,4e3),this.material=new r.ShaderMaterial({uniforms:{uColor:{value:this.params.color},uOffset:{value:new r.Vector2(0,0)},uTickStep:{value:50},uTickSize:{value:8},uSubTicks:{value:0},uSubTickSize:{value:4},uRangeX:{value:new r.Vector2(-200,200)},uRangeY:{value:new r.Vector2(-50,50)},uZoom:{value:1},uThickness:{value:1.5}},vertexShader:ht,fragmentShader:lt,transparent:!0,depthWrite:!1,blending:r.AdditiveBlending}),this.meshObj=new r.Mesh(this.geometry,this.material),this.meshObj.position.z=-.1}setParams(t){return this.params={...this.params,...t},this}color(t){return this.setParams({color:t})}offset(t,e){return this.setParams({offset:{x:t,y:e}})}ticks(t,e=8){return this.setParams({tickStep:t,tickSize:e})}subTicks(t,e=4){return this.setParams({subTicks:t,subTickSize:e})}precision(t){return this.setParams({labelPrecision:t})}rangeY(t,e){return this.setParams({minY:t,maxY:e})}rangeX(t,e){return this.setParams({minX:t,maxX:e})}thickness(t){return this.setParams({thickness:t})}labels(t,e=.06,i="#888"){return this.textEngine=t,this.setParams({showLabels:!0,labelSize:e,labelColor:i})}displayLabels(t){return this.setParams({showLabels:t})}update(t,e){const i=this.material.uniforms;if(!i)return;const s=this.params;s.color!==void 0&&i.uColor.value.set(s.color),i.uOffset.value.set(s.offset.x,s.offset.y),i.uRangeX.value.set(s.minX,s.maxX),i.uRangeY.value.set(s.minY,s.maxY),this.updateUniform(i.uTickStep,s.tickStep),this.updateUniform(i.uTickSize,s.tickSize),this.updateUniform(i.uSubTicks,s.subTicks),this.updateUniform(i.uSubTickSize,s.subTickSize),this.updateUniform(i.uZoom,e.zoom),this.updateUniform(i.uThickness,s.thickness),this.meshObj.position.x=e.minX+(e.maxX-e.minX)/2,this.meshObj.position.y=s.offset.y,s.showLabels&&this.textEngine&&this.renderLabels()}renderLabels(){if(!this.textEngine)return;const t=this.params,e=this.textEngine,i=t.offset.x,s=t.offset.y,n=t.labelPrecision,a=t.minX+i-4;e.add(t.maxY.toFixed(n),a,s+t.maxY,t.labelSize,t.labelColor,"right"),e.add(0 .toFixed(n),a,s,t.labelSize,t.labelColor,"right"),e.add(t.minY.toFixed(n),a,s+t.minY,t.labelSize,t.labelColor,"right");const l=t.tickStep,u=Math.ceil(t.minX/l)*l;for(let f=u;f<=t.maxX;f+=l)Math.abs(f-t.minX)<10||e.add(f.toFixed(n),f+i,s-8,t.labelSize*.8,t.labelColor,"center")}updateUniform(t,e){t.value!==e&&(t.value=e)}get mesh(){return this.meshObj}getDrawStats(){return{total:1,visible:1}}dispose(){this.geometry.dispose(),this.material.dispose()}}class F{params;textEngine;dummyMesh;constructor(){this.params={minX:-200,maxX:200,minY:-50,maxY:50,color:"#ffffff",size:.08,precision:1,showMin:!0,showMax:!0,showRangeX:!1,position:"right",offset:{x:0,y:0}},this.dummyMesh=new r.Object3D}setParams(t){return this.params={...this.params,...t},this}rangeY(t,e){return this.setParams({minY:t,maxY:e})}rangeX(t,e){return this.setParams({minX:t,maxX:e})}color(t){return this.setParams({color:t})}size(t){return this.setParams({size:t})}precision(t){return this.setParams({precision:t})}side(t){return this.setParams({position:t})}showMinMax(t,e){return this.setParams({showMin:t,showMax:e})}showRangeX(t){return this.setParams({showRangeX:t})}use(t){return this.textEngine=t,this}update(t,e){if(!this.textEngine)return;const i=this.params,s=this.textEngine,n=i.precision,a=i.offset;if(i.position==="left"||i.position==="both"){const l=i.minX+a.x-5;i.showMax&&s.add(i.maxY.toFixed(n),l,i.maxY+a.y,i.size,i.color,"right"),i.showMin&&s.add(i.minY.toFixed(n),l,i.minY+a.y,i.size,i.color,"right")}if(i.position==="right"||i.position==="both"){const l=i.maxX+a.x+5;i.showMax&&s.add(i.maxY.toFixed(n),l,i.maxY+a.y,i.size,i.color,"left"),i.showMin&&s.add(i.minY.toFixed(n),l,i.minY+a.y,i.size,i.color,"left")}i.showRangeX&&(s.add(i.minX.toFixed(n),i.minX+a.x,i.minY+a.y-12,i.size*.8,i.color,"center"),s.add(i.maxX.toFixed(n),i.maxX+a.x,i.minY+a.y-12,i.size*.8,i.color,"center"))}get mesh(){return this.dummyMesh}getDrawStats(){return{total:0,visible:0}}dispose(){}}class N{scene;camera;renderer;controls;container;animationId=null;resizeObserver;isExternalRenderer=!1;autoRender=!0;plots=new Set;textPlots=new Set;fontConfig;customPresets=new Map;onUpdate;constructor(t,e={}){this.container=t,this.autoRender=e.autoRender!==!1,this.fontConfig=e.font,this.scene=e.scene||new r.Scene,e.scene||(this.scene.background=new r.Color(657930));const i=this.container.clientWidth,s=this.container.clientHeight,n=i/s,a=250;this.camera=e.camera||new r.OrthographicCamera(-a*n,a*n,a,-a,.1,2e3),e.camera||this.camera.position.set(0,0,500),e.renderer?(this.renderer=e.renderer,this.isExternalRenderer=!0):(this.renderer=new r.WebGLRenderer({antialias:e.antialias??!1,alpha:e.alpha??!1,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(i,s),this.container.appendChild(this.renderer.domElement)),this.controls=new K(this.camera,this.renderer.domElement),this.controls.enableDamping=!0,this.controls.enableRotate=!1,this.controls.mouseButtons={LEFT:r.MOUSE.PAN,MIDDLE:r.MOUSE.DOLLY,RIGHT:r.MOUSE.ROTATE},this.resizeObserver=new ResizeObserver(()=>this.onResize()),this.resizeObserver.observe(this.container),this.autoRender&&this.animate()}registerPreset(t,e){return this.customPresets.set(t,e),this.plots.forEach(i=>{i.injectPresets&&i.injectPresets(this.customPresets)}),this}add(t,e,i){let s;return t==="line"?s=new x(e,new r.Color(i||"#00ff88")):t==="point"?s=new b(e,new r.Color(i||"#00ff88")):t==="axis"?s=new X(e||"#ffffff"):t==="legend"?s=new F:t==="text"&&(s=new T(e||100),this.fontConfig&&this.fontConfig.json&&this.fontConfig.texture&&s.load(this.fontConfig.json,this.fontConfig.texture),this.textPlots.add(s)),t!=="text"&&(this.plots.add(s),s.injectPresets&&this.customPresets.size>0&&s.injectPresets(this.customPresets)),this.scene.add(s.mesh),s}line(t,e){return this.add("line",t,e)}point(t,e){return this.add("point",t,e)}axis(t){return this.add("axis",t)}legend(){return this.add("legend",null)}text(t){return this.add("text",t)}remove(t){return this.plots.delete(t),t instanceof T&&this.textPlots.delete(t),this.scene.remove(t.mesh),t.dispose(),this}clear(){return this.plots.forEach(t=>{this.scene.remove(t.mesh),t.dispose()}),this.textPlots.forEach(t=>{this.scene.remove(t.mesh),t.dispose()}),this.plots.clear(),this.textPlots.clear(),this}onResize(){const t=this.container.clientWidth,e=this.container.clientHeight,i=t/e,s=250;this.camera.left=-s*i,this.camera.right=s*i,this.camera.top=s,this.camera.bottom=-s,this.camera.updateProjectionMatrix(),this.renderer.setSize(t,e)}getViewportStats(){const t=this.container.clientWidth,e=this.container.clientHeight,i=this.camera.zoom,s=this.camera.position.x+this.camera.left/i,n=this.camera.position.x+this.camera.right/i;return{pixelWidth:t,pixelHeight:e,minX:s,maxX:n,zoom:i}}getRendererInfo(){return{frame:this.renderer.info.render.frame,calls:this.renderer.info.render.calls,points:this.renderer.info.render.points,triangles:this.renderer.info.render.triangles}}render(){const t=performance.now(),e=this.getViewportStats();this.onUpdate&&this.onUpdate(t),this.plots.forEach(i=>i.update(t/1e3,e)),this.textPlots.forEach(i=>i.update(t/1e3,e)),this.controls.update(),this.renderer.render(this.scene,this.camera)}animate(){this.autoRender&&(this.animationId=requestAnimationFrame(()=>this.animate()),this.render())}destroy(){this.animationId!==null&&cancelAnimationFrame(this.animationId),this.resizeObserver.disconnect(),this.clear(),this.isExternalRenderer||(this.renderer.dispose(),this.renderer.domElement.remove()),this.controls.dispose()}}const dt={init(o,t){return new N(o,t)},version:"1.2.0"};p.AxisPlot=X,p.LegendPlot=F,p.LinePlot=x,p.MSDFText=Y,p.PlotContainer=N,p.PointPlot=b,p.TextPlot=T,p.ThreePlot=dt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@extrabinoss/three-plot",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "High-performance Three.js plotting library using GPU instancing and shaders",
|
|
6
|
+
"main": "./dist/three-plot.umd.cjs",
|
|
7
|
+
"module": "./dist/three-plot.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/three-plot.js",
|
|
12
|
+
"require": "./dist/three-plot.umd.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "npm run build:lib && npm run build:app",
|
|
22
|
+
"build:lib": "vite build --config vite.config.lib.ts",
|
|
23
|
+
"build:app": "vue-tsc -b && vite build",
|
|
24
|
+
"preview": "vite preview"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^24.10.1",
|
|
28
|
+
"@types/three": "^0.182.0",
|
|
29
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
30
|
+
"@vue/tsconfig": "^0.8.1",
|
|
31
|
+
"lil-gui": "^0.21.0",
|
|
32
|
+
"three": "^0.182.0",
|
|
33
|
+
"typescript": "~5.9.3",
|
|
34
|
+
"vite": "^7.3.1",
|
|
35
|
+
"vite-plugin-glsl": "^1.5.5",
|
|
36
|
+
"vue": "^3.5.25",
|
|
37
|
+
"vue-tsc": "^3.1.5"
|
|
38
|
+
}
|
|
39
|
+
}
|