Skip to content

Three.js + Vue 3 .glb viewer, with buttons to cluster objects by shape or color.

License

Notifications You must be signed in to change notification settings

richplastow/cluster-viewer

Repository files navigation

cluster-viewer

Three.js + Vue 3 .glb viewer, with buttons to cluster objects by shape or color.

Approach

  • A bare-bones solution, with tidy code and a presentable UI
  • Keep within the npm init vue@latest guardrails, for a 'standard' Vue 3 app
  • The app is simple enough not to need a UI library or global state system
  • Allows for slightly updated versions of the glTF models to be swapped in
  • Heads toward a more general purpose app, which can deal with any glTF model

Next steps

  1. Accessibility: Add aria-roles, and test and improve text-to-speech and keyboard access
  2. Internationalization: Currently UI text is hard coded in British English
  3. Tests and Documentation: More unit tests and end-to-end tests, and better JSDoc documentation throughout (also, refactoring)
  4. Performance: In terms of bundle/chink size, Lighthouse TTI, animation FPS
  5. Orbit Controls: Limit how far the user can zoom, and provide a reset
  6. SEO: Add Open Graph metadata, for better searchability and social media previews - and then add a share button
  7. Offline Mode: for iOS's 'Add to Home Screen', maybe with a service worker
  8. Icons: A full set of icons and native theme, eg using RealFaviconGenerator
  9. Error Handling: Show user-friendly error popups on unhandled exceptions, or Sentry ...the usage analytics would be interesting
  10. Tidier Clusters: They should stack up in size-order, and all sit on the ground plane
  11. Model Upload: Let the user upload or link to any glTF file
  12. Settings Popup: For example, set language, theme and animation speed

Recommended IDE Setup

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).

Type Support for .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

Customize configuration

See Vite Configuration Reference.

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Type-Check, Compile, Minify and Serve Locally for Production

npm start

Run Unit Tests with Vitest

npm run test:unit

Run End-to-End Tests with Playwright

# Install browsers for the first run
npx playwright install

# When testing on CI, must build the project first
npm run build

# Runs the end-to-end tests
npm run test
# Runs the tests only on Chromium
npm run test -- --project=chromium
# And also just a specific file's tests
npm run test -- e2e/02-screenshots.spec.ts --project=chromium
# Runs the tests in debug mode
npm run test -- --debug

Lint with ESLint

npm run lint