gl-draw 0.8.34 → 0.9.0-beta.1

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.
Files changed (46) hide show
  1. package/dist/BaseObject.js +1 -0
  2. package/dist/BaseObject.module.js +88 -0
  3. package/dist/core/BaseObject.d.ts +1 -1
  4. package/dist/core/Pencil.d.ts +7 -8
  5. package/dist/disposeMesh.js +1 -0
  6. package/dist/disposeMesh.module.js +9 -0
  7. package/dist/effect/index.js +20 -19
  8. package/dist/effect/index.module.js +299 -19
  9. package/dist/effect/scan.d.ts +1 -1
  10. package/dist/effect/scan2.d.ts +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +1 -1
  13. package/dist/index.module.js +867 -1
  14. package/dist/isPlainObject.js +1 -0
  15. package/dist/isPlainObject.module.js +15 -0
  16. package/dist/makePromiseCreator.js +1 -0
  17. package/dist/makePromiseCreator.module.js +24 -0
  18. package/dist/objects/conicPolygon/index.d.ts +1 -1
  19. package/dist/objects/extrudePolygon/getWorkerGeometry.d.ts +2 -2
  20. package/dist/objects/extrudePolygon/index.d.ts +3 -2
  21. package/dist/objects/group/index.d.ts +1 -1
  22. package/dist/objects/image/index.d.ts +2 -2
  23. package/dist/objects/index.d.ts +0 -1
  24. package/dist/objects/index.js +11 -11
  25. package/dist/objects/index.module.js +1201 -11
  26. package/dist/objects/line/getWorkerGeometry.d.ts +2 -2
  27. package/dist/objects/line/index.d.ts +5 -4
  28. package/dist/objects/node/index.d.ts +3 -3
  29. package/dist/objects/text/index.d.ts +2 -2
  30. package/dist/objects/video/index.d.ts +2 -2
  31. package/dist/plugins/Draw.d.ts +3 -3
  32. package/dist/plugins/Worker.d.ts +1 -1
  33. package/dist/plugins/index.js +1 -1
  34. package/dist/plugins/index.module.js +272 -1
  35. package/dist/utils/index.js +1 -1
  36. package/dist/utils/index.module.js +178 -1
  37. package/dist/uvGenerator.js +1 -0
  38. package/dist/uvGenerator.module.js +93 -0
  39. package/dist/worker/extrudePolygon.w.js +3009 -0
  40. package/dist/worker/line.w.js +3140 -0
  41. package/package.json +24 -25
  42. package/dist/shims.d.ts +0 -5
  43. package/dist/workers/extrudePolygon.js +0 -3046
  44. package/dist/workers/line.js +0 -3177
  45. /package/dist/objects/extrudePolygon/{w.d.ts → extrudePolygon.w.d.ts} +0 -0
  46. /package/dist/objects/line/{w.d.ts → line.w.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ "use strict";const o=require("three"),a=require("./makePromiseCreator.js"),h=require("three/examples/jsm/renderers/CSS2DRenderer"),c=require("three/examples/jsm/renderers/CSS3DRenderer"),d=require("./disposeMesh.js");require("idb-keyval");function u(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const s=u(o),n=t=>{t&&(d.disposeMesh(t),t.children.forEach(e=>{e.userData.BaseObject_||n(e)}))};class b{constructor(){this.objecttype__="BaseObject",this.userData={},this.pm=a.makePromiseCreator(),this.visible=!1}get parent(){const e=this.object3d.parent;return(e==null?void 0:e.userData.BaseObject_)||this.pencil.scene}get children(){return this.object3d.children.map(e=>e.userData.BaseObject_).filter(e=>!!e)}init(){}create(){}render(){}update(e,r){}resize(e,r){}show(){return this.object3d&&(this.object3d.visible=!0),this.visible=!0,this}hide(){return this.object3d&&(this.object3d.visible=!1),this.visible=!1,this}isVisible(){return this.visible}createMesh(...e){return this.object3d=new s.Mesh(...e),this}createGroup(){return this.object3d=new s.Group,this}createPoints(...e){return this.object3d=new s.Points(...e),this}createCSS2DObject(e){return this.object3d=new h.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new c.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new c.CSS3DSprite(e),this}createSprite(e){return this.object3d=new s.Sprite(e),this}add(...e){return this.object3d.add(...e),this}remove(...e){return this.object3d.remove(...e),this}getSize(){const e=new s.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new s.Vector3)}}traverse(e){e(this),this.children.forEach(r=>{r.traverse(e)})}dispose(){n(this.object3d)}}exports.BaseObject=b;
