@margoengine/viewcube 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,127 +1,131 @@
1
- # @margoengine/viewcube
2
-
3
- Import `margoengine/viewcube` from the `margoengine` package, or `@margoengine/viewcube` 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).
4
-
5
- A CAD orientation cube for Margo Engine: a small cube in a corner of the view that turns with the camera. Click a face,
6
- edge or corner and the camera animates around its target to that view (Top, Front, Right, ..., the twelve edge views
7
- and the eight isometric corners), keeping the distance. With `@margoengine/cameras` it also toggles perspective and
8
- orthographic projection.
9
-
10
- ```ts
11
- import {Engine} from 'margoengine/core';
12
- import {CameraProjection} from 'margoengine/cameras';
13
- import {OrbitControls} from 'margoengine/controls';
14
- import {ViewCube} from 'margoengine/viewcube';
15
- const canvas = document.querySelector('canvas')!;
16
-
17
- const engine = await Engine.create(canvas); // the canvas needs a parent element; the cube is placed in it
18
- const projection = CameraProjection.attach(engine, {mode: 'perspective'});
19
- OrbitControls.attach(engine); // or the stage's CADCameraControls
20
- const cube = ViewCube.attach(engine, {projection}); // omit projection to hide the toggle
21
-
22
- cube.view('top'); // 'top' | 'bottom' | 'front' | 'back' | 'left' | 'right' | 'iso'
23
- cube.view([1, 1, 0]); // any direction from the target toward the camera
24
- cube.view('front', 0); // jump without animating
25
- cube.setProjection('orthographic');
26
- cube.setTheme('dark'); // 'light' | 'dark' | 'high-contrast' | 'auto' | your own tokens
27
- cube.drag = false; // dragging the cube orbits the camera unless turned off
28
- cube.setHome({position: [6, 4, 8], target: [0, 1, 0]}); // your own home view; shows the home button
29
- cube.home(); // the home button and the Home key do the same
30
- cube.roll(1); // a quarter turn counter-clockwise about the view axis (-1 clockwise)
31
- cube.dispose(); // engine.dispose() also disposes it
32
- ```
33
-
34
- For less than a cube, `margoengine/viewcube/axes` (`@margoengine/viewcube/axes`) has an axis triad: X, Y and Z
35
- balls on sticks and a smaller ball at each negative end, turning with the camera.
36
-
37
- ```ts
38
- import {Engine} from 'margoengine/core';
39
- import {AxisTriad} from 'margoengine/viewcube/axes';
40
- const canvas = document.querySelector('canvas')!;
41
-
42
- const engine = await Engine.create(canvas);
43
- const triad = AxisTriad.attach(engine, {corner: 'bottom-left', home: true}); // every ViewCube option works
44
- triad.view('right'); // a ViewCube in every other way
45
- ```
46
-
47
- Options: `container` (default: the canvas's parent; made `position: relative` if it is static), `corner`
48
- (`'top-right'` default, `'top-left'`, `'bottom-right'`, `'bottom-left'`), `size` (cube edge in CSS pixels, 80),
49
- `duration` (seconds, 0.4), `projection` (a CameraProjection, or anything with `mode`), `labels` (face names, for
50
- translation), `flip` (false; also a public field: clicking the view already shown turns to the opposite one, as
51
- Blender's navigation gizmo and SolidWorks' "Normal To" pressed twice do; Autodesk's ViewCube keeps the view),
52
- `drag` (true; also a public field: dragging the cube orbits the camera), `home` (none; a `{position, target}`, or
53
- `true` for the camera as it is when the cube attaches: shows the home button), `roll` (false; shows the two roll
54
- buttons), `theme` (none: the light colours; see Themes).
55
- `@margoengine/controls` navigation profiles carry it: `ViewCube.attach(engine, {...BLENDER.viewCube})`. The toggle
56
- also follows projection changes made elsewhere (Blender's numpad 5 through a profile) on the next frame.
57
- `cube.element` is the widget root for your own styling.
58
-
59
- - **Orientation.** World Y is up, front is +Z, right is +X (glTF and Blender exports). Top shows X right and -Z up,
60
- bottom X right and +Z up, from whichever side the camera comes, because the animation interpolates azimuth and
61
- elevation the way OrbitControls moves. Top and bottom are exactly vertical: on the pole the cube sets `camera.up` to
62
- the screen up of the way it came (arrow keys turn it there) and puts the previous up back as soon as the camera
63
- leaves the pole, or on `dispose` (then 1e-6 rad off the pole, same image). An up it did not set is left alone, such as
64
- a CameraProjection's vertical `up`, until a drag on the cube or its compass turns the heading on the pole: then the
65
- cube turns the projection's `up` with it, so the image spins, and the projection keeps that up. OrbitControls and CADCameraControls leave an exact pole at azimuth 0, so after a
66
- top view reached from the side they start from the front.
67
- - **Drag to orbit.** Press on the cube and drag: the camera orbits its target at the same distance, with the
68
- azimuth and elevation OrbitControls uses, so the cube's surface follows the pointer (half the cube's width is one
69
- radian). Dragging right turns the front to the right; dragging down tips the top toward you and stops on the pole
70
- in a standard top view. A press that moves under 3 pixels is still a click on the face, edge or corner, and the
71
- click that ends a drag does nothing. The cube keeps the pointer while dragging, a drag cancels a view animation,
72
- and only the primary button drags (`touch-action: none` on the widget, so a touch drag does not scroll the page).
73
- - **Home view.** `home` or `cube.setHome(view)` sets the app's own home: a camera position and the target it looks
74
- at (`cube.setHome()` takes the camera as it is now). A round home button appears above the cube's top-left corner;
75
- it and the Home key animate the camera there, moving the target and the distance too, and land on them exactly.
76
- A vertical home is exactly vertical with the standard top or bottom orientation. `cube.getHome()` returns a copy;
77
- without a home, Home goes to the isometric view and there is no button. A press on the button never starts a drag.
78
- - **Roll.** `roll: true` shows two round buttons above the cube's top-right corner that turn the view a quarter turn
79
- about its axis, counter-clockwise and clockwise; `cube.roll(turns)` does the same for any number of quarter turns
80
- and `cube.turns` reads the roll (0 to 3 at rest). The camera position and target stay; the cube rolls
81
- `camera.up` about the view axis again every frame, so the roll holds while OrbitControls or another control
82
- orbits, on the poles too, and a drag on a rolled cube still follows the pointer on screen. A view change from the
83
- cube (a face, edge or corner, the arrow keys, Home) turns the view upright again; an up set by someone else wins
84
- and ends the roll; `dispose` gives the app's up back. The buttons and the home button share a row above the cube,
85
- so a cube in a top corner sits 38 px from the edge instead of 12 px.
86
- - **Themes.** The colours are six tokens, each a CSS custom property on the widget root: `--mvc-background` (face
87
- and button fill), `--mvc-text`, `--mvc-line` (edges and borders), `--mvc-hover` (fill of a hovered or focused face,
88
- edge, corner or button), `--mvc-hover-text` and `--mvc-focus` (keyboard focus ring). `THEMES` exports the built-in
89
- `light`, `dark` and `high-contrast` sets; `theme` or `cube.setTheme(...)` takes one of their names, `'auto'`
90
- (dark when the browser prefers a dark scheme, high contrast when it prefers more contrast, else light) or your own
91
- tokens, for example `cube.setTheme({background: '#1b1f27', text: '#f2f4f7'})`; tokens you leave out keep the
92
- stylesheet's. Without a theme the cube sets no inline colours, so your own CSS can set the properties on `.mvc`.
93
- The package tests check every built-in pair against WCAG 2 contrast over both a black and a white page behind the
94
- translucent fill: text and hovered text at least 4.5:1 (high contrast 7:1), edges and the focus ring at least 3:1.
95
- The light theme's edges and focus ring are darker than before themes (`#6b7280`, `#0b3d91`) for that reason.
96
- - **Axis triad.** `AxisTriad` (entry `viewcube/axes`) is a `ViewCube` subclass that builds balls in place of the
97
- faces: +X, +Y and +Z are buttons labelled X, Y and Z ("Right view (X)", "Top view (Y)", "Front view (Z)"), the
98
- negative ends smaller rings. Each ball sits where its axis points on screen, nearer balls drawn in front, so the
99
- view is read the way a CAD axis gizmo reads. Clicking a ball animates to that axis view, dragging orbits (two
100
- radians per triad width), and the home view, roll buttons, projection toggle, themes, flip and keyboard behave as
101
- on the cube. Default `size` is 64. The axis colours are `--mvc-x`, `--mvc-y` and `--mvc-z` (default `#c62828`,
102
- `#2e7d32`, `#1565c0`, white letters at 4.5:1 or more). The cube's `build` and `draw` are the protected hooks it
103
- overrides.
104
- - **Engine views.** `ViewCube.attach(engine, {view: {camera, viewport}})` turns that view's camera and sits in the chosen corner of its rectangle (the cube's container must cover the canvas). One cube per view.
105
- - **Controls.** The cube writes `camera.position` (and `camera.up` on the poles); OrbitControls, MapControls and the stage's CADCameraControls read
106
- the camera each frame, so they keep working. Any other camera change during an animation (a drag, a wheel) cancels it.
107
- A running `fitToBoundingBox` animation is cancelled when a view starts.
108
- - **Accessibility.** The root is a labelled group. The six faces are buttons named "Front view", "Top view", ...; only
109
- faces turned toward the viewer are in the tab order (screen readers reach all six). Arrow keys step the view 45°
110
- around and over the target, Home goes to the home view (the isometric view without one), Enter or Space activates the focused face. Edge and
111
- corner hot spots are pointer targets with tooltips. The projection toggle is a button with `aria-pressed`; the home button is named "Home view", the roll buttons "Roll the view counter-clockwise" and "... clockwise".
112
- - **Rendering.** Plain DOM and CSS 3D transforms: no GPU work, no extra pass, crisp text at any DPR, works on WebGPU
113
- and WebGL2. The cube turns in a frame-graph step after every control has moved the camera, so it never lags a frame,
114
- and touches the DOM only when the orientation changed.
115
-
116
- Why a separate package and not `@margoengine/controls`: the cube is a DOM widget that drives any camera controller
117
- (including the stage's CADCameraControls, which does not use controls) and optionally `@margoengine/cameras`; keeping it
118
- out leaves controls' bundle and dependencies unchanged.
119
-
120
- Limits: roll is in quarter turns from the cube's buttons and `roll` (any whole or fractional count, landing on a
121
- whole quarter turn), the home view keeps the camera's field of view and
122
- projection (only position and target), and a custom theme's contrast is yours to check (only the built-in ones are
123
- tested).
124
-
125
- Size: 5,130 B min + gzip (the test enforces under 5,150 B); `viewcube/axes` adds 1,127 B on top (under 1,200 B). Apache-2.0. Peer: `@margoengine/core` (^0.1.0 || ^1.0.0).
126
-
127
- Unit tests: `npm test --workspace @margoengine/viewcube`. Browser check with real clicks: `node packages/viewcube/test/browser-check.mjs`.
1
+ # @margoengine/viewcube
2
+
3
+ Import `margoengine/viewcube` from the `margoengine` package, or `@margoengine/viewcube` 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).
4
+
5
+ A CAD orientation cube for Margo Engine: a small cube in a corner of the view that turns with the camera. Click a face,
6
+ edge or corner and the camera animates around its target to that view (Top, Front, Right, ..., the twelve edge views
7
+ and the eight isometric corners), keeping the distance. With `@margoengine/cameras` it also toggles perspective and
8
+ orthographic projection.
9
+
10
+ ```ts
11
+ import {Engine} from 'margoengine/core';
12
+ import {CameraProjection} from 'margoengine/cameras';
13
+ import {OrbitControls} from 'margoengine/controls';
14
+ import {ViewCube} from 'margoengine/viewcube';
15
+ const canvas = document.querySelector('canvas')!;
16
+
17
+ const engine = await Engine.create(canvas); // the canvas needs a parent element; the cube is placed in it
18
+ const projection = CameraProjection.attach(engine, {mode: 'perspective'});
19
+ OrbitControls.attach(engine); // or the stage's CADCameraControls
20
+ const cube = ViewCube.attach(engine, {projection}); // omit projection to hide the toggle
21
+
22
+ cube.view('top'); // 'top' | 'bottom' | 'front' | 'back' | 'left' | 'right' | 'iso'
23
+ cube.view([1, 1, 0]); // any direction from the target toward the camera
24
+ cube.view('front', 0); // jump without animating
25
+ cube.setProjection('orthographic');
26
+ cube.setTheme('dark'); // 'light' | 'dark' | 'high-contrast' | 'auto' | your own tokens
27
+ cube.drag = false; // dragging the cube orbits the camera unless turned off
28
+ cube.setHome({position: [6, 4, 8], target: [0, 1, 0]}); // your own home view; shows the home button
29
+ cube.home(); // the home button and the Home key do the same
30
+ cube.roll(1); // a quarter turn counter-clockwise about the view axis (-1 clockwise)
31
+ cube.dispose(); // engine.dispose() also disposes it
32
+ ```
33
+
34
+ For less than a cube, `margoengine/viewcube/axes` (`@margoengine/viewcube/axes`) has an axis triad: X, Y and Z
35
+ balls on sticks and a smaller ball at each negative end, turning with the camera.
36
+
37
+ ```ts
38
+ import {Engine} from 'margoengine/core';
39
+ import {AxisTriad} from 'margoengine/viewcube/axes';
40
+ const canvas = document.querySelector('canvas')!;
41
+
42
+ const engine = await Engine.create(canvas);
43
+ const triad = AxisTriad.attach(engine, {corner: 'bottom-left', home: true}); // every ViewCube option works
44
+ triad.view('right'); // a ViewCube in every other way
45
+ ```
46
+
47
+ Options: `container` (default: the canvas's parent; made `position: relative` if it is static), `corner`
48
+ (`'top-right'` default, `'top-left'`, `'bottom-right'`, `'bottom-left'`), `size` (cube edge in CSS pixels, 80),
49
+ `duration` (seconds, 0.4), `projection` (a CameraProjection, or anything with `mode`), `labels` (face names, for
50
+ translation), `flip` (false; also a public field: clicking the view already shown turns to the opposite one, as
51
+ Blender's navigation gizmo and SolidWorks' "Normal To" pressed twice do; Autodesk's ViewCube keeps the view),
52
+ `drag` (true; also a public field: dragging the cube orbits the camera), `home` (none; a `{position, target}`, or
53
+ `true` for the camera as it is when the cube attaches: shows the home button), `roll` (false; shows the two roll
54
+ buttons), `theme` (none: the light colours; see Themes).
55
+ `@margoengine/controls` navigation profiles carry it: `ViewCube.attach(engine, {...BLENDER.viewCube})`. The toggle
56
+ also follows projection changes made elsewhere (Blender's numpad 5 through a profile) on the next frame.
57
+ `cube.element` is the widget root for your own styling.
58
+
59
+ - **Orientation.** World Y is up, front is +Z, right is +X (glTF and Blender exports). Top shows X right and -Z up,
60
+ bottom X right and +Z up, from whichever side the camera comes, because the animation interpolates azimuth and
61
+ elevation the way OrbitControls moves. Top and bottom are exactly vertical: on the pole the cube sets `camera.up` to
62
+ the screen up of the way it came (arrow keys turn it there) and puts the previous up back as soon as the camera
63
+ leaves the pole, or on `dispose` (then 1e-6 rad off the pole, same image). An up it did not set is left alone, such as
64
+ a CameraProjection's vertical `up`, until a drag on the cube or its compass turns the heading on the pole: then the
65
+ cube turns the projection's `up` with it, so the image spins, and the projection keeps that up. OrbitControls and CADCameraControls leave an exact pole at azimuth 0, so after a
66
+ top view reached from the side they start from the front.
67
+ - **Drag to orbit.** Press on the cube and drag: the camera orbits its target at the same distance, with the
68
+ azimuth and elevation OrbitControls uses, so the cube's surface follows the pointer (half the cube's width is one
69
+ radian). Dragging right turns the front to the right; dragging down tips the top toward you and stops on the pole
70
+ in a standard top view. A press that moves under 3 pixels is still a click on the face, edge or corner, and the
71
+ click that ends a drag does nothing. The cube keeps the pointer while dragging, a drag cancels a view animation,
72
+ and only the primary button drags (`touch-action: none` on the widget, so a touch drag does not scroll the page).
73
+ - **Home view.** `home` or `cube.setHome(view)` sets the app's own home: a camera position and the target it looks
74
+ at (`cube.setHome()` takes the camera as it is now). A round home button appears above the cube's top-left corner;
75
+ it and the Home key animate the camera there, moving the target and the distance too, and land on them exactly.
76
+ A vertical home is exactly vertical with the standard top or bottom orientation. `cube.getHome()` returns a copy;
77
+ without a home, Home goes to the isometric view and there is no button. A press on the button never starts a drag.
78
+ - **Roll.** `roll: true` shows two round buttons above the cube's top-right corner that turn the view a quarter turn
79
+ about its axis, counter-clockwise and clockwise; `cube.roll(turns)` does the same for any number of quarter turns
80
+ and `cube.turns` reads the roll (0 to 3 at rest). The camera position and target stay; the cube rolls
81
+ `camera.up` about the view axis again every frame, so the roll holds while OrbitControls or another control
82
+ orbits, on the poles too, and a drag on a rolled cube still follows the pointer on screen. A view change from the
83
+ cube (a face, edge or corner, the arrow keys, Home) turns the view upright again; an up set by someone else wins
84
+ and ends the roll; `dispose` gives the app's up back. The buttons and the home button share a row above the cube,
85
+ so a cube in a top corner sits 38 px from the edge instead of 12 px.
86
+ - **Themes.** The colours are six tokens, each a CSS custom property on the widget root: `--mvc-background` (face
87
+ and button fill), `--mvc-text`, `--mvc-line` (edges and borders), `--mvc-hover` (fill of a hovered or focused face,
88
+ edge, corner or button), `--mvc-hover-text` and `--mvc-focus` (keyboard focus ring). `THEMES` exports the built-in
89
+ `light`, `dark` and `high-contrast` sets; `theme` or `cube.setTheme(...)` takes one of their names, `'auto'`
90
+ (dark when the browser prefers a dark scheme, high contrast when it prefers more contrast, else light) or your own
91
+ tokens, for example `cube.setTheme({background: '#1b1f27', text: '#f2f4f7'})`; tokens you leave out keep the
92
+ stylesheet's. Without a theme the cube sets no inline colours, so your own CSS can set the properties on `.mvc`.
93
+ The package tests check every built-in pair against WCAG 2 contrast over both a black and a white page behind the
94
+ translucent fill: text and hovered text at least 4.5:1 (high contrast 7:1), edges and the focus ring at least 3:1.
95
+ The light theme's edges and focus ring are darker than before themes (`#6b7280`, `#0b3d91`) for that reason.
96
+ - **Axis triad.** `AxisTriad` (entry `viewcube/axes`) is a `ViewCube` subclass that builds balls in place of the
97
+ faces: +X, +Y and +Z are buttons labelled X, Y and Z ("Right view (X)", "Top view (Y)", "Front view (Z)"), the
98
+ negative ends smaller rings. Each ball sits where its axis points on screen, nearer balls drawn in front, so the
99
+ view is read the way a CAD axis gizmo reads. Clicking a ball animates to that axis view, dragging orbits (two
100
+ radians per triad width), and the home view, roll buttons, projection toggle, themes, flip and keyboard behave as
101
+ on the cube. Default `size` is 64. The axis colours are `--mvc-x`, `--mvc-y` and `--mvc-z` (default `#c62828`,
102
+ `#2e7d32`, `#1565c0`, white letters at 4.5:1 or more). The cube's `build` and `draw` are the protected hooks it
103
+ overrides.
104
+ - **Engine views.** `ViewCube.attach(engine, {view: {camera, viewport}})` turns that view's camera and sits in the chosen corner of its rectangle (the cube's container must cover the canvas). One cube per view.
105
+ - **Controls.** The cube writes `camera.position` (and `camera.up` on the poles); OrbitControls, MapControls and the stage's CADCameraControls read
106
+ the camera each frame, so they keep working. Any other camera change during an animation (a drag, a wheel) cancels it.
107
+ A running `fitToBoundingBox` animation is cancelled when a view starts.
108
+ - **Accessibility.** The root is a labelled group. The six faces are buttons named "Front view", "Top view", ...; only
109
+ faces turned toward the viewer are in the tab order (screen readers reach all six). Arrow keys step the view 45°
110
+ around and over the target, Home goes to the home view (the isometric view without one), Enter or Space activates the focused face. Edge and
111
+ corner hot spots are pointer targets with tooltips. The projection toggle is a button with `aria-pressed`; the home button is named "Home view", the roll buttons "Roll the view counter-clockwise" and "... clockwise".
112
+ - **Rendering.** Plain DOM and CSS 3D transforms: no GPU work, no extra pass, crisp text at any DPR, works on WebGPU
113
+ and WebGL2. The cube turns in a frame-graph step after every control has moved the camera, so it never lags a frame,
114
+ and touches the DOM only when the orientation changed.
115
+
116
+ Why a separate package and not `@margoengine/controls`: the cube is a DOM widget that drives any camera controller
117
+ (including the stage's CADCameraControls, which does not use controls) and optionally `@margoengine/cameras`; keeping it
118
+ out leaves controls' bundle and dependencies unchanged.
119
+
120
+ Limits: roll is in quarter turns from the cube's buttons and `roll` (any whole or fractional count, landing on a
121
+ whole quarter turn), the home view keeps the camera's field of view and
122
+ projection (only position and target), and a custom theme's contrast is yours to check (only the built-in ones are
123
+ tested).
124
+
125
+ Size: 5,130 B min + gzip (the test enforces under 5,150 B); `viewcube/axes` adds 1,127 B on top (under 1,200 B). Apache-2.0. Peer: `@margoengine/core` (^0.1.0 || ^1.0.0).
126
+
127
+ Unit tests: `npm test --workspace @margoengine/viewcube`. Browser check with real clicks: `node packages/viewcube/test/browser-check.mjs`.
128
+
129
+ ## Core compatibility at engine boundaries
130
+
131
+ Each engine-bound entry (`.`, `/axes`, `/up`, `/fit`, `/compass`) carries the core version its build was made for, stamped into its plugins, `attach` methods and `engineRuntime` calls, and checks the engine's core when it attaches or its plugin is set up, before it reads or changes the engine. A mismatched core version, or a second core module in the page (two installs, or one bundled twice), throws MargoError `'version'` naming both cores and the package, with the help link https://margoengine.com/errors#version. The cure is one core: dedupe or rebuild the packages against the same core build (`npm ls @margoengine/core` lists the copies); do not catch the error and go on. The check keeps no global state, and importing an entry registers nothing and attaches nothing. Details: [One core per engine](../core/README.md#one-core-per-engine-version-checks-extension) in the core README.
package/dist/axes.js CHANGED
@@ -1,4 +1,4 @@
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
3
 
