@luma.gl/engine 9.0.0-alpha.3 → 9.0.0-alpha.30

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 (148) hide show
  1. package/LICENSE +2 -1
  2. package/dist/animation/key-frames.d.ts +1 -1
  3. package/dist/animation/key-frames.d.ts.map +1 -1
  4. package/dist/animation/key-frames.js +0 -20
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +5 -5
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +0 -30
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/{lib → animation-loop}/animation-loop.d.ts +28 -29
  11. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  12. package/dist/{lib → animation-loop}/animation-loop.js +96 -175
  13. package/dist/animation-loop/animation-loop.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +7 -7
  15. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  16. package/dist/animation-loop/animation-props.js.map +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  19. package/dist/animation-loop/make-animation-loop.js +28 -0
  20. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  21. package/dist/animation-loop/render-loop.d.ts +23 -0
  22. package/dist/animation-loop/render-loop.d.ts.map +1 -0
  23. package/dist/animation-loop/render-loop.js +7 -0
  24. package/dist/animation-loop/render-loop.js.map +1 -0
  25. package/dist/dist.dev.js +14887 -0
  26. package/dist/geometries/cone-geometry.d.ts +1 -1
  27. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/cone-geometry.js +6 -5
  29. package/dist/geometries/cone-geometry.js.map +1 -1
  30. package/dist/geometries/cube-geometry.d.ts +2 -2
  31. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  32. package/dist/geometries/cube-geometry.js +15 -8
  33. package/dist/geometries/cube-geometry.js.map +1 -1
  34. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  35. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  36. package/dist/geometries/cylinder-geometry.js +6 -5
  37. package/dist/geometries/cylinder-geometry.js.map +1 -1
  38. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  39. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  40. package/dist/geometries/ico-sphere-geometry.js +9 -18
  41. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  42. package/dist/geometries/plane-geometry.d.ts +2 -2
  43. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  44. package/dist/geometries/plane-geometry.js +10 -19
  45. package/dist/geometries/plane-geometry.js.map +1 -1
  46. package/dist/geometries/sphere-geometry.d.ts +2 -2
  47. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  48. package/dist/geometries/sphere-geometry.js +9 -13
  49. package/dist/geometries/sphere-geometry.js.map +1 -1
  50. package/dist/geometries/truncated-cone-geometry.d.ts +2 -2
  51. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  52. package/dist/geometries/truncated-cone-geometry.js +9 -14
  53. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  54. package/dist/geometry/geometry-table.d.ts +2 -2
  55. package/dist/geometry/geometry-table.d.ts.map +1 -1
  56. package/dist/geometry/geometry-table.js.map +1 -1
  57. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  58. package/dist/geometry/geometry-utils.js +0 -9
  59. package/dist/geometry/geometry-utils.js.map +1 -1
  60. package/dist/geometry/geometry.d.ts +35 -58
  61. package/dist/geometry/geometry.d.ts.map +1 -1
  62. package/dist/geometry/geometry.js +26 -89
  63. package/dist/geometry/geometry.js.map +1 -1
  64. package/dist/geometry/primitive-utils.js.map +1 -1
  65. package/dist/index.cjs +2574 -0
  66. package/dist/index.d.ts +18 -9
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +20 -13
  69. package/dist/index.js.map +1 -1
  70. package/dist/lib/clip-space.d.ts +8 -0
  71. package/dist/lib/clip-space.d.ts.map +1 -1
  72. package/dist/lib/clip-space.js +36 -1
  73. package/dist/lib/clip-space.js.map +1 -1
  74. package/dist/lib/pipeline-factory.d.ts +19 -14
  75. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  76. package/dist/lib/pipeline-factory.js +52 -63
  77. package/dist/lib/pipeline-factory.js.map +1 -1
  78. package/dist/{lib → model}/model-utils.d.ts +2 -2
  79. package/dist/model/model-utils.d.ts.map +1 -0
  80. package/dist/{lib → model}/model-utils.js +3 -8
  81. package/dist/model/model-utils.js.map +1 -0
  82. package/dist/model/model.d.ts +65 -0
  83. package/dist/model/model.d.ts.map +1 -0
  84. package/dist/{lib → model}/model.js +56 -75
  85. package/dist/model/model.js.map +1 -0
  86. package/dist/scenegraph/group-node.d.ts +21 -0
  87. package/dist/scenegraph/group-node.d.ts.map +1 -0
  88. package/dist/scenegraph/group-node.js +95 -0
  89. package/dist/scenegraph/group-node.js.map +1 -0
  90. package/dist/scenegraph/model-node.d.ts +18 -0
  91. package/dist/scenegraph/model-node.d.ts.map +1 -0
  92. package/dist/scenegraph/model-node.js +29 -0
  93. package/dist/scenegraph/model-node.js.map +1 -0
  94. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  95. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  96. package/dist/scenegraph/scenegraph-node.js +142 -0
  97. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  98. package/dist/transform/transform.d.ts +98 -0
  99. package/dist/transform/transform.d.ts.map +1 -0
  100. package/dist/transform/transform.js +67 -0
  101. package/dist/transform/transform.js.map +1 -0
  102. package/dist.min.js +314 -0
  103. package/package.json +22 -12
  104. package/src/animation/timeline.ts +2 -2
  105. package/src/{lib → animation-loop}/animation-loop.ts +115 -97
  106. package/src/{lib → animation-loop}/animation-props.ts +6 -5
  107. package/src/animation-loop/make-animation-loop.ts +44 -0
  108. package/src/animation-loop/render-loop.ts +23 -0
  109. package/src/geometries/cone-geometry.ts +1 -1
  110. package/src/geometries/cube-geometry.ts +6 -3
  111. package/src/geometries/cylinder-geometry.ts +2 -2
  112. package/src/geometries/ico-sphere-geometry.ts +7 -6
  113. package/src/geometries/plane-geometry.ts +5 -4
  114. package/src/geometries/sphere-geometry.ts +4 -3
  115. package/src/geometries/truncated-cone-geometry.ts +4 -3
  116. package/src/geometry/geometry-table.ts +1 -1
  117. package/src/geometry/geometry-utils.ts +3 -3
  118. package/src/geometry/geometry.ts +72 -115
  119. package/src/index.ts +28 -12
  120. package/src/lib/clip-space.ts +17 -15
  121. package/src/lib/pipeline-factory.ts +60 -51
  122. package/src/{lib → model}/model-utils.ts +5 -4
  123. package/src/model/model.ts +226 -0
  124. package/src/scenegraph/group-node.ts +103 -0
  125. package/src/scenegraph/model-node.ts +50 -0
  126. package/src/scenegraph/scenegraph-node.ts +204 -0
  127. package/src/transform/transform.ts +246 -0
  128. package/dist/bundle.d.ts +0 -2
  129. package/dist/bundle.d.ts.map +0 -1
  130. package/dist/bundle.js +0 -5
  131. package/dist/bundle.js.map +0 -1
  132. package/dist/lib/animation-loop.d.ts.map +0 -1
  133. package/dist/lib/animation-loop.js.map +0 -1
  134. package/dist/lib/animation-props.d.ts.map +0 -1
  135. package/dist/lib/animation-props.js.map +0 -1
  136. package/dist/lib/model-utils.d.ts.map +0 -1
  137. package/dist/lib/model-utils.js.map +0 -1
  138. package/dist/lib/model.d.ts +0 -41
  139. package/dist/lib/model.d.ts.map +0 -1
  140. package/dist/lib/model.js.map +0 -1
  141. package/dist/lib/render-loop.d.ts +0 -14
  142. package/dist/lib/render-loop.d.ts.map +0 -1
  143. package/dist/lib/render-loop.js +0 -49
  144. package/dist/lib/render-loop.js.map +0 -1
  145. package/src/bundle.ts +0 -4
  146. package/src/lib/model.ts +0 -179
  147. package/src/lib/render-loop.ts +0 -58
  148. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,10 +1,21 @@
