@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,152 +1,106 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { uid, assert } from '@luma.gl/api';
|
|
3
2
|
import GL from '@luma.gl/constants';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
3
|
+
class Geometry {
|
|
4
|
+
constructor(props = {}) {
|
|
5
|
+
this.userData = {};
|
|
6
|
+
/** @deprecated */
|
|
7
|
+
this.drawMode = GL.TRIANGLES;
|
|
8
|
+
const { id = uid('geometry'), drawMode = GL.TRIANGLES, attributes = {}, indices = null, vertexCount = null } = props;
|
|
9
|
+
this.id = id;
|
|
10
|
+
this.drawMode = drawMode;
|
|
11
|
+
this.topology = props.topology || convertToTopology(drawMode);
|
|
12
|
+
if (indices) {
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
this.indices = ArrayBuffer.isView(indices) ? { value: indices, size: 1 } : indices;
|
|
15
|
+
}
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
this.attributes = {};
|
|
18
|
+
for (const [attributeName, attributeValue] of Object.entries(attributes)) {
|
|
19
|
+
// Wrap "unwrapped" arrays and try to autodetect their type
|
|
20
|
+
const attribute = ArrayBuffer.isView(attributeValue) ? { value: attributeValue } : attributeValue;
|
|
21
|
+
assert(ArrayBuffer.isView(attribute.value), `${this._print(attributeName)}: must be typed array or object with value as typed array`);
|
|
22
|
+
if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
|
|
23
|
+
attribute.size = 3;
|
|
24
|
+
}
|
|
25
|
+
// Move indices to separate field
|
|
26
|
+
if (attributeName === 'indices') {
|
|
27
|
+
assert(!this.indices);
|
|
28
|
+
// @ts-expect-error
|
|
29
|
+
this.indices = attribute;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.attributes[attributeName] = attribute;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// @ts-expect-error
|
|
36
|
+
if (this.indices && this.indices.isIndexed !== undefined) {
|
|
37
|
+
this.indices = Object.assign({}, this.indices);
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
delete this.indices.isIndexed;
|
|
40
|
+
}
|
|
41
|
+
this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
|
|
36
42
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (const [attributeName, attributeValue] of Object.entries(attributes)) {
|
|
41
|
-
const attribute = ArrayBuffer.isView(attributeValue) ? {
|
|
42
|
-
value: attributeValue
|
|
43
|
-
} : attributeValue;
|
|
44
|
-
assert(ArrayBuffer.isView(attribute.value), "".concat(this._print(attributeName), ": must be typed array or object with value as typed array"));
|
|
45
|
-
|
|
46
|
-
if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
|
|
47
|
-
attribute.size = 3;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (attributeName === 'indices') {
|
|
51
|
-
assert(!this.indices);
|
|
52
|
-
this.indices = attribute;
|
|
53
|
-
} else {
|
|
54
|
-
this.attributes[attributeName] = attribute;
|
|
55
|
-
}
|
|
43
|
+
/** @deprecated Use string topology constants instead */
|
|
44
|
+
get mode() {
|
|
45
|
+
return this.drawMode;
|
|
56
46
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.indices = Object.assign({}, this.indices);
|
|
60
|
-
delete this.indices.isIndexed;
|
|
47
|
+
getVertexCount() {
|
|
48
|
+
return this.vertexCount;
|
|
61
49
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
get mode() {
|
|
67
|
-
return this.drawMode;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getVertexCount() {
|
|
71
|
-
return this.vertexCount;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getAttributes() {
|
|
75
|
-
return this.indices ? {
|
|
76
|
-
indices: this.indices,
|
|
77
|
-
...this.attributes
|
|
78
|
-
} : this.attributes;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_print(attributeName) {
|
|
82
|
-
return "Geometry ".concat(this.id, " attribute ").concat(attributeName);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_setAttributes(attributes, indices) {
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
_calculateVertexCount(attributes, indices) {
|
|
90
|
-
if (indices) {
|
|
91
|
-
return indices.value.length;
|
|
50
|
+
// Return an object with all attributes plus indices added as a field.
|
|
51
|
+
getAttributes() {
|
|
52
|
+
// @ts-expect-error Geometry types are a mess
|
|
53
|
+
return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
|
|
92
54
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
55
|
+
// PRIVATE
|
|
56
|
+
_print(attributeName) {
|
|
57
|
+
return `Geometry ${this.id} attribute ${attributeName}`;
|
|
58
|
+
}
|
|
59
|
+
// GeometryAttribute
|
|
60
|
+
// value: typed array
|
|
61
|
+
// type: indices, vertices, uvs
|
|
62
|
+
// size: elements per vertex
|
|
63
|
+
// target: WebGL buffer type (string or constant)
|
|
64
|
+
_setAttributes(attributes, indices) {
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
_calculateVertexCount(attributes, indices) {
|
|
68
|
+
if (indices) {
|
|
69
|
+
return indices.value.length;
|
|
70
|
+
}
|
|
71
|
+
let vertexCount = Infinity;
|
|
72
|
+
for (const attributeName in attributes) {
|
|
73
|
+
const attribute = attributes[attributeName];
|
|
74
|
+
const { value, size, constant } = attribute;
|
|
75
|
+
if (!constant && value && size >= 1) {
|
|
76
|
+
vertexCount = Math.min(vertexCount, value.length / size);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
assert(Number.isFinite(vertexCount));
|
|
80
|
+
return vertexCount;
|
|
107
81
|
}
|
|
108
|
-
|
|
109
|
-
assert(Number.isFinite(vertexCount));
|
|
110
|
-
return vertexCount;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
82
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
83
|
+
/** @deprecated */
|
|
84
|
+
Geometry.DRAW_MODE = {
|
|
85
|
+
POINTS: GL.POINTS,
|
|
86
|
+
LINES: GL.LINES,
|
|
87
|
+
LINE_LOOP: GL.LINE_LOOP,
|
|
88
|
+
LINE_STRIP: GL.LINE_STRIP,
|
|
89
|
+
TRIANGLES: GL.TRIANGLES,
|
|
90
|
+
TRIANGLE_STRIP: GL.TRIANGLE_STRIP,
|
|
91
|
+
TRIANGLE_FAN: GL.TRIANGLE_FAN // draw a connected group of triangles.
|
|
92
|
+
};
|
|
93
|
+
export default Geometry;
|
|
125
94
|
function convertToTopology(drawMode) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return 'triangle-list';
|
|
138
|
-
|
|
139
|
-
case GL.TRIANGLE_STRIP:
|
|
140
|
-
return 'triangle-strip';
|
|
141
|
-
|
|
142
|
-
case GL.TRIANGLE_FAN:
|
|
143
|
-
return 'triangle-fan';
|
|
144
|
-
|
|
145
|
-
case GL.LINE_LOOP:
|
|
146
|
-
return 'line-loop';
|
|
147
|
-
|
|
148
|
-
default:
|
|
149
|
-
throw new Error(String(drawMode));
|
|
150
|
-
}
|
|
95
|
+
switch (drawMode) {
|
|
96
|
+
case GL.POINTS: return 'point-list'; // draw single points.
|
|
97
|
+
case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.
|
|
98
|
+
case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last
|
|
99
|
+
case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.
|
|
100
|
+
case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.
|
|
101
|
+
case GL.TRIANGLE_FAN: return 'triangle-fan'; // draw a connected group of triangles.
|
|
102
|
+
case GL.LINE_LOOP: return 'line-loop'; // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
103
|
+
default:
|
|
104
|
+
throw new Error(String(drawMode));
|
|
105
|
+
}
|
|
151
106
|
}
|
|
152
|
-
//# sourceMappingURL=geometry.js.map
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
import type {GeometryTable} from './geometry-table.js';
|
|
1
4
|
|
|
2
|
-
|
|
5
|
+
export function unpackIndexedGeometry(geometry: GeometryTable): GeometryTable {
|
|
6
|
+
const {indices, attributes} = geometry;
|
|
7
|
+
if (!indices) {
|
|
8
|
+
return geometry;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const vertexCount = indices.length;
|
|
12
|
+
const unpackedAttributes = {};
|
|
13
|
+
|
|
14
|
+
for (const [name, values] of Object.entries(attributes)) {
|
|
15
|
+
const size = {POSITION: 3, NORMAL: 3, TEX_COORD0: 2}[name];
|
|
16
|
+
const unpackedValues = new values.constructor(length * size);
|
|
17
|
+
for (let x = 0; x < vertexCount; ++x) {
|
|
18
|
+
const index = indices[x];
|
|
19
|
+
for (let i = 0; i < size; i++) {
|
|
20
|
+
unpackedValues[x * size + i] = values[index * size + i];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
unpackedAttributes[name] = unpackedValues;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
length,
|
|
28
|
+
attributes: unpackedAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
*/
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
|
|
1
|
+
// luma.gl Engine API
|
|
2
|
+
// Animation
|
|
3
|
+
export { Timeline } from './animation/timeline.js';
|
|
4
|
+
export { KeyFrames } from './animation/key-frames.js';
|
|
5
|
+
export { AnimationLoopTemplate } from './animation-loop/render-loop.js';
|
|
6
|
+
export { AnimationLoop } from './animation-loop/animation-loop.js';
|
|
7
|
+
export { makeAnimationLoop } from './animation-loop/make-animation-loop.js';
|
|
8
|
+
export { Model } from './lib/model.js';
|
|
9
|
+
export { PipelineFactory } from './lib/pipeline-factory.js';
|
|
10
|
+
// Utils
|
|
11
|
+
// export {default as ClipSpace} from './lib/clip-space.js';
|
|
12
|
+
// Geometries
|
|
13
|
+
export { default as Geometry } from './geometry/geometry.js';
|
|
14
|
+
export { ConeGeometry } from './geometries/cone-geometry.js';
|
|
15
|
+
export { CubeGeometry } from './geometries/cube-geometry.js';
|
|
16
|
+
export { CylinderGeometry } from './geometries/cylinder-geometry.js';
|
|
17
|
+
export { IcoSphereGeometry } from './geometries/ico-sphere-geometry.js';
|
|
18
|
+
export { PlaneGeometry } from './geometries/plane-geometry.js';
|
|
19
|
+
export { SphereGeometry } from './geometries/sphere-geometry.js';
|
|
20
|
+
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry.js';
|
package/dist/lib/clip-space.js
CHANGED
|
@@ -1,2 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ClipSpace
|
|
3
|
+
/*
|
|
4
|
+
import GL from '@luma.gl/constants';
|
|
5
|
+
import Model, {ModelProps} from './model.js';
|
|
6
|
+
import Geometry from '../geometry/geometry.js';
|
|
1
7
|
|
|
2
|
-
|
|
8
|
+
const CLIPSPACE_VERTEX_SHADER = glsl`\
|
|
9
|
+
attribute vec2 aClipSpacePosition;
|
|
10
|
+
attribute vec2 aTexCoord;
|
|
11
|
+
attribute vec2 aCoordinate;
|
|
12
|
+
|
|
13
|
+
varying vec2 position;
|
|
14
|
+
varying vec2 coordinate;
|
|
15
|
+
varying vec2 uv;
|
|
16
|
+
|
|
17
|
+
void main(void) {
|
|
18
|
+
gl_Position = vec4(aClipSpacePosition, 0., 1.);
|
|
19
|
+
position = aClipSpacePosition;
|
|
20
|
+
coordinate = aCoordinate;
|
|
21
|
+
uv = aTexCoord;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
/* eslint-disable indent, no-multi-spaces *
|
|
26
|
+
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export default class ClipSpace extends Model {
|
|
30
|
+
constructor(gl: WebGLRenderingContext, opts?: ModelProps) {
|
|
31
|
+
const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));
|
|
32
|
+
|
|
33
|
+
super(
|
|
34
|
+
gl,
|
|
35
|
+
Object.assign({}, opts, {
|
|
36
|
+
vs: CLIPSPACE_VERTEX_SHADER,
|
|
37
|
+
geometry: new Geometry({
|
|
38
|
+
drawMode: GL.TRIANGLE_STRIP,
|
|
39
|
+
vertexCount: 4,
|
|
40
|
+
attributes: {
|
|
41
|
+
aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},
|
|
42
|
+
aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},
|
|
43
|
+
aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
this.setVertexCount(4);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
*/
|
package/dist/lib/model-utils.js
CHANGED
|
@@ -1,45 +1,113 @@
|
|
|
1
1
|
import { Buffer, assert } from '@luma.gl/api';
|
|
2
|
+
// Support for mapping new geometries with glTF attribute names to "classic" luma.gl shader names
|
|
2
3
|
const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
POSITION: 'positions',
|
|
5
|
+
NORMAL: 'normals',
|
|
6
|
+
COLOR_0: 'colors',
|
|
7
|
+
TEXCOORD_0: 'texCoords',
|
|
8
|
+
TEXCOORD_1: 'texCoords1',
|
|
9
|
+
TEXCOORD_2: 'texCoords2'
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const data = geometry.indices.value || geometry.indices;
|
|
16
|
-
assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
|
|
17
|
-
return device.createBuffer({
|
|
18
|
-
usage: Buffer.INDEX,
|
|
19
|
-
data
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export function getAttributeBuffersFromGeometry(device, geometry) {
|
|
23
|
-
const buffers = {};
|
|
11
|
+
/*
|
|
12
|
+
export function getAttributeLayoutsFromGeometry(geometry: Geometry) {
|
|
13
|
+
const layouts: Record<string, {}> = {};
|
|
14
|
+
let indices = geometry.indices;
|
|
24
15
|
|
|
25
16
|
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
26
17
|
const remappedName = mapAttributeName(name);
|
|
27
18
|
|
|
28
|
-
if (attribute
|
|
19
|
+
if (attribute.constant) {
|
|
29
20
|
throw new Error('constant attributes not supported');
|
|
30
21
|
} else {
|
|
31
|
-
const typedArray = attribute
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const typedArray = attribute.value;
|
|
23
|
+
// Create accessor by copying the attribute and removing `value``
|
|
24
|
+
const accessor = {...attribute};
|
|
25
|
+
delete accessor.value;
|
|
26
|
+
buffers[remappedName] = [device.createBuffer(typedArray), accessor];
|
|
27
|
+
|
|
28
|
+
inferAttributeAccessor(name, accessor);
|
|
36
29
|
}
|
|
37
30
|
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class Table {
|
|
34
|
+
length: number;
|
|
35
|
+
// columns: Record<string, TypedArray> = {};
|
|
36
|
+
}
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
export class GPUTable {
|
|
39
|
+
length: number;
|
|
40
|
+
columns: Record<string, Buffer> = {};
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
export function convertTableToGPUTable(table: Table) {
|
|
44
|
+
// for (const ) {}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function renameTableColumns(table: Table, map: (name: string) => string) {
|
|
48
|
+
const newColumns = table.columns.reduce()
|
|
49
|
+
table.clone();
|
|
50
|
+
}
|
|
51
|
+
*/
|
|
52
|
+
export function getIndexBufferFromGeometry(device, geometry) {
|
|
53
|
+
if (!geometry.indices) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
// @ts-expect-error
|
|
57
|
+
const data = geometry.indices.value || geometry.indices;
|
|
58
|
+
assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
|
|
59
|
+
return device.createBuffer({ usage: Buffer.INDEX, data });
|
|
60
|
+
}
|
|
61
|
+
export function getAttributeBuffersFromGeometry(device, geometry) {
|
|
62
|
+
const buffers = {};
|
|
63
|
+
for (const [name, attribute] of Object.entries(geometry.attributes)) {
|
|
64
|
+
const remappedName = mapAttributeName(name);
|
|
65
|
+
if (attribute?.constant) {
|
|
66
|
+
throw new Error('constant attributes not supported');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const typedArray = attribute?.value;
|
|
70
|
+
buffers[remappedName] = device.createBuffer({ data: typedArray, id: `${remappedName}-buffer` });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return buffers;
|
|
74
|
+
}
|
|
42
75
|
function mapAttributeName(name) {
|
|
43
|
-
|
|
76
|
+
// @ts-ignore-error
|
|
77
|
+
return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
|
|
78
|
+
}
|
|
79
|
+
/*
|
|
80
|
+
// Check for well known attribute names
|
|
81
|
+
// eslint-disable-next-line complexity
|
|
82
|
+
export function inferAttributeAccessor(attributeName, attribute) {
|
|
83
|
+
let category;
|
|
84
|
+
switch (attributeName) {
|
|
85
|
+
case 'texCoords':
|
|
86
|
+
case 'texCoord1':
|
|
87
|
+
case 'texCoord2':
|
|
88
|
+
case 'texCoord3':
|
|
89
|
+
category = 'uvs';
|
|
90
|
+
break;
|
|
91
|
+
case 'vertices':
|
|
92
|
+
case 'positions':
|
|
93
|
+
case 'normals':
|
|
94
|
+
case 'pickingColors':
|
|
95
|
+
category = 'vectors';
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Check for categorys
|
|
101
|
+
switch (category) {
|
|
102
|
+
case 'vectors':
|
|
103
|
+
attribute.size = attribute.size || 3;
|
|
104
|
+
break;
|
|
105
|
+
case 'uvs':
|
|
106
|
+
attribute.size = attribute.size || 2;
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);
|
|
44
112
|
}
|
|
45
|
-
|
|
113
|
+
*/
|
package/dist/lib/model.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Device, Buffer, RenderPipelineProps, RenderPass, Binding, Primitiv
|
|
|
2
2
|
import { RenderPipeline } from '@luma.gl/api';
|
|
3
3
|
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
4
4
|
import type Geometry from '../geometry/geometry';
|
|
5
|
-
export
|
|
5
|
+
export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
6
6
|
vs?: {
|
|
7
7
|
glsl?: string;
|
|
8
8
|
wgsl?: string;
|
package/dist/lib/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/lib/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,U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