Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Updates three to version 0.125.0 (#2129)
Browse files Browse the repository at this point in the history
* Updates three to version 0.125.0

Signed-off-by: Frauke Fritz <[email protected]>
  • Loading branch information
FraukeF authored Mar 2, 2021
1 parent af3cc56 commit 3edcac6
Show file tree
Hide file tree
Showing 36 changed files with 119 additions and 190 deletions.
4 changes: 2 additions & 2 deletions @here/harp-datasource-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"cross-env": "^7.0.2",
"mocha": "^8.2.1",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"three": "^0.125.0",
"ts-json-schema-generator": "^0.68.1",
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"publishConfig": {
"access": "public"
Expand Down
16 changes: 12 additions & 4 deletions @here/harp-debug-datasource/lib/DebugTileDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under Apache 2.0, see full license in LICENSE
* SPDX-License-Identifier: Apache-2.0
*/

import { GeoCoordinates, ProjectionType, TileKey, TilingScheme } from "@here/harp-geoutils";
import { DataSource, TextElement, Tile } from "@here/harp-mapview";
import {
Expand All @@ -28,7 +27,7 @@ const PRIORITY_ALWAYS = Number.MAX_SAFE_INTEGER;
const TEXT_SCALE = 0.8;

export class DebugTile extends Tile {
private readonly geometry = new THREE.Geometry();
private readonly geometry = new THREE.BufferGeometry();
private readonly m_labelPositions = new THREE.BufferAttribute(new Float32Array(3), 3);

private readonly m_textRenderStyle = new TextRenderStyle({
Expand Down Expand Up @@ -57,13 +56,18 @@ export class DebugTile extends Tile {

const middlePoint = new THREE.Vector3();

const vertices: number[] = [];
geoCoordinates.forEach(geoPoint => {
const pt = new THREE.Vector3();
this.projection.projectPoint(geoPoint, pt);
pt.sub(this.center);
this.geometry.vertices.push(pt);
vertices.push(...pt.toArray());
middlePoint.add(pt);
});
this.geometry.setAttribute(
"position",
new THREE.BufferAttribute(new Float32Array(vertices), 3)
);

middlePoint.divideScalar(geoCoordinates.length);

Expand All @@ -77,7 +81,11 @@ export class DebugTile extends Tile {

if (this.projection.type === ProjectionType.Planar) {
// place the text position at north/west for planar projections.
textPosition.copy(this.geometry.vertices[3]);
textPosition.set(
this.geometry.getAttribute("position").getX(3),
this.geometry.getAttribute("position").getY(3),
this.geometry.getAttribute("position").getZ(3)
);
textPosition.multiplyScalar(0.95);

this.m_textLayoutStyle = new TextLayoutStyle({
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-debug-datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"stats.js": "^0.17.0",
"style-loader": "^2.0.0",
"suncalc": "^1.8.0",
"three": "^0.124.0",
"three": "^0.125.0",
"ts-loader": "^8.0.7",
"typescript": "^4.1.2",
"webpack": "^5.12.3",
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-features-datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-geojson-datasource/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"mocha": "^8.2.1",
"sinon": "^9.2.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"three": "^0.125.0",
"typescript": "^4.1.2"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-geometry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"mocha": "^8.2.1",
"sinon": "^9.2.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"three": "^0.125.0",
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"dependencies": {
"@here/harp-geoutils": "^0.22.0",
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-geoutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"mocha": "^8.2.1",
"sinon": "^9.2.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"three": "^0.125.0",
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-lines/lib/HighPrecisionLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class HighPrecisionWireFrameLine extends THREE.Line implements HighPrecis
_renderer: THREE.WebGLRenderer,
_scene: THREE.Scene,
camera: THREE.Camera,
_geometry: THREE.Geometry | THREE.BufferGeometry,
_geometry: THREE.BufferGeometry,
_material: THREE.Material,
_group: THREE.Group
) => {
Expand Down Expand Up @@ -148,7 +148,7 @@ export class HighPrecisionLine extends THREE.Mesh implements HighPrecisionObject
_renderer: THREE.WebGLRenderer,
_scene: THREE.Scene,
camera: THREE.Camera,
_geometry: THREE.Geometry | THREE.BufferGeometry,
_geometry: THREE.BufferGeometry,
_material: THREE.Material,
_group: THREE.Group
) => {
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-lines/lib/HighPrecisionPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class HighPrecisionPoints extends THREE.Points implements HighPrecisionOb
_renderer: THREE.WebGLRenderer,
_scene: THREE.Scene,
camera: THREE.Camera,
_geometry: THREE.Geometry | THREE.BufferGeometry,
_geometry: THREE.BufferGeometry,
_material: THREE.Material,
_group: THREE.Group
) => {
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-lines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"cross-env": "^7.0.2",
"mocha": "^8.2.1",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"three": "^0.125.0",
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-map-controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
"mocha": "^8.2.1",
"sinon": "^9.2.2",
"source-map-support": "^0.5.19",
"three": "^0.124.0",
"three": "^0.125.0",
"typescript": "^4.1.2"
},
"peerDependencies": {
"three": "^0.124.0"
"three": "^0.125.0"
},
"publishConfig": {
"access": "public"
Expand Down
26 changes: 9 additions & 17 deletions @here/harp-mapview/lib/MapViewAtmosphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,21 @@ export class MapViewAtmosphere {
}

private createSkyGeometry() {
let skyGeometry: THREE.Geometry;
switch (this.m_projection.type) {
case ProjectionType.Spherical:
skyGeometry = new THREE.SphereGeometry(
this.m_skyGeometry = new THREE.SphereGeometry(
EarthConstants.EQUATORIAL_RADIUS * (1 + SKY_ATMOSPHERE_ALTITUDE_FACTOR),
256,
256
);
break;
default: {
skyGeometry = new THREE.PlaneGeometry(200, 200);
this.m_skyGeometry = new THREE.PlaneGeometry(200, 200);
break;
}
}

skyGeometry.translate(0, 0, 0);
this.m_skyGeometry = new THREE.BufferGeometry();
this.m_skyGeometry.fromGeometry(skyGeometry);
skyGeometry.dispose();
this.m_skyGeometry.translate(0, 0, 0);

if (this.m_materialVariant === AtmosphereShadingVariant.ScatteringShader) {
this.m_skyMaterial = new SkyAtmosphereMaterial({
Expand Down Expand Up @@ -335,24 +331,20 @@ export class MapViewAtmosphere {
}

private createGroundGeometry() {
let groundGeometry: THREE.Geometry;
switch (this.m_projection.type) {
case ProjectionType.Spherical:
groundGeometry = new THREE.SphereGeometry(
this.m_groundGeometry = new THREE.SphereGeometry(
EarthConstants.EQUATORIAL_RADIUS * (1 + GROUND_ATMOSPHERE_ALTITUDE_FACTOR),
256,
256
);
break;
default: {
groundGeometry = new THREE.PlaneGeometry(200, 200);
this.m_groundGeometry = new THREE.PlaneGeometry(200, 200);
break;
}
}
groundGeometry.translate(0, 0, 0);
this.m_groundGeometry = new THREE.BufferGeometry();
this.m_groundGeometry.fromGeometry(groundGeometry);
groundGeometry.dispose();
this.m_groundGeometry.translate(0, 0, 0);

if (this.m_materialVariant === AtmosphereShadingVariant.ScatteringShader) {
this.m_groundMaterial = new GroundAtmosphereMaterial({
Expand Down Expand Up @@ -416,7 +408,7 @@ export class MapViewAtmosphere {
_renderer: THREE.WebGLRenderer,
_scene: THREE.Scene,
camera: THREE.Camera,
_geometry: THREE.Geometry | THREE.BufferGeometry,
_geometry: THREE.BufferGeometry,
material: THREE.Material,
_group: THREE.Group
) => {
Expand All @@ -427,7 +419,7 @@ export class MapViewAtmosphere {
_renderer: THREE.WebGLRenderer,
_scene: THREE.Scene,
camera: THREE.Camera,
_geometry: THREE.Geometry | THREE.BufferGeometry,
_geometry: THREE.BufferGeometry,
_material: THREE.Material,
_group: THREE.Group
) => {
Expand All @@ -450,7 +442,7 @@ export class MapViewAtmosphere {
_renderer: THREE.WebGLRenderer,
_scene: THREE.Scene,
camera: THREE.Camera,
_geometry: THREE.Geometry | THREE.BufferGeometry,
_geometry: THREE.BufferGeometry,
material: THREE.Material,
_group: THREE.Group
) => {
Expand Down
2 changes: 1 addition & 1 deletion @here/harp-mapview/lib/MapViewEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class MapViewEnvironment {
}
this.m_createdLights!.push(light);

const clonedLight: THREE.Light = light.clone();
const clonedLight: THREE.Light = light.clone() as THREE.Light;
this.m_mapView.overlayScene.add(clonedLight);
if (clonedLight instanceof THREE.DirectionalLight) {
this.m_mapView.overlayScene.add(clonedLight.target.clone());
Expand Down
29 changes: 11 additions & 18 deletions @here/harp-mapview/lib/MapViewPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export abstract class MapViewPoints extends THREE.Points {
* @param point - The point to test.
* @param screenPosition - The point position on screen.
* @param pickCoordinates - The picking position on screen.
* @param index - The index of the point in the [[THREE.Geometry]].
* @param index - The index of the point in the [[THREE.BufferGeometry]].
* @param distance - The distance between the point and the ray origin.
* @param intersects - The results array.
*/
Expand Down Expand Up @@ -88,25 +88,18 @@ export abstract class MapViewPoints extends THREE.Points {
}
};

if (geometry instanceof THREE.BufferGeometry) {
const point = new THREE.Vector3();
const index = geometry.index;
const attributes = geometry.attributes;
const positions = attributes.position.array;
if (index !== null) {
const indices = index.array;
for (let i = 0, il = indices.length; i < il; i++) {
testPoint(point.fromArray(positions as number[], indices[i] * 3), i);
}
} else {
for (let i = 0, l = positions.length / 3; i < l; i++) {
testPoint(point.fromArray(positions as number[], i * 3), i);
}
const point = new THREE.Vector3();
const index = geometry.index;
const attributes = geometry.attributes;
const positions = attributes.position.array;
if (index !== null) {
const indices = index.array;
for (let i = 0, il = indices.length; i < il; i++) {
testPoint(point.fromArray(positions as number[], indices[i] * 3), i);
}
} else {
const vertices = geometry.vertices;
for (let index = 0; index < vertices.length; index++) {
testPoint(vertices[index], index);
for (let i = 0, l = positions.length / 3; i < l; i++) {
testPoint(point.fromArray(positions as number[], i * 3), i);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions @here/harp-mapview/lib/PolarTileDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,20 +332,20 @@ export class PolarTileDataSource extends DataSource {
}
}

const g = new THREE.Geometry();
const geometry = new THREE.BufferGeometry();

for (const point of points) {
const vertices: THREE.Vector3[] = points.map(point => {
const projected = dstProjection.projectPoint(point, new THREE.Vector3());
g.vertices.push(projected.sub(tile.center));
}
projected.sub(tile.center);
return projected;
});
geometry.setFromPoints(vertices);

for (let i = 1; i < points.length - 1; i++) {
g.faces.push(isNorthPole ? new THREE.Face3(0, i, i + 1) : new THREE.Face3(0, i + 1, i));
const indices: number[] = [];
for (let i = 1; i < vertices.length - 1; i++) {
isNorthPole ? indices.push(0, i, i + 1) : indices.push(0, i + 1, i);
}

const geometry = new THREE.BufferGeometry();
geometry.fromGeometry(g);
g.dispose();
geometry.setIndex(indices);

const mesh = new THREE.Mesh(geometry, techniqueEntry.material);
mesh.userData = {
Expand Down
4 changes: 2 additions & 2 deletions @here/harp-mapview/lib/Tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export type TileObject = THREE.Object3D & {
};

interface DisposableObject {
geometry?: THREE.BufferGeometry | THREE.Geometry;
geometries?: Array<THREE.BufferGeometry | THREE.Geometry>;
geometry?: THREE.BufferGeometry;
geometries?: THREE.BufferGeometry[];
material?: THREE.Material[] | THREE.Material;
}

Expand Down
Loading

0 comments on commit 3edcac6

Please sign in to comment.