@luma.gl/engine 9.0.0-alpha.8 → 9.0.0-alpha.9
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TypedArray } from '@luma.gl/api';
|
|
1
|
+
import type { PrimitiveTopology, TypedArray } from '@luma.gl/api';
|
|
2
2
|
import GL from '@luma.gl/constants';
|
|
3
3
|
/**
|
|
4
4
|
* Rendering primitives - "topology" specifies how to extract primitives from vertices.
|
|
@@ -40,7 +40,7 @@ export default class Geometry {
|
|
|
40
40
|
readonly id: string;
|
|
41
41
|
userData: Record<string, unknown>;
|
|
42
42
|
/** Determines how vertices are read from the 'vertex' attributes */
|
|
43
|
-
topology?:
|
|
43
|
+
topology?: PrimitiveTopology;
|
|
44
44
|
/** @deprecated */
|
|
45
45
|
readonly drawMode: GLTopology;
|
|
46
46
|
readonly vertexCount: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;
|
|
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,oBAAY,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,CAC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AAc,IAAI,MAAM;IAWxB,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IASrC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,KAAA,GAAG,IAAI;IAK5E,qBAAqB,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA,GAAG,MAAM;CAgBnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometry/geometry.ts"],"names":["uid","assert","GL","Geometry","constructor","props","TRIANGLES","id","drawMode","attributes","indices","vertexCount","topology","convertToTopology","ArrayBuffer","isView","value","size","attributeName","attributeValue","Object","entries","attribute","_print","isIndexed","undefined","assign","_calculateVertexCount","mode","getVertexCount","_setAttributes","length","Infinity","constant","Math","min","Number","isFinite","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLE_STRIP","TRIANGLE_FAN","Error","String"],"mappings":";AAEA,SAAQA,GAAR,EAAaC,MAAb,QAA0B,cAA1B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAyCA,eAAe,MAAMC,QAAN,CAAe;AA6B5BC,EAAAA,WAAW,CAACC,KAAoB,GAAG,EAAxB,EAA4B;AAAA;;AAAA,sCAhBH,EAgBG;;AAAA;;AAAA,sCAXPH,EAAE,CAACI,SAWI;;AAAA;;AAAA;;AAAA;;AACrC,UAAM;AACJC,MAAAA,EAAE,GAAGP,GAAG,CAAC,UAAD,CADJ;AAEJQ,MAAAA,QAAQ,GAAGN,EAAE,CAACI,SAFV;AAGJG,MAAAA,UAAU,GAAG,EAHT;AAIJC,MAAAA,OAAO,GAAG,IAJN;AAKJC,MAAAA,WAAW,GAAG;AALV,QAMFN,KANJ;AAQA,SAAKE,EAAL,GAAUA,EAAV;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,SAAKI,QAAL,GAAgBP,KAAK,CAACO,QAAN,IAAkBC,iBAAiB,CAACL,QAAD,CAAnD;;AAEA,QAAIE,OAAJ,EA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,cAAc,EAAExC,EAAE,CAACwC,cANF;AAOjBC,EAAAA,YAAY,EAAEzC,EAAE,CAACyC;AAPA,C;;AAkIrB,SAAS9B,iBAAT,CAA2BL,QAA3B,EAAiI;AAC/H,UAAQA,QAAR;AACE,SAAKN,EAAE,CAACoC,MAAR;AAAgB,aAAO,YAAP;;AAChB,SAAKpC,EAAE,CAACqC,KAAR;AAAe,aAAO,WAAP;;AACf,SAAKrC,EAAE,CAACuC,UAAR;AAAoB,aAAO,YAAP;;AACpB,SAAKvC,EAAE,CAACI,SAAR;AAAmB,aAAO,eAAP;;AACnB,SAAKJ,EAAE,CAACwC,cAAR;AAAwB,aAAO,gBAAP;;AAExB,SAAKxC,EAAE,CAACyC,YAAR;AACA,SAAKzC,EAAE,CAACsC,SAAR;AACA;AACE,YAAM,IAAII,KAAJ,CAAUC,MAAM,CAACrC,QAAD,CAAhB,CAAN;AAVJ;AAYD","sourcesContent":["// luma.gl, MIT license\nimport type {TypedArray} from '@luma.gl/api';\nimport {uid, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n/**\n * Rendering primitives - \"topology\" specifies how to extract primitives from vertices.\n * @deprecated - use string constants instead\n */\nexport type GLTopology =\n GL.POINTS | // draw single points.\n GL.LINES | // draw lines. Each vertex connects to the one after it.\n GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.\n GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last\n GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.\n GL.TRIANGLE_STRIP | // draw a connected group of triangles.\n GL.TRIANGLE_FAN // draw a connected group of triangles.\n ;\n\nexport type GeometryAttribute = {\n size?: number;\n value: TypedArray;\n [key: string]: any\n}\n\nexport type GeometryProps = {\n id?: string;\n attributes?: Record<string, GeometryAttribute | TypedArray>,\n indices?: GeometryAttribute | TypedArray;\n vertexCount?: number;\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';\n /** @deprecated */\n drawMode?: GLTopology;\n};\n\ntype GeometryAttributes = {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n indices?: {size?: number, value: Uint32Array | Uint16Array};\n};\n\nexport default class Geometry {\n /** @deprecated */\n static DRAW_MODE = {\n POINTS: GL.POINTS, // draw single points.\n LINES: GL.LINES, // draw lines. Each vertex connects to the one after it.\n LINE_LOOP: GL.LINE_LOOP, // draw lines. Each set of two vertices is treated as a separate line segment.\n LINE_STRIP: GL.LINE_STRIP, // draw a connected group of line segments from the first vertex to the last\n TRIANGLES: GL.TRIANGLES, // draw triangles. Each set of three vertices creates a separate triangle.\n TRIANGLE_STRIP: GL.TRIANGLE_STRIP, // draw a connected group of triangles.\n TRIANGLE_FAN: GL.TRIANGLE_FAN // draw a connected group of triangles.\n };\n\n readonly id: string;\n userData: Record<string, unknown> = {};\n\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';\n /** @deprecated */\n readonly drawMode: GLTopology = GL.TRIANGLES;\n\n readonly vertexCount: number;\n readonly attributes: {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n };\n readonly indices?: Uint16Array | Uint32Array;\n\n constructor(props: GeometryProps = {}) {\n const {\n id = uid('geometry'),\n drawMode = GL.TRIANGLES,\n attributes = {},\n indices = null,\n vertexCount = null\n } = props;\n\n this.id = id;\n this.drawMode = drawMode;\n this.topology = props.topology || convertToTopology(drawMode);\n\n if (indices) {\n // @ts-expect-error\n this.indices = ArrayBuffer.isView(indices) ? {value: indices, size: 1} : indices;\n }\n\n // @ts-expect-error\n this.attributes = {};\n\n for (const [attributeName, attributeValue] of Object.entries(attributes)) {\n\n // Wrap \"unwrapped\" arrays and try to autodetect their type\n const attribute: GeometryAttribute = ArrayBuffer.isView(attributeValue) ? {value: attributeValue} : attributeValue;\n\n assert(\n ArrayBuffer.isView(attribute.value),\n `${this._print(attributeName)}: must be typed array or object with value as typed array`\n );\n\n if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {\n attribute.size = 3;\n }\n\n // Move indices to separate field\n if (attributeName === 'indices') {\n assert(!this.indices);\n // @ts-expect-error\n this.indices = attribute;\n } else {\n this.attributes[attributeName] = attribute;\n }\n }\n\n // @ts-expect-error\n if (this.indices && this.indices.isIndexed !== undefined) {\n this.indices = Object.assign({}, this.indices);\n // @ts-expect-error\n delete this.indices.isIndexed;\n }\n\n this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);\n }\n\n /** @deprecated Use string topology constants instead */\n get mode() {\n return this.drawMode;\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n // Return an object with all attributes plus indices added as a field.\n // getAttributes(): GeometryAttributes {\n // return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;\n // }\n\n // PRIVATE\n\n _print(attributeName: string): string {\n return `Geometry ${this.id} attribute ${attributeName}`;\n }\n\n // GeometryAttribute\n // value: typed array\n // type: indices, vertices, uvs\n // size: elements per vertex\n // target: WebGL buffer type (string or constant)\n _setAttributes(attributes: Record<string, GeometryAttribute>, indices): this {\n\n return this;\n }\n\n _calculateVertexCount(attributes, indices): number {\n if (indices) {\n return indices.value.length;\n }\n let vertexCount = Infinity;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const {value, size, constant} = attribute;\n if (!constant && value && size >= 1) {\n vertexCount = Math.min(vertexCount, value.length / size);\n }\n }\n\n assert(Number.isFinite(vertexCount));\n return vertexCount;\n }\n}\n\nfunction convertToTopology(drawMode: GLTopology): 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip' {\n switch (drawMode) {\n case GL.POINTS: return 'point-list'; // draw single points.\n case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.\n case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last\n case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.\n case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.\n\n case GL.TRIANGLE_FAN: // draw a connected group of triangles.\n case GL.LINE_LOOP: // draw lines. Each set of two vertices is treated as a separate line segment.\n default:\n throw new Error(String(drawMode));\n }\n}\n"],"file":"geometry.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/geometry/geometry.ts"],"names":["uid","assert","GL","Geometry","constructor","props","TRIANGLES","id","drawMode","attributes","indices","vertexCount","topology","convertToTopology","ArrayBuffer","isView","value","size","attributeName","attributeValue","Object","entries","attribute","_print","isIndexed","undefined","assign","_calculateVertexCount","mode","getVertexCount","_setAttributes","length","Infinity","constant","Math","min","Number","isFinite","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLE_STRIP","TRIANGLE_FAN","Error","String"],"mappings":";AAEA,SAAQA,GAAR,EAAaC,MAAb,QAA0B,cAA1B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAyCA,eAAe,MAAMC,QAAN,CAAe;AA6B5BC,EAAAA,WAAW,CAACC,KAAoB,GAAG,EAAxB,EAA4B;AAAA;;AAAA,sCAhBH,EAgBG;;AAAA;;AAAA,sCAXPH,EAAE,CAACI,SAWI;;AAAA;;AAAA;;AAAA;;AACrC,UAAM;AACJC,MAAAA,EAAE,GAAGP,GAAG,CAAC,UAAD,CADJ;AAEJQ,MAAAA,QAAQ,GAAGN,EAAE,CAACI,SAFV;AAGJG,MAAAA,UAAU,GAAG,EAHT;AAIJC,MAAAA,OAAO,GAAG,IAJN;AAKJC,MAAAA,WAAW,GAAG;AALV,QAMFN,KANJ;AAQA,SAAKE,EAAL,GAAUA,EAAV;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,SAAKI,QAAL,GAAgBP,KAAK,CAACO,QAAN,IAAkBC,iBAAiB,CAACL,QAAD,CAAnD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AACI,SALG;AAMjBoC,EAAAA,cAAc,EAAExC,EAAE,CAACwC,cANF;AAOjBC,EAAAA,YAAY,EAAEzC,EAAE,CAACyC;AAPA,C;;AAkIrB,SAAS9B,iBAAT,CAA2BL,QAA3B,EAAoE;AAClE,UAAQA,QAAR;AACE,SAAKN,EAAE,CAACoC,MAAR;AAAgB,aAAO,YAAP;;AAChB,SAAKpC,EAAE,CAACqC,KAAR;AAAe,aAAO,WAAP;;AACf,SAAKrC,EAAE,CAACuC,UAAR;AAAoB,aAAO,YAAP;;AACpB,SAAKvC,EAAE,CAACI,SAAR;AAAmB,aAAO,eAAP;;AACnB,SAAKJ,EAAE,CAACwC,cAAR;AAAwB,aAAO,gBAAP;;AAExB,SAAKxC,EAAE,CAACyC,YAAR;AAAsB,aAAO,cAAP;;AACtB,SAAKzC,EAAE,CAACsC,SAAR;AAAmB,aAAO,WAAP;;AACnB;AACE,YAAM,IAAII,KAAJ,CAAUC,MAAM,CAACrC,QAAD,CAAhB,CAAN;AAVJ;AAYD","sourcesContent":["// luma.gl, MIT license\nimport type {PrimitiveTopology, TypedArray} from '@luma.gl/api';\nimport {uid, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n/**\n * Rendering primitives - \"topology\" specifies how to extract primitives from vertices.\n * @deprecated - use string constants instead\n */\nexport type GLTopology =\n GL.POINTS | // draw single points.\n GL.LINES | // draw lines. Each vertex connects to the one after it.\n GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.\n GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last\n GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.\n GL.TRIANGLE_STRIP | // draw a connected group of triangles.\n GL.TRIANGLE_FAN // draw a connected group of triangles.\n ;\n\nexport type GeometryAttribute = {\n size?: number;\n value: TypedArray;\n [key: string]: any\n}\n\nexport type GeometryProps = {\n id?: string;\n attributes?: Record<string, GeometryAttribute | TypedArray>,\n indices?: GeometryAttribute | TypedArray;\n vertexCount?: number;\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';\n /** @deprecated */\n drawMode?: GLTopology;\n};\n\ntype GeometryAttributes = {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n indices?: {size?: number, value: Uint32Array | Uint16Array};\n};\n\nexport default class Geometry {\n /** @deprecated */\n static DRAW_MODE = {\n POINTS: GL.POINTS, // draw single points.\n LINES: GL.LINES, // draw lines. Each vertex connects to the one after it.\n LINE_LOOP: GL.LINE_LOOP, // draw lines. Each set of two vertices is treated as a separate line segment.\n LINE_STRIP: GL.LINE_STRIP, // draw a connected group of line segments from the first vertex to the last\n TRIANGLES: GL.TRIANGLES, // draw triangles. Each set of three vertices creates a separate triangle.\n TRIANGLE_STRIP: GL.TRIANGLE_STRIP, // draw a connected group of triangles.\n TRIANGLE_FAN: GL.TRIANGLE_FAN // draw a connected group of triangles.\n };\n\n readonly id: string;\n userData: Record<string, unknown> = {};\n\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: PrimitiveTopology;\n /** @deprecated */\n readonly drawMode: GLTopology = GL.TRIANGLES;\n\n readonly vertexCount: number;\n readonly attributes: {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n };\n readonly indices?: Uint16Array | Uint32Array;\n\n constructor(props: GeometryProps = {}) {\n const {\n id = uid('geometry'),\n drawMode = GL.TRIANGLES,\n attributes = {},\n indices = null,\n vertexCount = null\n } = props;\n\n this.id = id;\n this.drawMode = drawMode;\n this.topology = props.topology || convertToTopology(drawMode);\n\n if (indices) {\n // @ts-expect-error\n this.indices = ArrayBuffer.isView(indices) ? {value: indices, size: 1} : indices;\n }\n\n // @ts-expect-error\n this.attributes = {};\n\n for (const [attributeName, attributeValue] of Object.entries(attributes)) {\n\n // Wrap \"unwrapped\" arrays and try to autodetect their type\n const attribute: GeometryAttribute = ArrayBuffer.isView(attributeValue) ? {value: attributeValue} : attributeValue;\n\n assert(\n ArrayBuffer.isView(attribute.value),\n `${this._print(attributeName)}: must be typed array or object with value as typed array`\n );\n\n if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {\n attribute.size = 3;\n }\n\n // Move indices to separate field\n if (attributeName === 'indices') {\n assert(!this.indices);\n // @ts-expect-error\n this.indices = attribute;\n } else {\n this.attributes[attributeName] = attribute;\n }\n }\n\n // @ts-expect-error\n if (this.indices && this.indices.isIndexed !== undefined) {\n this.indices = Object.assign({}, this.indices);\n // @ts-expect-error\n delete this.indices.isIndexed;\n }\n\n this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);\n }\n\n /** @deprecated Use string topology constants instead */\n get mode() {\n return this.drawMode;\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n // Return an object with all attributes plus indices added as a field.\n // getAttributes(): GeometryAttributes {\n // return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;\n // }\n\n // PRIVATE\n\n _print(attributeName: string): string {\n return `Geometry ${this.id} attribute ${attributeName}`;\n }\n\n // GeometryAttribute\n // value: typed array\n // type: indices, vertices, uvs\n // size: elements per vertex\n // target: WebGL buffer type (string or constant)\n _setAttributes(attributes: Record<string, GeometryAttribute>, indices): this {\n\n return this;\n }\n\n _calculateVertexCount(attributes, indices): number {\n if (indices) {\n return indices.value.length;\n }\n let vertexCount = Infinity;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const {value, size, constant} = attribute;\n if (!constant && value && size >= 1) {\n vertexCount = Math.min(vertexCount, value.length / size);\n }\n }\n\n assert(Number.isFinite(vertexCount));\n return vertexCount;\n }\n}\n\nfunction convertToTopology(drawMode: GLTopology): PrimitiveTopology {\n switch (drawMode) {\n case GL.POINTS: return 'point-list'; // draw single points.\n case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.\n case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last\n case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.\n case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.\n\n case GL.TRIANGLE_FAN: return 'triangle-fan'; // draw a connected group of triangles.\n case GL.LINE_LOOP: return 'line-loop'; // draw lines. Each set of two vertices is treated as a separate line segment.\n default:\n throw new Error(String(drawMode));\n }\n}\n"],"file":"geometry.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.9",
|
|
4
4
|
"description": "WebGL2 Components for High Performance Rendering and Computation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
35
|
-
"@luma.gl/shadertools": "9.0.0-alpha.
|
|
36
|
-
"@luma.gl/webgl": "9.0.0-alpha.
|
|
34
|
+
"@luma.gl/constants": "9.0.0-alpha.9",
|
|
35
|
+
"@luma.gl/shadertools": "9.0.0-alpha.9",
|
|
36
|
+
"@luma.gl/webgl": "9.0.0-alpha.9",
|
|
37
37
|
"@math.gl/core": "^3.5.0",
|
|
38
38
|
"@probe.gl/log": "^3.5.0",
|
|
39
39
|
"@probe.gl/stats": "^3.5.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "b84aae16edcdee2be84d2861c81cc6584e336b28"
|
|
42
42
|
}
|
package/src/geometry/geometry.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
|
-
import type {TypedArray} from '@luma.gl/api';
|
|
2
|
+
import type {PrimitiveTopology, TypedArray} from '@luma.gl/api';
|
|
3
3
|
import {uid, assert} from '@luma.gl/api';
|
|
4
4
|
import GL from '@luma.gl/constants';
|
|
5
5
|
|
|
@@ -58,7 +58,7 @@ export default class Geometry {
|
|
|
58
58
|
userData: Record<string, unknown> = {};
|
|
59
59
|
|
|
60
60
|
/** Determines how vertices are read from the 'vertex' attributes */
|
|
61
|
-
topology?:
|
|
61
|
+
topology?: PrimitiveTopology;
|
|
62
62
|
/** @deprecated */
|
|
63
63
|
readonly drawMode: GLTopology = GL.TRIANGLES;
|
|
64
64
|
|
|
@@ -174,7 +174,7 @@ export default class Geometry {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function convertToTopology(drawMode: GLTopology):
|
|
177
|
+
function convertToTopology(drawMode: GLTopology): PrimitiveTopology {
|
|
178
178
|
switch (drawMode) {
|
|
179
179
|
case GL.POINTS: return 'point-list'; // draw single points.
|
|
180
180
|
case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.
|
|
@@ -182,8 +182,8 @@ function convertToTopology(drawMode: GLTopology): 'point-list' | 'line-list' | '
|
|
|
182
182
|
case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.
|
|
183
183
|
case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.
|
|
184
184
|
|
|
185
|
-
case GL.TRIANGLE_FAN: // draw a connected group of triangles.
|
|
186
|
-
case GL.LINE_LOOP:
|
|
185
|
+
case GL.TRIANGLE_FAN: return 'triangle-fan'; // draw a connected group of triangles.
|
|
186
|
+
case GL.LINE_LOOP: return 'line-loop'; // draw lines. Each set of two vertices is treated as a separate line segment.
|
|
187
187
|
default:
|
|
188
188
|
throw new Error(String(drawMode));
|
|
189
189
|
}
|