@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.2
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 +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +8 -8
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- 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 +7 -0
- package/dist/animation-loop/animation-loop-template.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +77 -192
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +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 +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -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 +46 -0
- package/dist/debug/copy-texture-to-image.js.map +1 -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 +43 -0
- package/dist/debug/debug-framebuffer.js.map +1 -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 +28 -0
- package/dist/debug/debug-shader-layout.js.map +1 -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 +41 -0
- package/dist/debug/pixel-data-utils.js.map +1 -0
- package/dist/dist.dev.js +10073 -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 +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- 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 +16 -10
- package/dist/geometries/cube-geometry.js.map +1 -1
- 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 +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- 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 +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- 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 +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- 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 +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- 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 +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- 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.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +43 -43
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +20 -86
- package/dist/geometry/geometry.js.map +1 -1
- 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 +110 -0
- package/dist/geometry/gpu-geometry.js.map +1 -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 +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +3120 -0
- package/dist/index.d.ts +24 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- 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 +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -46
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +36 -179
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +206 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +440 -0
- package/dist/model/model.js.map +1 -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 +94 -0
- package/dist/scenegraph/group-node.js.map +1 -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 +28 -0
- package/dist/scenegraph/model-node.js.map +1 -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 +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shader-inputs.d.ts +63 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +66 -0
- package/dist/shader-inputs.js.map +1 -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 +62 -0
- package/dist/transform/buffer-transform.js.map +1 -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 +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +293 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +15 -14
- package/src/animation-loop/animation-loop-template.ts +23 -0
- package/src/{lib → animation-loop}/animation-loop.ts +99 -88
- package/src/{lib → animation-loop}/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/debug/copy-texture-to-image.ts +72 -0
- package/src/debug/debug-framebuffer.ts +57 -0
- package/src/debug/debug-shader-layout.ts +38 -0
- package/src/debug/pixel-data-utils.ts +57 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +47 -45
- 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 +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +19 -3
- package/src/geometry/geometry.ts +65 -110
- package/src/geometry/gpu-geometry.ts +125 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +34 -10
- package/src/lib/clip-space.ts +22 -21
- package/src/lib/pipeline-factory.ts +48 -179
- package/src/model/model.ts +733 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +150 -0
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- 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/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/lib/animation-loop.d.ts.map +0 -1
- 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.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/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
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/sphere-geometry.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/sphere-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,GAAG,CAAA;CACjB,CAAC;AAKF,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,KAAK,GAAE,mBAAwB;CAW5C"}
|
|
@@ -1,7 +1,8 @@
|
|
|
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
|
export class SphereGeometry extends Geometry {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor() {
|
|
5
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5
6
|
const {
|
|
6
7
|
id = uid('sphere-geometry')
|
|
7
8
|
} = props;
|
|
@@ -9,17 +10,18 @@ export class SphereGeometry extends Geometry {
|
|
|
9
10
|
indices,
|
|
10
11
|
attributes
|
|
11
12
|
} = tesselateSphere(props);
|
|
12
|
-
super({
|
|
13
|
+
super({
|
|
14
|
+
...props,
|
|
13
15
|
id,
|
|
16
|
+
topology: 'triangle-list',
|
|
14
17
|
indices,
|
|
15
|
-
attributes: {
|
|
18
|
+
attributes: {
|
|
19
|
+
...attributes,
|
|
16
20
|
...props.attributes
|
|
17
21
|
}
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
|
-
|
|
21
24
|
}
|
|
22
|
-
|
|
23
25
|
function tesselateSphere(props) {
|
|
24
26
|
const {
|
|
25
27
|
nlat = 10,
|
|
@@ -32,15 +34,12 @@ function tesselateSphere(props) {
|
|
|
32
34
|
const endLong = 2 * Math.PI;
|
|
33
35
|
const longRange = endLong - startLong;
|
|
34
36
|
const numVertices = (nlat + 1) * (nlong + 1);
|
|
35
|
-
|
|
36
37
|
const radius = (n1, n2, n3, u, v) => props.radius || 1;
|
|
37
|
-
|
|
38
38
|
const positions = new Float32Array(numVertices * 3);
|
|
39
39
|
const normals = new Float32Array(numVertices * 3);
|
|
40
40
|
const texCoords = new Float32Array(numVertices * 2);
|
|
41
41
|
const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;
|
|
42
42
|
const indices = new IndexType(nlat * nlong * 6);
|
|
43
|
-
|
|
44
43
|
for (let y = 0; y <= nlat; y++) {
|
|
45
44
|
for (let x = 0; x <= nlong; x++) {
|
|
46
45
|
const u = x / nlong;
|
|
@@ -68,9 +67,7 @@ function tesselateSphere(props) {
|
|
|
68
67
|
texCoords[i2 + 1] = 1 - v;
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
|
|
72
70
|
const numVertsAround = nlong + 1;
|
|
73
|
-
|
|
74
71
|
for (let x = 0; x < nlong; x++) {
|
|
75
72
|
for (let y = 0; y < nlat; y++) {
|
|
76
73
|
const index = (x * nlat + y) * 6;
|
|
@@ -82,7 +79,6 @@ function tesselateSphere(props) {
|
|
|
82
79
|
indices[index + 5] = (y + 1) * numVertsAround + x + 1;
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
|
|
86
82
|
return {
|
|
87
83
|
indices: {
|
|
88
84
|
size: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sphere-geometry.js","names":["uid","Geometry","SphereGeometry","constructor","props","arguments","length","undefined","id","indices","attributes","tesselateSphere","topology","nlat","nlong","startLat","endLat","Math","PI","latRange","startLong","endLong","longRange","numVertices","radius","n1","n2","n3","u","v","positions","Float32Array","normals","texCoords","IndexType","Uint32Array","Uint16Array","y","x","index","i2","i3","theta","phi","sinTheta","sin","cosTheta","cos","sinPhi","cosPhi","ux","uy","uz","r","numVertsAround","size","value","POSITION","NORMAL","TEXCOORD_0"],"sources":["../../src/geometries/sphere-geometry.ts"],"sourcesContent":["import {uid} from '@luma.gl/core';\nimport {Geometry} from '../geometry/geometry';\n\nexport type SphereGeometryProps = {\n id?: string;\n radius?: number;\n nlat?: number;\n nlong?: number;\n attributes?: any\n};\n\n// Primitives inspired by TDL http://code.google.com/p/webglsamples/,\n// copyright 2011 Google Inc. new BSD License\n// (http://www.opensource.org/licenses/bsd-license.php).\nexport class SphereGeometry extends Geometry {\n constructor(props: SphereGeometryProps = {}) {\n const {id = uid('sphere-geometry')} = props;\n const {indices, attributes} = tesselateSphere(props);\n super({\n ...props,\n id,\n topology: 'triangle-list',\n indices,\n attributes: {...attributes, ...props.attributes}\n });\n }\n}\n\n/* eslint-disable max-statements, complexity */\nfunction tesselateSphere(props: SphereGeometryProps) {\n const {nlat = 10, nlong = 10} = props;\n\n const startLat = 0;\n const endLat = Math.PI;\n const latRange = endLat - startLat;\n const startLong = 0;\n const endLong = 2 * Math.PI;\n const longRange = endLong - startLong;\n const numVertices = (nlat + 1) * (nlong + 1);\n\n const radius = (n1: number, n2: number, n3: number, u: number, v: number) => props.radius || 1;\n\n const positions = new Float32Array(numVertices * 3);\n const normals = new Float32Array(numVertices * 3);\n const texCoords = new Float32Array(numVertices * 2);\n\n const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;\n const indices = new IndexType(nlat * nlong * 6);\n\n // Create positions, normals and texCoords\n for (let y = 0; y <= nlat; y++) {\n for (let x = 0; x <= nlong; x++) {\n const u = x / nlong;\n const v = y / nlat;\n\n const index = x + y * (nlong + 1);\n const i2 = index * 2;\n const i3 = index * 3;\n\n const theta = longRange * u;\n const phi = latRange * v;\n const sinTheta = Math.sin(theta);\n const cosTheta = Math.cos(theta);\n const sinPhi = Math.sin(phi);\n const cosPhi = Math.cos(phi);\n const ux = cosTheta * sinPhi;\n const uy = cosPhi;\n const uz = sinTheta * sinPhi;\n\n const r = radius(ux, uy, uz, u, v);\n\n positions[i3 + 0] = r * ux;\n positions[i3 + 1] = r * uy;\n positions[i3 + 2] = r * uz;\n\n normals[i3 + 0] = ux;\n normals[i3 + 1] = uy;\n normals[i3 + 2] = uz;\n\n texCoords[i2 + 0] = u;\n texCoords[i2 + 1] = 1 - v;\n }\n }\n\n // Create indices\n const numVertsAround = nlong + 1;\n for (let x = 0; x < nlong; x++) {\n for (let y = 0; y < nlat; y++) {\n const index = (x * nlat + y) * 6;\n\n indices[index + 0] = y * numVertsAround + x;\n indices[index + 1] = y * numVertsAround + x + 1;\n indices[index + 2] = (y + 1) * numVertsAround + x;\n\n indices[index + 3] = (y + 1) * numVertsAround + x;\n indices[index + 4] = y * numVertsAround + x + 1;\n indices[index + 5] = (y + 1) * numVertsAround + x + 1;\n }\n }\n\n return {\n indices: {size: 1, value: indices},\n attributes: {\n POSITION: {size: 3, value: positions},\n NORMAL: {size: 3, value: normals},\n TEXCOORD_0: {size: 2, value: texCoords}\n }\n };\n}\n"],"mappings":"AAAA,SAAQA,GAAG,QAAO,eAAe;AAAC,SAC1BC,QAAQ;AAahB,OAAO,MAAMC,cAAc,SAASD,QAAQ,CAAC;EAC3CE,WAAWA,CAAA,EAAkC;IAAA,IAAjCC,KAA0B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACzC,MAAM;MAACG,EAAE,GAAGR,GAAG,CAAC,iBAAiB;IAAC,CAAC,GAAGI,KAAK;IAC3C,MAAM;MAACK,OAAO;MAAEC;IAAU,CAAC,GAAGC,eAAe,CAACP,KAAK,CAAC;IACpD,KAAK,CAAC;MACJ,GAAGA,KAAK;MACRI,EAAE;MACFI,QAAQ,EAAE,eAAe;MACzBH,OAAO;MACPC,UAAU,EAAE;QAAC,GAAGA,UAAU;QAAE,GAAGN,KAAK,CAACM;MAAU;IACjD,CAAC,CAAC;EACJ;AACF;AAGA,SAASC,eAAeA,CAACP,KAA0B,EAAE;EACnD,MAAM;IAACS,IAAI,GAAG,EAAE;IAAEC,KAAK,GAAG;EAAE,CAAC,GAAGV,K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AK,EAAEvB;MAAS;IACxC;EACF,CAAC;AACH"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Geometry from '../geometry/geometry';
|
|
2
|
-
|
|
3
|
-
export declare type TruncatedConeGeometryProps = {
|
|
1
|
+
import { Geometry } from '../geometry/geometry';
|
|
2
|
+
export type TruncatedConeGeometryProps = {
|
|
4
3
|
topRadius?: number;
|
|
5
4
|
bottomRadius?: number;
|
|
6
5
|
topCap?: boolean;
|
|
@@ -15,7 +14,6 @@ export declare type TruncatedConeGeometryProps = {
|
|
|
15
14
|
* copyright 2011 Google Inc. new BSD License
|
|
16
15
|
* (http://www.opensource.org/licenses/bsd-license.php).
|
|
17
16
|
*/
|
|
18
|
-
export declare function makeTruncatedConeGeometry(props?: TruncatedConeGeometryProps): GeometryTable;
|
|
19
17
|
export declare class TruncatedConeGeometry extends Geometry {
|
|
20
18
|
constructor(props?: TruncatedConeGeometryProps & {
|
|
21
19
|
id?: string;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"truncated-cone-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAQ9C,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,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,KAAK,GAAE,0BAA0B,GAAG;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,GAAG,CAAA;KAAM;CAerF"}
|
|
@@ -1,23 +1,13 @@
|
|
|
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
4
|
x: [2, 0, 1],
|
|
5
5
|
y: [0, 1, 2],
|
|
6
6
|
z: [1, 2, 0]
|
|
7
7
|
};
|
|
8
|
-
export function makeTruncatedConeGeometry(props) {
|
|
9
|
-
const {
|
|
10
|
-
indices,
|
|
11
|
-
attributes
|
|
12
|
-
} = tesselateTruncatedCone(props);
|
|
13
|
-
return {
|
|
14
|
-
length: indices.length,
|
|
15
|
-
indices,
|
|
16
|
-
attributes
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
8
|
export class TruncatedConeGeometry extends Geometry {
|
|
20
|
-
constructor(
|
|
9
|
+
constructor() {
|
|
10
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
11
|
const {
|
|
22
12
|
id = uid('truncated-code-geometry')
|
|
23
13
|
} = props;
|
|
@@ -25,8 +15,10 @@ export class TruncatedConeGeometry extends Geometry {
|
|
|
25
15
|
indices,
|
|
26
16
|
attributes
|
|
27
17
|
} = tesselateTruncatedCone(props);
|
|
28
|
-
super({
|
|
18
|
+
super({
|
|
19
|
+
...props,
|
|
29
20
|
id,
|
|
21
|
+
topology: 'triangle-list',
|
|
30
22
|
indices,
|
|
31
23
|
attributes: {
|
|
32
24
|
POSITION: {
|
|
@@ -45,10 +37,9 @@ export class TruncatedConeGeometry extends Geometry {
|
|
|
45
37
|
}
|
|
46
38
|
});
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
}
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
function tesselateTruncatedCone() {
|
|
42
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
52
43
|
const {
|
|
53
44
|
bottomRadius = 0,
|
|
54
45
|
topRadius = 0,
|
|
@@ -77,12 +68,10 @@ function tesselateTruncatedCone(props = {}) {
|
|
|
77
68
|
const texCoords = new Float32Array(numVertices * 2);
|
|
78
69
|
let i3 = 0;
|
|
79
70
|
let i2 = 0;
|
|
80
|
-
|
|
81
71
|
for (let i = start; i <= end; i++) {
|
|
82
72
|
let v = i / nvertical;
|
|
83
73
|
let y = height * v;
|
|
84
74
|
let ringRadius;
|
|
85
|
-
|
|
86
75
|
if (i < 0) {
|
|
87
76
|
y = 0;
|
|
88
77
|
v = 1;
|
|
@@ -94,14 +83,11 @@ function tesselateTruncatedCone(props = {}) {
|
|
|
94
83
|
} else {
|
|
95
84
|
ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
|
|
96
85
|
}
|
|
97
|
-
|
|
98
86
|
if (i === -2 || i === nvertical + 2) {
|
|
99
87
|
ringRadius = 0;
|
|
100
88
|
v = 0;
|
|
101
89
|
}
|
|
102
|
-
|
|
103
90
|
y -= height / 2;
|
|
104
|
-
|
|
105
91
|
for (let j = 0; j < vertsAroundEdge; j++) {
|
|
106
92
|
const sin = msin(j * mpi * 2 / nradial);
|
|
107
93
|
const cos = mcos(j * mpi * 2 / nradial);
|
|
@@ -117,7 +103,6 @@ function tesselateTruncatedCone(props = {}) {
|
|
|
117
103
|
i3 += 3;
|
|
118
104
|
}
|
|
119
105
|
}
|
|
120
|
-
|
|
121
106
|
for (let i = 0; i < nvertical + extra; i++) {
|
|
122
107
|
for (let j = 0; j < nradial; j++) {
|
|
123
108
|
const index = (i * nradial + j) * 6;
|
|
@@ -129,7 +114,6 @@ function tesselateTruncatedCone(props = {}) {
|
|
|
129
114
|
indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
|
|
130
115
|
}
|
|
131
116
|
}
|
|
132
|
-
|
|
133
117
|
return {
|
|
134
118
|
indices,
|
|
135
119
|
attributes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":["uid","Geometry","INDEX_OFFSETS","x","y","z","makeTruncatedConeGeometry","props","indices","attributes","tesselateTruncatedCone","length","TruncatedConeGeometry","constructor","id","POSITION","size","value","NORMAL","TEXCOORD_0","bottomRadius","topRadius","height","nradial","nvertical","verticalAxis","topCap","bottomCap","extra","numVertices","slant","Math","atan2","msin","sin","mcos","cos","mpi","PI","cosSlant","sinSlant","start","end","vertsAroundEdge","Uint16Array","indexOffset","positions","Float32Array","normals","texCoords","i3","i2","i","v","ringRadius","j","index"],"mappings":"AAAA,SAAQA,GAAR,QAAkB,cAAlB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAGA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CADiB;AAEpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAFiB;AAGpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP;AAHiB,CAAtB;AAsBA,OAAO,SAASC,yBAAT,CAAmCC,KAAnC,EAAsF;AAC3F,QAAM;AAACC,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAwBC,sBAAsB,CAACH,KAAD,CAApD;AACA,SAAO;AACLI,IAAAA,MAAM,EAAEH,OAAO,CAACG,MADX;AAELH,IAAAA,OAFK;AAGLC,IAAAA;AAHK,GAAP;AAKD;AAED,OAAO,MAAMG,qBAAN,SAAoCX,QAApC,CAA6C;AAClDY,EAAAA,WAAW,CAACN,KAA8D,GAAG,EAAlE,EAAsE;AAC/E,UAAM;AAACO,MAAAA,EAAE,GAAGd,GA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5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACA/C,MAAAA,OAAO,CAACgD,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACD;AACF;;AAED,SAAO;AACL/C,IAAAA,OADK;AAELC,IAAAA,UAAU,EAAE;AACVM,MAAAA,QAAQ,EAAE+B,SADA;AAEV5B,MAAAA,MAAM,EAAE8B,OAFE;AAGV7B,MAAAA,UAAU,EAAE8B;AAHF;AAFP,GAAP;AAQD","sourcesContent":["import {uid} from '@luma.gl/api';\nimport Geometry from '../geometry/geometry';\nimport {GeometryTable} from '../geometry/geometry-table';\n\nconst INDEX_OFFSETS = {\n x: [2, 0, 1],\n y: [0, 1, 2],\n z: [1, 2, 0]\n};\n\nexport type TruncatedConeGeometryProps = {\n topRadius?: number;\n bottomRadius?: number;\n topCap?: boolean;\n bottomCap?: boolean;\n height?: number;\n nradial?: number;\n nvertical?: number;\n verticalAxis?: 'x' | 'y' | 'z';\n};\n\n/**\n * Primitives inspired by TDL http://code.google.com/p/webglsamples/,\n * copyright 2011 Google Inc. new BSD License\n * (http://www.opensource.org/licenses/bsd-license.php).\n */\nexport function makeTruncatedConeGeometry(props?: TruncatedConeGeometryProps): GeometryTable {\n const {indices, attributes} = tesselateTruncatedCone(props);\n return {\n length: indices.length,\n indices,\n attributes\n };\n}\n\nexport class TruncatedConeGeometry extends Geometry {\n constructor(props: TruncatedConeGeometryProps & {id?: string; attributes?} = {}) {\n const {id = uid('truncated-code-geometry')} = props;\n const {indices, attributes} = tesselateTruncatedCone(props);\n super({\n ...props,\n id,\n indices,\n attributes: {\n POSITION: {size: 3, value: attributes.POSITION},\n NORMAL: {size: 3, value: attributes.NORMAL},\n TEXCOORD_0: {size: 2, value: attributes.TEXCOORD_0},\n ...props.attributes}\n });\n }\n}\n\n/* eslint-disable max-statements, complexity */\nfunction tesselateTruncatedCone(props: TruncatedConeGeometryProps = {}) {\n const {\n bottomRadius = 0,\n topRadius = 0,\n height = 1,\n nradial = 10,\n nvertical = 10,\n verticalAxis = 'y',\n topCap = false,\n bottomCap = false\n } = props;\n\n const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);\n const numVertices = (nradial + 1) * (nvertical + 1 + extra);\n\n const slant = Math.atan2(bottomRadius - topRadius, height);\n const msin = Math.sin;\n const mcos = Math.cos;\n const mpi = Math.PI;\n const cosSlant = mcos(slant);\n const sinSlant = msin(slant);\n const start = topCap ? -2 : 0;\n const end = nvertical + (bottomCap ? 2 : 0);\n const vertsAroundEdge = nradial + 1;\n\n const indices = new Uint16Array(nradial * (nvertical + extra) * 6);\n const indexOffset = INDEX_OFFSETS[verticalAxis];\n\n const positions = new Float32Array(numVertices * 3);\n const normals = new Float32Array(numVertices * 3);\n const texCoords = new Float32Array(numVertices * 2);\n\n let i3 = 0;\n let i2 = 0;\n for (let i = start; i <= end; i++) {\n let v = i / nvertical;\n let y = height * v;\n let ringRadius;\n\n if (i < 0) {\n y = 0;\n v = 1;\n ringRadius = bottomRadius;\n } else if (i > nvertical) {\n y = height;\n v = 1;\n ringRadius = topRadius;\n } else {\n ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);\n }\n if (i === -2 || i === nvertical + 2) {\n ringRadius = 0;\n v = 0;\n }\n y -= height / 2;\n for (let j = 0; j < vertsAroundEdge; j++) {\n const sin = msin((j * mpi * 2) / nradial);\n const cos = mcos((j * mpi * 2) / nradial);\n\n positions[i3 + indexOffset[0]] = sin * ringRadius;\n positions[i3 + indexOffset[1]] = y;\n positions[i3 + indexOffset[2]] = cos * ringRadius;\n\n normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;\n normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;\n normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;\n\n texCoords[i2 + 0] = j / nradial;\n texCoords[i2 + 1] = v;\n\n i2 += 2;\n i3 += 3;\n }\n }\n\n for (let i = 0; i < nvertical + extra; i++) {\n for (let j = 0; j < nradial; j++) {\n const index = (i * nradial + j) * 6;\n indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;\n indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;\n indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;\n indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;\n indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;\n indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;\n }\n }\n\n return {\n indices,\n attributes: {\n POSITION: positions,\n NORMAL: normals,\n TEXCOORD_0: texCoords\n }\n };\n}\n"],"file":"truncated-cone-geometry.js"}
|
|
1
|
+
{"version":3,"file":"truncated-cone-geometry.js","names":["uid","Geometry","INDEX_OFFSETS","x","y","z","TruncatedConeGeometry","constructor","props","arguments","length","undefined","id","indices","attributes","tesselateTruncatedCone","topology","POSITION","size","value","NORMAL","TEXCOORD_0","bottomRadius","topRadius","height","nradial","nvertical","verticalAxis","topCap","bottomCap","extra","numVertices","slant","Math","atan2","msin","sin","mcos","cos","mpi","PI","cosSlant","sinSlant","start","end","vertsAroundEdge","Uint16Array","indexOffset","positions","Float32Array","normals","texCoords","i3","i2","i","v","ringRadius","j","index"],"sources":["../../src/geometries/truncated-cone-geometry.ts"],"sourcesContent":["import {uid} from '@luma.gl/core';\nimport {Geometry} from '../geometry/geometry';\n\nconst INDEX_OFFSETS = {\n x: [2, 0, 1],\n y: [0, 1, 2],\n z: [1, 2, 0]\n};\n\nexport type TruncatedConeGeometryProps = {\n topRadius?: number;\n bottomRadius?: number;\n topCap?: boolean;\n bottomCap?: boolean;\n height?: number;\n nradial?: number;\n nvertical?: number;\n verticalAxis?: 'x' | 'y' | 'z';\n};\n\n/**\n * Primitives inspired by TDL http://code.google.com/p/webglsamples/,\n * copyright 2011 Google Inc. new BSD License\n * (http://www.opensource.org/licenses/bsd-license.php).\n */\nexport class TruncatedConeGeometry extends Geometry {\n constructor(props: TruncatedConeGeometryProps & {id?: string; attributes?: any} = {}) {\n const {id = uid('truncated-code-geometry')} = props;\n const {indices, attributes} = tesselateTruncatedCone(props);\n super({\n ...props,\n id,\n topology: 'triangle-list',\n indices,\n attributes: {\n POSITION: {size: 3, value: attributes.POSITION},\n NORMAL: {size: 3, value: attributes.NORMAL},\n TEXCOORD_0: {size: 2, value: attributes.TEXCOORD_0},\n ...props.attributes}\n });\n }\n}\n\n/* eslint-disable max-statements, complexity */\nfunction tesselateTruncatedCone(props: TruncatedConeGeometryProps = {}) {\n const {\n bottomRadius = 0,\n topRadius = 0,\n height = 1,\n nradial = 10,\n nvertical = 10,\n verticalAxis = 'y',\n topCap = false,\n bottomCap = false\n } = props;\n\n const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);\n const numVertices = (nradial + 1) * (nvertical + 1 + extra);\n\n const slant = Math.atan2(bottomRadius - topRadius, height);\n const msin = Math.sin;\n const mcos = Math.cos;\n const mpi = Math.PI;\n const cosSlant = mcos(slant);\n const sinSlant = msin(slant);\n const start = topCap ? -2 : 0;\n const end = nvertical + (bottomCap ? 2 : 0);\n const vertsAroundEdge = nradial + 1;\n\n const indices = new Uint16Array(nradial * (nvertical + extra) * 6);\n const indexOffset = INDEX_OFFSETS[verticalAxis];\n\n const positions = new Float32Array(numVertices * 3);\n const normals = new Float32Array(numVertices * 3);\n const texCoords = new Float32Array(numVertices * 2);\n\n let i3 = 0;\n let i2 = 0;\n for (let i = start; i <= end; i++) {\n let v = i / nvertical;\n let y = height * v;\n let ringRadius;\n\n if (i < 0) {\n y = 0;\n v = 1;\n ringRadius = bottomRadius;\n } else if (i > nvertical) {\n y = height;\n v = 1;\n ringRadius = topRadius;\n } else {\n ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);\n }\n if (i === -2 || i === nvertical + 2) {\n ringRadius = 0;\n v = 0;\n }\n y -= height / 2;\n for (let j = 0; j < vertsAroundEdge; j++) {\n const sin = msin((j * mpi * 2) / nradial);\n const cos = mcos((j * mpi * 2) / nradial);\n\n positions[i3 + indexOffset[0]] = sin * ringRadius;\n positions[i3 + indexOffset[1]] = y;\n positions[i3 + indexOffset[2]] = cos * ringRadius;\n\n normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;\n normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;\n normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;\n\n texCoords[i2 + 0] = j / nradial;\n texCoords[i2 + 1] = v;\n\n i2 += 2;\n i3 += 3;\n }\n }\n\n for (let i = 0; i < nvertical + extra; i++) {\n for (let j = 0; j < nradial; j++) {\n const index = (i * nradial + j) * 6;\n indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;\n indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;\n indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;\n indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;\n indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;\n indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;\n }\n }\n\n return {\n indices,\n attributes: {\n POSITION: positions,\n NORMAL: normals,\n TEXCOORD_0: texCoords\n }\n };\n}\n"],"mappings":"AAAA,SAAQA,GAAG,QAAO,eAAe;AAAC,SAC1BC,QAAQ;AAEhB,MAAMC,aAAa,GAAG;EACpBC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EACZC,CAAC,EAAE,CAAC,C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C,GAAG,CAAC,CAAC,GAAG,CAAC,GAAGG,CAAC;MACtD5C,OAAO,CAAC6C,KAAK,GAAG,CAAC,CAAC,GAAGb,eAAe,IAAIS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAGG,CAAC;MACtD5C,OAAO,CAAC6C,KAAK,GAAG,CAAC,CAAC,GAAGb,eAAe,IAAIS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAGG,CAAC;MACtD5C,OAAO,CAAC6C,KAAK,GAAG,CAAC,CAAC,GAAGb,eAAe,IAAIS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAGG,CAAC;IACxD;EACF;EAEA,OAAO;IACL5C,OAAO;IACPC,UAAU,EAAE;MACVG,QAAQ,EAAE+B,SAAS;MACnB5B,MAAM,EAAE8B,OAAO;MACf7B,UAAU,EAAE8B;IACd;EACF,CAAC;AACH"}
|
|
@@ -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":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,
|
|
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,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,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"geometry-table.js","names":[],"sources":["../../src/geometry/geometry-table.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {TypedArray, VertexFormat} from '@luma.gl/core';\n\n/** Holds one geometry */\nexport type GeometryTable = {\n length: number;\n schema?: Record<string, VertexFormat>;\n attributes: {\n POSITION: TypedArray,\n NORMAL: TypedArray,\n TEXCOORD_0: TypedArray,\n [key: string]: TypedArray,\n };\n indices?: Uint16Array | Uint32Array;\n topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';\n}\n"],"mappings":""}
|
|
@@ -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"}
|
|
@@ -3,14 +3,11 @@ export function unpackIndexedGeometry(geometry) {
|
|
|
3
3
|
indices,
|
|
4
4
|
attributes
|
|
5
5
|
} = geometry;
|
|
6
|
-
|
|
7
6
|
if (!indices) {
|
|
8
7
|
return geometry;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
const vertexCount = indices.value.length;
|
|
12
10
|
const unpackedAttributes = {};
|
|
13
|
-
|
|
14
11
|
for (const attributeName in attributes) {
|
|
15
12
|
const attribute = attributes[attributeName];
|
|
16
13
|
const {
|
|
@@ -18,27 +15,21 @@ export function unpackIndexedGeometry(geometry) {
|
|
|
18
15
|
value,
|
|
19
16
|
size
|
|
20
17
|
} = attribute;
|
|
21
|
-
|
|
22
18
|
if (constant || !size) {
|
|
23
19
|
continue;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
const unpackedValue = new value.constructor(vertexCount * size);
|
|
27
|
-
|
|
28
22
|
for (let x = 0; x < vertexCount; ++x) {
|
|
29
23
|
const index = indices.value[x];
|
|
30
|
-
|
|
31
24
|
for (let i = 0; i < size; i++) {
|
|
32
25
|
unpackedValue[x * size + i] = value[index * size + i];
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
unpackedAttributes[attributeName] = {
|
|
37
29
|
size,
|
|
38
30
|
value: unpackedValue
|
|
39
31
|
};
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
return {
|
|
43
34
|
attributes: Object.assign({}, attributes, unpackedAttributes)
|
|
44
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"geometry-utils.js","names":["unpackIndexedGeometry","geometry","indices","attributes","vertexCount","value","length","unpackedAttributes","attributeName","attribute","constant","size","unpackedValue","constructor","x","index","i","Object","assign"],"sources":["../../src/geometry/geometry-utils.ts"],"sourcesContent":["// import type {Geometry} from './geometry';\n\nexport function unpackIndexedGeometry(geometry: any) {\n const {indices, attributes} = geometry;\n if (!indices) {\n return geometry;\n }\n\n const vertexCount = indices.value.length;\n const unpackedAttributes: Record<string, any> = {};\n\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const {constant, value, size} = attribute;\n if (constant || !size) {\n continue; // eslint-disable-line\n }\n const unpackedValue = new value.constructor(vertexCount * size);\n for (let x = 0; x < vertexCount; ++x) {\n const index = indices.value[x];\n for (let i = 0; i < size; i++) {\n unpackedValue[x * size + i] = value[index * size + i];\n }\n }\n unpackedAttributes[attributeName] = {size, value: unpackedValue};\n }\n\n return {\n attributes: Object.assign({}, attributes, unpackedAttributes)\n };\n}\n\n// export function calculateVertexNormals(positions: Float32Array): Uint8Array {\n// let normals = new Uint8Array(positions.length / 3);\n\n// for (let i = 0; i < positions.length; i++) {\n// const vec1 = new Vector3(positions.subarray(i * 3, i + 0, i + 3));\n// const vec2 = new Vector3(positions.subarray(i + 3, i + 6));\n// const vec3 = new Vector3(positions.subarray(i + 6, i + 9));\n\n// const normal = new Vector3(vec1).cross(vec2).normalize();\n// normals.set(normal[0], i + 4);\n// normals.set(normal[1], i + 4 + 1);\n// normals.set(normal[2], i + 2);\n// }\n// const normal = new Vector3(vec1).cross(vec2).normalize();\n// }"],"mappings":"AAEA,OAAO,SAASA,qBAAqBA,CAACC,QAAa,EAAE;EACnD,MAAM;IAACC,OAAO;IAAEC;EAAU,CAAC,GAAGF,QAAQ;EACtC,IAAI,CAACC,OAAO,EAAE;IACZ,OAAOD,QAAQ;EACjB;EAEA,MAAMG,WAAW,GAAGF,OAAO,CAACG,KAAK,CAACC,MAAM;EACxC,MAAMC,kBAAuC,GAAG,CAAC,CAAC;EAElD,KAAK,MAAMC,aAAa,IAAIL,UAAU,EAAE;IACtC,MAAMM,SAAS,GAAGN,UAAU,CAACK,aAAa,CAAC;IAC3C,MAAM;MAACE,QAAQ;MAAEL,KAAK;MAAEM;IAAI,CAAC,GAAGF,SAAS;IACzC,IAAIC,QAAQ,IAAI,CAACC,IAAI,EAAE;MACrB;IACF;IACA,MAAMC,aAAa,GAAG,IAAIP,KAAK,CAACQ,WAAW,CAACT,WAAW,GAAGO,IAAI,CAAC;IAC/D,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGV,WAAW,EAAE,EAAEU,CAAC,EAAE;MACpC,MAAMC,KAAK,GAAGb,OAAO,CAACG,KAAK,CAACS,CAAC,CAAC;MAC9B,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,IAAI,EAAEK,CAAC,EAAE,EAAE;QAC7BJ,aAAa,CAACE,CAAC,GAAGH,IAAI,GAAGK,CAAC,CAAC,GAAGX,KAAK,CAACU,KAAK,GAAGJ,IAAI,GAAGK,CAAC,CAAC;MACvD;IACF;IACAT,kBAAkB,CAACC,aAAa,CAAC,GAAG;MAACG,IAAI;MAAEN,KAAK,EAAEO;IAAa,CAAC;EAClE;EAEA,OAAO;IACLT,UAAU,EAAEc,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEf,UAAU,EAAEI,kBAAkB;EAC9D,CAAC;AACH"}
|
|
@@ -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":"AACA,OAAO,KAAK,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","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