Skip to content
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

Open
wants to merge 5 commits into
base: dev-v3
Choose a base branch
from

Conversation

yue4u
Copy link
Contributor

@yue4u yue4u commented May 5, 2024

Add experimental @pixiv/vrm-viewer package via model-viewer

Copy link
Contributor Author

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, {
Copy link
Contributor Author

@yue4u yue4u May 8, 2024

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);
Copy link
Contributor Author

@yue4u yue4u May 8, 2024

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.

package.json Outdated Show resolved Hide resolved
@0b5vr 0b5vr added this to the v3 milestone May 20, 2024
@0b5vr 0b5vr added the enhancement New feature or request label May 20, 2024
@0b5vr 0b5vr changed the base branch from dev to dev-v3 May 20, 2024 02:48
Copy link
Contributor Author

@yue4u yue4u left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed for decorators

Copy link
Contributor

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 =
Copy link
Contributor Author

@yue4u yue4u May 23, 2024

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

Copy link
Contributor

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

Copy link
Contributor Author

@yue4u yue4u May 24, 2024

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).

Copy link
Contributor

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?

Copy link
Contributor Author

@yue4u yue4u May 24, 2024

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

Comment on lines +139 to +148
function vrmViewOptions(baseBuildOptions) {
return {
...baseBuildOptions,
format: 'esm',
entryPoints: {
[`vrm-viewer${minifySuffix}`]: 'src/index.ts',
},
external: [], // include three
};
}
Copy link
Contributor

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 or vrm-viewer.min.js
  • we want to include Three.js in the build

Copy link
Contributor Author

@yue4u yue4u May 24, 2024

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.

Copy link
Contributor

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?

@0b5vr
Copy link
Contributor

0b5vr commented May 24, 2024

example.html and separate-three.html, Do they mean that I should choose one of them?

@yue4u
Copy link
Contributor Author

yue4u commented May 24, 2024

example.html and separate-three.html, Do they mean that I should choose one of them?

Those have different concerns and controls.

  1. example.html for easiest vrm display, only using three-vrm + modal-viewer features, not assuming extending three/three-vrm via another build system.
  2. separate-three.html for the possibility to use more three-related libraries, and the .module build can be consumed via any build system again. (I'm not very confident about the filename.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants