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

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 (183) hide show
  1. package/dist/animation/key-frames.d.ts +1 -1
  2. package/dist/animation/key-frames.d.ts.map +1 -1
  3. package/dist/animation/key-frames.js +55 -54
  4. package/dist/animation/key-frames.js.map +1 -0
  5. package/dist/animation/timeline.d.ts +4 -4
  6. package/dist/animation/timeline.d.ts.map +1 -1
  7. package/dist/animation/timeline.js +101 -94
  8. package/dist/animation/timeline.js.map +1 -0
  9. package/dist/animation-loop/animation-loop.d.ts +4 -2
  10. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  11. package/dist/animation-loop/animation-loop.js +358 -414
  12. package/dist/animation-loop/animation-loop.js.map +1 -0
  13. package/dist/animation-loop/animation-props.d.ts +3 -1
  14. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  15. package/dist/animation-loop/animation-props.js +1 -0
  16. package/dist/animation-loop/animation-props.js.map +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +1 -1
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  19. package/dist/animation-loop/make-animation-loop.js +25 -26
  20. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  21. package/dist/animation-loop/render-loop.js +5 -17
  22. package/dist/animation-loop/render-loop.js.map +1 -0
  23. package/dist/dist.dev.js +5240 -0
  24. package/dist/geometries/cone-geometry.d.ts +1 -1
  25. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  26. package/dist/geometries/cone-geometry.js +18 -12
  27. package/dist/geometries/cone-geometry.js.map +1 -0
  28. package/dist/geometries/cube-geometry.d.ts +1 -1
  29. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  30. package/dist/geometries/cube-geometry.js +60 -187
  31. package/dist/geometries/cube-geometry.js.map +1 -0
  32. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  33. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  34. package/dist/geometries/cylinder-geometry.js +15 -10
  35. package/dist/geometries/cylinder-geometry.js.map +1 -0
  36. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  37. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  38. package/dist/geometries/ico-sphere-geometry.js +160 -141
  39. package/dist/geometries/ico-sphere-geometry.js.map +1 -0
  40. package/dist/geometries/plane-geometry.d.ts +1 -1
  41. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  42. package/dist/geometries/plane-geometry.js +111 -93
  43. package/dist/geometries/plane-geometry.js.map +1 -0
  44. package/dist/geometries/sphere-geometry.d.ts +1 -1
  45. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  46. package/dist/geometries/sphere-geometry.js +95 -76
  47. package/dist/geometries/sphere-geometry.js.map +1 -0
  48. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  49. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  50. package/dist/geometries/truncated-cone-geometry.js +126 -105
  51. package/dist/geometries/truncated-cone-geometry.js.map +1 -0
  52. package/dist/geometry/geometry-table.d.ts +1 -1
  53. package/dist/geometry/geometry-table.d.ts.map +1 -1
  54. package/dist/geometry/geometry-table.js +1 -0
  55. package/dist/geometry/geometry-table.js.map +1 -0
  56. package/dist/geometry/geometry-utils.js +32 -22
  57. package/dist/geometry/geometry-utils.js.map +1 -0
  58. package/dist/geometry/geometry.d.ts +4 -4
  59. package/dist/geometry/geometry.d.ts.map +1 -1
  60. package/dist/geometry/geometry.js +109 -96
  61. package/dist/geometry/geometry.js.map +1 -0
  62. package/dist/geometry/primitive-utils.js +1 -30
  63. package/dist/geometry/primitive-utils.js.map +1 -0
  64. package/dist/index.cjs +2222 -0
  65. package/dist/index.js +16 -20
  66. package/dist/index.js.map +1 -0
  67. package/dist/lib/clip-space.js +1 -50
  68. package/dist/lib/clip-space.js.map +1 -0
  69. package/dist/lib/model-utils.js +28 -101
  70. package/dist/lib/model-utils.js.map +1 -0
  71. package/dist/lib/model.d.ts +1 -1
  72. package/dist/lib/model.d.ts.map +1 -1
  73. package/dist/lib/model.js +129 -121
  74. package/dist/lib/model.js.map +1 -0
  75. package/dist/lib/pipeline-factory.d.ts +3 -3
  76. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  77. package/dist/lib/pipeline-factory.js +165 -136
  78. package/dist/lib/pipeline-factory.js.map +1 -0
  79. package/dist.min.js +245 -0
  80. package/package.json +22 -13
  81. package/src/.DS_Store +0 -0
  82. package/src/animation/timeline.ts +1 -1
  83. package/src/animation-loop/animation-loop.ts +5 -5
  84. package/src/animation-loop/make-animation-loop.ts +2 -1
  85. package/src/geometry/geometry.ts +2 -2
  86. package/src/lib/pipeline-factory.ts +1 -1
  87. package/dist/bundle.d.ts +0 -2
  88. package/dist/bundle.d.ts.map +0 -1
  89. package/dist/bundle.js +0 -5
  90. package/dist/dist.min.js +0 -31
  91. package/dist/es5/animation/key-frames.js +0 -84
  92. package/dist/es5/animation/key-frames.js.map +0 -1
  93. package/dist/es5/animation/timeline.js +0 -183
  94. package/dist/es5/animation/timeline.js.map +0 -1
  95. package/dist/es5/animation-loop/animation-loop.js +0 -534
  96. package/dist/es5/animation-loop/animation-loop.js.map +0 -1
  97. package/dist/es5/animation-loop/animation-props.js +0 -2
  98. package/dist/es5/animation-loop/animation-props.js.map +0 -1
  99. package/dist/es5/animation-loop/make-animation-loop.js +0 -53
  100. package/dist/es5/animation-loop/make-animation-loop.js.map +0 -1
  101. package/dist/es5/animation-loop/render-loop.js +0 -39
  102. package/dist/es5/animation-loop/render-loop.js.map +0 -1
  103. package/dist/es5/bundle.js +0 -6
  104. package/dist/es5/bundle.js.map +0 -1
  105. package/dist/es5/geometries/cone-geometry.js +0 -43
  106. package/dist/es5/geometries/cone-geometry.js.map +0 -1
  107. package/dist/es5/geometries/cube-geometry.js +0 -84
  108. package/dist/es5/geometries/cube-geometry.js.map +0 -1
  109. package/dist/es5/geometries/cylinder-geometry.js +0 -39
  110. package/dist/es5/geometries/cylinder-geometry.js.map +0 -1
  111. package/dist/es5/geometries/ico-sphere-geometry.js +0 -185
  112. package/dist/es5/geometries/ico-sphere-geometry.js.map +0 -1
  113. package/dist/es5/geometries/plane-geometry.js +0 -137
  114. package/dist/es5/geometries/plane-geometry.js.map +0 -1
  115. package/dist/es5/geometries/sphere-geometry.js +0 -120
  116. package/dist/es5/geometries/sphere-geometry.js.map +0 -1
  117. package/dist/es5/geometries/truncated-cone-geometry.js +0 -160
  118. package/dist/es5/geometries/truncated-cone-geometry.js.map +0 -1
  119. package/dist/es5/geometry/geometry-table.js +0 -2
  120. package/dist/es5/geometry/geometry-table.js.map +0 -1
  121. package/dist/es5/geometry/geometry-utils.js +0 -39
  122. package/dist/es5/geometry/geometry-utils.js.map +0 -1
  123. package/dist/es5/geometry/geometry.js +0 -150
  124. package/dist/es5/geometry/geometry.js.map +0 -1
  125. package/dist/es5/geometry/primitive-utils.js +0 -2
  126. package/dist/es5/geometry/primitive-utils.js.map +0 -1
  127. package/dist/es5/index.js +0 -112
  128. package/dist/es5/index.js.map +0 -1
  129. package/dist/es5/lib/clip-space.js +0 -2
  130. package/dist/es5/lib/clip-space.js.map +0 -1
  131. package/dist/es5/lib/model-utils.js +0 -52
  132. package/dist/es5/lib/model-utils.js.map +0 -1
  133. package/dist/es5/lib/model.js +0 -173
  134. package/dist/es5/lib/model.js.map +0 -1
  135. package/dist/es5/lib/pipeline-factory.js +0 -244
  136. package/dist/es5/lib/pipeline-factory.js.map +0 -1
  137. package/dist/esm/animation/key-frames.js +0 -57
  138. package/dist/esm/animation/key-frames.js.map +0 -1
  139. package/dist/esm/animation/timeline.js +0 -113
  140. package/dist/esm/animation/timeline.js.map +0 -1
  141. package/dist/esm/animation-loop/animation-loop.js +0 -367
  142. package/dist/esm/animation-loop/animation-loop.js.map +0 -1
  143. package/dist/esm/animation-loop/animation-props.js +0 -2
  144. package/dist/esm/animation-loop/animation-props.js.map +0 -1
  145. package/dist/esm/animation-loop/make-animation-loop.js +0 -28
  146. package/dist/esm/animation-loop/make-animation-loop.js.map +0 -1
  147. package/dist/esm/animation-loop/render-loop.js +0 -7
  148. package/dist/esm/animation-loop/render-loop.js.map +0 -1
  149. package/dist/esm/bundle.js +0 -4
  150. package/dist/esm/bundle.js.map +0 -1
  151. package/dist/esm/geometries/cone-geometry.js +0 -21
  152. package/dist/esm/geometries/cone-geometry.js.map +0 -1
  153. package/dist/esm/geometries/cube-geometry.js +0 -67
  154. package/dist/esm/geometries/cube-geometry.js.map +0 -1
  155. package/dist/esm/geometries/cylinder-geometry.js +0 -18
  156. package/dist/esm/geometries/cylinder-geometry.js.map +0 -1
  157. package/dist/esm/geometries/ico-sphere-geometry.js +0 -170
  158. package/dist/esm/geometries/ico-sphere-geometry.js.map +0 -1
  159. package/dist/esm/geometries/plane-geometry.js +0 -119
  160. package/dist/esm/geometries/plane-geometry.js.map +0 -1
  161. package/dist/esm/geometries/sphere-geometry.js +0 -102
  162. package/dist/esm/geometries/sphere-geometry.js.map +0 -1
  163. package/dist/esm/geometries/truncated-cone-geometry.js +0 -136
  164. package/dist/esm/geometries/truncated-cone-geometry.js.map +0 -1
  165. package/dist/esm/geometry/geometry-table.js +0 -2
  166. package/dist/esm/geometry/geometry-table.js.map +0 -1
  167. package/dist/esm/geometry/geometry-utils.js +0 -37
  168. package/dist/esm/geometry/geometry-utils.js.map +0 -1
  169. package/dist/esm/geometry/geometry.js +0 -119
  170. package/dist/esm/geometry/geometry.js.map +0 -1
  171. package/dist/esm/geometry/primitive-utils.js +0 -2
  172. package/dist/esm/geometry/primitive-utils.js.map +0 -1
  173. package/dist/esm/index.js +0 -16
  174. package/dist/esm/index.js.map +0 -1
  175. package/dist/esm/lib/clip-space.js +0 -2
  176. package/dist/esm/lib/clip-space.js.map +0 -1
  177. package/dist/esm/lib/model-utils.js +0 -40
  178. package/dist/esm/lib/model-utils.js.map +0 -1
  179. package/dist/esm/lib/model.js +0 -146
  180. package/dist/esm/lib/model.js.map +0 -1
  181. package/dist/esm/lib/pipeline-factory.js +0 -180
  182. package/dist/esm/lib/pipeline-factory.js.map +0 -1
  183. package/src/bundle.ts +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-loop.js","names":["luma","requestAnimationFrame","cancelAnimationFrame","Stats","statIdCounter","DEFAULT_ANIMATION_LOOP_PROPS","device","onAddHTML","onInitialize","onRender","onFinalize","onError","error","console","stats","get","concat","useDevicePixels","autoResizeViewport","autoResizeDrawingBuffer","AnimationLoop","constructor","props","_defineProperty","Error","id","cpuTime","gpuTime","frameRate","setProps","start","bind","stop","_onMousemove","_onMouseleave","destroy","_setDisplay","delete","setNeedsRedraw","reason","needsRedraw","_running","appContext","_initialized","_initDevice","_initialize","_getAnimationProps","_cancelAnimationFrame","_requestAnimationFrame","err","redraw","_this$device","isLost","_beginTimers","_setupFrame","_updateAnimationProps","_renderFrame","_clearNeedsRedraw","_resolveNextFrame","_nextFramePromise","_endTimers","animationProps","attachTimeline","timeline","detachTimeline","waitForRender","Promise","resolve","toDataURL","canvas","HTMLCanvasElement","_startEventHandling","_initializeAnimationProps","_resizeCanvasDrawingBuffer","_resizeViewport","display","animationLoop","_animationFrameId","_animationFrame","_this$device2","_this$device2$canvasC","canvasContext","width","height","aspect","time","startTime","Date","now","engineTime","tick","tock","_mousePosition","_getSizeAndAspect","update","Math","floor","getTime","_this$device$canvasCo","_createInfoDiv","wrapperDiv","document","createElement","body","appendChild","style","position","div","left","bottom","background","html","innerHTML","_this$device3","_this$device3$canvasC","_this$device4","_this$device4$canvasC","getPixelSize","clientHeight","clientWidth","gl","viewport","drawingBufferWidth","drawingBufferHeight","_this$device5","_this$device5$canvasC","resize","timeEnd","timeStart","addEventListener","event","MouseEvent","offsetX","offsetY"],"sources":["../../src/animation-loop/animation-loop.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {luma, Device} from '@luma.gl/api';\nimport {requestAnimationFrame, cancelAnimationFrame} from '@luma.gl/api';\nimport {Timeline} from '../animation/timeline';\nimport {AnimationProps} from './animation-props';\nimport {Stats, Stat} from '@probe.gl/stats';\n\nlet statIdCounter = 0;\n\n/** AnimationLoop properties */\nexport type AnimationLoopProps = {\n device: Device | Promise<Device>;\n\n onAddHTML?: (div: HTMLDivElement) => string; // innerHTML\n onInitialize?: (animationProps: AnimationProps) => Promise<unknown>;\n onRender?: (animationProps: AnimationProps) => unknown;\n onFinalize?: (animationProps: AnimationProps) => void;\n onError?: (reason: Error) => void;\n\n stats?: Stats;\n\n // view parameters - TODO move to CanvasContext?\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n};\n\nexport type MutableAnimationLoopProps = {\n // view parameters\n autoResizeViewport?: boolean;\n autoResizeDrawingBuffer?: boolean;\n useDevicePixels?: number | boolean;\n}\n\n\nconst DEFAULT_ANIMATION_LOOP_PROPS: Required<AnimationLoopProps> = {\n device: null!,\n\n onAddHTML: () => '',\n onInitialize: async () => { return null; },\n onRender: () => {},\n onFinalize: () => {},\n onError: (error) => console.error(error), // eslint-disable-line no-console\n\n stats: luma.stats.get(`animation-loop-${statIdCounter++}`),\n\n // view parameters\n useDevicePixels: true,\n autoResizeViewport: false,\n autoResizeDrawingBuffer: false,\n};\n\n/** Convenient animation loop */\nexport class AnimationLoop {\n device: Device | null = null;\n canvas: HTMLCanvasElement | OffscreenCanvas | null = null;\n\n props: Required<AnimationLoopProps>;\n animationProps: AnimationProps | null = null;\n timeline: Timeline | null = null;\n stats: Stats;\n cpuTime: Stat;\n gpuTime: Stat;\n frameRate: Stat;\n\n display: any;\n\n needsRedraw: string | false = 'initialized';\n\n _initialized: boolean = false;\n _running: boolean = false;\n _animationFrameId: any = null;\n _nextFramePromise: Promise<AnimationLoop> | null = null;\n _resolveNextFrame: ((animationLoop: AnimationLoop) => void) | null = null;\n _cpuStartTime: number = 0;\n\n // _gpuTimeQuery: Query | null = null;\n\n /*\n * @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context\n */\n constructor(props: AnimationLoopProps) {\n this.props = {...DEFAULT_ANIMATION_LOOP_PROPS, ...props};\n props = this.props;\n\n if (!props.device) {\n throw new Error('No device provided');\n }\n\n const {useDevicePixels = true} = this.props;\n\n // state\n this.stats = props.stats || new Stats({id: 'animation-loop-stats'});\n this.cpuTime = this.stats.get('CPU Time');\n this.gpuTime = this.stats.get('GPU Time');\n this.frameRate = this.stats.get('Frame Rate');\n\n this.setProps({\n autoResizeViewport: props.autoResizeViewport,\n autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,\n useDevicePixels\n });\n\n // Bind methods\n this.start = this.start.bind(this);\n this.stop = this.stop.bind(this);\n\n this._onMousemove = this._onMousemove.bind(this);\n this._onMouseleave = this._onMouseleave.bind(this);\n }\n\n destroy(): void {\n this.stop();\n this._setDisplay(null);\n }\n\n /** @deprecated Use .destroy() */\n delete(): void {\n this.destroy();\n }\n\n setNeedsRedraw(reason: string): this {\n this.needsRedraw = this.needsRedraw || reason;\n return this;\n }\n\n // TODO - move to CanvasContext\n setProps(props: MutableAnimationLoopProps): this {\n if ('autoResizeViewport' in props) {\n this.props.autoResizeViewport = props.autoResizeViewport || false;\n }\n if ('autoResizeDrawingBuffer' in props) {\n this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer || false;\n }\n if ('useDevicePixels' in props) {\n this.props.useDevicePixels = props.useDevicePixels || false;\n }\n return this;\n }\n\n /** Starts a render loop if not already running */\n async start() {\n if (this._running) {\n return this;\n }\n this._running = true;\n\n try {\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n let appContext;\n if (!this._initialized) {\n this._initialized = true;\n // Create the WebGL context\n await this._initDevice();\n this._initialize();\n\n // Note: onIntialize can return a promise (e.g. in case app needs to load resources)\n await this.props.onInitialize(this._getAnimationProps());\n }\n\n // check that we haven't been stopped\n if (!this._running) {\n return null;\n }\n\n // Start the loop\n if (appContext !== false) {\n // cancel any pending renders to ensure only one loop can ever run\n this._cancelAnimationFrame();\n this._requestAnimationFrame();\n }\n\n return this;\n } catch (err: unknown) {\n const error = err instanceof Error ? err : new Error('Unknown error')\n this.props.onError(error);\n // this._running = false; // TODO\n throw error;\n }\n }\n\n /** Explicitly draw a frame */\n redraw(): this {\n if (this.device?.isLost) {\n return this;\n }\n\n this._beginTimers();\n\n this._setupFrame();\n this._updateAnimationProps();\n\n this._renderFrame(this._getAnimationProps());\n\n // clear needsRedraw flag\n this._clearNeedsRedraw();\n\n if (this._resolveNextFrame) {\n this._resolveNextFrame(this);\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n }\n\n this._endTimers();\n\n return this;\n }\n\n // Stops a render loop if already running, finalizing\n stop() {\n // console.debug(`Stopping ${this.constructor.name}`);\n if (this._running) {\n // call callback\n // If stop is called immediately, we can end up in a state where props haven't been initialized...\n if (this.animationProps) {\n this.props.onFinalize(this.animationProps);\n }\n\n this._cancelAnimationFrame();\n this._nextFramePromise = null;\n this._resolveNextFrame = null;\n this._running = false;\n }\n return this;\n }\n\n attachTimeline(timeline: Timeline): Timeline {\n this.timeline = timeline;\n return this.timeline;\n }\n\n detachTimeline(): void {\n this.timeline = null;\n }\n\n waitForRender(): Promise<AnimationLoop> {\n this.setNeedsRedraw('waitForRender');\n\n if (!this._nextFramePromise) {\n this._nextFramePromise = new Promise((resolve) => {\n this._resolveNextFrame = resolve;\n });\n }\n return this._nextFramePromise;\n }\n\n async toDataURL(): Promise<string> {\n this.setNeedsRedraw('toDataURL');\n await this.waitForRender();\n if (this.canvas instanceof HTMLCanvasElement) {\n return this.canvas.toDataURL();\n }\n throw new Error('OffscreenCanvas');\n }\n\n // PRIVATE METHODS\n\n _initialize() {\n this._startEventHandling();\n\n // Initialize the callback data\n this._initializeAnimationProps();\n this._updateAnimationProps();\n\n // Default viewport setup, in case onInitialize wants to render\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n\n // this._gpuTimeQuery = Query.isSupported(this.gl, ['timers']) ? new Query(this.gl) : null;\n }\n\n _setDisplay(display: any) {\n if (this.display) {\n this.display.delete();\n this.display.animationLoop = null;\n }\n\n // store animation loop on the display\n if (display) {\n display.animationLoop = this;\n }\n\n this.display = display;\n }\n\n _requestAnimationFrame() {\n if (!this._running) {\n return;\n }\n\n // VR display has a separate animation frame to sync with headset\n // TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/\n // See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame\n // if (this.display && this.display.requestAnimationFrame) {\n // this._animationFrameId = this.display.requestAnimationFrame(this._animationFrame.bind(this));\n // }\n this._animationFrameId = requestAnimationFrame(this._animationFrame.bind(this));\n }\n\n _cancelAnimationFrame() {\n if (this._animationFrameId !== null) {\n return;\n }\n\n // VR display has a separate animation frame to sync with headset\n // TODO WebVR API discontinued, replaced by WebXR: https://immersive-web.github.io/webxr/\n // See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/requestAnimationFrame\n // if (this.display && this.display.cancelAnimationFrame) {\n // this.display.cancelAnimationFrame(this._animationFrameId);\n // }\n cancelAnimationFrame(this._animationFrameId);\n this._animationFrameId = null;\n }\n\n _animationFrame() {\n if (!this._running) {\n return;\n }\n this.redraw();\n this._requestAnimationFrame();\n }\n\n // Called on each frame, can be overridden to call onRender multiple times\n // to support e.g. stereoscopic rendering\n _renderFrame(animationProps: AnimationProps) {\n // Allow e.g. VR display to render multiple frames.\n if (this.display) {\n this.display._renderFrame(animationProps);\n return;\n }\n\n // call callback\n this.props.onRender(this._getAnimationProps());\n // end callback\n }\n\n _clearNeedsRedraw() {\n this.needsRedraw = false;\n }\n\n _setupFrame() {\n this._resizeCanvasDrawingBuffer();\n this._resizeViewport();\n }\n\n // Initialize the object that will be passed to app callbacks\n _initializeAnimationProps() {\n if (!this.device) {\n throw new Error('loop');\n }\n this.animationProps = {\n animationLoop: this,\n device: this.device,\n canvas: this.device?.canvasContext?.canvas,\n timeline: this.timeline,\n\n // Initial values\n useDevicePixels: this.props.useDevicePixels,\n needsRedraw: false,\n\n // Placeholders\n width: 1,\n height: 1,\n aspect: 1,\n\n // Animation props\n time: 0,\n startTime: Date.now(),\n engineTime: 0,\n tick: 0,\n tock: 0,\n\n // Experimental\n _mousePosition: null // Event props\n };\n }\n\n _getAnimationProps(): AnimationProps {\n if (!this.animationProps) {\n throw new Error('animationProps');\n }\n return this.animationProps;\n }\n\n // Update the context object that will be passed to app callbacks\n _updateAnimationProps(): void {\n if (!this.animationProps) {\n return;\n }\n\n const {width, height, aspect} = this._getSizeAndAspect();\n if (width !== this.animationProps.width || height !== this.animationProps.height) {\n this.setNeedsRedraw('drawing buffer resized');\n }\n if (aspect !== this.animationProps.aspect) {\n this.setNeedsRedraw('drawing buffer aspect changed');\n }\n\n this.animationProps.width = width;\n this.animationProps.height = height;\n this.animationProps.aspect = aspect;\n\n this.animationProps.needsRedraw = this.needsRedraw;\n\n // Update time properties\n this.animationProps.engineTime = Date.now() - this.animationProps.startTime;\n\n if (this.timeline) {\n this.timeline.update(this.animationProps.engineTime);\n }\n\n this.animationProps.tick = Math.floor((this.animationProps.time / 1000) * 60);\n this.animationProps.tock++;\n\n // For back compatibility\n this.animationProps.time = this.timeline\n ? this.timeline.getTime()\n : this.animationProps.engineTime;\n }\n\n /** Wait for supplied device */\n async _initDevice() {\n this.device = await this.props.device;\n if (!this.device) {\n throw new Error('No device provided');\n }\n this.canvas = this.device.canvasContext?.canvas || null;\n // this._createInfoDiv();\n }\n\n _createInfoDiv() {\n if (this.canvas && this.props.onAddHTML) {\n const wrapperDiv = document.createElement('div');\n document.body.appendChild(wrapperDiv);\n wrapperDiv.style.position = 'relative';\n const div = document.createElement('div');\n div.style.position = 'absolute';\n div.style.left = '10px';\n div.style.bottom = '10px';\n div.style.width = '300px';\n div.style.background = 'white';\n if (this.canvas instanceof HTMLCanvasElement) {\n wrapperDiv.appendChild(this.canvas);\n }\n wrapperDiv.appendChild(div);\n const html = this.props.onAddHTML(div);\n if (html) {\n div.innerHTML = html;\n }\n }\n }\n\n _getSizeAndAspect(): {width: number; height: number; aspect: number} {\n if (!this.device) {\n return {width: 1, height: 1, aspect: 1};\n }\n // https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n const [width, height] = this.device?.canvasContext?.getPixelSize() || [1, 1];\n\n // https://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html\n let aspect = 1;\n const canvas = this.device?.canvasContext?.canvas;\n\n // @ts-expect-error\n if (canvas && canvas.clientHeight) {\n // @ts-expect-error\n aspect = canvas.clientWidth / canvas.clientHeight;\n } else if (width > 0 && height > 0) {\n aspect = width / height;\n }\n\n return {width, height, aspect};\n }\n\n /** Default viewport setup */\n _resizeViewport() {\n // @ts-expect-error Expose on canvasContext\n if (this.props.autoResizeViewport && this.device.gl) {\n // @ts-expect-error Expose canvasContext\n this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);\n }\n }\n\n /**\n * Resize the render buffer of the canvas to match canvas client size\n * Optionally multiplying with devicePixel ratio\n */\n _resizeCanvasDrawingBuffer() {\n if (this.props.autoResizeDrawingBuffer) {\n this.device?.canvasContext?.resize({useDevicePixels: this.props.useDevicePixels});\n }\n }\n\n _beginTimers() {\n this.frameRate.timeEnd();\n this.frameRate.timeStart();\n\n // Check if timer for last frame has completed.\n // GPU timer results are never available in the same\n // frame they are captured.\n // if (\n // this._gpuTimeQuery &&\n // this._gpuTimeQuery.isResultAvailable() &&\n // !this._gpuTimeQuery.isTimerDisjoint()\n // ) {\n // this.stats.get('GPU Time').addTime(this._gpuTimeQuery.getTimerMilliseconds());\n // }\n\n // if (this._gpuTimeQuery) {\n // // GPU time query start\n // this._gpuTimeQuery.beginTimeElapsedQuery();\n // }\n\n // this.cpuTime.timeStart();\n }\n\n _endTimers() {\n this.cpuTime.timeEnd();\n\n // if (this._gpuTimeQuery) {\n // // GPU time query end. Results will be available on next frame.\n // this._gpuTimeQuery.end();\n // }\n }\n\n // Event handling\n\n _startEventHandling() {\n if (this.canvas) {\n this.canvas.addEventListener('mousemove', this._onMousemove.bind(this));\n this.canvas.addEventListener('mouseleave', this._onMouseleave.bind(this));\n }\n }\n\n _onMousemove(event: Event) {\n if (event instanceof MouseEvent) {\n this._getAnimationProps()._mousePosition = [event.offsetX, event.offsetY];\n }\n }\n\n _onMouseleave(event: Event) {\n this._getAnimationProps()._mousePosition = null;\n }\n}\n"],"mappings":";AAEA,SAAQA,IAAI,QAAe,cAAc;AACzC,SAAQC,qBAAqB,EAAEC,oBAAoB,QAAO,cAAc;AAGxE,SAAQC,KAAK,QAAa,iBAAiB;AAE3C,IAAIC,aAAa,GAAG,CAAC;AA4BrB,MAAMC,4BAA0D,GAAG;EACjEC,MAAM,EAAE,IAAK;EAEbC,SAAS,EAAEA,CAAA,KAAM,EAAE;EACnBC,YAAY,EAAE,MAAAA,CAAA,KAAY;IAAE,OAAO,IAAI;EAAE,CAAC;EAC1CC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClBC,UAAU,EAAEA,CAAA,KAAM,CAAC,CAAC;EACpBC,OAAO,EAAGC,KAAK,IAAKC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;EAExCE,KAAK,EAAEd,IAAI,CAACc,KAAK,CAACC,GAAG,mBAAAC,MAAA,CAAmBZ,aAAa,EAAE,EAAG;EAG1Da,eAAe,EAAE,IAAI;EACrBC,kBAAkB,EAAE,KAAK;EACzBC,uBAAuB,EAAE;AAC3B,CAAC;AAGD,OAAO,MAAMC,aAAa,CAAC;EA4BzBC,WAAWA,CAACC,KAAyB,EAAE;IAAAC,eAAA,iBA3Bf,IAAI;IAAAA,eAAA,iBACyB,IAAI;IAAAA,eAAA;IAAAA,eAAA,yBAGjB,IAAI;IAAAA,eAAA,mBAChB,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,sBAQF,aAAa;IAAAA,eAAA,uBAEnB,KAAK;IAAAA,eAAA,mBACT,KAAK;I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AACnG,SAAS,CAACoG,SAAS,EAAE;EAmB5B;EAEApE,UAAUA,CAAA,EAAG;IACX,IAAI,CAAClC,OAAO,CAACqG,OAAO,EAAE;EAMxB;EAIAxD,mBAAmBA,CAAA,EAAG;IACpB,IAAI,IAAI,CAACF,MAAM,EAAE;MACf,IAAI,CAACA,MAAM,CAAC4D,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAChG,YAAY,CAACF,IAAI,CAAC,IAAI,CAAC,CAAC;MACvE,IAAI,CAACsC,MAAM,CAAC4D,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC/F,aAAa,CAACH,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E;EACF;EAEAE,YAAYA,CAACiG,KAAY,EAAE;IACzB,IAAIA,KAAK,YAAYC,UAAU,EAAE;MAC/B,IAAI,CAACrF,kBAAkB,EAAE,CAAC8C,cAAc,GAAG,CAACsC,KAAK,CAACE,OAAO,EAAEF,KAAK,CAACG,OAAO,CAAC;IAC3E;EACF;EAEAnG,aAAaA,CAACgG,KAAY,EAAE;IAC1B,IAAI,CAACpF,kBAAkB,EAAE,CAAC8C,cAAc,GAAG,IAAI;EACjD;AACF"}
@@ -1,8 +1,10 @@
1
+ /// <reference types="dist" />
2
+ /// <reference types="offscreencanvas" />
1
3
  import { Device } from '@luma.gl/api';
2
4
  import { Timeline } from '../animation/timeline';
3
5
  import type { AnimationLoop } from './animation-loop';
4
6
  /** Properties passed to every render frame */
5
- export type AnimationProps = {
7
+ export declare type AnimationProps = {
6
8
  device: Device;
7
9
  animationLoop: AnimationLoop;
8
10
  /** @todo Should be canvasContext */
@@ -1 +1 @@
1
- {"version":3,"file":"animation-props.d.ts","sourceRoot":"","sources":["../../src/animation-loop/animation-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,KAAK,EAAC,aAAa,EAAC,M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M,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE7B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG1B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC"}
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=animation-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-props.js","names":[],"sources":["../../src/animation-loop/animation-props.ts"],"sourcesContent":["import {Device} from '@luma.gl/api';\nimport {Timeline} from '../animation/timeline'\nimport type {AnimationLoop} from './animation-loop';\n\n/** Properties passed to every render frame */\nexport type AnimationProps = {\n device: Device;\n animationLoop: AnimationLoop;\n\n /** @todo Should be canvasContext */\n canvas: HTMLCanvasElement | OffscreenCanvas;\n useDevicePixels: number | boolean;\n width: number;\n height: number;\n aspect: number;\n\n // Animation props\n time: number;\n startTime: number;\n engineTime: number;\n tick: number;\n tock: number;\n\n // Initial values\n needsRedraw?: string | false;\n\n timeline: Timeline | null;\n\n // Experimental\n _mousePosition?: [number, number] | null; // [offsetX, offsetY],\n};\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { AnimationLoopTemplate } from './render-loop';
2
2
  import { AnimationLoop, AnimationLoopProps } from './animation-loop';
3
- export type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;
3
+ export declare type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;
4
4
  /** Instantiates and runs the render loop */
5
5
  export declare function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop;
6
6
  //# sourceMappingURL=make-animation-loop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/make-animation-loop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAA;AAGlE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AAE7H,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,yBAAyB,EAAE,OAAO,qBAAqB,EAAE,KAAK,CAAC,EAAE,sBAAsB,GAAG,aAAa,CAiCxI"}
1
+ {"version":3,"file":"make-animation-loop.d.ts","sourceRoot":"","sources":["../../src/animation-loop/make-animation-loop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAA;AACnD,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,kBAAkB,CAAA;AAGlE,oBAAY,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AAE7H,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,yBAAyB,EAAE,OAAO,qBAAqB,EAAE,KAAK,CAAC,EAAE,sBAAsB,GAAG,aAAa,CAkCxI"}
@@ -1,29 +1,28 @@
1
- // luma.gl, MIT license
2
1
  import { luma } from '@luma.gl/api';
3
- import { AnimationLoop } from './animation-loop.js';
4
- /** Instantiates and runs the render loop */
2
+ import { AnimationLoop } from "./animation-loop.js";
5
3
  export function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
6
- let renderLoop = null;
7
- const device = props?.device || luma.createDevice();
8
- // Create an animation loop;
9
- const animationLoop = new AnimationLoop({
10
- ...props,
11
- device,
12
- async onInitialize(animationProps) {
13
- // @ts-expect-error abstract to prevent instantiation
14
- renderLoop = new AnimationLoopTemplateCtor(animationProps);
15
- // Any async loading can be handled here
16
- return await renderLoop?.onInitialize(animationProps);
17
- },
18
- onRender: (animationProps) => renderLoop?.onRender(animationProps),
19
- onFinalize: (animationProps) => renderLoop?.onFinalize(animationProps)
20
- });
21
- // @ts-expect-error Hack: adds info for the website to find
22
- animationLoop.getInfo = () => {
23
- // @ts-ignore
24
- return this.AnimationLoopTemplateCtor.info;
25
- };
26
- // Start the loop automatically
27
- // animationLoop.start();
28
- return animationLoop;
4
+ let renderLoop = null;
5
+ const device = (props === null || props === void 0 ? void 0 : props.device) || luma.createDevice();
6
+ const animationLoop = new AnimationLoop({
7
+ ...props,
8
+ device,
9
+ async onInitialize(animationProps) {
10
+ var _renderLoop;
11
+ renderLoop = new AnimationLoopTemplateCtor(animationProps);
12
+ return await ((_renderLoop = renderLoop) === null || _renderLoop === void 0 ? void 0 : _renderLoop.onInitialize(animationProps));
13
+ },
14
+ onRender: animationProps => {
15
+ var _renderLoop2;
16
+ return (_renderLoop2 = renderLoop) === null || _renderLoop2 === void 0 ? void 0 : _renderLoop2.onRender(animationProps);
17
+ },
18
+ onFinalize: animationProps => {
19
+ var _renderLoop3;
20
+ return (_renderLoop3 = renderLoop) === null || _renderLoop3 === void 0 ? void 0 : _renderLoop3.onFinalize(animationProps);
21
+ }
22
+ });
23
+ animationLoop.getInfo = () => {
24
+ return this.AnimationLoopTemplateCtor.info;
25
+ };
26
+ return animationLoop;
29
27
  }
28
+ //# sourceMappingURL=make-animation-loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-animation-loop.js","names":["luma","AnimationLoop","makeAnimationLoop","AnimationLoopTemplateCtor","props","renderLoop","device","createDevice","animationLoop","onInitialize","animationProps","_renderLoop","onRender","_renderLoop2","onFinalize","_renderLoop3","getInfo","info"],"sources":["../../src/animation-loop/make-animation-loop.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {luma} from '@luma.gl/api';\nimport {AnimationLoopTemplate} from './render-loop'\nimport {AnimationLoop, AnimationLoopProps} from './animation-loop'\nimport type {AnimationProps} from './animation-props';\n\nexport type MakeAnimationLoopProps = Omit<AnimationLoopProps, 'onCreateDevice' | 'onInitialize' | 'onRedraw' | 'onFinalize'>;\n\n/** Instantiates and runs the render loop */\nexport function makeAnimationLoop(AnimationLoopTemplateCtor: typeof AnimationLoopTemplate, props?: MakeAnimationLoopProps): AnimationLoop {\n let renderLoop: AnimationLoopTemplate | null = null;\n\n const device = props?.device || luma.createDevice();\n\n // Create an animation loop;\n const animationLoop = new AnimationLoop({\n ... props,\n\n device,\n\n async onInitialize(animationProps: AnimationProps): Promise<unknown> {\n // @ts-expect-error abstract to prevent instantiation\n renderLoop = new AnimationLoopTemplateCtor(animationProps);\n // Any async loading can be handled here\n return await renderLoop?.onInitialize(animationProps);\n },\n\n onRender: (animationProps: AnimationProps) => renderLoop?.onRender(animationProps),\n \n onFinalize: (animationProps: AnimationProps) => renderLoop?.onFinalize(animationProps)\n });\n\n // @ts-expect-error Hack: adds info for the website to find\n animationLoop.getInfo = () => {\n // @ts-ignore\n // eslint-disable-next-line no-invalid-this\n return this.AnimationLoopTemplateCtor.info;\n }\n\n // Start the loop automatically\n // animationLoop.start();\n\n return animationLoop;\n}\n"],"mappings":"AACA,SAAQA,IAAI,QAAO,cAAc;AAAC,SAE1BC,aAAa;AAMrB,OAAO,SAASC,iBAAiBA,CAACC,yBAAuD,EAAEC,KAA8B,EAAiB;EACxI,IAAIC,UAAwC,GAAG,IAAI;EAEnD,MAAMC,MAAM,GAAG,CAAAF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,MAAM,KAAIN,IAAI,CAACO,YAAY,EAAE;EAGnD,MAAMC,aAAa,GAAG,IAAIP,aAAa,CAAC;IACtC,GAAIG,KAAK;IAETE,MAAM;IAEN,MAAMG,YAAYA,CAACC,cAA8B,EAAoB;MAAA,IAAAC,WAAA;MAEnEN,UAAU,GAAG,IAAIF,yBAAyB,CAACO,cAAc,CAAC;MAE1D,OAAO,QAAAC,WAAA,GAAMN,UAAU,cAAAM,WAAA,uBAAVA,WAAA,CAAYF,YAAY,CAACC,cAAc,CAAC;IACvD,CAAC;IAEDE,QAAQ,EAAGF,cAA8B;MAAA,IAAAG,YAAA;MAAA,QAAAA,YAAA,GAAKR,UAAU,cAAAQ,YAAA,uBAAVA,YAAA,CAAYD,QAAQ,CAACF,cAAc,CAAC;IAAA;IAElFI,UAAU,EAAGJ,cAA8B;MAAA,IAAAK,YAAA;MAAA,QAAAA,YAAA,GAAKV,UAAU,cAAAU,YAAA,uBAAVA,YAAA,CAAYD,UAAU,CAACJ,cAAc,CAAC;IAAA;EACxF,CAAC,CAAC;EAGFF,aAAa,CAACQ,OAAO,GAAG,MAAM;IAG5B,OAAO,IAAI,CAACb,yBAAyB,CAACc,IAAI;EAC5C,CAAC;EAKD,OAAOT,aAAa;AACtB"}
@@ -1,19 +1,7 @@
1
- /**
2
- * Minimal class that represents a "componentized" rendering life cycle
3
- * (resource construction, repeated rendering, resource destruction)
4
- *
5
- * @note A motivation for this class compared to the raw animation loop is
6
- * that it simplifies TypeScript code by allowing resources to be typed unconditionally
7
- * since they are allocated in the constructor rather than in onInitialized
8
- *
9
- * @note Introduced in luma.gl v9
10
- *
11
- * @example AnimationLoopTemplate is intended to be subclassed,
12
- * but the subclass should not be instantiated directly. Instead the subclass
13
- * (i.e. the constructor of the subclass) should be used
14
- * as an argument to create an AnimationLoop.
15
- */
16
1
  export class AnimationLoopTemplate {
17
- constructor(animationProps) { }
18
- async onInitialize(animationProps) { return null; }
2
+ constructor(animationProps) {}
3
+ async onInitialize(animationProps) {
4
+ return null;
5
+ }
19
6
  }
7
+ //# sourceMappingURL=render-loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-loop.js","names":["AnimationLoopTemplate","constructor","animationProps","onInitialize"],"sources":["../../src/animation-loop/render-loop.ts"],"sourcesContent":["import type {AnimationProps} from './animation-props';\n\n/**\n * Minimal class that represents a \"componentized\" rendering life cycle\n * (resource construction, repeated rendering, resource destruction)\n * \n * @note A motivation for this class compared to the raw animation loop is \n * that it simplifies TypeScript code by allowing resources to be typed unconditionally \n * since they are allocated in the constructor rather than in onInitialized\n * \n * @note Introduced in luma.gl v9\n * \n * @example AnimationLoopTemplate is intended to be subclassed, \n * but the subclass should not be instantiated directly. Instead the subclass\n * (i.e. the constructor of the subclass) should be used \n * as an argument to create an AnimationLoop.\n */\nexport abstract class AnimationLoopTemplate {\n constructor(animationProps?: AnimationProps) {}\n async onInitialize(animationProps: AnimationProps): Promise<unknown> { return null; }\n abstract onRender(animationProps: AnimationProps): unknown;\n abstract onFinalize(animationProps: AnimationProps): void;\n}\n"],"mappings":"AAiBA,OAAO,MAAeA,qBAAqB,CAAC;EAC1CC,WAAWA,CAACC,cAA+B,EAAE,CAAC;EAC9C,MAAMC,YAAYA,CAACD,cAA8B,EAAoB;IAAE,OAAO,IAAI;EAAE;AAGtF"}