@@ -0,0 +1,88 @@
1
+ import * as t from "three";
2
+ import { m as h } from "./makePromiseCreator.module.js";
3
+ import { CSS2DObject as c } from "three/examples/jsm/renderers/CSS2DRenderer";
4
+ import { CSS3DObject as o, CSS3DSprite as a } from "three/examples/jsm/renderers/CSS3DRenderer";
5
+ import { d as n } from "./disposeMesh.module.js";
6
+ import "idb-keyval";
7
+ const r = (i) => {
8
+ i && (n(i), i.children.forEach((e) => {
9
+ e.userData.BaseObject_ || r(e);
10
+ }));
11
+ };
12
+ class p {
13
+ constructor() {
14
+ this.objecttype__ = "BaseObject", this.userData = {}, this.pm = h(), this.visible = !1;
15
+ }
16
+ get parent() {
17
+ const e = this.object3d.parent;
18
+ return (e == null ? void 0 : e.userData.BaseObject_) || this.pencil.scene;
19
+ }
20
+ get children() {
21
+ return this.object3d.children.map((e) => e.userData.BaseObject_).filter((e) => !!e);
22
+ }
23
+ init() {
24
+ }
25
+ create() {
26
+ }
27
+ render() {
28
+ }
29
+ update(e, s) {
30
+ }
31
+ resize(e, s) {
32
+ }
33
+ show() {
34
+ return this.object3d && (this.object3d.visible = !0), this.visible = !0, this;
35
+ }
36
+ hide() {
37
+ return this.object3d && (this.object3d.visible = !1), this.visible = !1, this;
38
+ }
39
+ isVisible() {
40
+ return this.visible;
41
+ }
42
+ createMesh(...e) {
43
+ return this.object3d = new t.Mesh(...e), this;
44
+ }
45
+ createGroup() {
46
+ return this.object3d = new t.Group(), this;
47
+ }
48
+ createPoints(...e) {
49
+ return this.object3d = new t.Points(...e), this;
50
+ }
51
+ createCSS2DObject(e) {
52
+ return this.object3d = new c(e), this;
53
+ }
54
+ createCSS3DObject(e) {
55
+ return this.object3d = new o(e), this;
56
+ }
57
+ createCSS3DSprite(e) {
58
+ return this.object3d = new a(e), this;
59
+ }
60
+ createSprite(e) {
61
+ return this.object3d = new t.Sprite(e), this;
62
+ }
63
+ add(...e) {
64
+ return this.object3d.add(...e), this;
65
+ }
66
+ remove(...e) {
67
+ return this.object3d.remove(...e), this;
68
+ }
69
+ getSize() {
70
+ const e = new t.Box3().setFromObject(this.object3d);
71
+ return {
72
+ min: e.min,
73
+ max: e.max,
74
+ size: e.getSize(new t.Vector3())
75
+ };
76
+ }
77
+ traverse(e) {
78
+ e(this), this.children.forEach((s) => {
79
+ s.traverse(e);
80
+ });
81
+ }
82
+ dispose() {
83
+ r(this.object3d);
84
+ }
85
+ }
86
+ export {
87
+ p as B
88
+ };
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import type Pencil from '../core/Pencil';
2
+ import type Pencil from "./Pencil";
3
3
  export { CSS3DObject, CSS3DSprite, } from 'three/examples/jsm/renderers/CSS3DRenderer';
