5.2 Queries, rules and Parts ​

Contract 2.0.0 · package sha256 a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e · generated from examples/section-5/5.02-queries-rules-and-parts.ts by services/onsite-scripter/scripts/build-contract-docs.mjs; edit the source, not this file.

Imports: values (has, validate, the Holo*Error classes, the pure helpers) from @holostep-configurators/runtime-client, types from @holostep-configurators/runtime-client/contract, /math and /testing names from those entries; boot from the runtime module the root's loadRuntimeAtFloor resolves to. A type your page defines is your app's: declare it there, never import it from the package.

ts
import type { PoseInput, Query, Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
declare const oakUrl: string;
declare const previewPose: PoseInput;                               // a look-only preview placement
declare const twoPrimitiveBodies: readonly Query[];                 // the 2F bodies by part id (C.8)
await session.find([{ name: 'mp-l*' }, { name: 'mp-r*' }]).set({ visible: false });   // the find() block: apply() never removes it
await session.apply({                                                                 // replaces only apply()'s own block
  materials: { oak: { maps: { baseColor: { url: oakUrl, sizeM: 1.2 }, roughness: 'none' } } },
  rules: [
    { query: [{ name: 'Corpus*', kind: 'mesh' }, ...twoPrimitiveBodies],                 // the room finish
      set: { material: { ref: 'oak' } } },
    { query: { node: 'cab:42', name: 'Front*' },                                          // an override: later in order
      set: { material: { baseColor: '#2b2b2b', maps: { baseColor: 'none' } } } },
  ],
});
await session.node('cab:42').set({ pose: previewPose });            // the model as a whole; reset with { pose: null }

Back to the examples · llms.txt