Commit e800b2e
Improved GLTF API (#282)
* feat(gltf-scene): introduce GLTF Scene Modification API and related components
- Added a new GLTF Scene Modification API, including components like GltfScene, Modify, and hooks for entity management.
- Implemented context for managing GLTF scene state and hierarchy.
- Introduced examples demonstrating the usage of the new API for modifying GLTF assets.
- Updated existing components (Camera, Light, Render) to export their definitions for better integration with the new API.
- Added type definitions for improved TypeScript support.
This commit enhances the library's capabilities for declarative modifications of GLTF assets, providing a more flexible and powerful way to manage 3D scenes.
* feat: add new <Gltf/> API for enhanced 3D scene management
* refactor(gltf): restructure GLTF API and introduce new components
- Moved GLTF scene management to a dedicated API, enhancing modularity and usability.
- Introduced new components: Gltf, Modify, and associated hooks for improved entity manipulation.
- Updated type definitions and context management for better integration and TypeScript support.
- Added examples demonstrating the new API's capabilities for modifying GLTF assets.
- Removed deprecated components and streamlined the overall structure for clarity.
This commit significantly enhances the library's functionality for declarative modifications of GLTF assets, providing a more robust framework for 3D scene management.
* Improve tests
* fix(gltf): enhance Gltf component and integration tests
- Updated the Gltf component to include a check for the parent entity in the useEffect hook, improving asset instantiation logic.
- Refactored integration tests to improve clarity and coverage, including modifications to existing component props and handling of edge cases.
- Adjusted test assertions to ensure proper state before and after modifications, enhancing reliability of test outcomes.
- Improved the structure of test cases for better readability and maintainability.
* refactor(gltf): enhance integration tests with new test components
- Introduced a new file containing test component fixtures to streamline integration tests for the Gltf component.
- Replaced direct Gltf usage in tests with specific test components to improve clarity and maintainability.
- Updated various test cases to utilize the new components, demonstrating different GLTF modification patterns.
- Enhanced the overall structure of integration tests for better readability and organization.
* add warnings tests
* feat(gltf): add warnings for adding existing components to entities
- Enhanced the RuleProcessor component to check for existing components on entities before adding new ones.
- Introduced a warning mechanism to inform users when attempting to add a component that already exists, guiding them to use modification actions instead.
- Updated tests to reflect changes in component handling and ensure proper functionality.
* Fixed entity cast
* updated changeset
* Update packages/lib/src/gltf/examples.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor(gltf): update rule merging logic to use MODIFY_COMPONENT action
- Changed instances of REMOVE_COMPONENT to MODIFY_COMPONENT in rule merging tests to reflect updated action handling.
- Enhanced test cases to ensure proper functionality of component modifications, including the addition of props for removal.
- Improved clarity and maintainability of tests by aligning with the new action structure.
* refactor(tests): enhance rule merging tests for clarity and accuracy
- Updated assertions in the rule merging test to explicitly check the winning rule's ID, action type, and properties.
- Improved test readability by assigning the winning action to a variable for clearer context.
- Ensured that the tests accurately reflect the expected behavior of the merging logic with the MODIFY_COMPONENT action.
* Update packages/lib/src/gltf/components/Gltf.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor(gltf): optimize child clearing logic in RuleProcessor component
- Improved efficiency of child clearing by using a Map for O(1) lookups of current children by GUID.
- Updated the logic to find original children, enhancing performance and clarity of the code.
- Ensured that the functionality remains intact while streamlining the process of managing entity children.
* fix(gltf): correct import extension and add useEntity tests
- Updated the import of useParent from '.ts' to '.tsx' for consistency.
- Introduced comprehensive tests for the useEntity hook, covering various path matching scenarios, wildcard usage, and predicate functions.
- Enhanced test coverage to ensure accurate entity retrieval and handling of edge cases.
* fix(gltf): resolve entity component duplication warnings
- Implemented logic in the RuleProcessor to prevent adding duplicate components to entities.
- Added warning messages to inform users when attempting to add an existing component, promoting the use of modification actions.
- Updated tests to verify the new warning functionality and ensure correct handling of component additions.
* test(gltf): add comprehensive tests for functional prop updates
- Introduced multiple test cases to validate the behavior of functional updates for light and render components.
- Ensured correct handling of various scenarios, including undefined values, boolean toggles, and zero values.
- Enhanced test coverage for the Modify component to verify the integration of functional updates with direct prop modifications.
* Update .changeset/stale-pandas-fetch.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feat(gltf): enhance useEntity hook with PathMatcher for improved entity retrieval
- Integrated PathMatcher into the useEntity hook to support consistent path matching, including component filters and wildcards.
- Updated the logic for finding entities by pattern, allowing for more flexible and efficient entity searches.
- Added comprehensive tests to validate the new functionality, ensuring correct behavior with various path patterns and component filters.
* refactor(gltf): improve useEntity hook for enhanced entity retrieval
- Refactored the useEntity hook to streamline entity matching logic, ensuring consistent handling of string paths and predicate functions.
- Updated return logic to handle wildcards and predicates more effectively, returning arrays or null as appropriate.
- Enhanced traversal methods in helper functions to build relative paths correctly, improving the accuracy of entity searches.
* Update packages/lib/src/gltf/components/Gltf.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* linting fix
* refactor(gltf): remove unused exports from index files
- Removed unused exports PathMatcher and defaultPathMatcher from gltf/index.ts to streamline the module.
- Cleaned up index.ts by eliminating the unused useEntity export, improving code clarity and maintainability.
* Update packages/lib/src/gltf/components/RuleProcessor.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update packages/lib/src/Application.test.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update packages/lib/src/gltf/hooks/use-entity.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* chore(gltf): remove COVERAGE_ANALYSIS.md file
- Deleted the COVERAGE_ANALYSIS.md file as it is no longer needed for tracking test coverage analysis for the GLTF module.
- This cleanup helps streamline the documentation and focuses on more relevant resources.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent c623176 commit e800b2e
File tree
28 files changed
+6161
-3
lines changed- .changeset
- packages/lib
- src
- components
- gltf
- components
- hooks
- tests
- fixtures
- utils
- test
- fixtures
- utils
28 files changed
+6161
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
0 commit comments