1
- export type { AnimationProps } from './lib/animation-props';
2
- export { RenderLoop } from './lib/render-loop';
3
- export type { ModelProps } from './lib/model';
4
- export { default as Model } from './lib/model';
5
- export type { AnimationLoopProps } from './lib/animation-loop';
6
- export { default as AnimationLoop } from './lib/animation-loop';
7
- export { default as Geometry } from './geometry/geometry';
1
+ export { Timeline } from './animation/timeline';
2
+ export { KeyFrames } from './animation/key-frames';
3
+ export type { AnimationProps } from './animation-loop/animation-props';
4
+ export { AnimationLoopTemplate } from './animation-loop/render-loop';
5
+ export type { AnimationLoopProps } from './animation-loop/animation-loop';
6
+ export { AnimationLoop } from './animation-loop/animation-loop';
7
+ export type { MakeAnimationLoopProps } from './animation-loop/make-animation-loop';
8
+ export { makeAnimationLoop } from './animation-loop/make-animation-loop';
9
+ export type { ModelProps } from './model/model';
10
+ export { Model } from './model/model';
11
+ export { Transform } from './transform/transform';
12
+ export { PipelineFactory } from './lib/pipeline-factory';
13
+ export { ClipSpace } from './lib/clip-space';
14
+ export { ScenegraphNode } from './scenegraph/scenegraph-node';
15
+ export { GroupNode } from './scenegraph/group-node';
16
+ export { ModelNode } from './scenegraph/model-node';
17
+ export type { GeometryProps } from './geometry/geometry';
18
+ export { Geometry } from './geometry/geometry';
8
19
  export type { ConeGeometryProps } from './geometries/cone-geometry';
9
20
  export { ConeGeometry } from './geometries/cone-geometry';
10
21
  export type { CubeGeometryProps } from './geometries/cube-geometry';
@@ -19,6 +30,4 @@ export type { SphereGeometryProps } from './geometries/sphere-geometry';
19
30
  export { SphereGeometry } from './geometries/sphere-geometry';
20
31
  export type { TruncatedConeGeometryProps } from './geometries/truncated-cone-geometry';
21
32
  export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
