@luma.gl/engine 9.0.0-alpha.4 → 9.0.0-alpha.40

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 (166) hide show
  1. package/LICENSE +3 -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 +6 -27
  5. package/dist/animation/key-frames.js.map +1 -1
  6. package/dist/animation/timeline.d.ts +9 -9
  7. package/dist/animation/timeline.d.ts.map +1 -1
  8. package/dist/animation/timeline.js +18 -49
  9. package/dist/animation/timeline.js.map +1 -1
  10. package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -31
  11. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  12. package/dist/{lib → animation-loop}/animation-loop.js +114 -195
  13. package/dist/animation-loop/animation-loop.js.map +1 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +6 -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 +7149 -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 +10 -19
  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 +14 -23
  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 -4
  51. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  52. package/dist/geometries/truncated-cone-geometry.js +9 -25
  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 +50 -59
  61. package/dist/geometry/geometry.d.ts.map +1 -1
  62. package/dist/geometry/geometry.js +32 -97
  63. package/dist/geometry/geometry.js.map +1 -1
  64. package/dist/geometry/gpu-geometry.d.ts +37 -0
  65. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  66. package/dist/geometry/gpu-geometry.js +102 -0
  67. package/dist/geometry/gpu-geometry.js.map +1 -0
  68. package/dist/geometry/gpu-table.d.ts +1 -0
  69. package/dist/geometry/gpu-table.d.ts.map +1 -0
  70. package/dist/geometry/gpu-table.js +2 -0
  71. package/dist/geometry/gpu-table.js.map +1 -0
  72. package/dist/index.cjs +2802 -0
  73. package/dist/index.d.ts +19 -9
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +21 -13
  76. package/dist/index.js.map +1 -1
  77. package/dist/lib/clip-space.d.ts +8 -0
  78. package/dist/lib/clip-space.d.ts.map +1 -1
  79. package/dist/lib/clip-space.js +47 -0
  80. package/dist/lib/clip-space.js.map +1 -1
  81. package/dist/lib/pipeline-factory.d.ts +12 -40
  82. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  83. package/dist/lib/pipeline-factory.js +50 -148
  84. package/dist/lib/pipeline-factory.js.map +1 -1
  85. package/dist/model/model.d.ts +175 -0
  86. package/dist/model/model.d.ts.map +1 -0
  87. package/dist/model/model.js +273 -0
  88. package/dist/model/model.js.map +1 -0
  89. package/dist/scenegraph/group-node.d.ts +21 -0
  90. package/dist/scenegraph/group-node.d.ts.map +1 -0
  91. package/dist/scenegraph/group-node.js +94 -0
  92. package/dist/scenegraph/group-node.js.map +1 -0
  93. package/dist/scenegraph/model-node.d.ts +18 -0
  94. package/dist/scenegraph/model-node.d.ts.map +1 -0
  95. package/dist/scenegraph/model-node.js +28 -0
  96. package/dist/scenegraph/model-node.js.map +1 -0
  97. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  98. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  99. package/dist/scenegraph/scenegraph-node.js +141 -0
  100. package/dist/scenegraph/scenegraph-node.js.map +1 -0
  101. package/dist/shadertools/shader-module-uniforms.d.ts +36 -0
  102. package/dist/shadertools/shader-module-uniforms.d.ts.map +1 -0
  103. package/dist/shadertools/shader-module-uniforms.js +87 -0
  104. package/dist/shadertools/shader-module-uniforms.js.map +1 -0
  105. package/dist/transform/transform.d.ts +98 -0
  106. package/dist/transform/transform.d.ts.map +1 -0
  107. package/dist/transform/transform.js +48 -0
  108. package/dist/transform/transform.js.map +1 -0
  109. package/dist.min.js +264 -0
  110. package/package.json +21 -12
  111. package/src/animation/timeline.ts +16 -15
  112. package/src/{lib → animation-loop}/animation-loop.ts +119 -102
  113. package/src/{lib → animation-loop}/animation-props.ts +5 -5
  114. package/src/animation-loop/make-animation-loop.ts +44 -0
  115. package/src/animation-loop/render-loop.ts +23 -0
  116. package/src/geometries/cone-geometry.ts +1 -1
  117. package/src/geometries/cube-geometry.ts +6 -3
  118. package/src/geometries/cylinder-geometry.ts +2 -2
  119. package/src/geometries/ico-sphere-geometry.ts +7 -6
  120. package/src/geometries/plane-geometry.ts +5 -4
  121. package/src/geometries/sphere-geometry.ts +4 -3
  122. package/src/geometries/truncated-cone-geometry.ts +4 -13
  123. package/src/geometry/geometry-table.ts +1 -1
  124. package/src/geometry/geometry-utils.ts +3 -3
  125. package/src/geometry/geometry.ts +79 -119
  126. package/src/geometry/gpu-geometry.ts +124 -0
  127. package/src/geometry/gpu-table.ts +41 -0
  128. package/src/index.ts +31 -12
  129. package/src/lib/clip-space.ts +16 -15
  130. package/src/lib/pipeline-factory.ts +60 -168
  131. package/src/model/model.ts +489 -0
  132. package/src/scenegraph/group-node.ts +103 -0
  133. package/src/scenegraph/model-node.ts +50 -0
  134. package/src/scenegraph/scenegraph-node.ts +204 -0
  135. package/src/shadertools/shader-module-uniforms.ts +178 -0
  136. package/src/transform/transform.ts +249 -0
  137. package/dist/bundle.d.ts +0 -2
  138. package/dist/bundle.d.ts.map +0 -1
  139. package/dist/bundle.js +0 -5
  140. package/dist/bundle.js.map +0 -1
  141. package/dist/geometry/primitive-utils.d.ts +0 -1
  142. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  143. package/dist/geometry/primitive-utils.js +0 -2
  144. package/dist/geometry/primitive-utils.js.map +0 -1
  145. package/dist/lib/animation-loop.d.ts.map +0 -1
  146. package/dist/lib/animation-loop.js.map +0 -1
  147. package/dist/lib/animation-props.d.ts.map +0 -1
  148. package/dist/lib/animation-props.js.map +0 -1
  149. package/dist/lib/model-utils.d.ts +0 -5
  150. package/dist/lib/model-utils.d.ts.map +0 -1
  151. package/dist/lib/model-utils.js +0 -45
  152. package/dist/lib/model-utils.js.map +0 -1
  153. package/dist/lib/model.d.ts +0 -41
  154. package/dist/lib/model.d.ts.map +0 -1
  155. package/dist/lib/model.js +0 -176
  156. package/dist/lib/model.js.map +0 -1
  157. package/dist/lib/render-loop.d.ts +0 -14
  158. package/dist/lib/render-loop.d.ts.map +0 -1
  159. package/dist/lib/render-loop.js +0 -49
  160. package/dist/lib/render-loop.js.map +0 -1
  161. package/src/bundle.ts +0 -4
  162. package/src/geometry/primitive-utils.ts +0 -30
  163. package/src/lib/model-utils.ts +0 -124
  164. package/src/lib/model.ts +0 -179
  165. package/src/lib/render-loop.ts +0 -58
  166. /package/dist/{lib → animation-loop}/animation-props.js +0 -0
