Tree shaking improvements - #417
Conversation
| t2: 0.0115, | ||
| t0: 0.015, | ||
| t1: 0.012, | ||
| t2: 0.0105, |
There was a problem hiding this comment.
Curious about these changes? Do they match another part of the code or a previous source? I forget but I think I may have edited them from the original data I used. Don't feel strongly either way but just curious!
There was a problem hiding this comment.
There were two almost identical lists, one in hands.ts and one in SparkXr.ts, the latter seemed more recent so those values are now used. They seemed close enough that either one would probably be fine.
One alternative could be to retrieve the joint radii from the WebXR API (https://www.w3.org/TR/webxr-hand-input-1/#dom-xrframe-filljointradii), as that could in theory align better with the user's actual hands (bar spec mandated anonymization)
|
This is great, anything that reduces bundle size and opts-in code sounds good to me! @oscarlorentzon @dmarcos we should merge this yes? |
| p3 = "pinky-finger-phalanx-distal", | ||
| p4 = "pinky-finger-tip", | ||
| } | ||
| export const JointEnum = { |
There was a problem hiding this comment.
JointEnum is exported from index.ts, so this seems to break compatibility for anyone currently using let j: JointEnum. Do we need handle that for minor version releases?
There was a problem hiding this comment.
Frankly I doubt people use the JointEnum type, as it's effectively just the WebXR Hand Input Module joint names. The interaction with the WebXR API is handled by the SparkXr/hands.ts code and from the user's code everything is keyed on JointId.
Mentioning the change in the release notes should suffice IMHO.
Looks good. It would be good to clarify the potential API compatibility issue before we merge. |
This PR improves the tree-shakability of Spark by focussing on classes that users might not need or use. See #321
SplatSkinningclass is only included when used, including its shader chunks.SplatEditandSplatEditSdfare tree-shaken, unless imported.isType = trueproperties on the classes for type discrimination. Since these can't easily be used in TypeScript, however, helper type guard functions are introduced (isSplatEditandisSplatEditSdf).SplatEditsclass is still included at all times asSplatMeshis capable of constructing this:SplatMesh.ts#975SparkXrand related code is tree-shaken.SparkXr.tsandhands.ts, but now the former imports from the latter.lengthprevented tree-shaking, so resorted to a reduce function which can be statically analyzed for elimination (alternatively an IIFE could be used for this as well)