@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.10
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/LICENSE +3 -1
- 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 +8 -8
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +95 -131
- package/dist/animation-loop/animation-loop-template.d.ts +23 -0
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop-template.js +21 -0
- package/dist/{lib → animation-loop}/animation-loop.d.ts +31 -23
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop.js +442 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +4 -5
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +32 -0
- package/dist/computation.d.ts +95 -0
- package/dist/computation.d.ts.map +1 -0
- package/dist/computation.js +248 -0
- package/dist/debug/copy-texture-to-image.d.ts +26 -0
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
- package/dist/debug/copy-texture-to-image.js +43 -0
- package/dist/debug/debug-framebuffer.d.ts +11 -0
- package/dist/debug/debug-framebuffer.d.ts.map +1 -0
- package/dist/debug/debug-framebuffer.js +46 -0
- package/dist/debug/debug-shader-layout.d.ts +9 -0
- package/dist/debug/debug-shader-layout.d.ts.map +1 -0
- package/dist/debug/debug-shader-layout.js +27 -0
- package/dist/debug/pixel-data-utils.d.ts +24 -0
- package/dist/debug/pixel-data-utils.d.ts.map +1 -0
- package/dist/debug/pixel-data-utils.js +39 -0
- package/dist/dist.dev.js +9592 -0
- package/dist/dist.min.js +102 -0
- package/dist/geometries/cone-geometry.d.ts +2 -2
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +13 -18
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +192 -57
- package/dist/geometries/cylinder-geometry.d.ts +2 -2
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +11 -15
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +143 -171
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +95 -122
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +78 -101
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +100 -134
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +3 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +35 -41
- package/dist/geometry/geometry.d.ts +43 -43
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +82 -139
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +90 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +42 -0
- package/dist/index.cjs +3444 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +43 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -15
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +43 -2
- package/dist/lib/pipeline-factory.d.ts +17 -51
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +84 -209
- package/dist/lib/shader-factory.d.ts +17 -0
- package/dist/lib/shader-factory.d.ts.map +1 -0
- package/dist/lib/shader-factory.js +46 -0
- package/dist/model/model.d.ts +219 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +659 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +84 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +35 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +153 -0
- package/dist/shader-inputs.d.ts +63 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +107 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +70 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +117 -0
- package/dist.min.js +25 -0
- package/package.json +24 -14
- package/src/animation/timeline.ts +35 -34
- package/src/animation-loop/animation-loop-template.ts +25 -0
- package/src/{lib → animation-loop}/animation-loop.ts +114 -93
- package/src/{lib → animation-loop}/animation-props.ts +2 -2
- package/src/animation-loop/make-animation-loop.ts +53 -0
- package/src/computation.ts +346 -0
- package/src/debug/copy-texture-to-image.ts +70 -0
- package/src/debug/debug-framebuffer.ts +70 -0
- package/src/debug/debug-shader-layout.ts +38 -0
- package/src/debug/pixel-data-utils.ts +54 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +62 -56
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +6 -5
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +6 -14
- package/src/geometry/geometry-table.ts +10 -7
- package/src/geometry/geometry-utils.ts +19 -3
- package/src/geometry/geometry.ts +68 -110
- package/src/geometry/gpu-geometry.ts +132 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +37 -10
- package/src/lib/clip-space.ts +32 -34
- package/src/lib/pipeline-factory.ts +83 -193
- package/src/lib/shader-factory.ts +57 -0
- package/src/model/model.ts +835 -0
- package/src/scenegraph/group-node.ts +107 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +157 -0
- package/src/transform/buffer-transform.ts +102 -0
- package/src/transform/texture-transform.ts +168 -0
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- 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.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js +0 -480
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js +0 -2
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -182
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -183
- package/src/lib/render-loop.ts +0 -58
|
@@ -1,142 +1,108 @@
|
|
|
1
|
-
import { uid } from '@luma.gl/
|
|
2
|
-
import Geometry from
|
|
1
|
+
import { uid } from '@luma.gl/core';
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
length: indices.length,
|
|
15
|
-
indices,
|
|
16
|
-
attributes
|
|
17
|
-
};
|
|
18
|
-
}
|
|
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
|
+
*/
|
|
19
13
|
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
|
-
|
|
14
|
+
constructor(props = {}) {
|
|
15
|
+
const { id = uid('truncated-code-geometry') } = props;
|
|
16
|
+
const { indices, attributes } = tesselateTruncatedCone(props);
|
|
17
|
+
super({
|
|
18
|
+
...props,
|
|
19
|
+
id,
|
|
20
|
+
topology: 'triangle-list',
|
|
21
|
+
indices,
|
|
22
|
+
attributes: {
|
|
23
|
+
POSITION: { size: 3, value: attributes.POSITION },
|
|
24
|
+
NORMAL: { size: 3, value: attributes.NORMAL },
|
|
25
|
+
TEXCOORD_0: { size: 2, value: attributes.TEXCOORD_0 },
|
|
26
|
+
...props.attributes
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
49
30
|
}
|
|
50
|
-
|
|
31
|
+
/* eslint-disable max-statements, complexity */
|
|
51
32
|
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;
|
|
33
|
+
const { bottomRadius = 0, topRadius = 0, height = 1, nradial = 10, nvertical = 10, verticalAxis = 'y', topCap = false, bottomCap = false } = props;
|
|
34
|
+
const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
|
|
35
|
+
const numVertices = (nradial + 1) * (nvertical + 1 + extra);
|
|
36
|
+
const slant = Math.atan2(bottomRadius - topRadius, height);
|
|
37
|
+
const msin = Math.sin;
|
|
38
|
+
const mcos = Math.cos;
|
|
39
|
+
const mpi = Math.PI;
|
|
40
|
+
const cosSlant = mcos(slant);
|
|
41
|
+
const sinSlant = msin(slant);
|
|
42
|
+
const start = topCap ? -2 : 0;
|
|
43
|
+
const end = nvertical + (bottomCap ? 2 : 0);
|
|
44
|
+
const vertsAroundEdge = nradial + 1;
|
|
45
|
+
const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
|
|
46
|
+
const indexOffset = INDEX_OFFSETS[verticalAxis];
|
|
47
|
+
const positions = new Float32Array(numVertices * 3);
|
|
48
|
+
const normals = new Float32Array(numVertices * 3);
|
|
49
|
+
const texCoords = new Float32Array(numVertices * 2);
|
|
50
|
+
let i3 = 0;
|
|
51
|
+
let i2 = 0;
|
|
52
|
+
for (let i = start; i <= end; i++) {
|
|
53
|
+
let v = i / nvertical;
|
|
54
|
+
let y = height * v;
|
|
55
|
+
let ringRadius;
|
|
56
|
+
if (i < 0) {
|
|
57
|
+
y = 0;
|
|
58
|
+
v = 1;
|
|
59
|
+
ringRadius = bottomRadius;
|
|
60
|
+
}
|
|
61
|
+
else if (i > nvertical) {
|
|
62
|
+
y = height;
|
|
63
|
+
v = 1;
|
|
64
|
+
ringRadius = topRadius;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
|
|
68
|
+
}
|
|
69
|
+
if (i === -2 || i === nvertical + 2) {
|
|
70
|
+
ringRadius = 0;
|
|
71
|
+
v = 0;
|
|
72
|
+
}
|
|
73
|
+
y -= height / 2;
|
|
74
|
+
for (let j = 0; j < vertsAroundEdge; j++) {
|
|
75
|
+
const sin = msin((j * mpi * 2) / nradial);
|
|
76
|
+
const cos = mcos((j * mpi * 2) / nradial);
|
|
77
|
+
positions[i3 + indexOffset[0]] = sin * ringRadius;
|
|
78
|
+
positions[i3 + indexOffset[1]] = y;
|
|
79
|
+
positions[i3 + indexOffset[2]] = cos * ringRadius;
|
|
80
|
+
normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
|
|
81
|
+
normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
|
|
82
|
+
normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
|
|
83
|
+
texCoords[i2 + 0] = j / nradial;
|
|
84
|
+
texCoords[i2 + 1] = v;
|
|
85
|
+
i2 += 2;
|
|
86
|
+
i3 += 3;
|
|
87
|
+
}
|
|
130
88
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
89
|
+
for (let i = 0; i < nvertical + extra; i++) {
|
|
90
|
+
for (let j = 0; j < nradial; j++) {
|
|
91
|
+
const index = (i * nradial + j) * 6;
|
|
92
|
+
indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
93
|
+
indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
|
|
94
|
+
indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
95
|
+
indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
|
|
96
|
+
indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
|
|
97
|
+
indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
|
|
98
|
+
}
|
|
139
99
|
}
|
|
140
|
-
|
|
100
|
+
return {
|
|
101
|
+
indices,
|
|
102
|
+
attributes: {
|
|
103
|
+
POSITION: positions,
|
|
104
|
+
NORMAL: normals,
|
|
105
|
+
TEXCOORD_0: texCoords
|
|
106
|
+
}
|
|
107
|
+
};
|
|
141
108
|
}
|
|
142
|
-
//# sourceMappingURL=truncated-cone-geometry.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { TypedArray, VertexFormat } from '@luma.gl/
|
|
1
|
+
import type { TypedArray, VertexFormat } from '@luma.gl/core';
|
|
2
2
|
/** Holds one geometry */
|
|
3
|
-
export
|
|
3
|
+
export type GeometryTable = {
|
|
4
4
|
length: number;
|
|
5
5
|
schema?: Record<string, VertexFormat>;
|
|
6
6
|
attributes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAE5D,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,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-utils.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"geometry-utils.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,OA4BlD"}
|
|
@@ -1,46 +1,40 @@
|
|
|
1
|
+
// import type {Geometry} from './geometry';
|
|
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
|
-
|
|
28
|
+
// export function calculateVertexNormals(positions: Float32Array): Uint8Array {
|
|
29
|
+
// let normals = new Uint8Array(positions.length / 3);
|
|
30
|
+
// for (let i = 0; i < positions.length; i++) {
|
|
31
|
+
// const vec1 = new Vector3(positions.subarray(i * 3, i + 0, i + 3));
|
|
32
|
+
// const vec2 = new Vector3(positions.subarray(i + 3, i + 6));
|
|
33
|
+
// const vec3 = new Vector3(positions.subarray(i + 6, i + 9));
|
|
34
|
+
// const normal = new Vector3(vec1).cross(vec2).normalize();
|
|
35
|
+
// normals.set(normal[0], i + 4);
|
|
36
|
+
// normals.set(normal[1], i + 4 + 1);
|
|
37
|
+
// normals.set(normal[2], i + 2);
|
|
38
|
+
// }
|
|
39
|
+
// const normal = new Vector3(vec1).cross(vec2).normalize();
|
|
40
|
+
// }
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import type { PrimitiveTopology, TypedArray } from '@luma.gl/
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Rendering primitives - "topology" specifies how to extract primitives from vertices.
|
|
5
|
-
* @deprecated - use string constants instead
|
|
6
|
-
*/
|
|
7
|
-
export declare type GLTopology = GL.POINTS | // draw single points.
|
|
8
|
-
GL.LINES | // draw lines. Each vertex connects to the one after it.
|
|
9
|
-
GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
10
|
-
GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last
|
|
11
|
-
GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.
|
|
12
|
-
GL.TRIANGLE_STRIP | // draw a connected group of triangles.
|
|
13
|
-
GL.TRIANGLE_FAN;
|
|
14
|
-
export declare type GeometryAttribute = {
|
|
15
|
-
size?: number;
|
|
16
|
-
value: TypedArray;
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
};
|
|
19
|
-
export declare type GeometryProps = {
|
|
1
|
+
import type { PrimitiveTopology, TypedArray } from '@luma.gl/core';
|
|
2
|
+
export type GeometryProps = {
|
|
20
3
|
id?: string;
|
|
4
|
+
/** Determines how vertices are read from the 'vertex' attributes */
|
|
5
|
+
topology: 'point-list' | 'line-list' | 'line-strip' | 'line-loop-webgl' | 'triangle-list' | 'triangle-strip' | 'triangle-fan-webgl';
|
|
6
|
+
/** Auto calculated from attributes if not provided */
|
|
7
|
+
vertexCount?: number;
|
|
21
8
|
attributes?: Record<string, GeometryAttribute | TypedArray>;
|
|
22
9
|
indices?: GeometryAttribute | TypedArray;
|
|
23
|
-
vertexCount?: number;
|
|
24
|
-
/** Determines how vertices are read from the 'vertex' attributes */
|
|
25
|
-
topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
|
|
26
|
-
/** @deprecated */
|
|
27
|
-
drawMode?: GLTopology;
|
|
28
10
|
};
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
TRIANGLE_STRIP: GL;
|
|
38
|
-
TRIANGLE_FAN: GL;
|
|
11
|
+
export type GeometryAttributes = {
|
|
12
|
+
POSITION: GeometryAttribute;
|
|
13
|
+
NORMAL: GeometryAttribute;
|
|
14
|
+
TEXCOORD_0: GeometryAttribute;
|
|
15
|
+
COLOR_0?: GeometryAttribute;
|
|
16
|
+
indices?: GeometryAttribute & {
|
|
17
|
+
size: 1;
|
|
18
|
+
value: Uint32Array | Uint16Array;
|
|
39
19
|
};
|
|
20
|
+
};
|
|
21
|
+
export type GeometryAttribute = {
|
|
22
|
+
size?: number;
|
|
23
|
+
value: TypedArray;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
export declare class Geometry {
|
|
40
27
|
readonly id: string;
|
|
41
|
-
userData: Record<string, unknown>;
|
|
42
28
|
/** Determines how vertices are read from the 'vertex' attributes */
|
|
43
|
-
topology?: PrimitiveTopology;
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
readonly drawMode: GLTopology;
|
|
29
|
+
readonly topology?: PrimitiveTopology;
|
|
46
30
|
readonly vertexCount: number;
|
|
31
|
+
readonly indices?: GeometryAttribute;
|
|
47
32
|
readonly attributes: {
|
|
48
33
|
POSITION: GeometryAttribute;
|
|
49
34
|
NORMAL: GeometryAttribute;
|
|
50
35
|
TEXCOORD_0: GeometryAttribute;
|
|
51
36
|
COLOR_0?: GeometryAttribute;
|
|
37
|
+
[key: string]: GeometryAttribute | undefined;
|
|
52
38
|
};
|
|
53
|
-
|
|
54
|
-
constructor(props
|
|
55
|
-
/** @deprecated Use string topology constants instead */
|
|
56
|
-
get mode(): GLTopology;
|
|
39
|
+
userData: Record<string, unknown>;
|
|
40
|
+
constructor(props: GeometryProps);
|
|
57
41
|
getVertexCount(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Return an object with all attributes plus indices added as a field.
|
|
44
|
+
* TODO Geometry types are a mess
|
|
45
|
+
*/
|
|
46
|
+
getAttributes(): GeometryAttributes;
|
|
58
47
|
_print(attributeName: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* GeometryAttribute
|
|
50
|
+
* value: typed array
|
|
51
|
+
* type: indices, vertices, uvs
|
|
52
|
+
* size: elements per vertex
|
|
53
|
+
* target: WebGL buffer type (string or constant)
|
|
54
|
+
*
|
|
55
|
+
* @param attributes
|
|
56
|
+
* @param indices
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
59
|
_setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this;
|
|
60
|
-
_calculateVertexCount(attributes:
|
|
60
|
+
_calculateVertexCount(attributes: GeometryAttributes, indices: GeometryAttribute): number;
|
|
61
61
|
}
|
|
62
62
|
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAGjE,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,QAAQ,EACJ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,oBAAoB,CAAC;IACzB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC,CAAC;IAC5D,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,GAAG;QAAC,IAAI,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAAA;KAAC,CAAC;CAC3E,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,qBAAa,QAAQ;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IACrC,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,CAAC;KAC9C,CAAC;IAEF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;gBAE3B,KAAK,EAAE,aAAa;IA6ChC,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACH,aAAa,IAAI,kBAAkB;IAMnC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAIrC;;;;;;;;;;OAUG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;IAIjF,qBAAqB,CAAC,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM;CAe1F"}
|