@maptalks/transform-control 0.6.1 → 0.7.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
CHANGED
|
@@ -40,10 +40,12 @@ const map = new maptalks.Map("map",{
|
|
|
40
40
|
const transformControl = new maptalks.TransformControl();
|
|
41
41
|
transformControl.addTo(map);
|
|
42
42
|
transformControl.on('transforming', e => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const target = e.target;
|
|
44
|
+
target.setTRS(e.translate, e.rotation, e.scale);
|
|
45
|
+
});
|
|
46
|
+
transformControl.on('positionchange', e => {
|
|
47
|
+
const target = e.target;
|
|
48
|
+
target.setCoordinates(e.coordinate);
|
|
47
49
|
});
|
|
48
50
|
```
|
|
49
51
|
|
|
@@ -91,3 +93,31 @@ transformControl.on('transforming', e => {
|
|
|
91
93
|
#### Method : isEnbale()
|
|
92
94
|
_whether the control is enable_
|
|
93
95
|
Boolean: true or false
|
|
96
|
+
|
|
97
|
+
#### Event : transforming
|
|
98
|
+
_when transforming the target, it will trigger transforming event_
|
|
99
|
+
| Parameter | Type | Default | Description|
|
|
100
|
+
| ------------- |---------- |-------------|--------- |
|
|
101
|
+
| `target` | GLTFMarker | | the target to transform |
|
|
102
|
+
| `action` | String | | transforming action, includes `xy-translate`、`x-translate`、`y-translate`、`z-translate`、`z-rotate`、`scale` |
|
|
103
|
+
| `type` | GLTFMarker | | event type name |
|
|
104
|
+
| `translate` | Array | | current translate when transforming |
|
|
105
|
+
| `scale` | Array | | current scale when transforming |
|
|
106
|
+
| `rotation` | Array | | current rotation when transforming |
|
|
107
|
+
|
|
108
|
+
#### Event : positionchange
|
|
109
|
+
_when changing target's position, it will trigger positionchange event_
|
|
110
|
+
| Parameter | Type | Default | Description|
|
|
111
|
+
| ------------- |---------- |-------------|--------- |
|
|
112
|
+
| `target` | GLTFMarker | | the target to transform |
|
|
113
|
+
| `action` | String | | transforming action, includes `xy-translate`、`x-translate`、`y-translate`、`z-translate`、`z-rotate`、`scale` |
|
|
114
|
+
| `type` | GLTFMarker | | event type name |
|
|
115
|
+
| `coordinate` | Array | | current coordinate when changing target's position |
|
|
116
|
+
|
|
117
|
+
#### Event : transformend
|
|
118
|
+
_when endding the transform task, it will trigger transformend event_
|
|
119
|
+
| Parameter | Type | Default | Description|
|
|
120
|
+
| ------------- |---------- |-------------|--------- |
|
|
121
|
+
| `target` | GLTFMarker | | the target to be transformed |
|
|
122
|
+
| `action` | String | | current action |
|
|
123
|
+
| `type` | GLTFMarker | | event type name |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/transform-control v0.
|
|
2
|
+
* @maptalks/transform-control v0.7.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2022 maptalks.org
|
|
5
5
|
*/
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* LICENSE : UNLICENSED
|
|
10
10
|
* (c) 2016-2021 maptalks.org
|
|
11
11
|
*/
|
|
12
|
-
var C="undefined"!=typeof Promise?Promise:a;function y(A){return null==A}function b(A){return!y(A)}function P(A){for(let t=1;t<arguments.length;t++){const e=arguments[t];for(const t in e)A[t]=e[t]}return A}function Q(A){switch(A){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+A)}function d(A){return 0===A.indexOf("data:")&&A.indexOf("base64,")>0}function v(A){const t=A.substring(A.indexOf(",")+1),e=window.atob(t),s=e.length,n=new Uint8Array(s);for(let A=0;A<s;A++)n[A]=e.charCodeAt(A);return n.buffer}const p={get:function(A,t){const e=p.t(),s=new C(((s,n)=>{if(e.open("GET",A,!0),t){for(const A in t.headers)e.setRequestHeader(A,t.headers[A]);e.withCredentials="include"===t.credentials,t.responseType&&(e.responseType=t.responseType)}e.onreadystatechange=p.i(e,(function(A,t){A?n(A):s(t)})),e.send(null)}));return s.xhr=e,s},i:function(A,t){return function(){if(4===A.readyState)if(200===A.status)"arraybuffer"===A.responseType?0===A.response.byteLength?t(new Error("http status 200 returned without content.")):t(null,{data:A.response,cacheControl:A.getResponseHeader("Cache-Control"),expires:A.getResponseHeader("Expires"),contentType:A.getResponseHeader("Content-Type")}):t(null,A.responseText);else{if(0===A.status)return;t(new Error(A.statusText+","+A.status))}}},t:function(){let A;try{A=new XMLHttpRequest}catch(t){try{A=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{A=new ActiveXObject("Microsoft.XMLHTTP")}catch(A){}}}return A},getArrayBuffer:(A,t)=>(t||(t={}),t.responseType="arraybuffer",p.get(A,t)),getJSON:function(A,t){const e=p.get(A,t),s=e.then((A=>A?JSON.parse(A):null));return s.xhr=e.xhr,s}};class M{constructor(A,t,e){this.rootPath=A,this.gltf=t,this.requests={},this.buffers={},this.glbBuffer=e}iterate(A,t){const e=this.gltf[t];if(!e)return;let s=0;for(const t in e)A(t,e[t],s++)}createNode(A){const t={};return b(A.name)&&(t.name=A.name),b(A.children)&&(t.children=A.children),b(A.jointName)&&(t.jointName=A.jointName),b(A.matrix)&&(t.matrix=A.matrix),b(A.rotation)&&(t.rotation=A.rotation),b(A.scale)&&(t.scale=A.scale),b(A.translation)&&(t.translation=A.translation),b(A.extras)&&(t.extras=A.extras),b(A.meshes)&&(t.mesh=A.meshes[0]),t}o(A){const t={};for(const e in A){const s=A[e];let n;const i={baseColorTexture:{index:s.instanceTechnique&&s.instanceTechnique.values?(n=s.instanceTechnique).values.diffuse:(n=s).values.tex||n.values.diffuseTex||n.values.diffuse}};s.name&&(i.name=s.name),s.extensions&&(i.extensions=s.extensions),s.extras&&(i.extras=s.extras),t[e]=i}return t}h(A){if(A.bufferView||A.extensions&&(A.extensions.KHR_binary_glTF||A.extensions.binary_glTF)){const t=A.bufferView?A:A.extensions.KHR_binary_glTF||A.extensions.binary_glTF;if(A.extensions&&(A.mimeType=t.mimeType,A.width=t.width,A.height=t.height),this.buffers[t.bufferView])return Promise.resolve(this.buffers[t.bufferView]);const e=this.gltf.bufferViews[t.bufferView],s=(e.byteOffset||0)+this.glbBuffer.byteOffset,n=e.byteLength,i=this.buffers[t.bufferView]=new Uint8Array(this.glbBuffer.buffer,s,n);return Promise.resolve(i)}{const t=A.uri,e=this.rootPath+"/"+t;return this.requests[e]?this.requests[e].then((()=>this.buffers[e])):this.requests[e]=p.getArrayBuffer(e,null).then((A=>{const t=A.data;return this.buffers[e]=t,new Uint8Array(t)}))}}I(A){const t=this.gltf.textures[A];if(!t)return null;const e=this.gltf.images[t.source];return this.h(e).then((A=>{const s=this.gltf.samplers[t.sampler];return{image:{array:A,width:e.width,height:e.height,index:t.source,mimeType:e.mimeType,name:e.name,extras:e.extras},type:t.type||5121,sampler:s,format:t.format||6408,internalFormat:t.internalFormat||6408}}))}getBaseColorTexture(A){const t=this.gltf.materials[A];let e,s;if(void 0===(s=t.instanceTechnique&&t.instanceTechnique.values?(e=t.instanceTechnique).values.diffuse:(e=t).values.tex||e.values.diffuseTex||e.values.diffuse)||void 0===this.gltf.textures)return null;const n=this.gltf.textures[s];if(!n)return null;const i=this.gltf.samplers[n.sampler];return{format:n.format||6408,internalFormat:n.internalFormat||6408,type:n.type||5121,sampler:i,source:this.gltf.images[n.source]}}getMaterial(){return null}getAnimations(){return null}}const E=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class D{constructor(A,t,e,s){this.rootPath=A,this.gltf=t,this.glbBuffer=e,this.buffers={},this.requests={},this.accessors={},this.ignoreGLBOffset=s}u(A,t){const e=this.gltf,s=e.accessors[t],n=e.bufferViews[s.bufferView],i=e.buffers[n.buffer];if(this.accessors[s.id])return C.resolve(this.accessors[s.id]);if(this.buffers[i.id]){const e=this.buffers[i.id],s=this.g(A,t,e);return C.resolve(s)}if(this.requests[i.id])return this.requests[i.id].then((()=>{const e=this.buffers[i.id];return this.g(A,t,e)}));if("binary_glTF"!==n.buffer&&"KHR_binary_glTF"!==n.buffer&&i.uri){if(d(i.uri)){const e=this.buffers[i.id]=v(i.uri),n=this.accessors[s.id]=this.g(A,t,e);return C.resolve(n)}const e=this.rootPath+"/"+i.uri;return this.requests[i.id]=p.getArrayBuffer(e,null).then((e=>{const n=this.buffers[i.id]=e.data;return this.accessors[s.id]=this.g(A,t,n)}))}{const e=this.accessors[s.id]=this.g(A,t,this.glbBuffer.buffer,this.ignoreGLBOffset?0:this.glbBuffer.byteOffset);return C.resolve(e)}}g(A,t,e,s=0){const n=this.gltf,i=n.accessors[t],r=n.bufferViews[i.bufferView],o=(r.byteOffset||0)+s,a=this.l(i.type),h=Q(i.componentType),c=h.BYTES_PER_ELEMENT;let I=r.byteStride||0;I===c*a&&(I=0);const u={array:void 0,name:A,accessorName:t,bufferView:i.bufferView,byteOffset:I&&i.byteOffset||0,byteStride:I,byteLength:i.count*a*h.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:a};if(i.min&&(u.min=i.min),i.max&&(u.max=i.max),s=o+(i.byteOffset||0),0===I)s%h.BYTES_PER_ELEMENT!=0&&(e=e.slice(o,o+i.count*a*h.BYTES_PER_ELEMENT),s=0),u.array=new h(e,s,a*i.count);else{const A=[];for(let t=0;t<i.count;t++){const n=e.slice(s+I*t,s+I*t+a*h.BYTES_PER_ELEMENT);A.push(n)}const t=this.concatenate(h,A);u.array=new h(t,0,a*i.count)}return delete u.bufferView,u}concatenate(A,t){let e=0;for(const s of t)e+=s.byteLength/A.BYTES_PER_ELEMENT;const s=new A(e);let n=0;for(const e of t){const t=new A(e);s.set(t,n),n+=e.byteLength/A.BYTES_PER_ELEMENT}return s.buffer}l(A){const t=E.indexOf(A);return E[t+1]}}class x{constructor(A,t,e,s,n){this.rootPath=A,this.gltf=t,this.glbBuffer=e,this.images={},this.buffers={},this.requests={},this.m=s,this.accessor=new D(A,t,e),this.imageDecoders=n}iterate(A,t){const e=this.gltf[t];if(e)for(let t=0;t<e.length;t++)A(t,e[t],t)}createNode(A){const t={};return P(t,A),!b(A.weights)&&this.gltf.meshes&&b(t.mesh)?t.weights=this.gltf.meshes[t.mesh].weights:t.weights=A.weights,t}I(A){const t=this.gltf.textures[A];if(!t)return null;const e=this.gltf.images[t.source];return this.h(e).then((A=>{const s={image:{array:A.data,width:A.width,height:A.height,index:t.source,mimeType:e.mimeType,name:e.name,extensions:e.extensions,extras:e.extras}};P(s,t);const n=b(t.sampler)?this.gltf.samplers[t.sampler]:void 0;return n&&(s.sampler=n),A.format&&(s.format=A.format),s}))}h(A){if(!b(A.bufferView))return this.B(A);{const t=this.gltf.bufferViews[A.bufferView];if(this.images[A.id])return C.resolve(this.images[A.id]);const e=this.gltf.buffers[t.buffer];if(e.uri)return this.C(e,t,A);if(this.glbBuffer)return this.P(t,A)}return null}B(A){const t=0===A.uri.indexOf("data:image/")?A.uri:this.rootPath+"/"+A.uri;return this.requests[A.id]?this.requests[A.id].then((()=>this.images[A.id])):this.requests[A.id]=this.M(A.id,t)}C(A,t,e){const s=e.id;if(this.buffers[A.id]){const n=this.buffers[A.id],i=this.D(t,n),r=new Blob([i],{type:e.mimeType}),o=URL.createObjectURL(r);return this.M(s,o)}if(this.requests[A.id])return this.requests[A.id].then((()=>{const n=this.buffers[A.id],i=this.D(t,n),r=new Blob([i],{type:e.mimeType}),o=URL.createObjectURL(r);return this.M(s,o)}));if(d(A.uri)){const n=this.buffers[A.id]=v(A.uri),i=this.D(t,n),r=new Blob([i],{type:e.mimeType}),o=URL.createObjectURL(r);return this.M(s,o)}return this.requests[A.id]=p.getArrayBuffer(A.uri,null).then((n=>{const i=this.buffers[A.id]=n.data,r=this.D(t,i),o=new Blob([r],{type:e.mimeType}),a=URL.createObjectURL(o);return this.M(s,a)}))}P(A,t){const e=this.D(A,this.glbBuffer.buffer),s=this.imageDecoders;if(s[t.mimeType])return C.resolve(s[t.mimeType](e));const n=new Blob([e],{type:t.mimeType}),i=URL.createObjectURL(n);return this.M(t.bufferView,i)}M(A,t){return new C(((e,s)=>{this.m(t,((t,n)=>{t?s(t):(this.images[A]=n,e(this.images[A]))}))}))}D(A,t,e){e=e||0;const s=A.byteOffset+e,n=A.byteLength;return new Uint8Array(t,s,n)}F(A,t){const e=new Array(A.byteLength);for(let t=0;t<A.byteLength;t++)e[t]=String.fromCharCode(A[t]);return e.join(""),"data:"+(t=t||"image/png")+";base64,"+window.btoa(unescape(encodeURIComponent(e)))}getAnimations(A){const t=[];return A.forEach((A=>{t.push(this.getSamplers(A.samplers))})),C.all(t).then((t=>{for(let e=0;e<t.length;e++)A[e].samplers=t[e];return A}))}getSamplers(A){const t=[];for(let e=0;e<A.length;e++)(b(A[e].input)||b(A[e].output))&&(t.push(this.accessor.u("input",A[e].input)),t.push(this.accessor.u("output",A[e].output)));return C.all(t).then((t=>{for(let e=0;e<t.length/2;e++)A[e].input=t[2*e],A[e].output=t[2*e+1],A[e].interpolation||(A[e].interpolation="LINEAR");return A}))}}const F="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,U=1313821514,k=5130562;class O{static read(A,t=0){const e=new DataView(A,t),s=e.getUint32(4,!0);if(1===s)return O.readV1(e,t);if(2===s)return O.readV2(A,t);throw new Error("Unsupported glb version : "+s)}static readV1(A,t){const e=A.getUint32(8,!0),s=A.getUint32(12,!0);if(e!==A.buffer.byteLength-t)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const n=L(A.buffer,20+t,s);return{json:JSON.parse(n),glbBuffer:{byteOffset:20+t+s,buffer:A.buffer}}}static readV2(A,t){let e,s;const n=new DataView(A,t+12);let i=0;for(;i<n.byteLength;){const r=n.getUint32(i,!0);i+=4;const o=n.getUint32(i,!0);if(i+=4,o===U)e=L(A,t+12+i,r);else if(o===k){const e=t+12+i;s=A.slice(e,e+r)}i+=r}return{json:JSON.parse(e),glbBuffer:{byteOffset:t,buffer:s}}}}function L(A,t,e){if(F){const s=new Uint8Array(A,t,e);return F.decode(s)}return function(A){const t=A.length;let e="";for(let s=0;s<t;){let n=A[s++];if(128&n){let e=S[n>>3&7];if(!(64&n)||!e||s+e>t)return null;for(n&=63>>e;e>0;e-=1){const t=A[s++];if(128!=(192&t))return null;n=n<<6|63&t}}e+=String.fromCharCode(n)}return e}(new Uint8Array(A,t,e))}const S=[1,1,1,1,2,2,3,0],V=[0,0,0],T=[0,0,0,1],N=[1,1,1],_={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},H={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},R={U(A,t,e,s,n,i,r,o){const a=b(A)?t.animations:[t.animations[0]],h={};for(let t=0;t<a.length;t++){const c=a[t];if(b(A)&&c.name!==A)continue;const I=c.channelsMap[e];if(I)for(let A=0;A<I.length;A++){const t=I[A];"translation"===t.target.path?(this.k(n,c.samplers[t.sampler],s,1),h.translation=u(V,n)):"rotation"===t.target.path?(this.O(i,c.samplers[t.sampler],s,1),h.rotation=B(T,i)):"scale"===t.target.path?(this.k(r,c.samplers[t.sampler],s,1),h.scale=u(N,r)):"weights"===t.target.path&&o&&(this.k(o,c.samplers[t.sampler],s,o.length),h.weights=o)}}return h},k(A,t,e,s){switch(t.interpolation){case"LINEAR":{const n=this.L(H,t,e,1*s);n&&(A=function(A,t,e,s){for(let n=0;n<A.length;n++)A[n]=t[n]+s*(e[n]-t[n]);return A}(A,n.PREVIOUS,n.NEXT,n.INTERPOLATION));break}case"STEP":{const n=this.L(H,t,e,1*s);n&&(A=function(A,t){for(let e=0;e<A.length;e++)A[e]=t[e];return A}(A,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.L(H,t,e,3*s);n&&(A=this.S(A,n,t.input.array,3*s));break}}return A},O(A,t,e){switch(t.interpolation){case"LINEAR":{const s=this.L(H,t,e,1);s&&l(A,s.PREVIOUS,s.NEXT,s.INTERPOLATION);break}case"STEP":{const s=this.L(H,t,e,1);s&&(A=g(A,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.L(H,t,e,3);if(s){for(let A=0;A<s.PREVIOUS.length;A++)s.PREVIOUS[A]=Math.acos(s.PREVIOUS[A]),s.NEXT[A]=Math.acos(s.NEXT[A]);A=this.S(A,s,t.input.array,3);for(let t=0;t<A.length;t++)A[t]=Math.cos(A[t])}break}}return A},V(A,t){const e=A.length;let s=0,n=e-1,i=Math.floor((s+n)/2);for(;s<=e-1&&n>=0;){if(s===n)return null;if(A[i]<=t&&t<=A[i+1]){const e=A[i];return{preIndx:i,nextIndex:i+1,interpolation:(t-e)/(A[i+1]-e)}}t<A[i]?(n=i,i=Math.floor((s+n)/2)):A[i+1]<t&&(s=i,i=Math.floor((s+n)/2))}return null},L(A,t,e,s){const n=t.input.array,i=t.output.array,r=t.output.itemSize;(e<n[0]||e>n[n.length-1])&&(e=Math.max(n[0],Math.min(n[n.length-1],e))),e===n[n.length-1]&&(e=n[0]);const o=this.V(n,e);if(!o||!o.nextIndex)return null;const{preIndx:a,nextIndex:h,interpolation:c}=o;A.PREINDEX=a,A.NEXTINDEX=h,A.INTERPOLATION=c;const I=r*s;return A.PREVIOUS=i.subarray(A.PREINDEX*I,(A.PREINDEX+1)*I),A.NEXT=i.subarray(A.NEXTINDEX*I,(A.NEXTINDEX+1)*I),A},S(A,t,e,s){const n=t.INTERPOLATION,i=e[t.PREINDEX],r=e[t.NEXTINDEX];for(let e=0;e<3;e++){const o=t.PREVIOUS[s+e],a=(r-i)*t.PREVIOUS[2*s+e],h=t.NEXT[3+e],c=(r-i)*t.NEXT[e],I=(2*Math.pow(n,3)-3*Math.pow(n,2)+1)*o+(Math.pow(n,3)-2*Math.pow(n,2)+n)*a+(2*-Math.pow(n,3)+3*Math.pow(n,2))*h+(Math.pow(n,3)-Math.pow(n,2))*c;A[e]=I}return A},getAnimationClip(A,t,e,s){const n=A.nodes[t]&&A.nodes[t].weights;return f(V,..._.TRANSLATION),g(T,..._.ROTATION),f(N,..._.SCALE),this.U(s,A,t,e,V,T,N,n)},getTimeSpan(A){if(!A.animations)return null;if(A.timeSpan)return A.timeSpan;const t=A.animations;return A.timeSpan={},t.forEach(((t,e)=>{let s=-1/0,n=1/0;const i=t.channels;for(let A=0;A<i.length;A++){const e=i[A],r=t.samplers[e.sampler].input.array;r[r.length-1]>s&&(s=r[r.length-1]),r[0]<n&&(n=r[0])}const r=t.name||e;A.timeSpan[r]={max:s,min:n}})),A.timeSpan},getTimeSpanByName(A,t){const e=this.getTimeSpan(A);return e?b(t)?e[t]:e[Object.keys(e)[0]]:null}},K="undefined"==typeof document?null:document.createElement("canvas");class j{constructor(A,t,e){if(this.options=e||{},t.buffer instanceof ArrayBuffer){const{json:e,glbBuffer:s}=O.read(t.buffer,t.byteOffset);this.T(A,e,s)}else this.T(A,t)}load(){const A=this.N(),t=this._(),e=this.H();return C.all([A,t,e]).then((A=>(A[0].animations=A[1],A[0].textures=A[2],this.createChannelsMap(A[0]),A[0])))}createChannelsMap(A){const t=A.animations;if(t)for(let A=0;A<t.length;A++){const e=t[A];e.channelsMap={};for(let A=0;A<e.channels.length;A++){const t=e.channels[A];e.channelsMap[t.target.node]||(e.channelsMap[t.target.node]=[]),e.channelsMap[t.target.node].push(t)}}}getExternalResources(){const A=[];if(this.gltf){const{buffers:t,images:e}=this.gltf;for(let e=0;e<t.length;e++)t[e].uri&&t[e].uri.indexOf("data:application/octet-stream;base64")<0&&A.push({type:"buffer",uri:t[e].uri});for(let t=0;t<e.length;t++)e[t].uri&&e[t].uri.indexOf("data:image/")<0&&A.push({type:"image",uri:e[t].uri})}return A}static getAnimationClip(A,t,e,s){return R.getAnimationClip(A,t,e,s)}static getAnimationTimeSpan(A,t){return R.getTimeSpanByName(A,t)}static getTypedArrayCtor(A){return Q(A)}T(A,t,e){this.gltf=t,this.version=t.asset?+t.asset.version:1,this.rootPath=A,this.glbBuffer=e,this.buffers={},this.requests={},this.options.requestImage=this.options.requestImage||G,this.options.transferable&&(this.transferables=[]),2===this.version?(this.accessor=new D(A,t,e,!0),this.adapter=new x(A,t,e,this.options.requestImage,this.options.imageDecoders||{}),this.adapter.iterate(((A,t,e)=>{t.id="buffer_"+e}),"buffers"),this.adapter.iterate(((A,t,e)=>{t.id="image_"+e}),"images"),this.adapter.iterate(((A,t,e)=>{t.id="accessor_"+e}),"accessors")):(this.accessor=new D(A,t,e),this.adapter=new M(A,t,e),this.adapter.iterate(((A,t,e)=>{t.id="accessor_"+e}),"accessors"))}R(A,t){if(A.children&&A.children.length>0){if(!("number"==typeof(e=A.children[0])&&isFinite(e)||function(A){return!y(A)&&("string"==typeof A||null!==A.constructor&&A.constructor===String)}(A.children[0])))return A;const s=A.children.map((A=>{const e=t[A];return e.nodeIndex=A,this.R(e,t)}));A.children=s}var e;return A}N(){return this.K().then((A=>{const t=this.scenes=[];let e;for(const t in A)A[t]=this.R(A[t],A),A[t].nodeIndex=Number(t)?Number(t):t;this.adapter.iterate(((s,n,i)=>{const r={};n.name&&(r.name=n.name),n.nodes&&(r.nodes=n.nodes.map((t=>A[t]))),this.gltf.scene===s&&(e=i),t.push(r)}),"scenes");const s={asset:this.gltf.asset,scene:e,scenes:t,nodes:A,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(s.extensions=this.gltf.extensions),1===this.version){const A=this.adapter.o(this.gltf.materials);s.materials=A}return s}))}K(){return this.j().then((()=>{const A=this.nodes={};return this.adapter.iterate(((t,e)=>{const s=this.adapter.createNode(e,this.meshes,this.skins);A[t]=s}),"nodes"),A}))}G(){this.skins=[];const A=[];return this.adapter.iterate(((t,e,s)=>{A.push(this.Z(e).then((A=>{A.index=s,this.skins.push(A)})))}),"skins"),A}Z(A){const t=A.inverseBindMatrices;return this.accessor.u("inverseBindMatrices",t).then((t=>(A.inverseBindMatrices=t,A)))}_(){const A=this.gltf.animations;return b(A)?this.adapter.getAnimations(A):null}j(){this.meshes={};let A=[];return this.adapter.iterate(((t,e,s)=>{A.push(this.J(e).then((A=>{A.index=s,this.meshes[t]=A})))}),"meshes"),A=A.concat(this.G()),C.all(A)}J(A){const t=A.primitives.map((A=>this.q(A)));return C.all(t).then((t=>{const e={};return P(e,A),e.primitives=t,e}))}H(){const A=this.gltf.textures;if(!A)return null;const t=[];for(const e in A)t.push(this.adapter.I(e));return C.all(t).then((t=>{if(this.transferables)for(let A=0;A<t.length;A++)if(t[A].image.array){const e=t[A].image.array.buffer;this.transferables.indexOf(e)<0&&this.transferables.push(e)}if(!Array.isArray(A)){const e={},s=Object.keys(A);for(let A=0;A<t.length;A++)e[s[A]]=t[A];return e}return t}))}q(A){const t=[],e=A.attributes;for(const A in e){const s=this.accessor.u(A,e[A]);s&&t.push(s)}if(b(A.indices)){const e=this.accessor.u("indices",A.indices);e&&t.push(e)}if(b(A.targets))for(let e=0;e<A.targets.length;e++){const s=A.targets[e];for(const A in s){const n=this.accessor.u(`morphTargets_${A}_${e}`,s[A]);n&&t.push(n)}}return C.all(t).then((t=>{let e,s;const n={attributes:t.reduce(((A,t)=>("indices"===t.name?e=t:t.name.indexOf("morphTargets_")>-1?(s=s||{})[t.name.slice(13)]=t:A[t.name]=t,this.transferables&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),A)),{}),material:A.material};return e&&(n.indices=e),s&&(n.morphTargets=s),n.mode=b(A.mode)?A.mode:4,b(A.extras)&&(n.extras=A.extras),n}))}}function G(A,t){const e=new Image;e.crossOrigin="",e.onload=()=>{if(!K)return void t(new Error("There is no canvas to draw image!"));K.width=e.width,K.height=e.height;const A=K.getContext("2d");A.drawImage(e,0,0,e.width,e.height);const s=A.getImageData(0,0,e.width,e.height),n={width:e.width,height:e.height,data:new Uint8Array(s.data)};t(null,n)},e.onerror=function(A){t(A)},e.src=A}const z=[];function Z(A,e,s,n,r,o){const a=[],h=t.quat.fromEuler([],s[0],s[1],s[2]),c=t.mat4.fromRotationTranslationScale([],h,e,n),I=function(A){return new j("",i[A]).load().then((A=>A))}(A);return I.then((A=>{const i=t.reshader.GLTFHelper.exportGLTFPack(A).getMeshesInfo(),h=new t.reshader.Material({color:r});i.forEach((A=>{const i=new t.reshader.Mesh(A.geometry,h);i.setUniform("uPickingId",o);const I=i.getDefines();I.HAS_PICKING_ID=2,i.setDefines(I),i.translate=e,i.rotation=s,i.scaling=n,t.mat4.multiply(i.localTransform,c,A.nodeMatrix),i.originTransform=t.mat4.copy([],i.localTransform),i.originColor=r,a.push(i)}))})),a}function J(A,e){const s=A.getCoordinates(),i=e.coordinateToPointAtRes(s,e.getGLRes()),r=[i.x,i.y,0],o=A.getTranslation();t.vec3.add(r,r,o);const a=function(A,t,e,s){return A._pointAtResToContainerPoint(t,e,s)}(e,new n.Point(r[0],r[1]),e.getGLRes());a.x+=170;const h=function(A,e,s,i){if(i){const r=s/A._getResolution(),o=A.width/2,a=A.height/2;z[0]=(e.x-o)/o,z[1]=e.y/a-1,z[3]=i*r;const h=t.mat4.invert([],A.projViewMatrix);t.vec3.transformMat4(z,z,h);const c=A.getGLScale();return t.vec3.set(z,z[0]/c,z[1]/c,z[2]/c),t.vec3.scale(z,z,1/r),new n.Point(z[0],z[1])}{const t=A.containerPointToCoordinate(e);return A.coordinateToPointAtRes(t,s)}}(e,a,e.getGLRes());return Math.sqrt(Math.pow(h.x-r[0],2)+Math.pow(h.y-r[1],2))/5.272881136101205}class q{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=340/177,e=Z("jiantou",[1.2*t,0,0],[0,0,90],[t,t,t],[89/255,206/255,147/255,0],7),s=Z("jiantou",[0,1.2*t,0],[0,0,180],[t,t,t],[89/255,206/255,147/255,0],8),n=Z("jiantou",[-1.2*t,0,0],[0,0,270],[t,t,t],[89/255,206/255,147/255,0],9),i=Z("jiantou",[0,-1.2*t,0],[0,0,0],[t,t,t],[89/255,206/255,147/255,0],10);return A.push(e,s,n,i),A}getMeshes(){return this._meshes}}class Y{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=340/177,e=Z("xuanzhuan",[0,0,0],[180,0,0],[.5*t,.5*t,.5*t],[50/255,130/255,184/255,.8],11);return A.push(e),A}getMeshes(){return this._meshes}}class W{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=340/177,e=Z("yuanhuan",[0,0,0],[0,0,0],[.5*t,.5*t,.5*t],[149/255,179/255,199/255,.5],12);return A.push(e),A}getMeshes(){return this._meshes}}class X{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=Z("plane",[0,0,0],[0,0,0],[10,10,10],[1,0,0,.5],16);return A.push(t),A}getMeshes(){return this._meshes}}const $=[],AA=[],tA=[],eA=[],sA=[],nA=[177/170,177/170,177/170],iA=[1,2,3,4,12];class rA{constructor(){this.translate=new q,this.rotation=new Y,this.scaling=new W,this.planeHelper=new X,this._meshes=this.W(),this.X=!0}W(){const A={};A.translate=this.translate.getMeshes(),A.rotation=this.rotation.getMeshes(),A.scaling=this.scaling.getMeshes(),A.planeHelper=this.planeHelper.getMeshes();const t=340/177,e=Z("yuanhuan41",[-2.745*t,2.745*t,0],[90,0,0],[.5*t,.5*t,.5*t],[149/255,179/255,199/255,.6],1),s=Z("yuanhuan41",[2.745*t,2.745*t,0],[-90,0,180],[.5*t,.5*t,.5*t],[50/255,130/255,184/255,.5],2),n=Z("yuanhuan41",[2.745*t,-2.745*t,0],[90,0,180],[.5*t,.5*t,.5*t],[149/255,179/255,199/255,.6],3),i=Z("yuanhuan41",[-2.745*t,-2.745*t,0],[-90,0,0],[.5*t,.5*t,.5*t],[50/255,130/255,184/255,.5],4),r=Z("yuanpan",[0,0,0],[90,0,0],[.5*t,.5*t,.5*t],[89/255,206/255,147/255,.5],5),o=Z("zzhou",[0,0,6.5],[90,0,0],[1,1,1],[14/255,127/255,191/255,1],6);return A.translate.push(e,s,n,i,r,o),A}updateMatrix(A,e,s,n,i){const r=e.getCoordinates(),o=A.coordinateToPointAtRes(r,A.getGLRes());t.vec3.set(AA,o.x,o.y,0);const a=t.vec3.copy($,i),h=e.getTranslation();t.vec3.add(AA,AA,h),t.vec3.add(AA,AA,a);for(const i in this._meshes)for(let r=0;r<this._meshes[i].length;r++){const o=this._meshes[i][r];for(let i=0;i<o.length;i++){const r=o[i],a=r.getUniform("uPickingId"),h=t.vec3.copy($,r.translate),c=[r.rotation[0],r.rotation[1],r.rotation[2]],I=r.scaling;if(11===a&&(this.X?(c[2]+=s,r.rotation[2]+=s):this.X||(c[2]+=s,r.rotation[2]+=s,c[0]=360,c[2]-=90)),iA.indexOf(a)>-1)if(12!==a)I[0]+=n,I[1]+=n,I[2]+=n;else{const A=this._meshes.translate[4][0];I[0]=1.2*A.scaling[0],I[1]=1.2*A.scaling[0],I[2]=1.2*A.scaling[0]}let u=J(e,A);if(u=t.vec3.set(tA,u,u,u),t.vec3.multiply(h,h,u),t.vec3.multiply(u,u,I),1===a||2===a||3===a||4===a){const A=t.vec3.multiply(sA,I,nA);t.vec3.multiply(h,h,A)}const f=t.quat.fromEuler(eA,c[0],c[1],c[2]);t.vec3.add(h,h,AA),t.mat4.fromRotationTranslationScale(r.localTransform,f,h,u)}}}getMeshes(A){const t={};return t.translate=this._meshes.translate,A&&"translate"!==A&&(t[A]=this._meshes[A]),t}$(A){this.X=A}dispose(){for(const A in this._meshes)for(let t=0;t<this._meshes[A].length;t++){const e=this._meshes[A][t];for(let A=0;A<e.length;A++){const t=e[A];t.geometry.dispose(),t.dispose()}}}}const oA=[5,6,7,8,9,10],aA=[5,7,8,9,10],hA=[2,4,11],cA=[1,3,12],IA=[12,16],uA=[1,2,3,4],fA=[1,2,3,4,12],gA=.01,wA=[],lA=[],mA=[],BA=[],CA=[],yA=[],bA=[];class PA extends(e.Eventable(e.Handlerable(e.Class))){constructor(A){super(A),this.options=A,this.mouseAction="moving",this.AA="translate",this.tA=!0,this.TransformHelper=new rA,this.helperScene=new t.reshader.Scene([]),this.addToMapCount=0}enable(){return this.tA=!0,this.layerRenderer&&this.layerRenderer.setToRedraw(),this}disable(){return this.tA=!1,this.layerRenderer&&this.layerRenderer.setToRedraw(),this.map&&this.map.resetCursor(),this}isEnable(){return this.tA}eA(A){oA.indexOf(A)>-1?this.AA="translate":hA.indexOf(A)>-1?this.AA="rotation":cA.indexOf(A)>-1?this.AA="scaling":this.AA="translate"}sA(){return this.AA}addTo(A){this.map&&(this.nA(),console.warn("transform control has been added to a map, it suggest remove from the map before")),this.addToMapCount++,this.map=A,this.container=A.getContainer(),A.on("dom:mousemove",this.iA,this),A.on("dom:mousedown",this.rA,this),A.on("dom:mouseup",this.oA,this),A.on("zooming moving dragrotating",this.aA,this),this.hA()}remove(){this.map&&this.container&&this.layerRenderer&&(this.nA(),this.TransformHelper.dispose(),this.layerRenderer.setToRedraw(),delete this.map,delete this.layer,delete this.layerRenderer,delete this.container,delete this.cA)}nA(){this.container&&this.map&&(this.map.off("mousemove",this.iA,this),this.map.off("mousedown",this.rA,this),this.map.off("mouseup",this.oA,this),this.map.off("zooming moving dragrotating",this.aA,this),this.layer&&this.layer.off("renderend",this.render,this))}iA(A){if(this.IA()){if(this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y},"moving"===this.mouseAction){const A=this.uA();this.currentPickingObject=this.fA(this.currentMousePosition,A,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.pickingId?(this.eA(this.currentPickingObject.pickingId),6===this.currentPickingObject.pickingId?this.gA(!0):this.gA(!1)):(this.gA(!1),this.eA()),this.wA()}this.lA(this.currentMousePosition)}}rA(A){if(!this.IA())return;const t=this.uA();this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y},this.mA=!0,this.currentPickingObject=this.fA(this.currentMousePosition,t,"meshes"),this.firstDownPoint=this.fA(this.currentMousePosition,t,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.meshId?(this.mouseAction="transform",this.BA(this.currentPickingObject.pickingId),this.map.config("zoomable",!1),this.map.config("draggable",!1),this.layerRenderer&&this.layerRenderer.setToRedraw()):(this.mouseAction="pan",this.map.config("zoomable",!0),this.map.config("draggable",!0),this.CA()),this.lastMousePosition=this.currentMousePosition,this.lastPickingObject=this.currentPickingObject,this.lastPickingMesh=t[this.currentPickingObject.meshId]}oA(){"transform"===this.mouseAction&&(this.firstDownPoint=null,this.CA(),this.mA=!0,this.fire("transformend",{action:this.yA,type:"transformend"})),this.mouseAction="moving",this.AA="translate",this.map.config("zoomable",!0),this.map.config("draggable",!0),this.layerRenderer&&this.layerRenderer.setToRedraw()}aA(){const A=this.TransformHelper.planeHelper.getMeshes()[0][0],t=this.map.getBearing();A.rotation[2]=-t,this.bA()}bA(){this.IA()&&(this.TransformHelper.updateMatrix(this.map,this.cA,0,0,[0,0,0]),this.mA=!0)}picked(A){if(!this.layerRenderer)return!1;const t=this.uA(),s=this.map;let n=A;A instanceof e.Point||(n=s.coordinateToContainerPoint(new e.Coordinate(A)));const i=this.fA(n,t,"picked");return!(!i||null===i.meshId)}CA(){const A=this.TransformHelper.getMeshes("scaling").scaling[0][0],t=340/177;A.scaling=[.6*t,.6*t,.6*t],this.layerRenderer&&(this.PA(A),this.QA())}QA(){this.TransformHelper._meshes.translate.forEach((A=>{for(let t=0;t<A.length;t++){const e=A[t];uA.indexOf(e.getUniform("uPickingId"))>-1&&e.material.set("color",e.originColor)}}))}PA(A){const e=this.cA.getCoordinates(),s=this.map.coordinateToPointAtRes(e,this.map.getGLRes()),n=[s.x,s.y,0],i=this.cA.getTranslation();t.vec3.add(n,n,i);const r=t.vec3.copy([],A.translate),o=A.scaling;let a=J(this.cA,this.map);a=t.vec3.set([],a,a,a),t.vec3.multiply(r,r,a),t.vec3.multiply(a,a,o),t.vec3.add(r,r,n),t.mat4.fromRotationTranslationScale(A.localTransform,[0,0,0,1],r,a);this.uA().forEach((A=>{const e=A.getUniform("uPickingId");if(1===e||3===e||2===e||4===e){const e=t.vec3.copy([],A.translate),s=170/177;A.scaling=[s,s,s];const i=A.scaling,r=A.rotation;let o=J(this.cA,this.map);o=t.vec3.set([],o,o,o),t.vec3.multiply(e,e,o),t.vec3.multiply(o,o,i),t.vec3.add(e,e,n);const a=t.quat.fromEuler([],r[0],r[1],r[2]);t.mat4.fromRotationTranslationScale(A.localTransform,a,e,o)}}))}dA(A){const t=this.map.containerPointToCoordinate(A),e=this.map.coordinateToPointAtRes(t,this.map.getGLRes());return{point:[e.x,e.y]}}lA(A){if("transform"===this.mouseAction){const A=this.sA(),s=this.cA.getTranslation(),n=this.cA.getRotation(),i=this.cA.getScale();let r=null,o=null;if(0===s[2]&&"z-translate"!==this.yA)r=this.dA(this.currentMousePosition),o=this.dA(this.lastMousePosition);else{const A=this.TransformHelper.planeHelper.getMeshes()[0];if(r=this.fA(this.currentMousePosition,A,"plane"),o=this.fA(this.lastMousePosition,A,"plane"),!r||null===r.meshId||!o||null===o.meshId)return}const a=[0,0,0],h=[0,0,0];let c=0,I=0,u=0;if("translate"===A){if("xy-translate"===this.yA){const A=r.point[0]-o.point[0],t=r.point[1]-o.point[1];a[0]=A,a[1]=t}else if("x-translate"===this.yA){const A=r.point[0]-o.point[0];a[0]=A}else if("y-translate"===this.yA){const A=r.point[1]-o.point[1];a[1]=A}else if("z-translate"===this.yA){let A=0;if(this.vA()){const s=this.map.getGLRes(),n=this.map._pointAtResToContainerPoint(new e.Point(o.point[0],o.point[1]),s),i=this.map._pointAtResToContainerPoint(new e.Point(r.point[0],r.point[1]),s),a=t.vec2.length(t.vec2.set(BA,r.point[0]-o.point[0],r.point[1]-o.point[1]));A=i.y<n.y?a:-a}else A=r.point[2]-o.point[2];a[2]=A}}else if("rotation"===A)I=this.pA(r.point,o.point),I>=0?this.TransformHelper.$(!0):this.TransformHelper.$(!1),h[2]+=I;else if("scaling"===A){const A=this.MA(),e=t.vec2.length(t.vec2.set(BA,this.firstDownPoint.point[0]-A[0],this.firstDownPoint.point[1]-A[1])),s=t.vec2.length(t.vec2.set(BA,o.point[0]-A[0],o.point[1]-A[1]));c=this.EA(r.point,o.point,A,s,i),u=this.EA(r.point,o.point,A,e)}const f=t.vec3.add([],a,s);let g=null;g=c>=0?c:c*(this.options&&this.options.scaleStrength||1);const w=t.vec3.add(i,t.vec3.set(BA,g,g*(i[1]/i[0]),g*(i[2]/i[0])),i);if(Math.min(...w)<gA){const A=Math.min(...i);w[0]=i[0]*(gA/A),w[1]=i[1]*(gA/A),w[2]=i[2]*(gA/A)}const l=t.vec3.add(n,h,n);this.TransformHelper.updateMatrix(this.map,this.cA,I,u,a),this.fire("transforming",{action:this.yA,type:"transforming",translate:f,rotation:l,scale:w})}this.lastMousePosition=A,this.lastPickingObject=this.currentPickingObject;const s=this.uA();this.lastPickingMesh=s[this.currentPickingObject.meshId]}EA(A,e,s,n,i){const r=(t.vec2.length(t.vec2.set(BA,A[0]-s[0],A[1]-s[1]))-t.vec2.length(t.vec2.set(BA,e[0]-s[0],e[1]-s[1])))/n;return i?(i[0]-gA)*r:r}MA(){const A=this.map,e=this.cA.getCoordinates(),s=A.coordinateToPointAtRes(e,A.getGLRes()),n=t.vec3.set(CA,s.x,s.y,0),i=this.cA.getTranslation();return t.vec3.add(n,n,i),n}gA(A){const e=this.TransformHelper.planeHelper.getMeshes()[0][0],s=t.mat4.getTranslation(mA,e.localTransform),n=t.mat4.getScaling(lA,e.localTransform);let i=t.quat.fromEuler(wA,0,0,0);const r=this.map.getBearing();A&&!this.vA()?(i=t.quat.fromEuler(wA,90,0,-r),0===e.rotation[0]&&(this.mA=!0),t.vec3.set(e.rotation,90,0,-r)):(90===e.rotation[0]&&(this.mA=!0),t.vec3.set(e.rotation,0,0,-r)),t.mat4.fromRotationTranslationScale(e.localTransform,i,s,n)}vA(){if(this.map.getPitch())return!1;const A=this.map.cameraPosition,e=this.map.coordinateToPointAtRes(this.map.getCenter(),this.map.getGLRes());t.vec3.set(e,e.x,e.y,0);const s=this.cA.getCoordinates(),n=this.map.coordinateToPointAtRes(s,this.map.getGLRes()),i=this.cA.getTranslation(),r=t.vec3.set(mA,n.x,n.y,0),o=t.vec3.add(r,r,i),a=t.vec3.subtract([],A,o),h=t.vec3.subtract([],A,e);return t.vec3.angle(a,h)<1/180*Math.PI}wA(){const A=this.uA();if(this.currentPickingObject&&null!=this.currentPickingObject.meshId){this.DA(),this.lastPickingObject&&null!=this.lastPickingObject.meshId&&this.lastPickingObject.meshId!==this.currentPickingObject.meshId&&this.xA();const t=A[this.currentPickingObject.meshId];if(t&&IA.indexOf(this.currentPickingObject.pickingId)<0){const A=[t.originColor[0],t.originColor[1],t.originColor[2],.8];t.material.set("color",A),this.FA(t,.5)}this.layerRenderer.setToRedraw()}else this.lastPickingObject&&null!=this.lastPickingObject.meshId&&(this.map.resetCursor(),this.xA(),this.layerRenderer.setToRedraw())}DA(){6===this.currentPickingObject.pickingId?this.map.setCursor("ns-resize"):aA.indexOf(this.currentPickingObject.pickingId)>-1?this.map.setCursor("move"):this.map.setCursor("pointer")}xA(){const A=this.lastPickingMesh;if(!A)return;const t=A.getUniform("uPickingId"),e=this.uA();aA.indexOf(t)>-1?e.forEach((A=>{aA.indexOf(A.getUniform("uPickingId"))>-1&&A.material.set("color",A.originColor)})):fA.indexOf(t)>-1?e.forEach((A=>{const t=A.getUniform("uPickingId");uA.indexOf(t)>-1&&A.material.set("color",A.originColor)})):11===t&&e.forEach((A=>{uA.indexOf(A.getUniform("uPickingId"))>-1&&A.material.set("color",A.originColor)})),A.material.set("color",A.originColor)}FA(A,t){const e=A.getUniform("uPickingId"),s=this.uA();aA.indexOf(e)>-1?s.forEach((e=>{if(aA.indexOf(e.getUniform("uPickingId"))>-1&&e.getUniform("uPickingId")!==A.getUniform("uPickingId")){const A=[e.originColor[0],e.originColor[1],e.originColor[2],t];e.material.set("color",A)}})):"scaling"===this.AA?s.forEach((A=>{const t=A.getUniform("uPickingId");if(1===t||3===t||2===t||4===t){const t=[149/255,179/255,199/255,.8];A.material.set("color",t)}})):"rotation"===this.AA&&s.forEach((A=>{const t=A.getUniform("uPickingId");if(1===t||3===t||2===t||4===t){const t=A.originColor;A.material.set("color",[t[0],t[1],t[2],0])}}))}reset(){if(!this.map||!this.cA)return;this.cA.setTranslation(this.cA.originTrans),this.cA.setRotation(this.UA),this.cA.setScale(this.kA);const A=this.cA.getTranslation();t.vec3.scale(A,A,-1),this.TransformHelper.updateMatrix(this.map,this.cA,0,1,[0,0,0])}pA(A,e){const s=this.MA(),n=t.vec2.set(yA,e[0]-s[0],e[1]-s[1]),i=t.vec2.set(bA,A[0]-s[0],A[1]-s[1]),r=Math.atan2(n[1],n[0]);return(Math.atan2(i[1],i[0])-r)/Math.PI*180}BA(A){return 5===A?this.yA="xy-translate":6===A?this.yA="z-translate":7===A||9===A?this.yA="x-translate":8===A||10===A?this.yA="y-translate":11===A&&(this.yA="z-rotation-scaling"),this.yA}transform(A){if(this.layerRenderer&&this.layerRenderer.layer&&(this.layerRenderer.layer.off("renderend",this.render),this.layerRenderer.layer.off("resizeCanvas",this.OA)),this.cA&&(this.cA.off("remove",this.LA,this),delete this.cA),this.cA=A,this.cA.on("remove",this.LA,this),!this.map)return void console.error("should add to a target first");const t=this.map;this.cA.originTrans||(this.cA.originTrans=this.cA.getTranslation(),this.cA.originRotation=this.cA.getRotation(),this.cA.originScale=this.cA.getScale()),this.TransformHelper.updateMatrix(t,A,0,0,[0,0,0]),this.SA(),this.mA=!0}getTransformTarget(){return this.cA}LA(){delete this.cA}SA(){const A=this.cA.getLayer();A&&(A.off("renderend",this.render),A.off("resizeCanvas",this.OA));const e=this.map.getLayers();let s=null;for(let A=0;A<e.length;A++)if(e[A]instanceof t.GroupGLLayer){s=e[A];break}if(!s)return;const n=s.getLayers(),i=n.indexOf(A);if(i<0)return;n.splice(i,1),n.push(A);const r=this.map,o=A.getRenderer();this.layerRenderer=o,this.regl=o.regl,this.renderer=o.renderer,this.VA=this.layerRenderer.getFBORayPicking(),this.TA={projViewMatrix:r.projViewMatrix},A.on("renderend",this.render,this),A.on("resizeCanvas",this.OA,this),o.setToRedraw()}OA(){this.VA.clear(),this.mA=!0}fA(A,t,e){const s=this.map;if(!(s&&this.VA&&this.layerRenderer&&this.layerRenderer.canvas))return null;const n=s.getDevicePixelRatio(),i=A.x*n,r=A.y*n,o={projViewMatrix:this.map.projViewMatrix,pointSize:1};!this.mA&&this.NA&&this.NA===e||(this.VA.render(t,o,!0),this.NA=e,this.mA=!1);return this.VA.pick(i,r,10,o,{viewMatrix:this.map.viewMatrix,projMatrix:this.map.projMatrix,returnPoint:!0})}hA(){const A=this.map.getDevicePixelRatio(),e={x:0,y:0,width:()=>this.map?this.map.width*A:1,height:()=>this.map?this.map.height*A:1};this._A=new t.reshader.MeshShader({vert:"attribute vec3 aPosition;\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main()\n\n{\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n\n\n}\n\n",frag:"precision mediump float;\n\nuniform vec4 color;\n\n\n\nvoid main() {\n\n gl_FragColor = color;\n\n}\n\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:function(A,e){return t.mat4.multiply([],e.projViewMatrix,e.modelMatrix)}}],extraCommandProps:{viewport:e,depth:{enable:!0,func:"always",mask:!1,range:[0,0]},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}},defines:{}})}render(){if(!this.IA())return;const A=this.uA();this.helperScene.setMeshes(A);const t=this.layerRenderer.getFrameContext();if(t&&t.renderTarget&&this.layerRenderer.getFrameTimestamp()!==t.timestamp)return;this.bA(),this._A.filter=t&&t.sceneFilter;const e=t&&t.renderTarget&&t.renderTarget.fbo;this.renderer.render(this._A,this.TA,this.helperScene,e)}uA(){let A=[];const t=this.TransformHelper.getMeshes(this.AA);for(const e in t){if("translate"===e)continue;const s=t[e];for(let t=0;t<s.length;t++)A=A.concat(s[t])}const e=t.translate;for(let t=0;t<e.length;t++)A=A.concat(e[t]);return A}IA(){const A=this.layerRenderer,t=A&&A.layer;return A&&this.cA&&t&&t.isVisible()&&this.cA.isVisible()&&this.regl&&this.tA}}PA.mergeOptions({scaleStrength:2}),A.TransformControl=PA,Object.defineProperty(A,"A",{value:!0}),"undefined"!=typeof console&&console.log("@maptalks/transform-control v0.6.1")}));
|
|
12
|
+
var C="undefined"!=typeof Promise?Promise:a;function y(A){return null==A}function b(A){return!y(A)}function P(A){for(let t=1;t<arguments.length;t++){const e=arguments[t];for(const t in e)A[t]=e[t]}return A}function Q(A){switch(A){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+A)}function d(A){return 0===A.indexOf("data:")&&A.indexOf("base64,")>0}function v(A){const t=A.substring(A.indexOf(",")+1),e=window.atob(t),s=e.length,n=new Uint8Array(s);for(let A=0;A<s;A++)n[A]=e.charCodeAt(A);return n.buffer}const p={get:function(A,t){const e=p.t(),s=new C(((s,n)=>{if(e.open("GET",A,!0),t){for(const A in t.headers)e.setRequestHeader(A,t.headers[A]);e.withCredentials="include"===t.credentials,t.responseType&&(e.responseType=t.responseType)}e.onreadystatechange=p.i(e,(function(A,t){A?n(A):s(t)})),e.send(null)}));return s.xhr=e,s},i:function(A,t){return function(){if(4===A.readyState)if(200===A.status)"arraybuffer"===A.responseType?0===A.response.byteLength?t(new Error("http status 200 returned without content.")):t(null,{data:A.response,cacheControl:A.getResponseHeader("Cache-Control"),expires:A.getResponseHeader("Expires"),contentType:A.getResponseHeader("Content-Type")}):t(null,A.responseText);else{if(0===A.status)return;t(new Error(A.statusText+","+A.status))}}},t:function(){let A;try{A=new XMLHttpRequest}catch(t){try{A=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{A=new ActiveXObject("Microsoft.XMLHTTP")}catch(A){}}}return A},getArrayBuffer:(A,t)=>(t||(t={}),t.responseType="arraybuffer",p.get(A,t)),getJSON:function(A,t){const e=p.get(A,t),s=e.then((A=>A?JSON.parse(A):null));return s.xhr=e.xhr,s}};class M{constructor(A,t,e){this.rootPath=A,this.gltf=t,this.requests={},this.buffers={},this.glbBuffer=e}iterate(A,t){const e=this.gltf[t];if(!e)return;let s=0;for(const t in e)A(t,e[t],s++)}createNode(A){const t={};return b(A.name)&&(t.name=A.name),b(A.children)&&(t.children=A.children),b(A.jointName)&&(t.jointName=A.jointName),b(A.matrix)&&(t.matrix=A.matrix),b(A.rotation)&&(t.rotation=A.rotation),b(A.scale)&&(t.scale=A.scale),b(A.translation)&&(t.translation=A.translation),b(A.extras)&&(t.extras=A.extras),b(A.meshes)&&(t.mesh=A.meshes[0]),t}o(A){const t={};for(const e in A){const s=A[e];let n;const i={baseColorTexture:{index:s.instanceTechnique&&s.instanceTechnique.values?(n=s.instanceTechnique).values.diffuse:(n=s).values.tex||n.values.diffuseTex||n.values.diffuse}};s.name&&(i.name=s.name),s.extensions&&(i.extensions=s.extensions),s.extras&&(i.extras=s.extras),t[e]=i}return t}h(A){if(A.bufferView||A.extensions&&(A.extensions.KHR_binary_glTF||A.extensions.binary_glTF)){const t=A.bufferView?A:A.extensions.KHR_binary_glTF||A.extensions.binary_glTF;if(A.extensions&&(A.mimeType=t.mimeType,A.width=t.width,A.height=t.height),this.buffers[t.bufferView])return Promise.resolve(this.buffers[t.bufferView]);const e=this.gltf.bufferViews[t.bufferView],s=(e.byteOffset||0)+this.glbBuffer.byteOffset,n=e.byteLength,i=this.buffers[t.bufferView]=new Uint8Array(this.glbBuffer.buffer,s,n);return Promise.resolve(i)}{const t=A.uri,e=this.rootPath+"/"+t;return this.requests[e]?this.requests[e].then((()=>this.buffers[e])):this.requests[e]=p.getArrayBuffer(e,null).then((A=>{const t=A.data;return this.buffers[e]=t,new Uint8Array(t)}))}}I(A){const t=this.gltf.textures[A];if(!t)return null;const e=this.gltf.images[t.source];return this.h(e).then((A=>{const s=this.gltf.samplers[t.sampler];return{image:{array:A,width:e.width,height:e.height,index:t.source,mimeType:e.mimeType,name:e.name,extras:e.extras},type:t.type||5121,sampler:s,format:t.format||6408,internalFormat:t.internalFormat||6408}}))}getBaseColorTexture(A){const t=this.gltf.materials[A];let e,s;if(void 0===(s=t.instanceTechnique&&t.instanceTechnique.values?(e=t.instanceTechnique).values.diffuse:(e=t).values.tex||e.values.diffuseTex||e.values.diffuse)||void 0===this.gltf.textures)return null;const n=this.gltf.textures[s];if(!n)return null;const i=this.gltf.samplers[n.sampler];return{format:n.format||6408,internalFormat:n.internalFormat||6408,type:n.type||5121,sampler:i,source:this.gltf.images[n.source]}}getMaterial(){return null}getAnimations(){return null}}const E=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class D{constructor(A,t,e,s){this.rootPath=A,this.gltf=t,this.glbBuffer=e,this.buffers={},this.requests={},this.accessors={},this.ignoreGLBOffset=s}u(A,t){const e=this.gltf,s=e.accessors[t],n=e.bufferViews[s.bufferView],i=e.buffers[n.buffer];if(this.accessors[s.id])return C.resolve(this.accessors[s.id]);if(this.buffers[i.id]){const e=this.buffers[i.id],s=this.g(A,t,e);return C.resolve(s)}if(this.requests[i.id])return this.requests[i.id].then((()=>{const e=this.buffers[i.id];return this.g(A,t,e)}));if("binary_glTF"!==n.buffer&&"KHR_binary_glTF"!==n.buffer&&i.uri){if(d(i.uri)){const e=this.buffers[i.id]=v(i.uri),n=this.accessors[s.id]=this.g(A,t,e);return C.resolve(n)}const e=this.rootPath+"/"+i.uri;return this.requests[i.id]=p.getArrayBuffer(e,null).then((e=>{const n=this.buffers[i.id]=e.data;return this.accessors[s.id]=this.g(A,t,n)}))}{const e=this.accessors[s.id]=this.g(A,t,this.glbBuffer.buffer,this.ignoreGLBOffset?0:this.glbBuffer.byteOffset);return C.resolve(e)}}g(A,t,e,s=0){const n=this.gltf,i=n.accessors[t],r=n.bufferViews[i.bufferView],o=(r.byteOffset||0)+s,a=this.l(i.type),h=Q(i.componentType),c=h.BYTES_PER_ELEMENT;let I=r.byteStride||0;I===c*a&&(I=0);const u={array:void 0,name:A,accessorName:t,bufferView:i.bufferView,byteOffset:I&&i.byteOffset||0,byteStride:I,byteLength:i.count*a*h.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:a};if(i.min&&(u.min=i.min),i.max&&(u.max=i.max),s=o+(i.byteOffset||0),0===I)s%h.BYTES_PER_ELEMENT!=0&&(e=e.slice(o,o+i.count*a*h.BYTES_PER_ELEMENT),s=0),u.array=new h(e,s,a*i.count);else{const A=[];for(let t=0;t<i.count;t++){const n=e.slice(s+I*t,s+I*t+a*h.BYTES_PER_ELEMENT);A.push(n)}const t=this.concatenate(h,A);u.array=new h(t,0,a*i.count)}return delete u.bufferView,u}concatenate(A,t){let e=0;for(const s of t)e+=s.byteLength/A.BYTES_PER_ELEMENT;const s=new A(e);let n=0;for(const e of t){const t=new A(e);s.set(t,n),n+=e.byteLength/A.BYTES_PER_ELEMENT}return s.buffer}l(A){const t=E.indexOf(A);return E[t+1]}}class x{constructor(A,t,e,s,n){this.rootPath=A,this.gltf=t,this.glbBuffer=e,this.images={},this.buffers={},this.requests={},this.m=s,this.accessor=new D(A,t,e),this.imageDecoders=n}iterate(A,t){const e=this.gltf[t];if(e)for(let t=0;t<e.length;t++)A(t,e[t],t)}createNode(A){const t={};return P(t,A),!b(A.weights)&&this.gltf.meshes&&b(t.mesh)?t.weights=this.gltf.meshes[t.mesh].weights:t.weights=A.weights,t}I(A){const t=this.gltf.textures[A];if(!t)return null;const e=this.gltf.images[t.source];return this.h(e).then((A=>{const s={image:{array:A.data,width:A.width,height:A.height,index:t.source,mimeType:e.mimeType,name:e.name,extensions:e.extensions,extras:e.extras}};P(s,t);const n=b(t.sampler)?this.gltf.samplers[t.sampler]:void 0;return n&&(s.sampler=n),A.format&&(s.format=A.format),s}))}h(A){if(!b(A.bufferView))return this.B(A);{const t=this.gltf.bufferViews[A.bufferView];if(this.images[A.id])return C.resolve(this.images[A.id]);const e=this.gltf.buffers[t.buffer];if(e.uri)return this.C(e,t,A);if(this.glbBuffer)return this.P(t,A)}return null}B(A){const t=0===A.uri.indexOf("data:image/")?A.uri:this.rootPath+"/"+A.uri;return this.requests[A.id]?this.requests[A.id].then((()=>this.images[A.id])):this.requests[A.id]=this.M(A.id,t)}C(A,t,e){const s=e.id;if(this.buffers[A.id]){const n=this.buffers[A.id],i=this.D(t,n),r=new Blob([i],{type:e.mimeType}),o=URL.createObjectURL(r);return this.M(s,o)}if(this.requests[A.id])return this.requests[A.id].then((()=>{const n=this.buffers[A.id],i=this.D(t,n),r=new Blob([i],{type:e.mimeType}),o=URL.createObjectURL(r);return this.M(s,o)}));if(d(A.uri)){const n=this.buffers[A.id]=v(A.uri),i=this.D(t,n),r=new Blob([i],{type:e.mimeType}),o=URL.createObjectURL(r);return this.M(s,o)}return this.requests[A.id]=p.getArrayBuffer(A.uri,null).then((n=>{const i=this.buffers[A.id]=n.data,r=this.D(t,i),o=new Blob([r],{type:e.mimeType}),a=URL.createObjectURL(o);return this.M(s,a)}))}P(A,t){const e=this.D(A,this.glbBuffer.buffer),s=this.imageDecoders;if(s[t.mimeType])return C.resolve(s[t.mimeType](e));const n=new Blob([e],{type:t.mimeType}),i=URL.createObjectURL(n);return this.M(t.bufferView,i)}M(A,t){return new C(((e,s)=>{this.m(t,((t,n)=>{t?s(t):(this.images[A]=n,e(this.images[A]))}))}))}D(A,t,e){e=e||0;const s=A.byteOffset+e,n=A.byteLength;return new Uint8Array(t,s,n)}F(A,t){const e=new Array(A.byteLength);for(let t=0;t<A.byteLength;t++)e[t]=String.fromCharCode(A[t]);return e.join(""),"data:"+(t=t||"image/png")+";base64,"+window.btoa(unescape(encodeURIComponent(e)))}getAnimations(A){const t=[];return A.forEach((A=>{t.push(this.getSamplers(A.samplers))})),C.all(t).then((t=>{for(let e=0;e<t.length;e++)A[e].samplers=t[e];return A}))}getSamplers(A){const t=[];for(let e=0;e<A.length;e++)(b(A[e].input)||b(A[e].output))&&(t.push(this.accessor.u("input",A[e].input)),t.push(this.accessor.u("output",A[e].output)));return C.all(t).then((t=>{for(let e=0;e<t.length/2;e++)A[e].input=t[2*e],A[e].output=t[2*e+1],A[e].interpolation||(A[e].interpolation="LINEAR");return A}))}}const F="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,U=1313821514,k=5130562;class O{static read(A,t=0){const e=new DataView(A,t),s=e.getUint32(4,!0);if(1===s)return O.readV1(e,t);if(2===s)return O.readV2(A,t);throw new Error("Unsupported glb version : "+s)}static readV1(A,t){const e=A.getUint32(8,!0),s=A.getUint32(12,!0);if(e!==A.buffer.byteLength-t)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const n=L(A.buffer,20+t,s);return{json:JSON.parse(n),glbBuffer:{byteOffset:20+t+s,buffer:A.buffer}}}static readV2(A,t){let e,s;const n=new DataView(A,t+12);let i=0;for(;i<n.byteLength;){const r=n.getUint32(i,!0);i+=4;const o=n.getUint32(i,!0);if(i+=4,o===U)e=L(A,t+12+i,r);else if(o===k){const e=t+12+i;s=A.slice(e,e+r)}i+=r}return{json:JSON.parse(e),glbBuffer:{byteOffset:t,buffer:s}}}}function L(A,t,e){if(F){const s=new Uint8Array(A,t,e);return F.decode(s)}return function(A){const t=A.length;let e="";for(let s=0;s<t;){let n=A[s++];if(128&n){let e=S[n>>3&7];if(!(64&n)||!e||s+e>t)return null;for(n&=63>>e;e>0;e-=1){const t=A[s++];if(128!=(192&t))return null;n=n<<6|63&t}}e+=String.fromCharCode(n)}return e}(new Uint8Array(A,t,e))}const S=[1,1,1,1,2,2,3,0],V=[0,0,0],T=[0,0,0,1],N=[1,1,1],_={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},H={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},R={U(A,t,e,s,n,i,r,o){const a=b(A)?t.animations:[t.animations[0]],h={};for(let t=0;t<a.length;t++){const c=a[t];if(b(A)&&c.name!==A)continue;const I=c.channelsMap[e];if(I)for(let A=0;A<I.length;A++){const t=I[A];"translation"===t.target.path?(this.k(n,c.samplers[t.sampler],s,1),h.translation=u(V,n)):"rotation"===t.target.path?(this.O(i,c.samplers[t.sampler],s,1),h.rotation=B(T,i)):"scale"===t.target.path?(this.k(r,c.samplers[t.sampler],s,1),h.scale=u(N,r)):"weights"===t.target.path&&o&&(this.k(o,c.samplers[t.sampler],s,o.length),h.weights=o)}}return h},k(A,t,e,s){switch(t.interpolation){case"LINEAR":{const n=this.L(H,t,e,1*s);n&&(A=function(A,t,e,s){for(let n=0;n<A.length;n++)A[n]=t[n]+s*(e[n]-t[n]);return A}(A,n.PREVIOUS,n.NEXT,n.INTERPOLATION));break}case"STEP":{const n=this.L(H,t,e,1*s);n&&(A=function(A,t){for(let e=0;e<A.length;e++)A[e]=t[e];return A}(A,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.L(H,t,e,3*s);n&&(A=this.S(A,n,t.input.array,3*s));break}}return A},O(A,t,e){switch(t.interpolation){case"LINEAR":{const s=this.L(H,t,e,1);s&&l(A,s.PREVIOUS,s.NEXT,s.INTERPOLATION);break}case"STEP":{const s=this.L(H,t,e,1);s&&(A=g(A,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.L(H,t,e,3);if(s){for(let A=0;A<s.PREVIOUS.length;A++)s.PREVIOUS[A]=Math.acos(s.PREVIOUS[A]),s.NEXT[A]=Math.acos(s.NEXT[A]);A=this.S(A,s,t.input.array,3);for(let t=0;t<A.length;t++)A[t]=Math.cos(A[t])}break}}return A},V(A,t){const e=A.length;let s=0,n=e-1,i=Math.floor((s+n)/2);for(;s<=e-1&&n>=0;){if(s===n)return null;if(A[i]<=t&&t<=A[i+1]){const e=A[i];return{preIndx:i,nextIndex:i+1,interpolation:(t-e)/(A[i+1]-e)}}t<A[i]?(n=i,i=Math.floor((s+n)/2)):A[i+1]<t&&(s=i,i=Math.floor((s+n)/2))}return null},L(A,t,e,s){const n=t.input.array,i=t.output.array,r=t.output.itemSize;(e<n[0]||e>n[n.length-1])&&(e=Math.max(n[0],Math.min(n[n.length-1],e))),e===n[n.length-1]&&(e=n[0]);const o=this.V(n,e);if(!o||!o.nextIndex)return null;const{preIndx:a,nextIndex:h,interpolation:c}=o;A.PREINDEX=a,A.NEXTINDEX=h,A.INTERPOLATION=c;const I=r*s;return A.PREVIOUS=i.subarray(A.PREINDEX*I,(A.PREINDEX+1)*I),A.NEXT=i.subarray(A.NEXTINDEX*I,(A.NEXTINDEX+1)*I),A},S(A,t,e,s){const n=t.INTERPOLATION,i=e[t.PREINDEX],r=e[t.NEXTINDEX];for(let e=0;e<3;e++){const o=t.PREVIOUS[s+e],a=(r-i)*t.PREVIOUS[2*s+e],h=t.NEXT[3+e],c=(r-i)*t.NEXT[e],I=(2*Math.pow(n,3)-3*Math.pow(n,2)+1)*o+(Math.pow(n,3)-2*Math.pow(n,2)+n)*a+(2*-Math.pow(n,3)+3*Math.pow(n,2))*h+(Math.pow(n,3)-Math.pow(n,2))*c;A[e]=I}return A},getAnimationClip(A,t,e,s){const n=A.nodes[t]&&A.nodes[t].weights;return f(V,..._.TRANSLATION),g(T,..._.ROTATION),f(N,..._.SCALE),this.U(s,A,t,e,V,T,N,n)},getTimeSpan(A){if(!A.animations)return null;if(A.timeSpan)return A.timeSpan;const t=A.animations;return A.timeSpan={},t.forEach(((t,e)=>{let s=-1/0,n=1/0;const i=t.channels;for(let A=0;A<i.length;A++){const e=i[A],r=t.samplers[e.sampler].input.array;r[r.length-1]>s&&(s=r[r.length-1]),r[0]<n&&(n=r[0])}const r=t.name||e;A.timeSpan[r]={max:s,min:n}})),A.timeSpan},getTimeSpanByName(A,t){const e=this.getTimeSpan(A);return e?b(t)?e[t]:e[Object.keys(e)[0]]:null}},K="undefined"==typeof document?null:document.createElement("canvas");class j{constructor(A,t,e){if(this.options=e||{},t.buffer instanceof ArrayBuffer){const{json:e,glbBuffer:s}=O.read(t.buffer,t.byteOffset);this.T(A,e,s)}else this.T(A,t)}load(){const A=this.N(),t=this._(),e=this.H();return C.all([A,t,e]).then((A=>(A[0].animations=A[1],A[0].textures=A[2],this.createChannelsMap(A[0]),A[0])))}createChannelsMap(A){const t=A.animations;if(t)for(let A=0;A<t.length;A++){const e=t[A];e.channelsMap={};for(let A=0;A<e.channels.length;A++){const t=e.channels[A];e.channelsMap[t.target.node]||(e.channelsMap[t.target.node]=[]),e.channelsMap[t.target.node].push(t)}}}getExternalResources(){const A=[];if(this.gltf){const{buffers:t,images:e}=this.gltf;for(let e=0;e<t.length;e++)t[e].uri&&t[e].uri.indexOf("data:application/octet-stream;base64")<0&&A.push({type:"buffer",uri:t[e].uri});for(let t=0;t<e.length;t++)e[t].uri&&e[t].uri.indexOf("data:image/")<0&&A.push({type:"image",uri:e[t].uri})}return A}static getAnimationClip(A,t,e,s){return R.getAnimationClip(A,t,e,s)}static getAnimationTimeSpan(A,t){return R.getTimeSpanByName(A,t)}static getTypedArrayCtor(A){return Q(A)}T(A,t,e){this.gltf=t,this.version=t.asset?+t.asset.version:1,this.rootPath=A,this.glbBuffer=e,this.buffers={},this.requests={},this.options.requestImage=this.options.requestImage||G,this.options.transferable&&(this.transferables=[]),2===this.version?(this.accessor=new D(A,t,e,!0),this.adapter=new x(A,t,e,this.options.requestImage,this.options.imageDecoders||{}),this.adapter.iterate(((A,t,e)=>{t.id="buffer_"+e}),"buffers"),this.adapter.iterate(((A,t,e)=>{t.id="image_"+e}),"images"),this.adapter.iterate(((A,t,e)=>{t.id="accessor_"+e}),"accessors")):(this.accessor=new D(A,t,e),this.adapter=new M(A,t,e),this.adapter.iterate(((A,t,e)=>{t.id="accessor_"+e}),"accessors"))}R(A,t){if(A.children&&A.children.length>0){if(!("number"==typeof(e=A.children[0])&&isFinite(e)||function(A){return!y(A)&&("string"==typeof A||null!==A.constructor&&A.constructor===String)}(A.children[0])))return A;const s=A.children.map((A=>{const e=t[A];return e.nodeIndex=A,this.R(e,t)}));A.children=s}var e;return A}N(){return this.K().then((A=>{const t=this.scenes=[];let e;for(const t in A)A[t]=this.R(A[t],A),A[t].nodeIndex=Number(t)?Number(t):t;this.adapter.iterate(((s,n,i)=>{const r={};n.name&&(r.name=n.name),n.nodes&&(r.nodes=n.nodes.map((t=>A[t]))),this.gltf.scene===s&&(e=i),t.push(r)}),"scenes");const s={asset:this.gltf.asset,scene:e,scenes:t,nodes:A,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(s.extensions=this.gltf.extensions),1===this.version){const A=this.adapter.o(this.gltf.materials);s.materials=A}return s}))}K(){return this.j().then((()=>{const A=this.nodes={};return this.adapter.iterate(((t,e)=>{const s=this.adapter.createNode(e,this.meshes,this.skins);A[t]=s}),"nodes"),A}))}G(){this.skins=[];const A=[];return this.adapter.iterate(((t,e,s)=>{A.push(this.Z(e).then((A=>{A.index=s,this.skins.push(A)})))}),"skins"),A}Z(A){const t=A.inverseBindMatrices;return this.accessor.u("inverseBindMatrices",t).then((t=>(A.inverseBindMatrices=t,A)))}_(){const A=this.gltf.animations;return b(A)?this.adapter.getAnimations(A):null}j(){this.meshes={};let A=[];return this.adapter.iterate(((t,e,s)=>{A.push(this.J(e).then((A=>{A.index=s,this.meshes[t]=A})))}),"meshes"),A=A.concat(this.G()),C.all(A)}J(A){const t=A.primitives.map((A=>this.q(A)));return C.all(t).then((t=>{const e={};return P(e,A),e.primitives=t,e}))}H(){const A=this.gltf.textures;if(!A)return null;const t=[];for(const e in A)t.push(this.adapter.I(e));return C.all(t).then((t=>{if(this.transferables)for(let A=0;A<t.length;A++)if(t[A].image.array){const e=t[A].image.array.buffer;this.transferables.indexOf(e)<0&&this.transferables.push(e)}if(!Array.isArray(A)){const e={},s=Object.keys(A);for(let A=0;A<t.length;A++)e[s[A]]=t[A];return e}return t}))}q(A){const t=[],e=A.attributes;for(const A in e){const s=this.accessor.u(A,e[A]);s&&t.push(s)}if(b(A.indices)){const e=this.accessor.u("indices",A.indices);e&&t.push(e)}if(b(A.targets))for(let e=0;e<A.targets.length;e++){const s=A.targets[e];for(const A in s){const n=this.accessor.u(`morphTargets_${A}_${e}`,s[A]);n&&t.push(n)}}return C.all(t).then((t=>{let e,s;const n={attributes:t.reduce(((A,t)=>("indices"===t.name?e=t:t.name.indexOf("morphTargets_")>-1?(s=s||{})[t.name.slice(13)]=t:A[t.name]=t,this.transferables&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),A)),{}),material:A.material};return e&&(n.indices=e),s&&(n.morphTargets=s),n.mode=b(A.mode)?A.mode:4,b(A.extras)&&(n.extras=A.extras),n}))}}function G(A,t){const e=new Image;e.crossOrigin="",e.onload=()=>{if(!K)return void t(new Error("There is no canvas to draw image!"));K.width=e.width,K.height=e.height;const A=K.getContext("2d");A.drawImage(e,0,0,e.width,e.height);const s=A.getImageData(0,0,e.width,e.height),n={width:e.width,height:e.height,data:new Uint8Array(s.data)};t(null,n)},e.onerror=function(A){t(A)},e.src=A}const z=[];function Z(A,e,s,n,r,o){const a=[],h=t.quat.fromEuler([],s[0],s[1],s[2]),c=t.mat4.fromRotationTranslationScale([],h,e,n),I=function(A){return new j("",i[A]).load().then((A=>A))}(A);return I.then((A=>{const i=t.reshader.GLTFHelper.exportGLTFPack(A).getMeshesInfo(),h=new t.reshader.Material({color:r});i.forEach((A=>{const i=new t.reshader.Mesh(A.geometry,h);i.setUniform("uPickingId",o);const I=i.getDefines();I.HAS_PICKING_ID=2,i.setDefines(I),i.translate=e,i.rotation=s,i.scaling=n,t.mat4.multiply(i.localTransform,c,A.nodeMatrix),i.originTransform=t.mat4.copy([],i.localTransform),i.originColor=r,a.push(i)}))})),a}function J(A,e){const s=A.getCoordinates(),i=e.coordinateToPointAtRes(s,e.getGLRes()),r=[i.x,i.y,0],o=A.getTranslation();t.vec3.add(r,r,o);const a=function(A,t,e,s){return A._pointAtResToContainerPoint(t,e,s)}(e,new n.Point(r[0],r[1]),e.getGLRes());a.x+=170;const h=function(A,e,s,i){if(i){const r=s/A._getResolution(),o=A.width/2,a=A.height/2;z[0]=(e.x-o)/o,z[1]=e.y/a-1,z[3]=i*r;const h=t.mat4.invert([],A.projViewMatrix);t.vec3.transformMat4(z,z,h);const c=A.getGLScale();return t.vec3.set(z,z[0]/c,z[1]/c,z[2]/c),t.vec3.scale(z,z,1/r),new n.Point(z[0],z[1])}{const t=A.containerPointToCoordinate(e);return A.coordinateToPointAtRes(t,s)}}(e,a,e.getGLRes());return Math.sqrt(Math.pow(h.x-r[0],2)+Math.pow(h.y-r[1],2))/5.272881136101205}class q{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=340/177,e=Z("jiantou",[1.2*t,0,0],[0,0,90],[t,t,t],[89/255,206/255,147/255,0],7),s=Z("jiantou",[0,1.2*t,0],[0,0,180],[t,t,t],[89/255,206/255,147/255,0],8),n=Z("jiantou",[-1.2*t,0,0],[0,0,270],[t,t,t],[89/255,206/255,147/255,0],9),i=Z("jiantou",[0,-1.2*t,0],[0,0,0],[t,t,t],[89/255,206/255,147/255,0],10);return A.push(e,s,n,i),A}getMeshes(){return this._meshes}}class Y{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=340/177,e=Z("xuanzhuan",[0,0,0],[180,0,0],[.5*t,.5*t,.5*t],[50/255,130/255,184/255,.8],11);return A.push(e),A}getMeshes(){return this._meshes}}class W{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=340/177,e=Z("yuanhuan",[0,0,0],[0,0,0],[.5*t,.5*t,.5*t],[149/255,179/255,199/255,.5],12);return A.push(e),A}getMeshes(){return this._meshes}}class X{constructor(A){this.Y=A,this._meshes=this.W()}setCoordinate(A){this.Y=A}W(){const A=[],t=Z("plane",[0,0,0],[0,0,0],[10,10,10],[1,0,0,.5],16);return A.push(t),A}getMeshes(){return this._meshes}}const $=[],AA=[],tA=[],eA=[],sA=[],nA=[177/170,177/170,177/170],iA=[1,2,3,4,12];class rA{constructor(){this.translate=new q,this.rotation=new Y,this.scaling=new W,this.planeHelper=new X,this._meshes=this.W(),this.X=!0}W(){const A={};A.translate=this.translate.getMeshes(),A.rotation=this.rotation.getMeshes(),A.scaling=this.scaling.getMeshes(),A.planeHelper=this.planeHelper.getMeshes();const t=340/177,e=Z("yuanhuan41",[-2.745*t,2.745*t,0],[90,0,0],[.5*t,.5*t,.5*t],[149/255,179/255,199/255,.6],1),s=Z("yuanhuan41",[2.745*t,2.745*t,0],[-90,0,180],[.5*t,.5*t,.5*t],[50/255,130/255,184/255,.5],2),n=Z("yuanhuan41",[2.745*t,-2.745*t,0],[90,0,180],[.5*t,.5*t,.5*t],[149/255,179/255,199/255,.6],3),i=Z("yuanhuan41",[-2.745*t,-2.745*t,0],[-90,0,0],[.5*t,.5*t,.5*t],[50/255,130/255,184/255,.5],4),r=Z("yuanpan",[0,0,0],[90,0,0],[.5*t,.5*t,.5*t],[89/255,206/255,147/255,.5],5),o=Z("zzhou",[0,0,6.5],[90,0,0],[1,1,1],[14/255,127/255,191/255,1],6);return A.translate.push(e,s,n,i,r,o),A}updateMatrix(A,e,s,n,i){const r=e.getCoordinates(),o=A.coordinateToPointAtRes(r,A.getGLRes()),a=e.getPointZ();t.vec3.set(AA,o.x,o.y,a);const h=t.vec3.copy($,i),c=e.getTranslation();t.vec3.add(AA,AA,c),t.vec3.add(AA,AA,h);for(const i in this._meshes)for(let r=0;r<this._meshes[i].length;r++){const o=this._meshes[i][r];for(let i=0;i<o.length;i++){const r=o[i],a=r.getUniform("uPickingId"),h=t.vec3.copy($,r.translate),c=[r.rotation[0],r.rotation[1],r.rotation[2]],I=r.scaling;if(11===a&&(this.X?(c[2]+=s,r.rotation[2]+=s):this.X||(c[2]+=s,r.rotation[2]+=s,c[0]=360,c[2]-=90)),iA.indexOf(a)>-1)if(12!==a)I[0]+=n,I[1]+=n,I[2]+=n;else{const A=this._meshes.translate[4][0];I[0]=1.2*A.scaling[0],I[1]=1.2*A.scaling[0],I[2]=1.2*A.scaling[0]}let u=J(e,A);if(u=t.vec3.set(tA,u,u,u),t.vec3.multiply(h,h,u),t.vec3.multiply(u,u,I),1===a||2===a||3===a||4===a){const A=t.vec3.multiply(sA,I,nA);t.vec3.multiply(h,h,A)}const f=t.quat.fromEuler(eA,c[0],c[1],c[2]);t.vec3.add(h,h,AA),t.mat4.fromRotationTranslationScale(r.localTransform,f,h,u)}}}getMeshes(A){const t={};return t.translate=this._meshes.translate,A&&"translate"!==A&&(t[A]=this._meshes[A]),t}$(A){this.X=A}dispose(){for(const A in this._meshes)for(let t=0;t<this._meshes[A].length;t++){const e=this._meshes[A][t];for(let A=0;A<e.length;A++){const t=e[A];t.geometry.dispose(),t.dispose()}}}}const oA=[5,6,7,8,9,10],aA=[5,7,8,9,10],hA=[2,4,11],cA=[1,3,12],IA=[12,16],uA=[1,2,3,4],fA=[1,2,3,4,12],gA=.01,wA=[],lA=[],mA=[],BA=[],CA=[],yA=[],bA=[];class PA extends(e.Eventable(e.Handlerable(e.Class))){constructor(A){super(A),this.options=A,this.mouseAction="moving",this.AA="translate",this.tA=!0,this.TransformHelper=new rA,this.helperScene=new t.reshader.Scene([]),this.addToMapCount=0}enable(){return this.tA=!0,this.layerRenderer&&this.layerRenderer.setToRedraw(),this}disable(){return this.tA=!1,this.layerRenderer&&this.layerRenderer.setToRedraw(),this.map&&this.map.resetCursor(),this}isEnable(){return this.tA}eA(A){oA.indexOf(A)>-1?this.AA="translate":hA.indexOf(A)>-1?this.AA="rotation":cA.indexOf(A)>-1?this.AA="scaling":this.AA="translate"}sA(){return this.AA}addTo(A){this.map&&(this.nA(),console.warn("transform control has been added to a map, it suggest remove from the map before")),this.addToMapCount++,this.map=A,this.container=A.getContainer(),A.on("dom:mousemove",this.iA,this),A.on("dom:mousedown",this.rA,this),A.on("dom:mouseup",this.oA,this),A.on("zooming moving dragrotating",this.aA,this),this.hA()}remove(){this.map&&this.container&&this.layerRenderer&&(this.nA(),this.TransformHelper.dispose(),this.layerRenderer.setToRedraw(),delete this.map,delete this.layer,delete this.layerRenderer,delete this.container,delete this.cA)}nA(){this.container&&this.map&&(this.map.off("mousemove",this.iA,this),this.map.off("mousedown",this.rA,this),this.map.off("mouseup",this.oA,this),this.map.off("zooming moving dragrotating",this.aA,this),this.layer&&this.layer.off("renderend",this.render,this))}iA(A){if(this.IA()){if(this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y},"moving"===this.mouseAction){const A=this.uA();this.currentPickingObject=this.fA(this.currentMousePosition,A,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.pickingId?(this.eA(this.currentPickingObject.pickingId),6===this.currentPickingObject.pickingId?this.gA(!0):this.gA(!1)):(this.gA(!1),this.eA()),this.wA()}this.lA(this.currentMousePosition)}}rA(A){if(!this.IA())return;const t=this.uA();this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y},this.mA=!0,this.currentPickingObject=this.fA(this.currentMousePosition,t,"meshes"),this.firstDownPoint=this.fA(this.currentMousePosition,t,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.meshId?(this.mouseAction="transform",this.BA(this.currentPickingObject.pickingId),this.map.config("zoomable",!1),this.map.config("draggable",!1),this.layerRenderer&&this.layerRenderer.setToRedraw()):(this.mouseAction="pan",this.map.config("zoomable",!0),this.map.config("draggable",!0),this.CA()),this.lastMousePosition=this.currentMousePosition,this.lastPickingObject=this.currentPickingObject,this.lastPickingMesh=t[this.currentPickingObject.meshId]}oA(){"transform"===this.mouseAction&&(this.firstDownPoint=null,this.CA(),this.mA=!0,this.fire("transformend",{action:this.yA,type:"transformend"})),this.mouseAction="moving",this.AA="translate",this.map.config("zoomable",!0),this.map.config("draggable",!0),this.layerRenderer&&this.layerRenderer.setToRedraw()}aA(){const A=this.TransformHelper.planeHelper.getMeshes()[0][0],t=this.map.getBearing();A.rotation[2]=-t,this.bA()}bA(){this.IA()&&(this.TransformHelper.updateMatrix(this.map,this.cA,0,0,[0,0,0]),this.mA=!0)}picked(A){if(!this.layerRenderer)return!1;const t=this.uA(),s=this.map;let n=A;A instanceof e.Point||(n=s.coordinateToContainerPoint(new e.Coordinate(A)));const i=this.fA(n,t,"picked");return!(!i||null===i.meshId)}CA(){const A=this.TransformHelper.getMeshes("scaling").scaling[0][0],t=340/177;A.scaling=[.6*t,.6*t,.6*t],this.layerRenderer&&(this.PA(A),this.QA())}QA(){this.TransformHelper._meshes.translate.forEach((A=>{for(let t=0;t<A.length;t++){const e=A[t];uA.indexOf(e.getUniform("uPickingId"))>-1&&e.material.set("color",e.originColor)}}))}PA(A){const e=this.cA.getCoordinates(),s=this.map.coordinateToPointAtRes(e,this.map.getGLRes()),n=[s.x,s.y,0],i=this.cA.getTranslation();t.vec3.add(n,n,i);const r=t.vec3.copy([],A.translate),o=A.scaling;let a=J(this.cA,this.map);a=t.vec3.set([],a,a,a),t.vec3.multiply(r,r,a),t.vec3.multiply(a,a,o),t.vec3.add(r,r,n),t.mat4.fromRotationTranslationScale(A.localTransform,[0,0,0,1],r,a);this.uA().forEach((A=>{const e=A.getUniform("uPickingId");if(1===e||3===e||2===e||4===e){const e=t.vec3.copy([],A.translate),s=170/177;A.scaling=[s,s,s];const i=A.scaling,r=A.rotation;let o=J(this.cA,this.map);o=t.vec3.set([],o,o,o),t.vec3.multiply(e,e,o),t.vec3.multiply(o,o,i),t.vec3.add(e,e,n);const a=t.quat.fromEuler([],r[0],r[1],r[2]);t.mat4.fromRotationTranslationScale(A.localTransform,a,e,o)}}))}dA(A){const t=this.map.containerPointToCoordinate(A),e=this.map.coordinateToPointAtRes(t,this.map.getGLRes());return{point:[e.x,e.y]}}lA(A){if("transform"===this.mouseAction){const A=this.sA(),s=this.cA.getTranslation(),n=this.cA.getPointZ(),i=this.cA.getCoordinates(),r=this.map.coordinateToPointAtRes(i,this.map.getGLRes()),o=this.cA.getRotation(),a=this.cA.getScale();let h=null,c=null;if(s[2]+n<.01&&"z-translate"!==this.yA)h=this.dA(this.currentMousePosition),c=this.dA(this.lastMousePosition);else{const A=this.TransformHelper.planeHelper.getMeshes()[0];if(h=this.fA(this.currentMousePosition,A,"plane"),c=this.fA(this.lastMousePosition,A,"plane"),!h||null===h.meshId||!c||null===c.meshId)return}const I=[0,0,0],u=[0,0,0];let f=0,g=0,w=0;if("translate"===A){if("xy-translate"===this.yA){const A=h.point[0]-c.point[0],t=h.point[1]-c.point[1];I[0]=A,I[1]=t}else if("x-translate"===this.yA){const A=h.point[0]-c.point[0];I[0]=A}else if("y-translate"===this.yA){const A=h.point[1]-c.point[1];I[1]=A}else if("z-translate"===this.yA){let A=0;if(this.vA()){const s=this.map.getGLRes(),n=this.map._pointAtResToContainerPoint(new e.Point(c.point[0],c.point[1]),s),i=this.map._pointAtResToContainerPoint(new e.Point(h.point[0],h.point[1]),s),r=t.vec2.length(t.vec2.set(BA,h.point[0]-c.point[0],h.point[1]-c.point[1]));A=i.y<n.y?r:-r}else A=h.point[2]-c.point[2];I[2]=Math.sign(A)*this.map.pointAtResToAltitude(A,this.map.getGLRes())}}else if("rotation"===A)g=this.pA(h.point,c.point),g>=0?this.TransformHelper.$(!0):this.TransformHelper.$(!1),u[2]+=g;else if("scaling"===A){const A=this.MA(),e=t.vec2.length(t.vec2.set(BA,this.firstDownPoint.point[0]-A[0],this.firstDownPoint.point[1]-A[1])),s=t.vec2.length(t.vec2.set(BA,c.point[0]-A[0],c.point[1]-A[1]));f=this.EA(h.point,c.point,A,s,a),w=this.EA(h.point,c.point,A,e)}const l=t.vec3.set([],r.x,r.y,i.z||0),m=t.vec3.add(l,l,I),B=this.map.pointAtResToCoordinate(new e.Coordinate(m[0],m[1]),this.map.getGLRes());B.z=m[2];let C=null;C=f>=0?f:f*(this.options&&this.options.scaleStrength||1);const y=t.vec3.add(a,t.vec3.set(BA,C,C*(a[1]/a[0]),C*(a[2]/a[0])),a);if(Math.min(...y)<gA){const A=Math.min(...a);y[0]=a[0]*(gA/A),y[1]=a[1]*(gA/A),y[2]=a[2]*(gA/A)}const b=t.vec3.add(o,u,o);this.TransformHelper.updateMatrix(this.map,this.cA,g,w,I),this.yA.indexOf("translate")>-1?this.fire("positionchange",{action:this.yA,type:"positionchange",target:this.cA,coordinate:B}):this.fire("transforming",{action:this.yA,type:"transforming",target:this.cA,translate:s,rotation:b,scale:y})}this.lastMousePosition=A,this.lastPickingObject=this.currentPickingObject;const s=this.uA();this.lastPickingMesh=s[this.currentPickingObject.meshId]}EA(A,e,s,n,i){const r=(t.vec2.length(t.vec2.set(BA,A[0]-s[0],A[1]-s[1]))-t.vec2.length(t.vec2.set(BA,e[0]-s[0],e[1]-s[1])))/n;return i?(i[0]-gA)*r:r}MA(){const A=this.map,e=this.cA.getCoordinates(),s=A.coordinateToPointAtRes(e,A.getGLRes()),n=t.vec3.set(CA,s.x,s.y,0),i=this.cA.getTranslation();return t.vec3.add(n,n,i),n}gA(A){const e=this.TransformHelper.planeHelper.getMeshes()[0][0],s=t.mat4.getTranslation(mA,e.localTransform),n=t.mat4.getScaling(lA,e.localTransform);let i=t.quat.fromEuler(wA,0,0,0);const r=this.map.getBearing();A&&!this.vA()?(i=t.quat.fromEuler(wA,90,0,-r),0===e.rotation[0]&&(this.mA=!0),t.vec3.set(e.rotation,90,0,-r)):(90===e.rotation[0]&&(this.mA=!0),t.vec3.set(e.rotation,0,0,-r)),t.mat4.fromRotationTranslationScale(e.localTransform,i,s,n)}vA(){if(this.map.getPitch())return!1;const A=this.map.cameraPosition,e=this.map.coordinateToPointAtRes(this.map.getCenter(),this.map.getGLRes());t.vec3.set(e,e.x,e.y,0);const s=this.cA.getCoordinates(),n=this.map.coordinateToPointAtRes(s,this.map.getGLRes()),i=this.cA.getTranslation(),r=t.vec3.set(mA,n.x,n.y,0),o=t.vec3.add(r,r,i),a=t.vec3.subtract([],A,o),h=t.vec3.subtract([],A,e);return t.vec3.angle(a,h)<1/180*Math.PI}wA(){const A=this.uA();if(this.currentPickingObject&&null!=this.currentPickingObject.meshId){this.DA(),this.lastPickingObject&&null!=this.lastPickingObject.meshId&&this.lastPickingObject.meshId!==this.currentPickingObject.meshId&&this.xA();const t=A[this.currentPickingObject.meshId];if(t&&IA.indexOf(this.currentPickingObject.pickingId)<0){const A=[t.originColor[0],t.originColor[1],t.originColor[2],.8];t.material.set("color",A),this.FA(t,.5)}this.layerRenderer.setToRedraw()}else this.lastPickingObject&&null!=this.lastPickingObject.meshId&&(this.map.resetCursor(),this.xA(),this.layerRenderer.setToRedraw())}DA(){6===this.currentPickingObject.pickingId?this.map.setCursor("ns-resize"):aA.indexOf(this.currentPickingObject.pickingId)>-1?this.map.setCursor("move"):this.map.setCursor("pointer")}xA(){const A=this.lastPickingMesh;if(!A)return;const t=A.getUniform("uPickingId"),e=this.uA();aA.indexOf(t)>-1?e.forEach((A=>{aA.indexOf(A.getUniform("uPickingId"))>-1&&A.material.set("color",A.originColor)})):fA.indexOf(t)>-1?e.forEach((A=>{const t=A.getUniform("uPickingId");uA.indexOf(t)>-1&&A.material.set("color",A.originColor)})):11===t&&e.forEach((A=>{uA.indexOf(A.getUniform("uPickingId"))>-1&&A.material.set("color",A.originColor)})),A.material.set("color",A.originColor)}FA(A,t){const e=A.getUniform("uPickingId"),s=this.uA();aA.indexOf(e)>-1?s.forEach((e=>{if(aA.indexOf(e.getUniform("uPickingId"))>-1&&e.getUniform("uPickingId")!==A.getUniform("uPickingId")){const A=[e.originColor[0],e.originColor[1],e.originColor[2],t];e.material.set("color",A)}})):"scaling"===this.AA?s.forEach((A=>{const t=A.getUniform("uPickingId");if(1===t||3===t||2===t||4===t){const t=[149/255,179/255,199/255,.8];A.material.set("color",t)}})):"rotation"===this.AA&&s.forEach((A=>{const t=A.getUniform("uPickingId");if(1===t||3===t||2===t||4===t){const t=A.originColor;A.material.set("color",[t[0],t[1],t[2],0])}}))}reset(){if(!this.map||!this.cA)return;this.cA.setTranslation(this.cA.originTrans),this.cA.setRotation(this.UA),this.cA.setScale(this.kA);const A=this.cA.getTranslation();t.vec3.scale(A,A,-1),this.TransformHelper.updateMatrix(this.map,this.cA,0,1,[0,0,0])}pA(A,e){const s=this.MA(),n=t.vec2.set(yA,e[0]-s[0],e[1]-s[1]),i=t.vec2.set(bA,A[0]-s[0],A[1]-s[1]),r=Math.atan2(n[1],n[0]);return(Math.atan2(i[1],i[0])-r)/Math.PI*180}BA(A){return this.yA=5===A?"xy-translate":6===A?"z-translate":7===A||9===A?"x-translate":8===A||10===A?"y-translate":11===A?"z-rotate":"scale",this.yA}transform(A){if(this.layerRenderer&&this.layerRenderer.layer&&(this.layerRenderer.layer.off("renderend",this.render),this.layerRenderer.layer.off("resizeCanvas",this.OA)),this.cA&&(this.cA.off("remove",this.LA,this),delete this.cA),this.cA=A,this.cA.on("remove",this.LA,this),!this.map)return void console.error("should add to a target first");const t=this.map;this.cA.originTrans||(this.cA.originTrans=this.cA.getTranslation(),this.cA.originRotation=this.cA.getRotation(),this.cA.originScale=this.cA.getScale()),this.TransformHelper.updateMatrix(t,A,0,0,[0,0,0]),this.SA(),this.mA=!0}getTransformTarget(){return this.cA}LA(){delete this.cA}SA(){const A=this.cA.getLayer();A&&(A.off("renderend",this.render),A.off("resizeCanvas",this.OA));const e=this.map.getLayers();let s=null;for(let A=0;A<e.length;A++)if(e[A]instanceof t.GroupGLLayer){s=e[A];break}if(!s)return;const n=s.getLayers(),i=n.indexOf(A);if(i<0)return;n.splice(i,1),n.push(A);const r=this.map,o=A.getRenderer();this.layerRenderer=o,this.regl=o.regl,this.renderer=o.renderer,this.VA=this.layerRenderer.getFBORayPicking(),this.TA={projViewMatrix:r.projViewMatrix},A.on("renderend",this.render,this),A.on("resizeCanvas",this.OA,this),o.setToRedraw()}OA(){this.VA.clear(),this.mA=!0}fA(A,t,e){const s=this.map;if(!(s&&this.VA&&this.layerRenderer&&this.layerRenderer.canvas))return null;const n=s.getDevicePixelRatio(),i=A.x*n,r=A.y*n,o={projViewMatrix:this.map.projViewMatrix,pointSize:1},a=this.layerRenderer.canvas.gl&&this.layerRenderer.canvas.gl.wrap;(this.mA||a||!this.NA||this.NA!==e)&&(this.VA.render(t,o,!0),this.NA=e,this.mA=!1);return this.VA.pick(i,r,10,o,{viewMatrix:this.map.viewMatrix,projMatrix:this.map.projMatrix,returnPoint:!0})}hA(){const A=this.map.getDevicePixelRatio(),e={x:0,y:0,width:()=>this.map?this.map.width*A:1,height:()=>this.map?this.map.height*A:1};this._A=new t.reshader.MeshShader({vert:"attribute vec3 aPosition;\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main()\n\n{\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n\n\n}\n\n",frag:"precision mediump float;\n\nuniform vec4 color;\n\n\n\nvoid main() {\n\n gl_FragColor = color;\n\n}\n\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:function(A,e){return t.mat4.multiply([],e.projViewMatrix,e.modelMatrix)}}],extraCommandProps:{viewport:e,depth:{enable:!0,func:"always",mask:!1,range:[0,0]},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}},defines:{}})}render(){if(!this.IA())return;const A=this.uA();this.helperScene.setMeshes(A);const t=this.layerRenderer.getFrameContext();if(t&&t.renderTarget&&this.layerRenderer.getFrameTimestamp()!==t.timestamp)return;this.bA(),this._A.filter=t&&t.sceneFilter;const e=t&&t.renderTarget&&t.renderTarget.fbo;this.renderer.render(this._A,this.TA,this.helperScene,e)}uA(){let A=[];const t=this.TransformHelper.getMeshes(this.AA);for(const e in t){if("translate"===e)continue;const s=t[e];for(let t=0;t<s.length;t++)A=A.concat(s[t])}const e=t.translate;for(let t=0;t<e.length;t++)A=A.concat(e[t]);return A}IA(){const A=this.layerRenderer,t=A&&A.layer;return A&&this.cA&&t&&t.isVisible()&&this.cA.isVisible()&&this.regl&&this.tA}}PA.mergeOptions({scaleStrength:2}),A.TransformControl=PA,Object.defineProperty(A,"A",{value:!0}),"undefined"!=typeof console&&console.log("@maptalks/transform-control v0.7.0")}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/transform-control v0.
|
|
2
|
+
* @maptalks/transform-control v0.7.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2022 maptalks.org
|
|
5
5
|
*/
|
|
@@ -868,7 +868,7 @@ class Q {
|
|
|
868
868
|
|
|
869
869
|
const l = [], b = [], y = [], v = [], M = [], E = [ 177 / 170, 177 / 170, 177 / 170 ], D = [ 1, 2, 3, 4, 12 ];
|
|
870
870
|
|
|
871
|
-
class
|
|
871
|
+
class p {
|
|
872
872
|
constructor() {
|
|
873
873
|
this.translate = new P, this.rotation = new m, this.scaling = new u, this.planeHelper = new Q,
|
|
874
874
|
this._meshes = this.t(), this.i = !0;
|
|
@@ -881,10 +881,10 @@ class d {
|
|
|
881
881
|
return A.translate.push(e, s, i, n, o, I), A;
|
|
882
882
|
}
|
|
883
883
|
updateMatrix(e, i, n, o, I) {
|
|
884
|
-
const r = i.getCoordinates(), a = e.coordinateToPointAtRes(r, e.getGLRes());
|
|
885
|
-
s.set(b, a.x, a.y,
|
|
886
|
-
const
|
|
887
|
-
s.add(b, b,
|
|
884
|
+
const r = i.getCoordinates(), a = e.coordinateToPointAtRes(r, e.getGLRes()), h = i.getPointZ();
|
|
885
|
+
s.set(b, a.x, a.y, h);
|
|
886
|
+
const g = s.copy(l, I), c = i.getTranslation();
|
|
887
|
+
s.add(b, b, c), s.add(b, b, g);
|
|
888
888
|
for (const I in this._meshes) for (let r = 0; r < this._meshes[I].length; r++) {
|
|
889
889
|
const a = this._meshes[I][r];
|
|
890
890
|
for (let I = 0; I < a.length; I++) {
|
|
@@ -924,12 +924,12 @@ class d {
|
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
|
|
927
|
-
const
|
|
927
|
+
const d = [ 5, 6, 7, 8, 9, 10 ], x = [ 5, 7, 8, 9, 10 ], F = [ 2, 4, 11 ], U = [ 1, 3, 12 ], k = [ 12, 16 ], L = [ 1, 2, 3, 4 ], V = [ 1, 2, 3, 4, 12 ], O = [], S = [], H = [], N = [], T = [], K = [], _ = [];
|
|
928
928
|
|
|
929
929
|
class R extends(I(r(a))){
|
|
930
930
|
constructor(A) {
|
|
931
931
|
super(A), this.options = A, this.mouseAction = "moving", this.I = "translate", this.h = !0,
|
|
932
|
-
this.TransformHelper = new
|
|
932
|
+
this.TransformHelper = new p, this.helperScene = new e.Scene([]), this.addToMapCount = 0;
|
|
933
933
|
}
|
|
934
934
|
enable() {
|
|
935
935
|
return this.h = !0, this.layerRenderer && this.layerRenderer.setToRedraw(), this;
|
|
@@ -942,7 +942,7 @@ class R extends(I(r(a))){
|
|
|
942
942
|
return this.h;
|
|
943
943
|
}
|
|
944
944
|
g(A) {
|
|
945
|
-
|
|
945
|
+
d.indexOf(A) > -1 ? this.I = "translate" : F.indexOf(A) > -1 ? this.I = "rotation" : U.indexOf(A) > -1 ? this.I = "scaling" : this.I = "translate";
|
|
946
946
|
}
|
|
947
947
|
B() {
|
|
948
948
|
return this.I;
|
|
@@ -1054,54 +1054,61 @@ class R extends(I(r(a))){
|
|
|
1054
1054
|
}
|
|
1055
1055
|
L(A) {
|
|
1056
1056
|
if ("transform" === this.mouseAction) {
|
|
1057
|
-
const A = this.B(), t = this.M.getTranslation(), e = this.M.
|
|
1058
|
-
let
|
|
1059
|
-
if (
|
|
1060
|
-
|
|
1057
|
+
const A = this.B(), t = this.M.getTranslation(), e = this.M.getPointZ(), n = this.M.getCoordinates(), o = this.map.coordinateToPointAtRes(n, this.map.getGLRes()), I = this.M.getRotation(), r = this.M.getScale();
|
|
1058
|
+
let a = null, c = null;
|
|
1059
|
+
if (t[2] + e < .01 && "z-translate" !== this.H) a = this._(this.currentMousePosition),
|
|
1060
|
+
c = this._(this.lastMousePosition); else {
|
|
1061
1061
|
const A = this.TransformHelper.planeHelper.getMeshes()[0];
|
|
1062
|
-
if (
|
|
1063
|
-
!
|
|
1062
|
+
if (a = this.F(this.currentMousePosition, A, "plane"), c = this.F(this.lastMousePosition, A, "plane"),
|
|
1063
|
+
!a || null === a.meshId || !c || null === c.meshId) return;
|
|
1064
1064
|
}
|
|
1065
|
-
const
|
|
1066
|
-
let
|
|
1065
|
+
const w = [ 0, 0, 0 ], B = [ 0, 0, 0 ];
|
|
1066
|
+
let f = 0, C = 0, P = 0;
|
|
1067
1067
|
if ("translate" === A) {
|
|
1068
1068
|
if ("xy-translate" === this.H) {
|
|
1069
|
-
const A =
|
|
1070
|
-
|
|
1069
|
+
const A = a.point[0] - c.point[0], t = a.point[1] - c.point[1];
|
|
1070
|
+
w[0] = A, w[1] = t;
|
|
1071
1071
|
} else if ("x-translate" === this.H) {
|
|
1072
|
-
const A =
|
|
1073
|
-
|
|
1072
|
+
const A = a.point[0] - c.point[0];
|
|
1073
|
+
w[0] = A;
|
|
1074
1074
|
} else if ("y-translate" === this.H) {
|
|
1075
|
-
const A =
|
|
1076
|
-
|
|
1075
|
+
const A = a.point[1] - c.point[1];
|
|
1076
|
+
w[1] = A;
|
|
1077
1077
|
} else if ("z-translate" === this.H) {
|
|
1078
1078
|
let A = 0;
|
|
1079
1079
|
if (this.R()) {
|
|
1080
|
-
const t = this.map.getGLRes(), e = this.map._pointAtResToContainerPoint(new h(
|
|
1080
|
+
const t = this.map.getGLRes(), e = this.map._pointAtResToContainerPoint(new h(c.point[0], c.point[1]), t), s = this.map._pointAtResToContainerPoint(new h(a.point[0], a.point[1]), t), n = i.length(i.set(N, a.point[0] - c.point[0], a.point[1] - c.point[1]));
|
|
1081
1081
|
A = s.y < e.y ? n : -n;
|
|
1082
|
-
} else A =
|
|
1083
|
-
|
|
1082
|
+
} else A = a.point[2] - c.point[2];
|
|
1083
|
+
w[2] = Math.sign(A) * this.map.pointAtResToAltitude(A, this.map.getGLRes());
|
|
1084
1084
|
}
|
|
1085
|
-
} else if ("rotation" === A)
|
|
1086
|
-
|
|
1087
|
-
const A = this.j(), t = i.length(i.set(N, this.firstDownPoint.point[0] - A[0], this.firstDownPoint.point[1] - A[1])), e = i.length(i.set(N,
|
|
1088
|
-
|
|
1085
|
+
} else if ("rotation" === A) C = this.G(a.point, c.point), C >= 0 ? this.TransformHelper.o(!0) : this.TransformHelper.o(!1),
|
|
1086
|
+
B[2] += C; else if ("scaling" === A) {
|
|
1087
|
+
const A = this.j(), t = i.length(i.set(N, this.firstDownPoint.point[0] - A[0], this.firstDownPoint.point[1] - A[1])), e = i.length(i.set(N, c.point[0] - A[0], c.point[1] - A[1]));
|
|
1088
|
+
f = this.Z(a.point, c.point, A, e, r), P = this.Z(a.point, c.point, A, t);
|
|
1089
1089
|
}
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1090
|
+
const m = s.set([], o.x, o.y, n.z || 0), u = s.add(m, m, w), Q = this.map.pointAtResToCoordinate(new g(u[0], u[1]), this.map.getGLRes());
|
|
1091
|
+
Q.z = u[2];
|
|
1092
|
+
let l = null;
|
|
1093
|
+
l = f >= 0 ? f : f * (this.options && this.options.scaleStrength || 1);
|
|
1094
|
+
const b = s.add(r, s.set(N, l, l * (r[1] / r[0]), l * (r[2] / r[0])), r);
|
|
1095
|
+
if (Math.min(...b) < .01) {
|
|
1096
|
+
const A = Math.min(...r);
|
|
1097
|
+
b[0] = r[0] * (.01 / A), b[1] = r[1] * (.01 / A), b[2] = r[2] * (.01 / A);
|
|
1097
1098
|
}
|
|
1098
|
-
const
|
|
1099
|
-
this.TransformHelper.updateMatrix(this.map, this.M,
|
|
1099
|
+
const y = s.add(I, B, I);
|
|
1100
|
+
this.TransformHelper.updateMatrix(this.map, this.M, C, P, w), this.H.indexOf("translate") > -1 ? this.fire("positionchange", {
|
|
1101
|
+
action: this.H,
|
|
1102
|
+
type: "positionchange",
|
|
1103
|
+
target: this.M,
|
|
1104
|
+
coordinate: Q
|
|
1105
|
+
}) : this.fire("transforming", {
|
|
1100
1106
|
action: this.H,
|
|
1101
1107
|
type: "transforming",
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1108
|
+
target: this.M,
|
|
1109
|
+
translate: t,
|
|
1110
|
+
rotation: y,
|
|
1111
|
+
scale: b
|
|
1105
1112
|
});
|
|
1106
1113
|
}
|
|
1107
1114
|
this.lastMousePosition = A, this.lastPickingObject = this.currentPickingObject;
|
|
@@ -1192,7 +1199,7 @@ class R extends(I(r(a))){
|
|
|
1192
1199
|
return (Math.atan2(n[1], n[0]) - o) / Math.PI * 180;
|
|
1193
1200
|
}
|
|
1194
1201
|
O(A) {
|
|
1195
|
-
return 5 === A ?
|
|
1202
|
+
return this.H = 5 === A ? "xy-translate" : 6 === A ? "z-translate" : 7 === A || 9 === A ? "x-translate" : 8 === A || 10 === A ? "y-translate" : 11 === A ? "z-rotate" : "scale",
|
|
1196
1203
|
this.H;
|
|
1197
1204
|
}
|
|
1198
1205
|
transform(A) {
|
|
@@ -1238,8 +1245,9 @@ class R extends(I(r(a))){
|
|
|
1238
1245
|
const i = s.getDevicePixelRatio(), n = A.x * i, o = A.y * i, I = {
|
|
1239
1246
|
projViewMatrix: this.map.projViewMatrix,
|
|
1240
1247
|
pointSize: 1
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1248
|
+
}, r = this.layerRenderer.canvas.gl && this.layerRenderer.canvas.gl.wrap;
|
|
1249
|
+
(this.V || r || !this.iA || this.iA !== e) && (this.eA.render(t, I, !0), this.iA = e,
|
|
1250
|
+
this.V = !1);
|
|
1243
1251
|
return this.eA.pick(n, o, 10, I, {
|
|
1244
1252
|
viewMatrix: this.map.viewMatrix,
|
|
1245
1253
|
projMatrix: this.map.projMatrix,
|
|
@@ -1317,4 +1325,4 @@ R.mergeOptions({
|
|
|
1317
1325
|
|
|
1318
1326
|
export { R as TransformControl };
|
|
1319
1327
|
|
|
1320
|
-
"undefined" != typeof console && console.log("@maptalks/transform-control v0.
|
|
1328
|
+
"undefined" != typeof console && console.log("@maptalks/transform-control v0.7.0");
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@maptalks/transform-control",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "a plugin to control model's translate、rotation and scale",
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/maptalks/transform-control.git"
|
|
9
|
-
},
|
|
10
|
-
"main": "dist/transform-control.js",
|
|
11
|
-
"browser": "dist/transform-control.js",
|
|
12
|
-
"module": "dist/transform-control.
|
|
13
|
-
"jsnext:main": "dist/transform-control.
|
|
14
|
-
"files": [
|
|
15
|
-
"dist/transform-control.js",
|
|
16
|
-
"dist/transform-control.
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"dev": "rollup -w -c rollup.config.js",
|
|
20
|
-
"build": "rollup --environment BUILD:production -c rollup.config.js",
|
|
21
|
-
"build-dev": "rollup -c rollup.config.js",
|
|
22
|
-
"pretest": "npm run lint && npm run build",
|
|
23
|
-
"test": "karma start --single-run",
|
|
24
|
-
"tdd": "karma start --no-single-run",
|
|
25
|
-
"preversion": "npm run lint",
|
|
26
|
-
"version": "npm run build",
|
|
27
|
-
"lint": "eslint src/**/*.js test/**/*.js",
|
|
28
|
-
"prepare": "npm run lint && npm run build"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@babel/core": "^7.15.0",
|
|
32
|
-
"@babel/eslint-parser": "^7.15.0",
|
|
33
|
-
"@babel/preset-env": "^7.15.0",
|
|
34
|
-
"@rollup/plugin-commonjs": "^20.0.0",
|
|
35
|
-
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
36
|
-
"@rollup/plugin-replace": "4.0.0",
|
|
37
|
-
"eslint": "^7.32.0",
|
|
38
|
-
"eslint-plugin-mocha": "^9.0.0",
|
|
39
|
-
"maptalks": "^1.0.0-rc.4",
|
|
40
|
-
"pixelmatch": "^4.0.2",
|
|
41
|
-
"rollup": "^2.56.2",
|
|
42
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
43
|
-
"expect.js": "^0.3.1",
|
|
44
|
-
"karma": "^3.1.1",
|
|
45
|
-
"karma-chrome-launcher": "^2.2.0",
|
|
46
|
-
"karma-expect": "^1.1.3",
|
|
47
|
-
"karma-ie-launcher": "^1.0.0",
|
|
48
|
-
"karma-mocha": "^1.3.0",
|
|
49
|
-
"karma-mocha-reporter": "^2.2.5",
|
|
50
|
-
"mocha": "^5.2.0"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@maptalks/gl": "<2.0.0",
|
|
54
|
-
"@maptalks/gltf-loader": "^0.11.1"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@maptalks/transform-control",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "a plugin to control model's translate、rotation and scale",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/maptalks/transform-control.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/transform-control.js",
|
|
11
|
+
"browser": "dist/transform-control.js",
|
|
12
|
+
"module": "dist/transform-control.mjs",
|
|
13
|
+
"jsnext:main": "dist/transform-control.mjs",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/transform-control.js",
|
|
16
|
+
"dist/transform-control.mjs"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "rollup -w -c rollup.config.js",
|
|
20
|
+
"build": "rollup --environment BUILD:production -c rollup.config.js",
|
|
21
|
+
"build-dev": "rollup -c rollup.config.js",
|
|
22
|
+
"pretest": "npm run lint && npm run build",
|
|
23
|
+
"test": "karma start --single-run",
|
|
24
|
+
"tdd": "karma start --no-single-run",
|
|
25
|
+
"preversion": "npm run lint",
|
|
26
|
+
"version": "npm run build",
|
|
27
|
+
"lint": "eslint src/**/*.js test/**/*.js",
|
|
28
|
+
"prepare": "npm run lint && npm run build"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@babel/core": "^7.15.0",
|
|
32
|
+
"@babel/eslint-parser": "^7.15.0",
|
|
33
|
+
"@babel/preset-env": "^7.15.0",
|
|
34
|
+
"@rollup/plugin-commonjs": "^20.0.0",
|
|
35
|
+
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
36
|
+
"@rollup/plugin-replace": "4.0.0",
|
|
37
|
+
"eslint": "^7.32.0",
|
|
38
|
+
"eslint-plugin-mocha": "^9.0.0",
|
|
39
|
+
"maptalks": "^1.0.0-rc.4",
|
|
40
|
+
"pixelmatch": "^4.0.2",
|
|
41
|
+
"rollup": "^2.56.2",
|
|
42
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
43
|
+
"expect.js": "^0.3.1",
|
|
44
|
+
"karma": "^3.1.1",
|
|
45
|
+
"karma-chrome-launcher": "^2.2.0",
|
|
46
|
+
"karma-expect": "^1.1.3",
|
|
47
|
+
"karma-ie-launcher": "^1.0.0",
|
|
48
|
+
"karma-mocha": "^1.3.0",
|
|
49
|
+
"karma-mocha-reporter": "^2.2.5",
|
|
50
|
+
"mocha": "^5.2.0"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@maptalks/gl": "<2.0.0",
|
|
54
|
+
"@maptalks/gltf-loader": "^0.11.1"
|
|
55
|
+
}
|
|
56
|
+
}
|