package/dist/index.d.ts CHANGED
@@ -1,10 +1,22 @@
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 { ShaderModuleUniforms } from './shadertools/shader-module-uniforms';
14
+ export { ClipSpace } from './lib/clip-space';
15
+ export { ScenegraphNode } from './scenegraph/scenegraph-node';
16
+ export { GroupNode } from './scenegraph/group-node';
17
+ export { ModelNode } from './scenegraph/model-node';
18
+ export type { GeometryProps } from './geometry/geometry';
19
+ export { Geometry } from './geometry/geometry';
8
20
  export type { ConeGeometryProps } from './geometries/cone-geometry';
9
21
  export { ConeGeometry } from './geometries/cone-geometry';
10
22
  export type { CubeGeometryProps } from './geometries/cube-geometry';
@@ -19,6 +31,4 @@ export type { SphereGeometryProps } from './geometries/sphere-geometry';
19
31
  export { SphereGeometry } from './geometries/sphere-geometry';
20
32
  export type { TruncatedConeGeometryProps } from './geometries/truncated-cone-geometry';
21
33
  export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
22
- export { Timeline } from './animation/timeline';
23
- export { KeyFrames } from './animation/key-frames';
24
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAM9D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAGxD,YAAY,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AACxD,YAAY,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MA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-1,14 +1,22 @@
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 { ShaderModuleUniforms } from "./shadertools/shader-module-uniforms.js";
10
+ export { ClipSpace } from "./lib/clip-space.js";
11
+ export { ScenegraphNode } from "./scenegraph/scenegraph-node.js";
12
+ export { GroupNode } from "./scenegraph/group-node.js";
13
+ export { ModelNode } from "./scenegraph/model-node.js";
14
+ export { Geometry } from "./geometry/geometry.js";
15
+ export { ConeGeometry } from "./geometries/cone-geometry.js";
16
+ export { CubeGeometry } from "./geometries/cube-geometry.js";
17
+ export { CylinderGeometry } from "./geometries/cylinder-geometry.js";
18
+ export { IcoSphereGeometry } from "./geometries/ico-sphere-geometry.js";
19
+ export { PlaneGeometry } from "./geometries/plane-geometry.js";
20
+ export { SphereGeometry } from "./geometries/sphere-geometry.js";
21
+ export { TruncatedConeGeometry } from "./geometries/truncated-cone-geometry.js";
14
22
  //# 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","ShaderModuleUniforms","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// shadertools\nexport {ShaderModuleUniforms} from './shadertools/shader-module-uniforms';\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,oBAAoB;AAAA,SAGpBC,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, 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;AAC3C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAuBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU;CAqB9C"}
