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

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 (129) hide show
  1. package/dist/animation/key-frames.d.ts +1 -0
  2. package/dist/animation/key-frames.d.ts.map +1 -1
  3. package/dist/animation/key-frames.js.map +1 -1
  4. package/dist/animation/timeline.d.ts +1 -1
  5. package/dist/animation/timeline.d.ts.map +1 -1
  6. package/dist/animation/timeline.js.map +1 -1
  7. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  8. package/dist/geometries/cone-geometry.js +1 -1
  9. package/dist/geometries/cone-geometry.js.map +1 -1
  10. package/dist/geometries/cube-geometry.d.ts +4 -0
  11. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  12. package/dist/geometries/cube-geometry.js +30 -7
  13. package/dist/geometries/cube-geometry.js.map +1 -1
  14. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  15. package/dist/geometries/cylinder-geometry.js +1 -1
  16. package/dist/geometries/cylinder-geometry.js.map +1 -1
  17. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  18. package/dist/geometries/ico-sphere-geometry.js +1 -1
  19. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  20. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  21. package/dist/geometries/plane-geometry.js +1 -1
  22. package/dist/geometries/plane-geometry.js.map +1 -1
  23. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  24. package/dist/geometries/sphere-geometry.js +1 -1
  25. package/dist/geometries/sphere-geometry.js.map +1 -1
  26. package/dist/geometries/truncated-cone-geometry.d.ts +15 -3
  27. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/truncated-cone-geometry.js +29 -15
  29. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  30. package/dist/geometry/geometry-table.d.ts +15 -0
  31. package/dist/geometry/geometry-table.d.ts.map +1 -0
  32. package/dist/geometry/geometry-table.js +2 -0
  33. package/dist/{transform/transform-types.js.map → geometry/geometry-table.js.map} +1 -1
  34. package/dist/geometry/geometry-utils.js.map +1 -1
  35. package/dist/geometry/geometry.d.ts +34 -7
  36. package/dist/geometry/geometry.d.ts.map +1 -1
  37. package/dist/geometry/geometry.js +33 -11
  38. package/dist/geometry/geometry.js.map +1 -1
  39. package/dist/geometry/primitive-utils.d.ts +1 -0
  40. package/dist/geometry/primitive-utils.d.ts.map +1 -0
  41. package/dist/geometry/primitive-utils.js +2 -0
  42. package/dist/geometry/primitive-utils.js.map +1 -0
  43. package/dist/index.d.ts +3 -5
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -4
  46. package/dist/index.js.map +1 -1
  47. package/dist/lib/animation-loop.d.ts +14 -73
  48. package/dist/lib/animation-loop.d.ts.map +1 -1
  49. package/dist/lib/animation-loop.js +39 -160
  50. package/dist/lib/animation-loop.js.map +1 -1
  51. package/dist/lib/animation-props.d.ts +24 -0
  52. package/dist/lib/animation-props.d.ts.map +1 -0
  53. package/dist/lib/animation-props.js +2 -0
  54. package/dist/lib/animation-props.js.map +1 -0
  55. package/dist/lib/clip-space.d.ts +1 -0
  56. package/dist/lib/clip-space.d.ts.map +1 -0
  57. package/dist/lib/clip-space.js +2 -0
  58. package/dist/lib/clip-space.js.map +1 -0
  59. package/dist/lib/model-utils.d.ts +4 -3
  60. package/dist/lib/model-utils.d.ts.map +1 -1
  61. package/dist/lib/model-utils.js +24 -70
  62. package/dist/lib/model-utils.js.map +1 -1
  63. package/dist/lib/model.d.ts +34 -104
  64. package/dist/lib/model.d.ts.map +1 -1
  65. package/dist/lib/model.js +108 -505
  66. package/dist/lib/model.js.map +1 -1
  67. package/dist/lib/pipeline-factory.d.ts +55 -0
  68. package/dist/lib/pipeline-factory.d.ts.map +1 -0
  69. package/dist/lib/pipeline-factory.js +191 -0
  70. package/dist/lib/pipeline-factory.js.map +1 -0
  71. package/dist/lib/render-loop.d.ts +4 -17
  72. package/dist/lib/render-loop.d.ts.map +1 -1
  73. package/dist/lib/render-loop.js +14 -21
  74. package/dist/lib/render-loop.js.map +1 -1
  75. package/package.json +5 -5
  76. package/src/animation/key-frames.ts +1 -0
  77. package/src/animation/timeline.ts +1 -1
  78. package/src/geometries/cone-geometry.ts +1 -1
  79. package/src/geometries/cube-geometry.ts +159 -8
  80. package/src/geometries/cylinder-geometry.ts +1 -1
  81. package/src/geometries/ico-sphere-geometry.ts +1 -1
  82. package/src/geometries/plane-geometry.ts +1 -1
  83. package/src/geometries/sphere-geometry.ts +2 -2
  84. package/src/geometries/truncated-cone-geometry.ts +30 -12
  85. package/src/geometry/geometry-table.ts +16 -0
  86. package/src/geometry/geometry-utils.ts +1 -1
  87. package/src/geometry/geometry.ts +58 -13
  88. package/src/geometry/primitive-utils.ts +30 -0
  89. package/src/index.ts +7 -8
  90. package/src/lib/animation-loop.ts +85 -274
  91. package/src/lib/animation-props.ts +31 -0
  92. package/src/{utils → lib}/clip-space.ts +5 -2
  93. package/src/lib/model-utils.ts +60 -32
  94. package/src/lib/model.ts +126 -642
  95. package/src/lib/pipeline-factory.ts +225 -0
  96. package/src/lib/render-loop.ts +21 -19
  97. package/dist/lib/program-manager.d.ts +0 -39
  98. package/dist/lib/program-manager.d.ts.map +0 -1
  99. package/dist/lib/program-manager.js +0 -175
  100. package/dist/lib/program-manager.js.map +0 -1
  101. package/dist/transform/buffer-transform.d.ts +0 -36
  102. package/dist/transform/buffer-transform.d.ts.map +0 -1
  103. package/dist/transform/buffer-transform.js +0 -255
  104. package/dist/transform/buffer-transform.js.map +0 -1
  105. package/dist/transform/texture-transform.d.ts +0 -57
  106. package/dist/transform/texture-transform.d.ts.map +0 -1
  107. package/dist/transform/texture-transform.js +0 -412
  108. package/dist/transform/texture-transform.js.map +0 -1
  109. package/dist/transform/transform-shader-utils.d.ts +0 -26
  110. package/dist/transform/transform-shader-utils.d.ts.map +0 -1
  111. package/dist/transform/transform-shader-utils.js +0 -149
  112. package/dist/transform/transform-shader-utils.js.map +0 -1
  113. package/dist/transform/transform-types.d.ts +0 -44
  114. package/dist/transform/transform-types.d.ts.map +0 -1
  115. package/dist/transform/transform-types.js +0 -2
  116. package/dist/transform/transform.d.ts +0 -47
  117. package/dist/transform/transform.d.ts.map +0 -1
  118. package/dist/transform/transform.js +0 -198
  119. package/dist/transform/transform.js.map +0 -1
  120. package/dist/utils/clip-space.d.ts +0 -5
  121. package/dist/utils/clip-space.d.ts.map +0 -1
  122. package/dist/utils/clip-space.js +0 -34
  123. package/dist/utils/clip-space.js.map +0 -1
  124. package/src/lib/program-manager.ts +0 -187
  125. package/src/transform/buffer-transform.ts +0 -214
  126. package/src/transform/texture-transform.ts +0 -344
  127. package/src/transform/transform-shader-utils.ts +0 -169
  128. package/src/transform/transform-types.ts +0 -42
  129. package/src/transform/transform.ts +0 -189
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/model.ts"],"names":["GL","WebGLDevice","Program","VertexArray","clear","TransformFeedback","Buffer","log","isObjectEmpty","uid","assert","getDebugTableForUniforms","getDebugTableForVertexArray","getDebugTableForProgramConfiguration","ProgramManager","getBuffersFromGeometry","LOG_DRAW_PRIORITY","LOG_DRAW_TIMEOUT","ERR_MODEL_PARAMS","NOOP","DRAW_PARAMS","Model","constructor","device","props","id","webglDevice","attach","gl","initialize","programManager","getDefaultProgramManager","_programManagerState","_managedProgram","program","vs","fs","modules","defines","inject","varyings","bufferMode","transpileToGLSL100","programProps","vertexArray","_programDirty","userData","needsRedraw","_attributes","attributes","uniforms","pickable","_checkProgram","setUniforms","Object","assign","getModuleUniforms","moduleSettings","drawMode","undefined","TRIANGLES","vertexCount","geometryBuffers","isInstanced","instanced","instanceCount","_setModelProps","geometry","Number","isFinite","setProps","destroy","key","delete","release","_deleteGeometryBuffers","getDrawMode","getVertexCount","getInstanceCount","getAttributes","getProgram","setProgram","getUniforms","setDrawMode","setVertexCount","setInstanceCount","setGeometry","setAttributes","normalizedAttributes","name","attribute","getValue","opts","updateModuleSettings","draw","framebuffer","transformFeedback","parameters","logPriority","priority","_logDrawCallStart","drawParams","getDrawParams","isIndexed","indexType","indexOffset","vertexArrayInstanced","warn","onBeforeRender","onAfterRender","didDraw","offset","_logDrawCallEnd","transform","discard","feedbackBuffers","unbindModels","_setFeedbackBuffers","RASTERIZER_DISCARD","forEach","model","unbindBuffers","bindBuffers","render","_feedbackBuffers","needsUpdate","stateHash","get","buffer","_setAnimationProps","animationProps","animated","setBuffers","logLevel","logDrawTimeout","Date","now","lastLogTime","group","collapsed","level","attributeTable","header","table","uniformTable","unusedTable","unusedCount","missingTable","count","missingCount","undefinedOnly","keys","configTable","configuration","message","groupEnd"],"mappings":";AAEA,OAAOA,EAAP,MAAe,oBAAf;AAEA,SACEC,WADF,EAEEC,OAFF,EAGEC,WAHF,EAIEC,KAJF,EAKEC,iBALF,EAMEC,MANF,EAOEC,GAPF,EAQEC,aARF,EASEC,GATF,EAUEC,MAVF,QAWO,gBAXP;AAYA,SACEC,wBADF,EAEEC,2BAFF,EAGEC,oCAHF,QAIO,gBAJP;AAKA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,SAAQC,sBAAR,QAAqC,eAArC;AAEA,MAAMC,iBAAiB,GAAG,CAA1B;AACA,MAAMC,gBAAgB,GAAG,KAAzB;AAEA,MAAMC,gBAAgB,GAAG,sCAAzB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,WAAW,GAAG,EAApB;AA0FA,eAAe,MAAMC,KAAN,CAAY;AAwCzBC,EAAAA,WAAW,CAACC,MAAD,EAASC,KAAiB,GAAG,EAA7B,EAAiC;AAAA;;AAAA;;AAAA;;AAAA,sCAnCf,KAmCe;;AAAA;;AAAA;;AAAA,yCA/BtB,CA+BsB;;AAAA;;AAAA,sCA5BZ,EA4BY;;AAAA,yCA3BrB,IA2BqB;;AAAA,wCA1BV,EA0BU;;AAAA,yCAzBT,EAyBS;;AAAA,sCAxBZ,EAwBY;;AAAA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AAC,KAAK+B,WAAL,CAAiB6G,aAAlB,CAAxD;AAEAlJ,IAAAA,GAAG,CAACwI,KAAJ,CAAUV,QAAV,EAAoBQ,cAApB;AAEAtI,IAAAA,GAAG,CAACwI,KAAJ,CAAUV,QAAV,EAAoBW,YAApB;AAEAzI,IAAAA,GAAG,CAACwI,KAAJ,CAAUV,QAAQ,GAAG,CAArB,EAAwBmB,WAAxB;;AAEA,QAAIzD,WAAJ,EAAiB;AACfA,MAAAA,WAAW,CAACxF,GAAZ,CAAgB;AAAC8H,QAAAA,QAAQ,EAAErH,iBAAX;AAA8B0I,QAAAA,OAAO,wBAAiB3D,WAAW,CAACtE,EAA7B;AAArC,OAAhB;AACD;;AAEDlB,IAAAA,GAAG,CAACoJ,QAAJ,CAAa3I,iBAAb;AACD;;AA7jBwB","sourcesContent":["// luma.gl, MIT license\nimport {Device} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport type {ProgramProps} from '@luma.gl/webgl';\nimport {\n WebGLDevice,\n Program,\n VertexArray,\n clear,\n TransformFeedback,\n Buffer,\n log,\n isObjectEmpty,\n uid,\n assert\n} from '@luma.gl/webgl';\nimport {\n getDebugTableForUniforms,\n getDebugTableForVertexArray,\n getDebugTableForProgramConfiguration\n} from '@luma.gl/webgl';\nimport ProgramManager from './program-manager';\nimport {getBuffersFromGeometry} from './model-utils';\n\nconst LOG_DRAW_PRIORITY = 2;\nconst LOG_DRAW_TIMEOUT = 10000;\n\nconst ERR_MODEL_PARAMS = 'Model needs drawMode and vertexCount';\n\nconst NOOP = () => {};\nconst DRAW_PARAMS = {};\n\nexport type ModelProps = ProgramProps & {\n id?: string;\n\n // program props\n // vs,\n // fs,\n varyings?: string[];\n bufferMode?;\n\n program?: Program;\n modules?: any[];\n defines?: Record<string, number | boolean>;\n inject?: Record<string, any>;\n transpileToGLSL100?: boolean;\n\n moduleSettings?: object; // UniformsOptions\n attributes?: object;\n uniforms?: object; // Uniforms\n geometry?: object; // Geometry\n vertexCount?: number\n drawMode?: number\n isInstanced?: boolean\n instanceCount?: number\n programManager?: ProgramManager\n onBeforeRender?: () => void\n onAfterRender?: () => void\n _feedbackBuffers?: object; // FeedbackBuffers\n\n // Deprecated?\n isIndexed?: boolean;\n indexType?;\n indexOffset?: number;\n vertexArrayInstanced?: boolean;\n\n /** @deprecated Use isInstanced */\n instanced?: boolean\n};\n\n\nexport type ModelDrawOptions = {\n moduleSettings?;\n framebuffer?;\n uniforms?;\n attributes?;\n transformFeedback?;\n parameters?;\n vertexArray?;\n};\n\n/* TODO - from autogenerated declarations, copy types and delete\ninterface ModelProps extends ProgramProps {\n id?: string\n moduleSettings?: UniformsOptions\n uniforms?: Uniforms\n geometry?: Geometry\n vertexCount?: number\n drawMode?: number\n programManager?: ProgramManager\n onBeforeRender?: () => void\n onAfterRender?: () => void\n _feedbackBuffers?: FeedbackBuffers\n}\n\ninterface DrawOpts {\n moduleSettings?: UniformsOptions\n framebuffer: Framebuffer\n uniforms?: Uniforms\n attributes?: Attributes\n parameters?: Parameters\n transformFeedback?: TransformFeedback\n vertexArray?: VertexArray\n}\n\ninterface ClearOpts {\n framebuffer?: Framebuffer\n color?: boolean\n depth?: boolean\n stencil?: boolean\n}\n\ninterface TransformOpts extends DrawOpts {\n discard: boolean\n feedbackBuffers: FeedbackBuffers\n unbindModels: Array<Model>\n parameters: Parameters\n}\n*/\n\nexport default class Model {\n readonly device: Device;\n readonly gl: WebGLRenderingContext;\n\n readonly id: string;\n readonly animated: boolean = false;\n programManager: ProgramManager;\n vertexCount: number;\n\n lastLogTime: number = 0; // TODO - move to probe.gl\n\n props: ModelProps;\n userData: Record<string, any> = {};\n needsRedraw: boolean = true;\n attributes: Record<string, any> = {};\n _attributes: Record<string, any> = {};\n uniforms: Record<string, any> = {};\n\n drawMode;\n instanceCount: number;\n pickable: boolean = true;\n\n programProps: ProgramProps & {program?: Program; modules; inject; defines; varyings; bufferMode; transpileToGLSL100;};\n vertexArray: VertexArray;\n program: Program;\n transformFeedback: TransformFeedback | undefined;\n _programDirty = true;\n _programManagerState;\n _managedProgram;\n\n // Track buffers created by setGeometry\n geometryBuffers = {};\n // geometry might have set drawMode and vertexCount\n isInstanced: boolean;\n // TODO - just to unbreak deck.gl 7.0-beta, remove as soon as updated\n geometry = {};\n\n constructor(device: Device, props?: ModelProps);\n /* @deprecated */\n constructor(gl: WebGLRenderingContext, props?: ModelProps);\n constructor(device, props: ModelProps = {}) {\n // Deduce a helpful id\n const {id = uid('model')} = props;\n this.id = id;\n const webglDevice = WebGLDevice.attach(device);\n this.device = webglDevice;\n this.gl = webglDevice.gl;\n this.id = props.id || uid('Model');\n this.initialize(props);\n }\n\n initialize(props: ModelProps) {\n this.props = {};\n\n this.programManager = props.programManager || ProgramManager.getDefaultProgramManager(this.device);\n this._programManagerState = -1;\n this._managedProgram = false;\n\n const {\n program = null,\n vs,\n fs,\n modules,\n defines,\n inject,\n varyings,\n bufferMode,\n transpileToGLSL100\n } = props;\n\n this.programProps = {\n program,\n modules,\n vs,\n fs,\n defines,\n inject,\n varyings,\n bufferMode,\n transpileToGLSL100\n };\n this.program = null;\n this.vertexArray = null;\n this._programDirty = true;\n\n // Initialize state\n this.userData = {};\n this.needsRedraw = true;\n\n // Attributes and buffers\n // Model manages auto Buffer creation from typed arrays\n this._attributes = {}; // All attributes\n this.attributes = {}; // User defined attributes\n\n // Model manages uniform animation\n this.uniforms = {};\n\n // picking options\n this.pickable = true;\n\n this._checkProgram();\n\n this.setUniforms(\n Object.assign(\n {},\n this.getModuleUniforms(props.moduleSettings) // Get unforms for supplied parameters\n )\n );\n\n this.drawMode = props.drawMode !== undefined ? props.drawMode : GL.TRIANGLES;\n this.vertexCount = props.vertexCount || 0;\n\n // Track buffers created by setGeometry\n this.geometryBuffers = {};\n\n // geometry might have set drawMode and vertexCount\n this.isInstanced = props.isInstanced || props.instanced || props.instanceCount > 0;\n\n this._setModelProps(props);\n\n // TODO - just to unbreak deck.gl 7.0-beta, remove as soon as updated\n this.geometry = {};\n\n // assert(program || program instanceof Program);\n assert(this.drawMode !== undefined && Number.isFinite(this.vertexCount), ERR_MODEL_PARAMS);\n }\n\n setProps(props) {\n this._setModelProps(props);\n }\n\n destroy(): void {\n // delete all attributes created by this model\n // TODO - should buffer deletes be handled by vertex array?\n for (const key in this._attributes) {\n if (this._attributes[key] !== this.attributes[key]) {\n this._attributes[key].delete();\n }\n }\n\n if (this._managedProgram) {\n this.programManager.release(this.program);\n this._managedProgram = false;\n }\n\n this.vertexArray.delete();\n\n this._deleteGeometryBuffers();\n }\n\n /** @deprecated Use .destroy() */\n delete(): void {\n this.destroy();\n }\n\n // GETTERS\n\n getDrawMode() {\n return this.drawMode;\n }\n\n getVertexCount(): number {\n return this.vertexCount;\n }\n\n getInstanceCount(): number {\n return this.instanceCount;\n }\n\n getAttributes() {\n return this.attributes;\n }\n\n getProgram(): Program {\n return this.program;\n }\n\n setProgram(props): void {\n const {program, vs, fs, modules, defines, inject, varyings, bufferMode, transpileToGLSL100} =\n props;\n this.programProps = {\n program,\n vs,\n fs,\n modules,\n defines,\n inject,\n varyings,\n bufferMode,\n transpileToGLSL100\n };\n this._programDirty = true;\n }\n\n getUniforms() {\n return this.uniforms;\n }\n\n // SETTERS\n\n setDrawMode(drawMode): this {\n this.drawMode = drawMode;\n return this;\n }\n\n setVertexCount(vertexCount): this {\n assert(Number.isFinite(vertexCount));\n this.vertexCount = vertexCount;\n return this;\n }\n\n setInstanceCount(instanceCount): this {\n assert(Number.isFinite(instanceCount));\n this.instanceCount = instanceCount;\n return this;\n }\n\n setGeometry(geometry): this {\n this.drawMode = geometry.drawMode;\n this.vertexCount = geometry.getVertexCount();\n\n this._deleteGeometryBuffers();\n\n this.geometryBuffers = getBuffersFromGeometry(this.gl, geometry);\n this.vertexArray.setAttributes(this.geometryBuffers);\n return this;\n }\n\n setAttributes(attributes = {}): this {\n // Avoid setting needsRedraw if no attributes\n if (isObjectEmpty(attributes)) {\n return this;\n }\n\n const normalizedAttributes = {};\n for (const name in attributes) {\n const attribute = attributes[name];\n // The `getValue` call provides support for deck.gl `Attribute` class\n // TODO - remove once deck refactoring completes\n normalizedAttributes[name] = attribute.getValue ? attribute.getValue() : attribute;\n }\n\n this.vertexArray.setAttributes(normalizedAttributes);\n return this;\n }\n\n // TODO - should actually set the uniforms\n setUniforms(uniforms = {}): this {\n Object.assign(this.uniforms, uniforms);\n return this;\n }\n\n getModuleUniforms(opts?) {\n this._checkProgram();\n\n const getUniforms = this.programManager.getUniforms(this.program);\n\n if (getUniforms) {\n return getUniforms(opts);\n }\n\n return {};\n }\n\n updateModuleSettings(opts?): this {\n const uniforms = this.getModuleUniforms(opts || {});\n return this.setUniforms(uniforms);\n }\n\n // DRAW CALLS\n\n clear(opts): this {\n clear(this.program.gl, opts);\n return this;\n }\n\n draw(opts: ModelDrawOptions = {}): boolean {\n // Lazy update program and vertex array\n this._checkProgram();\n\n const {\n moduleSettings = null,\n framebuffer,\n uniforms = {},\n attributes = {},\n transformFeedback = this.transformFeedback,\n parameters = {},\n vertexArray = this.vertexArray\n } = opts;\n\n // Update model with any just provided attributes, settings or uniforms\n this.setAttributes(attributes);\n this.updateModuleSettings(moduleSettings);\n this.setUniforms(uniforms);\n\n let logPriority;\n\n if (log.priority >= LOG_DRAW_PRIORITY) {\n logPriority = this._logDrawCallStart(LOG_DRAW_PRIORITY);\n }\n\n const drawParams = this.vertexArray.getDrawParams();\n const {\n isIndexed = drawParams.isIndexed,\n indexType = drawParams.indexType,\n indexOffset = drawParams.indexOffset,\n vertexArrayInstanced = drawParams.isInstanced\n } = this.props;\n\n if (vertexArrayInstanced && !this.isInstanced) {\n log.warn('Found instanced attributes on non-instanced model', this.id)();\n }\n\n const {isInstanced, instanceCount} = this;\n\n const {onBeforeRender = NOOP, onAfterRender = NOOP} = this.props;\n\n onBeforeRender();\n\n this.program.setUniforms(this.uniforms);\n\n const didDraw = this.program.draw(\n Object.assign(DRAW_PARAMS, opts, {\n logPriority,\n uniforms: null, // Already set (may contain \"function values\" not understood by Program)\n framebuffer,\n parameters,\n drawMode: this.getDrawMode(),\n vertexCount: this.getVertexCount(),\n vertexArray,\n transformFeedback,\n isIndexed,\n indexType,\n isInstanced,\n instanceCount,\n offset: isIndexed ? indexOffset : 0\n })\n );\n\n onAfterRender();\n\n if (log.priority >= LOG_DRAW_PRIORITY) {\n this._logDrawCallEnd(logPriority, vertexArray, framebuffer);\n }\n\n return didDraw;\n }\n\n // Draw call for transform feedback, TBD...\n transform(opts: ModelDrawOptions = {}): this {\n // @ts-expect-error\n const {discard = true, feedbackBuffers, unbindModels = []} = opts;\n\n let {parameters} = opts;\n\n if (feedbackBuffers) {\n this._setFeedbackBuffers(feedbackBuffers);\n }\n\n if (discard) {\n parameters = Object.assign({}, parameters, {[GL.RASTERIZER_DISCARD]: discard});\n }\n\n unbindModels.forEach((model) => model.vertexArray.unbindBuffers());\n try {\n this.draw(Object.assign({}, opts, {parameters}));\n } finally {\n unbindModels.forEach((model) => model.vertexArray.bindBuffers());\n }\n\n return this;\n }\n\n // DEPRECATED METHODS\n\n render(uniforms = {}): boolean {\n log.warn('Model.render() is deprecated. Use Model.setUniforms() and Model.draw()')();\n return this.setUniforms(uniforms).draw();\n }\n\n // PRIVATE METHODS\n\n _setModelProps(props): void {\n Object.assign(this.props, props);\n\n if ('uniforms' in props) {\n this.setUniforms(props.uniforms);\n }\n\n if ('pickable' in props) {\n this.pickable = props.pickable;\n }\n\n if ('instanceCount' in props) {\n this.instanceCount = props.instanceCount;\n }\n if ('geometry' in props) {\n this.setGeometry(props.geometry);\n }\n\n // webgl settings\n if ('attributes' in props) {\n this.setAttributes(props.attributes);\n }\n if ('_feedbackBuffers' in props) {\n this._setFeedbackBuffers(props._feedbackBuffers);\n }\n }\n\n _checkProgram(): void {\n const needsUpdate =\n this._programDirty || this.programManager.stateHash !== this._programManagerState;\n\n if (!needsUpdate) {\n return;\n }\n\n let {program} = this.programProps;\n\n if (program) {\n this._managedProgram = false;\n } else {\n const {vs, fs, modules, inject, defines, varyings, bufferMode, transpileToGLSL100} =\n this.programProps;\n program = this.programManager.get({\n // @ts-expect-error\n vs,\n // @ts-expect-error\n fs,\n modules,\n inject,\n defines,\n varyings,\n bufferMode,\n transpileToGLSL100\n });\n if (this.program && this._managedProgram) {\n this.programManager.release(this.program);\n }\n this._programManagerState = this.programManager.stateHash;\n this._managedProgram = true;\n }\n\n assert(program instanceof Program, 'Model needs a program');\n\n this._programDirty = false;\n\n if (program === this.program) {\n return;\n }\n\n this.program = program;\n\n if (this.vertexArray) {\n this.vertexArray.setProps({program: this.program, attributes: this.vertexArray.attributes});\n } else {\n this.vertexArray = new VertexArray(this.gl, {program: this.program});\n }\n\n // Make sure we have some reasonable default uniforms in place\n this.setUniforms(\n Object.assign(\n {},\n this.getModuleUniforms() // Get all default uniforms,\n )\n );\n }\n\n _deleteGeometryBuffers(): void {\n for (const name in this.geometryBuffers) {\n // Buffer is raw value (for indices) or first element of [buffer, accessor] pair\n const buffer = this.geometryBuffers[name][0] || this.geometryBuffers[name];\n if (buffer instanceof Buffer) {\n buffer.destroy();\n }\n }\n }\n\n // Updates (evaluates) all function valued uniforms based on a new set of animationProps\n // experimental\n _setAnimationProps(animationProps): void {\n if (this.animated) {\n assert(animationProps, 'Model.draw(): animated uniforms but no animationProps');\n // const animatedUniforms = this._evaluateAnimateUniforms(animationProps);\n // Object.assign(this.uniforms, animatedUniforms);\n }\n }\n\n // Transform Feedback\n\n _setFeedbackBuffers(feedbackBuffers = {}): this {\n // Avoid setting needsRedraw if no feedbackBuffers\n if (isObjectEmpty(feedbackBuffers)) {\n return this;\n }\n\n const {gl} = this.program;\n this.transformFeedback =\n this.transformFeedback ||\n new TransformFeedback(gl, {\n program: this.program\n });\n\n this.transformFeedback.setBuffers(feedbackBuffers);\n return this;\n }\n\n _logDrawCallStart(logLevel: number): number {\n const logDrawTimeout = logLevel > 3 ? 0 : LOG_DRAW_TIMEOUT;\n if (Date.now() - this.lastLogTime < logDrawTimeout) {\n return undefined;\n }\n\n this.lastLogTime = Date.now();\n\n log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, {collapsed: log.level <= 2})();\n\n return logLevel;\n }\n\n _logDrawCallEnd(logLevel, vertexArray, uniforms, framebuffer?): void {\n // HACK: logLevel === undefined means logDrawCallStart didn't run\n if (logLevel === undefined) {\n return;\n }\n\n const attributeTable = getDebugTableForVertexArray({\n vertexArray,\n header: `${this.id} attributes`,\n // @ts-expect-error\n attributes: this._attributes\n });\n\n const {\n table: uniformTable,\n unusedTable,\n unusedCount\n } = getDebugTableForUniforms({\n header: `${this.id} uniforms`,\n program: this.program,\n uniforms: Object.assign({}, this.program.uniforms, uniforms)\n });\n\n // log missing uniforms\n const {table: missingTable, count: missingCount} = getDebugTableForUniforms({\n header: `${this.id} uniforms`,\n program: this.program,\n uniforms: Object.assign({}, this.program.uniforms, uniforms),\n undefinedOnly: true\n });\n\n if (missingCount > 0) {\n log.log('MISSING UNIFORMS', Object.keys(missingTable))();\n // log.table(logLevel, missingTable)();\n }\n if (unusedCount > 0) {\n log.log('UNUSED UNIFORMS', Object.keys(unusedTable))();\n // log.log(logLevel, 'Unused uniforms ', unusedTable)();\n }\n\n const configTable = getDebugTableForProgramConfiguration(this.vertexArray.configuration);\n\n log.table(logLevel, attributeTable)();\n\n log.table(logLevel, uniformTable)();\n\n log.table(logLevel + 1, configTable)();\n\n if (framebuffer) {\n framebuffer.log({logLevel: LOG_DRAW_PRIORITY, message: `Rendered to ${framebuffer.id}`});\n }\n\n log.groupEnd(LOG_DRAW_PRIORITY)();\n }\n}\n"],"file":"model.js"}
1
+ {"version":3,"sources":["../../src/lib/model.ts"],"names":["RenderPipeline","getAttributeBuffersFromGeometry","getIndexBufferFromGeometry","PipelineFactory","DEFAULT_MODEL_PROPS","_DEFAULT_PROPS","vs","undefined","fs","id","handle","userData","modules","moduleSettings","geometry","Model","constructor","device","props","getShaderSource","vertexCount","topology","renderPipeline","getUniforms","getDefaultPipelineFactory","createRenderPipeline","parameters","layout","pipeline","_getModuleUniforms","_setGeometry","setUniforms","setProps","destroy","draw","renderPass","instanceCount","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","updateModuleSettings","Object","assign","geometryBuffers","indexBuffer","shader","info","type","wgsl","Error","glsl"],"mappings":";AACA,SAAQA,cAAR,QAA2C,cAA3C;AAGA,SAAQC,+BAAR,EAAyCC,0BAAzC,QAA0E,eAA1E;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AAWA,MAAMC,mBAAyC,GAAG,EAChD,GAAGJ,cAAc,CAACK,cAD8B;AAEhDC,EAAAA,EAAE,EAAEC,SAF4C;AAGhDC,EAAAA,EAAE,EAAED,SAH4C;AAIhDE,EAAAA,EAAE,EAAE,SAJ4C;AAKhDC,EAAAA,MAAM,EAAEH,SALwC;AAMhDI,EAAAA,QAAQ,EAAE,EANsC;AAOhDC,EAAAA,OAAO,EAAE,EAPuC;AAQhDC,EAAAA,cAAc,EAAE,EARgC;AAShDC,EAAAA,QAAQ,EAAEP;AATsC,CAAlD;AAaA,eAAe,MAAMQ,KAAN,CAAY;AAYzBC,EAAAA,WAAW,CAACC,MAAD,EAAiBC,KAAjB,EAAoC;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAC7C,SAAKA,KAAL,GAAa,EAAC,GAAGd,mBAAJ;AAAyB,SAAGc;AAA5B,KAAb;AACAA,IAAAA,KAAK,GAAG,KAAKA,KAAb;AACA,SAAKT,EAAL,GAAUS,KAAK,CAACT,EAAhB;AACA,SAAKQ,MAAL,GAAcA,MAAd;AAGA,SAAKX,EAAL,GAAUa,eAAe,CAAC,KAAKF,MAAN,EAAcC,KAAK,CAACZ,EAApB,CAAzB;;AACA,QAAIY,KAAK,CAACV,EAAV,EAAc;AACZ,WAAKA,EAAL,GAAUW,eAAe,CAAC,KAAKF,MAAN,EAAcC,KAAK,CAACV,EAApB,CAAzB;AACD;;AAED,SAAKY,WAAL,GAAmB,KAAKF,KAA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C;AAC/C,SAAKf,QAAL,CAAcG,WAAd,CAA0BY,QAA1B;AACAE,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAK5B,KAAL,CAAWyB,QAAzB,EAAmCA,QAAnC;AACA,WAAO,IAAP;AACD;;AAEDb,EAAAA,YAAY,CAAChB,QAAD,EAA2B;AAGrC,UAAMiC,eAAe,GAAG9C,+BAA+B,CAAC,KAAKgB,MAAN,EAAcH,QAAd,CAAvD;AACA,SAAK0B,aAAL,CAAmBO,eAAnB;AAEA,UAAMC,WAAW,GAAG9C,0BAA0B,CAAC,KAAKe,MAAN,EAAcH,QAAd,CAA9C;;AACA,QAAIkC,WAAJ,EAAiB;AACf,WAAKV,cAAL,CAAoBU,WAApB;AACD;AACF;;AA9HwB;;AAkI3B,SAAS7B,eAAT,CAAyBF,MAAzB,EAAyCgC,MAAzC,EAAkG;AAEhG,MAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9B,WAAOA,MAAP;AACD;;AAED,UAAQhC,MAAM,CAACiC,IAAP,CAAYC,IAApB;AACE,SAAK,QAAL;AACE,UAAIF,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEG,IAAZ,EAAkB;AAChB,eAAOH,MAAM,CAACG,IAAd;AACD;;AACD,YAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;;AAEF;AACE,UAAIJ,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEK,IAAZ,EAAkB;AAChB,eAAOL,MAAM,CAACK,IAAd;AACD;;AACD,YAAM,IAAID,KAAJ,CAAU,qCAAV,CAAN;AAXJ;AAaD","sourcesContent":["import type {Device, Buffer, RenderPipelineProps, RenderPass, Binding} from '@luma.gl/api';\nimport {RenderPipeline, Shader, cast} from '@luma.gl/api';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport type Geometry from '../geometry/geometry';\nimport {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';\nimport PipelineFactory from './pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string\n vs?: {glsl?: string; wgsl?: string} | string;\n fs?: {glsl?: string; wgsl?: string} | string;\n modules?: ShaderModule[];\n moduleSettings?: Record<string, Record<string, any>>;\n geometry?: Geometry;\n};\n\nconst DEFAULT_MODEL_PROPS: Required<ModelProps> = {\n ...RenderPipeline._DEFAULT_PROPS,\n vs: undefined,\n fs: undefined,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n modules: [],\n moduleSettings: {},\n geometry: undefined\n};\n\n/** v9 API */\nexport default class Model {\n readonly device: Device;\n readonly pipeline: RenderPipeline;\n readonly id: string;\n readonly vs: string;\n readonly fs: string | undefined;\n readonly topology: string;\n readonly vertexCount;\n props: Required<ModelProps>;\n\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...DEFAULT_MODEL_PROPS, ...props};\n props = this.props;\n this.id = props.id;\n this.device = device;\n\n // Create the pipeline\n this.vs = getShaderSource(this.device, props.vs);\n if (props.fs) {\n this.fs = getShaderSource(this.device, props.fs);\n }\n\n this.vertexCount = this.props.vertexCount;\n this.topology = this.props.topology;\n\n if (this.props.geometry) {\n this.vertexCount = this.props.geometry.vertexCount;\n this.topology = this.props.geometry.topology;\n }\n\n const {renderPipeline, getUniforms} = PipelineFactory.getDefaultPipelineFactory(this.device).createRenderPipeline({\n ...this.props,\n vs: this.vs,\n fs: this.fs,\n topology: this.topology,\n parameters: props.parameters,\n // Geometry in the vertex shader!\n // @ts-expect-error\n layout: props.layout\n });\n\n this.pipeline = renderPipeline;\n this._getModuleUniforms = getUniforms;\n\n if (this.props.geometry) {\n this._setGeometry(this.props.geometry);\n }\n this.setUniforms(this._getModuleUniforms()) // Get all default module uniforms\n this.setProps(this.props);\n }\n\n destroy(): void {\n this.pipeline.destroy();\n }\n\n draw(renderPass?: RenderPass): this {\n this.pipeline.draw({\n renderPass,\n vertexCount: this.vertexCount,\n instanceCount: this.props.instanceCount\n });\n return this;\n }\n\n setProps(props: ModelProps): this {\n if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n this.updateModuleSettings(props.moduleSettings);\n }\n return this;\n }\n\n updateModuleSettings(props: Record<string, any>): this {\n const uniforms = this._getModuleUniforms(props);\n this.setUniforms(uniforms);\n return this;\n }\n\n setIndexBuffer(indices: Buffer): this {\n this.pipeline.setIndexBuffer(indices);\n // this._indices = indices;\n return this;\n }\n\n setAttributes(attributes: Record<string, Buffer>): this {\n this.pipeline.setAttributes(attributes);\n Object.assign(this.props.attributes, attributes);\n return this;\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): this {\n this.pipeline.setBindings(bindings);\n Object.assign(this.props.bindings, bindings);\n return this;\n }\n\n setUniforms(uniforms: Record<string, any>): this {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.props.uniforms, uniforms);\n return this;\n }\n\n _setGeometry(geometry: Geometry): void {\n // this._deleteGeometryBuffers();\n\n const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);\n this.setAttributes(geometryBuffers);\n\n const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);\n if (indexBuffer) {\n this.setIndexBuffer(indexBuffer);\n }\n }\n}\n\n/** Create a shader from the different overloads */\nfunction getShaderSource(device: Device, shader: string | {glsl?: string; wgsl?: string}): string {\n // TODO - detect WGSL/GLSL and throw an error if not supported\n if (typeof shader === 'string') {\n return shader;\n }\n\n switch (device.info.type) {\n case 'webgpu':\n if (shader?.wgsl) {\n return shader.wgsl;\n }\n throw new Error('WebGPU does not support GLSL shaders');\n\n default:\n if (shader?.glsl) {\n return shader.glsl;\n }\n throw new Error('WebGL does not support WGSL shaders');\n }\n}\n"],"file":"model.js"}
@@ -0,0 +1,55 @@
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 = {
5
+ vs: string;
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
+ };
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 {
28
+ readonly device: Device;
29
+ stateHash: number;
30
+ private _hashCounter;
31
+ private readonly _hashes;
32
+ private readonly _useCounts;
33
+ private readonly _pipelineCache;
34
+ private readonly _getUniforms;
35
+ private readonly _hookFunctions;
36
+ private _defaultModules;
37
+ static getDefaultPipelineFactory(device: Device): PipelineFactory;
38
+ 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
+ };
44
+ 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
+ };
50
+ /** Calculate a hash based on all the inputs for a render pipeline */
51
+ _hashRenderPipeline(props: GetRenderPipelineOptions): string;
52
+ _getHash(key: string): number;
53
+ _getModuleList(appModules?: ShaderModule[]): ShaderModule[];
54
+ }
55
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AY,EAAE;CAyBhE"}
@@ -0,0 +1,191 @@
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 {
16
+ static getDefaultPipelineFactory(device) {
17
+ device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
18
+ return device.defaultPipelineFactory;
19
+ }
20
+
21
+ 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
+
40
+ this.device = device;
41
+ }
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
+ createRenderPipeline(options) {
56
+ const props = { ...DEFAULT_RENDER_PIPELINE_OPTIONS,
57
+ ...options
58
+ };
59
+
60
+ const modules = this._getModuleList(props.modules);
61
+
62
+ const hash = this._hashRenderPipeline({ ...props,
63
+ modules
64
+ });
65
+
66
+ if (!this._pipelineCache[hash]) {
67
+ const {
68
+ renderPipeline,
69
+ getUniforms
70
+ } = this._createRenderPipeline({ ...props,
71
+ modules
72
+ });
73
+
74
+ renderPipeline.hash = hash;
75
+ this._pipelineCache[hash] = renderPipeline;
76
+
77
+ this._getUniforms[hash] = getUniforms || (x => {});
78
+
79
+ this._useCounts[hash] = 0;
80
+ }
81
+
82
+ this._useCounts[hash]++;
83
+ return {
84
+ renderPipeline: this._pipelineCache[hash],
85
+ getUniforms: this._getUniforms[hash]
86
+ };
87
+ }
88
+
89
+ release(pipeline) {
90
+ const hash = pipeline.hash;
91
+ this._useCounts[hash]--;
92
+
93
+ if (this._useCounts[hash] === 0) {
94
+ this._pipelineCache[hash].destroy();
95
+
96
+ delete this._pipelineCache[hash];
97
+ delete this._getUniforms[hash];
98
+ delete this._useCounts[hash];
99
+ }
100
+ }
101
+
102
+ getUniforms(pipeline) {
103
+ return this._getUniforms[pipeline.hash] || null;
104
+ }
105
+
106
+ _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,
115
+ vs: this.device.createShader({
116
+ stage: 'vertex',
117
+ source: assembled.vs
118
+ }),
119
+ fs: assembled.fs && this.device.createShader({
120
+ stage: 'fragment',
121
+ source: assembled.fs
122
+ })
123
+ });
124
+ return {
125
+ renderPipeline,
126
+ getUniforms: assembled.getUniforms
127
+ };
128
+ }
129
+
130
+ _hashRenderPipeline(props) {
131
+ 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]));
145
+ }
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
+ }
155
+
156
+ _getHash(key) {
157
+ if (this._hashes[key] === undefined) {
158
+ this._hashes[key] = this._hashCounter++;
159
+ }
160
+
161
+ return this._hashes[key];
162
+ }
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
+ }
191
+ //# sourceMappingURL=pipeline-factory.js.map
@@ -0,0 +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;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,IAAIuB,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGP,UAAU,CAACG,MAAjC,EAAyCG,CAAC,GAAGC,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,27 +1,14 @@
1
- import type { AnimationProps } from './animation-loop';
1
+ import type { DeviceProps } from '@luma.gl/api';
2
+ import type { AnimationProps } from '../lib/animation-props';
2
3
  import AnimationLoop from './animation-loop';