4
4
  import { ViewCube as e } from "./index.js";
@@ -23,7 +23,7 @@ var t = [
23
23
  "Z"
24
24
  ]
25
25
  ], n = 18, r = 12, i = ".mvc-ball{position:absolute;left:0;top:0;box-sizing:border-box;margin:0;padding:0;border:2px solid var(--c);border-radius:50%;background:var(--c);color:#fff;font:700 10px/14px system-ui,sans-serif;text-align:center;pointer-events:auto;cursor:pointer;outline:none}\n.mvc-ball[aria-hidden]{background:var(--mvc-background)}\n.mvc-ball:hover,.mvc-ball:focus-visible{box-shadow:0 0 0 2px var(--mvc-focus)}\n.mvc-stick{position:absolute;left:0;top:0;height:2px;background:var(--c);transform-origin:0 50%;pointer-events:none}", a = class a extends e {
26
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
26
+ static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
27
27
  return new a(e, t);
28
28
  }
29
29
  constructor(e, t = {}) {
package/dist/compass.js CHANGED
@@ -1,4 +1,4 @@
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
3
 
4
4
  import { ViewCube as e } from "./index.js";
@@ -23,7 +23,7 @@ var n = class t extends e {
23
23
  "south",
24
24
  "west"
25
25
  ], a = ".mvc-compass{position:absolute;left:-8px;right:-8px;top:calc(100% + 32px);height:36px;pointer-events:none}\n.mvc-compass-track{position:absolute;inset:0;border:1px solid var(--mvc-line);border-radius:50%;box-sizing:border-box}\n.mvc-compass button{position:absolute;transform:translate(-50%,-50%);width:22px;height:22px;border:1px solid var(--mvc-line);border-radius:50%;padding:0;pointer-events:auto;background:var(--mvc-background);color:var(--mvc-text);font:600 10px system-ui;cursor:pointer}\n.mvc-compass button:hover,.mvc-compass button:focus-visible{background:var(--mvc-hover);color:var(--mvc-hover-text)}\n.mvc:has(>.mvc-compass)>.mvc-projection{bottom:-110px}\n.mvc-menu{position:fixed;z-index:10000;min-width:180px;max-width:calc(100vw - 8px);padding:4px;border:1px solid var(--mvc-line);border-radius:5px;background:var(--mvc-background);color:var(--mvc-text);font:12px system-ui;box-sizing:border-box}\n.mvc-menu button{display:block;width:100%;padding:6px 10px;text-align:left;border:0;background:none;color:inherit;font:inherit;cursor:pointer}\n.mvc-menu button:hover,.mvc-menu button:focus-visible{background:var(--mvc-hover);color:var(--mvc-hover-text);outline:2px solid var(--mvc-focus);outline-offset:-2px}\n.mvc-menu button:disabled{opacity:.5;cursor:default}\n.mvc-menu [aria-checked=true]::before{content:'✓ ';}\n.mvc-menu[hidden],.mvc-compass[hidden]{display:none}", o = class e {
26
- static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("0.1.0",import.meta.url));
26
+ static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
27
27
  return new e(t, n);
28
28
  }
