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

@ubilabs/threejs-overlay-view

Package Overview
Dependencies
Maintainers
8
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ubilabs/threejs-overlay-view - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

2

dist/threejs-overlay-view.modern.js

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

import{Vector3 as e,MathUtils as t,Vector2 as r,Raycaster as n,PerspectiveCamera as i,WebGL1Renderer as s,Scene as a,HemisphereLight as o,DirectionalLight as l,Matrix4 as h}from"three";function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const{sin:d,cos:u,pow:g,sqrt:p,atan2:y,asin:w,sign:v}=Math,{degToRad:f,radToDeg:m,euclideanModulo:x}=t;function b(e,t){const{lat:r,lng:n}=e,{lat:i,lng:s}=t,a=f(i-r),o=f(s-n),l=f(r),h=f(i),c=g(d(a/2),2)+g(d(o/2),2)*u(l)*u(h);return 2*y(p(c),p(1-c))*6371008.8}const A=new h;function P(e){return(...t)=>{try{return e(...t)}catch(e){throw console.error(e),e}}}export default class{constructor(e){this.overlay=void 0,this.camera=void 0,this.renderer=void 0,this.scene=void 0,this.referencePoint=void 0,this.viewportSize=new r,this.raycaster=new n,this.onAdd=null,this.onRemove=null,this.update=null,this.referencePoint=c({altitude:0},e),this.overlay=this.initWebGLOverlayView(),this.renderer=null,this.scene=this.initScene(),this.camera=new i}setMap(e){this.overlay.setMap(e)}setReferencePoint(e){this.referencePoint=c({altitude:0},e)}getScene(){return this.scene}getViewportSize(){return this.viewportSize}requestRedraw(){this.overlay.requestRedraw()}raycast(e,t=null,r={updateMatrix:!0,recursive:!1}){let{updateMatrix:n,recursive:i,raycasterParameters:s}=r;n&&A.copy(this.camera.projectionMatrix).invert(),this.raycaster.ray.origin.set(e.x,e.y,0).applyMatrix4(A),this.raycaster.ray.direction.set(e.x,e.y,.5).applyMatrix4(A).sub(this.raycaster.ray.origin).normalize();let a=this.raycaster.params;s&&(this.raycaster.params=s),null===t&&(t=this.scene,i=!0);const o=Array.isArray(t)?this.raycaster.intersectObjects(t,i):this.raycaster.intersectObject(t,i);return this.raycaster.params=a,o}latLngAltToVector3(t,r=new e){return function(t,r,n=new e){const i=b(r,{lng:t.lng,lat:r.lat}),s=b(r,{lng:r.lng,lat:t.lat}),a=v(t.lng-r.lng),o=v(t.lat-r.lat),{altitude:l=0}=t;return n.set(a*i,o*s,l)}(t,this.referencePoint,r)}vector3ToLatLngAlt(e,t={lat:0,lng:0,altitude:0}){return function(e,t,r={lat:0,lng:0,altitude:0}){return function(e,t,r,n={lat:0,lng:0}){const i=f(e.lng),s=f(e.lat),a=f(r),o=t/6371008.8,l=w(d(s)*u(o)+u(s)*d(o)*u(a)),h=i+y(d(a)*d(o)*u(s),u(o)-d(s)*d(l));n.lat=m(l),n.lng=m(h)}(t,e.length(),function(e){return x(90-m(y(e.y,e.x)),360)}(e),r),r.altitude=e.z,r}(e,this.referencePoint,t)}onContextRestored(e){const{gl:t}=e;let r=new s(c({canvas:t.canvas,context:t},t.getContextAttributes()));r.autoClear=!1,r.autoClearDepth=!1;const{width:n,height:i}=t.canvas;this.viewportSize.set(n,i),this.renderer=r}onContextLost(){this.renderer&&(this.viewportSize.set(0,0),this.renderer.dispose(),this.renderer=null)}onDraw(e){const{gl:t,transformer:r}=e;if(!this.scene||!this.renderer)return;if(null===this.overlay.getMap())return;const{lat:n,lng:i,altitude:s}=this.referencePoint;this.camera.projectionMatrix.fromArray(r.fromLatLngAltitude({lat:n,lng:i},s));const{width:a,height:o}=t.canvas;this.viewportSize.set(a,o),this.renderer.setViewport(0,0,a,o),this.update&&this.update(),this.renderer.render(this.scene,this.camera),this.renderer.resetState()}initScene(){const e=new a,t=new o(16777215,4473924,1);t.position.set(0,-.2,1).normalize();const r=new l(16777215);return r.position.set(0,10,100),e.add(t,r),e}initWebGLOverlayView(){if(!google||!google.maps)throw new Error("Google Maps API not loaded. Please make sure to create the overlay after the API has been loaded.");if(!google.maps.WebGLOverlayView)throw new Error("WebGLOverlayView not found. Please make sure to load the beta-channel of the Google Maps API.");const e=new google.maps.WebGLOverlayView;return e.onAdd=P(()=>{null!==this.onAdd&&this.onAdd()}),e.onRemove=P(()=>{null!==this.onRemove&&this.onRemove()}),e.onDraw=P(this.onDraw.bind(this)),e.onContextRestored=P(this.onContextRestored.bind(this)),e.onContextLost=P(this.onContextLost.bind(this)),e}}
import{Vector3 as e,MathUtils as t,Vector2 as r,Raycaster as n,PerspectiveCamera as i,WebGL1Renderer as s,Scene as a,HemisphereLight as o,DirectionalLight as l,Matrix4 as h}from"three";function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const{sin:d,cos:u,pow:g,sqrt:p,atan2:y,asin:w,sign:v}=Math,{degToRad:f,radToDeg:m,euclideanModulo:x}=t;function b(e,t){const{lat:r,lng:n}=e,{lat:i,lng:s}=t,a=f(i-r),o=f(s-n),l=f(r),h=f(i),c=g(d(a/2),2)+g(d(o/2),2)*u(l)*u(h);return 2*y(p(c),p(1-c))*6371008.8}const A=new h;function P(e){return(...t)=>{try{return e(...t)}catch(e){throw console.error(e),e}}}export default class{constructor(e){this.overlay=void 0,this.camera=void 0,this.renderer=void 0,this.scene=void 0,this.referencePoint=void 0,this.viewportSize=new r,this.raycaster=new n,this.onAdd=null,this.onRemove=null,this.update=null,this.referencePoint=c({altitude:0},e),this.overlay=this.initWebGLOverlayView(),this.renderer=null,this.scene=this.initScene(),this.camera=new i}setMap(e){this.overlay.setMap(e)}setReferencePoint(e){this.referencePoint=c({altitude:0},e)}getScene(){return this.scene}getViewportSize(){return this.viewportSize}requestRedraw(){this.overlay.requestRedraw()}raycast(e,t=null,r={updateMatrix:!0,recursive:!1}){let{updateMatrix:n,recursive:i,raycasterParameters:s}=r;n&&A.copy(this.camera.projectionMatrix).invert(),this.raycaster.ray.origin.set(e.x,e.y,0).applyMatrix4(A),this.raycaster.ray.direction.set(e.x,e.y,.5).applyMatrix4(A).sub(this.raycaster.ray.origin).normalize();let a=this.raycaster.params;s&&(this.raycaster.params=s),null===t&&(t=this.scene,i=!0);const o=Array.isArray(t)?this.raycaster.intersectObjects(t,i):this.raycaster.intersectObject(t,i);return this.raycaster.params=a,o}latLngAltToVector3(t,r=new e){return function(t,r,n=new e){const i=b(r,{lng:t.lng,lat:r.lat}),s=b(r,{lng:r.lng,lat:t.lat}),a=v(t.lng-r.lng),o=v(t.lat-r.lat),{altitude:l=0}=t;return n.set(a*i,o*s,l)}(t,this.referencePoint,r)}vector3ToLatLngAlt(e,t={lat:0,lng:0,altitude:0}){return function(e,t,r={lat:0,lng:0,altitude:0}){return function(e,t,r,n={lat:0,lng:0}){const i=f(e.lng),s=f(e.lat),a=f(r),o=t/6371008.8,l=w(d(s)*u(o)+u(s)*d(o)*u(a)),h=i+y(d(a)*d(o)*u(s),u(o)-d(s)*d(l));n.lat=m(l),n.lng=m(h)}(t,e.length(),function(e){return x(90-m(y(e.y,e.x)),360)}(e),r),r.altitude=e.z,r}(e,this.referencePoint,t)}onContextRestored(e){const{gl:t}=e;let r=new s(c({canvas:t.canvas,context:t},t.getContextAttributes()));r.autoClear=!1,r.autoClearDepth=!1;const{width:n,height:i}=t.canvas;this.viewportSize.set(n,i),this.renderer=r}onContextLost(){this.renderer&&(this.viewportSize.set(0,0),this.renderer.dispose(),this.renderer=null)}onDraw(e){const{gl:t,transformer:r}=e;if(!this.scene||!this.renderer)return;if(null===this.overlay.getMap())return;this.camera.projectionMatrix.fromArray(r.fromLatLngAltitude(this.referencePoint));const{width:n,height:i}=t.canvas;this.viewportSize.set(n,i),this.renderer.setViewport(0,0,n,i),this.update&&this.update(),this.renderer.render(this.scene,this.camera),this.renderer.resetState()}initScene(){const e=new a,t=new o(16777215,4473924,1);t.position.set(0,-.2,1).normalize();const r=new l(16777215);return r.position.set(0,10,100),e.add(t,r),e}initWebGLOverlayView(){if(!google||!google.maps)throw new Error("Google Maps API not loaded. Please make sure to create the overlay after the API has been loaded.");if(!google.maps.WebGLOverlayView)throw new Error("WebGLOverlayView not found. Please make sure to load the beta-channel of the Google Maps API.");const e=new google.maps.WebGLOverlayView;return e.onAdd=P(()=>{null!==this.onAdd&&this.onAdd()}),e.onRemove=P(()=>{null!==this.onRemove&&this.onRemove()}),e.onDraw=P(this.onDraw.bind(this)),e.onContextRestored=P(this.onContextRestored.bind(this)),e.onContextLost=P(this.onContextLost.bind(this)),e}}
//# sourceMappingURL=threejs-overlay-view.modern.js.map

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