3
4
  /**
4
5
  * Minimal animation loop that initializes models in constructor
5
6
  * Simplifying type management
7
+ * v9 API
6
8
  */
7
9
  export declare abstract class RenderLoop {
8
10
  constructor(animationProps?: AnimationProps);
9
- onRender(animationProps: AnimationProps): void;
10
- onFinalize(animationProps: AnimationProps): void;
11
- static getAnimationLoop(RenderLoopConstructor: typeof RenderLoop): WrappedAnimationLoop;
12
11
  /** Instantiates and runs the render loop */
13
- static run(RenderLoopConstructor: typeof RenderLoop, options?: {
14
- start?: boolean;
15
- }): WrappedAnimationLoop;
12
+ static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop;
16
13
  }
17
- declare class WrappedAnimationLoop extends AnimationLoop {
18
- RenderLoopConstructor: typeof RenderLoop;
19
- renderLoop: RenderLoop;
20
- getInfo(): any;
21
- constructor(RenderLoopConstructor: typeof RenderLoop);
22
- onInitialize(animationProps: AnimationProps): void;
23
- onRender(animationProps: AnimationProps): void;
24
- onFinalize(animationProps: AnimationProps): void;
25
- }
26
- export {};
27
14
  //# sourceMappingURL=render-loop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-loop.d.ts","sourceRoot":"","sources":["../../src/lib/render-loop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAG7C;;;GAGG;AACH,8BAAsB,UAAU;gBAClB,cAAc,CAAC,EAAE,cAAc;IAC3C,QAAQ,CAAC,cAAc,EAAE,cAAc;IACvC,UAAU,CAAC,cAAc,EAAE,cAAc;IAEzC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,OAAO,UAAU;IAIhE,4CAA4C;IAC5C,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,UAAU,EAAE,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,oBAAoB;CAOxG;AAED,cAAM,oBAAqB,SAAQ,aAAa;IAC9C,qBAAqB,EAAE,OAAO,UAAU,CAAC;IACzC,UAAU,EAAE,UAAU,CAAC;IAEvB,OAAO;gBAKK,qBAAqB,EAAE,OAAO,UAAU;IAKpD,YAAY,CAAC,cAAc,EAAE,cAAc;IAK3C,QAAQ,CAAC,cAAc,EAAE,cAAc;IAIvC,UAAU,CAAC,cAAc,EAAE,cAAc;CAG1C"}
