@margoengine/html 0.1.0 → 1.0.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.
package/LICENSE CHANGED
@@ -1,201 +1,201 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2026 Scott Campbell
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Scott Campbell
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE CHANGED
@@ -1,4 +1,4 @@
1
- Margo Engine
2
- Copyright 2026 Scott Campbell
3
-
4
- This product includes Margo Engine (https://margoengine.com) by Scott Campbell.
1
+ Margo Engine
2
+ Copyright 2026 Scott Campbell
3
+
4
+ This product includes Margo Engine (https://margoengine.com) by Scott Campbell.
package/README.md CHANGED
@@ -1,88 +1,198 @@
1
- # @margoengine/html
2
-
3
- World-space DOM anchors, CSS3D placement and scene-depth occlusion.
4
-
5
- Import `margoengine/html` from the `margoengine` package, or `@margoengine/html` from this package alone; the two are the same module. Neither is on npm yet: the [Install](../../README.md#install) section lists the two routes that work today (run in a clone, or install local tarballs).
6
-
7
- World-space DOM anchors reuse labels' projection, frustum clipping, inherited visibility and CSS3D placement. 2D anchors additionally use asynchronous scene-depth occlusion.
8
-
9
- ```ts
10
- import {HTML} from 'margoengine/html';
11
- import {Engine} from 'margoengine/core';
12
- import {createMesh} from 'margoengine/materials';
13
- import {box} from 'margoengine/core';
14
- const engine = await Engine.create(document.querySelector('canvas')!);
15
- const mesh = engine.createMesh().setGeometry(box());
16
- const element = document.createElement('div');
17
- const html = HTML.attach(engine);
18
- html.add(element, {mesh, offset: [0,1,0]});
19
- ```
20
-
21
- WebGPU defaults to a shared sampleable depth target, also used by water. Pass depth: () => effect.depthTexture with SSAO/DOF, or depth: false to disable GPU occlusion. On the WebGL2 preview backend (`@margoengine/webgl2-compat/preview`), whose canvas depth cannot be sampled, the same tests run as occlusion queries: after the scene, one point a test is drawn at the anchor with colour and depth writes off inside an `ANY_SAMPLES_PASSED` query, and the result is read when the browser makes it available, a frame or more later. A round of queries is in flight per anchor at a time; `fade` there costs `samples` x `samples` points and queries an anchor, so keep it small (`samples: 2`) with many anchors. Capacity defaults to 1024 anchors, maximum 1,048,576 (`capacity`); storage starts at 64 slots and doubles as anchors are added, and each frame's depth work runs to the highest slot in use, not to the capacity. Depth results arrive asynchronously and stale results after substantial motion are ignored; there can be a frame of visibility latency. depthBias is reversed-Z depth, not world units. CSS3D objects are projected but not sampled for depth. dispose removes the overlay and owned elements.
22
-
23
- ## Smooth partial occlusion
24
-
25
- `fade` fades an anchor as geometry slides over it instead of hiding it at once. Each frame the depth pass tests an `samples` x `samples` grid over a square `radius` CSS pixels around the anchor (4 x 4 over 8 px by default) and the element's `style.opacity` moves toward the share of tests the scene leaves clear, at most from 1 to 0 in `duration` seconds (default 0.15; 0 follows each result at once). At opacity 0 the element is hidden (`display: none`); at 1 its inline opacity is removed again. Both backends; style the element's own opacity on a child, since fade writes the element's.
26
-
27
- ```ts
28
- import {HTML} from 'margoengine/html';
29
- import {Engine, box} from 'margoengine/core';
30
- const engine = await Engine.create(document.querySelector('canvas')!);
31
- engine.createMesh().setGeometry(box());
32
- const html = HTML.attach(engine, {fade: {radius: 8, samples: 4, duration: 0.15}});
33
- const tip = document.createElement('div');
34
- tip.textContent = 'Behind the box';
35
- html.add(tip, {position: [0.6, 0, -1]});
36
- ```
37
-
38
- Results arrive a frame or two late, like the hard test's. A result taken before the anchor moved more than `radius` (at least 4) CSS pixels is not applied and the anchor's target opacity goes back to 1, as a moving anchor is never hidden by where it was.
39
-
40
- ## DOM drawn into the scene
41
-
42
- `margoengine/html/texture` (`@margoengine/html/texture`) draws HTML elements as textures on quads in the scene. A quad is depth-tested and writes depth like scene geometry, so a mesh in front of it hides its part, and the page's pointer reaches the element where it hits the quad: hover, focus, clicks and typing go to the element itself, through the browser's own hit test. WebGPU only.
43
-
44
- ```ts
45
- import {HTMLTexture} from 'margoengine/html/texture';
46
- import {Engine} from 'margoengine/core';
47
- const engine = await Engine.create(document.querySelector('canvas')!);
48
- const panel = document.createElement('div');
49
- panel.style.cssText = 'width:200px;height:100px;background:#0af';
50
- const button = document.createElement('button');
51
- button.textContent = 'Press';
52
- button.addEventListener('click', () => (button.textContent = 'Pressed'));
53
- panel.append(button);
54
- const textures = HTMLTexture.attach(engine);
55
- // 2 x 1 world units at the origin, facing +Z; pass {mesh} to follow a mesh, or {matrix} for any pose.
56
- const surface = textures.add(panel, {width: 2, height: 1});
57
- ```
58
-
59
- `add` moves the element into an invisible holder at the top left of the page (opacity 0, no pointer events), where it keeps its layout, focus and events. The size defaults to the element's CSS size at 100 CSS pixels a world unit, the texture to `devicePixelRatio` texture pixels a CSS pixel (`pixelRatio`, 0.25 to 4). Two rasterizers draw the element: `'element-image'`, the HTML-in-canvas `drawElementImage` where the browser has it (the default there), and `'foreign-object'`, the element's tree with its computed styles inlined into an SVG `foreignObject` image, everywhere else. The texture is drawn again when the element changes (a mutation, input, focus or hover, or an HTML-in-canvas paint event); call `surface.invalidate()` after a change none of these shows, such as a loaded font. While the pointer is over a quad, the holder moves so that the element's point under the pointer is the hit point on the quad; off every quad it moves back out of the way. A raster that fails (a `prepare` that rejects, a tainting or broken image) reaches `engine.onError` as a `MargoError` with code `failed` and the original error as `cause`; the surface keeps its last texture until `surface.invalidate()` draws it again.
60
-
61
- With `'foreign-object'`, fonts and images the element uses must be same-origin data the SVG image can embed (data URLs); the browser loads nothing from inside it. Scene geometry in front of a quad hides it on screen but does not stop the pointer reaching the element. On a linear HDR target (rgba16float, as post-processing uses) the element's sRGB colour is decoded to linear light (the CSS Color 4 sRGB curve), as `ColorBackground` does, so the post chain's tone map and encode apply to it like any unlit surface; on a display target the bytes are drawn as they are. Pointer routing maps the whole canvas: with a view rectangle or several views it does not follow the view's camera. `textures.dispose()` removes the holders and the elements in them.
62
-
63
- ## Many anchors
64
-
65
- One overlay takes up to 1,048,576 anchors. Its point, result and readback buffers start at 64 slots and double as anchors are added (re-made at the next depth test, never while a read is in flight), a removed anchor's slot is taken again first, and the per-frame depth work, WebGL2 queries included, runs to the highest slot in use.
66
-
67
- ```ts
68
- import {HTML} from 'margoengine/html';
69
- import {Engine} from 'margoengine/core';
70
- const engine = await Engine.create(document.querySelector('canvas')!);
71
- // 10,000 map pins in one overlay: past the old 4,096 limit.
72
- const pins = HTML.attach(engine, {capacity: 10_000});
73
- for (let i = 0; i < 10_000; i++) {
74
- const pin = document.createElement('div');
75
- pin.textContent = String(i);
76
- pins.add(pin, {position: [(i % 100) - 50, 0, Math.floor(i / 100) - 50]});
77
- }
78
- ```
79
-
80
- Apache-2.0. Optional, tree-shakable package; core peer: ^0.1.0 || ^1.0.0.
81
-
82
- Build and unit tests: npm test --workspace @margoengine/html
83
-
84
- ## Preview tier contract
85
-
86
- GPU-only attachments refuse the small WebGL2 preview during setup with `MargoError` code `unsupported` and a help link. Native WebGPU and the full WebGL2 compatibility layer expose the WebGPU-shaped device these passes need. Use [automatic escalation](../webgl2-compat/README.md#automatic-escalation) with awaited setup to load the full layer when required. Existing real preview routes remain available.
87
-
88
- `HTMLBlend`, `HTMLTextureGL` and `HTMLTexture` are reviewed preview routes in `scripts/check-preview-contract.mjs` (2026-11-10): each has one `backend` test and real drawing on the small preview. `HTMLBlend` punches its mask with WebGL2 on the preview and with WebGPU elsewhere; `HTMLTextureGL` draws textured quads with WebGL2 on the preview; plain `HTMLTexture` refuses the preview (`unsupported`) and draws only through its `HTMLTextureGL` subclass there. Pixel evidence for both backends is `test/html-browser.js` (`npm run test:browser`, also with `MARGO_COMPAT=1`); the plain refusal is in `test/texture.test.js`. No behaviour changed; the routes were added after `4e3337946` first broke `npm run verify`.
1
+ # @margoengine/html
2
+
3
+ World-space DOM anchors, CSS3D placement and scene-depth occlusion.
4
+
5
+ Import `margoengine/html` from the `margoengine` package, or `@margoengine/html` from this package alone; the two are the same module. Neither is on npm yet: the [Install](../../README.md#install) section lists the two routes that work today (run in a clone, or install local tarballs).
6
+
7
+ World-space DOM anchors reuse labels' projection, frustum clipping, inherited visibility and CSS3D placement. 2D anchors additionally use asynchronous scene-depth occlusion.
8
+
9
+ ```ts
10
+ import {HTML} from 'margoengine/html';
11
+ import {Engine} from 'margoengine/core';
12
+ import {createMesh} from 'margoengine/materials';
13
+ import {box} from 'margoengine/core';
14
+ const engine = await Engine.create(document.querySelector('canvas')!);
15
+ const mesh = engine.createMesh().setGeometry(box());
16
+ const element = document.createElement('div');
17
+ const html = HTML.attach(engine);
18
+ html.add(element, {mesh, offset: [0,1,0]});
19
+ ```
20
+
21
+ WebGPU defaults to a shared sampleable depth target, also used by water. Pass depth: () => effect.depthTexture with SSAO/DOF, or depth: false to disable GPU occlusion. On the WebGL2 preview backend (`@margoengine/webgl2-compat/preview`), whose canvas depth cannot be sampled, the same tests run as occlusion queries: after the scene, one point a test is drawn at the anchor with colour and depth writes off inside an `ANY_SAMPLES_PASSED` query, and the result is read when the browser makes it available, a frame or more later. A round of queries is in flight per anchor at a time; `fade` there costs `samples` x `samples` points and queries an anchor, so keep it small (`samples: 2`) with many anchors. Capacity defaults to 1024 anchors, maximum 1,048,576 (`capacity`); storage starts at 64 slots and doubles as anchors are added, and each frame's depth work runs to the highest slot in use, not to the capacity. Depth results arrive asynchronously and stale results after substantial motion are ignored; there can be a frame of visibility latency. depthBias is reversed-Z depth, not world units. CSS3D objects are projected but not sampled for depth. dispose removes the overlay and owned elements.
22
+
23
+ ## Smooth partial occlusion
24
+
25
+ `fade` fades an anchor as geometry slides over it instead of hiding it at once. Each frame the depth pass tests an `samples` x `samples` grid over a square `radius` CSS pixels around the anchor (4 x 4 over 8 px by default) and the element's `style.opacity` moves toward the share of tests the scene leaves clear, at most from 1 to 0 in `duration` seconds (default 0.15; 0 follows each result at once). At opacity 0 the element is hidden (`display: none`); at 1 its inline opacity is removed again. Both backends; style the element's own opacity on a child, since fade writes the element's.
26
+
27
+ ```ts
28
+ import {HTML} from 'margoengine/html';
29
+ import {Engine, box} from 'margoengine/core';
30
+ const engine = await Engine.create(document.querySelector('canvas')!);
31
+ engine.createMesh().setGeometry(box());
32
+ const html = HTML.attach(engine, {fade: {radius: 8, samples: 4, duration: 0.15}});
33
+ const tip = document.createElement('div');
34
+ tip.textContent = 'Behind the box';
35
+ html.add(tip, {position: [0.6, 0, -1]});
36
+ ```
37
+
38
+ Results arrive a frame or two late, like the hard test's. A result taken before the anchor moved more than `radius` (at least 4) CSS pixels is not applied and the anchor's target opacity goes back to 1, as a moving anchor is never hidden by where it was.
39
+
40
+ ## DOM drawn into the scene
41
+
42
+ `margoengine/html/texture` (`@margoengine/html/texture`) draws HTML elements as textures on quads in the scene. A quad is depth-tested and writes depth like scene geometry, so a mesh in front of it hides its part, and the page's pointer reaches the element where it hits the quad: hover, focus, clicks and typing go to the element itself, through the browser's own hit test. WebGPU only.
43
+
44
+ ```ts
45
+ import {HTMLTexture} from 'margoengine/html/texture';
46
+ import {Engine} from 'margoengine/core';
47
+ const engine = await Engine.create(document.querySelector('canvas')!);
48
+ const panel = document.createElement('div');
49
+ panel.style.cssText = 'width:200px;height:100px;background:#0af';
50
+ const button = document.createElement('button');
51
+ button.textContent = 'Press';
52
+ button.addEventListener('click', () => (button.textContent = 'Pressed'));
53
+ panel.append(button);
54
+ const textures = HTMLTexture.attach(engine);
55
+ // 2 x 1 world units at the origin, facing +Z; pass {mesh} to follow a mesh, or {matrix} for any pose.
56
+ const surface = textures.add(panel, {width: 2, height: 1});
57
+ ```
58
+
59
+ `add` moves the element into an invisible holder at the top left of the page (opacity 0, no pointer events), where it keeps its layout, focus and events. The size defaults to the element's CSS size at 100 CSS pixels a world unit, the texture to `devicePixelRatio` texture pixels a CSS pixel (`pixelRatio`, 0.25 to 4). Two rasterizers draw the element: `'element-image'`, the HTML-in-canvas `drawElementImage` where the browser has it (the default there), and `'foreign-object'`, the element's tree with its computed styles inlined into an SVG `foreignObject` image, everywhere else. The texture is drawn again when the element changes (a mutation, input, focus or hover, or an HTML-in-canvas paint event); call `surface.invalidate()` after a change none of these shows, such as a loaded font. While the pointer is over a quad, the holder moves so that the element's point under the pointer is the hit point on the quad; off every quad it moves back out of the way. A raster that fails (a `prepare` that rejects, a tainting or broken image) reaches `engine.onError` as a `MargoError` with code `failed` and the original error as `cause`; the surface keeps its last texture until `surface.invalidate()` draws it again.
60
+
61
+ With `'foreign-object'`, fonts and images the element uses must be same-origin data the SVG image can embed (data URLs); the browser loads nothing from inside it. Scene geometry in front of a quad hides it on screen but does not stop the pointer reaching the element. On a linear HDR target (rgba16float, as post-processing uses) the element's sRGB colour is decoded to linear light (the CSS Color 4 sRGB curve), as `ColorBackground` does, so the post chain's tone map and encode apply to it like any unlit surface; on a display target the bytes are drawn as they are. Pointer routing maps the whole canvas: with a view rectangle or several views it does not follow the view's camera. `textures.dispose()` removes the holders and the elements in them.
62
+
63
+ ## DOM textures on the WebGL2 preview (`@margoengine/html/texture-gl`)
64
+
65
+ `margoengine/html/texture-gl` (`@margoengine/html/texture-gl`) is `HTMLTexture` with a WebGL2 route, so the same panels
66
+ draw on the small WebGL2 preview (`@margoengine/webgl2-compat/preview`) as on WebGPU and the full compatibility layer.
67
+ Options, rasterizers, `prepare`, pointer routing and errors are `HTMLTexture`'s; only the draw differs.
68
+
69
+ ```ts
70
+ import {HTMLTextureGL} from 'margoengine/html/texture-gl';
71
+ import {Engine} from 'margoengine/core';
72
+ import {webglRenderer} from 'margoengine/webgl2-compat/preview';
73
+ // WebGPU where the browser has it, the WebGL2 preview where it does not; the panel draws on both.
74
+ const engine = await Engine.create(document.querySelector('canvas')!, {backend: 'auto', fallback: webglRenderer});
75
+ const panel = document.createElement('div');
76
+ panel.style.cssText = 'width:200px;height:100px;background:#fa0';
77
+ panel.textContent = 'Hello';
78
+ const textures = HTMLTextureGL.attach(engine);
79
+ const surface = textures.add(panel, {width: 2, height: 1});
80
+ ```
81
+
82
+ - On WebGPU and the full layer the `HTMLTexture` pass draws and the WebGL2 route does nothing. On the preview a WebGL2
83
+ pass after the scene draws each quad into the frame's view viewport, depth-tested against the canvas depth
84
+ (`LESS`, depth writes on, so later overlays see it), blended premultiplied over (`ONE`, `ONE_MINUS_SRC_ALPHA`), with
85
+ texels under 0.4 percent alpha discarded. The preview draws to the display, so the element's bytes are drawn as they
86
+ are.
87
+ - Both rasterizers are shared: `'element-image'` where the browser has HTML-in-canvas, `'foreign-object'` elsewhere.
88
+ Each surface uploads its raster once per redraw to a texture of its own (RGBA8, premultiplied on upload, linear
89
+ filtering, clamped edges); the GL unpack settings and bindings the upload touches are put back after it.
90
+ - Pointer input is `HTMLTexture`'s: the page's own hit test reaches the element through the quad under the pointer.
91
+ - `textures.remove(surface)` deletes that surface's texture. `textures.dispose()` deletes every texture, the program
92
+ and the vertex array, then removes the holders and their elements. While the context is lost an upload is skipped
93
+ and the surface is drawn again later; after a restore the GL objects are made again on the next frame.
94
+
95
+ ## CSS3D panels behind the scene (`@margoengine/html/blend`)
96
+
97
+ `margoengine/html/blend` (`@margoengine/html/blend`) places real DOM elements in the scene and lets the scene hide them.
98
+ `HTMLBlend` puts CSS3D panels (as `@margoengine/labels` places them) under the canvas and, each frame, cuts a
99
+ depth-tested window in the canvas for each one: where scene geometry is in front of a panel the scene draws, and where
100
+ the panel is in front the canvas is clear and the page shows the element itself, live and interactive (a form, a video,
101
+ an iframe).
102
+
103
+ ```ts
104
+ import {HTMLBlend} from 'margoengine/html/blend';
105
+ import {Engine, box} from 'margoengine/core';
106
+ const engine = await Engine.create(document.querySelector('canvas')!);
107
+ engine.createMesh().setGeometry(box()); // in front of the panel's middle, so it hides that part
108
+ const blend = HTMLBlend.attach(engine);
109
+ const form = document.createElement('div');
110
+ form.style.cssText = 'width:300px;height:200px;background:#fff';
111
+ form.innerHTML = '<input placeholder="Type here">';
112
+ const panel = blend.add3D(form, {position: [0, 0, -2]}); // 300 x 200 CSS px at 0.01 world units a pixel
113
+ ```
114
+
115
+ - The window is the panel's rectangle (its CSS size times `pixelScale`, at the panel's matrix) drawn in transparent
116
+ black with a `less` depth test and depth writes, after the scene. On WebGPU the canvas is configured with
117
+ `alphaMode: 'premultiplied'`. Panels are rectangles: a transparent part of an element shows the page behind the
118
+ canvas, not the scene.
119
+ - Canvas alpha: the small preview must be created with `webglRenderer(canvas, {transparent: true})`. Without alpha,
120
+ `attach` throws a `MargoError` with code `'unsupported'`. WebGPU and the full compatibility layer need nothing.
121
+ - Input: the canvas gets `z-index: 1` and `pointer-events: none` (and `position: relative` when it had none), so the
122
+ panels under it (overlay `zIndex` 0) take the pointer; `add3D` defaults `pointerEvents` to `'auto'`.
123
+ - Several `HTMLBlend`s on one canvas share it: the first saves the canvas's `position`, `z-index`, `pointer-events`
124
+ and alpha mode, and the last one disposed puts them back.
125
+ - `view` (a labels `LabelView`) places panels and windows with that view's camera (the engine camera when it has none)
126
+ in its rectangle: `viewport` as fractions of the canvas, or canvas pixels with `pixels: true`, scaled to the
127
+ render target when that is not the canvas size. The viewport keeps fractional edges and the scissor rounds outward
128
+ to whole pixels, on WebGPU and on the preview, where the GL viewport, scissor and state are put back after the
129
+ pass. Without `view` the windows follow the frame's own view rectangle and camera.
130
+ - `remove(panel)` frees its window's buffer. After a device restore pipelines and buffers are made again and the
131
+ premultiplied alpha mode is applied to the new canvas context. `dispose()` (or `using`) is final: `add3D` or a new
132
+ `attach` of that instance then throws a `MargoError` with code `'disposed'`.
133
+
134
+ ## Self-contained snapshots for `'foreign-object'` (`@margoengine/html/inline`)
135
+
136
+ An SVG `foreignObject` image loads nothing, so with the `'foreign-object'` rasterizer an element's images and web fonts
137
+ are missing unless they are data URLs. `margoengine/html/inline` (`@margoengine/html/inline`) fetches them for you:
138
+ `inlineResources(element, options)` returns a detached copy of the element with every image and used font embedded,
139
+ and `resourceInliner(options)` is the same as `HTMLTexture`'s `prepare` hook, run before each raster.
140
+
141
+ ```ts
142
+ import {HTMLTexture} from 'margoengine/html/texture';
143
+ import {inlineResources, resourceInliner} from 'margoengine/html/inline';
144
+ import {Engine} from 'margoengine/core';
145
+ const engine = await Engine.create(document.querySelector('canvas')!);
146
+ const art = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><circle cx="32" cy="32" r="30" fill="#0af"/></svg>';
147
+ const card = document.createElement('div');
148
+ card.style.cssText = 'width:200px;height:100px;background:#fff';
149
+ card.innerHTML = `<img src="${URL.createObjectURL(new Blob([art], {type: 'image/svg+xml'}))}" width="64" height="64">`;
150
+ document.body.append(card);
151
+
152
+ const copy = await inlineResources(card, {timeout: 5000}); // the live card is not changed
153
+ console.log(copy.querySelector('img')!.getAttribute('src')!.startsWith('data:image/svg+xml')); // true
154
+
155
+ const textures = HTMLTexture.attach(engine, {rasterizer: 'foreign-object', prepare: resourceInliner({timeout: 5000})});
156
+ textures.add(card, {width: 2, height: 1});
157
+ ```
158
+
159
+ - Embedded: `<img>` (its current source; `srcset` and `sizes` are dropped), `<input type="image">`, SVG `<image>`
160
+ `href`, every `url(...)` in the copy's inline styles (the copy already carries the computed styles), and the
161
+ `@font-face` rules of the font families the element uses. Those come from the document's style sheets and adopted
162
+ sheets, including `@import`ed sheets, cross-origin sheets (fetched again with CORS) and rules inside `@media` and
163
+ other grouping rules. The copy's own `<style>` and style sheet links are removed. Data URLs and `#fragment`
164
+ references stay as they are.
165
+ - Each address is fetched once per call with `mode: 'cors'` and same-origin credentials. A failed or refused fetch
166
+ throws a `MargoError` with code `'failed'` that names the address: serve it same-origin or with CORS headers.
167
+ - `timeout` bounds the whole snapshot, in whole milliseconds from 1 to 2147483647 (default 15000; `RangeError`
168
+ otherwise). `signal` cancels it. Through `resourceInliner` the surface's own signal joins yours, so removing the
169
+ surface cancels its fetches.
170
+ - `fontCSS` replaces the sheet search with `@font-face` CSS you pass, for faces a script made (`new FontFace(...)` in
171
+ `document.fonts` is in no sheet). Its URLs resolve against the element's `baseURI`.
172
+
173
+ ## Many anchors
174
+
175
+ One overlay takes up to 1,048,576 anchors. Its point, result and readback buffers start at 64 slots and double as anchors are added (re-made at the next depth test, never while a read is in flight), a removed anchor's slot is taken again first, and the per-frame depth work, WebGL2 queries included, runs to the highest slot in use.
176
+
177
+ ```ts
178
+ import {HTML} from 'margoengine/html';
179
+ import {Engine} from 'margoengine/core';
180
+ const engine = await Engine.create(document.querySelector('canvas')!);
181
+ // 10,000 map pins in one overlay: past the old 4,096 limit.
182
+ const pins = HTML.attach(engine, {capacity: 10_000});
183
+ for (let i = 0; i < 10_000; i++) {
184
+ const pin = document.createElement('div');
185
+ pin.textContent = String(i);
186
+ pins.add(pin, {position: [(i % 100) - 50, 0, Math.floor(i / 100) - 50]});
187
+ }
188
+ ```
189
+
190
+ Apache-2.0. Optional, tree-shakable package; core peer: ^0.1.0 || ^1.0.0.
191
+
192
+ Build and unit tests: npm test --workspace @margoengine/html
193
+
194
+ ## Preview tier contract
195
+
196
+ GPU-only attachments refuse the small WebGL2 preview during setup with `MargoError` code `unsupported` and a help link. Native WebGPU and the full WebGL2 compatibility layer expose the WebGPU-shaped device these passes need. Use [automatic escalation](../webgl2-compat/README.md#automatic-escalation) with awaited setup to load the full layer when required. Existing real preview routes remain available.
197
+
198
+ `HTMLBlend`, `HTMLTextureGL` and `HTMLTexture` are reviewed preview routes in `scripts/check-preview-contract.mjs` (2026-11-10): each has one `backend` test and real drawing on the small preview. `HTMLBlend` punches its mask with WebGL2 on the preview and with WebGPU elsewhere; `HTMLTextureGL` draws textured quads with WebGL2 on the preview; plain `HTMLTexture` refuses the preview (`unsupported`) and draws only through its `HTMLTextureGL` subclass there. Pixel evidence for both backends is `test/html-browser.js` (`npm run test:browser`, also with `MARGO_COMPAT=1`); the plain refusal is in `test/texture.test.js`. No behaviour changed; the routes were added after `4e3337946` first broke `npm run verify`.
package/dist/blend.js CHANGED
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const a=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const a=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { t as e } from "./errors-fc4i1pSL.js";
5
5
  import { t } from "./view-rect-Be4T67Kk.js";
6
6
  import { t as n } from "./pass-BVRaGB09.js";
@@ -8,7 +8,7 @@ import { n as r, t as i } from "./gl-j8yV2Jj1.js";
8
8
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
9
9
  import { LabelRenderer as o } from "@margoengine/labels";
10
10
  //#region src/blend.ts
11
- var s = "struct Mask {camera:mat4x4f,model:mat4x4f,size:vec4f}\n@group(0) @binding(0) var<uniform> mask:Mask;\n@vertex fn vertex(@builtin(vertex_index) i:u32)->@builtin(position) vec4f {\n let p=array<vec2f,6>(vec2f(-.5,.5),vec2f(.5,.5),vec2f(-.5,-.5),vec2f(-.5,-.5),vec2f(.5,.5),vec2f(.5,-.5))[i];\n return mask.camera*mask.model*vec4f(p*mask.size.xy,0,1);\n}\n@fragment fn fragment()->@location(0) vec4f {return vec4f(0);}", c = "#version 300 es\nuniform mat4 camera,model;uniform vec2 size;\nvoid main(){vec2 p[6]=vec2[6](vec2(-.5,.5),vec2(.5,.5),vec2(-.5,-.5),vec2(-.5,-.5),vec2(.5,.5),vec2(.5,-.5));\ngl_Position=camera*model*vec4(p[gl_VertexID]*size,0,1);}", l = "#version 300 es\nprecision highp float;out vec4 color;void main(){color=vec4(0);}", u = /* @__PURE__ */ new WeakMap(), d = class d extends o {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
11
+ var s = "struct Mask {camera:mat4x4f,model:mat4x4f,size:vec4f}\n@group(0) @binding(0) var<uniform> mask:Mask;\n@vertex fn vertex(@builtin(vertex_index) i:u32)->@builtin(position) vec4f {\n let p=array<vec2f,6>(vec2f(-.5,.5),vec2f(.5,.5),vec2f(-.5,-.5),vec2f(-.5,-.5),vec2f(.5,.5),vec2f(.5,-.5))[i];\n return mask.camera*mask.model*vec4f(p*mask.size.xy,0,1);\n}\n@fragment fn fragment()->@location(0) vec4f {return vec4f(0);}", c = "#version 300 es\nuniform mat4 camera,model;uniform vec2 size;\nvoid main(){vec2 p[6]=vec2[6](vec2(-.5,.5),vec2(.5,.5),vec2(-.5,-.5),vec2(-.5,-.5),vec2(.5,.5),vec2(.5,-.5));\ngl_Position=camera*model*vec4(p[gl_VertexID]*size,0,1);}", l = "#version 300 es\nprecision highp float;out vec4 color;void main(){color=vec4(0);}", u = /* @__PURE__ */ new WeakMap(), d = class d extends o {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
12
12
  constructor(e = {}) {
13
13
  super({
14
14
  ...e,
@@ -21,7 +21,7 @@ var s = "struct Mask {camera:mat4x4f,model:mat4x4f,size:vec4f}\n@group(0) @bindi
21
21
  0
22
22
  ], this.descriptor = n(), this.disposed = !1;
23
23
  }
24
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
24
+ static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
25
25
  let n = new d(t);
26
26
  return a(e).use(n), n;
27
27
  }
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const r=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const r=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { t as e } from "./errors-fc4i1pSL.js";
5
5
  import { n as t, t as n } from "./view-rect-Be4T67Kk.js";
6
6
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
@@ -92,7 +92,29 @@ function m(e, t, n, r, i, a = !1) {
92
92
  }
93
93
  };
94
94
  }
95
- var h = class {
95
+ function h(e, t, r, i, a, o) {
96
+ let s = e.pipelines.get(i);
97
+ s || e.pipelines.set(i, s = /* @__PURE__ */ new Map());
98
+ let c = s.get(a);
99
+ if (!c) {
100
+ let t = e.samples === 1;
101
+ s.set(a, c = m(e.device, e.depthSource, r, i, a, t));
102
+ }
103
+ c.descriptor.depthStencilAttachment.view = r, c.descriptor.depthStencilAttachment.depthLoadOp = o?.view ? "load" : "clear";
104
+ let l = t.beginRenderPass(c.descriptor);
105
+ o && n(l, o);
106
+ let u = c.draws;
107
+ for (let e = 0; e < u.length; e++) l.setPipeline(u[e].pipeline), l.setBindGroup(0, u[e].group), l.draw(3);
108
+ l.end();
109
+ }
110
+ var g = class {
111
+ constructor(e, t, n) {
112
+ this.device = e, this.samples = n, this.pipelines = /* @__PURE__ */ new Map(), this.depthSource = t.createView({ aspect: "depth-only" });
113
+ }
114
+ copy(e, t, n, r) {
115
+ h(this, e.encoder, t, n, r, e);
116
+ }
117
+ }, _ = class {
96
118
  constructor(e, t, n, r = 4) {
97
119
  if (r !== 1 && r !== 4) throw RangeError("Scene samples must be 1 or 4");
98
120
  this.samples = r, this.device = e, this.resolvedColor = t, this.resolvedDepth = n, this.textures = [], this.pipelines = /* @__PURE__ */ new Map();
@@ -134,7 +156,7 @@ var h = class {
134
156
  depth: e.depth,
135
157
  format: e.format,
136
158
  descriptor: e.descriptor,
137
- owner: g(e)
159
+ owner: v(e)
138
160
  }), e.color = this.color, e.depth = this.depth, e.format = this.resolvedColor.format, this.baseDescriptor !== e.descriptor && (this.baseDescriptor = e.descriptor, this.descriptor = {
139
161
  ...e.descriptor,
140
162
  depthStencil: {
@@ -142,41 +164,33 @@ var h = class {
142
164
  format: this.resolvedDepth.format
143
165
  },
144
166
  multisample: { count: this.samples }
145
- }), e.descriptor = this.descriptor, e[f] = this, this.retired = !1;
167
+ }), e.descriptor = this.descriptor, e[f] = this, this.retired = !1, this.resized = e.width !== void 0 && (e.width !== this.resolvedDepth.width || e.height !== this.resolvedDepth.height);
146
168
  }
147
- copyDepth(e, t, r, i = this.resolvedDepth.format) {
148
- let a = this.pipelines.get(r);
149
- a || this.pipelines.set(r, a = /* @__PURE__ */ new Map());
150
- let o = a.get(i);
151
- o || (this.depthSource ??= this.resolvedDepth.createView({ aspect: "depth-only" }), a.set(i, o = m(this.device, this.depthSource, t, r, i, this.samples === 1))), o.descriptor.depthStencilAttachment.view = t, o.descriptor.depthStencilAttachment.depthLoadOp = this.viewContext?.view ? "load" : "clear";
152
- let s = e.beginRenderPass(o.descriptor);
153
- this.viewContext && n(s, this.viewContext);
154
- let c = o.draws;
155
- for (let e = 0; e < c.length; e++) s.setPipeline(c[e].pipeline), s.setBindGroup(0, c[e].group), s.draw(3);
156
- s.end();
169
+ copyDepth(e, t, n, r = this.resolvedDepth.format) {
170
+ this.depthSource ??= this.resolvedDepth.createView({ aspect: "depth-only" }), h(this, e, t, n, r, this.viewContext);
157
171
  }
158
172
  resolve(e, t = !1, n = !0) {
159
- if (this.samples !== 1) {
173
+ if (this.samples === 1) t && this.give(e);
174
+ else {
160
175
  if (n && this.copyDepth(e, this.resolvedDepthView, 1), t) {
161
176
  let t = this.viewContext?.view ? "store" : "discard";
162
- this.finalResolution.colorAttachments[0].storeOp = t, this.finalResolution.depthStencilAttachment.depthStoreOp = t, this.original && this.copyDepth(e, this.original.depth, this.original.descriptor.multisample?.count ?? 1, this.original.descriptor.depthStencil.format), this.retired = !0;
177
+ this.finalResolution.colorAttachments[0].storeOp = t, this.finalResolution.depthStencilAttachment.depthStoreOp = t, this.give(e);
163
178
  }
164
179
  e.beginRenderPass(t ? this.finalResolution : this.resolution).end();
165
180
  }
166
181
  }
182
+ give(e) {
183
+ let t = this.original;
184
+ this.retired || !t || this.resized || (this.copyDepth(e, t.depth, t.descriptor.multisample?.count ?? 1, t.descriptor.depthStencil.format), this.retired = !0);
185
+ }
167
186
  restore(e) {
168
187
  let t = this.original;
169
- this.samples === 1 ? (Object.assign(e, {
188
+ this.give(e.encoder), Object.assign(e, {
170
189
  color: t.color,
171
190
  depth: t.depth,
172
191
  format: t.format,
173
192
  descriptor: t.descriptor
174
- }), e[f] = t.owner) : (this.retired || this.copyDepth(e.encoder, t.depth, t.descriptor.multisample?.count ?? 1, t.descriptor.depthStencil.format), Object.assign(e, {
175
- color: t.color,
176
- depth: t.depth,
177
- format: t.format,
178
- descriptor: t.descriptor
179
- }), e[f] = t.owner);
193
+ }), e[f] = t.owner;
180
194
  }
181
195
  present(e) {
182
196
  this.resolve(e.encoder, !0), this.restore(e);
@@ -211,16 +225,16 @@ var h = class {
211
225
  this.textures = [], this.pipelines.clear();
212
226
  }
213
227
  };
214
- function g(e) {
228
+ function v(e) {
215
229
  let t = e[f];
216
230
  return t?.color === e.color && t.depth === e.depth ? t : void 0;
217
231
  }
218
- function _(e) {
219
- g(e)?.resolve(e.encoder);
232
+ function y(e) {
233
+ v(e)?.resolve(e.encoder);
220
234
  }
221
235
  //#endregion
222
236
  //#region ../shared/gpu.js
223
- function v(e, t, n) {
237
+ function b(e, t, n) {
224
238
  return e.createBindGroup({
225
239
  layout: t.getBindGroupLayout(0),
226
240
  entries: n.map((e, t) => ({
@@ -229,7 +243,7 @@ function v(e, t, n) {
229
243
  }))
230
244
  });
231
245
  }
232
- function y(e, t, n = "main") {
246
+ function x(e, t, n = "main") {
233
247
  return e.createComputePipeline({
234
248
  layout: "auto",
235
249
  compute: {
@@ -238,15 +252,14 @@ function y(e, t, n = "main") {
238
252
  }
239
253
  });
240
254
  }
241
- function b(e, t, n, r, i = 1) {
255
+ function S(e, t, n, r, i = 1) {
242
256
  let a = e.encoder.beginComputePass();
243
257
  a.setPipeline(t), a.setBindGroup(0, n), a.dispatchWorkgroups(r, i), a.end();
244
258
  }
245
- function x(t) {
259
+ function C(t) {
246
260
  if (!t.gpu) throw e("unsupported", "Scene depth requires WebGPU; see https://margoengine.com/errors#webgpu");
247
- if (t.hasPlugin("ssao") || t.hasPlugin("dof")) throw e("state", "Another effect owns scene capture; use its depth texture");
248
261
  let n = t.plugins.get("optional:scene-depth");
249
- n || (n = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
262
+ n || (n = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
250
263
  name: "optional:scene-depth",
251
264
  references: 0,
252
265
  texture: void 0,
@@ -254,51 +267,53 @@ function x(t) {
254
267
  target: void 0,
255
268
  borrowed: !1,
256
269
  setup() {},
257
- registerPasses(n) {
258
- n.add({
270
+ registerPasses(e) {
271
+ e.add({
259
272
  name: this.name + ":capture",
260
273
  order: -15,
261
- execute: (n) => {
262
- if (n.backend !== "webgpu") return;
263
- if (t.hasPlugin("ssao") || t.hasPlugin("dof")) throw e("state", "Another effect owns scene capture; use its depth texture");
264
- let r = g(n);
265
- if (this.borrowed = !!r, r) {
266
- this.borrowedDepth = r.resolvedDepth;
274
+ execute: (e) => {
275
+ if (e.backend !== "webgpu") return;
276
+ let t = v(e);
277
+ if (this.borrowed = !!t, t) {
278
+ this.borrowedDepth = t.resolvedDepth;
267
279
  return;
268
280
  }
269
- let i = n.descriptor.multisample?.count ?? 4;
281
+ let n = e.descriptor.multisample?.count ?? 4;
270
282
  try {
271
- if (i === 1) {
272
- (!this.depthView || this.texture?.width !== n.width || this.texture?.height !== n.height || this.texture?.format !== n.descriptor.depthStencil.format) && (this.onDeviceRestored(), this.texture = n.device.createTexture({
273
- size: [n.width, n.height],
274
- format: n.descriptor.depthStencil.format,
283
+ if (n === 1) {
284
+ (!this.depthView || this.texture?.width !== e.width || this.texture?.height !== e.height || this.texture?.format !== e.descriptor.depthStencil.format) && (this.onDeviceRestored(), this.texture = e.device.createTexture({
285
+ size: [e.width, e.height],
286
+ format: e.descriptor.depthStencil.format,
275
287
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
276
- }), this.depthView = this.texture.createView()), n.depth = this.depthView;
288
+ }), this.depthView = this.texture.createView()), this.outer = e.depth, e.depth = this.depthView;
277
289
  return;
278
290
  }
279
- (this.target?.samples !== i || this.texture?.width !== n.width || this.texture?.height !== n.height || this.texture?.format !== n.descriptor.depthStencil.format || this.color?.format !== n.format) && (this.onDeviceRestored(), this.texture = n.device.createTexture({
280
- size: [n.width, n.height],
281
- format: n.descriptor.depthStencil.format,
291
+ (this.target?.samples !== n || this.texture?.width !== e.width || this.texture?.height !== e.height || this.texture?.format !== e.descriptor.depthStencil.format || this.color?.format !== e.format) && (this.onDeviceRestored(), this.texture = e.device.createTexture({
292
+ size: [e.width, e.height],
293
+ format: e.descriptor.depthStencil.format,
282
294
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
283
- }), this.color = n.device.createTexture({
284
- size: [n.width, n.height],
285
- format: n.format,
295
+ }), this.color = e.device.createTexture({
296
+ size: [e.width, e.height],
297
+ format: e.format,
286
298
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
287
- }), this.target = new h(n.device, this.color, this.texture, i)), this.target.begin(n);
299
+ }), this.target = new _(e.device, this.color, this.texture, n)), this.target.begin(e);
288
300
  } catch (e) {
289
301
  throw this.onDeviceRestored(), e;
290
302
  }
291
303
  }
292
- }), n.add({
304
+ }), e.add({
293
305
  name: this.name + ":restore",
294
306
  order: 1e4,
295
307
  execute: (e) => {
296
- e.backend === "webgpu" && !this.borrowed && e.descriptor.multisample?.count !== 1 && this.target.present(e);
308
+ if (!(e.backend !== "webgpu" || this.borrowed)) {
309
+ if (e.descriptor.multisample?.count !== 1) return this.target.present(e);
310
+ this.outer &&= (this.copier ??= new g(e.device, this.texture, 1), this.copier.copy(e, this.outer, 1, e.descriptor.depthStencil.format), e.depth = this.outer, void 0);
311
+ }
297
312
  }
298
313
  });
299
314
  },
300
315
  onDeviceRestored() {
301
- this.target?.dispose(), this.texture?.destroy(), this.color?.destroy(), this.target = this.texture = this.color = this.depthView = void 0;
316
+ this.target?.dispose(), this.texture?.destroy(), this.color?.destroy(), this.target = this.texture = this.color = this.depthView = this.copier = this.outer = void 0;
302
317
  },
303
318
  dispose() {
304
319
  this.onDeviceRestored();
@@ -314,7 +329,7 @@ function x(t) {
314
329
  }
315
330
  //#endregion
316
331
  //#region src/index.ts
317
- var S = "\n@group(0) @binding(0) var depth:texture_depth_2d;\n@group(0) @binding(1) var<storage,read> points:array<vec4f>;\n@group(0) @binding(2) var<storage,read_write> output:array<u32>;\n@compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id:vec3u){\n if(id.x>=arrayLength(&points)){return;}let point=points[id.x];let p=vec2i(point.xy);let size=vec2i(textureDimensions(depth));\n output[id.x]=0u;if(any(p<vec2i(0))||any(p>=size)){return;}\n let d=textureLoad(depth,p,0);output[id.x]=select(0u,1u,d>point.z+point.w);\n}", C = (e) => `
332
+ var w = "\n@group(0) @binding(0) var depth:texture_depth_2d;\n@group(0) @binding(1) var<storage,read> points:array<vec4f>;\n@group(0) @binding(2) var<storage,read_write> output:array<u32>;\n@compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id:vec3u){\n if(id.x>=arrayLength(&points)){return;}let point=points[id.x];let p=vec2i(point.xy);let size=vec2i(textureDimensions(depth));\n output[id.x]=0u;if(any(p<vec2i(0))||any(p>=size)){return;}\n let d=textureLoad(depth,p,0);output[id.x]=select(0u,1u,d>point.z+point.w);\n}", T = (e) => `
318
333
  @group(0) @binding(0) var depth:texture_depth_2d;
319
334
  @group(0) @binding(1) var<storage,read> points:array<vec4f>;
320
335
  @group(0) @binding(2) var<storage,read_write> output:array<u32>;
@@ -327,7 +342,7 @@ var S = "\n@group(0) @binding(0) var depth:texture_depth_2d;\n@group(0) @binding
327
342
  }}
328
343
  output[id.x]=covered;
329
344
  }`;
330
- function w(e) {
345
+ function E(e) {
331
346
  if (e === void 0 || e === !1) return;
332
347
  let t = e === !0 ? {} : e;
333
348
  if (typeof t != "object" || !t) throw RangeError("Invalid HTML fade options; pass fade: true or an object of radius, samples and duration");
@@ -339,10 +354,10 @@ function w(e) {
339
354
  duration: i
340
355
  };
341
356
  }
342
- var T = "#version 300 es\nuniform mat4 camera;uniform vec3 world;uniform vec2 offset;uniform float bias;\nvoid main(){vec4 p=camera*vec4(world,1.0);p.xy+=offset*p.w;p.z-=2.0*bias*p.w;gl_Position=p;gl_PointSize=1.0;}", E = "#version 300 es\nprecision lowp float;out vec4 color;void main(){color=vec4(0.0);}";
343
- function D(t) {
357
+ var D = "#version 300 es\nuniform mat4 camera;uniform vec3 world;uniform vec2 offset;uniform float bias;\nvoid main(){vec4 p=camera*vec4(world,1.0);p.xy+=offset*p.w;p.z-=2.0*bias*p.w;gl_Position=p;gl_PointSize=1.0;}", O = "#version 300 es\nprecision lowp float;out vec4 color;void main(){color=vec4(0.0);}";
358
+ function k(t) {
344
359
  let n = t.createProgram(), r = t.createShader(t.VERTEX_SHADER), i = t.createShader(t.FRAGMENT_SHADER);
345
- if (t.shaderSource(r, T), t.shaderSource(i, E), t.compileShader(r), t.compileShader(i), t.attachShader(n, r), t.attachShader(n, i), t.linkProgram(n), t.deleteShader(r), t.deleteShader(i), !t.getProgramParameter(n, t.LINK_STATUS) && !t.isContextLost()) throw e("failed", `HTML could not build its WebGL2 occlusion shaders (${t.getProgramInfoLog(n)}); pass depth: false to draw without occlusion`);
360
+ if (t.shaderSource(r, D), t.shaderSource(i, O), t.compileShader(r), t.compileShader(i), t.attachShader(n, r), t.attachShader(n, i), t.linkProgram(n), t.deleteShader(r), t.deleteShader(i), !t.getProgramParameter(n, t.LINK_STATUS) && !t.isContextLost()) throw e("failed", `HTML could not build its WebGL2 occlusion shaders (${t.getProgramInfoLog(n)}); pass depth: false to draw without occlusion`);
346
361
  return {
347
362
  gl: t,
348
363
  program: n,
@@ -354,7 +369,7 @@ function D(t) {
354
369
  slots: []
355
370
  };
356
371
  }
357
- var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
372
+ var A = 1048576, j = class t extends i {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
358
373
  constructor(e = {}) {
359
374
  super({
360
375
  ...e,
@@ -362,12 +377,12 @@ var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("
362
377
  order: 1e3
363
378
  }), this.settings = e, this.records = /* @__PURE__ */ new Map(), this.slots = [], this.gpuSlots = 0, this.used = 0, this.free = [], this.pending = !1, this.generation = 0, this.disposed = !1, this.depthRequests = [], this.radiusValues = /* @__PURE__ */ new Float32Array(4), this.delta = 0;
364
379
  let t = e.capacity ?? 1024, n = e.depthBias ?? 1e-4;
365
- if (!Number.isInteger(t) || t < 1 || t > O) throw RangeError("Invalid HTML capacity; pass a whole number of anchors from 1 to 1,048,576");
380
+ if (!Number.isInteger(t) || t < 1 || t > A) throw RangeError("Invalid HTML capacity; pass a whole number of anchors from 1 to 1,048,576");
366
381
  if (!Number.isFinite(n) || n < 0 || n > .05 || e.depth !== void 0 && e.depth !== !1 && typeof e.depth != "function") throw RangeError("Invalid HTML depth options; pass depth: false or a function returning a depth texture, and a finite depthBias");
367
- this.fade = w(e.fade), this.capacity = t, this.allocated = Math.min(t, 64), this.values = new Float32Array(this.allocated * 4);
382
+ this.fade = E(e.fade), this.capacity = t, this.allocated = Math.min(t, 64), this.values = new Float32Array(this.allocated * 4);
368
383
  for (let e = 0; e < this.values.length; e += 4) this.values[e] = this.values[e + 1] = -1;
369
384
  }
370
- static attach(e, n = {}) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
385
+ static attach(e, n = {}) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
371
386
  let i = new t(n);
372
387
  return r(e).use(i), i;
373
388
  }
@@ -426,10 +441,10 @@ var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("
426
441
  }
427
442
  setupGPU() {
428
443
  let e = this.runtime;
429
- e.gpu && this.settings.depth !== !1 && (this.shared = this.settings.depth ? void 0 : this.shared ?? x(e), this.source = this.settings.depth || this.shared.texture, this.buffers(e.gpu), this.fade && (this.radius = e.gpu.createBuffer({
444
+ e.gpu && this.settings.depth !== !1 && (this.shared = this.settings.depth ? void 0 : this.shared ?? C(e), this.source = this.settings.depth || this.shared.texture, this.buffers(e.gpu), this.fade && (this.radius = e.gpu.createBuffer({
430
445
  size: 16,
431
446
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
432
- })), this.pipeline = y(e.gpu, this.fade ? C(this.fade.samples) : S));
447
+ })), this.pipeline = x(e.gpu, this.fade ? T(this.fade.samples) : w));
433
448
  }
434
449
  buffers(e) {
435
450
  this.input?.destroy(), this.output?.destroy(), this.read?.destroy();
@@ -473,7 +488,7 @@ var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("
473
488
  });
474
489
  }
475
490
  sample(t) {
476
- _(t);
491
+ y(t);
477
492
  let n = this.source();
478
493
  if (!n || n.width !== t.width || n.height !== t.height || !n.format.startsWith("depth")) throw e("state", "HTML requires viewport-sized scene depth; pass a depth texture that matches the canvas, or depth: false");
479
494
  if (!this.records.size) return;
@@ -493,9 +508,9 @@ var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("
493
508
  { buffer: this.input },
494
509
  { buffer: this.output }
495
510
  ];
496
- this.radius && e.push({ buffer: this.radius }), this.depthGroup = v(t.device, this.pipeline, e), this.sampledDepth = n;
511
+ this.radius && e.push({ buffer: this.radius }), this.depthGroup = b(t.device, this.pipeline, e), this.sampledDepth = n;
497
512
  }
498
- b(t, this.pipeline, this.depthGroup, Math.ceil(r / 64));
513
+ S(t, this.pipeline, this.depthGroup, Math.ceil(r / 64));
499
514
  let i = this.read, a = this.generation, o = this.depthRequests;
500
515
  for (let e = 0; e < r; e++) {
501
516
  let t = this.slots[e];
@@ -530,7 +545,7 @@ var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("
530
545
  }
531
546
  query(e, t, n) {
532
547
  let r = this.glOcclusion;
533
- r && r.gl !== e && this.releaseGL(), r = this.glOcclusion ??= D(e);
548
+ r && r.gl !== e && this.releaseGL(), r = this.glOcclusion ??= k(e);
534
549
  let i = this.fade, a = i ? i.samples : 1, o = a * a, s = i ? Math.max(4, i.radius) : 4, c = this.runtime?.canvas, l = c ? c.clientWidth || c.width : 1, u = c ? c.clientHeight || c.height : 1, [d, f, p, m] = n ?? [
535
550
  0,
536
551
  0,
@@ -596,4 +611,4 @@ var O = 1048576, k = class t extends i {coreRequirement=__margoCoreRequirement("
596
611
  }
597
612
  };
598
613
  //#endregion
599
- export { k as HTML };
614
+ export { j as HTML };
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const r=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const r=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { n as e } from "./texture-kX-VTlgW.js";
5
5
  import { n as t, t as n } from "./gl-j8yV2Jj1.js";
6
6
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
@@ -9,7 +9,7 @@ var i = "#version 300 es\nuniform mat4 camera,model;uniform vec2 size;out vec2 u
9
9
  constructor(...e) {
10
10
  super(...e), this.preview = !0;
11
11
  }
12
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
12
+ static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
13
13
  let n = new o(t);
14
14
  return r(e).use(n), n;
15
15
  }
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const i=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const i=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { t as e } from "./errors-fc4i1pSL.js";
5
5
  import { t } from "./view-rect-Be4T67Kk.js";
6
6
  import { t as n } from "./pass-BVRaGB09.js";
@@ -102,14 +102,14 @@ var d = class {
102
102
  ]) this.element.removeEventListener(e, this.mark);
103
103
  this.holder.removeEventListener("paint", this.paint), this.owner.rasterizer === "element-image" && this.element.removeAttribute("drawable"), this.painting = void 0, this.holder.remove(), this.texture?.destroy(), this.uniform?.destroy(), this.texture = this.uniform = this.group = void 0;
104
104
  }
105
- }, f = class c {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
105
+ }, f = class c {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
106
106
  constructor(t = {}) {
107
107
  this.surfaces = /* @__PURE__ */ new Set(), this.preview = !1, this.pipelines = /* @__PURE__ */ new Map(), this.disposed = !1, this.hovered = null, this.reversed = !1, this.descriptor = n(), this.values = /* @__PURE__ */ new Float32Array(36), this.pointer = (e) => this.route(e), this.name = t.name ?? "html-texture", this.prepare = t.prepare;
108
108
  let r = typeof CanvasRenderingContext2D < "u" && "drawElementImage" in CanvasRenderingContext2D.prototype;
109
109
  if (this.rasterizer = t.rasterizer ?? (r ? "element-image" : "foreign-object"), this.rasterizer !== "element-image" && this.rasterizer !== "foreign-object") throw RangeError("Invalid HTMLTexture rasterizer; pass 'element-image' or 'foreign-object'");
110
110
  if (this.rasterizer === "element-image" && !r) throw e("unsupported", "This browser has no HTML-in-canvas drawElementImage; use rasterizer: 'foreign-object'");
111
111
  }
112
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
112
+ static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
113
113
  let n = new c(t);
114
114
  return i(e).use(n), n;
115
115
  }
package/package.json CHANGED
@@ -1,66 +1,66 @@
1
- {
2
- "name": "@margoengine/html",
3
- "version": "0.1.0",
4
- "description": "World-space DOM anchors, CSS3D placement and scene-depth occlusion.",
5
- "keywords": [
6
- "margoengine",
7
- "webgpu",
8
- "3d",
9
- "html"
10
- ],
11
- "homepage": "https://margoengine.com",
12
- "bugs": {
13
- "url": "https://github.com/scottcampbelldata/margoengine/issues"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/scottcampbelldata/margoengine.git",
18
- "directory": "packages/html"
19
- },
20
- "license": "Apache-2.0",
21
- "author": "Scott Campbell",
22
- "type": "module",
23
- "sideEffects": false,
24
- "exports": {
25
- ".": {
26
- "types": "./dist/index.d.ts",
27
- "import": "./dist/index.js"
28
- },
29
- "./texture": {
30
- "types": "./dist/texture.d.ts",
31
- "import": "./dist/texture.js"
32
- },
33
- "./texture-gl": {
34
- "types": "./dist/texture-gl.d.ts",
35
- "import": "./dist/texture-gl.js"
36
- },
37
- "./blend": {
38
- "types": "./dist/blend.d.ts",
39
- "import": "./dist/blend.js"
40
- },
41
- "./inline": {
42
- "types": "./dist/inline.d.ts",
43
- "import": "./dist/inline.js"
44
- }
45
- },
46
- "files": [
47
- "dist",
48
- "LICENSE",
49
- "NOTICE"
50
- ],
51
- "publishConfig": {
52
- "access": "public"
53
- },
54
- "dependencies": {
55
- "@margoengine/labels": "^0.1.0"
56
- },
57
- "peerDependencies": {
58
- "@margoengine/core": "^0.1.0"
59
- },
60
- "scripts": {
61
- "build": "node ../../scripts/build-optional.js html",
62
- "test": "npm run build && node --test test/*.test.js",
63
- "test:browser": "npm run build && node scripts/test-browser.js",
64
- "prepack": "npm run build"
65
- }
66
- }
1
+ {
2
+ "name": "@margoengine/html",
3
+ "version": "1.0.0",
4
+ "description": "World-space DOM anchors, CSS3D placement and scene-depth occlusion.",
5
+ "keywords": [
6
+ "margoengine",
7
+ "webgpu",
8
+ "3d",
9
+ "html"
10
+ ],
11
+ "homepage": "https://margoengine.com",
12
+ "bugs": {
13
+ "url": "https://github.com/scottcampbelldata/margoengine/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/scottcampbelldata/margoengine.git",
18
+ "directory": "packages/html"
19
+ },
20
+ "license": "Apache-2.0",
21
+ "author": "Scott Campbell",
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./texture": {
30
+ "types": "./dist/texture.d.ts",
31
+ "import": "./dist/texture.js"
32
+ },
33
+ "./texture-gl": {
34
+ "types": "./dist/texture-gl.d.ts",
35
+ "import": "./dist/texture-gl.js"
36
+ },
37
+ "./blend": {
38
+ "types": "./dist/blend.d.ts",
39
+ "import": "./dist/blend.js"
40
+ },
41
+ "./inline": {
42
+ "types": "./dist/inline.d.ts",
43
+ "import": "./dist/inline.js"
44
+ }
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "LICENSE",
49
+ "NOTICE"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {
55
+ "@margoengine/labels": "^1.0.0"
56
+ },
57
+ "peerDependencies": {
58
+ "@margoengine/core": "^1.0.0"
59
+ },
60
+ "scripts": {
61
+ "build": "node ../../scripts/build-optional.js html",
62
+ "test": "npm run build && node --test test/*.test.js",
63
+ "test:browser": "npm run build && node scripts/test-browser.js",
64
+ "prepack": "npm run build"
65
+ }
66
+ }