Class: xgeom

xgeom()

new xgeom()

Source:

Members

(static) generateDirTube

Create a DirTubeBufferGeometry for rendering and tweening.

The vertices should include attributes of 'a_tan', and uniform 'wpos', the world pos can by tweend as XComponent.AnimType.U_PATH_MORPH.

Source:

(static) xzAngle

return |atan(vec0[2], vec0[0]) - atan(vec1[2], vec[0])|

Source:

Methods

(static) catmullRom()

Doc: Returns a vector for a given position on the curve.

Stolen from: https://github.com/mrdoob/three.js/blob/b11f897812a8a48bcd81e9bd46785d07939ec59e/src/extras/core/Interpolations.js#L8

Author:
  • zz85 / http://www.lab4games.net/zz85/blog Bezier Curves formulas obtained from http://en.wikipedia.org/wiki/Bézier_curve
Source:

(static) checkLineIntersection(x1, y1, x2, y2, x3, y3, x4, y4) → {object}

Find 2d line intersection
Line1: [(x1, y1), (x2, y2)]
Line2: [(x3, y3), (x4, y4)]
Reference: justin_c_rounds's Calculating the intersection of two lines & Math.js 3D version

Parameters:
Name Type Description
x1 number
y1 number
x2 number
y2 number
x3 number
y3 number
x4 number
y4 number
Source:
Returns:

{x: number | null, y: number | null, onL1: bool, onL2: bool}

Type
object

(static) formatPrismOption(obj3, vparas) → {object}

get prism paras from Visual.paras

Parameters:
Name Type Description
obj3 Obj3
Properties
Name Type Description
filter string

the feature area filter. If set, feature.properties must has an 'area' property equal to this. see AssetKeepr.geoTexturePrism

vparas object

Visual.paras

Properties
Name Type Attributes Default Description
maxVerts, number

only works in synchrodous mode

coutn number <optional>
100

features

tile array <optional>
[1, 1]

tiles

geoScale number <optional>
1
origin array <optional>
[0, 0]

geo-center

onFeature function <optional>

callback on each features

geostyle.onGroup function <optional>

callback on each group

Source:
Returns:

potions form prism generating

Type
object

(static) generateCurve(cmpObj3, paras) → {object}

Generate curve

Parameters:
Name Type Description
cmpObj3 object

Obj3

paras object

e.g. Visual.paras paras.curve CurveType

paras.segments: only for CurveType.randomCurve, | randomSegament generated curve segments
paras.range: only for CurveType.randomCurve | randomSegament, generated range, default 400
paras.points array of point, point = [nubmer, number, number]

Source:
Returns:

{curve, points}, where geomCurve is THREE.BufferGeometry, points is the THREE.Vector3 array

Type
object

(static) generateWayxz(paths, y0, origin, style, angleEpsilonopt) → {object}

Generate a x-z plane road polygon alone paths.

Generated road model is applied with geostyle.scale, default 1. So if the referencing path is scaled, the wpos/wtan for shader to animate also been scaled.
Parameters:
Name Type Attributes Default Description
paths array

array of geojson features.

y0 number

y for all vertices

origin array

[x, y, z]

style object

{halfWidth: number, scale: number}

angleEpsilon number <optional>
0.2

minimum angle to be taken as a stright segament.

  • using second point as intersecting point to avoid error (precision problem?)
Source:
Returns:

{geom: geometry, path: {points: Float32Array}}

Type
object

(static) getPointAt(pointBuffer, path, t) → {THREE.Vector3}

Get point alone path, at weight t, and set result point in buffer.

Stolen from SplineCurve.prototype.getPoint

https://github.com/mrdoob/three.js/blob/master/src/extras/curves/SplineCurve.js

Parameters:
Name Type Description
pointBuffer THREE.Vector3
path array.<THREE.Vector3>

point array of THREE.Vector3

t number

weight, range 0 - 1

Source:
Returns:

point

Type
THREE.Vector3

(static) getWayPointAt(pointBuffer, dirBufferopt, points32, t) → {object.<{point: THREE.Vector3, tan: THREE.Vecotor3}>}

Get point alone path, where path is a Float32Array array. The method ignored different distance between way points

