@luma.gl/engine 9.0.0-alpha.14 → 9.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +51 -72
- package/dist/animation/timeline.d.ts +4 -4
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +94 -131
- package/dist/animation-loop/animation-loop.d.ts +2 -3
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +414 -473
- package/dist/animation-loop/animation-props.d.ts +1 -2
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js +0 -1
- package/dist/animation-loop/make-animation-loop.d.ts +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +26 -31
- package/dist/animation-loop/render-loop.js +17 -7
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +31 -0
- package/dist/es5/animation/key-frames.js +84 -0
- package/dist/es5/animation/key-frames.js.map +1 -0
- package/dist/es5/animation/timeline.js +183 -0
- package/dist/es5/animation/timeline.js.map +1 -0
- package/dist/es5/animation-loop/animation-loop.js +534 -0
- package/dist/es5/animation-loop/animation-loop.js.map +1 -0
- package/dist/es5/animation-loop/animation-props.js +2 -0
- package/dist/es5/animation-loop/animation-props.js.map +1 -0
- package/dist/es5/animation-loop/make-animation-loop.js +53 -0
- package/dist/es5/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/es5/animation-loop/render-loop.js +39 -0
- package/dist/es5/animation-loop/render-loop.js.map +1 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/geometries/cone-geometry.js +43 -0
- package/dist/es5/geometries/cone-geometry.js.map +1 -0
- package/dist/es5/geometries/cube-geometry.js +84 -0
- package/dist/es5/geometries/cube-geometry.js.map +1 -0
- package/dist/es5/geometries/cylinder-geometry.js +39 -0
- package/dist/es5/geometries/cylinder-geometry.js.map +1 -0
- package/dist/es5/geometries/ico-sphere-geometry.js +185 -0
- package/dist/es5/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/es5/geometries/plane-geometry.js +137 -0
- package/dist/es5/geometries/plane-geometry.js.map +1 -0
- package/dist/es5/geometries/sphere-geometry.js +120 -0
- package/dist/es5/geometries/sphere-geometry.js.map +1 -0
- package/dist/es5/geometries/truncated-cone-geometry.js +160 -0
- package/dist/es5/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/es5/geometry/geometry-table.js +2 -0
- package/dist/es5/geometry/geometry-table.js.map +1 -0
- package/dist/es5/geometry/geometry-utils.js +39 -0
- package/dist/es5/geometry/geometry-utils.js.map +1 -0
- package/dist/es5/geometry/geometry.js +150 -0
- package/dist/es5/geometry/geometry.js.map +1 -0
- package/dist/es5/geometry/primitive-utils.js +2 -0
- package/dist/es5/geometry/primitive-utils.js.map +1 -0
- package/dist/es5/index.js +112 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/clip-space.js +2 -0
- package/dist/es5/lib/clip-space.js.map +1 -0
- package/dist/es5/lib/model-utils.js +52 -0
- package/dist/es5/lib/model-utils.js.map +1 -0
- package/dist/es5/lib/model.js +173 -0
- package/dist/es5/lib/model.js.map +1 -0
- package/dist/es5/lib/pipeline-factory.js +244 -0
- package/dist/es5/lib/pipeline-factory.js.map +1 -0
- package/dist/esm/animation/key-frames.js +57 -0
- package/dist/esm/animation/key-frames.js.map +1 -0
- package/dist/esm/animation/timeline.js +113 -0
- package/dist/esm/animation/timeline.js.map +1 -0
- package/dist/esm/animation-loop/animation-loop.js +367 -0
- package/dist/esm/animation-loop/animation-loop.js.map +1 -0
- package/dist/esm/animation-loop/animation-props.js +2 -0
- package/dist/esm/animation-loop/animation-props.js.map +1 -0
- package/dist/esm/animation-loop/make-animation-loop.js +28 -0
- package/dist/esm/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/esm/animation-loop/render-loop.js +7 -0
- package/dist/esm/animation-loop/render-loop.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/geometries/cone-geometry.js +21 -0
- package/dist/esm/geometries/cone-geometry.js.map +1 -0
- package/dist/esm/geometries/cube-geometry.js +67 -0
- package/dist/esm/geometries/cube-geometry.js.map +1 -0
- package/dist/esm/geometries/cylinder-geometry.js +18 -0
- package/dist/esm/geometries/cylinder-geometry.js.map +1 -0
- package/dist/esm/geometries/ico-sphere-geometry.js +170 -0
- package/dist/esm/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/esm/geometries/plane-geometry.js +119 -0
- package/dist/esm/geometries/plane-geometry.js.map +1 -0
- package/dist/esm/geometries/sphere-geometry.js +102 -0
- package/dist/esm/geometries/sphere-geometry.js.map +1 -0
- package/dist/esm/geometries/truncated-cone-geometry.js +136 -0
- package/dist/esm/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/esm/geometry/geometry-table.js +2 -0
- package/dist/esm/geometry/geometry-table.js.map +1 -0
- package/dist/esm/geometry/geometry-utils.js +37 -0
- package/dist/esm/geometry/geometry-utils.js.map +1 -0
- package/dist/esm/geometry/geometry.js +119 -0
- package/dist/esm/geometry/geometry.js.map +1 -0
- package/dist/esm/geometry/primitive-utils.js +2 -0
- package/dist/esm/geometry/primitive-utils.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/clip-space.js +2 -0
- package/dist/esm/lib/clip-space.js.map +1 -0
- package/dist/esm/lib/model-utils.js +40 -0
- package/dist/esm/lib/model-utils.js.map +1 -0
- package/dist/esm/lib/model.js +146 -0
- package/dist/esm/lib/model.js.map +1 -0
- package/dist/esm/lib/pipeline-factory.js +180 -0
- package/dist/esm/lib/pipeline-factory.js.map +1 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +12 -17
- package/dist/geometries/cube-geometry.d.ts +1 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +187 -56
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +10 -14
- package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +141 -170
- package/dist/geometries/plane-geometry.d.ts +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +93 -121
- package/dist/geometries/sphere-geometry.d.ts +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +76 -100
- package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +104 -131
- package/dist/geometry/geometry-table.d.ts +1 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +0 -1
- package/dist/geometry/geometry-utils.js +22 -41
- package/dist/geometry/geometry.d.ts +4 -4
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +96 -142
- package/dist/geometry/primitive-utils.js +30 -1
- package/dist/index.js +20 -16
- package/dist/lib/clip-space.js +50 -1
- package/dist/lib/model-utils.js +97 -29
- package/dist/lib/model.d.ts +1 -1
- package/dist/lib/model.d.ts.map +1 -1
- package/dist/lib/model.js +122 -166
- package/dist/lib/pipeline-factory.d.ts +3 -3
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +136 -204
- package/package.json +12 -11
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/animation-loop/animation-loop.js.map +0 -1
- package/dist/animation-loop/animation-props.js.map +0 -1
- package/dist/animation-loop/make-animation-loop.js.map +0 -1
- package/dist/animation-loop/render-loop.js.map +0 -1
- package/dist/bundle.js.map +0 -1
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/geometry/geometry-table.js.map +0 -1
- package/dist/geometry/geometry-utils.js.map +0 -1
- package/dist/geometry/geometry.js.map +0 -1
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
|
@@ -1,107 +1,83 @@
|
|
|
1
1
|
import { uid } from '@luma.gl/api';
|
|
2
|
-
import Geometry from '../geometry/geometry';
|
|
2
|
+
import Geometry from '../geometry/geometry.js';
|
|
3
|
+
// Primitives inspired by TDL http://code.google.com/p/webglsamples/,
|
|
4
|
+
// copyright 2011 Google Inc. new BSD License
|
|
5
|
+
// (http://www.opensource.org/licenses/bsd-license.php).
|
|
3
6
|
export class SphereGeometry extends Geometry {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
indices,
|
|
15
|
-
attributes: { ...attributes,
|
|
16
|
-
...props.attributes
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
7
|
+
constructor(props = {}) {
|
|
8
|
+
const { id = uid('sphere-geometry') } = props;
|
|
9
|
+
const { indices, attributes } = tesselateSphere(props);
|
|
10
|
+
super({
|
|
11
|
+
...props,
|
|
12
|
+
id,
|
|
13
|
+
indices,
|
|
14
|
+
attributes: { ...attributes, ...props.attributes }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
21
17
|
}
|
|
22
|
-
|
|
18
|
+
/* eslint-disable max-statements, complexity */
|
|
23
19
|
function tesselateSphere(props) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
normals[i3 + 1] = uy;
|
|
66
|
-
normals[i3 + 2] = uz;
|
|
67
|
-
texCoords[i2 + 0] = u;
|
|
68
|
-
texCoords[i2 + 1] = 1 - v;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const numVertsAround = nlong + 1;
|
|
73
|
-
|
|
74
|
-
for (let x = 0; x < nlong; x++) {
|
|
75
|
-
for (let y = 0; y < nlat; y++) {
|
|
76
|
-
const index = (x * nlat + y) * 6;
|
|
77
|
-
indices[index + 0] = y * numVertsAround + x;
|
|
78
|
-
indices[index + 1] = y * numVertsAround + x + 1;
|
|
79
|
-
indices[index + 2] = (y + 1) * numVertsAround + x;
|
|
80
|
-
indices[index + 3] = (y + 1) * numVertsAround + x;
|
|
81
|
-
indices[index + 4] = y * numVertsAround + x + 1;
|
|
82
|
-
indices[index + 5] = (y + 1) * numVertsAround + x + 1;
|
|
20
|
+
const { nlat = 10, nlong = 10 } = props;
|
|
21
|
+
const startLat = 0;
|
|
22
|
+
const endLat = Math.PI;
|
|
23
|
+
const latRange = endLat - startLat;
|
|
24
|
+
const startLong = 0;
|
|
25
|
+
const endLong = 2 * Math.PI;
|
|
26
|
+
const longRange = endLong - startLong;
|
|
27
|
+
const numVertices = (nlat + 1) * (nlong + 1);
|
|
28
|
+
const radius = (n1, n2, n3, u, v) => props.radius || 1;
|
|
29
|
+
const positions = new Float32Array(numVertices * 3);
|
|
30
|
+
const normals = new Float32Array(numVertices * 3);
|
|
31
|
+
const texCoords = new Float32Array(numVertices * 2);
|
|
32
|
+
const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;
|
|
33
|
+
const indices = new IndexType(nlat * nlong * 6);
|
|
34
|
+
// Create positions, normals and texCoords
|
|
35
|
+
for (let y = 0; y <= nlat; y++) {
|
|
36
|
+
for (let x = 0; x <= nlong; x++) {
|
|
37
|
+
const u = x / nlong;
|
|
38
|
+
const v = y / nlat;
|
|
39
|
+
const index = x + y * (nlong + 1);
|
|
40
|
+
const i2 = index * 2;
|
|
41
|
+
const i3 = index * 3;
|
|
42
|
+
const theta = longRange * u;
|
|
43
|
+
const phi = latRange * v;
|
|
44
|
+
const sinTheta = Math.sin(theta);
|
|
45
|
+
const cosTheta = Math.cos(theta);
|
|
46
|
+
const sinPhi = Math.sin(phi);
|
|
47
|
+
const cosPhi = Math.cos(phi);
|
|
48
|
+
const ux = cosTheta * sinPhi;
|
|
49
|
+
const uy = cosPhi;
|
|
50
|
+
const uz = sinTheta * sinPhi;
|
|
51
|
+
const r = radius(ux, uy, uz, u, v);
|
|
52
|
+
positions[i3 + 0] = r * ux;
|
|
53
|
+
positions[i3 + 1] = r * uy;
|
|
54
|
+
positions[i3 + 2] = r * uz;
|
|
55
|
+
normals[i3 + 0] = ux;
|
|
56
|
+
normals[i3 + 1] = uy;
|
|
57
|
+
normals[i3 + 2] = uz;
|
|
58
|
+
texCoords[i2 + 0] = u;
|
|
59
|
+
texCoords[i2 + 1] = 1 - v;
|
|
60
|
+
}
|
|
83
61
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
NORMAL: {
|
|
97
|
-
size: 3,
|
|
98
|
-
value: normals
|
|
99
|
-
},
|
|
100
|
-
TEXCOORD_0: {
|
|
101
|
-
size: 2,
|
|
102
|
-
value: texCoords
|
|
103
|
-
}
|
|
62
|
+
// Create indices
|
|
63
|
+
const numVertsAround = nlong + 1;
|
|
64
|
+
for (let x = 0; x < nlong; x++) {
|
|
65
|
+
for (let y = 0; y < nlat; y++) {
|
|
66
|
+
const index = (x * nlat + y) * 6;
|
|
67
|
+
indices[index + 0] = y * numVertsAround + x;
|
|
68
|
+
indices[index + 1] = y * numVertsAround + x + 1;
|
|
69
|
+
indices[index + 2] = (y + 1) * numVertsAround + x;
|
|
70
|
+
indices[index + 3] = (y + 1) * numVertsAround + x;
|
|
71
|
+
indices[index + 4] = y * numVertsAround + x + 1;
|
|
72
|
+
indices[index + 5] = (y + 1) * numVertsAround + x + 1;
|
|
73
|
+
}
|
|
104
74
|
}
|
|
105
|
-
|
|
75
|
+
return {
|
|
76
|
+
indices: { size: 1, value: indices },
|
|
77
|
+
attributes: {
|
|
78
|
+
POSITION: { size: 3, value: positions },
|
|
79
|
+
NORMAL: { size: 3, value: normals },
|
|
80
|
+
TEXCOORD_0: { size: 2, value: texCoords }
|
|
81
|
+
}
|
|
82
|
+
};
|
|
106
83
|
}
|
|
107
|
-
//# sourceMappingURL=sphere-geometry.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Geometry from '../geometry/geometry';
|
|
2
2
|
import { GeometryTable } from '../geometry/geometry-table';
|
|
3
|
-
export
|
|
3
|
+
export type TruncatedConeGeometryProps = {
|
|
4
4
|
topRadius?: number;
|
|
5
5
|
bottomRadius?: number;
|
|
6
6
|
topCap?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truncated-cone-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAQzD,
|
|
1
|
+
{"version":3,"file":"truncated-cone-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAQzD,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAChC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,0BAA0B,GAAG,aAAa,CAO3F;AAED,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,KAAK,GAAE,0BAA0B,GAAG;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,GAAG,CAAA;KAAM;CAcrF"}
|
|
@@ -1,142 +1,115 @@
|
|
|
1
1
|
import { uid } from '@luma.gl/api';
|
|
2
|
-
import Geometry from '../geometry/geometry';
|
|
2
|
+
import Geometry from '../geometry/geometry.js';
|
|
3
3
|
const INDEX_OFFSETS = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
x: [2, 0, 1],
|
|
5
|
+
y: [0, 1, 2],
|
|
6
|
+
z: [1, 2, 0]
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Primitives inspired by TDL http://code.google.com/p/webglsamples/,
|
|
10
|
+
* copyright 2011 Google Inc. new BSD License
|
|
11
|
+
* (http://www.opensource.org/licenses/bsd-license.php).
|
|
12
|
+
*/
|
|
8
13
|
export function makeTruncatedConeGeometry(props) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
indices,
|
|
16
|
-
attributes
|
|
17
|
-
};
|
|
14
|
+
const { indices, attributes } = tesselateTruncatedCone(props);
|
|
15
|
+
return {
|
|
16
|
+
length: indices.length,
|
|
17
|
+
indices,
|
|
18
|
+
attributes
|
|
19
|
+
};
|
|
18
20
|
}
|
|
19
21
|
export class TruncatedConeGeometry extends Geometry {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
NORMAL: {
|
|
37
|
-
size: 3,
|
|
38
|
-
value: attributes.NORMAL
|
|
39
|
-
},
|
|
40
|
-
TEXCOORD_0: {
|
|
41
|
-
size: 2,
|
|
42
|
-
value: attributes.TEXCOORD_0
|
|
43
|
-
},
|
|
44
|
-
...props.attributes
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
22
|
+
constructor(props = {}) {
|
|
23
|
+
const { id = uid('truncated-code-geometry') } = props;
|
|
24
|
+
const { indices, attributes } = tesselateTruncatedCone(props);
|
|
25
|
+
super({
|
|
26
|
+
...props,
|
|
27
|
+
id,
|
|
28
|
+
indices,
|
|
29
|
+
attributes: {
|
|
30
|
+
POSITION: { size: 3, value: attributes.POSITION },
|
|
31
|
+
NORMAL: { size: 3, value: attributes.NORMAL },
|
|
32
|
+
TEXCOORD_0: { size: 2, value: attributes.TEXCOORD_0 },
|
|
33
|
+
...props.attributes
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
49
37
|
}
|
|
50
|
-
|
|
38
|
+
/* eslint-disable max-statements, complexity */
|
|
51
39
|
function tesselateTruncatedCone(props = {}) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const cos = mcos(j * mpi * 2 / nradial);
|
|
108
|
-
positions[i3 + indexOffset[0]] = sin * ringRadius;
|
|
109
|
-
positions[i3 + indexOffset[1]] = y;
|
|
110
|
-
positions[i3 + indexOffset[2]] = cos * ringRadius;
|
|
111
|
-
normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
|
|
112
|
-
normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
|
|
113
|
-
normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
|
|
114
|
-
texCoords[i2 + 0] = j / nradial;
|
|
115
|
-
texCoords[i2 + 1] = v;
|
|
116
|
-
i2 += 2;
|
|
117
|
-
i3 += 3;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
for (let i = 0; i < nvertical + extra; i++) {
|
|
122
|
-
for (let j = 0; j < nradial; j++) {
|
|
123
|
-
const index = (i * nradial + j) * 6;
|
|
124
|
-
indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
125
|
-
indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
|
|
126
|
-
indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
127
|
-
indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
128
|
-
indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
129
|
-
indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
|
|
40
|
+
const { bottomRadius = 0, topRadius = 0, height = 1, nradial = 10, nvertical = 10, verticalAxis = 'y', topCap = false, bottomCap = false } = props;
|
|
41
|
+
const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
|
|
42
|
+
const numVertices = (nradial + 1) * (nvertical + 1 + extra);
|
|
43
|
+
const slant = Math.atan2(bottomRadius - topRadius, height);
|
|
44
|
+
const msin = Math.sin;
|
|
45
|
+
const mcos = Math.cos;
|
|
46
|
+
const mpi = Math.PI;
|
|
47
|
+
const cosSlant = mcos(slant);
|
|
48
|
+
const sinSlant = msin(slant);
|
|
49
|
+
const start = topCap ? -2 : 0;
|
|
50
|
+
const end = nvertical + (bottomCap ? 2 : 0);
|
|
51
|
+
const vertsAroundEdge = nradial + 1;
|
|
52
|
+
const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
|
|
53
|
+
const indexOffset = INDEX_OFFSETS[verticalAxis];
|
|
54
|
+
const positions = new Float32Array(numVertices * 3);
|
|
55
|
+
const normals = new Float32Array(numVertices * 3);
|
|
56
|
+
const texCoords = new Float32Array(numVertices * 2);
|
|
57
|
+
let i3 = 0;
|
|
58
|
+
let i2 = 0;
|
|
59
|
+
for (let i = start; i <= end; i++) {
|
|
60
|
+
let v = i / nvertical;
|
|
61
|
+
let y = height * v;
|
|
62
|
+
let ringRadius;
|
|
63
|
+
if (i < 0) {
|
|
64
|
+
y = 0;
|
|
65
|
+
v = 1;
|
|
66
|
+
ringRadius = bottomRadius;
|
|
67
|
+
}
|
|
68
|
+
else if (i > nvertical) {
|
|
69
|
+
y = height;
|
|
70
|
+
v = 1;
|
|
71
|
+
ringRadius = topRadius;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
|
|
75
|
+
}
|
|
76
|
+
if (i === -2 || i === nvertical + 2) {
|
|
77
|
+
ringRadius = 0;
|
|
78
|
+
v = 0;
|
|
79
|
+
}
|
|
80
|
+
y -= height / 2;
|
|
81
|
+
for (let j = 0; j < vertsAroundEdge; j++) {
|
|
82
|
+
const sin = msin((j * mpi * 2) / nradial);
|
|
83
|
+
const cos = mcos((j * mpi * 2) / nradial);
|
|
84
|
+
positions[i3 + indexOffset[0]] = sin * ringRadius;
|
|
85
|
+
positions[i3 + indexOffset[1]] = y;
|
|
86
|
+
positions[i3 + indexOffset[2]] = cos * ringRadius;
|
|
87
|
+
normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
|
|
88
|
+
normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
|
|
89
|
+
normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
|
|
90
|
+
texCoords[i2 + 0] = j / nradial;
|
|
91
|
+
texCoords[i2 + 1] = v;
|
|
92
|
+
i2 += 2;
|
|
93
|
+
i3 += 3;
|
|
94
|
+
}
|
|
130
95
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
96
|
+
for (let i = 0; i < nvertical + extra; i++) {
|
|
97
|
+
for (let j = 0; j < nradial; j++) {
|
|
98
|
+
const index = (i * nradial + j) * 6;
|
|
99
|
+
indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
100
|
+
indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
|
|
101
|
+
indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
102
|
+
indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
103
|
+
indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
104
|
+
indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
|
|
105
|
+
}
|
|
139
106
|
}
|
|
140
|
-
|
|
107
|
+
return {
|
|
108
|
+
indices,
|
|
109
|
+
attributes: {
|
|
110
|
+
POSITION: positions,
|
|
111
|
+
NORMAL: normals,
|
|
112
|
+
TEXCOORD_0: texCoords
|
|
113
|
+
}
|
|
114
|
+
};
|
|
141
115
|
}
|
|
142
|
-
//# sourceMappingURL=truncated-cone-geometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,yBAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,yBAAyB;AACzB,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,UAAU,EAAE;QACV,QAAQ,EAAE,UAAU,CAAC;QACrB,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,UAAU,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;CAC3F,CAAA"}
|
|
@@ -1,46 +1,27 @@
|
|
|
1
|
+
// import type Geometry from './geometry.js';
|
|
1
2
|
export function unpackIndexedGeometry(geometry) {
|
|
2
|
-
|
|
3
|
-
indices
|
|
4
|
-
|
|
5
|
-
} = geometry;
|
|
6
|
-
|
|
7
|
-
if (!indices) {
|
|
8
|
-
return geometry;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const vertexCount = indices.value.length;
|
|
12
|
-
const unpackedAttributes = {};
|
|
13
|
-
|
|
14
|
-
for (const attributeName in attributes) {
|
|
15
|
-
const attribute = attributes[attributeName];
|
|
16
|
-
const {
|
|
17
|
-
constant,
|
|
18
|
-
value,
|
|
19
|
-
size
|
|
20
|
-
} = attribute;
|
|
21
|
-
|
|
22
|
-
if (constant || !size) {
|
|
23
|
-
continue;
|
|
3
|
+
const { indices, attributes } = geometry;
|
|
4
|
+
if (!indices) {
|
|
5
|
+
return geometry;
|
|
24
6
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
const vertexCount = indices.value.length;
|
|
8
|
+
const unpackedAttributes = {};
|
|
9
|
+
for (const attributeName in attributes) {
|
|
10
|
+
const attribute = attributes[attributeName];
|
|
11
|
+
const { constant, value, size } = attribute;
|
|
12
|
+
if (constant || !size) {
|
|
13
|
+
continue; // eslint-disable-line
|
|
14
|
+
}
|
|
15
|
+
const unpackedValue = new value.constructor(vertexCount * size);
|
|
16
|
+
for (let x = 0; x < vertexCount; ++x) {
|
|
17
|
+
const index = indices.value[x];
|
|
18
|
+
for (let i = 0; i < size; i++) {
|
|
19
|
+
unpackedValue[x * size + i] = value[index * size + i];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
unpackedAttributes[attributeName] = { size, value: unpackedValue };
|
|
34
23
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
size,
|
|
38
|
-
value: unpackedValue
|
|
24
|
+
return {
|
|
25
|
+
attributes: Object.assign({}, attributes, unpackedAttributes)
|
|
39
26
|
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
attributes: Object.assign({}, attributes, unpackedAttributes)
|
|
44
|
-
};
|
|
45
27
|
}
|
|
46
|
-
//# sourceMappingURL=geometry-utils.js.map
|
|
@@ -4,19 +4,19 @@ import GL from '@luma.gl/constants';
|
|
|
4
4
|
* Rendering primitives - "topology" specifies how to extract primitives from vertices.
|
|
5
5
|
* @deprecated - use string constants instead
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type GLTopology = GL.POINTS | // draw single points.
|
|
8
8
|
GL.LINES | // draw lines. Each vertex connects to the one after it.
|
|
9
9
|
GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
10
10
|
GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last
|
|
11
11
|
GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.
|
|
12
12
|
GL.TRIANGLE_STRIP | // draw a connected group of triangles.
|
|
13
13
|
GL.TRIANGLE_FAN;
|
|
14
|
-
export
|
|
14
|
+
export type GeometryAttribute = {
|
|
15
15
|
size?: number;
|
|
16
16
|
value: TypedArray;
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type GeometryProps = {
|
|
20
20
|
id?: string;
|
|
21
21
|
attributes?: Record<string, GeometryAttribute | TypedArray>;
|
|
22
22
|
indices?: GeometryAttribute | TypedArray;
|
|
@@ -26,7 +26,7 @@ export declare type GeometryProps = {
|
|
|
26
26
|
/** @deprecated */
|
|
27
27
|
drawMode?: GLTopology;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
type GeometryAttributes = {
|
|
30
30
|
POSITION: GeometryAttribute;
|
|
31
31
|
NORMAL: GeometryAttribute;
|
|
32
32
|
TEXCOORD_0: GeometryAttribute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,UAAU,GACpB,EAAE,CAAC,MAAM,GAAI,sBAAsB;AACnC,EAAE,CAAC,KAAK,GAAI,wDAAwD;AACpE,EAAE,CAAC,SAAS,GAAI,8EAA8E;AAC9F,EAAE,CAAC,UAAU,GAAI,4EAA4E;AAC7F,EAAE,CAAC,SAAS,GAAI,0EAA0E;AAC1F,EAAE,CAAC,cAAc,GAAI,uCAAuC;AAC5D,EAAE,CAAC,YAAY,CACd;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC,CAAC;IAC5D,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAC1F,kBAAkB;IAClB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAAA;KAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,kBAAkB;IAClB,MAAM,CAAC,SAAS;;;;;;;;MAQd;IAEF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAEvC,oEAAoE;IACpE,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,kBAAkB;IAClB,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAgB;IAE7C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,EAAE,iBAAiB,CAAC;QAC5B,MAAM,EAAE,iBAAiB,CAAC;QAC1B,UAAU,EAAE,iBAAiB,CAAC;QAC9B,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAA;KAC7C,CAAC;IACF,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;gBAEjC,KAAK,GAAE,aAAkB;IAuDrC,wDAAwD;IACxD,IAAI,IAAI,eAEP;IAED,cAAc,IAAI,MAAM;IAKxB,aAAa,IAAI,kBAAkB;IAOnC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IASrC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;IAKjF,qBAAqB,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM;CAgB7D"}
|