22
- export { Timeline } from './animation/timeline';
23
- export { KeyFrames } from './animation/key-frames';
24
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAC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B,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"}
package/dist/index.js CHANGED
@@ -1,14 +1,21 @@
1
- export { RenderLoop } from './lib/render-loop';
2
- export { default as Model } from './lib/model';
3
- export { default as AnimationLoop } from './lib/animation-loop';
4
- export { default as Geometry } from './geometry/geometry';
5
- export { ConeGeometry } from './geometries/cone-geometry';
6
- export { CubeGeometry } from './geometries/cube-geometry';
7
- export { CylinderGeometry } from './geometries/cylinder-geometry';
8
- export { IcoSphereGeometry } from './geometries/ico-sphere-geometry';
9
- export { PlaneGeometry } from './geometries/plane-geometry';
10
- export { SphereGeometry } from './geometries/sphere-geometry';
11
- export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
12
- export { Timeline } from './animation/timeline';
13
- export { KeyFrames } from './animation/key-frames';
1
+ export { Timeline } from "./animation/timeline.js";
2
+ export { KeyFrames } from "./animation/key-frames.js";
3
+ export { AnimationLoopTemplate } from "./animation-loop/render-loop.js";
4
+ export { AnimationLoop } from "./animation-loop/animation-loop.js";
5
+ export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
6
+ export { Model } from "./model/model.js";
7
+ export { Transform } from "./transform/transform.js";
8
+ export { PipelineFactory } from "./lib/pipeline-factory.js";
9
+ export { ClipSpace } from "./lib/clip-space.js";
10
+ export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
11
+ export { GroupNode } from "./scenegraph/group-node.js";
12
+ export { ModelNode } from "./scenegraph/model-node.js";
13
+ export { Geometry } from "./geometry/geometry.js";
14
+ export { ConeGeometry } from "./geometries/cone-geometry.js";
15
+ export { CubeGeometry } from "./geometries/cube-geometry.js";
16
+ export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
17
+ export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
18
+ export { PlaneGeometry } from "./geometries/plane-geometry.js";
19
+ export { SphereGeometry } from "./geometries/sphere-geometry.js";
20
+ export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
14
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","Transform","PipelineFactory","ClipSpace","ScenegraphNode","GroupNode","ModelNode","Geometry","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 './model/model';\nexport {Model} from './model/model';\n\nexport {Transform} from './transform/transform';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// Utils\nexport {ClipSpace} from './lib/clip-space';\n\n// Scenegraph Core nodes\nexport {ScenegraphNode} from './scenegraph/scenegraph-node';\nexport {GroupNode} from './scenegraph/group-node';\nexport {ModelNode} from './scenegraph/model-node';\n\n// Geometries\nexport type {GeometryProps} from './geometry/geometry';\nexport {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":"SAGQA,QAAQ;AAAA,SACRC,SAAS;AAAA,SAGTC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAGbC,iBAAiB;AAAA,SAGjBC,KAAK;AAAA,SAELC,SAAS;AAAA,SAETC,eAAe;AAAA,SAGfC,SAAS;AAAA,SAGTC,cAAc;AAAA,SACdC,SAAS;AAAA,SACTC,SAAS;AAAA,SAITC,QAAQ;AAAA,SAIRC,YAAY;AAAA,SAEZC,YAAY;AAAA,SAEZC,gBAAgB;AAAA,SAEhBC,iBAAiB;AAAA,SAEjBC,aAAa;AAAA,SAEbC,cAAc;AAAA,SAEdC,qBAAqB"}
@@ -1 +1,9 @@
1
+ import { Device } from '@luma.gl/core';
2
+ import { Model, ModelProps } from '../model/model';
3
+ /**
4
+ * A flat geometry that covers the "visible area" that the GPU renders.
5
+ */
6
+ export declare class ClipSpace extends Model {
7
+ constructor(device: Device | WebGLRenderingContext, opts?: ModelProps);
8
+ }
1
9
  //# sourceMappingURL=clip-space.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAO,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAuBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,IAAI,CAAC,EAAE,UAAU;CAqBtE"}
@@ -1,2 +1,37 @@
1
-
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import { glsl } from '@luma.gl/core';
4
+ import { WebGLDevice } from '@luma.gl/webgl';
5
+ import { Model } from "../model/model.js";
6
+ import { Geometry } from "../geometry/geometry.js";
7
+ const CLIPSPACE_VERTEX_SHADER = glsl(_templateObject || (_templateObject = _taggedTemplateLiteral(["attribute 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"], ["\\\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"])));
8
+ const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
9
+ export class ClipSpace extends Model {
10
+ constructor(device, opts) {
11
+ const TEX_COORDS = POSITIONS.map(coord => coord === -1 ? 0 : coord);
12
+ super(WebGLDevice.attach(device), {
13
+ ...opts,
14
+ vs: CLIPSPACE_VERTEX_SHADER,
15
+ vertexCount: 4,
16
+ geometry: new Geometry({
17
+ topology: 'triangle-strip',
18
+ vertexCount: 4,
19
+ attributes: {
20
+ aClipSpacePosition: {
21
+ size: 2,
22
+ value: new Float32Array(POSITIONS)
23
+ },
24
+ aTexCoord: {
25
+ size: 2,
26
+ value: new Float32Array(TEX_COORDS)
27
+ },
28
+ aCoordinate: {
29
+ size: 2,
30
+ value: new Float32Array(TEX_COORDS)
31
+ }
32
+ }
33
+ })
34
+ });
35
+ }
36
+ }
2
37
  //# sourceMappingURL=clip-space.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"clip-space.js"}
