@luma.gl/engine 8.6.0-alpha.4 → 9.0.0-alpha.4
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 -0
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +1 -1
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js.map +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +1 -1
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +4 -0
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +30 -7
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +1 -1
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +1 -1
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +1 -1
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +1 -1
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +15 -3
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +29 -15
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +15 -0
- package/dist/geometry/geometry-table.d.ts.map +1 -0
- package/dist/geometry/geometry-table.js +2 -0
- package/dist/{transform/transform-types.js.map → geometry/geometry-table.js.map} +1 -1
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +34 -7
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +33 -11
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/primitive-utils.d.ts +1 -0
- package/dist/geometry/primitive-utils.d.ts.map +1 -0
- package/dist/geometry/primitive-utils.js +2 -0
- package/dist/geometry/primitive-utils.js.map +1 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/animation-loop.d.ts +14 -73
- package/dist/lib/animation-loop.d.ts.map +1 -1
- package/dist/lib/animation-loop.js +39 -160
- package/dist/lib/animation-loop.js.map +1 -1
- package/dist/lib/animation-props.d.ts +24 -0
- package/dist/lib/animation-props.d.ts.map +1 -0
- package/dist/lib/animation-props.js +2 -0
- package/dist/lib/animation-props.js.map +1 -0
- package/dist/lib/clip-space.d.ts +1 -0
- package/dist/lib/clip-space.d.ts.map +1 -0
- package/dist/lib/clip-space.js +2 -0
- package/dist/lib/clip-space.js.map +1 -0
- package/dist/lib/model-utils.d.ts +4 -3
- package/dist/lib/model-utils.d.ts.map +1 -1
- package/dist/lib/model-utils.js +24 -70
- package/dist/lib/model-utils.js.map +1 -1
- package/dist/lib/model.d.ts +34 -104
- package/dist/lib/model.d.ts.map +1 -1
- package/dist/lib/model.js +108 -505
- package/dist/lib/model.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +55 -0
- package/dist/lib/pipeline-factory.d.ts.map +1 -0
- package/dist/lib/pipeline-factory.js +191 -0
- package/dist/lib/pipeline-factory.js.map +1 -0
- package/dist/lib/render-loop.d.ts +4 -17
- package/dist/lib/render-loop.d.ts.map +1 -1
- package/dist/lib/render-loop.js +14 -21
- package/dist/lib/render-loop.js.map +1 -1
- package/package.json +5 -5
- package/src/animation/key-frames.ts +1 -0
- package/src/animation/timeline.ts +1 -1
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +159 -8
- package/src/geometries/cylinder-geometry.ts +1 -1
- package/src/geometries/ico-sphere-geometry.ts +1 -1
- package/src/geometries/plane-geometry.ts +1 -1
- package/src/geometries/sphere-geometry.ts +2 -2
- package/src/geometries/truncated-cone-geometry.ts +30 -12
- package/src/geometry/geometry-table.ts +16 -0
- package/src/geometry/geometry-utils.ts +1 -1
- package/src/geometry/geometry.ts +58 -13
- package/src/geometry/primitive-utils.ts +30 -0
- package/src/index.ts +7 -8
- package/src/lib/animation-loop.ts +85 -274
- package/src/lib/animation-props.ts +31 -0
- package/src/{utils → lib}/clip-space.ts +5 -2
- package/src/lib/model-utils.ts +60 -32
- package/src/lib/model.ts +126 -642
- package/src/lib/pipeline-factory.ts +225 -0
- package/src/lib/render-loop.ts +21 -19
- package/dist/lib/program-manager.d.ts +0 -39
- package/dist/lib/program-manager.d.ts.map +0 -1
- package/dist/lib/program-manager.js +0 -175
- package/dist/lib/program-manager.js.map +0 -1
- package/dist/transform/buffer-transform.d.ts +0 -36
- package/dist/transform/buffer-transform.d.ts.map +0 -1
- package/dist/transform/buffer-transform.js +0 -255
- package/dist/transform/buffer-transform.js.map +0 -1
- package/dist/transform/texture-transform.d.ts +0 -57
- package/dist/transform/texture-transform.d.ts.map +0 -1
- package/dist/transform/texture-transform.js +0 -412
- package/dist/transform/texture-transform.js.map +0 -1
- package/dist/transform/transform-shader-utils.d.ts +0 -26
- package/dist/transform/transform-shader-utils.d.ts.map +0 -1
- package/dist/transform/transform-shader-utils.js +0 -149
- package/dist/transform/transform-shader-utils.js.map +0 -1
- package/dist/transform/transform-types.d.ts +0 -44
- package/dist/transform/transform-types.d.ts.map +0 -1
- package/dist/transform/transform-types.js +0 -2
- package/dist/transform/transform.d.ts +0 -47
- package/dist/transform/transform.d.ts.map +0 -1
- package/dist/transform/transform.js +0 -198
- package/dist/transform/transform.js.map +0 -1
- package/dist/utils/clip-space.d.ts +0 -5
- package/dist/utils/clip-space.d.ts.map +0 -1
- package/dist/utils/clip-space.js +0 -34
- package/dist/utils/clip-space.js.map +0 -1
- package/src/lib/program-manager.ts +0 -187
- package/src/transform/buffer-transform.ts +0 -214
- package/src/transform/texture-transform.ts +0 -344
- package/src/transform/transform-shader-utils.ts +0 -169
- package/src/transform/transform-types.ts +0 -42
- package/src/transform/transform.ts +0 -189
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import { uid } from '@luma.gl/api';
|
|
1
2
|
import Geometry from '../geometry/geometry';
|
|
2
|
-
import { uid } from '@luma.gl/webgl';
|
|
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
|
+
}
|
|
8
19
|
export class TruncatedConeGeometry extends Geometry {
|
|
9
20
|
constructor(props = {}) {
|
|
10
21
|
const {
|
|
@@ -17,7 +28,19 @@ export class TruncatedConeGeometry extends Geometry {
|
|
|
17
28
|
super({ ...props,
|
|
18
29
|
id,
|
|
19
30
|
indices,
|
|
20
|
-
attributes: {
|
|
31
|
+
attributes: {
|
|
32
|
+
POSITION: {
|
|
33
|
+
size: 3,
|
|
34
|
+
value: attributes.POSITION
|
|
35
|
+
},
|
|
36
|
+
NORMAL: {
|
|
37
|
+
size: 3,
|
|
38
|
+
value: attributes.NORMAL
|
|
39
|
+
},
|
|
40
|
+
TEXCOORD_0: {
|
|
41
|
+
size: 2,
|
|
42
|
+
value: attributes.TEXCOORD_0
|
|
43
|
+
},
|
|
21
44
|
...props.attributes
|
|
22
45
|
}
|
|
23
46
|
});
|
|
@@ -25,7 +48,7 @@ export class TruncatedConeGeometry extends Geometry {
|
|
|
25
48
|
|
|
26
49
|
}
|
|
27
50
|
|
|
28
|
-
function tesselateTruncatedCone(props) {
|
|
51
|
+
function tesselateTruncatedCone(props = {}) {
|
|
29
52
|
const {
|
|
30
53
|
bottomRadius = 0,
|
|
31
54
|
topRadius = 0,
|
|
@@ -110,18 +133,9 @@ function tesselateTruncatedCone(props) {
|
|
|
110
133
|
return {
|
|
111
134
|
indices,
|
|
112
135
|
attributes: {
|
|
113
|
-
POSITION:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
NORMAL: {
|
|
118
|
-
size: 3,
|
|
119
|
-
value: normals
|
|
120
|
-
},
|
|
121
|
-
TEXCOORD_0: {
|
|
122
|
-
size: 2,
|
|
123
|
-
value: texCoords
|
|
124
|
-
}
|
|
136
|
+
POSITION: positions,
|
|
137
|
+
NORMAL: normals,
|
|
138
|
+
TEXCOORD_0: texCoords
|
|
125
139
|
}
|
|
126
140
|
};
|
|
127
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":["Geometry","uid","INDEX_OFFSETS","x","y","z","TruncatedConeGeometry","constructor","props","id","indices","attributes","tesselateTruncatedCone","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","POSITION","size","value","NORMAL","TEXCOORD_0"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAAQC,GAAR,QAAkB,gBAAlB;AAEA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CADiB;AAEpBC,EAAAA,CAAC,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAFi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AG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACAtC,MAAAA,OAAO,CAACuC,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACAtC,MAAAA,OAAO,CAACuC,KAAK,GAAG,CAAT,CAAP,GAAqBb,eAAe,IAAIS,CAAC,GAAG,CAAR,CAAf,GAA4B,CAA5B,GAAgCG,CAArD;AACD;AACF;;AAED,SAAO;AACLtC,IAAAA,OADK;AAELC,IAAAA,UAAU,EAAE;AACVuC,MAAAA,QAAQ,EAAE;AAACC,QAAAA,IAAI,EAAE,CAAP;AAAUC,QAAAA,KAAK,EAAEb;AAAjB,OADA;AAEVc,MAAAA,MAAM,EAAE;AAACF,QAAAA,IAAI,EAAE,CAAP;AAAUC,QAAAA,KAAK,EAAEX;AAAjB,OAFE;AAGVa,MAAAA,UAAU,EAAE;AAACH,QAAAA,IAAI,EAAE,CAAP;AAAUC,QAAAA,KAAK,EAAEV;AAAjB;AAHF;AAFP,GAAP;AAQD","sourcesContent":["import Geometry from '../geometry/geometry';\nimport {uid} from '@luma.gl/webgl';\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 id?: string;\n topRadius?: number;\n bottomRadius?: number;\n topCap?: boolean;\n bottomCap?: boolean;\n attributes?\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 TruncatedConeGeometry extends Geometry {\n constructor(props: TruncatedConeGeometryProps = {}) {\n const {id = uid('truncated-code-geometry')} = props;\n const {indices, attributes} = tesselateTruncatedCone(props);\n super({\n ...props,\n id,\n indices,\n attributes: {...attributes, ...props.attributes}\n });\n }\n}\n\n/* eslint-disable max-statements, complexity */\nfunction tesselateTruncatedCone(props) {\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: {size: 3, value: positions},\n NORMAL: {size: 3, value: normals},\n TEXCOORD_0: {size: 2, value: texCoords}\n }\n };\n}\n"],"file":"truncated-cone-geometry.js"}
|
|
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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ACgD,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;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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TypedArray, VertexFormat } from '@luma.gl/api';
|
|
2
|
+
/** Holds one geometry */
|
|
3
|
+
export declare type GeometryTable = {
|
|
4
|
+
length: number;
|
|
5
|
+
schema?: Record<string, VertexFormat>;
|
|
6
|
+
attributes: {
|
|
7
|
+
POSITION: TypedArray;
|
|
8
|
+
NORMAL: TypedArray;
|
|
9
|
+
TEXCOORD_0: TypedArray;
|
|
10
|
+
[key: string]: TypedArray;
|
|
11
|
+
};
|
|
12
|
+
indices?: Uint16Array | Uint32Array;
|
|
13
|
+
topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=geometry-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,yBAAyB;AACzB,oBAAY,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,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"geometry-table.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometry/geometry-utils.ts"],"names":["unpackIndexedGeometry","geometry","indices","attributes","vertexCount","value","length","unpackedAttributes","attributeName","attribute","constant","size","unpackedValue","constructor","x","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AP;AAGD","sourcesContent":["import type Geometry from './geometry';\n\nexport function unpackIndexedGeometry(geometry) {\n const {indices, attributes} = geometry;\n if (!indices) {\n return geometry;\n }\n\n const vertexCount = indices.value.length;\n const unpackedAttributes = {};\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"],"file":"geometry-utils.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/geometry/geometry-utils.ts"],"names":["unpackIndexedGeometry","geometry","indices","attributes","vertexCount","value","length","unpackedAttributes","attributeName","attribute","constant","size","unpackedValue","constructor","x","index","i","Object","assign"],"mappings":"AAEA,OAAO,SAASA,qBAAT,CAA+BC,QAA/B,EAAyC;AAC9C,QAAM;AAACC,IAAAA,OAAD;AAAUC,IAAAA;AAAV,MAAwBF,QAA9B;;AACA,MAAI,CAACC,OAAL,EAAc;AACZ,WAAOD,QAAP;AACD;;AAED,QAAMG,WAAW,GAAGF,OAAO,CAACG,KAAR,CAAcC,MAAlC;AACA,QAAMC,kBAAkB,GAAG,EAA3B;;AAEA,OAAK,MAAMC,aAAX,IAA4BL,UAA5B,EAAwC;AACtC,UAAMM,SAAS,GAAGN,UAAU,CAACK,aAAD,CAA5B;AACA,UAAM;AAACE,MAAAA,QAAD;AAAWL,MAAAA,KAAX;AAAkBM,MAAAA;AAAlB,QAA0BF,SAAhC;;AACA,QAAIC,QAAQ,IAAI,CAACC,IAAjB,EAAuB;AACrB;AACD;;AACD,UAAMC,aAAa,GAAG,IAAIP,KAAK,CAACQ,WAAV,CAAsBT,WAAW,GAAGO,IAApC,CAAtB;;AACA,SAAK,IAAIG,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGV,WAApB,EAAiC,EAAEU,CAAnC,EAAsC;AACpC,YAAMC,KAAK,GAAGb,OAAO,CAACG,KAAR,CAAcS,CAAd,CAAd;;AACA,WAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,IAApB,EAA0BK,CAAC,EAA3B,EAA+B;AAC7BJ,QAAAA,aAAa,CAACE,CAAC,GAAGH,IAAJ,GAAWK,CAAZ,CAAb,GAA8BX,KAAK,CAACU,KAAK,GAAGJ,IAAR,GAAeK,CAAhB,CAAnC;AACD;AACF;;AACDT,IAAAA,kBAAkB,CAACC,aAAD,CAAlB,GAAoC;AAACG,MAAAA,IAAD;AAAON,MAAAA,KAAK,EAAEO;AAAd,KAApC;AACD;;AAED,SAAO;AACLT,IAAAA,UAAU,EAAEc,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBf,UAAlB,EAA8BI,kBAA9B;AADP,GAAP;AAGD","sourcesContent":["// import type Geometry from './geometry';\n\nexport function unpackIndexedGeometry(geometry) {\n const {indices, attributes} = geometry;\n if (!indices) {\n return geometry;\n }\n\n const vertexCount = indices.value.length;\n const unpackedAttributes = {};\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"],"file":"geometry-utils.js"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { TypedArray } from '@luma.gl/api';
|
|
1
2
|
import GL from '@luma.gl/constants';
|
|
2
3
|
/**
|
|
3
|
-
* Rendering primitives - "
|
|
4
|
+
* Rendering primitives - "topology" specifies how to extract primitives from vertices.
|
|
4
5
|
*/
|
|
5
6
|
export declare type Topology = GL.POINTS | // draw single points.
|
|
6
7
|
GL.LINES | // draw lines. Each vertex connects to the one after it.
|
|
@@ -11,10 +12,13 @@ GL.TRIANGLE_STRIP | // draw a connected group of triangles.
|
|
|
11
12
|
GL.TRIANGLE_FAN;
|
|
12
13
|
export declare type GeometryProps = {
|
|
13
14
|
id?: string;
|
|
14
|
-
drawMode?: Topology;
|
|
15
15
|
attributes?: {};
|
|
16
16
|
indices?: any;
|
|
17
17
|
vertexCount?: number;
|
|
18
|
+
/** Determines how vertices are read from the 'vertex' attributes */
|
|
19
|
+
topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
|
|
20
|
+
/** @deprecated */
|
|
21
|
+
drawMode?: Topology;
|
|
18
22
|
};
|
|
19
23
|
export default class Geometry {
|
|
20
24
|
/** @deprecated */
|
|
@@ -28,15 +32,38 @@ export default class Geometry {
|
|
|
28
32
|
TRIANGLE_FAN: GL;
|
|
29
33
|
};
|
|
30
34
|
readonly id: string;
|
|
31
|
-
readonly drawMode: Topology;
|
|
32
|
-
vertexCount: number;
|
|
33
|
-
attributes: {};
|
|
34
|
-
indices: any;
|
|
35
35
|
userData: Record<string, any>;
|
|
36
|
+
/** Determines how vertices are read from the 'vertex' attributes */
|
|
37
|
+
topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
|
|
38
|
+
/** @deprecated */
|
|
39
|
+
readonly drawMode: Topology;
|
|
40
|
+
readonly vertexCount: number;
|
|
41
|
+
readonly attributes: {
|
|
42
|
+
POSITION: {
|
|
43
|
+
size: number;
|
|
44
|
+
value: TypedArray;
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
};
|
|
47
|
+
NORMAL: {
|
|
48
|
+
size: number;
|
|
49
|
+
value: TypedArray;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
52
|
+
TEXCOORD_0: {
|
|
53
|
+
size: number;
|
|
54
|
+
value: TypedArray;
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
};
|
|
57
|
+
COLOR_0?: {
|
|
58
|
+
size: number;
|
|
59
|
+
value: TypedArray;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly indices?: Uint16Array | Uint32Array;
|
|
36
64
|
constructor(props?: GeometryProps);
|
|
37
65
|
get mode(): Topology;
|
|
38
66
|
getVertexCount(): number;
|
|
39
|
-
getAttributes(): {};
|
|
40
67
|
_print(attributeName: any): string;
|
|
41
68
|
_setAttributes(attributes: any, indices: any): this;
|
|
42
69
|
_calculateVertexCount(attributes: any, indices: any): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC;;GAEG;AACH,oBAAY,QAAQ,GAClB,EAAE,CAAC,MAAM,GAAI,sBAAsB;AACnC,EAAE,CAAC,KAAK,GAAI,wDAAwD;AACpE,EAAE,CAAC,SAAS,GAAI,8EAA8E;AAC9F,EAAE,CAAC,UAAU,GAAI,4EAA4E;AAC7F,EAAE,CAAC,SAAS,GAAI,0EAA0E;AAC1F,EAAE,CAAC,cAAc,GAAI,uCAAuC;AAC5D,EAAE,CAAC,YAAY,CACd;AAEH,oBAAY,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,EAAE,CAAC;IAChB,OAAO,CAAC,MAAC;IACT,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAA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BAEjC,KAAK,GAAE,aAAkB;IAkBrC,IAAI,IAAI,aAEP;IAED,cAAc,IAAI,MAAM;IAWxB,MAAM,CAAC,aAAa,KAAA,GAAG,MAAM;IAS7B,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA,GAAG,IAAI;IA6CzC,qBAAqB,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA,GAAG,MAAM;CAgBnD"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { uid, assert } from '@luma.gl/api';
|
|
2
3
|
import GL from '@luma.gl/constants';
|
|
3
|
-
import { uid, assert } from '@luma.gl/webgl';
|
|
4
4
|
export default class Geometry {
|
|
5
5
|
constructor(props = {}) {
|
|
6
6
|
_defineProperty(this, "id", void 0);
|
|
7
7
|
|
|
8
|
+
_defineProperty(this, "userData", {});
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "topology", void 0);
|
|
11
|
+
|
|
8
12
|
_defineProperty(this, "drawMode", GL.TRIANGLES);
|
|
9
13
|
|
|
10
14
|
_defineProperty(this, "vertexCount", void 0);
|
|
11
15
|
|
|
12
|
-
_defineProperty(this, "attributes",
|
|
16
|
+
_defineProperty(this, "attributes", void 0);
|
|
13
17
|
|
|
14
18
|
_defineProperty(this, "indices", void 0);
|
|
15
19
|
|
|
16
|
-
_defineProperty(this, "userData", {});
|
|
17
|
-
|
|
18
20
|
const {
|
|
19
21
|
id = uid('geometry'),
|
|
20
22
|
drawMode = GL.TRIANGLES,
|
|
@@ -24,6 +26,7 @@ export default class Geometry {
|
|
|
24
26
|
} = props;
|
|
25
27
|
this.id = id;
|
|
26
28
|
this.drawMode = drawMode;
|
|
29
|
+
this.topology = props.topology || convertToTopology(drawMode);
|
|
27
30
|
|
|
28
31
|
this._setAttributes(attributes, indices);
|
|
29
32
|
|
|
@@ -38,13 +41,6 @@ export default class Geometry {
|
|
|
38
41
|
return this.vertexCount;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
getAttributes() {
|
|
42
|
-
return this.indices ? {
|
|
43
|
-
indices: this.indices,
|
|
44
|
-
...this.attributes
|
|
45
|
-
} : this.attributes;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
_print(attributeName) {
|
|
49
45
|
return "Geometry ".concat(this.id, " attribute ").concat(attributeName);
|
|
50
46
|
}
|
|
@@ -57,6 +53,8 @@ export default class Geometry {
|
|
|
57
53
|
} : indices;
|
|
58
54
|
}
|
|
59
55
|
|
|
56
|
+
this.attributes = {};
|
|
57
|
+
|
|
60
58
|
for (const attributeName in attributes) {
|
|
61
59
|
let attribute = attributes[attributeName];
|
|
62
60
|
attribute = ArrayBuffer.isView(attribute) ? {
|
|
@@ -119,4 +117,28 @@ _defineProperty(Geometry, "DRAW_MODE", {
|
|
|
119
117
|
TRIANGLE_STRIP: GL.TRIANGLE_STRIP,
|
|
120
118
|
TRIANGLE_FAN: GL.TRIANGLE_FAN
|
|
121
119
|
});
|
|
120
|
+
|
|
121
|
+
function convertToTopology(drawMode) {
|
|
122
|
+
switch (drawMode) {
|
|
123
|
+
case GL.POINTS:
|
|
124
|
+
return 'point-list';
|
|
125
|
+
|
|
126
|
+
case GL.LINES:
|
|
127
|
+
return 'line-list';
|
|
128
|
+
|
|
129
|
+
case GL.LINE_STRIP:
|
|
130
|
+
return 'line-strip';
|
|
131
|
+
|
|
132
|
+
case GL.TRIANGLES:
|
|
133
|
+
return 'triangle-list';
|
|
134
|
+
|
|
135
|
+
case GL.TRIANGLE_STRIP:
|
|
136
|
+
return 'triangle-strip';
|
|
137
|
+
|
|
138
|
+
case GL.TRIANGLE_FAN:
|
|
139
|
+
case GL.LINE_LOOP:
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(String(drawMode));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
122
144
|
//# sourceMappingURL=geometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geometry/geometry.ts"],"names":["GL","uid","assert","Geometry","constructor","props","TRIANGLES","id","drawMode","attributes","indices","vertexCount","_setAttributes","_calculateVertexCount","mode","getVertexCount","getAttributes","_print","attributeName","ArrayBuffer","isView","value","size","attribute","isIndexed","undefined","Object","assign","length","Infinity","constant","Math","min","Number","isFinite","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLE_STRIP","TRIANGLE_FAN"],"mappings":";AACA,OAAOA,EAAP,MAAe,oBAAf;AACA,SAAQC,GAAR,EAAaC,MAAb,QAA0B,gBAA1B;AAuBA,eAAe,MAAMC,QAAN,CAAe;AAoB5BC,EAAAA,WAAW,CAACC,KAAoB,GAAG,EAAxB,EAA4B;AAAA;;AAAA,sCAPTL,EAAE,CAACM,SAOM;;AAAA;;AAAA,wCAJ1B,EAI0B;;AAAA;;AAAA,sCAFP,EAEO;;AACrC,UAAM;AACJC,MAAAA,EAAE,GAAGN,GAAG,CAAC,UAAD,CADJ;AAEJO,MAAAA,QAAQ,GAAGR,EAAE,CAACM,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;;AAEA,SAAKI,cAAL,CAAoBH,UAApB,EAAgCC,OAAhC;;AAEA,SAAKC,WAAL,GAAmBA,WAAW,IAAI,KAAKE,qBAAL,CAA2B,KAAKJ,UAAhC,EAA4C,KAAKC,OAAjD,CAAlC;AACD;;AAEO,MAAJI,IAAI,GAAG;AACT,WAAO,KAAKN,QAAZ;AACD;;AAEDO,EAAAA,cAAc,GAAW;AACvB,WAAO,KAAKJ,WAAZ;AACD;;AAGDK,EAAAA,aAAa,GAAG;AACd,WAAO,KAAKN,OAAL,GAAe;AAACA,MAAAA,OAAO,EAAE,KAAKA,OAAf;AAAwB,SAAG,KAAKD;AAAhC,KAAf,GAA6D,KAA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;AACA,aAAO,KAAKA,OAAL,CAAac,SAApB;AACD;;AAED,WAAO,IAAP;AACD;;AAEDX,EAAAA,qBAAqB,CAACJ,UAAD,EAAaC,OAAb,EAA8B;AACjD,QAAIA,OAAJ,EAAa;AACX,aAAOA,OAAO,CAACW,KAAR,CAAcO,MAArB;AACD;;AACD,QAAIjB,WAAW,GAAGkB,QAAlB;;AACA,SAAK,MAAMX,aAAX,IAA4BT,UAA5B,EAAwC;AACtC,YAAMc,SAAS,GAAGd,UAAU,CAACS,aAAD,CAA5B;AACA,YAAM;AAACG,QAAAA,KAAD;AAAQC,QAAAA,IAAR;AAAcQ,QAAAA;AAAd,UAA0BP,SAAhC;;AACA,UAAI,CAACO,QAAD,IAAaT,KAAb,IAAsBC,IAAI,IAAI,CAAlC,EAAqC;AACnCX,QAAAA,WAAW,GAAGoB,IAAI,CAACC,GAAL,CAASrB,WAAT,EAAsBU,KAAK,CAACO,MAAN,GAAeN,IAArC,CAAd;AACD;AACF;;AAEDpB,IAAAA,MAAM,CAAC+B,MAAM,CAACC,QAAP,CAAgBvB,WAAhB,CAAD,CAAN;AACA,WAAOA,WAAP;AACD;;AAjH2B;;gBAATR,Q,eAEA;AACjBgC,EAAAA,MAAM,EAAEnC,EAAE,CAACmC,MADM;AAEjBC,EAAAA,KAAK,EAAEpC,EAAE,CAACoC,KAFO;AAGjBC,EAAAA,SAAS,EAAErC,EAAE,CAACqC,SAHG;AAIjBC,EAAAA,UAAU,EAAEtC,EAAE,CAACsC,UAJE;AAKjBhC,EAAAA,SAAS,EAAEN,EAAE,CAACM,SALG;AAMjBiC,EAAAA,cAAc,EAAEvC,EAAE,CAACuC,cANF;AAOjBC,EAAAA,YAAY,EAAExC,EAAE,CAACwC;AAPA,C","sourcesContent":["// luma.gl, MIT license\nimport GL from '@luma.gl/constants';\nimport {uid, assert} from '@luma.gl/webgl';\n\n/**\n * Rendering primitives - \"opology\" specifies how to extract primitives from vertices.\n */\nexport type Topology =\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 GeometryProps = {\n id?: string;\n drawMode?: Topology,\n attributes?: {},\n indices?;\n vertexCount?: number\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 readonly drawMode: Topology = GL.TRIANGLES;\n\n vertexCount: number;\n attributes = {};\n indices;\n userData: Record<string, any> = {};\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\n this._setAttributes(attributes, indices);\n\n this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);\n }\n\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() {\n return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;\n }\n\n // PRIVATE\n\n _print(attributeName): string {\n return `Geometry ${this.id} attribute ${attributeName}`;\n }\n\n // Attribute\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, indices): this {\n if (indices) {\n this.indices = ArrayBuffer.isView(indices) ? {value: indices, size: 1} : indices;\n }\n\n for (const attributeName in attributes) {\n let attribute = attributes[attributeName];\n\n // Wrap \"unwrapped\" arrays and try to autodetect their type\n attribute = ArrayBuffer.isView(attribute) ? {value: attribute} : attribute;\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 this.indices = attribute;\n } else {\n this.attributes[attributeName] = attribute;\n }\n }\n\n if (this.indices && this.indices.isIndexed !== undefined) {\n this.indices = Object.assign({}, this.indices);\n delete this.indices.isIndexed;\n }\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"],"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","_setAttributes","_calculateVertexCount","mode","getVertexCount","_print","attributeName","ArrayBuffer","isView","value","size","attribute","isIndexed","undefined","Object","assign","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;AAkCA,eAAe,MAAMC,QAAN,CAAe;AA6B5B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;AACA,UAAI,CAACO,QAAD,IAAaT,KAAb,IAAsBC,IAAI,IAAI,CAAlC,EAAqC;AACnCZ,QAAAA,WAAW,GAAGqB,IAAI,CAACC,GAAL,CAAStB,WAAT,EAAsBW,KAAK,CAACO,MAAN,GAAeN,IAArC,CAAd;AACD;AACF;;AAEDtB,IAAAA,MAAM,CAACiC,MAAM,CAACC,QAAP,CAAgBxB,WAAhB,CAAD,CAAN;AACA,WAAOA,WAAP;AACD;;AAnI2B;;gBAATR,Q,eAEA;AACjBiC,EAAAA,MAAM,EAAElC,EAAE,CAACkC,MADM;AAEjBC,EAAAA,KAAK,EAAEnC,EAAE,CAACmC,KAFO;AAGjBC,EAAAA,SAAS,EAAEpC,EAAE,CAACoC,SAHG;AAIjBC,EAAAA,UAAU,EAAErC,EAAE,CAACqC,UAJE;AAKjBjC,EAAAA,SAAS,EAAEJ,EAAE,CAACI,SALG;AAMjBkC,EAAAA,cAAc,EAAEtC,EAAE,CAACsC,cANF;AAOjBC,EAAAA,YAAY,EAAEvC,EAAE,CAACuC;AAPA,C;;AAoIrB,SAAS5B,iBAAT,CAA2BL,QAA3B,EAAyH;AACvH,UAAQA,QAAR;AACE,SAAKN,EAAE,CAACkC,MAAR;AAAgB,aAAO,YAAP;;AAChB,SAAKlC,EAAE,CAACmC,KAAR;AAAe,aAAO,WAAP;;AACf,SAAKnC,EAAE,CAACqC,UAAR;AAAoB,aAAO,YAAP;;AACpB,SAAKrC,EAAE,CAACI,SAAR;AAAmB,aAAO,eAAP;;AACnB,SAAKJ,EAAE,CAACsC,cAAR;AAAwB,aAAO,gBAAP;;AAExB,SAAKtC,EAAE,CAACuC,YAAR;AACA,SAAKvC,EAAE,CAACoC,SAAR;AACA;AACE,YAAM,IAAII,KAAJ,CAAUC,MAAM,CAACnC,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 */\nexport type Topology =\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 GeometryProps = {\n id?: string;\n attributes?: {},\n indices?;\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?: Topology;\n};\n\ntype GeometryAttributes = {\n POSITION: {size: number, value: TypedArray, [key: string]: any},\n NORMAL: {size: number, value: TypedArray, [key: string]: any},\n TEXCOORD_0: {size: number, value: TypedArray, [key: string]: any},\n COLOR_0?: {size: number, value: TypedArray, [key: string]: any},\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, any> = {};\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: Topology = GL.TRIANGLES;\n\n readonly vertexCount: number;\n readonly attributes: {\n POSITION: {size: number, value: TypedArray, [key: string]: any},\n NORMAL: {size: number, value: TypedArray, [key: string]: any},\n TEXCOORD_0: {size: number, value: TypedArray, [key: string]: any},\n COLOR_0?: {size: number, value: TypedArray, [key: string]: any},\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 this._setAttributes(attributes, indices);\n\n this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);\n }\n\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 {\n return `Geometry ${this.id} attribute ${attributeName}`;\n }\n\n // Attribute\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, indices): this {\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 in attributes) {\n let attribute = attributes[attributeName];\n\n // Wrap \"unwrapped\" arrays and try to autodetect their type\n attribute = ArrayBuffer.isView(attribute) ? {value: attribute} : attribute;\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 // @ts-expect-error\n this.indices = Object.assign({}, this.indices);\n // @ts-expect-error\n delete this.indices.isIndexed;\n }\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: GL): '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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=primitive-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive-utils.d.ts","sourceRoot":"","sources":["../../src/geometry/primitive-utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"primitive-utils.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export { default as AnimationLoop } from './lib/animation-loop';
|
|
1
|
+
export type { AnimationProps } from './lib/animation-props';
|
|
3
2
|
export { RenderLoop } from './lib/render-loop';
|
|
4
3
|
export type { ModelProps } from './lib/model';
|
|
5
4
|
export { default as Model } from './lib/model';
|
|
6
|
-
export {
|
|
7
|
-
export { default as
|
|
5
|
+
export type { AnimationLoopProps } from './lib/animation-loop';
|
|
6
|
+
export { default as AnimationLoop } from './lib/animation-loop';
|
|
8
7
|
export { default as Geometry } from './geometry/geometry';
|
|
9
8
|
export type { ConeGeometryProps } from './geometries/cone-geometry';
|
|
10
9
|
export { ConeGeometry } from './geometries/cone-geometry';
|
|
@@ -22,5 +21,4 @@ export type { TruncatedConeGeometryProps } from './geometries/truncated-cone-geo
|
|
|
22
21
|
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
|
|
23
22
|
export { Timeline } from './animation/timeline';
|
|
24
23
|
export { KeyFrames } from './animation/key-frames';
|
|
25
|
-
export { default as ClipSpace } from './utils/clip-space';
|
|
26
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAM9D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAGxD,YAAY,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AACxD,YAAY,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AACxD,YAAY,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAChE,YAAY,EAAC,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AACnE,YAAY,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,YAAY,EAAC,0BAA0B,EAAC,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAC,qBAAqB,EAAC,MAAM,sCAAsC,CAAC;AAG3E,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export { default as AnimationLoop } from './lib/animation-loop';
|
|
2
1
|
export { RenderLoop } from './lib/render-loop';
|
|
3
2
|
export { default as Model } from './lib/model';
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as Transform } from './transform/transform';
|
|
3
|
+
export { default as AnimationLoop } from './lib/animation-loop';
|
|
6
4
|
export { default as Geometry } from './geometry/geometry';
|
|
7
5
|
export { ConeGeometry } from './geometries/cone-geometry';
|
|
8
6
|
export { CubeGeometry } from './geometries/cube-geometry';
|
|
@@ -13,5 +11,4 @@ export { SphereGeometry } from './geometries/sphere-geometry';
|
|
|
13
11
|
export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
|
|
14
12
|
export { Timeline } from './animation/timeline';
|
|
15
13
|
export { KeyFrames } from './animation/key-frames';
|
|
16
|
-
export { default as ClipSpace } from './utils/clip-space';
|
|
17
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["RenderLoop","default","Model","AnimationLoop","Geometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry","Timeline","KeyFrames"],"mappings":"AAEA,SAAQA,UAAR,QAAyB,mBAAzB;AAEA,SAAQC,OAAO,IAAIC,KAAnB,QAA+B,aAA/B;AAEA,SAAQD,OAAO,IAAIE,aAAnB,QAAuC,sBAAvC;AAMA,SAAQF,OAAO,IAAIG,QAAnB,QAAkC,qBAAlC;AAIA,SAAQC,YAAR,QAA2B,4BAA3B;AAEA,SAAQC,YAAR,QAA2B,4BAA3B;AAEA,SAAQC,gBAAR,QAA+B,gCAA/B;AAEA,SAAQC,iBAAR,QAAgC,kCAAhC;AAEA,SAAQC,aAAR,QAA4B,6BAA5B;AAEA,SAAQC,cAAR,QAA6B,8BAA7B;AAEA,SAAQC,qBAAR,QAAoC,sCAApC;AAGA,SAAQC,QAAR,QAAuB,sBAAvB;AACA,SAAQC,SAAR,QAAwB,wBAAxB","sourcesContent":["// luma.gl Engine API\nexport type {AnimationProps} from './lib/animation-props';\nexport {RenderLoop} from './lib/render-loop';\nexport type {ModelProps} from './lib/model';\nexport {default as Model} from './lib/model';\nexport type {AnimationLoopProps} from './lib/animation-loop';\nexport {default as AnimationLoop} from './lib/animation-loop';\n\n// Utils\n// export {default as ClipSpace} from './lib/clip-space';\n\n// Geometries\nexport {default as Geometry} from './geometry/geometry';\n\n// Primitives\nexport type {ConeGeometryProps} from './geometries/cone-geometry';\nexport {ConeGeometry} from './geometries/cone-geometry';\nexport type {CubeGeometryProps} from './geometries/cube-geometry';\nexport {CubeGeometry} from './geometries/cube-geometry';\nexport type {CylinderGeometryProps} from './geometries/cylinder-geometry';\nexport {CylinderGeometry} from './geometries/cylinder-geometry';\nexport type {IcoSphereGeometryProps} from './geometries/ico-sphere-geometry';\nexport {IcoSphereGeometry} from './geometries/ico-sphere-geometry';\nexport type {PlaneGeometryProps} from './geometries/plane-geometry';\nexport {PlaneGeometry} from './geometries/plane-geometry';\nexport type {SphereGeometryProps} from './geometries/sphere-geometry';\nexport {SphereGeometry} from './geometries/sphere-geometry';\nexport type {TruncatedConeGeometryProps} from './geometries/truncated-cone-geometry';\nexport {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\n\n"],"file":"index.js"}
|
|
@@ -1,67 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import { Device } from '@luma.gl/api';
|
|
3
|
-
import type { WebGLDeviceProps } from '@luma.gl/webgl';
|
|
4
|
-
import { Query, Framebuffer } from '@luma.gl/webgl';
|
|
5
|
-
import { Stats, Stat } from '@probe.gl/stats';
|
|
1
|
+
import { Device, DeviceProps } from '@luma.gl/api';
|
|
6
2
|
import { Timeline } from '../animation/timeline';
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { AnimationProps } from '../lib/animation-props';
|
|
4
|
+
import { Stats, Stat } from '@probe.gl/stats';
|
|
9
5
|
/** AnimationLoop properties */
|
|
10
6
|
export declare type AnimationLoopProps = {
|
|
11
|
-
onCreateDevice?: (props: DeviceProps) => Device
|
|
12
|
-
onCreateContext?: (props: ContextProps) => WebGLRenderingContext;
|
|
7
|
+
onCreateDevice?: (props: DeviceProps) => Promise<Device>;
|
|
13
8
|
onAddHTML?: (div: HTMLDivElement) => string;
|
|
14
|
-
onInitialize?: (animationProps: AnimationProps) =>
|
|
9
|
+
onInitialize?: (animationProps: AnimationProps) => void;
|
|
15
10
|
onRender?: (animationProps: AnimationProps) => void;
|
|
16
11
|
onFinalize?: (animationProps: AnimationProps) => void;
|
|
17
|
-
onError?: (reason:
|
|
18
|
-
stats?: Stats;
|
|
12
|
+
onError?: (reason: Error) => void;
|
|
19
13
|
device?: Device;
|
|
20
|
-
|
|
14
|
+
deviceProps?: DeviceProps;
|
|
15
|
+
stats?: Stats;
|
|
21
16
|
debug?: boolean;
|
|
22
17
|
autoResizeViewport?: boolean;
|
|
23
18
|
autoResizeDrawingBuffer?: boolean;
|
|
24
19
|
useDevicePixels?: number | boolean;
|
|
25
|
-
/** @deprecated Use .device */
|
|
26
|
-
gl?: WebGLRenderingContext;
|
|
27
|
-
/** @deprecated Will be removed */
|
|
28
|
-
createFramebuffer?: boolean;
|
|
29
|
-
};
|
|
30
|
-
export declare type AnimationProps = {
|
|
31
|
-
device: Device;
|
|
32
|
-
stop: () => AnimationLoop;
|
|
33
|
-
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
34
|
-
useDevicePixels: number | boolean;
|
|
35
|
-
needsRedraw?: string;
|
|
36
|
-
startTime: number;
|
|
37
|
-
engineTime: number;
|
|
38
|
-
tick: number;
|
|
39
|
-
tock: number;
|
|
40
|
-
time: number;
|
|
41
|
-
width: number;
|
|
42
|
-
height: number;
|
|
43
|
-
aspect: number;
|
|
44
|
-
timeline: Timeline;
|
|
45
|
-
animationLoop: AnimationLoop;
|
|
46
|
-
_mousePosition?: [number, number];
|
|
47
|
-
/** @deprecated Will be removed, create your own Framebuffer */
|
|
48
|
-
framebuffer: Framebuffer;
|
|
49
|
-
/** @deprecated Use .device */
|
|
50
|
-
gl: WebGLRenderingContext;
|
|
51
|
-
/** @deprecated Use .timeline */
|
|
52
|
-
_timeline: Timeline;
|
|
53
|
-
/** @deprecated Use .animationLoop */
|
|
54
|
-
_loop: AnimationLoop;
|
|
55
|
-
/** @deprecated Use .animationLoop */
|
|
56
|
-
_animationLoop: AnimationLoop;
|
|
57
20
|
};
|
|
58
21
|
/** Convenient animation loop */
|
|
59
22
|
export default class AnimationLoop {
|
|
60
23
|
device: Device;
|
|
61
|
-
canvas: HTMLCanvasElement
|
|
24
|
+
canvas: HTMLCanvasElement;
|
|
62
25
|
props: Required<AnimationLoopProps>;
|
|
63
26
|
animationProps: AnimationProps;
|
|
64
|
-
framebuffer: Framebuffer;
|
|
65
27
|
timeline: Timeline;
|
|
66
28
|
stats: Stats;
|
|
67
29
|
cpuTime: Stat;
|
|
@@ -72,24 +34,17 @@ export default class AnimationLoop {
|
|
|
72
34
|
_initialized: boolean;
|
|
73
35
|
_running: boolean;
|
|
74
36
|
_animationFrameId: any;
|
|
75
|
-
_pageLoadPromise: Promise<{}> | null;
|
|
76
37
|
_nextFramePromise: Promise<AnimationLoop> | null;
|
|
77
38
|
_resolveNextFrame: ((AnimationLoop: any) => void) | null;
|
|
78
39
|
_cpuStartTime: number;
|
|
79
|
-
_gpuTimeQuery: Query | null;
|
|
80
|
-
/** @deprecated */
|
|
81
|
-
gl: WebGLRenderingContext;
|
|
82
40
|
constructor(props?: AnimationLoopProps);
|
|
83
41
|
destroy(): void;
|
|
84
42
|
/** @deprecated Use .destroy() */
|
|
85
43
|
delete(): void;
|
|
86
44
|
setNeedsRedraw(reason: string): this;
|
|
87
45
|
setProps(props: AnimationLoopProps): this;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* @param {Object} context - contains frame specific info (E.g. tick, width, height, etc)
|
|
91
|
-
*/
|
|
92
|
-
_start(opts: any): Promise<this>;
|
|
46
|
+
/** Starts a render loop if not already running */
|
|
47
|
+
start(): Promise<this>;
|
|
93
48
|
/** Explicitly draw a frame */
|
|
94
49
|
redraw(): this;
|
|
95
50
|
stop(): this;
|
|
@@ -97,17 +52,11 @@ export default class AnimationLoop {
|
|
|
97
52
|
detachTimeline(): void;
|
|
98
53
|
waitForRender(): Promise<AnimationLoop>;
|
|
99
54
|
toDataURL(): Promise<string>;
|
|
100
|
-
|
|
101
|
-
onCreateDevice(deviceProps: DeviceProps): Device;
|
|
55
|
+
onCreateDevice(deviceProps: DeviceProps): Promise<Device>;
|
|
102
56
|
onInitialize(animationProps: AnimationProps): {} | void;
|
|
103
57
|
onRender(animationProps: AnimationProps): void;
|
|
104
58
|
onFinalize(animationProps: AnimationProps): void;
|
|
105
|
-
|
|
106
|
-
onCreateContext(props: ContextProps): WebGLRenderingContext;
|
|
107
|
-
/** @deprecated */
|
|
108
|
-
getHTMLControlValue(id: any, defaultValue?: number): number;
|
|
109
|
-
_initialize(props: AnimationLoopProps): void;
|
|
110
|
-
_getPageLoadPromise(): Promise<{}>;
|
|
59
|
+
_initialize(): void;
|
|
111
60
|
_setDisplay(display: any): void;
|
|
112
61
|
_requestAnimationFrame(): void;
|
|
113
62
|
_cancelAnimationFrame(): void;
|
|
@@ -117,11 +66,8 @@ export default class AnimationLoop {
|
|
|
117
66
|
_setupFrame(): void;
|
|
118
67
|
_initializeCallbackData(): void;
|
|
119
68
|
_updateCallbackData(): void;
|
|
120
|
-
_finalizeCallbackData(): void;
|
|
121
|
-
/** Add application's data to the app context object */
|
|
122
|
-
_addCallbackData(appContext: any): void;
|
|
123
69
|
/** Either uses supplied or existing context, or calls provided callback to create one */
|
|
124
|
-
_createDevice(
|
|
70
|
+
_createDevice(): Promise<void>;
|
|
125
71
|
_createInfoDiv(): void;
|
|
126
72
|
_getSizeAndAspect(): {
|
|
127
73
|
width: number;
|
|
@@ -140,10 +86,5 @@ export default class AnimationLoop {
|
|
|
140
86
|
_startEventHandling(): void;
|
|
141
87
|
_onMousemove(e: any): void;
|
|
142
88
|
_onMouseleave(e: any): void;
|
|
143
|
-
/** @deprecated */
|
|
144
|
-
_createFramebuffer(): void;
|
|
145
|
-
/** @deprecated */
|
|
146
|
-
_resizeFramebuffer(): void;
|
|
147
89
|
}
|
|
148
|
-
export {};
|
|
149
90
|
//# sourceMappingURL=animation-loop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/lib/animation-loop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"animation-loop.d.ts","sourceRoot":"","sources":["../../src/lib/animation-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAS5C,+BAA+B;AAC/B,oBAAY,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,MAAM,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACxD,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;IAElC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IAGd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC,CAAC;AAqBF,gCAAgC;AAChC,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM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