@lightningjs/renderer 0.4.1 → 0.5.0

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 (162) hide show
  1. package/README.md +13 -13
  2. package/dist/exports/utils.d.ts +1 -1
  3. package/dist/exports/utils.js +1 -1
  4. package/dist/exports/utils.js.map +1 -1
  5. package/dist/src/common/CommonTypes.d.ts +32 -12
  6. package/dist/src/core/CoreNode.d.ts +14 -18
  7. package/dist/src/core/CoreNode.js +90 -124
  8. package/dist/src/core/CoreNode.js.map +1 -1
  9. package/dist/src/core/CoreTextNode.d.ts +0 -2
  10. package/dist/src/core/CoreTextNode.js +39 -17
  11. package/dist/src/core/CoreTextNode.js.map +1 -1
  12. package/dist/src/core/Stage.js +11 -8
  13. package/dist/src/core/Stage.js.map +1 -1
  14. package/dist/src/core/lib/Matrix3d.d.ts +59 -0
  15. package/dist/src/core/lib/Matrix3d.js +253 -0
  16. package/dist/src/core/lib/Matrix3d.js.map +1 -0
  17. package/dist/src/core/lib/utils.d.ts +1 -0
  18. package/dist/src/core/lib/utils.js +3 -0
  19. package/dist/src/core/lib/utils.js.map +1 -1
  20. package/dist/src/core/renderers/CoreRenderer.d.ts +2 -4
  21. package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
  22. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +1 -1
  23. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +16 -16
  24. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
  25. package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +1 -1
  26. package/dist/src/core/renderers/webgl/WebGlCoreShader.js +2 -2
  27. package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -1
  28. package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +2 -1
  29. package/dist/src/core/renderers/webgl/shaders/SdfShader.js +15 -6
  30. package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -1
  31. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.d.ts +2 -1
  32. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +27 -30
  33. package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -1
  34. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +2 -1
  35. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +7 -9
  36. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
  37. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +0 -1
  38. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +1 -1
  39. package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +24 -2
  40. package/dist/src/core/text-rendering/renderers/TextRenderer.js +6 -3
  41. package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -1
  42. package/dist/src/core/textures/SubTexture.js +1 -1
  43. package/dist/src/core/textures/SubTexture.js.map +1 -1
  44. package/dist/src/core/textures/Texture.d.ts +13 -1
  45. package/dist/src/core/textures/Texture.js.map +1 -1
  46. package/dist/src/main-api/INode.d.ts +30 -5
  47. package/dist/src/main-api/RendererMain.js +3 -1
  48. package/dist/src/main-api/RendererMain.js.map +1 -1
  49. package/dist/src/render-drivers/main/MainOnlyNode.d.ts +6 -4
  50. package/dist/src/render-drivers/main/MainOnlyNode.js +31 -16
  51. package/dist/src/render-drivers/main/MainOnlyNode.js.map +1 -1
  52. package/dist/src/render-drivers/main/MainOnlyTextNode.d.ts +0 -2
  53. package/dist/src/render-drivers/main/MainOnlyTextNode.js +3 -10
  54. package/dist/src/render-drivers/main/MainOnlyTextNode.js.map +1 -1
  55. package/dist/src/render-drivers/threadx/NodeStruct.d.ts +6 -3
  56. package/dist/src/render-drivers/threadx/NodeStruct.js +12 -3
  57. package/dist/src/render-drivers/threadx/NodeStruct.js.map +1 -1
  58. package/dist/src/render-drivers/threadx/SharedNode.d.ts +2 -1
  59. package/dist/src/render-drivers/threadx/SharedNode.js +2 -1
  60. package/dist/src/render-drivers/threadx/SharedNode.js.map +1 -1
  61. package/dist/src/render-drivers/threadx/ThreadXMainNode.d.ts +2 -0
  62. package/dist/src/render-drivers/threadx/ThreadXMainNode.js +14 -0
  63. package/dist/src/render-drivers/threadx/ThreadXMainNode.js.map +1 -1
  64. package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js +4 -2
  65. package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js.map +1 -1
  66. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +6 -5
  67. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +1 -1
  68. package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js +2 -7
  69. package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js.map +1 -1
  70. package/dist/src/render-drivers/threadx/worker/renderer.js +2 -1
  71. package/dist/src/render-drivers/threadx/worker/renderer.js.map +1 -1
  72. package/dist/src/utils.d.ts +7 -12
  73. package/dist/src/utils.js +9 -25
  74. package/dist/src/utils.js.map +1 -1
  75. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  76. package/exports/utils.ts +1 -1
  77. package/package.json +22 -19
  78. package/src/common/CommonTypes.ts +42 -16
  79. package/src/core/CoreNode.ts +120 -158
  80. package/src/core/CoreTextNode.ts +54 -24
  81. package/src/core/Stage.ts +16 -11
  82. package/src/core/lib/Matrix3d.ts +290 -0
  83. package/src/core/lib/utils.ts +4 -0
  84. package/src/core/renderers/CoreRenderer.ts +2 -4
  85. package/src/core/renderers/webgl/WebGlCoreRenderer.ts +18 -21
  86. package/src/core/renderers/webgl/WebGlCoreShader.ts +2 -2
  87. package/src/core/renderers/webgl/shaders/SdfShader.ts +17 -8
  88. package/src/core/text-rendering/renderers/CanvasTextRenderer.ts +30 -28
  89. package/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.ts +9 -20
  90. package/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.ts +0 -1
  91. package/src/core/text-rendering/renderers/TextRenderer.ts +37 -5
  92. package/src/core/textures/SubTexture.ts +6 -5
  93. package/src/core/textures/Texture.ts +19 -6
  94. package/src/main-api/INode.ts +32 -5
  95. package/src/main-api/RendererMain.ts +3 -1
  96. package/src/render-drivers/main/MainOnlyNode.ts +39 -22
  97. package/src/render-drivers/main/MainOnlyTextNode.ts +2 -15
  98. package/src/render-drivers/threadx/NodeStruct.ts +13 -3
  99. package/src/render-drivers/threadx/SharedNode.ts +4 -2
  100. package/src/render-drivers/threadx/ThreadXMainNode.ts +16 -0
  101. package/src/render-drivers/threadx/ThreadXRenderDriver.ts +4 -2
  102. package/src/render-drivers/threadx/worker/ThreadXRendererNode.ts +18 -8
  103. package/src/render-drivers/threadx/worker/ThreadXRendererTextNode.ts +2 -14
  104. package/src/render-drivers/threadx/worker/renderer.ts +2 -1
  105. package/src/utils.ts +10 -27
  106. package/dist/src/core/Matrix2DContext.d.ts +0 -15
  107. package/dist/src/core/Matrix2DContext.js +0 -45
  108. package/dist/src/core/Matrix2DContext.js.map +0 -1
  109. package/dist/src/core/lib/glm/common.d.ts +0 -162
  110. package/dist/src/core/lib/glm/common.js +0 -81
  111. package/dist/src/core/lib/glm/common.js.map +0 -1
  112. package/dist/src/core/lib/glm/index.d.ts +0 -11
  113. package/dist/src/core/lib/glm/index.js +0 -30
  114. package/dist/src/core/lib/glm/index.js.map +0 -1
  115. package/dist/src/core/lib/glm/mat2.d.ts +0 -219
  116. package/dist/src/core/lib/glm/mat2.js +0 -396
  117. package/dist/src/core/lib/glm/mat2.js.map +0 -1
  118. package/dist/src/core/lib/glm/mat2d.d.ts +0 -237
  119. package/dist/src/core/lib/glm/mat2d.js +0 -442
  120. package/dist/src/core/lib/glm/mat2d.js.map +0 -1
  121. package/dist/src/core/lib/glm/mat3.d.ts +0 -283
  122. package/dist/src/core/lib/glm/mat3.js +0 -680
  123. package/dist/src/core/lib/glm/mat3.js.map +0 -1
  124. package/dist/src/core/lib/glm/mat4.d.ts +0 -550
  125. package/dist/src/core/lib/glm/mat4.js +0 -1802
  126. package/dist/src/core/lib/glm/mat4.js.map +0 -1
  127. package/dist/src/core/lib/glm/quat.d.ts +0 -363
  128. package/dist/src/core/lib/glm/quat.js +0 -693
  129. package/dist/src/core/lib/glm/quat.js.map +0 -1
  130. package/dist/src/core/lib/glm/quat2.d.ts +0 -356
  131. package/dist/src/core/lib/glm/quat2.js +0 -754
  132. package/dist/src/core/lib/glm/quat2.js.map +0 -1
  133. package/dist/src/core/lib/glm/vec2.d.ts +0 -365
  134. package/dist/src/core/lib/glm/vec2.js +0 -569
  135. package/dist/src/core/lib/glm/vec2.js.map +0 -1
  136. package/dist/src/core/lib/glm/vec3.d.ts +0 -406
  137. package/dist/src/core/lib/glm/vec3.js +0 -720
  138. package/dist/src/core/lib/glm/vec3.js.map +0 -1
  139. package/dist/src/core/lib/glm/vec4.d.ts +0 -330
  140. package/dist/src/core/lib/glm/vec4.js +0 -608
  141. package/dist/src/core/lib/glm/vec4.js.map +0 -1
  142. package/dist/src/core/textures/utils.d.ts +0 -11
  143. package/dist/src/core/textures/utils.js +0 -32
  144. package/dist/src/core/textures/utils.js.map +0 -1
  145. package/dist/src/main-api/TextureRegistry.d.ts +0 -33
  146. package/dist/src/main-api/TextureRegistry.js +0 -97
  147. package/dist/src/main-api/TextureRegistry.js.map +0 -1
  148. package/dist/src/main-api/TextureUsageRegistry/TextureRegistry.d.ts +0 -33
  149. package/dist/src/main-api/TextureUsageRegistry/TextureRegistry.js +0 -97
  150. package/dist/src/main-api/TextureUsageRegistry/TextureRegistry.js.map +0 -1
  151. package/src/core/Matrix2DContext.ts +0 -52
  152. package/src/core/lib/glm/common.ts +0 -231
  153. package/src/core/lib/glm/index.ts +0 -31
  154. package/src/core/lib/glm/mat2.ts +0 -499
  155. package/src/core/lib/glm/mat2d.ts +0 -547
  156. package/src/core/lib/glm/mat3.ts +0 -849
  157. package/src/core/lib/glm/mat4.ts +0 -2169
  158. package/src/core/lib/glm/quat.ts +0 -828
  159. package/src/core/lib/glm/quat2.ts +0 -951
  160. package/src/core/lib/glm/vec2.ts +0 -671
  161. package/src/core/lib/glm/vec3.ts +0 -859
  162. package/src/core/lib/glm/vec4.ts +0 -708