1
+ {"version":3,"file":"clip-space.js","names":["glsl","WebGLDevice","Model","Geometry","CLIPSPACE_VERTEX_SHADER","_templateObject","_taggedTemplateLiteral","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","attach","vs","vertexCount","geometry","topology","attributes","aClipSpacePosition","size","value","Float32Array","aTexCoord","aCoordinate"],"sources":["../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\nimport {Device, glsl} from '@luma.gl/core';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {Model, ModelProps} from '../model/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/**\n * A flat geometry that covers the \"visible area\" that the GPU renders.\n */\nexport class ClipSpace extends Model {\n constructor(device: Device | WebGLRenderingContext, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n WebGLDevice.attach(device),\n {\n ...opts,\n vs: CLIPSPACE_VERTEX_SHADER,\n vertexCount: 4,\n geometry: new Geometry({\n topology: '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 }\n}\n"],"mappings":";;AAEA,SAAgBA,IAAI,QAAO,eAAe;AAC1C,SAAQC,WAAW,QAAO,gBAAgB;AAAC,SACnCC,KAAK;AAAA,SACLC,QAAQ;AAEhB,MAAMC,uBAAuB,GAAGJ,IAAI,CAAAK,eAAA,KAAAA,eAAA,GAAAC,sBAAA,gpBAenC;AAGD,MAAMC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAK9C,OAAO,MAAMC,SAAS,SAASN,KAAK,CAAC;EACnCO,WAAWA,CAACC,MAAsC,EAAEC,IAAiB,EAAE;IACrE,MAAMC,UAAU,GAAGL,SAAS,CAACM,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAGA,KAAM,CAAC;IAEvE,KAAK,CACHb,WAAW,CAACc,MAAM,CAACL,MAAM,CAAC,EAC1B;MACE,GAAGC,IAAI;MACPK,EAAE,EAAEZ,uBAAuB;MAC3Ba,WAAW,EAAE,CAAC;MACdC,QAAQ,EAAE,IAAIf,QAAQ,CAAC;QACrBgB,QAAQ,EAAE,gBAAgB;QAC1BF,WAAW,EAAE,CAAC;QACdG,UAAU,EAAE;UACVC,kBAAkB,EAAE;YAACC,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACjB,SAAS;UAAC,CAAC;UACjEkB,SAAS,EAAE;YAACH,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACZ,UAAU;UAAC,CAAC;UACzDc,WAAW,EAAE;YAACJ,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACZ,UAAU;UAAC;QAC5D;MACF,CAAC;IACH,CACF,CAAC;EACH;AACF"}
@@ -1,19 +1,20 @@
1
- import type { RenderPipelineParameters } from '@luma.gl/api';
2
- import { Device, RenderPipeline } from '@luma.gl/api/';
1
+ import type { RenderPipelineParameters, PrimitiveTopology, ShaderLayout } from '@luma.gl/core';
2
+ import { Device, RenderPipeline } from '@luma.gl/core';
3
3
  import type { ShaderModule } from '@luma.gl/shadertools';
