Skip to content

Commit

Permalink
feat: add option for default export (#196)
Browse files Browse the repository at this point in the history
* feat: add option for  default export

* Update cli.js

add missing comma

---------

Co-authored-by: drcmda <[email protected]>
  • Loading branch information
davcri and drcmda authored Dec 21, 2023
1 parent 85079c7 commit 199157b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const cli = meow(
--root, -r Sets directory from which .gltf file is served
--instance, -i Instance re-occuring geometry
--instanceall, -I Instance every geometry (for cheaper re-use)
--exportdefault, -E Use default export
--transform, -T Transform the asset for the web (draco, prune, resize)
--resolution, -R Resolution for texture resizing (default: 1024)
--keepmeshes, -j Do not join compatible meshes
Expand Down Expand Up @@ -62,6 +63,7 @@ const cli = meow(
keepmeshes: { type: 'boolean', shortFlag: 'j', default: false },
keepmaterials: { type: 'boolean', shortFlag: 'M', default: false },
format: { type: 'string', shortFlag: 'f', default: 'webp' },
exportdefault: { type: 'boolean', alias: 'E' },
weld: { type: 'number', default: 0.0001 },
ratio: { type: 'number', default: 0.75 },
error: { type: 'number', default: 0.001 },
Expand Down
4 changes: 3 additions & 1 deletion src/utils/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ ${parseExtras(gltf.parser.json.asset && gltf.parser.json.asset.extras)}*/`
: ''
}
export function Model(props${options.types ? ": JSX.IntrinsicElements['group']" : ''}) {
export ${options.exportdefault ? 'default' : ''} function Model(props${
options.types ? ": JSX.IntrinsicElements['group']" : ''
}) {
${hasInstances ? 'const instances = useContext(context);' : ''} ${
hasAnimations ? `const group = ${options.types ? 'useRef<THREE.Group>()' : 'useRef()'};` : ''
} ${
Expand Down

0 comments on commit 199157b

Please sign in to comment.