@@ -1,2 +1,49 @@
1
+ import { glsl } from '@luma.gl/core';
2
+ import { Model } from "../model/model.js";
3
+ import { Geometry } from "../geometry/geometry.js";
4
+ const CLIPSPACE_VERTEX_SHADER = glsl`\
5
+ attribute vec2 aClipSpacePosition;
6
+ attribute vec2 aTexCoord;
7
+ attribute vec2 aCoordinate;
1
8
 
9
+ varying vec2 position;
10
+ varying vec2 coordinate;
11
+ varying vec2 uv;
12
+
13
+ void main(void) {
14
+ gl_Position = vec4(aClipSpacePosition, 0., 1.);
15
+ position = aClipSpacePosition;
16
+ coordinate = aCoordinate;
17
+ uv = aTexCoord;
18
+ }
19
+ `;
20
+ const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
21
+ export class ClipSpace extends Model {
22
+ constructor(device, opts) {
23
+ const TEX_COORDS = POSITIONS.map(coord => coord === -1 ? 0 : coord);
24
+ super(device, {
25
+ ...opts,
26
+ vs: CLIPSPACE_VERTEX_SHADER,
27
+ vertexCount: 4,
28
+ geometry: new Geometry({
29
+ topology: 'triangle-strip',
30
+ vertexCount: 4,
31
+ attributes: {
32
+ aClipSpacePosition: {
33
+ size: 2,
34
+ value: new Float32Array(POSITIONS)
35
+ },
36
+ aTexCoord: {
37
+ size: 2,
38
+ value: new Float32Array(TEX_COORDS)
39
+ },
40
+ aCoordinate: {
41
+ size: 2,
42
+ value: new Float32Array(TEX_COORDS)
43
+ }
44
+ }
45
+ })
46
+ });
47
+ }
48
+ }
2
49
  //# 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","Model","Geometry","CLIPSPACE_VERTEX_SHADER","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","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 {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, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n 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;AAAC,SACnCC,KAAK;AAAA,SACLC,QAAQ;AAEhB,MAAMC,uBAAuB,GAAGH,IAAK;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAGD,MAAMI,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,SAASJ,KAAK,CAAC;EACnCK,WAAWA,CAACC,MAAc,EAAEC,IAAiB,EAAE;IAC7C,MAAMC,UAAU,GAAGL,SAAS,CAACM,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAGA,KAAM,CAAC;IAEvE,KAAK,CACHJ,MAAM,EACN;MACE,GAAGC,IAAI;MACPI,EAAE,EAAET,uBAAuB;MAC3BU,WAAW,EAAE,CAAC;MACdC,QAAQ,EAAE,IAAIZ,QAAQ,CAAC;QACrBa,QAAQ,EAAE,gBAAgB;QAC1BF,WAAW,EAAE,CAAC;QACdG,UAAU,EAAE;UACVC,kBAAkB,EAAE;YAACC,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAAChB,SAAS;UAAC,CAAC;UACjEiB,SAAS,EAAE;YAACH,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACX,UAAU;UAAC,CAAC;UACzDa,WAAW,EAAE;YAACJ,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACX,UAAU;UAAC;QAC5D;MACF,CAAC;IACH,CACF,CAAC;EACH;AACF"}
