@luma.gl/engine 10.0.0-alpha.12 → 10.0.0-alpha.14

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 (87) hide show
  1. package/LICENSE +4 -4
  2. package/THIRD-PARTY-NOTICES.md +185 -0
  3. package/dist/compute/swap.d.ts +2 -2
  4. package/dist/compute/swap.d.ts.map +1 -1
  5. package/dist/compute/swap.js.map +1 -1
  6. package/dist/dist.dev.js +181 -70
  7. package/dist/dist.min.js +61 -61
  8. package/dist/dynamic-texture/video-texture.cjs +1 -1
  9. package/dist/dynamic-texture/video-texture.d.ts +3 -3
  10. package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
  11. package/dist/dynamic-texture/video-texture.js +1 -1
  12. package/dist/dynamic-texture/video-texture.js.map +1 -1
  13. package/dist/effects/index.cjs.map +1 -1
  14. package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  15. package/dist/effects/passes/postprocessing/fxaa/fxaa.js +2 -1
  16. package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
  17. package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  18. package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +2 -0
  19. package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
  20. package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
  21. package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js +2 -0
  22. package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
  23. package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  24. package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js +2 -0
  25. package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
  26. package/dist/effects/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  27. package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js +2 -0
  28. package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
  29. package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
  30. package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js +2 -0
  31. package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
  32. package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  33. package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js +2 -0
  34. package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
  35. package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  36. package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js +2 -0
  37. package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
  38. package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
  39. package/dist/gltf/types/gltf-json-schema.js +1 -0
  40. package/dist/gltf/types/gltf-json-schema.js.map +1 -1
  41. package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
  42. package/dist/gltf/types/gltf-postprocessed-schema.js +1 -0
  43. package/dist/gltf/types/gltf-postprocessed-schema.js.map +1 -1
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/lighting/index.cjs.map +1 -1
  46. package/dist/text/index.cjs +2 -0
  47. package/dist/text/index.cjs.map +2 -2
  48. package/dist/text/index.d.ts +1 -1
  49. package/dist/text/index.d.ts.map +1 -1
  50. package/dist/text/index.js +1 -1
  51. package/dist/text/index.js.map +1 -1
  52. package/dist/text/text-2d/index.cjs +3 -0
  53. package/dist/text/text-2d/index.d.ts +1 -0
  54. package/dist/text/text-2d/index.d.ts.map +1 -1
  55. package/dist/text/text-2d/index.js +1 -0
  56. package/dist/text/text-2d/index.js.map +1 -1
  57. package/dist/text/text-2d/model-utils/text-code-point-source.cjs +41 -0
  58. package/dist/text/text-2d/model-utils/text-code-point-source.d.ts +8 -0
  59. package/dist/text/text-2d/model-utils/text-code-point-source.d.ts.map +1 -0
  60. package/dist/text/text-2d/model-utils/text-code-point-source.js +23 -0
  61. package/dist/text/text-2d/model-utils/text-code-point-source.js.map +1 -0
  62. package/licenses/cesium.txt +207 -0
  63. package/licenses/deck-community.txt +19 -0
  64. package/licenses/deck.txt +19 -0
  65. package/licenses/glfx.txt +19 -0
  66. package/licenses/gltf-loader-ts.txt +21 -0
  67. package/licenses/magenta-font.txt +13 -0
  68. package/licenses/nvidia-fxaa.txt +25 -0
  69. package/licenses/philogl.txt +19 -0
  70. package/licenses/spark.txt +21 -0
  71. package/licenses/three.txt +21 -0
  72. package/package.json +12 -9
  73. package/src/compute/swap.ts +2 -2
  74. package/src/dynamic-texture/video-texture.ts +9 -3
  75. package/src/effects/passes/postprocessing/fxaa/fxaa.ts +2 -1
  76. package/src/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -0
  77. package/src/effects/passes/postprocessing/image-adjust-filters/denoise.ts +2 -0
  78. package/src/effects/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -0
  79. package/src/effects/passes/postprocessing/image-adjust-filters/noise.ts +2 -0
  80. package/src/effects/passes/postprocessing/image-adjust-filters/sepia.ts +2 -0
  81. package/src/effects/passes/postprocessing/image-adjust-filters/vibrance.ts +2 -0
  82. package/src/effects/passes/postprocessing/image-adjust-filters/vignette.ts +2 -0
  83. package/src/gltf/types/gltf-json-schema.ts +1 -0
  84. package/src/gltf/types/gltf-postprocessed-schema.ts +1 -0
  85. package/src/text/index.ts +1 -0
  86. package/src/text/text-2d/index.ts +1 -0
  87. package/src/text/text-2d/model-utils/text-code-point-source.ts +34 -0