@@ -1,33 +0,0 @@
1
- import type { TextureDesc } from "./RendererMain.js";
2
- interface TextureRefInfo {
3
- /**
4
- * Texture Reference ID
5
- */
6
- id: number;
7
- /**
8
- * The number of references to this texture that are currently assigned to
9
- * Nodes.
10
- */
11
- nodeRefCount: number;
12
- /**
13
- * The last time the texture reference count was updated.
14
- *
15
- * @remarks
16
- * This is used to determine when a texture is no longer referenced by any
17
- * Nodes and can be removed from the GPU.
18
- */
19
- lastUpdate: number;
20
- }
21
- /**
22
- * Usage-based Texture Garbage Collection Registry
23
- */
24
- export declare class TextureRegistry {
25
- protected releaseCallback: (textureDescId: number) => void;
26
- textureMap: Map<number, TextureRefInfo>;
27
- zeroReferenceTextureSet: Set<TextureRefInfo>;
28
- constructor(releaseCallback: (textureDescId: number) => void);
29
- registerTexture(texture: TextureDesc): void;
30
- incrementTextureRefCount(texture: TextureDesc): void;
31
- decrementTextureRefCount(texture: TextureDesc): void;
32
- }
33
- export {};
@@ -1,97 +0,0 @@
1
- /*
2
- * If not stated otherwise in this file or this component's LICENSE file the
3
- * following copyright and licenses apply:
4
- *
5
- * Copyright 2023 Comcast Cable Communications Management, LLC.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the License);
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { assertTruthy } from "../utils.js";
20
- const TEXTURE_CLEANUP_INTERVAL_MS = 1000;
21
- const TEXTURE_CLEANUP_AGE_THREADHOLD_MS = 5000;
22
- /**
23
- * Usage-based Texture Garbage Collection Registry
24
- */
25
- export class TextureRegistry {
26
- releaseCallback;
27
- textureMap = new Map();
28
- zeroReferenceTextureSet = new Set();
29
- constructor(releaseCallback) {
30
- this.releaseCallback = releaseCallback;
31
- // Periodically check for textures that are no longer referenced by any
32
- // Nodes and notify RendererMain to release them.
33
- setInterval(() => {
34
- const now = Date.now();
35
- for (const textureRefInfo of this.zeroReferenceTextureSet) {
36
- if (now - textureRefInfo.lastUpdate > TEXTURE_CLEANUP_AGE_THREADHOLD_MS) {
37
- this.releaseCallback(textureRefInfo.id);
38
- this.textureMap.delete(textureRefInfo.id);
39
- this.zeroReferenceTextureSet.delete(textureRefInfo);
40
- }
41
- }
42
- }, TEXTURE_CLEANUP_INTERVAL_MS);
43
- }
44
- registerTexture(texture) {
45
- const textureId = texture.options?.id;
46
- assertTruthy(textureId, 'Texture must have an id to be registered');
47
- if (!this.textureMap.has(textureId)) {
48
- const textureRefInfo = {
49
- id: textureId,
50
- nodeRefCount: 0,
51
- lastUpdate: Date.now()
52
- };
53
- this.textureMap.set(textureId, textureRefInfo);
54
- this.zeroReferenceTextureSet.add(textureRefInfo);
55
- }
56
- }
57
- incrementTextureRefCount(texture) {
58
- const textureId = texture.options?.id;
59
- assertTruthy(textureId, 'Texture must have an id to be registered');
60
- let textureRefInfo = this.textureMap.get(textureId);
61
- if (!textureRefInfo) {
62
- // Texture has not been registered yet, so register it now.
63
- // This may happen if the TextureDesc was cleaned up from the registry
64
- // but was still alive in memory and eventually re-used.
65
- this.registerTexture(texture);
66
- textureRefInfo = this.textureMap.get(textureId);
67
- }
68
- assertTruthy(textureRefInfo, 'Texture must have been registered');
69
- if (texture.txType === 'SubTexture') {
70
- // If this is a SubTexture, then increment the reference count of the
71
- // parent texture as well.
72
- this.incrementTextureRefCount(texture.props.texture);
73
- }
74
- textureRefInfo.nodeRefCount++;
75
- textureRefInfo.lastUpdate = Date.now();
76
- if (this.zeroReferenceTextureSet.has(textureRefInfo)) {
77
- this.zeroReferenceTextureSet.delete(textureRefInfo);
78
- }
79
- }
80
- decrementTextureRefCount(texture) {
81
- const textureId = texture.options?.id;
82
- assertTruthy(textureId, 'Texture must have an id to be registered');
83
- const textureRefInfo = this.textureMap.get(textureId);
84
- assertTruthy(textureRefInfo, 'Texture must have been registered');
85
- textureRefInfo.nodeRefCount--;
86
- textureRefInfo.lastUpdate = Date.now();
87
- if (textureRefInfo.nodeRefCount === 0) {
88
- this.zeroReferenceTextureSet.add(textureRefInfo);
89
- }
90
- if (texture.txType === 'SubTexture') {
91
- // If this is a SubTexture, then decrement the reference count of the
92
- // parent texture as well.
93
- this.decrementTextureRefCount(texture.props.texture);
94
- }
95
- }
96
- }
97
- //# sourceMappingURL=TextureRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextureRegistry.js","sourceRoot":"","sources":["../../../src/main-api/TextureRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,MAAM,iCAAiC,GAAG,IAAI,CAAC;AAsB/C;;GAEG;AACH,MAAM,OAAO,eAAe;IAIJ;IAHtB,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAC;IACpD,uBAAuB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEzD,YAAsB,eAAgD;QAAhD,oBAAe,GAAf,eAAe,CAAiC;QACpE,uEAAuE;QACvE,iDAAiD;QACjD,WAAW,CAAC,GAAG,EAAE;YACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,uBAAuB,EAAE;gBACzD,IAAI,GAAG,GAAG,cAAc,CAAC,UAAU,GAAG,iCAAiC,EAAE;oBACvE,I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MAAM,KAAK,YAAY,EAAE;YACnC,qEAAqE;YACrE,0BAA0B;YAC1B,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACtD;QACD,cAAc,CAAC,YAAY,EAAE,CAAC;QAC9B,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;YACpD,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;SACrD;IACH,CAAC;IAED,wBAAwB,CAAC,OAAoB;QAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,YAAY,CAAC,SAAS,EAAE,0CAA0C,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtD,YAAY,CAAC,cAAc,EAAE,mCAAmC,CAAC,CAAC;QAClE,cAAc,CAAC,YAAY,EAAE,CAAC;QAC9B,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,cAAc,CAAC,YAAY,KAAK,CAAC,EAAE;YACrC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SAClD;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE;YACnC,qEAAqE;YACrE,0BAA0B;YAC1B,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACtD;IACH,CAAC;CACF"}
@@ -1,33 +0,0 @@
1
- import type { TextureDesc } from "../RendererMain.js";
2
- interface TextureRefInfo {
3
- /**
4
- * Texture Reference ID
5
- */
6
- id: number;
7
- /**
8
- * The number of references to this texture that are currently assigned to
9
- * Nodes.
10
- */
11
- nodeRefCount: number;
12
- /**
13
- * The last time the texture reference count was updated.
14
- *
15
- * @remarks
16
- * This is used to determine when a texture is no longer referenced by any
17
- * Nodes and can be removed from the GPU.
18
- */
19
- lastUpdate: number;
20
- }
21
- /**
22
- * Usage-based Texture Garbage Collection Registry
23
- */
24
- export declare class TextureRegistry {
25
- protected releaseCallback: (textureDescId: number) => void;
26
- textureMap: Map<number, TextureRefInfo>;
27
- zeroReferenceTextureSet: Set<TextureRefInfo>;
28
- constructor(releaseCallback: (textureDescId: number) => void);
29
- registerTexture(texture: TextureDesc): void;
30
- incrementTextureRefCount(texture: TextureDesc): void;
31
- decrementTextureRefCount(texture: TextureDesc): void;
32
- }
33
- export {};
@@ -1,97 +0,0 @@
1
- /*
2
- * If not stated otherwise in this file or this component's LICENSE file the
3
- * following copyright and licenses apply:
4
- *
5
- * Copyright 2023 Comcast Cable Communications Management, LLC.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the License);
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { assertTruthy } from "../../utils.js";
20
- const TEXTURE_CLEANUP_INTERVAL_MS = 1000;
21
- const TEXTURE_CLEANUP_AGE_THREADHOLD_MS = 5000;
22
- /**
23
- * Usage-based Texture Garbage Collection Registry
24
- */
25
- export class TextureRegistry {
26
- releaseCallback;
27
- textureMap = new Map();
28
- zeroReferenceTextureSet = new Set();
29
- constructor(releaseCallback) {
30
- this.releaseCallback = releaseCallback;
31
- // Periodically check for textures that are no longer referenced by any
32
- // Nodes and notify RendererMain to release them.
33
- setInterval(() => {
34
- const now = Date.now();
35
- for (const textureRefInfo of this.zeroReferenceTextureSet) {
36
- if (now - textureRefInfo.lastUpdate > TEXTURE_CLEANUP_AGE_THREADHOLD_MS) {
37
- this.releaseCallback(textureRefInfo.id);
38
- this.textureMap.delete(textureRefInfo.id);
39
- this.zeroReferenceTextureSet.delete(textureRefInfo);
40
- }
41
- }
42
- }, TEXTURE_CLEANUP_INTERVAL_MS);
43
- }
44
- registerTexture(texture) {
45
- const textureId = texture.options?.id;
46
- assertTruthy(textureId, 'Texture must have an id to be registered');
47
- if (!this.textureMap.has(textureId)) {
48
- const textureRefInfo = {
49
- id: textureId,
50
- nodeRefCount: 0,
51
- lastUpdate: Date.now()
52
- };
53
- this.textureMap.set(textureId, textureRefInfo);
54
- this.zeroReferenceTextureSet.add(textureRefInfo);
55
- }
56
- }
57
- incrementTextureRefCount(texture) {
58
- const textureId = texture.options?.id;
59
- assertTruthy(textureId, 'Texture must have an id to be registered');
60
- let textureRefInfo = this.textureMap.get(textureId);
61
- if (!textureRefInfo) {
62
- // Texture has not been registered yet, so register it now.
63
- // This may happen if the TextureDesc was cleaned up from the registry
64
- // but was still alive in memory and eventually re-used.
65
- this.registerTexture(texture);
66
- textureRefInfo = this.textureMap.get(textureId);
67
- }
68
- assertTruthy(textureRefInfo, 'Texture must have been registered');
69
- if (texture.txType === 'SubTexture') {
70
- // If this is a SubTexture, then increment the reference count of the
71
- // parent texture as well.
72
- this.incrementTextureRefCount(texture.props.texture);
73
- }
74
- textureRefInfo.nodeRefCount++;
75
- textureRefInfo.lastUpdate = Date.now();
76
- if (this.zeroReferenceTextureSet.has(textureRefInfo)) {
77
- this.zeroReferenceTextureSet.delete(textureRefInfo);
78
- }
79
- }
80
- decrementTextureRefCount(texture) {
81
- const textureId = texture.options?.id;
82
- assertTruthy(textureId, 'Texture must have an id to be registered');
83
- const textureRefInfo = this.textureMap.get(textureId);
84
- assertTruthy(textureRefInfo, 'Texture must have been registered');
85
- textureRefInfo.nodeRefCount--;
86
- textureRefInfo.lastUpdate = Date.now();
87
- if (textureRefInfo.nodeRefCount === 0) {
88
- this.zeroReferenceTextureSet.add(textureRefInfo);
89
- }
90
- if (texture.txType === 'SubTexture') {
91
- // If this is a SubTexture, then decrement the reference count of the
92
- // parent texture as well.
93
- this.decrementTextureRefCount(texture.props.texture);
94
- }
95
- }
96
- }
97
- //# sourceMappingURL=TextureRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextureRegistry.js","sourceRoot":"","sources":["../../../../src/main-api/TextureUsageRegistry/TextureRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,MAAM,iCAAiC,GAAG,IAAI,CAAC;AAsB/C;;GAEG;AACH,MAAM,OAAO,eAAe;IAIJ;IAHtB,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAC;IACpD,uBAAuB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEzD,YAAsB,eAAgD;QAAhD,oBAAe,GAAf,eAAe,CAAiC;QACpE,uEAAuE;QACvE,iDAAiD;QACjD,WAAW,CAAC,GAAG,EAAE;YACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,uBAAuB,EAAE;gBACzD,IAAI,GAAG,GAAG,cAAc,CAAC,UAAU,GAAG,iCAAiC,EAAE;oBACvE,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;oBACxC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;oBAC1C,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;iBACrD;aACF;QACH,CAAC,EAAE,2BAA2B,CAAC,CAAC;IAClC,CAAC;IAED,eAAe,CAAC,OAAoB;QAClC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,YAAY,CAAC,SAAS,EAAE,0CAA0C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AAC;IAED,wBAAwB,CAAC,OAAoB;QAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,YAAY,CAAC,SAAS,EAAE,0CAA0C,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtD,YAAY,CAAC,cAAc,EAAE,mCAAmC,CAAC,CAAC;QAClE,cAAc,CAAC,YAAY,EAAE,CAAC;QAC9B,cAAc,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,IAAI,cAAc,CAAC,YAAY,KAAK,CAAC,EAAE;YACrC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SAClD;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE;YACnC,qEAAqE;YACrE,0BAA0B;YAC1B,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SACtD;IACH,CAAC;CACF"}
@@ -1,52 +0,0 @@
1
- /*
2
- * If not stated otherwise in this file or this component's LICENSE file the
3
- * following copyright and licenses apply:
4
- *
5
- * Copyright 2023 Comcast Cable Communications Management, LLC.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the License);
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
-
20
- /**
21
- * Represents a 2D transformation context, providing a 2x2 matrix for transformations.
22
- */
23
- export class Matrix2DContext {
24
- // world alpha
25
- alpha = 1;
26
-
27
- // world position
28
- px = 0;
29
- py = 0;
30
-
31
- ta = 1;
32
- tb = 0;
33
- tc = 0;
34
- td = 1;
35
-
36
- isIdentity(): boolean {
37
- return (
38
- this.alpha === 1 &&
39
- this.px === 0 &&
40
- this.py === 0 &&
41
- this.isIdentityMatrix()
42
- );
43
- }
44
-
45
- isIdentityMatrix(): boolean {
46
- return this.ta === 1 && this.tb === 0 && this.tc === 0 && this.td === 1;
47
- }
48
-
49
- isSquare(): boolean {
50
- return this.tb === 0 && this.tc === 0;
51
- }
52
- }
@@ -1,231 +0,0 @@
1
- /*
2
- * If not stated otherwise in this file or this component's LICENSE file the
3
- * following copyright and licenses apply:
4
- *
5
- * Copyright 2023 Comcast Cable Communications Management, LLC.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the License);
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
-
20
- export const EPSILON = 0.00001;
21
- export const RANDOM = Math.random;
22
- export const ANGLE_ORDER = 'zyx';
23
-
24
- export type ConversionOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx';
25
-
26
- type RemoveIndex<T> = {
27
- [K in keyof T as number extends K ? never : K]: T[K];
28
- };
29
-
30
- export type Float32ArrayLen2 = RemoveIndex<Float32Array> & {
31
- 0: number;
32
- 1: number;
33
- length: 2;
34
- };
35
-
36
- export type NumberArrayLen2 = [number, number];
37
-
38
- export type Float32ArrayLen3 = RemoveIndex<Float32Array> & {
39
- 0: number;
40
- 1: number;
41
- 2: number;
42
- length: 3;
43
- };
44
-
45
- export type NumberArrayLen3 = [number, number, number];
46
-
47
- export type Float32ArrayLen4 = RemoveIndex<Float32Array> & {
48
- 0: number;
49
- 1: number;
50
- 2: number;
51
- 3: number;
52
- length: 4;
53
- };
54
-
55
- export type NumberArrayLen4 = [number, number, number, number];
56
-
57
- export type Float32ArrayLen6 = RemoveIndex<Float32Array> & {
58
- 0: number;
59
- 1: number;
60
- 2: number;
61
- 3: number;
62
- 4: number;
63
- 5: number;
64
- length: 6;
65
- };
66
-
67
- export type NumberArrayLen6 = [number, number, number, number, number, number];
68
-
69
- export type Float32ArrayLen8 = RemoveIndex<Float32Array> & {
70
- 0: number;
71
- 1: number;
72
- 2: number;
73
- 3: number;
74
- 4: number;
75
- 5: number;
76
- 6: number;
77
- 7: number;
78
- length: 8;
79
- };
80
-
81
- export type NumberArrayLen8 = [
82
- number,
83
- number,
84
- number,
85
- number,
86
- number,
87
- number,
88
- number,
89
- number,
90
- ];
91
-
92
- export type Float32ArrayLen9 = RemoveIndex<Float32Array> & {
93
- 0: number;
94
- 1: number;
95
- 2: number;
96
- 3: number;
97
- 4: number;
98
- 5: number;
99
- 6: number;
100
- 7: number;
101
- 8: number;
102
- length: 9;
103
- };
104
-
105
- export type NumberArrayLen9 = [
106
- number,
107
- number,
108
- number,
109
- number,
110
- number,
111
- number,
112
- number,
113
- number,
114
- number,
115
- ];
116
-
117
- export type Float32ArrayLen16 = RemoveIndex<Float32Array> & {
118
- 0: number;
119
- 1: number;
120
- 2: number;
121
- 3: number;
122
- 4: number;
123
- 5: number;
124
- 6: number;
125
- 7: number;
126
- 8: number;
127
- 9: number;
128
- 10: number;
129
- 11: number;
130
- 12: number;
131
- 13: number;
132
- 14: number;
133
- 15: number;
134
- length: 16;
135
- };
136
-
137
- export type NumberArrayLen16 = [
138
- number,
139
- number,
140
- number,
141
- number,
142
- number,
143
- number,
144
- number,
145
- number,
146
- number,
147
- number,
148
- number,
149
- number,
150
- number,
151
- number,
152
- number,
153
- number,
154
- ];
155
-
156
- export interface FOV {
157
- upDegrees: number;
158
- downDegrees: number;
159
- leftDegrees: number;
160
- rightDegrees: number;
161
- }
162
-
163
- let useFloat32Arrays = true;
164
-
165
- /**
166
- * Sets array type to be used.
167
- *
168
- * @param {number} size of matrix type
169
- * @returns {FloatArray} matrix type
170
- */
171
- export function setMatrixArrayType(type: Float32Array | number[]): void {
172
- useFloat32Arrays = type instanceof Float32Array;
173
- }
174
-
175
- /**
176
- * Return array type to be used.
177
- *
178
- * @param {number} size of matrix type
179
- * @returns {FloatArray} matrix type
180
- */
181
- export function getMatrixArrayType(size?: number): Float32Array | number[] {
182
- if (useFloat32Arrays && typeof Float32Array !== 'undefined') {
183
- return size ? new Float32Array(size) : new Float32Array();
184
- }
185
- return [];
186
- }
187
-
188
- /**
189
- * Convert Angle in Degrees To Radians
190
- *
191
- * @param {number} angle is an Angle in Degrees
192
- */
193
- export function toRadians(angle: number): number {
194
- return angle * (Math.PI / 180);
195
- }
196
-
197
- /**
198
- * Convert Angle in Radians To an Angle in Radians
199
- *
200
- * @param {number} angle is an Angle in Radians
201
- */
202
- export function toDegrees(angle: number): number {
203
- return angle * (180 / Math.PI);
204
- }
205
-
206
- /**
207
- * Tests whether or not the arguments have approximately the same value, within an absolute
208
- * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
209
- * than or equal to 1.0, and a relative tolerance is used for larger values)
210
- *
211
- * @param {number} a The first number to test.
212
- * @param {number} b The second number to test.
213
- * @returns {boolean} True if the numbers are approximately equal, false otherwise.
214
- */
215
-
216
- export function equals(a: number, b: number): boolean {
217
- return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
218
- }
219
-
220
- if (!Math.hypot)
221
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
222
- Math.hypot = function (...args: any[]): number {
223
- let y = 0,
224
- i: number = arguments.length;
225
-
226
- while (i--) {
227
- y += args[i] * args[i];
228
- }
229
-
230
- return Math.sqrt(y);
231
- };
@@ -1,31 +0,0 @@
1
- /*
2
- * If not stated otherwise in this file or this component's LICENSE file the
3
- * following copyright and licenses apply:
4
- *
5
- * Copyright 2023 Comcast Cable Communications Management, LLC.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the License);
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
-
20
- import * as glMatrix from './common.js';
21
- import * as mat2 from './mat2.js';
22
- import * as mat2d from './mat2d.js';
23
- import * as mat3 from './mat3.js';
24
- import * as mat4 from './mat4.js';
25
- import * as quat from './quat.js';
26
- import * as quat2 from './quat2.js';
27
- import * as vec2 from './vec2.js';
28
- import * as vec3 from './vec3.js';
29
- import * as vec4 from './vec4.js';
30
-
31
- export { glMatrix, mat2, mat2d, mat3, mat4, quat, quat2, vec2, vec3, vec4 };