import{Vector3 as e,MathUtils as t,Matrix4 as r,WebGL1Renderer as n,Scene as i,HemisphereLight as a,DirectionalLight as o,Vector2 as s,Raycaster as l,PerspectiveCamera as h}from"three";function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var u=Math.sin,d=Math.cos,v=Math.pow,f=Math.sqrt,p=Math.atan2,g=Math.asin,y=Math.sign,w=t.degToRad,m=t.radToDeg,M=t.euclideanModulo;function x(e,t){var r=e.lat,n=e.lng,i=t.lat,a=t.lng,o=w(i-r),s=w(a-n),l=w(r),h=w(i),c=v(u(o/2),2)+v(u(s/2),2)*d(l)*d(h);return 2*p(f(c),f(1-c))*6371008.8}var b=new r,A=function(){function t(e){this.overlay=void 0,this.camera=void 0,this.renderer=void 0,this.scene=void 0,this.referencePoint=void 0,this.viewportSize=new s,this.raycaster=new l,this.onAdd=null,this.onRemove=null,this.update=null,this.referencePoint=c({altitude:0},e),this.overlay=this.initWebGLOverlayView(),this.renderer=null,this.scene=this.initScene(),this.camera=new h}var r=t.prototype;return r.setMap=function(e){this.overlay.setMap(e)},r.setReferencePoint=function(e){this.referencePoint=c({altitude:0},e)},r.getScene=function(){return this.scene},r.getViewportSize=function(){return this.viewportSize},r.requestRedraw=function(){this.overlay.requestRedraw()},r.raycast=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r={updateMatrix:!0,recursive:!1});var n=r.recursive,i=r.raycasterParameters;r.updateMatrix&&b.copy(this.camera.projectionMatrix).invert(),this.raycaster.ray.origin.set(e.x,e.y,0).applyMatrix4(b),this.raycaster.ray.direction.set(e.x,e.y,.5).applyMatrix4(b).sub(this.raycaster.ray.origin).normalize();var a=this.raycaster.params;i&&(this.raycaster.params=i),null===t&&(t=this.scene,n=!0);var o=Array.isArray(t)?this.raycaster.intersectObjects(t,n):this.raycaster.intersectObject(t,n);return this.raycaster.params=a,o},r.latLngAltToVector3=function(t,r){return void 0===r&&(r=new e),function(t,r,n){void 0===n&&(n=new e);var i=x(r,{lng:t.lng,lat:r.lat}),a=x(r,{lng:r.lng,lat:t.lat}),o=y(t.lng-r.lng),s=y(t.lat-r.lat),l=t.altitude;return n.set(o*i,s*a,void 0===l?0:l)}(t,this.referencePoint,r)},r.vector3ToLatLngAlt=function(e,t){return void 0===t&&(t={lat:0,lng:0,altitude:0}),function(e,t,r){return void 0===r&&(r={lat:0,lng:0,altitude:0}),function(e,t,r,n){void 0===n&&(n={lat:0,lng:0});var i=w(e.lng),a=w(e.lat),o=w(r),s=t/6371008.8,l=g(u(a)*d(s)+d(a)*u(s)*d(o)),h=i+p(u(o)*u(s)*d(a),d(s)-u(a)*u(l));n.lat=m(l),n.lng=m(h)}(t,e.length(),function(e){return M(90-m(p(e.y,e.x)),360)}(e),r),r.altitude=e.z,r}(e,this.referencePoint,t)},r.onContextRestored=function(e){var t=e.gl,r=new n(c({canvas:t.canvas,context:t},t.getContextAttributes()));r.autoClear=!1,r.autoClearDepth=!1;var i=t.canvas;this.viewportSize.set(i.width,i.height),this.renderer=r},r.onContextLost=function(){this.renderer&&(this.viewportSize.set(0,0),this.renderer.dispose(),this.renderer=null)},r.onDraw=function(e){var t=e.gl,r=e.transformer;if(this.scene&&this.renderer&&null!==this.overlay.getMap()){var n=this.referencePoint;this.camera.projectionMatrix.fromArray(r.fromLatLngAltitude({lat:n.lat,lng:n.lng},n.altitude));var i=t.canvas,a=i.width,o=i.height;this.viewportSize.set(a,o),this.renderer.setViewport(0,0,a,o),this.update&&this.update(),this.renderer.render(this.scene,this.camera),this.renderer.resetState()}},r.initScene=function(){var e=new i,t=new a(16777215,4473924,1);t.position.set(0,-.2,1).normalize();var r=new o(16777215);return r.position.set(0,10,100),e.add(t,r),e},r.initWebGLOverlayView=function(){var e=this;if(!google||!google.maps)throw new Error("Google Maps API not loaded. Please make sure to create the overlay after the API has been loaded.");if(!google.maps.WebGLOverlayView)throw new Error("WebGLOverlayView not found. Please make sure to load the beta-channel of the Google Maps API.");var t=new google.maps.WebGLOverlayView;return t.onAdd=P(function(){null!==e.onAdd&&e.onAdd()}),t.onRemove=P(function(){null!==e.onRemove&&e.onRemove()}),t.onDraw=P(this.onDraw.bind(this)),t.onContextRestored=P(this.onContextRestored.bind(this)),t.onContextLost=P(this.onContextLost.bind(this)),t},t}();function P(e){return function(){try{return e.apply(void 0,[].slice.call(arguments))}catch(e){throw console.error(e),e}}}export default A;
import{Vector3 as e,MathUtils as t,Matrix4 as r,WebGL1Renderer as n,Scene as i,HemisphereLight as a,DirectionalLight as o,Vector2 as s,Raycaster as l,PerspectiveCamera as h}from"three";function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var u=Math.sin,d=Math.cos,v=Math.pow,f=Math.sqrt,p=Math.atan2,g=Math.asin,y=Math.sign,w=t.degToRad,m=t.radToDeg,M=t.euclideanModulo;function x(e,t){var r=e.lat,n=e.lng,i=t.lat,a=t.lng,o=w(i-r),s=w(a-n),l=w(r),h=w(i),c=v(u(o/2),2)+v(u(s/2),2)*d(l)*d(h);return 2*p(f(c),f(1-c))*6371008.8}var b=new r,A=function(){function t(e){this.overlay=void 0,this.camera=void 0,this.renderer=void 0,this.scene=void 0,this.referencePoint=void 0,this.viewportSize=new s,this.raycaster=new l,this.onAdd=null,this.onRemove=null,this.update=null,this.referencePoint=c({altitude:0},e),this.overlay=this.initWebGLOverlayView(),this.renderer=null,this.scene=this.initScene(),this.camera=new h}var r=t.prototype;return r.setMap=function(e){this.overlay.setMap(e)},r.setReferencePoint=function(e){this.referencePoint=c({altitude:0},e)},r.getScene=function(){return this.scene},r.getViewportSize=function(){return this.viewportSize},r.requestRedraw=function(){this.overlay.requestRedraw()},r.raycast=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r={updateMatrix:!0,recursive:!1});var n=r.recursive,i=r.raycasterParameters;r.updateMatrix&&b.copy(this.camera.projectionMatrix).invert(),this.raycaster.ray.origin.set(e.x,e.y,0).applyMatrix4(b),this.raycaster.ray.direction.set(e.x,e.y,.5).applyMatrix4(b).sub(this.raycaster.ray.origin).normalize();var a=this.raycaster.params;i&&(this.raycaster.params=i),null===t&&(t=this.scene,n=!0);var o=Array.isArray(t)?this.raycaster.intersectObjects(t,n):this.raycaster.intersectObject(t,n);return this.raycaster.params=a,o},r.latLngAltToVector3=function(t,r){return void 0===r&&(r=new e),function(t,r,n){void 0===n&&(n=new e);var i=x(r,{lng:t.lng,lat:r.lat}),a=x(r,{lng:r.lng,lat:t.lat}),o=y(t.lng-r.lng),s=y(t.lat-r.lat),l=t.altitude;return n.set(o*i,s*a,void 0===l?0:l)}(t,this.referencePoint,r)},r.vector3ToLatLngAlt=function(e,t){return void 0===t&&(t={lat:0,lng:0,altitude:0}),function(e,t,r){return void 0===r&&(r={lat:0,lng:0,altitude:0}),function(e,t,r,n){void 0===n&&(n={lat:0,lng:0});var i=w(e.lng),a=w(e.lat),o=w(r),s=t/6371008.8,l=g(u(a)*d(s)+d(a)*u(s)*d(o)),h=i+p(u(o)*u(s)*d(a),d(s)-u(a)*u(l));n.lat=m(l),n.lng=m(h)}(t,e.length(),function(e){return M(90-m(p(e.y,e.x)),360)}(e),r),r.altitude=e.z,r}(e,this.referencePoint,t)},r.onContextRestored=function(e){var t=e.gl,r=new n(c({canvas:t.canvas,context:t},t.getContextAttributes()));r.autoClear=!1,r.autoClearDepth=!1;var i=t.canvas;this.viewportSize.set(i.width,i.height),this.renderer=r},r.onContextLost=function(){this.renderer&&(this.viewportSize.set(0,0),this.renderer.dispose(),this.renderer=null)},r.onDraw=function(e){var t=e.gl,r=e.transformer;if(this.scene&&this.renderer&&null!==this.overlay.getMap()){this.camera.projectionMatrix.fromArray(r.fromLatLngAltitude(this.referencePoint));var n=t.canvas,i=n.width,a=n.height;this.viewportSize.set(i,a),this.renderer.setViewport(0,0,i,a),this.update&&this.update(),this.renderer.render(this.scene,this.camera),this.renderer.resetState()}},r.initScene=function(){var e=new i,t=new a(16777215,4473924,1);t.position.set(0,-.2,1).normalize();var r=new o(16777215);return r.position.set(0,10,100),e.add(t,r),e},r.initWebGLOverlayView=function(){var e=this;if(!google||!google.maps)throw new Error("Google Maps API not loaded. Please make sure to create the overlay after the API has been loaded.");if(!google.maps.WebGLOverlayView)throw new Error("WebGLOverlayView not found. Please make sure to load the beta-channel of the Google Maps API.");var t=new google.maps.WebGLOverlayView;return t.onAdd=P(function(){null!==e.onAdd&&e.onAdd()}),t.onRemove=P(function(){null!==e.onRemove&&e.onRemove()}),t.onDraw=P(this.onDraw.bind(this)),t.onContextRestored=P(this.onContextRestored.bind(this)),t.onContextLost=P(this.onContextLost.bind(this)),t},t}();function P(e){return function(){try{return e.apply(void 0,[].slice.call(arguments))}catch(e){throw console.error(e),e}}}export default A;
//# sourceMappingURL=threejs-overlay-view.module.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("three")):"function"==typeof define&&define.amd?define(["three"],t):(e||self).threejsOverlayView=t(e.three)}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var r=Math.sin,n=Math.cos,i=Math.pow,a=Math.sqrt,o=Math.atan2,s=Math.asin,l=Math.sign,h=e.MathUtils.degToRad,c=e.MathUtils.radToDeg,u=e.MathUtils.euclideanModulo,d=6371008.8;function v(e,t){var s=e.lat,l=e.lng,c=t.lat,u=t.lng,v=h(c-s),f=h(u-l),p=h(s),g=h(c),y=i(r(v/2),2)+i(r(f/2),2)*n(p)*n(g);return 2*o(a(y),a(1-y))*d}var f=new e.Matrix4;function p(e){return function(){try{return e.apply(void 0,[].slice.call(arguments))}catch(e){throw console.error(e),e}}}return function(){function i(r){this.overlay=void 0,this.camera=void 0,this.renderer=void 0,this.scene=void 0,this.referencePoint=void 0,this.viewportSize=new e.Vector2,this.raycaster=new e.Raycaster,this.onAdd=null,this.onRemove=null,this.update=null,this.referencePoint=t({altitude:0},r),this.overlay=this.initWebGLOverlayView(),this.renderer=null,this.scene=this.initScene(),this.camera=new e.PerspectiveCamera}var a=i.prototype;return a.setMap=function(e){this.overlay.setMap(e)},a.setReferencePoint=function(e){this.referencePoint=t({altitude:0},e)},a.getScene=function(){return this.scene},a.getViewportSize=function(){return this.viewportSize},a.requestRedraw=function(){this.overlay.requestRedraw()},a.raycast=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r={updateMatrix:!0,recursive:!1});var n=r.recursive,i=r.raycasterParameters;r.updateMatrix&&f.copy(this.camera.projectionMatrix).invert(),this.raycaster.ray.origin.set(e.x,e.y,0).applyMatrix4(f),this.raycaster.ray.direction.set(e.x,e.y,.5).applyMatrix4(f).sub(this.raycaster.ray.origin).normalize();var a=this.raycaster.params;i&&(this.raycaster.params=i),null===t&&(t=this.scene,n=!0);var o=Array.isArray(t)?this.raycaster.intersectObjects(t,n):this.raycaster.intersectObject(t,n);return this.raycaster.params=a,o},a.latLngAltToVector3=function(t,r){return void 0===r&&(r=new e.Vector3),function(t,r,n){void 0===n&&(n=new e.Vector3);var i=v(r,{lng:t.lng,lat:r.lat}),a=v(r,{lng:r.lng,lat:t.lat}),o=l(t.lng-r.lng),s=l(t.lat-r.lat),h=t.altitude;return n.set(o*i,s*a,void 0===h?0:h)}(t,this.referencePoint,r)},a.vector3ToLatLngAlt=function(e,t){return void 0===t&&(t={lat:0,lng:0,altitude:0}),function(e,t,i){return void 0===i&&(i={lat:0,lng:0,altitude:0}),function(e,t,i,a){void 0===a&&(a={lat:0,lng:0});var l=h(e.lng),u=h(e.lat),v=h(i),f=t/d,p=s(r(u)*n(f)+n(u)*r(f)*n(v)),g=l+o(r(v)*r(f)*n(u),n(f)-r(u)*r(p));a.lat=c(p),a.lng=c(g)}(t,e.length(),function(e){return u(90-c(o(e.y,e.x)),360)}(e),i),i.altitude=e.z,i}(e,this.referencePoint,t)},a.onContextRestored=function(r){var n=r.gl,i=new e.WebGL1Renderer(t({canvas:n.canvas,context:n},n.getContextAttributes()));i.autoClear=!1,i.autoClearDepth=!1;var a=n.canvas;this.viewportSize.set(a.width,a.height),this.renderer=i},a.onContextLost=function(){this.renderer&&(this.viewportSize.set(0,0),this.renderer.dispose(),this.renderer=null)},a.onDraw=function(e){var t=e.gl,r=e.transformer;if(this.scene&&this.renderer&&null!==this.overlay.getMap()){var n=this.referencePoint;this.camera.projectionMatrix.fromArray(r.fromLatLngAltitude({lat:n.lat,lng:n.lng},n.altitude));var i=t.canvas,a=i.width,o=i.height;this.viewportSize.set(a,o),this.renderer.setViewport(0,0,a,o),this.update&&this.update(),this.renderer.render(this.scene,this.camera),this.renderer.resetState()}},a.initScene=function(){var t=new e.Scene,r=new e.HemisphereLight(16777215,4473924,1);r.position.set(0,-.2,1).normalize();var n=new e.DirectionalLight(16777215);return n.position.set(0,10,100),t.add(r,n),t},a.initWebGLOverlayView=function(){var e=this;if(!google||!google.maps)throw new Error("Google Maps API not loaded. Please make sure to create the overlay after the API has been loaded.");if(!google.maps.WebGLOverlayView)throw new Error("WebGLOverlayView not found. Please make sure to load the beta-channel of the Google Maps API.");var t=new google.maps.WebGLOverlayView;return t.onAdd=p(function(){null!==e.onAdd&&e.onAdd()}),t.onRemove=p(function(){null!==e.onRemove&&e.onRemove()}),t.onDraw=p(this.onDraw.bind(this)),t.onContextRestored=p(this.onContextRestored.bind(this)),t.onContextLost=p(this.onContextLost.bind(this)),t},i}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("three")):"function"==typeof define&&define.amd?define(["three"],t):(e||self).threejsOverlayView=t(e.three)}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var r=Math.sin,n=Math.cos,i=Math.pow,a=Math.sqrt,o=Math.atan2,s=Math.asin,l=Math.sign,h=e.MathUtils.degToRad,c=e.MathUtils.radToDeg,u=e.MathUtils.euclideanModulo,d=6371008.8;function v(e,t){var s=e.lat,l=e.lng,c=t.lat,u=t.lng,v=h(c-s),f=h(u-l),p=h(s),g=h(c),y=i(r(v/2),2)+i(r(f/2),2)*n(p)*n(g);return 2*o(a(y),a(1-y))*d}var f=new e.Matrix4;function p(e){return function(){try{return e.apply(void 0,[].slice.call(arguments))}catch(e){throw console.error(e),e}}}return function(){function i(r){this.overlay=void 0,this.camera=void 0,this.renderer=void 0,this.scene=void 0,this.referencePoint=void 0,this.viewportSize=new e.Vector2,this.raycaster=new e.Raycaster,this.onAdd=null,this.onRemove=null,this.update=null,this.referencePoint=t({altitude:0},r),this.overlay=this.initWebGLOverlayView(),this.renderer=null,this.scene=this.initScene(),this.camera=new e.PerspectiveCamera}var a=i.prototype;return a.setMap=function(e){this.overlay.setMap(e)},a.setReferencePoint=function(e){this.referencePoint=t({altitude:0},e)},a.getScene=function(){return this.scene},a.getViewportSize=function(){return this.viewportSize},a.requestRedraw=function(){this.overlay.requestRedraw()},a.raycast=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r={updateMatrix:!0,recursive:!1});var n=r.recursive,i=r.raycasterParameters;r.updateMatrix&&f.copy(this.camera.projectionMatrix).invert(),this.raycaster.ray.origin.set(e.x,e.y,0).applyMatrix4(f),this.raycaster.ray.direction.set(e.x,e.y,.5).applyMatrix4(f).sub(this.raycaster.ray.origin).normalize();var a=this.raycaster.params;i&&(this.raycaster.params=i),null===t&&(t=this.scene,n=!0);var o=Array.isArray(t)?this.raycaster.intersectObjects(t,n):this.raycaster.intersectObject(t,n);return this.raycaster.params=a,o},a.latLngAltToVector3=function(t,r){return void 0===r&&(r=new e.Vector3),function(t,r,n){void 0===n&&(n=new e.Vector3);var i=v(r,{lng:t.lng,lat:r.lat}),a=v(r,{lng:r.lng,lat:t.lat}),o=l(t.lng-r.lng),s=l(t.lat-r.lat),h=t.altitude;return n.set(o*i,s*a,void 0===h?0:h)}(t,this.referencePoint,r)},a.vector3ToLatLngAlt=function(e,t){return void 0===t&&(t={lat:0,lng:0,altitude:0}),function(e,t,i){return void 0===i&&(i={lat:0,lng:0,altitude:0}),function(e,t,i,a){void 0===a&&(a={lat:0,lng:0});var l=h(e.lng),u=h(e.lat),v=h(i),f=t/d,p=s(r(u)*n(f)+n(u)*r(f)*n(v)),g=l+o(r(v)*r(f)*n(u),n(f)-r(u)*r(p));a.lat=c(p),a.lng=c(g)}(t,e.length(),function(e){return u(90-c(o(e.y,e.x)),360)}(e),i),i.altitude=e.z,i}(e,this.referencePoint,t)},a.onContextRestored=function(r){var n=r.gl,i=new e.WebGL1Renderer(t({canvas:n.canvas,context:n},n.getContextAttributes()));i.autoClear=!1,i.autoClearDepth=!1;var a=n.canvas;this.viewportSize.set(a.width,a.height),this.renderer=i},a.onContextLost=function(){this.renderer&&(this.viewportSize.set(0,0),this.renderer.dispose(),this.renderer=null)},a.onDraw=function(e){var t=e.gl,r=e.transformer;if(this.scene&&this.renderer&&null!==this.overlay.getMap()){this.camera.projectionMatrix.fromArray(r.fromLatLngAltitude(this.referencePoint));var n=t.canvas,i=n.width,a=n.height;this.viewportSize.set(i,a),this.renderer.setViewport(0,0,i,a),this.update&&this.update(),this.renderer.render(this.scene,this.camera),this.renderer.resetState()}},a.initScene=function(){var t=new e.Scene,r=new e.HemisphereLight(16777215,4473924,1);r.position.set(0,-.2,1).normalize();var n=new e.DirectionalLight(16777215);return n.position.set(0,10,100),t.add(r,n),t},a.initWebGLOverlayView=function(){var e=this;if(!google||!google.maps)throw new Error("Google Maps API not loaded. Please make sure to create the overlay after the API has been loaded.");if(!google.maps.WebGLOverlayView)throw new Error("WebGLOverlayView not found. Please make sure to load the beta-channel of the Google Maps API.");var t=new google.maps.WebGLOverlayView;return t.onAdd=p(function(){null!==e.onAdd&&e.onAdd()}),t.onRemove=p(function(){null!==e.onRemove&&e.onRemove()}),t.onDraw=p(this.onDraw.bind(this)),t.onContextRestored=p(this.onContextRestored.bind(this)),t.onContextLost=p(this.onContextLost.bind(this)),t},i}()});
//# sourceMappingURL=threejs-overlay-view.umd.js.map
{
"name": "@ubilabs/threejs-overlay-view",
"version": "0.7.0",
"version": "0.7.1",
"description": "A wrapper for the Google Maps WebGLOverlayView that takes care of the integration between three.js and the Google Maps JavaScript API. It lets you create a Google Maps overlays directly with three.js.",

@@ -48,3 +48,3 @@ "keywords": [

"devDependencies": {
"@types/google.maps": "^3.47.3",
"@types/google.maps": "^3.48.0",
"@types/three": "^0.128.0",

@@ -51,0 +51,0 @@ "microbundle": "^0.13.0",

@@ -286,5 +286,4 @@ import {

const {lat, lng, altitude} = this.referencePoint;
this.camera.projectionMatrix.fromArray(
transformer.fromLatLngAltitude({lat, lng}, altitude)
transformer.fromLatLngAltitude(this.referencePoint)
);

@@ -291,0 +290,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc