@antv/g-camera-api
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -1,2 +0,2 @@ | ||
import { getAngle, CameraType, deg2rad, createVec3, GlobalContainer, CameraContribution, ParseEasingFunction, injectable, Camera } from '@antv/g-lite'; | ||
import { getAngle, CameraType, deg2rad, createVec3, runtime, Camera } from '@antv/g-lite'; | ||
import { isString, isNumber } from '@antv/util'; | ||
@@ -19,24 +19,2 @@ | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __decorate(decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
/** | ||
@@ -1080,3 +1058,3 @@ * Common utilities | ||
zoom = _params.zoom; | ||
var camera = GlobalContainer.get(CameraContribution); | ||
var camera = new runtime.CameraContribution(); | ||
camera.setType(this.type, undefined); | ||
@@ -1155,3 +1133,3 @@ camera.setPosition(position[0], position[1] || this.position[1], position[2] || this.position[2]); | ||
var destRoll = landmark.roll; | ||
var easingFunc = easingFunction || GlobalContainer.get(ParseEasingFunction)(easing); | ||
var easingFunc = easingFunction || runtime.EasingFunction(easing); | ||
var timeStart; | ||
@@ -1250,12 +1228,4 @@ | ||
AdvancedCamera = __decorate([injectable({ | ||
token: CameraContribution | ||
})], AdvancedCamera); | ||
runtime.CameraContribution = AdvancedCamera; | ||
/** | ||
* Override CameraContribution | ||
*/ | ||
GlobalContainer.register(AdvancedCamera); | ||
export { AdvancedCamera }; |
@@ -23,24 +23,2 @@ 'use strict'; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __decorate(decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
/** | ||
@@ -964,3 +942,3 @@ * Common utilities | ||
exports.AdvancedCamera = /*#__PURE__*/function (_Camera) { | ||
var AdvancedCamera = /*#__PURE__*/function (_Camera) { | ||
_inheritsLoose(AdvancedCamera, _Camera); | ||
@@ -1085,3 +1063,3 @@ | ||
zoom = _params.zoom; | ||
var camera = gLite.GlobalContainer.get(gLite.CameraContribution); | ||
var camera = new gLite.runtime.CameraContribution(); | ||
camera.setType(this.type, undefined); | ||
@@ -1160,3 +1138,3 @@ camera.setPosition(position[0], position[1] || this.position[1], position[2] || this.position[2]); | ||
var destRoll = landmark.roll; | ||
var easingFunc = easingFunction || gLite.GlobalContainer.get(gLite.ParseEasingFunction)(easing); | ||
var easingFunc = easingFunction || gLite.runtime.EasingFunction(easing); | ||
var timeStart; | ||
@@ -1255,10 +1233,4 @@ | ||
exports.AdvancedCamera = __decorate([gLite.injectable({ | ||
token: gLite.CameraContribution | ||
})], exports.AdvancedCamera); | ||
gLite.runtime.CameraContribution = AdvancedCamera; | ||
/** | ||
* Override CameraContribution | ||
*/ | ||
gLite.GlobalContainer.register(exports.AdvancedCamera); | ||
exports.AdvancedCamera = AdvancedCamera; |
@@ -22,24 +22,2 @@ (function (global, factory) { | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __decorate(decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
} | ||
/** | ||
@@ -978,3 +956,3 @@ * Common utilities | ||
exports.AdvancedCamera = /*#__PURE__*/function (_Camera) { | ||
var AdvancedCamera = /*#__PURE__*/function (_Camera) { | ||
_inheritsLoose(AdvancedCamera, _Camera); | ||
@@ -1099,3 +1077,3 @@ | ||
zoom = _params.zoom; | ||
var camera = gLite.GlobalContainer.get(gLite.CameraContribution); | ||
var camera = new gLite.runtime.CameraContribution(); | ||
camera.setType(this.type, undefined); | ||
@@ -1174,3 +1152,3 @@ camera.setPosition(position[0], position[1] || this.position[1], position[2] || this.position[2]); | ||
var destRoll = landmark.roll; | ||
var easingFunc = easingFunction || gLite.GlobalContainer.get(gLite.ParseEasingFunction)(easing); | ||
var easingFunc = easingFunction || gLite.runtime.EasingFunction(easing); | ||
var timeStart; | ||
@@ -1269,14 +1247,8 @@ | ||
exports.AdvancedCamera = __decorate([gLite.injectable({ | ||
token: gLite.CameraContribution | ||
})], exports.AdvancedCamera); | ||
gLite.runtime.CameraContribution = AdvancedCamera; | ||
/** | ||
* Override CameraContribution | ||
*/ | ||
exports.AdvancedCamera = AdvancedCamera; | ||
gLite.GlobalContainer.register(exports.AdvancedCamera); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],i):i(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CameraAPI={}),t.window.G)}(this,(function(t,i){"use strict";function e(t,i){return e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},e(t,i)}var n="undefined"!=typeof Float32Array?Float32Array:Array;function o(t){var i=new n(16);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i}function r(t,i,e){var n,o,r,a,s,l,h,c,u,d,f,m,p=e[0],v=e[1],g=e[2];return i===t?(t[12]=i[0]*p+i[4]*v+i[8]*g+i[12],t[13]=i[1]*p+i[5]*v+i[9]*g+i[13],t[14]=i[2]*p+i[6]*v+i[10]*g+i[14],t[15]=i[3]*p+i[7]*v+i[11]*g+i[15]):(o=i[1],r=i[2],a=i[3],s=i[4],l=i[5],h=i[6],c=i[7],u=i[8],d=i[9],f=i[10],m=i[11],t[0]=n=i[0],t[1]=o,t[2]=r,t[3]=a,t[4]=s,t[5]=l,t[6]=h,t[7]=c,t[8]=u,t[9]=d,t[10]=f,t[11]=m,t[12]=n*p+s*v+u*g+i[12],t[13]=o*p+l*v+d*g+i[13],t[14]=r*p+h*v+f*g+i[14],t[15]=a*p+c*v+m*g+i[15]),t}function a(){var t=new n(3);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function s(t){var i=new n(3);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i}function l(t,i,e){var o=new n(3);return o[0]=t,o[1]=i,o[2]=e,o}function h(t,i){return t[0]=i[0],t[1]=i[1],t[2]=i[2],t}function c(t,i,e){return t[0]=i[0]+e[0],t[1]=i[1]+e[1],t[2]=i[2]+e[2],t}function u(t,i,e){return t[0]=i[0]*e,t[1]=i[1]*e,t[2]=i[2]*e,t}function d(t,i,e){var n=i[0],o=i[1],r=i[2],a=e[0],s=e[1],l=e[2];return t[0]=o*l-r*s,t[1]=r*a-n*l,t[2]=n*s-o*a,t}function f(t,i,e,n){var o=i[0],r=i[1],a=i[2];return t[0]=o+n*(e[0]-o),t[1]=r+n*(e[1]-r),t[2]=a+n*(e[2]-a),t}Math.hypot||(Math.hypot=function(){for(var t=0,i=arguments.length;i--;)t+=arguments[i]*arguments[i];return Math.sqrt(t)});var m,p=function(t,i){return Math.hypot(i[0]-t[0],i[1]-t[1],i[2]-t[2])},v=function(t){return Math.hypot(t[0],t[1],t[2])};m=a();!function(){var t,i=(t=new n(4),n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();function g(){var t=new n(4);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function y(t,i,e){e*=.5;var n=Math.sin(e);return t[0]=n*i[0],t[1]=n*i[1],t[2]=n*i[2],t[3]=Math.cos(e),t}function A(t,i,e){var n=i[0],o=i[1],r=i[2],a=i[3],s=e[0],l=e[1],h=e[2],c=e[3];return t[0]=n*c+a*s+o*h-r*l,t[1]=o*c+a*l+r*s-n*h,t[2]=r*c+a*h+n*l-o*s,t[3]=a*c-n*s-o*l-r*h,t}function P(t,i,e,n){var o,r,a,s,l,h=i[0],c=i[1],u=i[2],d=i[3],f=e[0],m=e[1],p=e[2],v=e[3];return 0>(r=h*f+c*m+u*p+d*v)&&(r=-r,f=-f,m=-m,p=-p,v=-v),1-r>1e-6?(o=Math.acos(r),a=Math.sin(o),s=Math.sin((1-n)*o)/a,l=Math.sin(n*o)/a):(s=1-n,l=n),t[0]=s*h+l*f,t[1]=s*c+l*m,t[2]=s*u+l*p,t[3]=s*d+l*v,t}var C,R,b,x,z,F,M,w=function(t,i){var e=i[0],n=i[1],o=i[2],r=i[3],a=e*e+n*n+o*o+r*r;return a>0&&(a=1/Math.sqrt(a)),t[0]=e*a,t[1]=n*a,t[2]=o*a,t[3]=r*a,t},T=(C=a(),R=l(1,0,0),b=l(0,1,0),x=g(),z=g(),F=new n(9),n!=Float32Array&&(F[1]=0,F[2]=0,F[3]=0,F[5]=0,F[6]=0,F[7]=0),F[0]=1,F[4]=1,F[8]=1,M=F,{}.toString),G=function(t,i){return T.call(t)==="[object "+i+"]"};t.AdvancedCamera=function(t){var l,d;function m(){for(var i,e=arguments.length,n=new Array(e),o=0;e>o;o++)n[o]=arguments[o];return(i=t.call.apply(t,[this].concat(n))||this).landmarks=[],i.landmarkAnimationID=void 0,i}d=t,(l=m).prototype=Object.create(d.prototype),l.prototype.constructor=l,e(l,d);var v=m.prototype;return v.rotate=function(t,e,o){if(this.relElevation=i.getAngle(e),this.relAzimuth=i.getAngle(t),this.relRoll=i.getAngle(o),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===i.CameraType.EXPLORING){var a=y(g(),[1,0,0],i.deg2rad((this.rotateWorld?1:-1)*this.relElevation)),s=y(g(),[0,1,0],i.deg2rad((this.rotateWorld?1:-1)*this.relAzimuth)),l=y(g(),[0,0,1],i.deg2rad(this.relRoll)),h=A(g(),s,a);h=A(g(),h,l);var c=function(t,i){var e=i[0],n=i[1],o=i[2],r=i[3],a=e+e,s=n+n,l=o+o,h=e*a,c=n*a,u=n*s,d=o*a,f=o*s,m=o*l,p=r*a,v=r*s,g=r*l;return t[0]=1-u-m,t[1]=c+g,t[2]=d-v,t[3]=0,t[4]=c-g,t[5]=1-h-m,t[6]=f+p,t[7]=0,t[8]=d+v,t[9]=f-p,t[10]=1-h-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(function(){var t=new n(16);return n!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}(),h);r(this.matrix,this.matrix,[0,0,-this.distance]),function(t,i,e){var n=i[0],o=i[1],r=i[2],a=i[3],s=i[4],l=i[5],h=i[6],c=i[7],u=i[8],d=i[9],f=i[10],m=i[11],p=i[12],v=i[13],g=i[14],y=i[15],A=e[0],P=e[1],C=e[2],R=e[3];t[0]=A*n+P*s+C*u+R*p,t[1]=A*o+P*l+C*d+R*v,t[2]=A*r+P*h+C*f+R*g,t[3]=A*a+P*c+C*m+R*y,t[4]=(A=e[4])*n+(P=e[5])*s+(C=e[6])*u+(R=e[7])*p,t[5]=A*o+P*l+C*d+R*v,t[6]=A*r+P*h+C*f+R*g,t[7]=A*a+P*c+C*m+R*y,t[8]=(A=e[8])*n+(P=e[9])*s+(C=e[10])*u+(R=e[11])*p,t[9]=A*o+P*l+C*d+R*v,t[10]=A*r+P*h+C*f+R*g,t[11]=A*a+P*c+C*m+R*y,t[12]=(A=e[12])*n+(P=e[13])*s+(C=e[14])*u+(R=e[15])*p,t[13]=A*o+P*l+C*d+R*v,t[14]=A*r+P*h+C*f+R*g,t[15]=A*a+P*c+C*m+R*y}(this.matrix,this.matrix,c),r(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===i.CameraType.ORBITING||this.type===i.CameraType.EXPLORING?this._getPosition():this.type===i.CameraType.TRACKING&&this._getFocalPoint(),this._update(),this},v.pan=function(t,e){var n=i.createVec3(t,e,0),o=s(this.position);return c(o,o,u(a(),this.right,n[0])),c(o,o,u(a(),this.up,n[1])),this._setPosition(o),this.triggerUpdate(),this},v.dolly=function(t){var e,n=this.forward,o=s(this.position);return e=Math.max(Math.min(this.distance+t*this.dollyingStep,this.maxDistance),this.minDistance)-this.distance,o[0]+=e*n[0],o[1]+=e*n[1],o[2]+=e*n[2],this._setPosition(o),this.type===i.CameraType.ORBITING||this.type===i.CameraType.EXPLORING?this._getDistance():this.type===i.CameraType.TRACKING&&c(this.focalPoint,o,this.distanceVector),this.triggerUpdate(),this},v.createLandmark=function(t,e){void 0===e&&(e={});var n=e.position,r=void 0===n?this.position:n,a=e.focalPoint,l=void 0===a?this.focalPoint:a,h=e.roll,c=e.zoom,u=i.GlobalContainer.get(i.CameraContribution);u.setType(this.type,void 0),u.setPosition(r[0],r[1]||this.position[1],r[2]||this.position[2]),u.setFocalPoint(l[0],l[1]||this.focalPoint[1],l[2]||this.focalPoint[2]),u.setRoll(h||this.roll),u.setZoom(c||this.zoom);var d={name:t,matrix:o(u.getWorldTransform()),right:s(u.right),up:s(u.up),forward:s(u.forward),position:s(u.getPosition()),focalPoint:s(u.getFocalPoint()),distanceVector:s(u.getDistanceVector()),distance:u.getDistance(),dollyingStep:u.getDollyingStep(),azimuth:u.getAzimuth(),elevation:u.getElevation(),roll:u.getRoll(),relAzimuth:u.relAzimuth,relElevation:u.relElevation,relRoll:u.relRoll,zoom:u.getZoom()};return this.landmarks.push(d),d},v.gotoLandmark=function(t,e){var n=this;void 0===e&&(e={});var o=G(t,"String")?this.landmarks.find((function(i){return i.name===t})):t;if(o){var r=G(e,"Number")?{duration:e}:e,s=r.easing,l=void 0===s?"linear":s,h=r.duration,c=void 0===h?100:h,u=r.easingFunction,d=void 0===u?void 0:u,m=r.onfinish,v=void 0===m?void 0:m;if(0===c)return this.syncFromLandmark(o),void(v&&v());void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID);var g,y=o.position,A=o.focalPoint,P=o.zoom,C=o.roll,R=d||i.GlobalContainer.get(i.ParseEasingFunction)(l),b=function(){n.setFocalPoint(A),n.setPosition(y),n.setRoll(C),n.setZoom(P),n.computeMatrix(),n.triggerUpdate(),v&&v()};this.canvas.requestAnimationFrame((function t(i){void 0===g&&(g=i);var e=i-g;if(c<e)b();else{var o,r,s=R(e/c),l=a(),h=a();f(l,n.focalPoint,A,s),f(h,n.position,y,s),r=n.roll*(1-s)+C*s,o=n.zoom*(1-s)+P*s,n.setFocalPoint(l),n.setPosition(h),n.setRoll(r),n.setZoom(o),p(l,A)+p(h,y)>.01?(n.computeMatrix(),n.triggerUpdate(),c>e&&(n.landmarkAnimationID=n.canvas.requestAnimationFrame(t))):b()}}))}},v.syncFromLandmark=function(t){this.matrix=function(t,i){return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t}(this.matrix,t.matrix),this.right=h(this.right,t.right),this.up=h(this.up,t.up),this.forward=h(this.forward,t.forward),this.position=h(this.position,t.position),this.focalPoint=h(this.focalPoint,t.focalPoint),this.distanceVector=h(this.distanceVector,t.distanceVector),this.azimuth=t.azimuth,this.elevation=t.elevation,this.roll=t.roll,this.relAzimuth=t.relAzimuth,this.relElevation=t.relElevation,this.relRoll=t.relRoll,this.dollyingStep=t.dollyingStep,this.distance=t.distance,this.zoom=t.zoom},m}(i.Camera),t.AdvancedCamera=function(t,i,e,n){var o,r=arguments.length,a=3>r?i:null===n?n=Object.getOwnPropertyDescriptor(i,e):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,i,e,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(3>r?o(a):r>3?o(i,e,a):o(i,e))||a);return r>3&&a&&Object.defineProperty(i,e,a),a}([i.injectable({token:i.CameraContribution})],t.AdvancedCamera),i.GlobalContainer.register(t.AdvancedCamera),Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],i):i(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CameraAPI={}),t.window.G)}(this,(function(t,i){"use strict";function n(t,i){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},n(t,i)}var o="undefined"!=typeof Float32Array?Float32Array:Array;function e(t){var i=new o(16);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i}function r(t,i,n){var o,e,r,a,s,h,l,u,c,m,d,f,p=n[0],v=n[1],g=n[2];return i===t?(t[12]=i[0]*p+i[4]*v+i[8]*g+i[12],t[13]=i[1]*p+i[5]*v+i[9]*g+i[13],t[14]=i[2]*p+i[6]*v+i[10]*g+i[14],t[15]=i[3]*p+i[7]*v+i[11]*g+i[15]):(e=i[1],r=i[2],a=i[3],s=i[4],h=i[5],l=i[6],u=i[7],c=i[8],m=i[9],d=i[10],f=i[11],t[0]=o=i[0],t[1]=e,t[2]=r,t[3]=a,t[4]=s,t[5]=h,t[6]=l,t[7]=u,t[8]=c,t[9]=m,t[10]=d,t[11]=f,t[12]=o*p+s*v+c*g+i[12],t[13]=e*p+h*v+m*g+i[13],t[14]=r*p+l*v+d*g+i[14],t[15]=a*p+u*v+f*g+i[15]),t}function a(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function s(t){var i=new o(3);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i}function h(t,i,n){var e=new o(3);return e[0]=t,e[1]=i,e[2]=n,e}function l(t,i){return t[0]=i[0],t[1]=i[1],t[2]=i[2],t}function u(t,i,n){return t[0]=i[0]+n[0],t[1]=i[1]+n[1],t[2]=i[2]+n[2],t}function c(t,i,n){return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t}function m(t,i,n){var o=i[0],e=i[1],r=i[2],a=n[0],s=n[1],h=n[2];return t[0]=e*h-r*s,t[1]=r*a-o*h,t[2]=o*s-e*a,t}function d(t,i,n,o){var e=i[0],r=i[1],a=i[2];return t[0]=e+o*(n[0]-e),t[1]=r+o*(n[1]-r),t[2]=a+o*(n[2]-a),t}Math.hypot||(Math.hypot=function(){for(var t=0,i=arguments.length;i--;)t+=arguments[i]*arguments[i];return Math.sqrt(t)});var f,p=function(t,i){return Math.hypot(i[0]-t[0],i[1]-t[1],i[2]-t[2])},v=function(t){return Math.hypot(t[0],t[1],t[2])};f=a();!function(){var t,i=(t=new o(4),o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();function g(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function y(t,i,n){n*=.5;var o=Math.sin(n);return t[0]=o*i[0],t[1]=o*i[1],t[2]=o*i[2],t[3]=Math.cos(n),t}function A(t,i,n){var o=i[0],e=i[1],r=i[2],a=i[3],s=n[0],h=n[1],l=n[2],u=n[3];return t[0]=o*u+a*s+e*l-r*h,t[1]=e*u+a*h+r*s-o*l,t[2]=r*u+a*l+o*h-e*s,t[3]=a*u-o*s-e*h-r*l,t}function P(t,i,n,o){var e,r,a,s,h,l=i[0],u=i[1],c=i[2],m=i[3],d=n[0],f=n[1],p=n[2],v=n[3];return 0>(r=l*d+u*f+c*p+m*v)&&(r=-r,d=-d,f=-f,p=-p,v=-v),1-r>1e-6?(e=Math.acos(r),a=Math.sin(e),s=Math.sin((1-o)*e)/a,h=Math.sin(o*e)/a):(s=1-o,h=o),t[0]=s*l+h*d,t[1]=s*u+h*f,t[2]=s*c+h*p,t[3]=s*m+h*v,t}var x,z,F,M,w,R,C,T=function(t,i){var n=i[0],o=i[1],e=i[2],r=i[3],a=n*n+o*o+e*e+r*r;return a>0&&(a=1/Math.sqrt(a)),t[0]=n*a,t[1]=o*a,t[2]=e*a,t[3]=r*a,t},I=(x=a(),z=h(1,0,0),F=h(0,1,0),M=g(),w=g(),R=new o(9),o!=Float32Array&&(R[1]=0,R[2]=0,R[3]=0,R[5]=0,R[6]=0,R[7]=0),R[0]=1,R[4]=1,R[8]=1,C=R,{}.toString),b=function(t,i){return I.call(t)==="[object "+i+"]"},_=function(t){var h,m;function f(){for(var i,n=arguments.length,o=new Array(n),e=0;n>e;e++)o[e]=arguments[e];return(i=t.call.apply(t,[this].concat(o))||this).landmarks=[],i.landmarkAnimationID=void 0,i}m=t,(h=f).prototype=Object.create(m.prototype),h.prototype.constructor=h,n(h,m);var v=f.prototype;return v.rotate=function(t,n,e){if(this.relElevation=i.getAngle(n),this.relAzimuth=i.getAngle(t),this.relRoll=i.getAngle(e),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===i.CameraType.EXPLORING){var a=y(g(),[1,0,0],i.deg2rad((this.rotateWorld?1:-1)*this.relElevation)),s=y(g(),[0,1,0],i.deg2rad((this.rotateWorld?1:-1)*this.relAzimuth)),h=y(g(),[0,0,1],i.deg2rad(this.relRoll)),l=A(g(),s,a);l=A(g(),l,h);var u=function(t,i){var n=i[0],o=i[1],e=i[2],r=i[3],a=n+n,s=o+o,h=e+e,l=n*a,u=o*a,c=o*s,m=e*a,d=e*s,f=e*h,p=r*a,v=r*s,g=r*h;return t[0]=1-c-f,t[1]=u+g,t[2]=m-v,t[3]=0,t[4]=u-g,t[5]=1-l-f,t[6]=d+p,t[7]=0,t[8]=m+v,t[9]=d-p,t[10]=1-l-c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(function(){var t=new o(16);return o!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}(),l);r(this.matrix,this.matrix,[0,0,-this.distance]),function(t,i,n){var o=i[0],e=i[1],r=i[2],a=i[3],s=i[4],h=i[5],l=i[6],u=i[7],c=i[8],m=i[9],d=i[10],f=i[11],p=i[12],v=i[13],g=i[14],y=i[15],A=n[0],P=n[1],x=n[2],z=n[3];t[0]=A*o+P*s+x*c+z*p,t[1]=A*e+P*h+x*m+z*v,t[2]=A*r+P*l+x*d+z*g,t[3]=A*a+P*u+x*f+z*y,t[4]=(A=n[4])*o+(P=n[5])*s+(x=n[6])*c+(z=n[7])*p,t[5]=A*e+P*h+x*m+z*v,t[6]=A*r+P*l+x*d+z*g,t[7]=A*a+P*u+x*f+z*y,t[8]=(A=n[8])*o+(P=n[9])*s+(x=n[10])*c+(z=n[11])*p,t[9]=A*e+P*h+x*m+z*v,t[10]=A*r+P*l+x*d+z*g,t[11]=A*a+P*u+x*f+z*y,t[12]=(A=n[12])*o+(P=n[13])*s+(x=n[14])*c+(z=n[15])*p,t[13]=A*e+P*h+x*m+z*v,t[14]=A*r+P*l+x*d+z*g,t[15]=A*a+P*u+x*f+z*y}(this.matrix,this.matrix,u),r(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===i.CameraType.ORBITING||this.type===i.CameraType.EXPLORING?this._getPosition():this.type===i.CameraType.TRACKING&&this._getFocalPoint(),this._update(),this},v.pan=function(t,n){var o=i.createVec3(t,n,0),e=s(this.position);return u(e,e,c(a(),this.right,o[0])),u(e,e,c(a(),this.up,o[1])),this._setPosition(e),this.triggerUpdate(),this},v.dolly=function(t){var n,o=this.forward,e=s(this.position);return n=Math.max(Math.min(this.distance+t*this.dollyingStep,this.maxDistance),this.minDistance)-this.distance,e[0]+=n*o[0],e[1]+=n*o[1],e[2]+=n*o[2],this._setPosition(e),this.type===i.CameraType.ORBITING||this.type===i.CameraType.EXPLORING?this._getDistance():this.type===i.CameraType.TRACKING&&u(this.focalPoint,e,this.distanceVector),this.triggerUpdate(),this},v.createLandmark=function(t,n){void 0===n&&(n={});var o=n.position,r=void 0===o?this.position:o,a=n.focalPoint,h=void 0===a?this.focalPoint:a,l=n.roll,u=n.zoom,c=new i.runtime.CameraContribution;c.setType(this.type,void 0),c.setPosition(r[0],r[1]||this.position[1],r[2]||this.position[2]),c.setFocalPoint(h[0],h[1]||this.focalPoint[1],h[2]||this.focalPoint[2]),c.setRoll(l||this.roll),c.setZoom(u||this.zoom);var m={name:t,matrix:e(c.getWorldTransform()),right:s(c.right),up:s(c.up),forward:s(c.forward),position:s(c.getPosition()),focalPoint:s(c.getFocalPoint()),distanceVector:s(c.getDistanceVector()),distance:c.getDistance(),dollyingStep:c.getDollyingStep(),azimuth:c.getAzimuth(),elevation:c.getElevation(),roll:c.getRoll(),relAzimuth:c.relAzimuth,relElevation:c.relElevation,relRoll:c.relRoll,zoom:c.getZoom()};return this.landmarks.push(m),m},v.gotoLandmark=function(t,n){var o=this;void 0===n&&(n={});var e=b(t,"String")?this.landmarks.find((function(i){return i.name===t})):t;if(e){var r=b(n,"Number")?{duration:n}:n,s=r.easing,h=void 0===s?"linear":s,l=r.duration,u=void 0===l?100:l,c=r.easingFunction,m=void 0===c?void 0:c,f=r.onfinish,v=void 0===f?void 0:f;if(0===u)return this.syncFromLandmark(e),void(v&&v());void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID);var g,y=e.position,A=e.focalPoint,P=e.zoom,x=e.roll,z=m||i.runtime.EasingFunction(h),F=function(){o.setFocalPoint(A),o.setPosition(y),o.setRoll(x),o.setZoom(P),o.computeMatrix(),o.triggerUpdate(),v&&v()};this.canvas.requestAnimationFrame((function t(i){void 0===g&&(g=i);var n=i-g;if(u<n)F();else{var e,r,s=z(n/u),h=a(),l=a();d(h,o.focalPoint,A,s),d(l,o.position,y,s),r=o.roll*(1-s)+x*s,e=o.zoom*(1-s)+P*s,o.setFocalPoint(h),o.setPosition(l),o.setRoll(r),o.setZoom(e),p(h,A)+p(l,y)>.01?(o.computeMatrix(),o.triggerUpdate(),u>n&&(o.landmarkAnimationID=o.canvas.requestAnimationFrame(t))):F()}}))}},v.syncFromLandmark=function(t){this.matrix=function(t,i){return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t}(this.matrix,t.matrix),this.right=l(this.right,t.right),this.up=l(this.up,t.up),this.forward=l(this.forward,t.forward),this.position=l(this.position,t.position),this.focalPoint=l(this.focalPoint,t.focalPoint),this.distanceVector=l(this.distanceVector,t.distanceVector),this.azimuth=t.azimuth,this.elevation=t.elevation,this.roll=t.roll,this.relAzimuth=t.relAzimuth,this.relElevation=t.relElevation,this.relRoll=t.relRoll,this.dollyingStep=t.dollyingStep,this.distance=t.distance,this.zoom=t.zoom},f}(i.Camera);i.runtime.CameraContribution=_,t.AdvancedCamera=_,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-camera-api", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "A simple implementation of Camera API.", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "f544c40d7f0c7ef712e81bd5311fc70530dc43e7" | ||
"gitHead": "c80e315d8611880f433168adad28dd31f2ad5980" | ||
} |
Sorry, the diff of this file is not supported yet
106830
3334