package/LICENSE CHANGED
@@ -8,16 +8,16 @@ Copyright (c) 2015 Uber Technologies, Inc.
8
8
  This software includes parts of PhiloGL (https://github.com/philogb/philogl)
9
9
  under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
10
10
 
11
- This software includes adaptations of some postprocessing code from
12
- THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
13
- THREE.js parts Copyright © 2010-2018 three.js authors.
11
+ This software includes adaptations of some postprocessing code from
12
+ THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
13
+ THREE.js parts Copyright © 2010-2018 three.js authors.
14
14
 
15
15
  This software includes adaptations of Gaussian-splat rendering and
16
16
  level-of-detail behavior from Spark (https://github.com/sparkjsdev/spark)
17
17
  under MIT license.
18
18
  Spark parts Copyright © 2025 WORLD LABS TECHNOLOGIES, INC.
19
19
 
20
- Additional attribution given in specific source files.
20
+ Additional attribution given in specific source files.
21
21
 
22
22
  Permission is hereby granted, free of charge, to any person obtaining a copy
23
23
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,185 @@
1
+ # Third-party notices: @luma.gl/engine
2
+
3
+ PhiloGL heritage; primitive generation is supplied by the separately installed math.gl geometry package. Historical Google TDL primitive contributions remain acknowledged in the public credits guide, rather than being described as source shipped by this package.
4
+
5
+ The [repository license](./LICENSE) retains historical project notices.
6
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
7
+ Separately installed dependencies retain their own licenses; this is not a transitive dependency inventory.
8
+
9
+ ## PhiloGL
10
+
11
+ Nicolas Garcia Belmonte; Sencha Labs.
12
+
13
+ Source: [PhiloGL](https://github.com/senchalabs/philogl).
14
+
15
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
16
+
17
+ Adaptation: Historical ES6 port and subsequent engine evolution. The root LICENSE retains the 2013 Sencha notice; upstream also names the author in its 2011 notice. This is project lineage, not a claim that every engine file is copied.
18
+
19
+ Full terms: [philogl](./licenses/philogl.txt).
20
+ ## Arrow interoperability
21
+
22
+ Apache Arrow and GeoArrow provide format and interoperability foundations. The separately installed apache-arrow dependency retains its Apache-2.0 license.
23
+
24
+ The [repository license](./LICENSE) retains historical project notices.
25
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
26
+ These notices accompany the engine package.
27
+ Separately installed dependencies retain their own licenses.
28
+ ## Effects
29
+
30
+ Classic image filters derive from Evan Wallace’s glfx.js; LICENSE also retains three.js postprocessing attribution. FXAA comes through NVIDIA and Cesium.
31
+
32
+ The [repository license](./LICENSE) retains historical project notices.
33
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
34
+ Separately installed dependencies retain their own licenses; this is not a transitive dependency inventory.
35
+
36
+ ## glfx.js
37
+
38
+ Copyright (C) 2011 by Evan Wallace.
39
+
40
+ Source: [glfx.js](https://github.com/evanw/glfx.js).
41
+
42
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
43
+
44
+ Adaptation: Classic adjustment, blur, artistic, and warp filters are adapted to ShaderPass, GLSL, and WGSL. The image-processing documentation identifies glfx.js; newer effects may be independently authored.
45
+
46
+ Full terms: [glfx](./licenses/glfx.txt).
47
+
48
+ ## three.js postprocessing
49
+
50
+ three.js authors; historical Copyright 2010-2018 retained in LICENSE.
51
+
52
+ Source: [three.js postprocessing](https://github.com/mrdoob/three.js).
53
+
54
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
55
+
56
+ Adaptation: Historical postprocessing adaptations recorded by the repository LICENSE; exact original file mapping is unknown.
57
+
58
+ Full terms: [three](./licenses/three.txt).
59
+
60
+ ## FXAA via Cesium
61
+
62
+ NVIDIA CORPORATION; Cesium Contributors.
63
+
64
+ Source: [FXAA via Cesium](https://github.com/CesiumGS/cesium/tree/1.40).
65
+
66
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
67
+
68
+ Adaptation: src/effects/passes/postprocessing/fxaa/fxaa.ts records sampling, alpha, and luminance modifications. Cesium 1.40 is a license reference, not an asserted import version. NVIDIA FXAA 3.11 BSD and Cesium Apache-2.0 terms are retained separately.
69
+
70
+ Full terms: [cesium](./licenses/cesium.txt).
71
+
72
+ ## NVIDIA FXAA 3.11
73
+
74
+ Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved..
75
+
76
+ Source: [NVIDIA FXAA 3.11](https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h).
77
+
78
+ Revision: historical import revision unknown unless explicitly identified below. Upstream license copies supplement retained source and repository notices.
79
+
80
+ Adaptation: See FXAA via Cesium. The full NVIDIA notice is extracted from the retained source comment.
81
+
82
+ Full terms: [nvidia-fxaa](./licenses/nvidia-fxaa.txt).
83
+ ## glTF
84
+
85
+ glTF interpretation follows Khronos specifications. Fixture provenance, licenses, revisions, and transformations are documented at modules/engine/test/gltf/data/README.md in the repository; test fixtures are not shipped by this package.
86
+
87
+ The [repository license](./LICENSE) retains historical project notices.
88
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
89
+ Separately installed dependencies retain their own licenses; this is not a transitive dependency inventory.
90
+
91
+
92
+
93
+ ## gltf-loader-ts schema types
94
+
95
+ Copyright (c) 2018 Benjamin Wasty.
96
+
97
+ Source: [gltf-loader-ts](https://github.com/bwasty/gltf-loader-ts). Historical import revision unknown; the source was previously maintained through loaders.gl and moved into luma.gl.
98
+
99
+ Affected files: src/gltf/types/gltf-json-schema.ts and src/gltf/types/gltf-postprocessed-schema.ts. Types are adapted for luma.gl’s glTF extensions, parser output, and strict TypeScript APIs.
100
+
101
+ Full terms: [MIT license](./licenses/gltf-loader-ts.txt).
102
+ ## Splats
103
+
104
+ Gaussian-splat rendering with Spark RAD opacity/support behavior adapted from World Labs.
105
+
106
+ The [repository license](./LICENSE) retains historical project notices.
107
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
108
+ These notices accompany the engine package.
109
+ Separately installed dependencies retain their own licenses.
110
+
111
+ ## Spark
112
+
113
+ Copyright © 2025 WORLD LABS TECHNOLOGIES, INC..
114
+
115
+ Source: [Spark](https://github.com/sparkjsdev/spark/blob/main/src/shaders/splatVertex.glsl).
116
+
117
+ Revision: historical import revision unknown unless identified below.
118
+
119
+ Adaptation: src/splats/splat-rad-hierarchy.ts and src/splats/gpu-paged-splat-shaders.ts adapt RAD opacity/support behavior for luma.gl paging and shaders.
120
+
121
+ Full terms: [spark](./licenses/spark.txt).
122
+ ## Text
123
+
124
+ Text paths, extrusion, and font loading adapted from three.js; browser atlas utilities adapted from deck.gl. Font data has its own retained terms.
125
+
126
+ The [repository license](./LICENSE) retains historical project notices.
127
+ See [References and credits](https://luma.gl/docs/references-and-credits) for people, research, standards, and assets.
128
+ These notices accompany the published text package and local distributions.
129
+ Separately installed dependencies retain their own licenses.
130
+
131
+ ## three.js text utilities
132
+
133
+ three.js authors.
134
+
135
+ Source: [three.js text utilities](https://github.com/mrdoob/three.js).
136
+
137
+ Revision: historical import revision unknown unless identified below.
138
+
139
+ Adaptation: src/text/text-3d paths, curves, shapes, FontLoader, TextGeometry, and ExtrudeGeometry adapted to TypeScript and luma.gl geometry; src/text/fonts/typeface-font-data.ts and helvetiker.ts retain three.js data lineage.
140
+
141
+ Full terms: [three](./licenses/three.txt).
142
+
143
+ ## deck.gl text atlas
144
+
145
+ Vis.gl contributors.
146
+
147
+ Source: [deck.gl text atlas](https://github.com/visgl/deck.gl).
148
+
149
+ Revision: historical import revision unknown unless identified below.
150
+
151
+ Adaptation: src/text/fonts/atlas/browser-font-atlas.ts and text-utils.ts adapt browser font atlas and text utilities.
152
+
153
+ Full terms: [deck](./licenses/deck.txt).
154
+
155
+ ## Helvetiker / MgOpen
156
+
157
+ Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved..
158
+
159
+ Source: [Helvetiker / MgOpen](https://github.com/mrdoob/three.js/blob/master/examples/fonts/helvetiker_regular.typeface.json).
160
+
161
+ Revision: historical import revision unknown unless identified below.
162
+
163
+ Adaptation: src/text/fonts/helvetiker.ts packages font data as TypeScript. Metadata identifies version 1.00, 2004 initial release. The embedded original font terms are reproduced separately from the code license.
164
+
165
+ Full terms: [magenta-font](./licenses/magenta-font.txt).
166
+
167
+ ## Linearly Transformed Cosines fit data
168
+
169
+ Copyright (c) 2017, Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt.
170
+
171
+ Source: [selfshadow/ltc_code fit/results/ltc.js](https://github.com/selfshadow/ltc_code/blob/31e5e96b54f98f33098f8503003119ba2231a1c6/fit/results/ltc.js),
172
+ pinned to commit `31e5e96b54f98f33098f8503003119ba2231a1c6`.
173
+ The GGX fit tables are embedded in `src/lighting/ltc-data.ts`
174
+ as TypeScript arrays for area-light shading.
175
+
176
+ Required paper reference: **Real-Time Polygonal-Light Shading with Linearly
177
+ Transformed Cosines**, Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt,
178
+ ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016), 35(4), 2016.
179
+ [Project page](https://eheitzresearch.wordpress.com/415-2/).
180
+
181
+ Full terms: [LicenseRef-LTC and paper citation](./src/lighting/LTC-LICENSE.txt).
182
+
183
+ ## deck.gl-community glyph utilities
184
+
185
+ Copyright (c) 2020 vis.gl a Series of LF Projects, LLC. Glyph range utilities from [deck.gl-community](https://github.com/visgl/deck.gl-community) were adapted for engine font loading and atlas construction. Historical import revision unknown. Full terms: [deck.gl-community MIT license](./licenses/deck-community.txt).
@@ -1,12 +1,12 @@
1
1
  import type { BufferProps, FramebufferProps } from '@luma.gl/core';
2
- import { Device, Resource, Buffer, Framebuffer } from '@luma.gl/core';
2
+ import { Device, DeviceResource, Buffer, Framebuffer } from '@luma.gl/core';
3
3
  /**
4
4
  * Helper class for working with repeated transformations / computations
5
5
  * Primarily intended for GPU buffers `Swap<Buffer>` or textures `Swap<Texture>`)
6
6
  * @note the two resources are expected to be structurally identical (same size, length, format, etc)
7
7
  * @note the two resources can be destroyed by calling `destroy()`
8
8
  */
9
- export declare class Swap<T extends Resource<any>> {
9
+ export declare class Swap<T extends DeviceResource<any>> {
10
10
  id: string;
11
11
  /** The current resource - usually the source for renders or computations */
12
12
  current: T;
@@ -1 +1 @@
1
- {"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/compute/swap.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAU,MAAM,eAAe,CAAC;AAE7E;;;;;GAKG;AACH,qBAAa,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;IAEX,4EAA4E;IAC5E,OAAO,EAAE,CAAC,CAAC;IACX,uFAAuF;IACvF,IAAI,EAAE,CAAC,CAAC;gBAEI,KAAK,EAAE;QAAC,OAAO,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,CAAC,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC;IAMrD,yCAAyC;IACzC,OAAO;IAKP,4GAA4G;IAC5G,IAAI;CAKL;AAED,uDAAuD;AACvD,qBAAa,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC;gBACzC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB;IA2CnD;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO;CAgBvD;AAYD,sDAAsD;AACtD,qBAAa,WAAY,SAAQ,IAAI,CAAC,MAAM,CAAC;gBAC/B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAI9C;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC;CAenC"}
1
+ {"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/compute/swap.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,EAAC,MAAM,EAAE,cAAc,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,IAAY;IAC3C,YAAY,MAAc,EAAE,KAAkB;QAC5C,KAAK,CAAC,EAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAC,CAAC,CAAC;IACjF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAA2B;QAChC,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACjD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC;QAE7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
package/dist/dist.dev.js CHANGED
@@ -11024,7 +11024,148 @@ ${declarations.join("\n")}`).match(
11024
11024
  return `${id}-${count}`;
11025
11025
  }
11026
11026
 
11027
+ // ../core/src/api/utils/assert.ts
11028
+ function assert8(condition, message) {
11029
+ if (!condition) {
11030
+ const error = new Error(message ?? "luma.gl assertion failed.");
11031
+ Error.captureStackTrace?.(error, assert8);
11032
+ throw error;
11033
+ }
11034
+ }
11035
+
11027
11036
  // ../core/src/api/adapter/resources/resource.ts
11037
+ var Resource = class {
11038
+ _owner = null;
11039
+ _ownedResources = /* @__PURE__ */ new Set();
11040
+ _state = "live";
11041
+ _destroyingOwnedResources = false;
11042
+ _destroyRequested = false;
11043
+ /** The resource responsible for destroying this resource, or null for caller-managed lifetime. */
11044
+ get owner() {
11045
+ return this._owner;
11046
+ }
11047
+ /** A snapshot of this resource's children. Mutating the snapshot cannot change ownership. */
11048
+ get ownedResources() {
11049
+ return Array.from(this._ownedResources);
11050
+ }
11051
+ /** Whether destruction has completed, including when cleanup reported an error. */
11052
+ get destroyed() {
11053
+ return this._state === "destroyed";
11054
+ }
11055
+ /** Transfer exclusive ownership, or return lifetime responsibility to the caller with null. */
11056
+ transferOwnershipTo(owner) {
11057
+ assert8(this._state === "live" && !this._destroyingOwnedResources);
11058
+ assert8(!this._owner || this._owner.canChangeOwnership());
11059
+ assert8(!owner || owner.canChangeOwnership());
11060
+ for (let ancestor = owner; ancestor; ancestor = ancestor._owner) {
11061
+ assert8(ancestor !== this);
11062
+ }
11063
+ if (owner !== this._owner) {
11064
+ this._owner?._ownedResources.delete(this);
11065
+ this._owner = owner;
11066
+ owner?._ownedResources.add(this);
11067
+ }
11068
+ return this;
11069
+ }
11070
+ /** Destroy children before this resource. Subclasses implement hooks instead of overriding. */
11071
+ destroy() {
11072
+ if (this._state !== "live") {
11073
+ return;
11074
+ }
11075
+ if (this._destroyingOwnedResources) {
11076
+ this._destroyRequested = true;
11077
+ return;
11078
+ }
11079
+ this._destroyRequested = false;
11080
+ this._state = "destroying";
11081
+ this._owner?._ownedResources.delete(this);
11082
+ this._owner = null;
11083
+ const errors = [];
11084
+ try {
11085
+ try {
11086
+ this.onBeforeDestroy();
11087
+ } catch (error) {
11088
+ errors.push(error);
11089
+ }
11090
+ this.destroyChildren(errors);
11091
+ try {
11092
+ this.onDestroy();
11093
+ } catch (error) {
11094
+ errors.push(error);
11095
+ }
11096
+ } finally {
11097
+ this._state = "destroyed";
11098
+ }
11099
+ if (errors.length) {
11100
+ throw new AggregateError(errors, "Resource cleanup failed");
11101
+ }
11102
+ }
11103
+ /** @deprecated Use destroy(). */
11104
+ delete() {
11105
+ this.destroy();
11106
+ return this;
11107
+ }
11108
+ /** @deprecated Use resource.transferOwnershipTo(this). */
11109
+ attachResource(resource) {
11110
+ resource.transferOwnershipTo(this);
11111
+ }
11112
+ /** @deprecated Use resource.transferOwnershipTo(null). Only detaches a child owned by this. */
11113
+ detachResource(resource) {
11114
+ if (resource._owner === this) {
11115
+ resource.transferOwnershipTo(null);
11116
+ }
11117
+ }
11118
+ /** @deprecated Check resource.owner and call resource.destroy(). */
11119
+ destroyAttachedResource(resource) {
11120
+ if (resource._owner === this) {
11121
+ resource.destroy();
11122
+ }
11123
+ }
11124
+ /** @deprecated Destroy individually owned resources, or destroy the owner. */
11125
+ destroyAttachedResources() {
11126
+ if (this._state !== "live" || this._destroyingOwnedResources) {
11127
+ return;
11128
+ }
11129
+ const errors = [];
11130
+ this.destroyChildren(errors);
11131
+ if (this._destroyRequested) {
11132
+ try {
11133
+ this.destroy();
11134
+ } catch (error) {
11135
+ errors.push(error);
11136
+ }
11137
+ }
11138
+ if (errors.length) {
11139
+ throw new AggregateError(errors, "Resource cleanup failed");
11140
+ }
11141
+ }
11142
+ /** Stop activity before children are destroyed. Errors are collected; this hook cannot veto cleanup. */
11143
+ onBeforeDestroy() {
11144
+ }
11145
+ /** Release this resource's own state after its children have been destroyed. */
11146
+ onDestroy() {
11147
+ }
11148
+ canChangeOwnership() {
11149
+ return this._state === "live" && !this._destroyingOwnedResources;
11150
+ }
11151
+ destroyChildren(errors) {
11152
+ this._destroyingOwnedResources = true;
11153
+ try {
11154
+ for (const resource of this._ownedResources) {
11155
+ try {
11156
+ resource.destroy();
11157
+ } catch (error) {
11158
+ errors.push(error);
11159
+ }
11160
+ }
11161
+ } finally {
11162
+ this._ownedResources.clear();
11163
+ this._destroyingOwnedResources = false;
11164
+ }
11165
+ }
11166
+ };
11167
+
11168
+ // ../core/src/api/adapter/resources/device-resource.ts
11028
11169
  var CPU_HOTSPOT_PROFILER_MODULE = "cpu-hotspot-profiler";
11029
11170
  var RESOURCE_COUNTS_STATS = "GPU Resource Counts";
11030
11171
  var LEGACY_RESOURCE_COUNTS_STATS = "Resource Counts";
@@ -11080,7 +11221,7 @@ ${declarations.join("\n")}`).match(
11080
11221
  ]);
11081
11222
  var ORDERED_STATS_CACHE = /* @__PURE__ */ new WeakMap();
11082
11223
  var ORDERED_STAT_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
11083
- var Resource = class {
11224
+ var DeviceResource = class extends Resource {
11084
11225
  /** Default properties for resource */
11085
11226
  static defaultProps = {
11086
11227
  id: "undefined",
@@ -11103,14 +11244,10 @@ ${declarations.join("\n")}`).match(
11103
11244
  userData = {};
11104
11245
  /** The device that this resource is associated with - TODO can we remove this dup? */
11105
11246
  _device;
11106
- /** Whether this resource has been destroyed */
11107
- destroyed = false;
11108
11247
  /** For resources that allocate GPU memory */
11109
11248
  allocatedBytes = 0;
11110
11249
  /** Stats bucket currently holding the tracked allocation */
11111
11250
  allocatedBytesName = null;
11112
- /** Attached resources will be destroyed when this resource is destroyed. Tracks auto-created "sub" resources. */
11113
- _attachedResources = /* @__PURE__ */ new Set();
11114
11251
  /** Whether luma.gl created and owns the underlying resource handle. */
11115
11252
  get ownsHandle() {
11116
11253
  return (this.props.handle === void 0 || this.props.handle === null) && !this.isHandleBorrowed;
@@ -11120,9 +11257,10 @@ ${declarations.join("\n")}`).match(
11120
11257
  return Boolean(this.props._isHandleBorrowed);
11121
11258
  }
11122
11259
  /**
11123
- * Create a new Resource. Called from Subclass
11260
+ * Create a new DeviceResource. Called from Subclass
11124
11261
  */
11125
11262
  constructor(device, props, defaultProps) {
11263
+ super();
11126
11264
  if (!device) {
11127
11265
  throw new Error("no device");
11128
11266
  }
@@ -11134,20 +11272,6 @@ ${declarations.join("\n")}`).match(
11134
11272
  this.userData = this.props.userData || {};
11135
11273
  this.addStats();
11136
11274
  }
11137
- /**
11138
- * destroy can be called on any resource to release it before it is garbage collected.
11139
- */
11140
- destroy() {
11141
- if (this.destroyed) {
11142
- return;
11143
- }
11144
- this.destroyResource();
11145
- }
11146
- /** @deprecated Use destroy() */
11147
- delete() {
11148
- this.destroy();
11149
- return this;
11150
- }
11151
11275
  /**
11152
11276
  * Combines a map of user props and default props, only including props from defaultProps
11153
11277
  * @returns returns a map of overridden default props
@@ -11155,46 +11279,19 @@ ${declarations.join("\n")}`).match(
11155
11279
  getProps() {
11156
11280
  return this.props;
11157
11281
  }
11158
- // ATTACHED RESOURCES
11159
- /**
11160
- * Attaches a resource. Attached resources are auto destroyed when this resource is destroyed
11161
- * Called automatically when sub resources are auto created but can be called by application
11162
- */
11163
- attachResource(resource) {
11164
- this._attachedResources.add(resource);
11282
+ /** Backend cleanup. Override this instead of destroy(); children are already destroyed. */
11283
+ destroyHandle() {
11165
11284
  }
11166
- /**
11167
- * Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
11168
- */
11169
- detachResource(resource) {
11170
- this._attachedResources.delete(resource);
11171
- }
11172
- /**
11173
- * Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
11174
- */
11175
- destroyAttachedResource(resource) {
11176
- if (this._attachedResources.delete(resource)) {
11177
- resource.destroy();
11178
- }
11179
- }
11180
- /** Destroy all owned resources. Make sure the resources are no longer needed before calling. */
11181
- destroyAttachedResources() {
11182
- for (const resource of this._attachedResources) {
11183
- resource.destroy();
11184
- }
11185
- this._attachedResources = /* @__PURE__ */ new Set();
11186
- }
11187
- // PROTECTED METHODS
11188
- /** Perform all destroy steps. Can be called by derived resources when overriding destroy() */
11189
- destroyResource() {
11190
- if (this.destroyed) {
11191
- return;
11285
+ /** Complete device bookkeeping even when backend cleanup fails. */
11286
+ onDestroy() {
11287
+ try {
11288
+ this.destroyHandle();
11289
+ } finally {
11290
+ this.trackDeallocatedMemory();
11291
+ this.removeStats();
11192
11292
  }
11193
- this.destroyAttachedResources();
11194
- this.removeStats();
11195
- this.destroyed = true;
11196
11293
  }
11197
- /** Called by .destroy() to track object destruction. Subclass must call if overriding destroy() */
11294
+ /** Track object destruction after backend cleanup. */
11198
11295
  removeStats() {
11199
11296
  const profiler = getCpuHotspotProfiler(this._device);
11200
11297
  const startTime = profiler ? getTimestamp() : 0;
@@ -11372,7 +11469,7 @@ ${declarations.join("\n")}`).match(
11372
11469
  let prototype = Object.getPrototypeOf(resource);
11373
11470
  while (prototype) {
11374
11471
  const parentPrototype = Object.getPrototypeOf(prototype);
11375
- if (!parentPrototype || parentPrototype === Resource.prototype) {
11472
+ if (!parentPrototype || parentPrototype === DeviceResource.prototype) {
11376
11473
  return getPrototypeToStringTag(prototype) || resource[Symbol.toStringTag] || resource.constructor.name;
11377
11474
  }
11378
11475
  prototype = parentPrototype;
@@ -11391,7 +11488,7 @@ ${declarations.join("\n")}`).match(
11391
11488
  }
11392
11489
 
11393
11490
  // ../core/src/api/adapter/resources/buffer.ts
11394
- var Buffer4 = class _Buffer extends Resource {
11491
+ var Buffer4 = class _Buffer extends DeviceResource {
11395
11492
  /** Index buffer */
11396
11493
  static INDEX = 16;
11397
11494
  /** Vertex buffer */
@@ -11472,7 +11569,7 @@ ${declarations.join("\n")}`).match(
11472
11569
  }
11473
11570
  }
11474
11571
  static defaultProps = {
11475
- ...Resource.defaultProps,
11572
+ ...DeviceResource.defaultProps,
11476
11573
  handle: void 0,
11477
11574
  usage: 0,
11478
11575
  // Buffer.COPY_DST | Buffer.COPY_SRC
@@ -12046,9 +12143,9 @@ ${declarations.join("\n")}`).match(
12046
12143
  }
12047
12144
 
12048
12145
  // ../core/src/api/adapter/resources/sampler.ts
12049
- var Sampler = class _Sampler extends Resource {
12146
+ var Sampler = class _Sampler extends DeviceResource {
12050
12147
  static defaultProps = {
12051
- ...Resource.defaultProps,
12148
+ ...DeviceResource.defaultProps,
12052
12149
  type: "color-sampler",
12053
12150
  addressModeU: "clamp-to-edge",
12054
12151
  addressModeV: "clamp-to-edge",
@@ -12073,6 +12170,20 @@ ${declarations.join("\n")}`).match(
12073
12170
  return props;
12074
12171
  }
12075
12172
  };
12173
+ function setTextureSampler(texture, sampler) {
12174
+ const nextSampler = sampler instanceof Sampler ? sampler : texture.device.createSampler(sampler);
12175
+ if (nextSampler === texture.sampler) {
12176
+ return;
12177
+ }
12178
+ if (!(sampler instanceof Sampler)) {
12179
+ nextSampler.transferOwnershipTo(texture);
12180
+ }
12181
+ const previousSampler = texture.sampler;
12182
+ texture.sampler = nextSampler;
12183
+ if (previousSampler?.owner === texture) {
12184
+ previousSampler.destroy();
12185
+ }
12186
+ }
12076
12187
 
12077
12188
  // ../core/src/api/adapter/resources/texture.ts
12078
12189
  var textureLayoutScratchPool = [];
@@ -12085,7 +12196,7 @@ ${declarations.join("\n")}`).match(
12085
12196
  "cube-array": "2d",
12086
12197
  "3d": "3d"
12087
12198
  };
12088
- var Texture = class _Texture extends Resource {
12199
+ var Texture = class _Texture extends DeviceResource {
12089
12200
  /** The texture can be bound for use as a sampled texture in a shader */
12090
12201
  static SAMPLE = 4;
12091
12202
  /** The texture can be bound for use as a storage texture in a shader */
@@ -12173,7 +12284,7 @@ ${declarations.join("\n")}`).match(
12173
12284
  }
12174
12285
  /** Set sampler props associated with this texture */
12175
12286
  setSampler(sampler) {
12176
- this.sampler = sampler instanceof Sampler ? sampler : this.device.createSampler(sampler);
12287
+ setTextureSampler(this, sampler);
12177
12288
  }
12178
12289
  /**
12179
12290
  * Copy raw image data (bytes) into the texture.
@@ -12481,7 +12592,7 @@ ${declarations.join("\n")}`).match(
12481
12592
  return result;
12482
12593
  }
12483
12594
  static defaultProps = {
12484
- ...Resource.defaultProps,
12595
+ ...DeviceResource.defaultProps,
12485
12596
  data: null,
12486
12597
  dimension: "2d",
12487
12598
  format: "rgba8unorm",
@@ -16551,7 +16662,7 @@ void main(void) {
16551
16662
  };
16552
16663
 
16553
16664
  // src/scenegraph/scenegraph-node.ts
16554
- function assert10(condition, message) {
16665
+ function assert11(condition, message) {
16555
16666
  if (!condition) {
16556
16667
  throw new Error(message);
16557
16668
  }
@@ -16593,17 +16704,17 @@ void main(void) {
16593
16704
  return `{type: ScenegraphNode, id: ${this.id})}`;
16594
16705
  }
16595
16706
  setPosition(position) {
16596
- assert10(position.length === 3, "setPosition requires vector argument");
16707
+ assert11(position.length === 3, "setPosition requires vector argument");
16597
16708
  this.position = position;
16598
16709
  return this;
16599
16710
  }
16600
16711
  setRotation(rotation) {
16601
- assert10(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16712
+ assert11(rotation.length === 3 || rotation.length === 4, "setRotation requires vector argument");
16602
16713
  this.rotation = rotation;
16603
16714
  return this;
16604
16715
  }
16605
16716
  setScale(scale5) {
16606
- assert10(scale5.length === 3, "setScale requires vector argument");
16717
+ assert11(scale5.length === 3, "setScale requires vector argument");
16607
16718
  this.scale = scale5;
16608
16719
  return this;
16609
16720
  }
@@ -17834,7 +17945,7 @@ void main(void) {
17834
17945
  this._observeSource();
17835
17946
  return this._updateTimestamp;
17836
17947
  }
17837
- /** Resource label used by debug output. */
17948
+ /** DeviceResource label used by debug output. */
17838
17949
  get [Symbol.toStringTag]() {
17839
17950
  return "VideoTexture";
17840
17951
  }