4
- export declare type GetRenderPipelineOptions = {
4
+ export type GetRenderPipelineOptions = {
5
5
  vs: string;
6
- fs: string;
7
- topology: any;
6
+ fs: string | null;
7
+ topology: PrimitiveTopology;
8
+ layout?: ShaderLayout | null;
8
9
  parameters?: RenderPipelineParameters;
9
10
  modules?: ShaderModule[];
10
- defines?: Record<string, string>;
11
+ defines?: Record<string, string | number | boolean>;
11
12
  inject?: Record<string, string>;
12
13
  transpileToGLSL100?: boolean;
13
14
  varyings?: string[];
14
15
  bufferMode?: number;
15
16
  };
16
- export declare type GetComputePipelineOptions = {
17
+ export type GetComputePipelineOptions = {
17
18
  cs: string;
18
19
  parameters?: RenderPipelineParameters;
19
20
  modules?: ShaderModule[];
@@ -23,8 +24,9 @@ export declare type GetComputePipelineOptions = {
23
24
  varyings?: string[];
24
25
  bufferMode?: number;
25
26
  };
27
+ type GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;
26
28
  /** Efficiently create shared pipelines with varying parameters */
27
- export default class PipelineFactory {
29
+ export declare class PipelineFactory {
28
30
  readonly device: Device;
29
31
  stateHash: number;
30
32
  private _hashCounter;
@@ -36,20 +38,23 @@ export default class PipelineFactory {
36
38
  private _defaultModules;
37
39
  static getDefaultPipelineFactory(device: Device): PipelineFactory;
38
40
  constructor(device: Device);
39
- addShaderHook(hook: any, opts?: any): void;
41
+ addDefaultModule(module: ShaderModule): void;
42
+ removeDefaultModule(module: ShaderModule): void;
43
+ addShaderHook(hook: string, opts?: any): void;
40
44
  createRenderPipeline(options: GetRenderPipelineOptions): {
41
- renderPipeline: RenderPipeline;
42
- getUniforms: (props: Record<string, Record<string, any>>) => Record<string, any>;
45
+ pipeline: RenderPipeline;
46
+ getUniforms: GetUniformsFunc;
43
47
  };
44
48
  release(pipeline: RenderPipeline): void;
45
- getUniforms(pipeline: RenderPipeline): any;
49
+ getUniforms(pipeline: RenderPipeline): GetUniformsFunc;
46
50
  _createRenderPipeline(props: GetRenderPipelineOptions): {
47
- renderPipeline: RenderPipeline;
48
- getUniforms: (props: Record<string, Record<string, any>>) => Record<string, any>;
51
+ pipeline: RenderPipeline;
52
+ getUniforms: GetUniformsFunc;
49
53
  };
50
54
  /** Calculate a hash based on all the inputs for a render pipeline */
51
55
  _hashRenderPipeline(props: GetRenderPipelineOptions): string;
52
56
  _getHash(key: string): number;
53
57
  _getModuleList(appModules?: ShaderModule[]): ShaderModule[];
54
58
  }
59
+ export {};
55
60
  //# sourceMappingURL=pipeline-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-factory.d.ts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YAAY,EAAO,GAAG,YAAY,EAAE;CAyBhE"}
@@ -7,185 +7,174 @@ const DEFAULT_RENDER_PIPELINE_OPTIONS = {
7
7
  defines: {},
8
8
  inject: {},
9
9
  transpileToGLSL100: false,
10
+ layout: null,
10
11
  varyings: [],
11
12
  bufferMode: 0x8c8d,
12
13
  topology: 'triangle-list',
13
14
  parameters: {}
14
15
  };
15
- export default class PipelineFactory {
16
+ export class PipelineFactory {
16
17
  static getDefaultPipelineFactory(device) {
17
18
  device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
18
19
  return device.defaultPipelineFactory;
19
20
  }
20
-
21
21
  constructor(device) {
22
22
  _defineProperty(this, "device", void 0);
23
-
24
23
  _defineProperty(this, "stateHash", 0);
25
-
26
24
  _defineProperty(this, "_hashCounter", 0);
27
-
28
25
  _defineProperty(this, "_hashes", {});
29
-
30
26
  _defineProperty(this, "_useCounts", {});
31
-
32
27
  _defineProperty(this, "_pipelineCache", {});
33
-
34
28
  _defineProperty(this, "_getUniforms", {});
35
-
36
29
  _defineProperty(this, "_hookFunctions", []);
37
-
38
30
  _defineProperty(this, "_defaultModules", []);
39
-
40
31
  this.device = device;
41
32
  }
42
-
33
+ addDefaultModule(module) {
34
+ if (!this._defaultModules.find(m => m.name === (typeof module === 'string' ? module : module.name))) {
35
+ this._defaultModules.push(module);
36
+ }
37
+ this.stateHash++;
38
+ }
39
+ removeDefaultModule(module) {
40
+ const moduleName = typeof module === 'string' ? module : module.name;
41
+ this._defaultModules = this._defaultModules.filter(m => m.name !== moduleName);
42
+ this.stateHash++;
43
+ }
43
44
  addShaderHook(hook, opts) {
44
45
  if (opts) {
45
46
  hook = Object.assign(opts, {
46
47
  hook
47
48
  });
48
49
  }
49
-
50
50
  this._hookFunctions.push(hook);
51
-
52
51
  this.stateHash++;
53
52
  }
54
-
55
53
  createRenderPipeline(options) {
56
- const props = { ...DEFAULT_RENDER_PIPELINE_OPTIONS,
54
+ const props = {
55
+ ...DEFAULT_RENDER_PIPELINE_OPTIONS,
57
56
  ...options
58
57
  };
59
-
60
58
  const modules = this._getModuleList(props.modules);
61
-
62
- const hash = this._hashRenderPipeline({ ...props,
59
+ const hash = this._hashRenderPipeline({
60
+ ...props,
63
61
  modules
64
62
  });
65
-
66
63
  if (!this._pipelineCache[hash]) {
67
64
  const {
68
- renderPipeline,
65
+ pipeline,
69
66
  getUniforms
70
- } = this._createRenderPipeline({ ...props,
67
+ } = this._createRenderPipeline({
68
+ ...props,
71
69
  modules
72
70
  });
73
-
74
- renderPipeline.hash = hash;
75
- this._pipelineCache[hash] = renderPipeline;
76
-
77
- this._getUniforms[hash] = getUniforms || (x => {});
78
-
71
+ pipeline.hash = hash;
72
+ this._pipelineCache[hash] = pipeline;
73
+ this._getUniforms[hash] = getUniforms || (x => ({}));
79
74
  this._useCounts[hash] = 0;
80
75
  }
81
-
82
76
  this._useCounts[hash]++;
83
77
  return {
84
- renderPipeline: this._pipelineCache[hash],
78
+ pipeline: this._pipelineCache[hash],
85
79
  getUniforms: this._getUniforms[hash]
86
80
  };
87
81
  }
88
-
89
82
  release(pipeline) {
90
83
  const hash = pipeline.hash;
91
84
  this._useCounts[hash]--;
92
-
93
85
  if (this._useCounts[hash] === 0) {
94
86
  this._pipelineCache[hash].destroy();
95
-
96
87
  delete this._pipelineCache[hash];
97
88
  delete this._getUniforms[hash];
98
89
  delete this._useCounts[hash];
99
90
  }
100
91
  }
101
-
102
92
  getUniforms(pipeline) {
103
93
  return this._getUniforms[pipeline.hash] || null;
104
94
  }
105
-
106
95
  _createRenderPipeline(props) {
107
96
  const platformInfo = {
108
97
  gpu: this.device.info.gpu,
109
98
  features: this.device.features
110
99
  };
111
- const assembled = assembleShaders(platformInfo, { ...props,
100
+ if (!props.fs) {
101
+ throw new Error('fs');
102
+ }
103
+ const assembled = assembleShaders(platformInfo, {
104
+ ...props,
105
+ fs: props.fs,
112
106
  hookFunctions: this._hookFunctions
113
107
  });
114
- const renderPipeline = this.device.createRenderPipeline({ ...props,
108
+ const pipeline = this.device.createRenderPipeline({
109
+ ...props,
115
110
  vs: this.device.createShader({
116
111
  stage: 'vertex',
117
112
  source: assembled.vs
118
113
  }),
119
- fs: assembled.fs && this.device.createShader({
114
+ fs: assembled.fs ? this.device.createShader({
120
115
  stage: 'fragment',
121
116
  source: assembled.fs
122
- })
117
+ }) : null
123
118
  });
124
119
  return {
125
- renderPipeline,
120
+ pipeline,
126
121
  getUniforms: assembled.getUniforms
127
122
  };
128
123
  }
129
-
130
124
  _hashRenderPipeline(props) {
125
+ const {
126
+ modules = [],
127
+ varyings = [],
128
+ defines = {},
129
+ inject = {},
130
+ parameters = {}
131
+ } = props;
131
132
  const vsHash = this._getHash(props.vs);
132
-
133
- const fsHash = this._getHash(props.fs);
134
-
135
- const moduleHashes = props.modules.map(m => this._getHash(typeof m === 'string' ? m : m.name)).sort();
136
- const varyingHashes = props.varyings.map(v => this._getHash(v));
137
- const defineKeys = Object.keys(props.defines).sort();
138
- const injectKeys = Object.keys(props.inject).sort();
133
+ const fsHash = props.fs ? this._getHash(props.fs) : 0;
134
+ const moduleHashes = modules.map(m => this._getHash(typeof m === 'string' ? m : m.name)).sort();
135
+ const varyingHashes = varyings.map(v => this._getHash(v));
136
+ const defineKeys = Object.keys(defines).sort();
137
+ const injectKeys = Object.keys(inject).sort();
139
138
  const defineHashes = [];
140
139
  const injectHashes = [];
141
-
142
140
  for (const key of defineKeys) {
143
141
  defineHashes.push(this._getHash(key));
144
- defineHashes.push(this._getHash(props.defines[key]));
142
+ defineHashes.push(this._getHash(String(defines[key])));
145
143
  }
146
-
147
144
  for (const key of injectKeys) {
148
145
  injectHashes.push(this._getHash(key));
149
- injectHashes.push(this._getHash(props.inject[key]));
146
+ injectHashes.push(this._getHash(inject[key]));
150
147
  }
151
-
152
- const parameterHash = JSON.stringify(props.parameters);
148
+ const parameterHash = JSON.stringify(parameters);
153
149
  return "".concat(vsHash, "/").concat(fsHash, "D").concat(defineHashes.join('/'), "M").concat(moduleHashes.join('/'), "I").concat(injectHashes.join('/'), "V").concat(varyingHashes.join('/'), "H").concat(this.stateHash, "B").concat(props.bufferMode).concat(props.transpileToGLSL100 ? 'T' : '', "P").concat(parameterHash);
154
150
  }
155
-
156
151
  _getHash(key) {
157
152
  if (this._hashes[key] === undefined) {
158
153
  this._hashes[key] = this._hashCounter++;
159
154
  }
160
-
161
155
  return this._hashes[key];
162
156
  }
163
-
164
- _getModuleList(appModules = []) {
157
+ _getModuleList() {
158
+ let appModules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
165
159
  const modules = new Array(this._defaultModules.length + appModules.length);
166
160
  const seen = {};
167
161
  let count = 0;
168
-
169
162
  for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
170
163
  const module = this._defaultModules[i];
171
164
  const name = module.name;
172
165
  modules[count++] = module;
173
166
  seen[name] = true;
174
167
  }
175
-
176
168
  for (let i = 0, len = appModules.length; i < len; ++i) {
177
169
  const module = appModules[i];
178
170
  const name = module.name;
179
-
180
171
  if (!seen[name]) {
181
172
  modules[count++] = module;
182
173
  seen[name] = true;
183
174
  }
184
175
  }
185
-
186
176
  modules.length = count;
187
177
  return modules;
188
178
  }
189
-
190
179
  }
191
180
  //# sourceMappingURL=pipeline-factory.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/pipeline-factory.ts"],"names":["assembleShaders","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","varyings","bufferMode","topology","parameters","PipelineFactory","getDefaultPipelineFactory","device","defaultPipelineFactory","constructor","addShaderHook","hook","opts","Object","assign","_hookFunctions","push","stateHash","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","renderPipeline","getUniforms","_createRenderPipeline","_getUniforms","x","_useCounts","release","pipeline","destroy","platformInfo","gpu","info","features","assembled","hookFunctions","createShader","stage","source","vsHash","_getHash","fsHash","moduleHashes","map","m","name","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","parameterHash","JSON","stringify","join","_hashes","undefined","_hashCounter","appModules","Array","_defaultModules","length","seen","count","i","len","module"],"mappings":";AAGA,SAAQA,eAAR,QAA8B,sBAA9B;AA8BA,MAAMC,+BAAmE,GAAG;AAC1EC,EAAAA,EAAE,EAAE,EADsE;AAE1EC,EAAAA,EAAE,EAAE,EAFsE;AAG1EC,EAAAA,OAAO,EAAE,EAHiE;AAI1EC,EAAAA,OAAO,EAAE,EAJiE;AAK1EC,EAAAA,MAAM,EAAE,EALkE;AAM1EC,EAAAA,kBAAkB,EAAE,KANsD;AAQ1EC,EAAAA,QAAQ,EAAE,EARgE;AAS1EC,EAAAA,UAAU,EAAE,MAT8D;AAU1EC,EAAAA,QAAQ,EAAE,eAVgE;AAW1EC,EAAAA,UAAU,EAAE;AAX8D,CAA5E;AAeA,eAAe,MAAMC,eAAN,CAAsB;AAeH,SAAzBC,yBAAyB,CAACC,MAAD,EAAkC;AAEhEA,IAAAA,MAAM,CAACC,sBAAP,GAAgCD,MAAM,CAACC,sBAAP,IAAiC,IAAIH,eAAJ,CAAoBE,MAApB,CAAjE;AAEA,WAAOA,MAAM,CAACC,sBAAd;AACD;;AAEDC,EAAAA,WAAW,CAACF,MAAD,EAAiB;AAAA;;AAAA,uCAnBR,CAmBQ;;AAAA,0CAlBG,CAkBH;;AAAA,qCAjBuB,EAiBvB;;AAAA,wCAhB0B,EAgB1B;;AAAA,4CAdsC,EActC;;AAAA,0CAZyB,EAYzB;;AAAA,4CAXa,EAWb;;AAAA,6CAVK,EAUL;;AAC1B,SAAKA,MAAL,GAAcA,MAAd;AACD;;AAeDG,EAAAA,aAAa,CAACC,IAAD,EAAOC,IAAP,EAAoB;AAC/B,QAAIA,IAAJ,EAAU;AACRD,MAAAA,IAAI,GAAGE,MAAM,CAACC,MAAP,CAAcF,IAAd,EAAoB;AAACD,QAAAA;AAAD,OAApB,CAAP;AACD;;AACD,SAAKI,cAAL,CAAoBC,IAApB,CAAyBL,IAAzB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AGC,GAA7C,EAAkD,EAAED,CAApD,EAAuD;AACrD,YAAME,MAAM,GAAGR,UAAU,CAACM,CAAD,CAAzB;AACA,YAAMvB,IAAI,GAAGyB,MAAM,CAACzB,IAApB;;AACA,UAAI,CAACqB,IAAI,CAACrB,IAAD,CAAT,EAAiB;AACfpD,QAAAA,OAAO,CAAC0E,KAAK,EAAN,CAAP,GAAmBG,MAAnB;AACAJ,QAAAA,IAAI,CAACrB,IAAD,CAAJ,GAAa,IAAb;AACD;AACF;;AAEDpD,IAAAA,OAAO,CAACwE,MAAR,GAAiBE,KAAjB;AAEA,WAAO1E,OAAP;AACD;;AA/KkC","sourcesContent":["import type {RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/api';\nimport {Device, RenderPipeline, ComputePipeline} from '@luma.gl/api/';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string,\n fs: string,\n topology;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>,\n inject?: Record<string, string>,\n transpileToGLSL100?: boolean;\n\n varyings?: string[],\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string,\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>,\n inject?: Record<string, string>,\n transpileToGLSL100?: boolean;\n\n varyings?: string[],\n bufferMode?: number,\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\n/** Efficiently create shared pipelines with varying parameters */\nexport default class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, any> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n // addDefaultModule(module: ShaderModule): void {\n // if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n // this._defaultModules.push(module);\n // }\n // this.stateHash++;\n // }\n\n // removeDefaultModule(module: ShaderModule): void {\n // const moduleName = typeof module === 'string' ? module : module.name;\n // this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n // this.stateHash++;\n // }\n\n addShaderHook(hook, opts?): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n renderPipeline: RenderPipeline;\n getUniforms: (props: Record<string, Record<string, any>>) => Record<string, any>;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {renderPipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n renderPipeline.hash = hash;\n this._pipelineCache[hash] = renderPipeline;\n this._getUniforms[hash] = getUniforms || ((x: Record<string, Record<string, any>>) => {});\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n renderPipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n renderPipeline: RenderPipeline,\n getUniforms: (props: Record<string, Record<string, any>>) => Record<string, any>\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n const assembled = assembleShaders(platformInfo, {...props, hookFunctions: this._hookFunctions});\n\n const renderPipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs && this.device.createShader({stage: 'fragment', source: assembled.fs}),\n });\n\n return {renderPipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const vsHash = this._getHash(props.vs);\n const fsHash = this._getHash(props.fs);\n\n const moduleHashes = props.modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = props.varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(props.defines).sort();\n const injectKeys = Object.keys(props.inject).sort();\n const defineHashes = [];\n const injectHashes = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(props.defines[key]));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(props.inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(props.parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"file":"pipeline-factory.js"}
1
+ {"version":3,"file":"pipeline-factory.js","names":["assembleShaders","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","layout","varyings","bufferMode","topology","parameters","PipelineFactory","getDefaultPipelineFactory","device","defaultPipelineFactory","constructor","_defineProperty","addDefaultModule","module","_defaultModules","find","m","name","push","stateHash","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","_hookFunctions","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","pipeline","getUniforms","_createRenderPipeline","_getUniforms","x","_useCounts","release","destroy","platformInfo","gpu","info","features","Error","assembled","hookFunctions","createShader","stage","source","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","String","parameterHash","JSON","stringify","concat","join","_hashes","undefined","_hashCounter","appModules","arguments","length","Array","seen","count","i","len"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["import type {RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/core';\nimport {Device, RenderPipeline} from '@luma.gl/core';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string;\n fs: string | null;\n topology: PrimitiveTopology;\n layout?: ShaderLayout | null;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number;\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n layout: null,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/** Efficiently create shared pipelines with varying parameters */\nexport class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, GetUniformsFunc> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n addDefaultModule(module: ShaderModule): void {\n if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n this._defaultModules.push(module);\n }\n this.stateHash++;\n }\n\n removeDefaultModule(module: ShaderModule): void {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook: string, opts?: any): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n pipeline: RenderPipeline;\n getUniforms: GetUniformsFunc;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {pipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._getUniforms[hash] = getUniforms || ((x?: unknown) => ({}));\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n pipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n pipeline: RenderPipeline,\n getUniforms: GetUniformsFunc\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const assembled = assembleShaders(platformInfo, {...props, fs: props.fs, hookFunctions: this._hookFunctions});\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs ? this.device.createShader({stage: 'fragment', source: assembled.fs}) : null,\n });\n\n return {pipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const {modules = [], varyings = [], defines = {}, inject = {}, parameters = {}} = props;\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n const moduleHashes = modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes: number[] = [];\n const injectHashes: number[] = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(String(defines[key])));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules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IAAI,CAAChE,IAAI,CAAC,GAAG,IAAI;MACnB;IACF;IAEApB,OAAO,CAACkF,MAAM,GAAGG,KAAK;IAEtB,OAAOrF,OAAO;EAChB;AACF"}
@@ -1,5 +1,5 @@
1
- import { Device, Buffer } from '@luma.gl/api';
2
- import type Geometry from '../geometry/geometry';
1
+ import { Device, Buffer } from '@luma.gl/core';
2
+ import type { Geometry } from '../geometry/geometry';
3
3
  export declare function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined;
4
4
  export declare function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer>;
5
5
  //# sourceMappingURL=model-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../src/model/model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAS,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAsDnD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAYjG;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAc1G"}
@@ -1,4 +1,4 @@
1
- import { Buffer, assert } from '@luma.gl/api';
1
+ import { Buffer, assert } from '@luma.gl/core';
2
2
  const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
3
3
  POSITION: 'positions',
4
4
  NORMAL: 'normals',
@@ -11,7 +11,6 @@ export function getIndexBufferFromGeometry(device, geometry) {
11
11
  if (!geometry.indices) {
12
12
  return undefined;
13
13
  }
14
-
15
14
  const data = geometry.indices.value || geometry.indices;
16
15
  assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
17
16
  return device.createBuffer({
@@ -21,24 +20,20 @@ export function getIndexBufferFromGeometry(device, geometry) {
21
20
  }
22
21
  export function getAttributeBuffersFromGeometry(device, geometry) {
23
22
  const buffers = {};
24
-
25
23
  for (const [name, attribute] of Object.entries(geometry.attributes)) {
26
24
  const remappedName = mapAttributeName(name);
27
-
28
- if (attribute.constant) {
25
+ if (attribute !== null && attribute !== void 0 && attribute.constant) {
29
26
  throw new Error('constant attributes not supported');
30
27
  } else {
31
- const typedArray = attribute.value;
28
+ const typedArray = attribute === null || attribute === void 0 ? void 0 : attribute.value;
32
29
  buffers[remappedName] = device.createBuffer({
33
30
  data: typedArray,
34
31
  id: "".concat(remappedName, "-buffer")
35
32
  });
36
33
  }
37
34
  }
38
-
39
35
  return buffers;
40
36
  }
41
-
42
37
  function mapAttributeName(name) {
43
38
  return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
44
39
  }