@luma.gl/engine 9.0.0-alpha.14 → 9.0.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/animation/key-frames.d.ts +1 -1
  2. package/dist/animation/key-frames.d.ts.map +1 -1
  3. package/dist/animation/key-frames.js +51 -72
  4. package/dist/animation/timeline.d.ts +4 -4
  5. package/dist/animation/timeline.d.ts.map +1 -1
  6. package/dist/animation/timeline.js +94 -131
  7. package/dist/animation-loop/animation-loop.d.ts +2 -3
  8. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  9. package/dist/animation-loop/animation-loop.js +414 -473
  10. package/dist/animation-loop/animation-props.d.ts +1 -2
  11. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  12. package/dist/animation-loop/animation-props.js +0 -1
  13. package/dist/animation-loop/make-animation-loop.d.ts +1 -1
  14. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  15. package/dist/animation-loop/make-animation-loop.js +26 -31
  16. package/dist/animation-loop/render-loop.js +17 -7
  17. package/dist/bundle.js +2 -2
  18. package/dist/dist.min.js +31 -0
  19. package/dist/es5/animation/key-frames.js +84 -0
  20. package/dist/es5/animation/key-frames.js.map +1 -0
  21. package/dist/es5/animation/timeline.js +183 -0
  22. package/dist/es5/animation/timeline.js.map +1 -0
  23. package/dist/es5/animation-loop/animation-loop.js +534 -0
  24. package/dist/es5/animation-loop/animation-loop.js.map +1 -0
  25. package/dist/es5/animation-loop/animation-props.js +2 -0
  26. package/dist/es5/animation-loop/animation-props.js.map +1 -0
  27. package/dist/es5/animation-loop/make-animation-loop.js +53 -0
  28. package/dist/es5/animation-loop/make-animation-loop.js.map +1 -0
  29. package/dist/es5/animation-loop/render-loop.js +39 -0
  30. package/dist/es5/animation-loop/render-loop.js.map +1 -0
  31. package/dist/es5/bundle.js +6 -0
  32. package/dist/es5/bundle.js.map +1 -0
  33. package/dist/es5/geometries/cone-geometry.js +43 -0
  34. package/dist/es5/geometries/cone-geometry.js.map +1 -0
  35. package/dist/es5/geometries/cube-geometry.js +84 -0
  36. package/dist/es5/geometries/cube-geometry.js.map +1 -0
  37. package/dist/es5/geometries/cylinder-geometry.js +39 -0
  38. package/dist/es5/geometries/cylinder-geometry.js.map +1 -0
  39. package/dist/es5/geometries/ico-sphere-geometry.js +185 -0
  40. package/dist/es5/geometries/ico-sphere-geometry.js.map +1 -0
  41. package/dist/es5/geometries/plane-geometry.js +137 -0
  42. package/dist/es5/geometries/plane-geometry.js.map +1 -0
  43. package/dist/es5/geometries/sphere-geometry.js +120 -0
  44. package/dist/es5/geometries/sphere-geometry.js.map +1 -0
  45. package/dist/es5/geometries/truncated-cone-geometry.js +160 -0
  46. package/dist/es5/geometries/truncated-cone-geometry.js.map +1 -0
  47. package/dist/es5/geometry/geometry-table.js +2 -0
  48. package/dist/es5/geometry/geometry-table.js.map +1 -0
  49. package/dist/es5/geometry/geometry-utils.js +39 -0
  50. package/dist/es5/geometry/geometry-utils.js.map +1 -0
  51. package/dist/es5/geometry/geometry.js +150 -0
  52. package/dist/es5/geometry/geometry.js.map +1 -0
  53. package/dist/es5/geometry/primitive-utils.js +2 -0
  54. package/dist/es5/geometry/primitive-utils.js.map +1 -0
  55. package/dist/es5/index.js +112 -0
  56. package/dist/es5/index.js.map +1 -0
  57. package/dist/es5/lib/clip-space.js +2 -0
  58. package/dist/es5/lib/clip-space.js.map +1 -0
  59. package/dist/es5/lib/model-utils.js +52 -0
  60. package/dist/es5/lib/model-utils.js.map +1 -0
  61. package/dist/es5/lib/model.js +173 -0
  62. package/dist/es5/lib/model.js.map +1 -0
  63. package/dist/es5/lib/pipeline-factory.js +244 -0
  64. package/dist/es5/lib/pipeline-factory.js.map +1 -0
  65. package/dist/esm/animation/key-frames.js +57 -0
  66. package/dist/esm/animation/key-frames.js.map +1 -0
  67. package/dist/esm/animation/timeline.js +113 -0
  68. package/dist/esm/animation/timeline.js.map +1 -0
  69. package/dist/esm/animation-loop/animation-loop.js +367 -0
  70. package/dist/esm/animation-loop/animation-loop.js.map +1 -0
  71. package/dist/esm/animation-loop/animation-props.js +2 -0
  72. package/dist/esm/animation-loop/animation-props.js.map +1 -0
  73. package/dist/esm/animation-loop/make-animation-loop.js +28 -0
  74. package/dist/esm/animation-loop/make-animation-loop.js.map +1 -0
  75. package/dist/esm/animation-loop/render-loop.js +7 -0
  76. package/dist/esm/animation-loop/render-loop.js.map +1 -0
  77. package/dist/esm/bundle.js +4 -0
  78. package/dist/esm/bundle.js.map +1 -0
  79. package/dist/esm/geometries/cone-geometry.js +21 -0
  80. package/dist/esm/geometries/cone-geometry.js.map +1 -0
  81. package/dist/esm/geometries/cube-geometry.js +67 -0
  82. package/dist/esm/geometries/cube-geometry.js.map +1 -0
  83. package/dist/esm/geometries/cylinder-geometry.js +18 -0
  84. package/dist/esm/geometries/cylinder-geometry.js.map +1 -0
  85. package/dist/esm/geometries/ico-sphere-geometry.js +170 -0
  86. package/dist/esm/geometries/ico-sphere-geometry.js.map +1 -0
  87. package/dist/esm/geometries/plane-geometry.js +119 -0
  88. package/dist/esm/geometries/plane-geometry.js.map +1 -0
  89. package/dist/esm/geometries/sphere-geometry.js +102 -0
  90. package/dist/esm/geometries/sphere-geometry.js.map +1 -0
  91. package/dist/esm/geometries/truncated-cone-geometry.js +136 -0
  92. package/dist/esm/geometries/truncated-cone-geometry.js.map +1 -0
  93. package/dist/esm/geometry/geometry-table.js +2 -0
  94. package/dist/esm/geometry/geometry-table.js.map +1 -0
  95. package/dist/esm/geometry/geometry-utils.js +37 -0
  96. package/dist/esm/geometry/geometry-utils.js.map +1 -0
  97. package/dist/esm/geometry/geometry.js +119 -0
  98. package/dist/esm/geometry/geometry.js.map +1 -0
  99. package/dist/esm/geometry/primitive-utils.js +2 -0
  100. package/dist/esm/geometry/primitive-utils.js.map +1 -0
  101. package/dist/esm/index.js +16 -0
  102. package/dist/esm/index.js.map +1 -0
  103. package/dist/esm/lib/clip-space.js +2 -0
  104. package/dist/esm/lib/clip-space.js.map +1 -0
  105. package/dist/esm/lib/model-utils.js +40 -0
  106. package/dist/esm/lib/model-utils.js.map +1 -0
  107. package/dist/esm/lib/model.js +146 -0
  108. package/dist/esm/lib/model.js.map +1 -0
  109. package/dist/esm/lib/pipeline-factory.js +180 -0
  110. package/dist/esm/lib/pipeline-factory.js.map +1 -0
  111. package/dist/geometries/cone-geometry.d.ts +1 -1
  112. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  113. package/dist/geometries/cone-geometry.js +12 -17
  114. package/dist/geometries/cube-geometry.d.ts +1 -1
  115. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  116. package/dist/geometries/cube-geometry.js +187 -56
  117. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  118. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  119. package/dist/geometries/cylinder-geometry.js +10 -14
  120. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  121. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  122. package/dist/geometries/ico-sphere-geometry.js +141 -170
  123. package/dist/geometries/plane-geometry.d.ts +1 -1
  124. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  125. package/dist/geometries/plane-geometry.js +93 -121
  126. package/dist/geometries/sphere-geometry.d.ts +1 -1
  127. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  128. package/dist/geometries/sphere-geometry.js +76 -100
  129. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  130. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  131. package/dist/geometries/truncated-cone-geometry.js +104 -131
  132. package/dist/geometry/geometry-table.d.ts +1 -1
  133. package/dist/geometry/geometry-table.d.ts.map +1 -1
  134. package/dist/geometry/geometry-table.js +0 -1
  135. package/dist/geometry/geometry-utils.js +22 -41
  136. package/dist/geometry/geometry.d.ts +4 -4
  137. package/dist/geometry/geometry.d.ts.map +1 -1
  138. package/dist/geometry/geometry.js +96 -142
  139. package/dist/geometry/primitive-utils.js +30 -1
  140. package/dist/index.js +20 -16
  141. package/dist/lib/clip-space.js +50 -1
  142. package/dist/lib/model-utils.js +97 -29
  143. package/dist/lib/model.d.ts +1 -1
  144. package/dist/lib/model.d.ts.map +1 -1
  145. package/dist/lib/model.js +122 -166
  146. package/dist/lib/pipeline-factory.d.ts +3 -3
  147. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  148. package/dist/lib/pipeline-factory.js +136 -204
  149. package/package.json +12 -11
  150. package/dist/animation/key-frames.js.map +0 -1
  151. package/dist/animation/timeline.js.map +0 -1
  152. package/dist/animation-loop/animation-loop.js.map +0 -1
  153. package/dist/animation-loop/animation-props.js.map +0 -1
  154. package/dist/animation-loop/make-animation-loop.js.map +0 -1
  155. package/dist/animation-loop/render-loop.js.map +0 -1
  156. package/dist/bundle.js.map +0 -1
  157. package/dist/geometries/cone-geometry.js.map +0 -1
  158. package/dist/geometries/cube-geometry.js.map +0 -1
  159. package/dist/geometries/cylinder-geometry.js.map +0 -1
  160. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  161. package/dist/geometries/plane-geometry.js.map +0 -1
  162. package/dist/geometries/sphere-geometry.js.map +0 -1
  163. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  164. package/dist/geometry/geometry-table.js.map +0 -1
  165. package/dist/geometry/geometry-utils.js.map +0 -1
  166. package/dist/geometry/geometry.js.map +0 -1
  167. package/dist/geometry/primitive-utils.js.map +0 -1
  168. package/dist/index.js.map +0 -1
  169. package/dist/lib/clip-space.js.map +0 -1
  170. package/dist/lib/model-utils.js.map +0 -1
  171. package/dist/lib/model.js.map +0 -1
  172. package/dist/lib/pipeline-factory.js.map +0 -1
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _api = require("@luma.gl/api");
13
+ var _constants = _interopRequireDefault(require("@luma.gl/constants"));
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ var Geometry = function () {
17
+ function Geometry() {
18
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19
+ (0, _classCallCheck2.default)(this, Geometry);
20
+ (0, _defineProperty2.default)(this, "id", void 0);
21
+ (0, _defineProperty2.default)(this, "userData", {});
22
+ (0, _defineProperty2.default)(this, "topology", void 0);
23
+ (0, _defineProperty2.default)(this, "drawMode", _constants.default.TRIANGLES);
24
+ (0, _defineProperty2.default)(this, "vertexCount", void 0);
25
+ (0, _defineProperty2.default)(this, "attributes", void 0);
26
+ (0, _defineProperty2.default)(this, "indices", void 0);
27
+ var _props$id = props.id,
28
+ id = _props$id === void 0 ? (0, _api.uid)('geometry') : _props$id,
29
+ _props$drawMode = props.drawMode,
30
+ drawMode = _props$drawMode === void 0 ? _constants.default.TRIANGLES : _props$drawMode,
31
+ _props$attributes = props.attributes,
32
+ attributes = _props$attributes === void 0 ? {} : _props$attributes,
33
+ _props$indices = props.indices,
34
+ indices = _props$indices === void 0 ? null : _props$indices,
35
+ _props$vertexCount = props.vertexCount,
36
+ vertexCount = _props$vertexCount === void 0 ? null : _props$vertexCount;
37
+ this.id = id;
38
+ this.drawMode = drawMode;
39
+ this.topology = props.topology || convertToTopology(drawMode);
40
+ if (indices) {
41
+ this.indices = ArrayBuffer.isView(indices) ? {
42
+ value: indices,
43
+ size: 1
44
+ } : indices;
45
+ }
46
+ this.attributes = {};
47
+ for (var _i = 0, _Object$entries = Object.entries(attributes); _i < _Object$entries.length; _i++) {
48
+ var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
49
+ attributeName = _Object$entries$_i[0],
50
+ attributeValue = _Object$entries$_i[1];
51
+ var attribute = ArrayBuffer.isView(attributeValue) ? {
52
+ value: attributeValue
53
+ } : attributeValue;
54
+ (0, _api.assert)(ArrayBuffer.isView(attribute.value), "".concat(this._print(attributeName), ": must be typed array or object with value as typed array"));
55
+ if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
56
+ attribute.size = 3;
57
+ }
58
+ if (attributeName === 'indices') {
59
+ (0, _api.assert)(!this.indices);
60
+ this.indices = attribute;
61
+ } else {
62
+ this.attributes[attributeName] = attribute;
63
+ }
64
+ }
65
+ if (this.indices && this.indices.isIndexed !== undefined) {
66
+ this.indices = Object.assign({}, this.indices);
67
+ delete this.indices.isIndexed;
68
+ }
69
+ this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
70
+ }
71
+ (0, _createClass2.default)(Geometry, [{
72
+ key: "mode",
73
+ get: function get() {
74
+ return this.drawMode;
75
+ }
76
+ }, {
77
+ key: "getVertexCount",
78
+ value: function getVertexCount() {
79
+ return this.vertexCount;
80
+ }
81
+ }, {
82
+ key: "getAttributes",
83
+ value: function getAttributes() {
84
+ return this.indices ? _objectSpread({
85
+ indices: this.indices
86
+ }, this.attributes) : this.attributes;
87
+ }
88
+ }, {
89
+ key: "_print",
90
+ value: function _print(attributeName) {
91
+ return "Geometry ".concat(this.id, " attribute ").concat(attributeName);
92
+ }
93
+ }, {
94
+ key: "_setAttributes",
95
+ value: function _setAttributes(attributes, indices) {
96
+ return this;
97
+ }
98
+ }, {
99
+ key: "_calculateVertexCount",
100
+ value: function _calculateVertexCount(attributes, indices) {
101
+ if (indices) {
102
+ return indices.value.length;
103
+ }
104
+ var vertexCount = Infinity;
105
+ for (var attributeName in attributes) {
106
+ var attribute = attributes[attributeName];
107
+ var value = attribute.value,
108
+ size = attribute.size,
109
+ constant = attribute.constant;
110
+ if (!constant && value && size >= 1) {
111
+ vertexCount = Math.min(vertexCount, value.length / size);
112
+ }
113
+ }
114
+ (0, _api.assert)(Number.isFinite(vertexCount));
115
+ return vertexCount;
116
+ }
117
+ }]);
118
+ return Geometry;
119
+ }();
120
+ exports.default = Geometry;
121
+ (0, _defineProperty2.default)(Geometry, "DRAW_MODE", {
122
+ POINTS: _constants.default.POINTS,
123
+ LINES: _constants.default.LINES,
124
+ LINE_LOOP: _constants.default.LINE_LOOP,
125
+ LINE_STRIP: _constants.default.LINE_STRIP,
126
+ TRIANGLES: _constants.default.TRIANGLES,
127
+ TRIANGLE_STRIP: _constants.default.TRIANGLE_STRIP,
128
+ TRIANGLE_FAN: _constants.default.TRIANGLE_FAN
129
+ });
130
+ function convertToTopology(drawMode) {
131
+ switch (drawMode) {
132
+ case _constants.default.POINTS:
133
+ return 'point-list';
134
+ case _constants.default.LINES:
135
+ return 'line-list';
136
+ case _constants.default.LINE_STRIP:
137
+ return 'line-strip';
138
+ case _constants.default.TRIANGLES:
139
+ return 'triangle-list';
140
+ case _constants.default.TRIANGLE_STRIP:
141
+ return 'triangle-strip';
142
+ case _constants.default.TRIANGLE_FAN:
143
+ return 'triangle-fan';
144
+ case _constants.default.LINE_LOOP:
145
+ return 'line-loop';
146
+ default:
147
+ throw new Error(String(drawMode));
148
+ }
149
+ }
150
+ //# sourceMappingURL=geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.js","names":["_api","require","_constants","_interopRequireDefault","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","Geometry","props","undefined","_classCallCheck2","GL","TRIANGLES","_props$id","id","uid","_props$drawMode","drawMode","_props$attributes","attributes","_props$indices","indices","_props$vertexCount","vertexCount","topology","convertToTopology","ArrayBuffer","isView","value","size","_i","_Object$entries","entries","_Object$entries$_i","_slicedToArray2","attributeName","attributeValue","attribute","assert","concat","_print","isIndexed","assign","_calculateVertexCount","_createClass2","get","getVertexCount","getAttributes","_setAttributes","Infinity","constant","Math","min","Number","isFinite","exports","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLE_STRIP","TRIANGLE_FAN","Error","String"],"sources":["../../../src/geometry/geometry.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {PrimitiveTopology, TypedArray} from '@luma.gl/api';\nimport {uid, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n/**\n * Rendering primitives - \"topology\" specifies how to extract primitives from vertices.\n * @deprecated - use string constants instead\n */\nexport type GLTopology =\n GL.POINTS | // draw single points.\n GL.LINES | // draw lines. Each vertex connects to the one after it.\n GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.\n GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last\n GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.\n GL.TRIANGLE_STRIP | // draw a connected group of triangles.\n GL.TRIANGLE_FAN // draw a connected group of triangles.\n ;\n\nexport type GeometryAttribute = {\n size?: number;\n value: TypedArray;\n [key: string]: any\n}\n\nexport type GeometryProps = {\n id?: string;\n attributes?: Record<string, GeometryAttribute | TypedArray>,\n indices?: GeometryAttribute | TypedArray;\n vertexCount?: number;\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';\n /** @deprecated */\n drawMode?: GLTopology;\n};\n\ntype GeometryAttributes = {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n indices?: {size?: number, value: Uint32Array | Uint16Array};\n};\n\nexport default class Geometry {\n /** @deprecated */\n static DRAW_MODE = {\n POINTS: GL.POINTS, // draw single points.\n LINES: GL.LINES, // draw lines. Each vertex connects to the one after it.\n LINE_LOOP: GL.LINE_LOOP, // draw lines. Each set of two vertices is treated as a separate line segment.\n LINE_STRIP: GL.LINE_STRIP, // draw a connected group of line segments from the first vertex to the last\n TRIANGLES: GL.TRIANGLES, // draw triangles. Each set of three vertices creates a separate triangle.\n TRIANGLE_STRIP: GL.TRIANGLE_STRIP, // draw a connected group of triangles.\n TRIANGLE_FAN: GL.TRIANGLE_FAN // draw a connected group of triangles.\n };\n\n readonly id: string;\n userData: Record<string, unknown> = {};\n\n /** Determines how vertices are read from the 'vertex' attributes */\n topology?: PrimitiveTopology;\n /** @deprecated */\n readonly drawMode: GLTopology = GL.TRIANGLES;\n\n readonly vertexCount: number;\n readonly attributes: {\n POSITION: GeometryAttribute,\n NORMAL: GeometryAttribute,\n TEXCOORD_0: GeometryAttribute,\n COLOR_0?: GeometryAttribute,\n [key: string]: GeometryAttribute | undefined\n };\n readonly indices?: Uint16Array | Uint32Array;\n\n constructor(props: GeometryProps = {}) {\n const {\n id = uid('geometry'),\n drawMode = GL.TRIANGLES,\n attributes = {},\n indices = null,\n vertexCount = null\n } = props;\n\n this.id = id;\n this.drawMode = drawMode;\n this.topology = props.topology || convertToTopology(drawMode);\n\n if (indices) {\n // @ts-expect-error\n this.indices = ArrayBuffer.isView(indices) ? {value: indices, size: 1} : indices;\n }\n\n // @ts-expect-error\n this.attributes = {};\n\n for (const [attributeName, attributeValue] of Object.entries(attributes)) {\n\n // Wrap \"unwrapped\" arrays and try to autodetect their type\n const attribute: GeometryAttribute = ArrayBuffer.isView(attributeValue) ? {value: attributeValue} : attributeValue;\n\n assert(\n ArrayBuffer.isView(attribute.value),\n `${this._print(attributeName)}: must be typed array or object with value as typed array`\n );\n\n if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {\n attribute.size = 3;\n }\n\n // Move indices to separate field\n if (attributeName === 'indices') {\n assert(!this.indices);\n // @ts-expect-error\n this.indices = attribute;\n } else {\n this.attributes[attributeName] = attribute;\n }\n }\n\n // @ts-expect-error\n if (this.indices && this.indices.isIndexed !== undefined) {\n this.indices = Object.assign({}, this.indices);\n // @ts-expect-error\n delete this.indices.isIndexed;\n }\n\n this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);\n }\n\n /** @deprecated Use string topology constants instead */\n get mode() {\n return this.drawMode;\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n // Return an object with all attributes plus indices added as a field.\n getAttributes(): GeometryAttributes {\n // @ts-expect-error Geometry types are a mess\n return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;\n }\n\n // PRIVATE\n\n _print(attributeName: string): string {\n return `Geometry ${this.id} attribute ${attributeName}`;\n }\n\n // GeometryAttribute\n // value: typed array\n // type: indices, vertices, uvs\n // size: elements per vertex\n // target: WebGL buffer type (string or constant)\n _setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this {\n\n return this;\n }\n\n _calculateVertexCount(attributes: any, indices: any): number {\n if (indices) {\n return indices.value.length;\n }\n let vertexCount = Infinity;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const {value, size, constant} = attribute;\n if (!constant && value && size >= 1) {\n vertexCount = Math.min(vertexCount, value.length / size);\n }\n }\n\n assert(Number.isFinite(vertexCount));\n return vertexCount;\n }\n}\n\nfunction convertToTopology(drawMode: GLTopology): PrimitiveTopology {\n switch (drawMode) {\n case GL.POINTS: return 'point-list'; // draw single points.\n case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.\n case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last\n case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.\n case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.\n\n case GL.TRIANGLE_FAN: return 'triangle-fan'; // draw a connected group of triangles.\n case GL.LINE_LOOP: return 'line-loop'; // draw lines. Each set of two vertices is treated as a separate line segment.\n default:\n throw new Error(String(drawMode));\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAoC,SAAAG,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,E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AACgD,UAAU;MAAE,OAAO,YAAY;IACvC,KAAKhD,kBAAE,CAACC,SAAS;MAAE,OAAO,eAAe;IACzC,KAAKD,kBAAE,CAACiD,cAAc;MAAE,OAAO,gBAAgB;IAE/C,KAAKjD,kBAAE,CAACkD,YAAY;MAAE,OAAO,cAAc;IAC3C,KAAKlD,kBAAE,CAAC+C,SAAS;MAAE,OAAO,WAAW;IACrC;MACE,MAAM,IAAII,KAAK,CAACC,MAAM,CAAC9C,QAAQ,CAAC,CAAC;EAAC;AAExC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=primitive-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive-utils.js","names":[],"sources":["../../../src/geometry/primitive-utils.ts"],"sourcesContent":["/*\nimport type {GeometryTable} from './geometry-table';\n\nexport function unpackIndexedGeometry(geometry: GeometryTable): GeometryTable {\n const {indices, attributes} = geometry;\n if (!indices) {\n return geometry;\n }\n\n const vertexCount = indices.length;\n const unpackedAttributes = {};\n\n for (const [name, values] of Object.entries(attributes)) {\n const size = {POSITION: 3, NORMAL: 3, TEX_COORD0: 2}[name];\n const unpackedValues = new values.constructor(length * size);\n for (let x = 0; x < vertexCount; ++x) {\n const index = indices[x];\n for (let i = 0; i < size; i++) {\n unpackedValues[x * size + i] = values[index * size + i];\n }\n }\n unpackedAttributes[name] = unpackedValues;\n }\n\n return {\n length,\n attributes: unpackedAttributes\n };\n}\n*/"],"mappings":""}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "AnimationLoop", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _animationLoop.AnimationLoop;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "AnimationLoopTemplate", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _renderLoop.AnimationLoopTemplate;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "ConeGeometry", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _coneGeometry.ConeGeometry;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "CubeGeometry", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _cubeGeometry.CubeGeometry;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "CylinderGeometry", {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _cylinderGeometry.CylinderGeometry;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "Geometry", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _geometry.default;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "IcoSphereGeometry", {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _icoSphereGeometry.IcoSphereGeometry;
47
+ }
48
+ });
49
+ Object.defineProperty(exports, "KeyFrames", {
50
+ enumerable: true,
51
+ get: function get() {
52
+ return _keyFrames.KeyFrames;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "Model", {
56
+ enumerable: true,
57
+ get: function get() {
58
+ return _model.Model;
59
+ }
60
+ });
61
+ Object.defineProperty(exports, "PipelineFactory", {
62
+ enumerable: true,
63
+ get: function get() {
64
+ return _pipelineFactory.PipelineFactory;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "PlaneGeometry", {
68
+ enumerable: true,
69
+ get: function get() {
70
+ return _planeGeometry.PlaneGeometry;
71
+ }
72
+ });
73
+ Object.defineProperty(exports, "SphereGeometry", {
74
+ enumerable: true,
75
+ get: function get() {
76
+ return _sphereGeometry.SphereGeometry;
77
+ }
78
+ });
79
+ Object.defineProperty(exports, "Timeline", {
80
+ enumerable: true,
81
+ get: function get() {
82
+ return _timeline.Timeline;
83
+ }
84
+ });
85
+ Object.defineProperty(exports, "TruncatedConeGeometry", {
86
+ enumerable: true,
87
+ get: function get() {
88
+ return _truncatedConeGeometry.TruncatedConeGeometry;
89
+ }
90
+ });
91
+ Object.defineProperty(exports, "makeAnimationLoop", {
92
+ enumerable: true,
93
+ get: function get() {
94
+ return _makeAnimationLoop.makeAnimationLoop;
95
+ }
96
+ });
97
+ var _timeline = require("./animation/timeline");
98
+ var _keyFrames = require("./animation/key-frames");
99
+ var _renderLoop = require("./animation-loop/render-loop");
100
+ var _animationLoop = require("./animation-loop/animation-loop");
101
+ var _makeAnimationLoop = require("./animation-loop/make-animation-loop");
102
+ var _model = require("./lib/model");
103
+ var _pipelineFactory = require("./lib/pipeline-factory");
104
+ var _geometry = _interopRequireDefault(require("./geometry/geometry"));
105
+ var _coneGeometry = require("./geometries/cone-geometry");
106
+ var _cubeGeometry = require("./geometries/cube-geometry");
107
+ var _cylinderGeometry = require("./geometries/cylinder-geometry");
108
+ var _icoSphereGeometry = require("./geometries/ico-sphere-geometry");
109
+ var _planeGeometry = require("./geometries/plane-geometry");
110
+ var _sphereGeometry = require("./geometries/sphere-geometry");
111
+ var _truncatedConeGeometry = require("./geometries/truncated-cone-geometry");
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_timeline","require","_keyFrames","_renderLoop","_animationLoop","_makeAnimationLoop","_model","_pipelineFactory","_geometry","_interopRequireDefault","_coneGeometry","_cubeGeometry","_cylinderGeometry","_icoSphereGeometry","_planeGeometry","_sphereGeometry","_truncatedConeGeometry"],"sources":["../../src/index.ts"],"sourcesContent":["// luma.gl Engine API\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\nexport type {AnimationProps} from './animation-loop/animation-props';\n\nexport {AnimationLoopTemplate} from './animation-loop/render-loop';\n\nexport type {AnimationLoopProps} from './animation-loop/animation-loop';\nexport {AnimationLoop} from './animation-loop/animation-loop';\n\nexport type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';\nexport {makeAnimationLoop} from './animation-loop/make-animation-loop';\n\nexport type {ModelProps} from './lib/model';\nexport {Model} from './lib/model';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGA,IAAAE,WAAA,GAAAF,OAAA;AAGA,IAAAG,cAAA,GAAAH,OAAA;AAGA,IAAAI,kBAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,gBAAA,GAAAN,OAAA;AAMA,IAAAO,SAAA,GAAAC,sBAAA,CAAAR,OAAA;AAIA,IAAAS,aAAA,GAAAT,OAAA;AAEA,IAAAU,aAAA,GAAAV,OAAA;AAEA,IAAAW,iBAAA,GAAAX,OAAA;AAEA,IAAAY,kBAAA,GAAAZ,OAAA;AAEA,IAAAa,cAAA,GAAAb,OAAA;AAEA,IAAAc,eAAA,GAAAd,OAAA;AAEA,IAAAe,sBAAA,GAAAf,OAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=clip-space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip-space.js","names":[],"sources":["../../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\n/*\nimport GL from '@luma.gl/constants';\nimport Model, {ModelProps} from './model';\nimport Geometry from '../geometry/geometry';\n\nconst CLIPSPACE_VERTEX_SHADER = glsl`\\\nattribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n`;\n\n/* eslint-disable indent, no-multi-spaces *\nconst POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];\n\n\nexport default class ClipSpace extends Model {\n constructor(gl: WebGLRenderingContext, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n gl,\n Object.assign({}, opts, {\n vs: CLIPSPACE_VERTEX_SHADER,\n geometry: new Geometry({\n drawMode: GL.TRIANGLE_STRIP,\n vertexCount: 4,\n attributes: {\n aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},\n aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},\n aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}\n }\n })\n })\n );\n this.setVertexCount(4);\n }\n}\n*/"],"mappings":""}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getAttributeBuffersFromGeometry = getAttributeBuffersFromGeometry;
8
+ exports.getIndexBufferFromGeometry = getIndexBufferFromGeometry;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _api = require("@luma.gl/api");
11
+ var GLTF_TO_LUMA_ATTRIBUTE_MAP = {
12
+ POSITION: 'positions',
13
+ NORMAL: 'normals',
14
+ COLOR_0: 'colors',
15
+ TEXCOORD_0: 'texCoords',
16
+ TEXCOORD_1: 'texCoords1',
17
+ TEXCOORD_2: 'texCoords2'
18
+ };
19
+ function getIndexBufferFromGeometry(device, geometry) {
20
+ if (!geometry.indices) {
21
+ return undefined;
22
+ }
23
+ var data = geometry.indices.value || geometry.indices;
24
+ (0, _api.assert)(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
25
+ return device.createBuffer({
26
+ usage: _api.Buffer.INDEX,
27
+ data: data
28
+ });
29
+ }
30
+ function getAttributeBuffersFromGeometry(device, geometry) {
31
+ var buffers = {};
32
+ for (var _i = 0, _Object$entries = Object.entries(geometry.attributes); _i < _Object$entries.length; _i++) {
33
+ var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
34
+ name = _Object$entries$_i[0],
35
+ attribute = _Object$entries$_i[1];
36
+ var remappedName = mapAttributeName(name);
37
+ if (attribute !== null && attribute !== void 0 && attribute.constant) {
38
+ throw new Error('constant attributes not supported');
39
+ } else {
40
+ var typedArray = attribute === null || attribute === void 0 ? void 0 : attribute.value;
41
+ buffers[remappedName] = device.createBuffer({
42
+ data: typedArray,
43
+ id: "".concat(remappedName, "-buffer")
44
+ });
45
+ }
46
+ }
47
+ return buffers;
48
+ }
49
+ function mapAttributeName(name) {
50
+ return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
51
+ }
52
+ //# sourceMappingURL=model-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-utils.js","names":["_api","require","GLTF_TO_LUMA_ATTRIBUTE_MAP","POSITION","NORMAL","COLOR_0","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","getIndexBufferFromGeometry","device","geometry","indices","undefined","data","value","assert","Uint16Array","Uint32Array","createBuffer","usage","Buffer","INDEX","getAttributeBuffersFromGeometry","buffers","_i","_Object$entries","Object","entries","attributes","length","_Object$entries$_i","_slicedToArray2","default","name","attribute","remappedName","mapAttributeName","constant","Error","typedArray","id","concat"],"sources":["../../../src/lib/model-utils.ts"],"sourcesContent":["import {Device, Buffer, assert} from '@luma.gl/api';\nimport type Geometry from '../geometry/geometry';\n\n// Support for mapping new geometries with glTF attribute names to \"classic\" luma.gl shader names\nconst GLTF_TO_LUMA_ATTRIBUTE_MAP = {\n POSITION: 'positions',\n NORMAL: 'normals',\n COLOR_0: 'colors',\n TEXCOORD_0: 'texCoords',\n TEXCOORD_1: 'texCoords1',\n TEXCOORD_2: 'texCoords2'\n};\n\n/*\nexport function getAttributeLayoutsFromGeometry(geometry: Geometry) {\n const layouts: Record<string, {}> = {};\n let indices = geometry.indices;\n\n for (const [name, attribute] of Object.entries(geometry.attributes)) {\n const remappedName = mapAttributeName(name);\n\n if (attribute.constant) {\n throw new Error('constant attributes not supported');\n } else {\n const typedArray = attribute.value;\n // Create accessor by copying the attribute and removing `value``\n const accessor = {...attribute};\n delete accessor.value;\n buffers[remappedName] = [device.createBuffer(typedArray), accessor];\n\n inferAttributeAccessor(name, accessor);\n }\n }\n}\n\nexport class Table {\n length: number;\n // columns: Record<string, TypedArray> = {};\n}\n\nexport class GPUTable {\n length: number;\n columns: Record<string, Buffer> = {};\n}\n\nexport function convertTableToGPUTable(table: Table) {\n // for (const ) {}\n}\n\nexport function renameTableColumns(table: Table, map: (name: string) => string) {\n const newColumns = table.columns.reduce()\n table.clone();\n}\n*/\n\nexport function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined {\n if (!geometry.indices) {\n return undefined;\n }\n\n // @ts-expect-error\n const data = geometry.indices.value || geometry.indices;\n assert(\n data instanceof Uint16Array || data instanceof Uint32Array,\n 'attribute array for \"indices\" must be of integer type'\n );\n return device.createBuffer({usage: Buffer.INDEX, data});\n}\n\nexport function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer> {\n const buffers: Record<string, Buffer> = {};\n\n for (const [name, attribute] of Object.entries(geometry.attributes)) {\n const remappedName = mapAttributeName(name);\n if (attribute?.constant) {\n throw new Error('constant attributes not supported');\n } else {\n const typedArray = attribute?.value;\n buffers[remappedName] = device.createBuffer({data: typedArray, id: `${remappedName}-buffer`});\n }\n }\n\n return buffers;\n}\n\nfunction mapAttributeName(name: string): string {\n // @ts-ignore-error\n return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;\n}\n\n/*\n// Check for well known attribute names\n// eslint-disable-next-line complexity\nexport function inferAttributeAccessor(attributeName, attribute) {\n let category;\n switch (attributeName) {\n case 'texCoords':\n case 'texCoord1':\n case 'texCoord2':\n case 'texCoord3':\n category = 'uvs';\n break;\n case 'vertices':\n case 'positions':\n case 'normals':\n case 'pickingColors':\n category = 'vectors';\n break;\n default:\n }\n\n // Check for categorys\n switch (category) {\n case 'vectors':\n attribute.size = attribute.size || 3;\n break;\n case 'uvs':\n attribute.size = attribute.size || 2;\n break;\n default:\n }\n\n assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);\n}\n*/\n"],"mappings":";;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAIA,IAAMC,0BAA0B,GAAG;EACjCC,QAAQ,EAAE,WAAW;EACrBC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,QAAQ;EACjBC,UAAU,EAAE,WAAW;EACvBC,UAAU,EAAE,YAAY;EACxBC,UAAU,EAAE;AACd,CAAC;AA4CM,SAASC,0BAA0BA,CAACC,MAAc,EAAEC,QAAkB,EAAsB;EACjG,IAAI,CAACA,QAAQ,CAACC,OAAO,EAAE;IACrB,OAAOC,SAAS;EAClB;EAGA,IAAMC,IAAI,GAAGH,QAAQ,CAACC,OAAO,CAACG,KAAK,IAAIJ,QAAQ,CAACC,OAAO;EACvD,IAAAI,WAAM,EACJF,IAAI,YAAYG,WAAW,IAAIH,IAAI,YAAYI,WAAW,EAC1D,uDAAuD,CACxD;EACD,OAAOR,MAAM,CAACS,YAAY,CAAC;IAACC,KAAK,EAAEC,WAAM,CAACC,KAAK;IAAER,IAAI,EAAJA;EAAI,CAAC,CAAC;AACzD;AAEO,SAASS,+BAA+BA,CAACb,MAAc,EAAEC,QAAkB,EAA0B;EAC1G,IAAMa,OAA+B,GAAG,CAAC,CAAC;EAE1C,SAAAC,EAAA,MAAAC,eAAA,GAAgCC,MAAM,CAACC,OAAO,CAACjB,QAAQ,CAACkB,UAAU,CAAC,EAAAJ,EAAA,GAAAC,eAAA,CAAAI,MAAA,EAAAL,EAAA,IAAE;IAAhE,IAAAM,kBAAA,OAAAC,eAAA,CAAAC,OAAA,EAAAP,eAAA,CAAAD,EAAA;MAAOS,IAAI,GAAAH,kBAAA;MAAEI,SAAS,GAAAJ,kBAAA;IACzB,IAAMK,YAAY,GAAGC,gBAAgB,CAACH,IAAI,CAAC;IAC3C,IAAIC,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEG,QAAQ,EAAE;MACvB,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC;IACtD,CAAC,MAAM;MACL,IAAMC,UAAU,GAAGL,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEpB,KAAK;MACnCS,OAAO,CAACY,YAAY,CAAC,GAAG1B,MAAM,CAACS,YAAY,CAAC;QAACL,IAAI,EAAE0B,UAAU;QAAEC,EAAE,KAAAC,MAAA,CAAKN,YAAY;MAAS,CAAC,CAAC;IAC/F;EACF;EAEA,OAAOZ,OAAO;AAChB;AAEA,SAASa,gBAAgBA,CAACH,IAAY,EAAU;EAE9C,OAAOhC,0BAA0B,CAACgC,IAAI,CAAC,IAAIA,IAAI;AACjD"}
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Model = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _api = require("@luma.gl/api");
12
+ var _modelUtils = require("./model-utils");
13
+ var _pipelineFactory = require("./pipeline-factory");
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ var DEFAULT_MODEL_PROPS = _objectSpread(_objectSpread({}, _api.RenderPipeline._DEFAULT_PROPS), {}, {
17
+ vs: null,
18
+ fs: null,
19
+ id: 'unnamed',
20
+ handle: undefined,
21
+ userData: {},
22
+ modules: [],
23
+ moduleSettings: {},
24
+ geometry: null
25
+ });
26
+ var Model = function () {
27
+ function Model(device, props) {
28
+ (0, _classCallCheck2.default)(this, Model);
29
+ (0, _defineProperty2.default)(this, "device", void 0);
30
+ (0, _defineProperty2.default)(this, "pipeline", void 0);
31
+ (0, _defineProperty2.default)(this, "id", void 0);
32
+ (0, _defineProperty2.default)(this, "vs", void 0);
33
+ (0, _defineProperty2.default)(this, "fs", null);
34
+ (0, _defineProperty2.default)(this, "topology", void 0);
35
+ (0, _defineProperty2.default)(this, "vertexCount", void 0);
36
+ (0, _defineProperty2.default)(this, "props", void 0);
37
+ (0, _defineProperty2.default)(this, "_getModuleUniforms", void 0);
38
+ this.props = _objectSpread(_objectSpread({}, DEFAULT_MODEL_PROPS), props);
39
+ props = this.props;
40
+ this.id = this.props.id;
41
+ this.device = device;
42
+ if (!props.vs) {
43
+ throw new Error('no vertex shader');
44
+ }
45
+ this.vs = getShaderSource(this.device, props.vs);
46
+ if (props.fs) {
47
+ this.fs = getShaderSource(this.device, props.fs);
48
+ }
49
+ this.vertexCount = this.props.vertexCount;
50
+ this.topology = this.props.topology;
51
+ if (this.props.geometry) {
52
+ this.vertexCount = this.props.geometry.vertexCount;
53
+ this.topology = this.props.geometry.topology || 'triangle-list';
54
+ }
55
+ var pipelineFactory = _pipelineFactory.PipelineFactory.getDefaultPipelineFactory(this.device);
56
+ var _pipelineFactory$crea = pipelineFactory.createRenderPipeline(_objectSpread(_objectSpread({}, this.props), {}, {
57
+ vs: this.vs,
58
+ fs: this.fs,
59
+ topology: this.topology,
60
+ parameters: props.parameters,
61
+ layout: props.layout
62
+ })),
63
+ pipeline = _pipelineFactory$crea.pipeline,
64
+ getUniforms = _pipelineFactory$crea.getUniforms;
65
+ this.pipeline = pipeline;
66
+ this._getModuleUniforms = getUniforms;
67
+ if (this.props.geometry) {
68
+ this._setGeometry(this.props.geometry);
69
+ }
70
+ this.setUniforms(this._getModuleUniforms());
71
+ this.setProps(this.props);
72
+ }
73
+ (0, _createClass2.default)(Model, [{
74
+ key: "destroy",
75
+ value: function destroy() {
76
+ this.pipeline.destroy();
77
+ }
78
+ }, {
79
+ key: "draw",
80
+ value: function draw(renderPass) {
81
+ this.pipeline.draw({
82
+ renderPass: renderPass,
83
+ vertexCount: this.vertexCount,
84
+ instanceCount: this.props.instanceCount
85
+ });
86
+ return this;
87
+ }
88
+ }, {
89
+ key: "setProps",
90
+ value: function setProps(props) {
91
+ if (props.indices) {
92
+ this.setIndexBuffer(props.indices);
93
+ }
94
+ if (props.attributes) {
95
+ this.setAttributes(props.attributes);
96
+ }
97
+ if (props.bindings) {
98
+ this.setBindings(props.bindings);
99
+ }
100
+ if (props.uniforms) {
101
+ this.setUniforms(props.uniforms);
102
+ }
103
+ if (props.moduleSettings) {
104
+ this.updateModuleSettings(props.moduleSettings);
105
+ }
106
+ return this;
107
+ }
108
+ }, {
109
+ key: "updateModuleSettings",
110
+ value: function updateModuleSettings(props) {
111
+ var uniforms = this._getModuleUniforms(props);
112
+ this.setUniforms(uniforms);
113
+ return this;
114
+ }
115
+ }, {
116
+ key: "setIndexBuffer",
117
+ value: function setIndexBuffer(indices) {
118
+ this.pipeline.setIndexBuffer(indices);
119
+ return this;
120
+ }
121
+ }, {
122
+ key: "setAttributes",
123
+ value: function setAttributes(attributes) {
124
+ this.pipeline.setAttributes(attributes);
125
+ Object.assign(this.props.attributes, attributes);
126
+ return this;
127
+ }
128
+ }, {
129
+ key: "setBindings",
130
+ value: function setBindings(bindings) {
131
+ this.pipeline.setBindings(bindings);
132
+ Object.assign(this.props.bindings, bindings);
133
+ return this;
134
+ }
135
+ }, {
136
+ key: "setUniforms",
137
+ value: function setUniforms(uniforms) {
138
+ this.pipeline.setUniforms(uniforms);
139
+ Object.assign(this.props.uniforms, uniforms);
140
+ return this;
141
+ }
142
+ }, {
143
+ key: "_setGeometry",
144
+ value: function _setGeometry(geometry) {
145
+ var geometryBuffers = (0, _modelUtils.getAttributeBuffersFromGeometry)(this.device, geometry);
146
+ this.setAttributes(geometryBuffers);
147
+ var indexBuffer = (0, _modelUtils.getIndexBufferFromGeometry)(this.device, geometry);
148
+ if (indexBuffer) {
149
+ this.setIndexBuffer(indexBuffer);
150
+ }
151
+ }
152
+ }]);
153
+ return Model;
154
+ }();
155
+ exports.Model = Model;
156
+ function getShaderSource(device, shader) {
157
+ if (typeof shader === 'string') {
158
+ return shader;
159
+ }
160
+ switch (device.info.type) {
161
+ case 'webgpu':
162
+ if (shader !== null && shader !== void 0 && shader.wgsl) {
163
+ return shader.wgsl;
164
+ }
165
+ throw new Error('WebGPU does not support GLSL shaders');
166
+ default:
167
+ if (shader !== null && shader !== void 0 && shader.glsl) {
168
+ return shader.glsl;
169
+ }
170
+ throw new Error('WebGL does not support WGSL shaders');
171
+ }
172
+ }
173
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":["_api","require","_modelUtils","_pipelineFactory","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DEFAULT_MODEL_PROPS","RenderPipeline","_DEFAULT_PROPS","vs","fs","id","handle","undefined","userData","modules","moduleSettings","geometry","Model","device","props","_classCallCheck2","Error","getShaderSource","vertexCount","topology","pipelineFactory","PipelineFactory","getDefaultPipelineFactory","_pipelineFactory$crea","createRenderPipeline","parameters","layout","pipeline","getUniforms","_getModuleUniforms","_setGeometry","setUniforms","setProps","_createClass2","value","destroy","draw","renderPass","instanceCount","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","updateModuleSettings","assign","geometryBuffers","getAttributeBuffersFromGeometry","indexBuffer","getIndexBufferFromGeometry","exports","shader","info","type","wgsl","glsl"],"sources":["../../../src/lib/model.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, Buffer, RenderPipelineProps, RenderPass, Binding, PrimitiveTopology} from '@luma.gl/api';\nimport {RenderPipeline} from '@luma.gl/api';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport type Geometry from '../geometry/geometry';\nimport {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';\nimport {PipelineFactory} from './pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string\n vs?: {glsl?: string; wgsl?: string} | string | null;\n fs?: {glsl?: string; wgsl?: string} | string | null;\n modules?: ShaderModule[];\n moduleSettings?: Record<string, Record<string, any>>;\n geometry?: Geometry | null;\n};\n\nconst DEFAULT_MODEL_PROPS: Required<ModelProps> = {\n ...RenderPipeline._DEFAULT_PROPS,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n modules: [],\n moduleSettings: {},\n geometry: null\n};\n\n/** v9 API */\nexport class Model {\n readonly device: Device;\n readonly pipeline: RenderPipeline;\n readonly id: string;\n readonly vs: string;\n readonly fs: string | null = null;\n readonly topology: PrimitiveTopology;\n readonly vertexCount;\n props: Required<ModelProps>;\n\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...DEFAULT_MODEL_PROPS, ...props};\n props = this.props;\n this.id = this.props.id;\n this.device = device;\n\n // Create the pipeline\n if (!props.vs) {\n throw new Error('no vertex shader');\n }\n this.vs = getShaderSource(this.device, props.vs);\n if (props.fs) {\n this.fs = getShaderSource(this.device, props.fs);\n }\n\n this.vertexCount = this.props.vertexCount;\n this.topology = this.props.topology;\n\n if (this.props.geometry) {\n this.vertexCount = this.props.geometry.vertexCount;\n this.topology = this.props.geometry.topology || 'triangle-list';\n }\n\n const pipelineFactory = PipelineFactory.getDefaultPipelineFactory(this.device);\n const {pipeline, getUniforms} = pipelineFactory.createRenderPipeline({\n ...this.props,\n vs: this.vs,\n fs: this.fs,\n topology: this.topology,\n parameters: props.parameters,\n layout: props.layout\n });\n\n this.pipeline = pipeline;\n this._getModuleUniforms = getUniforms;\n\n if (this.props.geometry) {\n this._setGeometry(this.props.geometry);\n }\n this.setUniforms(this._getModuleUniforms()) // Get all default module uniforms\n this.setProps(this.props);\n }\n\n destroy(): void {\n this.pipeline.destroy();\n }\n\n draw(renderPass?: RenderPass): this {\n this.pipeline.draw({\n renderPass,\n vertexCount: this.vertexCount,\n instanceCount: this.props.instanceCount\n });\n return this;\n }\n\n setProps(props: ModelProps): this {\n if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n this.updateModuleSettings(props.moduleSettings);\n }\n return this;\n }\n\n updateModuleSettings(props: Record<string, any>): this {\n const uniforms = this._getModuleUniforms(props);\n this.setUniforms(uniforms);\n return this;\n }\n\n setIndexBuffer(indices: Buffer): this {\n this.pipeline.setIndexBuffer(indices);\n // this._indices = indices;\n return this;\n }\n\n setAttributes(attributes: Record<string, Buffer>): this {\n this.pipeline.setAttributes(attributes);\n Object.assign(this.props.attributes, attributes);\n return this;\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): this {\n this.pipeline.setBindings(bindings);\n Object.assign(this.props.bindings, bindings);\n return this;\n }\n\n setUniforms(uniforms: Record<string, any>): this {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.props.uniforms, uniforms);\n return this;\n }\n\n _setGeometry(geometry: Geometry): void {\n // this._deleteGeometryBuffers();\n\n const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);\n this.setAttributes(geometryBuffers);\n\n const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);\n if (indexBuffer) {\n this.setIndexBuffer(indexBuffer);\n }\n }\n}\n\n/** Create a shader from the different overloads */\nfunction getShaderSource(device: Device, shader: string | {glsl?: string; wgsl?: string}): string {\n // TODO - detect WGSL/GLSL and throw an error if not supported\n if (typeof shader === 'string') {\n return shader;\n }\n\n switch (device.info.type) {\n case 'webgpu':\n if (shader?.wgsl) {\n return shader.wgsl;\n }\n throw new Error('WebGPU does not support GLSL shaders');\n\n default:\n if (shader?.glsl) {\n return shader.glsl;\n }\n throw new Error('WebGL does not support WGSL shaders');\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAAmD,SAAAG,QAAAC,MAAA,EAAAC,cAAA,QAAAC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