1
+ {"version":3,"file":"render-loop.d.ts","sourceRoot":"","sources":["../../src/lib/render-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C;;;;GAIG;AACH,8BAAsB,UAAU;gBAClB,cAAc,CAAC,EAAE,cAAc;IAE3C,4CAA4C;IAC5C,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,UAAU,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa;CAS/F"}
@@ -3,33 +3,22 @@ import AnimationLoop from './animation-loop';
3
3
  export class RenderLoop {
4
4
  constructor(animationProps) {}
5
5
 
6
- onRender(animationProps) {}
7
-
8
- onFinalize(animationProps) {}
9
-
10
- static getAnimationLoop(RenderLoopConstructor) {
11
- return new WrappedAnimationLoop(RenderLoopConstructor);
12
- }
13
-
14
- static run(RenderLoopConstructor, options) {
15
- const animationLoop = RenderLoop.getAnimationLoop(RenderLoopConstructor);
16
-
17
- if ((options === null || options === void 0 ? void 0 : options.start) !== false) {
18
- animationLoop.start();
19
- }
20
-
6
+ static run(RenderLoopConstructor, deviceProps) {
7
+ const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);
21
8
  return animationLoop;
22
9
  }
23
10
 
24
11
  }
25
12
 
26
- class WrappedAnimationLoop extends AnimationLoop {
13
+ class SyncInitAnimationLoop extends AnimationLoop {
27
14
  getInfo() {
28
15
  return this.RenderLoopConstructor.info;
29
16
  }
30
17
 
31
- constructor(RenderLoopConstructor) {
32
- super();
18
+ constructor(RenderLoopConstructor, deviceProps) {
19
+ super({
20
+ deviceProps
21
+ });
33
22
 
34
23
  _defineProperty(this, "RenderLoopConstructor", void 0);
35
24
 
@@ -43,13 +32,17 @@ class WrappedAnimationLoop extends AnimationLoop {
43
32
  }
44
33
 
45
34
  onRender(animationProps) {
46
- this.renderLoop.onRender(animationProps);
35
+ var _this$renderLoop, _this$renderLoop$onRe, _this$renderLoop2, _this$renderLoop2$fra;
36
+
37
+ (_this$renderLoop = this.renderLoop) === null || _this$renderLoop === void 0 ? void 0 : (_this$renderLoop$onRe = _this$renderLoop.onRender) === null || _this$renderLoop$onRe === void 0 ? void 0 : _this$renderLoop$onRe.call(_this$renderLoop, animationProps);
38
+ (_this$renderLoop2 = this.renderLoop) === null || _this$renderLoop2 === void 0 ? void 0 : (_this$renderLoop2$fra = _this$renderLoop2.frame) === null || _this$renderLoop2$fra === void 0 ? void 0 : _this$renderLoop2$fra.call(_this$renderLoop2, animationProps);
47
39
  }
48
40
 
49
41
  onFinalize(animationProps) {
50
- var _this$renderLoop, _this$renderLoop$onFi;
42
+ var _this$renderLoop3, _this$renderLoop3$onF, _this$renderLoop4, _this$renderLoop4$des;
51
43
 
52
- (_this$renderLoop = this.renderLoop) === null || _this$renderLoop === void 0 ? void 0 : (_this$renderLoop$onFi = _this$renderLoop.onFinalize) === null || _this$renderLoop$onFi === void 0 ? void 0 : _this$renderLoop$onFi.call(_this$renderLoop, animationProps);
44
+ (_this$renderLoop3 = this.renderLoop) === null || _this$renderLoop3 === void 0 ? void 0 : (_this$renderLoop3$onF = _this$renderLoop3.onFinalize) === null || _this$renderLoop3$onF === void 0 ? void 0 : _this$renderLoop3$onF.call(_this$renderLoop3, animationProps);
45
+ (_this$renderLoop4 = this.renderLoop) === null || _this$renderLoop4 === void 0 ? void 0 : (_this$renderLoop4$des = _this$renderLoop4.destroy) === null || _this$renderLoop4$des === void 0 ? void 0 : _this$renderLoop4$des.call(_this$renderLoop4, animationProps);
53
46
  }
54
47
 
55
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/render-loop.ts"],"names":["AnimationLoop","RenderLoop","constructor","animationProps","onRender","onFinalize","getAnimationLoop","RenderLoopConstructor","WrappedAnimationLoop","run","options","animationLoop","start","getInfo","info","onInitialize","renderLoop"],"mappings":";AAEA,OAAOA,aAAP,MAA0B,kBAA1B;AAOA,OAAO,MAAeC,UAAf,CAA0B;AAC/BC,EAAAA,WAAW,CAACC,cAAD,EAAkC,CAAE;;AAC/CC,EAAAA,QAAQ,CAACD,cAAD,EAAiC,CAAE;;AAC3CE,EAAAA,UAAU,CAACF,cAAD,EAAiC,CAAE;;AAEtB,SAAhBG,gBAAgB,CAACC,qBAAD,EAA2C;AAChE,WAAO,IAAIC,oBAAJ,CAAyBD,qBAAzB,CAAP;AACD;;AAGS,SAAHE,GAAG,CAACF,qBAAD,EAA2CG,OAA3C,EAA8F;AACtG,UAAMC,aAAa,GAAGV,UAAU,CAACK,gBAAX,CAA4BC,qBAA5B,CAAtB;;AACA,QAAI,CAAAG,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,KAAT,MAAmB,KAAvB,EAA8B;AAC5BD,MAAAA,aAAa,CAACC,KAAd;AACD;;AACD,WAAOD,aAAP;AACD;;AAhB8B;;AAmBjC,MAAMH,oBAAN,SAAmCR,aAAnC,CAAiD;AAI/Ca,EAAAA,OAAO,GAAG;AAER,WAAO,KAAKN,qBAAL,CAA2BO,IAAlC;AACD;;AAEDZ,EAAAA,WAAW,CAACK,qBAAD,EAA2C;AACpD;;AADoD;;AAAA;;AAEpD,SAAKA,qBAAL,GAA6BA,qBAA7B;AACD;;AAEDQ,EAAAA,YAAY,CAACZ,cAAD,EAAiC;AAE3C,SAAKa,UAAL,GAAkB,IAAI,KAAKT,qBAAT,CAA+BJ,cAA/B,CAAlB;AACD;;AAEDC,EAAAA,QAAQ,CAACD,cAAD,EAAiC;AACvC,SAAKa,UAAL,CAAgBZ,QAAhB,CAAyBD,cAAzB;AACD;;AAEDE,EAAAA,UAAU,CAACF,cAAD,EAAiC;AAAA;;AACzC,6BAAKa,UAAL,+FAAiBX,UAAjB,uGAA8BF,cAA9B;AACD;;AAzB8C","sourcesContent":["import {Stats} from '@probe.gl/stats';\nimport type {AnimationProps} from './animation-loop';\nimport AnimationLoop from './animation-loop';\nimport {Timeline} from '../animation/timeline'\n\n/**\n * Minimal animation loop that initializes models in constructor\n * Simplifying type management\n */\nexport abstract class RenderLoop {\n constructor(animationProps?: AnimationProps) {}\n onRender(animationProps: AnimationProps) {}\n onFinalize(animationProps: AnimationProps) {}\n\n static getAnimationLoop(RenderLoopConstructor: typeof RenderLoop) {\n return new WrappedAnimationLoop(RenderLoopConstructor);\n }\n\n /** Instantiates and runs the render loop */\n static run(RenderLoopConstructor: typeof RenderLoop, options?: {start?: boolean}): WrappedAnimationLoop {\n const animationLoop = RenderLoop.getAnimationLoop(RenderLoopConstructor);\n if (options?.start !== false) {\n animationLoop.start();\n }\n return animationLoop;\n }\n}\n\nclass WrappedAnimationLoop extends AnimationLoop {\n RenderLoopConstructor: typeof RenderLoop;\n renderLoop: RenderLoop;\n\n getInfo() {\n // @ts-ignore\n return this.RenderLoopConstructor.info;\n }\n\n constructor(RenderLoopConstructor: typeof RenderLoop) {\n super();\n this.RenderLoopConstructor = RenderLoopConstructor;\n }\n\n onInitialize(animationProps: AnimationProps) {\n // @ts-expect-error\n this.renderLoop = new this.RenderLoopConstructor(animationProps);\n }\n\n onRender(animationProps: AnimationProps) {\n this.renderLoop.onRender(animationProps);\n }\n\n onFinalize(animationProps: AnimationProps) {\n this.renderLoop?.onFinalize?.(animationProps);\n }\n}\n\n"],"file":"render-loop.js"}
1
+ {"version":3,"sources":["../../src/lib/render-loop.ts"],"names":["AnimationLoop","RenderLoop","constructor","animationProps","run","RenderLoopConstructor","deviceProps","animationLoop","SyncInitAnimationLoop","getInfo","info","onInitialize","renderLoop","onRender","frame","onFinalize","destroy"],"mappings":";AAEA,OAAOA,aAAP,MAA0B,kBAA1B;AAOA,OAAO,MAAeC,UAAf,CAA0B;AAC/BC,EAAAA,WAAW,CAACC,cAAD,EAAkC,CAAE;;AAGrC,SAAHC,GAAG,CAACC,qBAAD,EAA2CC,WAA3C,EAAqF;AAE7F,UAAMC,aAAa,GAAG,IAAIC,qBAAJ,CAA0BH,qBAA1B,EAAiDC,WAAjD,CAAtB;AAKA,WAAOC,aAAP;AACD;;AAZ8B;;AAgBjC,MAAMC,qBAAN,SAAoCR,aAApC,CAAkD;AAIhDS,EAAAA,OAAO,GAAG;AAER,WAAO,KAAKJ,qBAAL,CAA2BK,IAAlC;AACD;;AAEDR,EAAAA,WAAW,CAACG,qBAAD,EAA2CC,WAA3C,EAAsE;AAC/E,UAAM;AAACA,MAAAA;AAAD,KAAN;;AAD+E;;AAAA;;AAE/E,SAAKD,qBAAL,GAA6BA,qBAA7B;AACD;;AAEDM,EAAAA,YAAY,CAACR,cAAD,EAAiC;AAE3C,SAAKS,UAAL,GAAkB,IAAI,KAAKP,qBAAT,CAA+BF,cAA/B,CAAlB;AACD;;AAEDU,EAAAA,QAAQ,CAACV,cAAD,EAAiC;AAAA;;AAEvC,6BAAKS,UAAL,+FAAiBC,QAAjB,uGAA4BV,cAA5B;AAEA,8BAAKS,UAAL,iGAAiBE,KAAjB,wGAAyBX,cAAzB;AACD;;AAEDY,EAAAA,UAAU,CAACZ,cAAD,EAAiC;AAAA;;AAEzC,8BAAKS,UAAL,iGAAiBG,UAAjB,wGAA8BZ,cAA9B;AAEA,8BAAKS,UAAL,iGAAiBI,OAAjB,wGAA2Bb,cAA3B;AACD;;AA/B+C","sourcesContent":["import type {DeviceProps} from '@luma.gl/api';\nimport type {AnimationProps} from '../lib/animation-props';\nimport AnimationLoop from './animation-loop';\n\n/**\n * Minimal animation loop that initializes models in constructor\n * Simplifying type management\n * v9 API\n */\nexport abstract class RenderLoop {\n constructor(animationProps?: AnimationProps) {}\n\n /** Instantiates and runs the render loop */\n static run(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps): AnimationLoop {\n // Create an animation loop;\n const animationLoop = new SyncInitAnimationLoop(RenderLoopConstructor, deviceProps);\n\n // Start the loop automatically\n // animationLoop.start();\n\n return animationLoop;\n }\n}\n\n/** Instantiates the RenderLoop once the device is created */\nclass SyncInitAnimationLoop extends AnimationLoop {\n RenderLoopConstructor: typeof RenderLoop;\n renderLoop: RenderLoop;\n\n getInfo() {\n // @ts-ignore\n return this.RenderLoopConstructor.info;\n }\n\n constructor(RenderLoopConstructor: typeof RenderLoop, deviceProps?: DeviceProps) {\n super({deviceProps});\n this.RenderLoopConstructor = RenderLoopConstructor;\n }\n\n onInitialize(animationProps: AnimationProps) {\n // @ts-expect-error\n this.renderLoop = new this.RenderLoopConstructor(animationProps);\n }\n\n onRender(animationProps: AnimationProps) {\n // @ts-expect-error API still TBD\n this.renderLoop?.onRender?.(animationProps);\n // @ts-expect-error API still TBD\n this.renderLoop?.frame?.(animationProps);\n }\n\n onFinalize(animationProps: AnimationProps) {\n // @ts-expect-error API still TBD\n this.renderLoop?.onFinalize?.(animationProps);\n // @ts-expect-error API still TBD\n this.renderLoop?.destroy?.(animationProps);\n }\n}\n"],"file":"render-loop.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/engine",
3
- "version": "8.6.0-alpha.3",
3
+ "version": "9.0.0-alpha.3",
4
4
  "description": "WebGL2 Components for High Performance Rendering and Computation",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -31,12 +31,12 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.0.0",
34
- "@luma.gl/constants": "8.6.0-alpha.3",
35
- "@luma.gl/shadertools": "8.6.0-alpha.3",
36
- "@luma.gl/webgl": "8.6.0-alpha.3",
34
+ "@luma.gl/constants": "9.0.0-alpha.3",
35
+ "@luma.gl/shadertools": "9.0.0-alpha.3",
36
+ "@luma.gl/webgl": "9.0.0-alpha.3",
37
37
  "@math.gl/core": "^3.5.0",
38
38
  "@probe.gl/log": "^3.5.0",
39
39
  "@probe.gl/stats": "^3.5.0"
40
40
  },
41
- "gitHead": "a808a90fb8d59b682f5b647b8caa819f26827512"
41
+ "gitHead": "3f259d0de774c6b98dd5ded61e64a0bd9f58b61e"
42
42
  }
@@ -1,6 +1,7 @@
1
1
  // keyframes
2
2
  export type KeyFrame<T> = [number, T];
3
3
 
4
+ /** Holds a list of key frames (timestamped values) */
4
5
  export class KeyFrames<T = number> {
5
6
  startIndex: number = -1;
6
7
  endIndex: number = -1;
@@ -124,7 +124,7 @@ export class Timeline {
124
124
  this.setTime(0);
125
125
  }
126
126
 
127
- attachAnimation(animation: AnimationOptions, channelHandle: number): number {
127
+ attachAnimation(animation: AnimationOptions, channelHandle?: number): number {
128
128
  const animationHandle = animationHandles++;
129
129
 
130
130
  this.animations.set(animationHandle, {
@@ -1,5 +1,5 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import {TruncatedConeGeometry} from './truncated-cone-geometry';
2
- import {uid} from '@luma.gl/webgl';
3
3
 
4
4
  export type ConeGeometryProps = {
5
5
  id?: string;