29
29
  constructor(e, n = {}) {
@@ -79,7 +79,7 @@ var n = class t extends e {
79
79
  }
80
80
  this.previousDispose = e.dispose, this.disposeCube = () => {
81
81
  this.dispose(), this.previousDispose.call(e);
82
- }, e.dispose = this.disposeCube, r.set(e, this), e.engine.use(this.plugin = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
82
+ }, e.dispose = this.disposeCube, r.set(e, this), e.engine.use(this.plugin = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
83
83
  name: this.name,
84
84
  setup() {},
85
85
  registerPasses: (e) => {
package/dist/fit.js CHANGED
@@ -1,10 +1,10 @@
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
3
 
4
4
  import { UpViewCube as e } from "./up.js";
5
5
  //#region src/fit.ts
6
6
  var t = class t extends e {
7
- static attach(e, n) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
7
+ static attach(e, n) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
8
8
  return new t(e, n);
9
9
  }
10
10
  constructor(e, t = {}) {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
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
3
 
4
4
  import { MargoError as e } from "@margoengine/math/errors";
@@ -159,7 +159,7 @@ var t = {
159
159
  world(e) {
160
160
  return e;
161
161
  }
162
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
162
+ static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
163
163
  return new i(e, t);
164
164
  }
165
165
  constructor(e, { container: t = e.canvas.parentElement, corner: n = "top-right", size: r = 80, duration: i = .4, projection: a, labels: s = {}, flip: l = !1, drag: u = !0, home: d, roll: f = !1, theme: m, view: h } = {}) {
@@ -280,7 +280,7 @@ var t = {
280
280
  "pointerup",
281
281
  "pointercancel"
282
282
  ]) b.addEventListener(e, this.onPointer);
283
- this.position = t.style.position, !this.position && v.defaultView?.getComputedStyle(t).position === "static" && (t.style.position = "relative"), e.use(this.plugin = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("0.1.0",import.meta.url),
283
+ this.position = t.style.position, !this.position && v.defaultView?.getComputedStyle(t).position === "static" && (t.style.position = "relative"), e.use(this.plugin = {coreRequirement:/*@__PURE__*/__margoCoreRequirement("1.0.0",import.meta.url),
284
284
  name: this.name,
285
285
  setup() {},
286
286
  onPreUpdate: (e) => this.update(e),
package/dist/up.js CHANGED
@@ -1,4 +1,4 @@
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
3
 
4
4
  import { ViewCube as e } from "./index.js";
@@ -8,7 +8,7 @@ var t = (e, t) => e.reduce((e, n, r) => e + n * t[r], 0), n = (e) => {
8
8
  if (e.length !== 3 || !e.every(Number.isFinite) || !Number.isFinite(t) || !t) throw RangeError("View cube frame needs finite nonzero directions");
9
9
  return e.map((e) => e / t);
10
10
  }, r = class r extends e {
11
- static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
11
+ static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
12
12
  return new r(e, t);
13
13
  }
14
14
  constructor(e, { up: r = "z", front: i, ...a } = {}) {
package/package.json CHANGED
@@ -1,66 +1,66 @@
1
- {
2
- "name": "@margoengine/viewcube",
3
- "version": "0.1.0",
4
- "description": "CAD view cube: shows the camera orientation and animates to top, front, side and isometric views, with a perspective/orthographic toggle.",
5
- "keywords": [
6
- "margoengine",
7
- "webgpu",
8
- "3d",
9
- "viewcube"
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/viewcube"
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
- "./axes": {
30
- "types": "./dist/axes.d.ts",
31
- "import": "./dist/axes.js"
32
- },
33
- "./up": {
34
- "types": "./dist/up.d.ts",
35
- "import": "./dist/up.js"
36
- },
37
- "./fit": {
38
- "types": "./dist/fit.d.ts",
39
- "import": "./dist/fit.js"
40
- },
41
- "./compass": {
42
- "types": "./dist/compass.d.ts",
43
- "import": "./dist/compass.js"
44
- }
45
- },
46
- "files": [
47
- "dist",
48
- "LICENSE",
49
- "NOTICE"
50
- ],
51
- "publishConfig": {
52
- "access": "public"
53
- },
54
- "peerDependencies": {
55
- "@margoengine/core": "^0.1.0"
56
- },
57
- "dependencies": {
58
- "@margoengine/math": "^0.1.0"
59
- },
60
- "scripts": {
61
- "build": "node ../../scripts/build-optional.js viewcube",
62
- "test": "npm run build && node --test test/*.test.js",
63
- "prepack": "npm run build",
64
- "test:browser": "cd ../.. && node packages/viewcube/test/browser-check.mjs"
65
- }
66
- }
1
+ {
2
+ "name": "@margoengine/viewcube",
3
+ "version": "1.0.0",
4
+ "description": "CAD view cube: shows the camera orientation and animates to top, front, side and isometric views, with a perspective/orthographic toggle.",
5
+ "keywords": [
6
+ "margoengine",
7
+ "webgpu",
8
+ "3d",
9
+ "viewcube"
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/viewcube"
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
+ "./axes": {
30
+ "types": "./dist/axes.d.ts",
31
+ "import": "./dist/axes.js"
32
+ },
33
+ "./up": {
34
+ "types": "./dist/up.d.ts",
35
+ "import": "./dist/up.js"
36
+ },
37
+ "./fit": {
38
+ "types": "./dist/fit.d.ts",
39
+ "import": "./dist/fit.js"
40
+ },
41
+ "./compass": {
42
+ "types": "./dist/compass.d.ts",
43
+ "import": "./dist/compass.js"
44
+ }
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "LICENSE",
49
+ "NOTICE"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "peerDependencies": {
55
+ "@margoengine/core": "^1.0.0"
56
+ },
57
+ "dependencies": {
58
+ "@margoengine/math": "^1.0.0"
59
+ },
60
+ "scripts": {
61
+ "build": "node ../../scripts/build-optional.js viewcube",
62
+ "test": "npm run build && node --test test/*.test.js",
63
+ "prepack": "npm run build",
64
+ "test:browser": "cd ../.. && node packages/viewcube/test/browser-check.mjs"
65
+ }
66
+ }