Parameters:
Name Type Attributes Description
pointBuffer THREE.Vector3
dirBuffer THREE.Vector3 <optional>
points32 array.<Float32Array>

point array of path

t number

weight, range 0 - 1

Source:
Returns:

{point, tan}

Type
object.<{point: THREE.Vector3, tan: THREE.Vecotor3}>

(static) hexaprism3857(cell, geoCentre, tile0, ctx) → {object}

Generate a tile of hexagon volume. All coordinates are in world. This method is usually been used via AssetKeepr.geoHexaprism in synchronous way or AssetKeepr.geoHexaprismAsync asynchronously

The hexagon center = (cell - geoCentre) * scale, with height ignoring scale, and world z is reversed, z = - (cell.y - geoCentre.y)

This function is supposed to be called by a geojson stream handler, providing reversed +z direction.

Reference:
mathworks: Generating an Array of Hexagonal Shape Pattern
Best way of sharing vertices: flat
walk around of sharing vertics in webgl 1.0: flat shading in webGL
shareing vertices normals is hard in webgl 1.0: WebGL Flat Shading
Three.js cylinder way: CylinderGeometry#generateCap()
reading: OpenGl Tutorial - VBO Indexing
Three.js Custom BufferGeometry, Three.js Fundamentals

Parameters:
Name Type Description
cell object

information of cell geometry to be created cell.coord: [x, y] - 2d position, in epsg 3857 ( +y pointing -z in x world) cell.height: number - default 1 cell.geoscale: number - default 1, y scale ignored (always 1).

geoCentre array

2d position, in epsg 3857, for the scene center

tile0 array

2d array of model position of 6 hexagon vertices, in three.js world, typically got with xgeom.hexatile

ctx object

context of stream data processing

pos: Float32Array(verts * 3);
loc: Float32Array(verts * 3);
uvs: Float32Array(verts * 2);
normals: Float32Array(verts * 3);
dirs: Float32Array(verts * 3); attribute a_tan,
where a_tan[1] = onGroup(), (a_tan[0, 1] represent dir in xz plane),
where onGroup function is provide by user, giving a chance to set a feature's flag.
index: [];
vx: number - the first vertex index of a feature, 0, 26, ...
where verts is the total vertices number, verts = features * 26

Source:
Returns:

part of vertices {pos, uvs, normals, dirs, index}, totally 28 vertices

Type
object

(static) hexatile(r) → {object}

cell.radius: default 1

Parameters:
Name Type Description
r number

circumcircle's radius

Source:
Returns:

{vert, norm, r, r05, sqrt32}, where
.vert: an array of hexagon vertices
norm: 6 direction's normal
r: the radius
r05: half r
sqrt32:√3/2 * r

Type
object

(static) texPrism3857(cell, geoCenter, ctx) → {object}

Generate a prism by extruding polygon.

This method is also handling virtual boxes if the features is generated correctly before the polygon been handled.
Parameters:
Name Type Description
cell object

array of geojson features.

geoCenter array

[x, y] in 3857

ctx object

context of stream data processing

pos: Float32Array(verts * 3);
loc: Float32Array(verts * 3);
atiles: Float32Array(verts * 2), tiles attribute, number of x,z tiles
uvs: Float32Array(verts * 2);
normals: Float32Array(verts * 3);
box: Float32Array(verts * 3); attribute a_box,
index: [] js 1D array of face vertices index;
vx: number - the first vertex index of a feature. The function update
ctx.vx = ctx.vx + verts before return

Source:
Returns:

ctx, part of vertices {pos, uvs, normals, dirs, index}, saved in ctx

Type
object

(static) xof3857(xy, geoScale, geoC0, buf) → {array}

Get xworld postion of 3857 position.

Parameters:
Name Type Description
xy array

[x, y] in EPSG 3857

geoScale number

scale

geoC0 array

c0(x, y)

buf array

[x * geoScale, 0, -y * geoScale] x-world position

Source:
Returns:

buf

Type
array

(static) xzBox(polygon,) → {object}

Get bounding box of a polygon

Parameters:
Name Type Description
polygon, array

geojson feature's geometry.coordinates, in EPSG 3857

Source:
Returns:

{xzwh, loc}, where x,z:lower left xy, w,h:width height, loc: center

Type
object