New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add experimental @pixiv/vrm-viewer package #1395
base: dev-v3
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should merge all examples folders at root dir to avoid duplicates of vrms, envmaps, etc...
@@ -0,0 +1,106 @@ | |||
import { VRM, VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm'; | |||
import ModelViewerElementBase, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewing this reading some <model-viewer />
's source code would be helpful.
import { ModelViewerElement } from '@google/model-viewer/src/model-viewer'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export const VRMViewerElement = VRMMixin(ModelViewerElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not work with <model-viewer-effects />
yet due to node name check. I think it have to be fixed upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently type build fails and waiting for google/model-viewer#4786
https://github.com/pixiv/three-vrm/actions/runs/9203519761/job/25315221048#step:5:252
@@ -78,6 +83,8 @@ async function buildPackage(absWorkingDir) { | |||
loader: { '.frag': 'text', '.vert': 'text' }, | |||
sourcemap: DEV ? 'inline' : false, | |||
absWorkingDir, | |||
outdir: 'lib', | |||
tsconfig: path.join(absWorkingDir, 'tsconfig.json'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed for decorators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if we don't specify tsconfig
here? Does it attempt to discover tsconfig.json
near from its project root instead of the cwd?
absWorkingDir, | ||
}); | ||
|
||
await esmContext.watch(); | ||
const extraContext = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esbuild is clever enough to not bundle mutiple three, so created a bundle-all build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so created a bundle-all build
wdym
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using rollup there is a issue that three is bundled multiple times and that issue is lifted after switching to esbuild; therefore It becomes possible to create a build that includes three (not treat three as external to avoid importmap at all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is "bundle-all" here? Are you simply mentioning the vrm-viewer.js
build includes Three.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you simply mentioning the vrm-viewer.js build includes Three.js
yes, including three,three-vrm,model-viewer
function vrmViewOptions(baseBuildOptions) { | ||
return { | ||
...baseBuildOptions, | ||
format: 'esm', | ||
entryPoints: { | ||
[`vrm-viewer${minifySuffix}`]: 'src/index.ts', | ||
}, | ||
external: [], // include three | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clarify the intention why we have to separate options only for vrm-viewer.
I guess it's because:
- we don't have to output
cjs
builds - we want to specify that the output filename is
vrm-viewer.js
orvrm-viewer.min.js
- we want to include Three.js in the build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have to output cjs builds
YES, but can be avoided by reusing the esm context.
we want to specify that the output filename is vrm-viewer.js or vrm-viewer.min.js
YES, but can be avoided by reusing existing context.
we want to include Three.js in the build
YES, this is the main reason since external
is fixed per context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you put them in the code as comments?
|
Those have different concerns and controls.
|
Add experimental
@pixiv/vrm-viewer
package via model-viewer