cesium/packages/sandcastle
jjspace 0b11c10039
Merge remote-tracking branch 'origin/main' into fix-sandcastle-paths
2025-11-25 12:54:17 -05:00
..
@types Search and gallery updates 2025-08-23 01:22:28 +09:00
gallery Merge remote-tracking branch 'origin/main' into sandcastle-build-updates 2025-11-03 10:48:42 -05:00
public support multiple arguments in console mirror messages 2025-11-04 17:00:23 -05:00
scripts use node executable for windows 2025-11-25 12:50:55 -05:00
src support multiple arguments in console mirror messages 2025-11-04 17:00:23 -05:00
templates central sandcastle build function, bundle esm packages 2025-09-19 11:29:55 -04:00
.gitignore Search and gallery updates 2025-08-23 01:22:28 +09:00
README.md move and trim build config 2025-10-07 13:15:20 -04:00
index.html further isolate sandcastle build process 2025-09-29 16:08:45 -04:00
index.js further isolate sandcastle build process 2025-09-29 16:08:45 -04:00
package.json Merge remote-tracking branch 'origin/main' into sandcastle-build-updates 2025-10-23 12:56:59 -04:00
sandcastle.config.js don't include dev sandcastles in prod 2025-09-30 15:56:45 -04:00
standalone.html switch to relative routes for non-prod builds 2025-10-07 12:36:13 -04:00
tsconfig.app.json Search and gallery updates 2025-08-23 01:22:28 +09:00
tsconfig.json isolate sandcastle api compilation 2025-06-06 14:32:01 -04:00
tsconfig.node.json small cleanup, remove excess changes 2025-10-07 15:47:11 -04:00
vite-env.d.ts central sandcastle build function, bundle esm packages 2025-09-19 11:29:55 -04:00
vite-plugins.js central sandcastle build function, bundle esm packages 2025-09-19 11:29:55 -04:00
vite.config.dev.ts adjust config structure 2025-10-07 16:04:03 -04:00
vite.config.js switch to relative routes for non-prod builds 2025-10-07 12:36:13 -04:00

README.md

CesiumJS Sandcastle

This package is the application for Sandcastle.

Running/Building

  • npm run dev: run the development server
  • npm run build-app: build to static files in /Apps/Sandcastle2 for hosting/access from the root cesium dev server

Linting and style is managed under the project root's scripts.

Building Sandcastle

There are 2 main conceptual ways that Sandcastle gets built which mostly revolve around how to access CesiumJS resources:

  1. Sandcastle points to "external" paths for CesiumJS resources
  2. Sandcastle is built to 1 static location that is co-located with all CesiumJS files. ie they're all copied into the built location

The first method is useful and desired when developing the project locally and you want to refer to the actively built and updated CesiumJS files as you do other work. This is how the Sandcastle development server (npm run dev) and the local static version at /Apps/Sandcastle2 are built.

The second method is used when building Sandcastle to be deployed to the website or other static location. You can think of this as "bundling" all the necessary files needed for Sandcastle into 1 single directory.

Regardless the method you want to use Sandcastle is always built using the exported buildStatic, createSandcastleConfig and buildGalleryList functions.

The gallery for Sandcastle is located in the gallery directory. A "single sandcastle" consists of 4 files which should be contained in a sub-directory that matches the id of the sandcastle.

gallery
├── 3d-models             <-- "slug" id
│   ├── index.html        <-- Code that goes into the HTML tab
│   ├── main.js           <-- Code that goes into the JS tab (the main code of a Sandcastle)
│   ├── sandcastle.yaml   <-- Metadata file containing title, description, labels, etc.
│   └── thumbnail.jpg     <-- Optional thumbnail file
└── gallery-list.json     <-- "entry point" for a gallery, generated with `scripts/buildGallery.js`

sandcastle.yaml

Below is a sample metadata yaml file. This data is used in the scripts/buildGallery.js file to create the full gallery-list.json information. That script also does some validation on these values.

# The id of this sandcastle. Should match the sub-directory name and not contain spaces
id: 3d-models-coloring
# Used to map this sandcastle to a legacy html identifier. New sandcastles should NOT include this
legacyId: 3D Models Coloring.html
# Title for this sandcastle
title: 3D Models Coloring
# Description for this sandcastle
description: Change color of 3D models.
# Labels for this Sandcastle to help with filtering
labels:
  - Showcases
  - Beginner
# Optional thumbnail file. If set the file should be in the same directory
thumbnail: thumbnail.jpg
# Identify this as a development only Sandcastle. Will not be included in production builds if true
development: false

Thumbnails

Thumbnails should be any image that represents what the sandcastle does. Often this will just be the Viewer with or without any Sandcastle interaction buttons. Thumbnail files should be limited in size to help save on bandwidth. Currently most are around 225px in width.

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

export default tseslint.config({
  extends: [
    // Remove ...tseslint.configs.recommended and replace with this
    ...tseslint.configs.recommendedTypeChecked,
    // Alternatively, use this for stricter rules
    ...tseslint.configs.strictTypeChecked,
    // Optionally, add this for stylistic rules
    ...tseslint.configs.stylisticTypeChecked,
  ],
  languageOptions: {
    // other options...
    parserOptions: {
      project: ["./tsconfig.node.json", "./tsconfig.app.json"],
      tsconfigRootDir: import.meta.dirname,
    },
  },
});

You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:

// eslint.config.js
import reactX from "eslint-plugin-react-x";
import reactDom from "eslint-plugin-react-dom";

export default tseslint.config({
  plugins: {
    // Add the react-x and react-dom plugins
    "react-x": reactX,
    "react-dom": reactDom,
  },
  rules: {
    // other rules...
    // Enable its recommended typescript rules
    ...reactX.configs["recommended-typescript"].rules,
    ...reactDom.configs.recommended.rules,
  },
});