@@ -1,55 +1,27 @@
1
- import type { RenderPipelineParameters } from '@luma.gl/api';
2
- import { Device, RenderPipeline } from '@luma.gl/api/';
3
- import type { ShaderModule } from '@luma.gl/shadertools';
4
- export declare type GetRenderPipelineOptions = {
1
+ import type { RenderPipelineProps } from '@luma.gl/core';
2
+ import { Device, RenderPipeline } from '@luma.gl/core';
3
+ /** Todo - should be same as RenderPipelineProps */
4
+ export type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
5
5
  vs: string;
6
6
  fs: string;
7
- topology: any;
8
- parameters?: RenderPipelineParameters;
9
- modules?: ShaderModule[];
10
- defines?: Record<string, string>;
11
- inject?: Record<string, string>;
12
- transpileToGLSL100?: boolean;
13
- varyings?: string[];
14
- bufferMode?: number;
15
7
  };
16
- export declare type GetComputePipelineOptions = {
17
- cs: string;
18
- parameters?: RenderPipelineParameters;
19
- modules?: ShaderModule[];
20
- defines?: Record<string, string>;
21
- inject?: Record<string, string>;
22
- transpileToGLSL100?: boolean;
23
- varyings?: string[];
24
- bufferMode?: number;
25
- };
26
- /** Efficiently create shared pipelines with varying parameters */
27
- export default class PipelineFactory {
8
+ /**
9
+ * Efficiently creates / caches pipelines
10
+ */
11
+ export declare class PipelineFactory {
12
+ static defaultProps: Required<PipelineFactoryProps>;
28
13
  readonly device: Device;
29
- stateHash: number;
30
14
  private _hashCounter;
31
15
  private readonly _hashes;
32
16
  private readonly _useCounts;
33
17
  private readonly _pipelineCache;
34
- private readonly _getUniforms;
35
- private readonly _hookFunctions;
36
- private _defaultModules;
37
18
  static getDefaultPipelineFactory(device: Device): PipelineFactory;
38
19
  constructor(device: Device);
39
- addShaderHook(hook: any, opts?: any): void;
40
- createRenderPipeline(options: GetRenderPipelineOptions): {
41
- renderPipeline: RenderPipeline;
42
- getUniforms: (props: Record<string, Record<string, any>>) => Record<string, any>;
43
- };
20
+ createRenderPipeline(options: PipelineFactoryProps): RenderPipeline;
44
21
  release(pipeline: RenderPipeline): void;
45
- getUniforms(pipeline: RenderPipeline): any;
46
- _createRenderPipeline(props: GetRenderPipelineOptions): {
47
- renderPipeline: RenderPipeline;
48
- getUniforms: (props: Record<string, Record<string, any>>) => Record<string, any>;
49
- };
22
+ _createRenderPipeline(props: PipelineFactoryProps): RenderPipeline;
50
23
  /** Calculate a hash based on all the inputs for a render pipeline */
51
- _hashRenderPipeline(props: GetRenderPipelineOptions): string;
24
+ _hashRenderPipeline(props: PipelineFactoryProps): string;
52
25
  _getHash(key: string): number;
53
- _getModuleList(appModules?: ShaderModule[]): ShaderModule[];
54
26
  }
55
27
  //# sourceMappingURL=pipeline-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,wBAAwB,EAAC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAC,MAAM,EAAE,cAAc,EAAkB,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,oBAAY,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,MAAC;IACT,UAAU,CAAC,EAAE,wBAAwB,CAAC;IAEtC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,wBAAwB,CAAC;IAEtC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,QAAQ,CA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+1,93 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { assembleShaders } from '@luma.gl/shadertools';
3
- const DEFAULT_RENDER_PIPELINE_OPTIONS = {
4
- vs: '',
5
- fs: '',
6
- modules: [],
7
- defines: {},
8
- inject: {},
9
- transpileToGLSL100: false,
10
- varyings: [],
11
- bufferMode: 0x8c8d,
12
- topology: 'triangle-list',
13
- parameters: {}
14
- };
15
- export default class PipelineFactory {
1
+ import { RenderPipeline } from '@luma.gl/core';
2
+ export class PipelineFactory {
16
3
  static getDefaultPipelineFactory(device) {
17
- device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
18
- return device.defaultPipelineFactory;
4
+ device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);
5
+ return device._lumaData.defaultPipelineFactory;
19
6
  }
20
-
21
7
  constructor(device) {
22
- _defineProperty(this, "device", void 0);
23
-
24
- _defineProperty(this, "stateHash", 0);
25
-
26
- _defineProperty(this, "_hashCounter", 0);
27
-
28
- _defineProperty(this, "_hashes", {});
29
-
30
- _defineProperty(this, "_useCounts", {});
31
-
32
- _defineProperty(this, "_pipelineCache", {});
33
-
34
- _defineProperty(this, "_getUniforms", {});
35
-
36
- _defineProperty(this, "_hookFunctions", []);
37
-
38
- _defineProperty(this, "_defaultModules", []);
39
-
8
+ this.device = void 0;
9
+ this._hashCounter = 0;
10
+ this._hashes = {};
11
+ this._useCounts = {};
12
+ this._pipelineCache = {};
40
13
  this.device = device;
41
14
  }
42
-
43
- addShaderHook(hook, opts) {
44
- if (opts) {
45
- hook = Object.assign(opts, {
46
- hook
47
- });
48
- }
49
-
50
- this._hookFunctions.push(hook);
51
-
52
- this.stateHash++;
53
- }
54
-
55
15
  createRenderPipeline(options) {
56
- const props = { ...DEFAULT_RENDER_PIPELINE_OPTIONS,
16
+ const props = {
17
+ ...PipelineFactory.defaultProps,
57
18
  ...options
58
19
  };
59
-
60
- const modules = this._getModuleList(props.modules);
61
-
62
- const hash = this._hashRenderPipeline({ ...props,
63
- modules
20
+ const hash = this._hashRenderPipeline({
21
+ ...props
64
22
  });
65
-
66
23
  if (!this._pipelineCache[hash]) {
67
- const {
68
- renderPipeline,
69
- getUniforms
70
- } = this._createRenderPipeline({ ...props,
71
- modules
24
+ const pipeline = this.device.createRenderPipeline({
25
+ ...props,
26
+ vs: this.device.createShader({
27
+ stage: 'vertex',
28
+ source: props.vs
29
+ }),
30
+ fs: props.fs ? this.device.createShader({
31
+ stage: 'fragment',
32
+ source: props.fs
33
+ }) : null
72
34
  });
73
-
74
- renderPipeline.hash = hash;
75
- this._pipelineCache[hash] = renderPipeline;
76
-
77
- this._getUniforms[hash] = getUniforms || (x => {});
78
-
35
+ pipeline.hash = hash;
36
+ this._pipelineCache[hash] = pipeline;
79
37
  this._useCounts[hash] = 0;
80
38
  }
81
-
82
39
  this._useCounts[hash]++;
83
- return {
84
- renderPipeline: this._pipelineCache[hash],
85
- getUniforms: this._getUniforms[hash]
86
- };
40
+ return this._pipelineCache[hash];
87
41
  }
88
-
89
42
  release(pipeline) {
90
43
  const hash = pipeline.hash;
91
44
  this._useCounts[hash]--;
92
-
93
45
  if (this._useCounts[hash] === 0) {
94
46
  this._pipelineCache[hash].destroy();
95
-
96
47
  delete this._pipelineCache[hash];
97
- delete this._getUniforms[hash];
98
48
  delete this._useCounts[hash];
99
49
  }
100
50
  }
101
-
102
- getUniforms(pipeline) {
103
- return this._getUniforms[pipeline.hash] || null;
104
- }
105
-
106
51
  _createRenderPipeline(props) {
107
- const platformInfo = {
108
- gpu: this.device.info.gpu,
109
- features: this.device.features
110
- };
111
- const assembled = assembleShaders(platformInfo, { ...props,
112
- hookFunctions: this._hookFunctions
113
- });
114
- const renderPipeline = this.device.createRenderPipeline({ ...props,
52
+ if (!props.fs) {
53
+ throw new Error('fs');
54
+ }
55
+ const pipeline = this.device.createRenderPipeline({
56
+ ...props,
115
57
  vs: this.device.createShader({
116
58
  stage: 'vertex',
117
- source: assembled.vs
59
+ source: props.vs
118
60
  }),
119
- fs: assembled.fs && this.device.createShader({
61
+ fs: props.fs ? this.device.createShader({
120
62
  stage: 'fragment',
121
- source: assembled.fs
122
- })
63
+ source: props.fs
64
+ }) : null
123
65
  });
124
- return {
125
- renderPipeline,
126
- getUniforms: assembled.getUniforms
127
- };
66
+ return pipeline;
128
67
  }
129
-
130
68
  _hashRenderPipeline(props) {
131
69
  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();
139
- const defineHashes = [];
140
- const injectHashes = [];
141
-
142
- for (const key of defineKeys) {
143
- defineHashes.push(this._getHash(key));
144
- defineHashes.push(this._getHash(props.defines[key]));
70
+ const fsHash = props.fs ? this._getHash(props.fs) : 0;
71
+ const varyingHash = '-';
72
+ switch (this.device.info.type) {
73
+ case 'webgpu':
74
+ const parameterHash = this._getHash(JSON.stringify(props.parameters));
75
+ const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
76
+ return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
77
+ default:
78
+ return `${vsHash}/${fsHash}V${varyingHash}`;
145
79
  }
146
-
147
- for (const key of injectKeys) {
148
- injectHashes.push(this._getHash(key));
149
- injectHashes.push(this._getHash(props.inject[key]));
150
- }
151
-
152
- const parameterHash = JSON.stringify(props.parameters);
153
- 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
80
  }
155
-
156
81
  _getHash(key) {
157
82
  if (this._hashes[key] === undefined) {
158
83
  this._hashes[key] = this._hashCounter++;
159
84
  }
160
-
161
85
  return this._hashes[key];
162
86
  }
163
-
164
- _getModuleList(appModules = []) {
165
- const modules = new Array(this._defaultModules.length + appModules.length);
166
- const seen = {};
167
- let count = 0;
168
-
169
- for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
170
- const module = this._defaultModules[i];
171
- const name = module.name;
172
- modules[count++] = module;
173
- seen[name] = true;
174
- }
175
-
176
- for (let i = 0, len = appModules.length; i < len; ++i) {
177
- const module = appModules[i];
178
- const name = module.name;
179
-
180
- if (!seen[name]) {
181
- modules[count++] = module;
182
- seen[name] = true;
183
- }
184
- }
185
-
186
- modules.length = count;
187
- return modules;
188
- }
189
-
190
87
  }
88
+ PipelineFactory.defaultProps = {
89
+ ...RenderPipeline.defaultProps,
90
+ vs: undefined,
91
+ fs: undefined
92
+ };
191
93
  //# 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;A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D,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":["RenderPipeline","PipelineFactory","getDefaultPipelineFactory","device","_lumaData","defaultPipelineFactory","constructor","_hashCounter","_hashes","_useCounts","_pipelineCache","createRenderPipeline","options","props","defaultProps","hash","_hashRenderPipeline","pipeline","vs","createShader","stage","source","fs","release","destroy","_createRenderPipeline","Error","vsHash","_getHash","fsHash","varyingHash","info","type","parameterHash","JSON","stringify","parameters","bufferLayoutHash","bufferLayout","topology","key","undefined"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {RenderPipelineProps} from '@luma.gl/core';\nimport {Device, RenderPipeline} from '@luma.gl/core';\n\n/** Todo - should be same as RenderPipelineProps */\nexport type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Only accepts string shaders\n vs: string;\n fs: string;\n};\n\n/** \n * Efficiently creates / caches pipelines\n */\nexport class PipelineFactory {\n static defaultProps: Required<PipelineFactoryProps> = {\n ...RenderPipeline.defaultProps,\n vs: undefined!,\n fs: undefined!\n }\n\n readonly device: Device;\n\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);\n return device._lumaData.defaultPipelineFactory as PipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n createRenderPipeline(options: PipelineFactoryProps): RenderPipeline {\n const props: Required<PipelineFactoryProps> = {...PipelineFactory.defaultProps, ...options};\n\n const hash = this._hashRenderPipeline({...props});\n\n if (!this._pipelineCache[hash]) {\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null,\n });\n\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return this._pipelineCache[hash];\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._useCounts[hash];\n }\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: PipelineFactoryProps): RenderPipeline {\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null,\n });\n\n return pipeline;\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: PipelineFactoryProps): string {\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n // WebGL specific\n // const {varyings = [], bufferMode = {}} = props;\n // const varyingHashes = varyings.map((v) => this._getHash(v));\n const varyingHash = '-'; // `${varyingHashes.join('/')}B${bufferMode}`\n\n switch (this.device.info.type) {\n case 'webgpu':\n // On WebGPU we need to rebuild the pipeline if topology, parameters or bufferLayout change\n const parameterHash = this._getHash(JSON.stringify(props.parameters));\n const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));\n // TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?\n // create a deepHash() to deduplicate?\n return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;\n default:\n // WebGL is more dynamic\n return `${vsHash}/${fsHash}V${varyingHash}`;\n }\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\n"],"mappings":"AAEA,SAAgBA,cAAc,QAAO,eAAe;AAYpD,OAAO,MAAMC,eAAe,CAAC;EAc3B,OAAOC,yBAAyBA,CAACC,MAAc,EAAmB;IAChEA,MAAM,CAACC,SAAS,CAACC,sBAAsB,GAAGF,MAAM,CAACC,SAAS,CAACC,sBAAsB,IAAI,IAAIJ,eAAe,CAACE,MAAM,CAAC;IAChH,OAAOA,MAAM,CAACC,SAAS,CAACC,sBAAsB;EAChD;EAEAC,WAAWA,CAACH,MAAc,EAAE;IAAA,KAZnBA,MAAM;IAAA,KAEPI,YAAY,GAAW,CAAC;IAAA,KACfC,OAAO,GAA2B,CAAC,CAAC;IAAA,KACpCC,UAAU,GAA2B,CAAC,CAAC;IAAA,KACvCC,cAAc,GAAmC,CAAC,CAAC;IAQlE,IAAI,CAACP,MAAM,GAAGA,MAAM;EACtB;EAEAQ,oBAAoBA,CAACC,OAA6B,EAAkB;IAClE,MAAMC,KAAqC,GAAG;MAAC,GAAGZ,eAAe,CAACa,YAAY;MAAE,GAAGF;IAAO,CAAC;IAE3F,MAAMG,IAAI,GAAG,IAAI,CAACC,mBAAmB,CAAC;MAAC,GAAGH;IAAK,CAAC,CAAC;IAEjD,IAAI,CAAC,IAAI,CAACH,cAAc,CAACK,IAAI,CAAC,EAAE;MAC9B,MAAME,QAAQ,GAAG,IAAI,CAACd,MAAM,CAACQ,oBAAoB,CAAC;QAChD,GAAGE,KAAK;QACRK,EAAE,EAAE,IAAI,CAACf,MAAM,CAACgB,YAAY,CAAC;UAACC,KAAK,EAAE,QAAQ;UAAEC,MAAM,EAAER,KAAK,CAACK;QAAE,CAAC,CAAC;QACjEI,EAAE,EAAET,KAAK,CAACS,EAAE,GAA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