Skip to content

Commit

Permalink
Revert "update artifacts"
Browse files Browse the repository at this point in the history
This reverts commit 7998af5.
  • Loading branch information
RodrigoHamuy committed Sep 22, 2024
1 parent 7998af5 commit 56231f8
Show file tree
Hide file tree
Showing 9 changed files with 3,674 additions and 5,144 deletions.
175 changes: 43 additions & 132 deletions build/geo-three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@

var three = require('three');

/*! *****************************************************************************
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 __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
/*! *****************************************************************************
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 __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}

class MapProvider {
Expand Down Expand Up @@ -168,7 +168,16 @@ class MapNode extends three.Mesh {
}
try {
const image = yield this.mapView.provider.fetchTile(this.level, this.x, this.y);
yield this.applyTexture(image);
if (this.disposed) {
return;
}
const texture = new three.Texture(image);
texture.generateMipmaps = false;
texture.format = three.RGBAFormat;
texture.magFilter = three.LinearFilter;
texture.minFilter = three.LinearFilter;
texture.needsUpdate = true;
this.material.map = texture;
}
catch (e) {
if (this.disposed) {
Expand All @@ -180,23 +189,6 @@ class MapNode extends three.Mesh {
this.material.needsUpdate = true;
});
}
applyTexture(image) {
return __awaiter(this, void 0, void 0, function* () {
if (this.disposed) {
return;
}
const texture = new three.Texture(image);
if (parseInt(three.REVISION) >= 152) {
texture.colorSpace = 'srgb';
}
texture.generateMipmaps = false;
texture.format = three.RGBAFormat;
texture.magFilter = three.LinearFilter;
texture.minFilter = three.LinearFilter;
texture.needsUpdate = true;
this.material.map = texture;
});
}
nodeReady() {
if (this.disposed) {
console.warn('Geo-Three: nodeReady() called for disposed node.', this);
Expand Down Expand Up @@ -399,32 +391,12 @@ class UnitsUtils {
static mapboxAltitude(color) {
return (color.r * 255.0 * 65536.0 + color.g * 255.0 * 256.0 + color.b * 255.0) * 0.1 - 10000.0;
}
static getTileSize(zoom) {
const maxExtent = UnitsUtils.WEB_MERCATOR_MAX_EXTENT;
const numTiles = Math.pow(2, zoom);
return 2 * maxExtent / numTiles;
}
static tileBounds(zoom, x, y) {
const tileSize = UnitsUtils.getTileSize(zoom);
const minX = -UnitsUtils.WEB_MERCATOR_MAX_EXTENT + x * tileSize;
const minY = UnitsUtils.WEB_MERCATOR_MAX_EXTENT - (y + 1) * tileSize;
return [minX, tileSize, minY, tileSize];
}
static webMercatorToLatitude(zoom, y) {
const yMerc = UnitsUtils.WEB_MERCATOR_MAX_EXTENT - y * UnitsUtils.getTileSize(zoom);
return Math.atan(Math.sinh(yMerc / UnitsUtils.EARTH_RADIUS));
}
static webMercatorToLongitude(zoom, x) {
const xMerc = -UnitsUtils.WEB_MERCATOR_MAX_EXTENT + x * UnitsUtils.getTileSize(zoom);
return xMerc / UnitsUtils.EARTH_RADIUS;
}
}
UnitsUtils.EARTH_RADIUS = 6371008;
UnitsUtils.EARTH_RADIUS_A = 6378137.0;
UnitsUtils.EARTH_RADIUS_B = 6356752.314245;
UnitsUtils.EARTH_PERIMETER = 2 * Math.PI * UnitsUtils.EARTH_RADIUS;
UnitsUtils.EARTH_ORIGIN = UnitsUtils.EARTH_PERIMETER / 2.0;
UnitsUtils.WEB_MERCATOR_MAX_EXTENT = 20037508.34;

class MapPlaneNode extends MapNode {
constructor(parentNode = null, mapView = null, location = QuadTreePosition.root, level = 0, x = 0, y = 0) {
Expand Down Expand Up @@ -702,48 +674,7 @@ class MapSphereNodeGeometry extends three.BufferGeometry {

class MapSphereNode extends MapNode {
constructor(parentNode = null, mapView = null, location = QuadTreePosition.root, level = 0, x = 0, y = 0) {
let bounds = UnitsUtils.tileBounds(level, x, y);
const vertexShader = `
varying vec3 vPosition;
void main() {
vPosition = position;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragmentShader = `
#define PI 3.1415926538
varying vec3 vPosition;
uniform sampler2D uTexture;
uniform vec4 webMercatorBounds;
void main() {
// this could also be a constant, but for some reason using a constant causes more visible tile gaps at high zoom
float radius = length(vPosition);
float latitude = asin(vPosition.y / radius);
float longitude = atan(-vPosition.z, vPosition.x);
float web_mercator_x = radius * longitude;
float web_mercator_y = radius * log(tan(PI / 4.0 + latitude / 2.0));
float y = (web_mercator_y - webMercatorBounds.z) / webMercatorBounds.w;
float x = (web_mercator_x - webMercatorBounds.x) / webMercatorBounds.y;
vec4 color = texture2D(uTexture, vec2(x, y));
gl_FragColor = color;
${parseInt(three.REVISION) < 152 ? '' : `
#include <tonemapping_fragment>
#include ${(parseInt(three.REVISION) >= 154) ? '<colorspace_fragment>' : '<encodings_fragment>'}
`}
}
`;
let vBounds = new three.Vector4(...bounds);
const material = new three.ShaderMaterial({
uniforms: { uTexture: { value: new three.Texture() }, webMercatorBounds: { value: vBounds } },
vertexShader: vertexShader,
fragmentShader: fragmentShader
});
super(parentNode, mapView, location, level, x, y, MapSphereNode.createGeometry(level, x, y), material);
super(parentNode, mapView, location, level, x, y, MapSphereNode.createGeometry(level, x, y), new three.MeshBasicMaterial({ wireframe: false }));
this.applyScaleNode();
this.matrixAutoUpdate = false;
this.isMesh = true;
Expand All @@ -763,28 +694,12 @@ class MapSphereNode extends MapNode {
const range = Math.pow(2, zoom);
const max = 40;
const segments = Math.floor(MapSphereNode.segments * (max / (zoom + 1)) / max);
const lon1 = x > 0 ? UnitsUtils.webMercatorToLongitude(zoom, x) + Math.PI : 0;
const lon2 = x < range - 1 ? UnitsUtils.webMercatorToLongitude(zoom, x + 1) + Math.PI : 2 * Math.PI;
const phiStart = lon1;
const phiLength = lon2 - lon1;
const lat1 = y > 0 ? UnitsUtils.webMercatorToLatitude(zoom, y) : Math.PI / 2;
const lat2 = y < range - 1 ? UnitsUtils.webMercatorToLatitude(zoom, y + 1) : -Math.PI / 2;
const thetaLength = lat1 - lat2;
const thetaStart = Math.PI - (lat1 + Math.PI / 2);
const phiLength = 1 / range * 2 * Math.PI;
const phiStart = x * phiLength;
const thetaLength = 1 / range * Math.PI;
const thetaStart = y * thetaLength;
return new MapSphereNodeGeometry(1, segments, segments, phiStart, phiLength, thetaStart, thetaLength);
}
applyTexture(image) {
return __awaiter(this, void 0, void 0, function* () {
const textureLoader = new three.TextureLoader();
const texture = textureLoader.load(image.src, function () {
if (parseInt(three.REVISION) >= 152) {
texture.colorSpace = 'srgb';
}
});
this.material.uniforms.uTexture.value = texture;
this.material.uniforms.uTexture.needsUpdate = true;
});
}
applyScaleNode() {
this.geometry.computeBoundingBox();
const box = this.geometry.boundingBox.clone();
Expand Down Expand Up @@ -939,11 +854,7 @@ class LODRaycast {
for (let t = 0; t < this.subdivisionRays; t++) {
this.mouse.set(Math.random() * 2 - 1, Math.random() * 2 - 1);
this.raycaster.setFromCamera(this.mouse, camera);
let myIntersects = [];
this.raycaster.intersectObjects(view.children, true, myIntersects);
if (myIntersects.length > 0) {
intersects.push(myIntersects[0]);
}
this.raycaster.intersectObjects(view.children, true, intersects);
}
for (let i = 0; i < intersects.length; i++) {
const node = intersects[i].object;
Expand Down Expand Up @@ -1394,7 +1305,7 @@ MapMartiniHeightNode.tileSize = 256;

class MapView extends three.Mesh {
constructor(root = MapView.PLANAR, provider = new OpenStreetMapsProvider(), heightProvider = null) {
super(undefined, new three.MeshBasicMaterial({ transparent: true, opacity: 0.0, depthWrite: false, colorWrite: false }));
super(undefined, new three.MeshBasicMaterial({ transparent: true, opacity: 0.0 }));
this.lod = null;
this.provider = null;
this.heightProvider = null;
Expand Down Expand Up @@ -1681,7 +1592,7 @@ class GoogleMapsProvider extends MapProvider {
this.createSession();
}
createSession() {
const address = 'https://tile.googleapis.com/v1/createSession?key=' + this.apiToken;
const address = 'https://www.googleapis.com/tile/v1/createSession?key=' + this.apiToken;
const data = JSON.stringify({
mapType: this.mapType,
language: 'en-EN',
Expand All @@ -1690,7 +1601,7 @@ class GoogleMapsProvider extends MapProvider {
overlay: this.overlay,
scale: 'scaleFactor1x'
});
XHRUtils.request(address, 'POST', { 'Content-Type': 'text/json' }, data, (response, xhr) => {
XHRUtils.request(address, 'GET', { 'Content-Type': 'text/json' }, data, (response, xhr) => {
this.sessionToken = response.session;
}, function (xhr) {
throw new Error('Unable to create a google maps session.');
Expand All @@ -1706,7 +1617,7 @@ class GoogleMapsProvider extends MapProvider {
reject();
};
image.crossOrigin = 'Anonymous';
image.src = 'https://tile.googleapis.com/v1/2dtiles/' + zoom + '/' + x + '/' + y + '?session=' + this.sessionToken + '&orientation=' + this.orientation + '&key=' + this.apiToken;
image.src = 'https://www.googleapis.com/tile/v1/tiles/' + zoom + '/' + x + '/' + y + '?session=' + this.sessionToken + '&orientation=' + this.orientation + '&key=' + this.apiToken;
});
}
}
Expand Down
Loading

0 comments on commit 56231f8

Please sign in to comment.