4
4
  export { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer';
5
5
  export default class BaseObject {
@@ -1,15 +1,14 @@
1
- /// <reference types="node" />
2
1
  import * as THREE from 'three';
3
2
  import { EventEmitter } from 'events';
4
3
  import Stats from 'three/examples/jsm/libs/stats.module';
5
4
  import GUI from 'lil-gui';
6
- import { RendererParams } from '../core/Renderer';
7
- import { CameraParams } from '../core/Camera';
8
- import SceneController, { SceneParams } from '../core/Scene';
9
- import ControlController, { ControlParams } from '../core/Control';
10
- import CSSRendererController, { CSSRendererParams } from '../core/CSSRenderer';
11
- import ComposerController, { BloomParams } from '../core/Composer';
12
- declare type DeepRequired<T> = T extends Function | HTMLElement ? T : T extends object ? {
5
+ import { RendererParams } from "./Renderer";
6
+ import { CameraParams } from "./Camera";
7
+ import SceneController, { SceneParams } from "./Scene";
8
+ import ControlController, { ControlParams } from "./Control";
9
+ import CSSRendererController, { CSSRendererParams } from "./CSSRenderer";
10
+ import ComposerController, { BloomParams } from "./Composer";
11
+ type DeepRequired<T> = T extends Function | HTMLElement ? T : T extends object ? {
13
12
  [P in keyof T]-?: DeepRequired<T[P]>;
14
13
  } : T;
15
14
  interface Options {
@@ -0,0 +1 @@
1
+ "use strict";function y(a){a.geometry&&a.geometry.dispose(),a.material&&(Array.isArray(a.material)?a.material:[a.material]).forEach(s=>{var e,p,i,o,d,M,c,h,g,r,u,f,n;(e=s.map)==null||e.dispose(),(p=s.lightMap)==null||p.dispose(),(i=s.bumpMap)==null||i.dispose(),(o=s.normalMap)==null||o.dispose(),(d=s.specularMap)==null||d.dispose(),(M=s.envMap)==null||M.dispose(),(c=s.alphaMap)==null||c.dispose(),(h=s.aoMap)==null||h.dispose(),(g=s.displacementMap)==null||g.dispose(),(r=s.emissiveMap)==null||r.dispose(),(u=s.gradientMap)==null||u.dispose(),(f=s.metalnessMap)==null||f.dispose(),(n=s.roughnessMap)==null||n.dispose(),s.dispose()})}exports.disposeMesh=y;
@@ -0,0 +1,9 @@
1
+ function t(a) {
2
+ a.geometry && a.geometry.dispose(), a.material && (Array.isArray(a.material) ? a.material : [a.material]).forEach((s) => {
3
+ var p, e, i, o, d, M, c, g, h, r, f, n, u;
4
+ (p = s.map) == null || p.dispose(), (e = s.lightMap) == null || e.dispose(), (i = s.bumpMap) == null || i.dispose(), (o = s.normalMap) == null || o.dispose(), (d = s.specularMap) == null || d.dispose(), (M = s.envMap) == null || M.dispose(), (c = s.alphaMap) == null || c.dispose(), (g = s.aoMap) == null || g.dispose(), (h = s.displacementMap) == null || h.dispose(), (r = s.emissiveMap) == null || r.dispose(), (f = s.gradientMap) == null || f.dispose(), (n = s.metalnessMap) == null || n.dispose(), (u = s.roughnessMap) == null || u.dispose(), s.dispose();
5
+ });
6
+ }
7
+ export {
8
+ t as d
9
+ };
@@ -1,13 +1,14 @@
1
- (function(){var Q={666:function(w){var b=function(g){"use strict";var F=Object.prototype,M=F.hasOwnProperty,z,E=typeof Symbol=="function"?Symbol:{},x=E.iterator||"@@iterator",q=E.asyncIterator||"@@asyncIterator",I=E.toStringTag||"@@toStringTag";function W(r,e,n){return Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),r[e]}try{W({},"")}catch(r){W=function(e,n,f){return e[n]=f}}function B(r,e,n,f){var o=e&&e.prototype instanceof i?e:i,y=Object.create(o.prototype),P=new T(f||[]);return y._invoke=H(r,n,P),y}g.wrap=B;function R(r,e,n){try{return{type:"normal",arg:r.call(e,n)}}catch(f){return{type:"throw",arg:f}}}var m="suspendedStart",s="suspendedYield",l="executing",a="completed",t={};function i(){}function p(){}function u(){}var c={};W(c,x,function(){return this});var d=Object.getPrototypeOf,O=d&&d(d(L([])));O&&O!==F&&M.call(O,x)&&(c=O);var v=u.prototype=i.prototype=Object.create(c);p.prototype=u,W(v,"constructor",u),W(u,"constructor",p),p.displayName=W(u,I,"GeneratorFunction");function D(r){["next","throw","return"].forEach(function(e){W(r,e,function(n){return this._invoke(e,n)})})}g.isGeneratorFunction=function(r){var e=typeof r=="function"&&r.constructor;return e?e===p||(e.displayName||e.name)==="GeneratorFunction":!1},g.mark=function(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,u):(r.__proto__=u,W(r,I,"GeneratorFunction")),r.prototype=Object.create(v),r},g.awrap=function(r){return{__await:r}};function h(r,e){function n(y,P,N,C){var S=R(r[y],r,P);if(S.type==="throw")C(S.arg);else{var $=S.arg,U=$.value;return U&&typeof U=="object"&&M.call(U,"__await")?e.resolve(U.__await).then(function(V){n("next",V,N,C)},function(V){n("throw",V,N,C)}):e.resolve(U).then(function(V){$.value=V,N($)},function(V){return n("throw",V,N,C)})}}var f;function o(y,P){function N(){return new e(function(C,S){n(y,P,C,S)})}return f=f?f.then(N,N):N()}this._invoke=o}D(h.prototype),W(h.prototype,q,function(){return this}),g.AsyncIterator=h,g.async=function(r,e,n,f,o){o===void 0&&(o=Promise);var y=new h(B(r,e,n,f),o);return g.isGeneratorFunction(e)?y:y.next().then(function(P){return P.done?P.value:y.next()})};function H(r,e,n){var f=m;return function(y,P){if(f===l)throw new Error("Generator is already running");if(f===a){if(y==="throw")throw P;return _()}for(n.method=y,n.arg=P;;){var N=n.delegate;if(N){var C=G(N,n);if(C){if(C===t)continue;return C}}if(n.method==="next")n.sent=n._sent=n.arg;else if(n.method==="throw"){if(f===m)throw f=a,n.arg;n.dispatchException(n.arg)}else n.method==="return"&&n.abrupt("return",n.arg);f=l;var S=R(r,e,n);if(S.type==="normal"){if(f=n.done?a:s,S.arg===t)continue;return{value:S.arg,done:n.done}}else S.type==="throw"&&(f=a,n.method="throw",n.arg=S.arg)}}}function G(r,e){var n=r.iterator[e.method];if(n===z){if(e.delegate=null,e.method==="throw"){if(r.iterator.return&&(e.method="return",e.arg=z,G(r,e),e.method==="throw"))return t;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return t}var f=R(n,r.iterator,e.arg);if(f.type==="throw")return e.method="throw",e.arg=f.arg,e.delegate=null,t;var o=f.arg;if(!o)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,t;if(o.done)e[r.resultName]=o.value,e.next=r.nextLoc,e.method!=="return"&&(e.method="next",e.arg=z);else return o;return e.delegate=null,t}D(v),W(v,I,"Generator"),W(v,x,function(){return this}),W(v,"toString",function(){return"[object Generator]"});function A(r){var e={tryLoc:r[0]};1 in r&&(e.catchLoc=r[1]),2 in r&&(e.finallyLoc=r[2],e.afterLoc=r[3]),this.tryEntries.push(e)}function k(r){var e=r.completion||{};e.type="normal",delete e.arg,r.completion=e}function T(r){this.tryEntries=[{tryLoc:"root"}],r.forEach(A,this),this.reset(!0)}g.keys=function(r){var e=[];for(var n in r)e.push(n);return e.reverse(),function f(){for(;e.length;){var o=e.pop();if(o in r)return f.value=o,f.done=!1,f}return f.done=!0,f}};function L(r){if(r){var e=r[x];if(e)return e.call(r);if(typeof r.next=="function")return r;if(!isNaN(r.length)){var n=-1,f=function o(){for(;++n<r.length;)if(M.call(r,n))return o.value=r[n],o.done=!1,o;return o.value=z,o.done=!0,o};return f.next=f}}return{next:_}}g.values=L;function _(){return{value:z,done:!0}}return T.prototype={constructor:T,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=z,this.done=!1,this.delegate=null,this.method="next",this.arg=z,this.tryEntries.forEach(k),!r)for(var e in this)e.charAt(0)==="t"&&M.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=z)},stop:function(){this.done=!0;var r=this.tryEntries[0],e=r.completion;if(e.type==="throw")throw e.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(C,S){return y.type="throw",y.arg=r,e.next=C,S&&(e.method="next",e.arg=z),!!S}for(var f=this.tryEntries.length-1;f>=0;--f){var o=this.tryEntries[f],y=o.completion;if(o.tryLoc==="root")return n("end");if(o.tryLoc<=this.prev){var P=M.call(o,"catchLoc"),N=M.call(o,"finallyLoc");if(P&&N){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(P){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else if(N){if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(r,e){for(var n=this.tryEntries.length-1;n>=0;--n){var f=this.tryEntries[n];if(f.tryLoc<=this.prev&&M.call(f,"finallyLoc")&&this.prev<f.finallyLoc){var o=f;break}}o&&(r==="break"||r==="continue")&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var y=o?o.completion:{};return y.type=r,y.arg=e,o?(this.method="next",this.next=o.finallyLoc,t):this.complete(y)},complete:function(r,e){if(r.type==="throw")throw r.arg;return r.type==="break"||r.type==="continue"?this.next=r.arg:r.type==="return"?(this.rval=this.arg=r.arg,this.method="return",this.next="end"):r.type==="normal"&&e&&(this.next=e),t},finish:function(r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===r)return this.complete(n.completion,n.afterLoc),k(n),t}},catch:function(r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===r){var f=n.completion;if(f.type==="throw"){var o=f.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:L(r),resultName:e,nextLoc:n},this.method==="next"&&(this.arg=z),t}},g}(w.exports);try{regeneratorRuntime=b}catch(g){typeof globalThis=="object"?globalThis.regeneratorRuntime=b:Function("r","regeneratorRuntime = r")(b)}}},J={};function j(w){var b=J[w];if(b!==void 0)return b.exports;var g=J[w]={exports:{}};return Q[w](g,g.exports,j),g.exports}(function(){j.n=function(w){var b=w&&w.__esModule?function(){return w.default}:function(){return w};return j.d(b,{a:b}),b}})(),function(){j.d=function(w,b){for(var g in b)j.o(b,g)&&!j.o(w,g)&&Object.defineProperty(w,g,{enumerable:!0,get:b[g]})}}(),function(){j.o=function(w,b){return Object.prototype.hasOwnProperty.call(w,b)}}(),function(){j.r=function(w){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(w,"__esModule",{value:!0})}}();var Y={};(function(){"use strict";j.r(Y),j.d(Y,{Scan:function(){return B},Scan2:function(){return R}});function w(m,s,l,a,t,i,p){try{var u=m[i](p),c=u.value}catch(d){l(d);return}u.done?s(c):Promise.resolve(c).then(a,t)}function b(m){return function(){var s=this,l=arguments;return new Promise(function(a,t){var i=m.apply(s,l);function p(c){w(i,a,t,p,u,"next",c)}function u(c){w(i,a,t,p,u,"throw",c)}p(void 0)})}}function g(m,s){if(!(m instanceof s))throw new TypeError("Cannot call a class as a function")}function F(m,s,l){return s in m?Object.defineProperty(m,s,{value:l,enumerable:!0,configurable:!0,writable:!0}):m[s]=l,m}function M(m){for(var s=1;s<arguments.length;s++){var l=arguments[s]!=null?arguments[s]:{},a=Object.keys(l);typeof Object.getOwnPropertySymbols=="function"&&(a=a.concat(Object.getOwnPropertySymbols(l).filter(function(t){return Object.getOwnPropertyDescriptor(l,t).enumerable}))),a.forEach(function(t){F(m,t,l[t])})}return m}var z=j(666),E=j.n(z),x=require("three"),q=require("popmotion");function I(m){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return m.then(function(l){return M({err:null,res:l},s)}).catch(function(l){return M({err:l,res:void 0},s)})}function W(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l={};return l.promise=new Promise(function(a,t){l.resolve=a,l.reject=t}),m&&(l.promise=I(l.promise,s)),l}var B=function(){"use strict";function m(l){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g(this,m),this.object=l,this.options=M({},{color:16777215,opacity:1,lineNum:10,lineWidth:1,lineHieght:10,fade:!1,fadeType:2,radius:0,range:new x.Vector2(0,1),vertical:!1,step:0,pos:"bottom",duration:5e3,yoyo:!1,repeat:0},a)}var s=m.prototype;return s.initMaterial=function(){var a=this,t=this.options,i=t.color,p=t.lineNum,u=t.lineWidth,c=t.lineHieght,d=t.fade,O=t.fadeType,v=t.radius,D=t.range,h=t.vertical,H=t.step,G=t.opacity,A=t.exclude,k={field:{value:new x.Vector4(0,0,0,0)},color:{value:new x.Color(i)},opacity:{value:G},lineNum:{value:p},lineWidth:{value:u},lineHieght:{value:c},sizeNum:{value:new x.Vector3(v,v,v)},objPos:{value:new x.Vector3(0,0,0)},fade:{value:d},fadeType:{value:O},range:{value:D},angle:{value:0},stepNum:{value:H}};if(!v){var T=this.object.getSize().size;k.sizeNum.value.copy(T)}this.uniforms=k,this.object.object3d.traverse(function(L){var _=L;!_.material||A&&A.includes(_)||(_.userData.materialO?_.material=_.userData.materialO.clone():_.userData.materialO=Array.isArray(_.material)?_.material.map(function(r){return r.clone()}):_.material.clone(),Array.isArray(_.material)?_.material.forEach(function(r){h?a.setVerticalMaterial(r):a.setMaterial(r)}):h?a.setVerticalMaterial(_.material):a.setMaterial(_.material))})},s.setMaterial=function(a){var t=this.uniforms;a.onBeforeCompile=function(i){i.uniforms.field=t.field,i.uniforms.fieldColor=t.color,i.uniforms.fieldOpacity=t.opacity,i.uniforms.lineNum=t.lineNum,i.uniforms.lineWidth=t.lineWidth,i.uniforms.sizeNum=t.sizeNum,i.uniforms.fade=t.fade,i.uniforms.fadeType=t.fadeType,i.uniforms.range=t.range,i.uniforms.stepNum=t.stepNum,i.vertexShader=`
1
+ (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ "use strict";var _=Object.defineProperty;var z=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var W=Math.pow,D=(a,i,e)=>i in a?_(a,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[i]=e,c=(a,i)=>{for(var e in i||(i={}))T.call(i,e)&&D(a,e,i[e]);if(z)for(var e of z(i))A.call(i,e)&&D(a,e,i[e]);return a};var b=(a,i,e)=>new Promise((t,o)=>{var f=d=>{try{l(e.next(d))}catch(m){o(m)}},r=d=>{try{l(e.throw(d))}catch(m){o(m)}},l=d=>d.done?t(d.value):Promise.resolve(d.value).then(f,r);l((e=e.apply(a,i)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("three"),E=require("@tweenjs/tween.js"),j=require("../makePromiseCreator.js");function C(a){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(i,e,t.get?t:{enumerable:!0,get:()=>a[e]})}}return i.default=a,Object.freeze(i)}const u=C(V),S=C(E);class k{constructor(i,e={}){this.object=i,this.options=c({color:16777215,opacity:1,lineNum:10,lineWidth:1,lineHieght:10,fade:!1,fadeType:2,radius:0,range:new u.Vector2(0,1),vertical:!1,step:0,pos:"bottom",duration:5e3,yoyo:!1,repeat:0},e)}initMaterial(){const{color:i,lineNum:e,lineWidth:t,lineHieght:o,fade:f,fadeType:r,radius:l,range:d,vertical:m,step:g,opacity:w,exclude:p}=this.options,v={field:{value:new u.Vector4(0,0,0,0)},color:{value:new u.Color(i)},opacity:{value:w},lineNum:{value:e},lineWidth:{value:t},lineHieght:{value:o},sizeNum:{value:new u.Vector3(l,l,l)},objPos:{value:new u.Vector3(0,0,0)},fade:{value:f},fadeType:{value:r},range:{value:d},angle:{value:0},stepNum:{value:g}};if(!l){const{size:h}=this.object.getSize();v.sizeNum.value.copy(h)}this.uniforms=v,this.object.object3d.traverse(h=>{const n=h;!n.material||p&&p.includes(n)||(n.userData.materialO?n.material=n.userData.materialO.clone():n.userData.materialO=Array.isArray(n.material)?n.material.map(s=>s.clone()):n.material.clone(),Array.isArray(n.material)?n.material.forEach(s=>{m?this.setVerticalMaterial(s):this.setMaterial(s)}):m?this.setVerticalMaterial(n.material):this.setMaterial(n.material))})}setMaterial(i){const{uniforms:e}=this;i.onBeforeCompile=t=>{t.uniforms.field=e.field,t.uniforms.fieldColor=e.color,t.uniforms.fieldOpacity=e.opacity,t.uniforms.lineNum=e.lineNum,t.uniforms.lineWidth=e.lineWidth,t.uniforms.sizeNum=e.sizeNum,t.uniforms.fade=e.fade,t.uniforms.fadeType=e.fadeType,t.uniforms.range=e.range,t.uniforms.stepNum=e.stepNum,t.vertexShader=`
2
3
  varying vec4 vWorldPos;
3
- `.concat(i.vertexShader,`
4
- `).replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
4
+ ${t.vertexShader}
5
+ `.replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
5
6
  vWorldPos = vec4( transformed, 1.0 );
6
7
  #ifdef USE_INSTANCING
7
8
  vWorldPos = instanceMatrix * vWorldPos;
8
9
  #endif
9
10
  vWorldPos = modelMatrix * vWorldPos;
10
- `),i.fragmentShader=`
11
+ `),t.fragmentShader=`
11
12
  uniform vec4 field;
12
13
  uniform vec3 fieldColor;
13
14
  uniform float fieldOpacity;
@@ -19,8 +20,8 @@
19
20
  uniform vec2 range;
20
21
  uniform int stepNum;
21
22
  varying vec4 vWorldPos;
22
- `.concat(i.fragmentShader,`
23
- `).replace("#include <dithering_fragment>",`#include <dithering_fragment>
23
+ ${t.fragmentShader}
24
+ `.replace("#include <dithering_fragment>",`#include <dithering_fragment>
24
25
  float height = sizeNum.y;
25
26
  bool isTop = field.y > vWorldPos.y;
26
27
  float worldDist = distance(field.y, vWorldPos.y);
@@ -54,16 +55,16 @@
54
55
  }
55
56
  }
56
57
  }
57
- `)},a.needsUpdate=!0},s.setVerticalMaterial=function(a){var t=this.uniforms;a.onBeforeCompile=function(i){i.uniforms.field=t.field,i.uniforms.fieldColor=t.color,i.uniforms.fieldOpacity=t.opacity,i.uniforms.lineNum=t.lineNum,i.uniforms.lineWidth=t.lineWidth,i.uniforms.lineHieght=t.lineHieght,i.uniforms.sizeNum=t.sizeNum,i.uniforms.fade=t.fade,i.uniforms.range=t.range,i.uniforms.angle=t.angle,i.uniforms.objPos=t.objPos,i.vertexShader=`
58
+ `)},i.needsUpdate=!0}setVerticalMaterial(i){const{uniforms:e}=this;i.onBeforeCompile=t=>{t.uniforms.field=e.field,t.uniforms.fieldColor=e.color,t.uniforms.fieldOpacity=e.opacity,t.uniforms.lineNum=e.lineNum,t.uniforms.lineWidth=e.lineWidth,t.uniforms.lineHieght=e.lineHieght,t.uniforms.sizeNum=e.sizeNum,t.uniforms.fade=e.fade,t.uniforms.range=e.range,t.uniforms.angle=e.angle,t.uniforms.objPos=e.objPos,t.vertexShader=`
58
59
  varying vec4 vWorldPos;
59
- `.concat(i.vertexShader,`
60
- `).replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
60
+ ${t.vertexShader}
61
+ `.replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
61
62
  vWorldPos = vec4( transformed, 1.0 );
62
63
  #ifdef USE_INSTANCING
63
64
  vWorldPos = instanceMatrix * vWorldPos;
64
65
  #endif
65
66
  vWorldPos = modelMatrix * vWorldPos;
66
- `),i.fragmentShader=`
67
+ `),t.fragmentShader=`
67
68
  uniform vec4 field;
68
69
  uniform vec3 fieldColor;
69
70
  uniform float fieldOpacity;
@@ -81,8 +82,8 @@
81
82
  return(x - objPos.x)*cos(a) - (z - objPos.z)*sin(a) + objPos.x ;
82
83
  }
83
84
 
84
- `.concat(i.fragmentShader,`
85
- `).replace("#include <dithering_fragment>",`#include <dithering_fragment>
85
+ ${t.fragmentShader}
86
+ `.replace("#include <dithering_fragment>",`#include <dithering_fragment>
86
87
 
87
88
  float worldDist = distance(field.y, vWorldPos.y);
88
89
  bool isTop = field.x > vWorldPos.x;
@@ -125,24 +126,24 @@
125
126
  }
126
127
  }
127
128
 
128
- `)},a.needsUpdate=!0},s.resetMaterial=function(){this.object.object3d.traverse(function(a){var t=a;t.material&&t.userData.materialO&&(t.material=t.userData.materialO.clone(),t.userData.materialO=void 0)})},s.play=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=this;this.stop();var i=W(!0),p=this,u=p.object,c=p.uniforms,d=M({},this.options,a),O=d.lineNum,v=d.step,D=d.lineWidth,h=d.pos,H=d.duration,G=u.getSize(),A=G.min,k=G.max,T=G.size,L=O,_=D;v>0&&(L=1,_=T.y/v);var r=c.sizeNum.value.y*(L>1?2:1);return this.tween=(0,q.animate)({from:0,to:1,duration:H,onPlay:function(){var e,n=new x.Vector3;h==="bottom"?n.set(A.x-.001,A.y-.001,A.z-.001):h==="top"&&n.set(k.x+.001,k.y+.001,k.z+.001);var f=((e=u.pencil.control)===null||e===void 0?void 0:e.getAzimuthalAngle())||0,o=t.object.object3d.position.clone();if(f){var y=Math.sqrt(Math.pow(T.x,2)+Math.pow(T.z,2))/2;n.x=o.x+y,n.z=o.z+y;var P=new x.Vector3().subVectors(n,o),N=new x.Vector3(0,1,0);P.applyAxisAngle(N,f),n.addVectors(o,P)}c.objPos.value.copy(o),c.field.value.set(n.x,n.y,n.z,0),c.angle.value=f,c.lineNum.value=L,c.lineWidth.value=_},onUpdate:function(e){v>0?c.field.value.w=Math.floor(e*v)/v*r:c.field.value.w=e*r},onStop:function(){c.field.value.w=0,i.reject("stop")},onComplete:function(){i.resolve()}}),i.promise},s.checkRepeat=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=this;return b(E().mark(function i(){var p,u,c,d,O,v;return E().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return p=M({},t.options,a),u=p.yoyo,c=p.repeat,d=p.pos,c===t.options.repeat&&t.initMaterial(),h.next=4,t.play(a);case 4:if(O=h.sent.err,!O){h.next=8;break}return t.resetMaterial(),h.abrupt("return");case 8:if(!c){h.next=15;break}return v=d,u&&(v=v==="bottom"?"top":"bottom"),h.next=13,t.checkRepeat({pos:v,repeat:c===1/0?-1:c-1});case 13:h.next=16;break;case 15:t.resetMaterial();case 16:case"end":return h.stop()}},i)}))()},s.start=function(){return this.checkRepeat()},s.stop=function(){this.tween&&this.tween.stop()},m}(),R=function(){"use strict";function m(l){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g(this,m),this.object=l,this.options=M({},{color:16777215,lineWidth:2,opacity:.5,fade:!1,position:new x.Vector3(0,0,0),duration:5e3,repeat:0},a)}var s=m.prototype;return s.initMaterial=function(){var a=this,t=this.options.exclude,i={field:{value:new x.Vector4(0,0,0,1e-4)},color:{value:new x.Color(this.options.color)},opacity:{value:this.options.opacity},lineWidth:{value:this.options.lineWidth}};this.uniforms=i,this.object.object3d.traverse(function(p){var u=p;!u.material||t&&t.includes(u)||(u.userData.materialO?u.material=u.userData.materialO:u.userData.materialO=Array.isArray(u.material)?u.material.map(function(c){return c.clone()}):u.material.clone(),Array.isArray(u.material)?u.material.forEach(function(c){a.setMaterial(c)}):a.setMaterial(u.material))})},s.setMaterial=function(a){var t=this.uniforms;a.onBeforeCompile=function(i){i.uniforms.field=t.field,i.uniforms.fieldColor=t.color,i.uniforms.fieldOpacity=t.opacity,i.uniforms.lineWidth=t.lineWidth,i.vertexShader=`
129
+ `)},i.needsUpdate=!0}resetMaterial(){this.object.object3d.traverse(i=>{const e=i;e.material&&e.userData.materialO&&(e.material=e.userData.materialO.clone(),e.userData.materialO=void 0)})}play(i={}){this.stop();const e=j.makePromiseCreator(!0),{object:t,uniforms:o}=this,{lineNum:f,step:r,lineWidth:l,pos:d,duration:m}=c(c({},this.options),i),{min:g,max:w,size:p}=t.getSize();let v=f,h=l;r>0&&(v=1,h=p.y/r);const n=o.sizeNum.value.y*(v>1?2:1);return this.tween=new S.Tween({latest:0}).to({latest:1},m).onStart(()=>{var N;const s=new u.Vector3;d==="bottom"?s.set(g.x-.001,g.y-.001,g.z-.001):d==="top"&&s.set(w.x+.001,w.y+.001,w.z+.001);const x=((N=t.pencil.control)==null?void 0:N.getAzimuthalAngle())||0,y=this.object.object3d.position.clone();if(x){const M=Math.sqrt(W(p.x,2)+W(p.z,2))/2;s.x=y.x+M,s.z=y.z+M;const P=new u.Vector3().subVectors(s,y),O=new u.Vector3(0,1,0);P.applyAxisAngle(O,x),s.addVectors(y,P)}o.objPos.value.copy(y),o.field.value.set(s.x,s.y,s.z,0),o.angle.value=x,o.lineNum.value=v,o.lineWidth.value=h}).onUpdate(({latest:s})=>{r>0?o.field.value.w=Math.floor(s*r)/r*n:o.field.value.w=s*n}).onStop(()=>{o.field.value.w=0,e.reject("stop")}).onComplete(()=>{e.resolve()}).start(),e.promise}checkRepeat(){return b(this,arguments,function*(i={}){const{yoyo:e,repeat:t,pos:o}=c(c({},this.options),i);t===this.options.repeat&&this.initMaterial();const{err:f}=yield this.play(i);if(f){this.resetMaterial();return}if(t){let r=o;e&&(r=r==="bottom"?"top":"bottom"),yield this.checkRepeat({pos:r,repeat:t===1/0?-1:t-1})}else this.resetMaterial()})}start(){return this.checkRepeat()}stop(){this.tween&&this.tween.stop()}}class H{constructor(i,e={}){this.object=i,this.options=c({color:16777215,lineWidth:2,opacity:.5,fade:!1,position:new u.Vector3(0,0,0),duration:5e3,repeat:0},e)}initMaterial(){const{exclude:i}=this.options,e={field:{value:new u.Vector4(0,0,0,1e-4)},color:{value:new u.Color(this.options.color)},opacity:{value:this.options.opacity},lineWidth:{value:this.options.lineWidth}};this.uniforms=e,this.object.object3d.traverse(t=>{const o=t;!o.material||i&&i.includes(o)||(o.userData.materialO?o.material=o.userData.materialO:o.userData.materialO=Array.isArray(o.material)?o.material.map(f=>f.clone()):o.material.clone(),Array.isArray(o.material)?o.material.forEach(f=>{this.setMaterial(f)}):this.setMaterial(o.material))})}setMaterial(i){const{uniforms:e}=this;i.onBeforeCompile=t=>{t.uniforms.field=e.field,t.uniforms.fieldColor=e.color,t.uniforms.fieldOpacity=e.opacity,t.uniforms.lineWidth=e.lineWidth,t.vertexShader=`
129
130
  varying vec4 vWorldPos;
130
- `.concat(i.vertexShader,`
131
- `).replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
131
+ ${t.vertexShader}
132
+ `.replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
132
133
  vWorldPos = vec4( transformed, 1.0 );
133
134
  #ifdef USE_INSTANCING
134
135
  vWorldPos = instanceMatrix * vWorldPos;
135
136
  #endif
136
137
  vWorldPos = modelMatrix * vWorldPos;
137
- `),i.fragmentShader=`
138
+ `),t.fragmentShader=`
138
139
  uniform vec4 field;
139
140
  uniform vec3 fieldColor;
140
141
  uniform float fieldOpacity;
141
142
  uniform float lineWidth;
142
143
 
143
144
  varying vec4 vWorldPos;
144
- `.concat(i.fragmentShader,`
145
- `).replace("#include <dithering_fragment>",`#include <dithering_fragment>
145
+ ${t.fragmentShader}
146
+ `.replace("#include <dithering_fragment>",`#include <dithering_fragment>
146
147
 
147
148
  float worldDist = distance(field.xyz, vWorldPos.xyz);
148
149
  float fadeoutWidth = lineWidth;
@@ -157,4 +158,4 @@
157
158
  }
158
159
  gl_FragColor.rgb = mix(gl_FragColor.rgb, fieldColor, fadeout);
159
160
 
160
- `)},a.needsUpdate=!0},s.resetMaterial=function(){this.object.object3d.traverse(function(a){var t=a;t.material&&t.userData.materialO&&(t.material=t.userData.materialO.clone(),t.userData.materialO=void 0)})},s.play=function(){var a=this;this.stop();var t=W(!0),i=this,p=i.object,u=i.uniforms,c=this.options,d=c.position,O=c.duration,v=this.options.radius;if(!v){var D=p.getSize().size;v=Math.max(D.x,D.y,D.z)}return this.tween=(0,q.animate)({from:1e-4,to:1,duration:O,onPlay:function(){u.field.value.set(d.x,d.y,d.z,1e-4),a.options.fade&&(u.opacity.value=a.options.opacity)},onUpdate:function(h){u.field.value.w=h*v,a.options.fade&&(u.opacity.value=(1-h)*a.options.opacity)},onStop:function(){u.field.value.w=0,t.reject("stop")},onComplete:function(){t.resolve()}}),t.promise},s.checkRepeat=function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=this;return b(E().mark(function i(){var p,u;return E().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return p=M({},t.options,a).repeat,p===t.options.repeat&&t.initMaterial(),d.next=4,t.play();case 4:if(u=d.sent.err,!u){d.next=8;break}return t.resetMaterial(),d.abrupt("return");case 8:if(!p){d.next=13;break}return d.next=11,t.checkRepeat({repeat:p===1/0?-1:p-1});case 11:d.next=14;break;case 13:t.resetMaterial();case 14:case"end":return d.stop()}},i)}))()},s.start=function(){return this.checkRepeat()},s.stop=function(){this.tween&&this.tween.stop()},m}()})(),module.exports=Y})();
161
+ `)},i.needsUpdate=!0}resetMaterial(){this.object.object3d.traverse(i=>{const e=i;e.material&&e.userData.materialO&&(e.material=e.userData.materialO.clone(),e.userData.materialO=void 0)})}play(){this.stop();const i=j.makePromiseCreator(!0),{object:e,uniforms:t}=this,{position:o,duration:f}=this.options;let{radius:r}=this.options;if(!r){const{size:l}=e.getSize();r=Math.max(l.x,l.y,l.z)}return this.tween=new S.Tween({a:1e-4}).to({a:1},f).onStart(()=>{t.field.value.set(o.x,o.y,o.z,1e-4),this.options.fade&&(t.opacity.value=this.options.opacity)}).onUpdate(({a:l})=>{t.field.value.w=l*r,this.options.fade&&(t.opacity.value=(1-l)*this.options.opacity)}).onStop(()=>{t.field.value.w=0,i.reject("stop")}).onComplete(()=>{i.resolve()}).start(),i.promise}checkRepeat(){return b(this,arguments,function*(i={}){const{repeat:e}=c(c({},this.options),i);e===this.options.repeat&&this.initMaterial();const{err:t}=yield this.play();if(t){this.resetMaterial();return}e?yield this.checkRepeat({repeat:e===1/0?-1:e-1}):this.resetMaterial()})}start(){return this.checkRepeat()}stop(){this.tween&&this.tween.stop()}}exports.Scan=k;exports.Scan2=H;