@playcanvas/supersplat-viewer 1.41.0 → 1.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -90
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/viewer.css +7 -34
- package/dist/viewer.d.ts +4 -10
- package/dist/viewer.js +3622 -1780
- package/dist/viewer.js.map +1 -1
- package/package.json +2 -3
- package/public/index.css +7 -34
- package/public/index.html +0 -7
- package/public/index.js +2997 -1923
- package/public/index.js.map +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/module/render-html.ts","../src/module/index.ts"],"sourcesContent":["import css from '../../public/index.css';\nimport html from '../../public/index.html';\nimport js from '../../public/index.js';\nimport type { ViewerAssets } from '../options';\n\n/**\n * Asset urls and settings the embedder supplies to the viewer. The asset urls are the same\n * fields `createViewer` takes in a page ({@link ViewerAssets}); here every one is optional,\n * because the document has a default for each.\n *\n * Url params on the served page take precedence over every url here, so an embed stays\n * overridable per instance. Inline {@link ViewerBootstrap.settings} is the exception: it wins\n * over `?settings=`, so a published experience cannot be repointed at another settings file.\n * `contentFilename` is ignored when a `?content=` param overrides the url it describes.\n */\ntype ViewerBootstrap = Partial<ViewerAssets> & {\n /**\n * Experience settings as an object, avoiding a round trip. When omitted the viewer\n * fetches {@link ViewerBootstrap.settingsUrl}.\n */\n settings?: unknown;\n /** Where to fetch settings from. Defaults to `./settings.json`. */\n settingsUrl?: string;\n};\n\n/** Options for {@link renderViewerHtml}. */\ntype RenderViewerHtmlOptions = {\n /** Asset urls and settings for the viewer to boot with. */\n bootstrap?: ViewerBootstrap;\n /** Value for the document's `<base href>`, for a viewer served from a sub-path. */\n baseHref?: string;\n /**\n * Page background, applied before the first frame renders to avoid a flash. Components\n * are normalized 0..1, not 0..255, matching `background.color` in the settings format —\n * so an experience's own colour can be passed straight through.\n */\n backgroundColor?: readonly [number, number, number];\n /** Raw markup injected before `</head>`, for analytics or error reporting. */\n headExtras?: string;\n /**\n * Raw markup injected immediately after `<body>`, for content that must precede the\n * canvas — a marker element a screenshot pipeline waits on, for example.\n */\n bodyStartExtras?: string;\n /** Inline the stylesheet into a `<style>` block instead of linking `./index.css`. */\n inlineCss?: boolean;\n /**\n * Inline the module bundle instead of importing `./index.js`. Independent of\n * {@link RenderViewerHtmlOptions.inlineCss}: a host serving the bundle from its own route\n * wants the css inlined to avoid a round trip before first paint, but not a megabyte of\n * js in every page.\n */\n inlineJs?: boolean;\n};\n\ntype Replacer = (match: string, ...groups: string[]) => string;\n\n// The seams below are matched against this package's own `index.html`, so a miss means the\n// document and this function have drifted apart within one release — a build-time invariant,\n// not a bad caller. Throw rather than return a half-rendered document.\n//\n// Every replacement is a function, so `$&`-style sequences in settings json, urls or the\n// bundle are inserted literally instead of being interpreted as replacement patterns.\n// Annotation text is user-authored, so this matters.\nconst replaceOnce = (source: string, pattern: RegExp, replacement: Replacer) => {\n if (!pattern.test(source)) {\n throw new Error(`renderViewerHtml: no match for ${String(pattern)} in the viewer html`);\n }\n return source.replace(pattern, replacement);\n};\n\n// Serialize for embedding in a `<script type=\"application/json\">` block. Every `<` is\n// escaped with its json unicode escape (so the payload round-trips byte-exact), which\n// neutralises all of the parser's script-content hazards at once: `</script` ending\n// the block early, and `<!--` followed by `<script` switching the tokenizer into the\n// double-escaped state, where the block's own close tag is consumed as text and the rest of\n// the document is swallowed. U+2028/U+2029 are escaped because they are legal in json\n// strings but terminate a line in some js parsers.\nconst jsonForScriptBlock = (value: unknown) => {\n return JSON.stringify(value)\n .replace(/</g, '\\\\u003c')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n};\n\n// Escape for use inside a double-quoted html attribute. `headExtras` is documented as raw\n// markup and is deliberately not escaped, but scalar options like `baseHref` are not an\n// injection channel and a caller passing one through from user input should be safe.\nconst escapeAttribute = (value: string) => {\n return value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n};\n\nconst indent = (text: string, spaces: number) => {\n const whitespace = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => whitespace + line)\n .join('\\n');\n};\n\nconst BOOTSTRAP = /<script type=\"application\\/json\" id=\"sse-bootstrap\">[\\s\\S]*?<\\/script>/;\nconst BASE_HREF = /<base\\b[^>]*>/;\nconst STYLESHEET = /<link\\b[^>]*href=\"\\.\\/index\\.css\"[^>]*>/;\nconst MODULE_IMPORT = /import \\{ createViewer \\} from '\\.\\/index\\.js';/;\nconst HEAD_CLOSE = /^([ \\t]*)<\\/head>/m;\nconst BODY_OPEN = /<body\\b[^>]*>/;\n\n/**\n * Render a standalone viewer document.\n *\n * This is the supported way to embed the viewer in a page you generate. Called with no\n * options it returns the document this package ships, unmodified.\n *\n * @param options - Embedding options; see {@link RenderViewerHtmlOptions}.\n * @returns The rendered html document.\n */\nconst renderViewerHtml = (options: RenderViewerHtmlOptions = {}) => {\n const { bootstrap, baseHref, backgroundColor, headExtras, bodyStartExtras, inlineCss, inlineJs } = options;\n\n let result = html;\n\n // Order matters. Each seam is matched with a non-global regex, so the *first* occurrence\n // in the document wins — and caller-controlled content (the bootstrap json, `headExtras`)\n // can contain text that looks like a seam. Settings carry user-authored annotation text,\n // so treat that as hostile. Every seam is therefore replaced before any caller content is\n // inserted, and the two insertions go last, in document order.\n\n if (baseHref !== undefined) {\n result = replaceOnce(result, BASE_HREF, () => `<base href=\"${escapeAttribute(baseHref)}\">`);\n }\n\n if (inlineCss) {\n // A `<style>` element is rawtext: it ends at the first `</style` regardless of css\n // syntax, so a stylesheet containing that sequence cannot be inlined. The built css\n // contains no `<` at all today; fail loudly if that ever changes.\n if (/<\\/style/i.test(css)) {\n throw new Error('renderViewerHtml: the viewer stylesheet contains \"</style\" and cannot be inlined');\n }\n result = replaceOnce(result, STYLESHEET, () => `<style>\\n${indent(css, 12)}\\n </style>`);\n }\n\n if (inlineJs) {\n // The bundle's trailing sourceMappingURL comment points at a sibling index.js.map\n // that an inlined document does not sit next to, so devtools would 404 on it (or\n // bind whatever stranger's map the host serves at that path).\n const inlineJsSource = js.replace(/\\n\\/\\/# sourceMappingURL=\\S+\\s*$/, '\\n');\n\n // An inline module script ends at the first `</script`, and `<!--` followed by\n // `<script` switches the tokenizer into a state where that close tag is consumed as\n // text instead — either way the symptom is an exported file that renders nothing.\n // The bundle contains none of these today; fail loudly if that ever changes.\n // Case-insensitive, because the html parser is.\n if (/<\\/script|<!--|<script/i.test(inlineJsSource)) {\n throw new Error(\n 'renderViewerHtml: the viewer bundle contains markup the html parser acts on and cannot be inlined'\n );\n }\n result = replaceOnce(result, MODULE_IMPORT, () => inlineJsSource);\n }\n\n if (bodyStartExtras !== undefined) {\n result = replaceOnce(result, BODY_OPEN, (bodyTag) => `${bodyTag}\\n ${bodyStartExtras}`);\n }\n\n const headAppend: string[] = [];\n if (headExtras !== undefined) {\n headAppend.push(headExtras);\n }\n if (backgroundColor) {\n const rgb = backgroundColor.map((c) => Math.round(c * 255)).join(', ');\n headAppend.push(`<style>body { background-color: rgb(${rgb}); }</style>`);\n }\n\n // Emitted at the end of head, so the background rule wins over the stylesheet on equal\n // specificity. Only the first line gains indentation: `headExtras` is raw markup, and\n // reindenting its interior lines would rewrite whitespace-sensitive content (a template\n // literal in an inline script, for instance).\n if (headAppend.length > 0) {\n result = replaceOnce(result, HEAD_CLOSE, (_match, ws) => `${ws} ${headAppend.join('\\n')}\\n${ws}</head>`);\n }\n\n // Last: the bootstrap block sits earlier in the document than `</head>`, so its own seam\n // still matches ahead of anything `headExtras` added.\n if (bootstrap) {\n const json = jsonForScriptBlock(bootstrap);\n result = replaceOnce(\n result,\n BOOTSTRAP,\n () => `<script type=\"application/json\" id=\"sse-bootstrap\">${json}</script>`\n );\n }\n\n return result;\n};\n\nexport type { RenderViewerHtmlOptions, ViewerBootstrap };\nexport { renderViewerHtml };\n","import cssSource from '../../public/index.css';\nimport htmlSource from '../../public/index.html';\nimport jsSource from '../../public/index.js';\n\n/**\n * The viewer's html document.\n *\n * @deprecated Use {@link renderViewerHtml} instead. Pattern-matching this string is\n * unsupported — its formatting is not part of this package's api and changes between\n * releases.\n */\nconst html: string = htmlSource;\n\n/** The viewer's stylesheet, for serving alongside a rendered document. */\nconst css: string = cssSource;\n\n/** The viewer's module bundle, for serving alongside a rendered document. */\nconst js: string = jsSource;\n\nexport type { ViewerAssets, ViewerFlags } from '../options';\nexport type { RenderViewerHtmlOptions, ViewerBootstrap } from './render-html';\nexport { renderViewerHtml } from './render-html';\n\nexport { html, css, js };\n"],"names":["html","css","js"],"mappings":";;;;;;AAyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,OAAe,EAAE,WAAqB,KAAI;IAC3E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,CAAA,+BAAA,EAAkC,MAAM,CAAC,OAAO,CAAC,CAAA,mBAAA,CAAqB,CAAC;IAC3F;IACA,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC;AAC/C,CAAC;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,CAAC,KAAc,KAAI;AAC1C,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;AACtB,SAAA,OAAO,CAAC,IAAI,EAAE,SAAS;AACvB,SAAA,OAAO,CAAC,SAAS,EAAE,SAAS;AAC5B,SAAA,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;AACtC,CAAC;AAED;AACA;AACA;AACA,MAAM,eAAe,GAAG,CAAC,KAAa,KAAI;AACtC,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC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,CAChB,MAAM,EACN,SAAS,EACT,MAAM,CAAA,mDAAA,EAAsD,IAAI,CAAA,SAAA,CAAW,CAC9E;IACL;AAEA,IAAA,OAAO,MAAM;AACjB;;AC7LA;;;;;;AAMG;AACH,MAAM,IAAI,GAAW;AAErB;AACA,MAAM,GAAG,GAAW;AAEpB;AACA,MAAM,EAAE,GAAW;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/module/render-html.ts","../src/module/index.ts"],"sourcesContent":["import css from '../../public/index.css';\nimport html from '../../public/index.html';\nimport js from '../../public/index.js';\nimport type { ViewerAssets } from '../options';\n\n/**\n * Asset urls and settings the embedder supplies to the viewer. The asset urls are the same\n * fields `createViewer` takes in a page ({@link ViewerAssets}); here every one is optional,\n * because the document has a default for each.\n *\n * Url params on the served page take precedence over every url here, so an embed stays\n * overridable per instance. Inline {@link ViewerBootstrap.settings} is the exception: it wins\n * over `?settings=`, so a published experience cannot be repointed at another settings file.\n * `contentFilename` is ignored when a `?content=` param overrides the url it describes.\n */\ntype ViewerBootstrap = Partial<ViewerAssets> & {\n /**\n * Experience settings as an object, avoiding a round trip. When omitted the viewer\n * fetches {@link ViewerBootstrap.settingsUrl}.\n */\n settings?: unknown;\n /** Where to fetch settings from. Defaults to `./settings.json`. */\n settingsUrl?: string;\n};\n\n/** Options for {@link renderViewerHtml}. */\ntype RenderViewerHtmlOptions = {\n /** Asset urls and settings for the viewer to boot with. */\n bootstrap?: ViewerBootstrap;\n /** Value for the document's `<base href>`, for a viewer served from a sub-path. */\n baseHref?: string;\n /**\n * Page background, applied before the first frame renders to avoid a flash. Components\n * are normalized 0..1, not 0..255, matching `background.color` in the settings format —\n * so an experience's own colour can be passed straight through.\n */\n backgroundColor?: readonly [number, number, number];\n /** Raw markup injected before `</head>`, for analytics or error reporting. */\n headExtras?: string;\n /**\n * Raw markup injected immediately after `<body>`, for content that must precede the\n * canvas — a marker element a screenshot pipeline waits on, for example.\n */\n bodyStartExtras?: string;\n /** Inline the stylesheet into a `<style>` block instead of linking `./index.css`. */\n inlineCss?: boolean;\n /**\n * Inline the module bundle instead of importing `./index.js`. Independent of\n * {@link RenderViewerHtmlOptions.inlineCss}: a host serving the bundle from its own route\n * wants the css inlined to avoid a round trip before first paint, but not a megabyte of\n * js in every page.\n */\n inlineJs?: boolean;\n};\n\ntype Replacer = (match: string, ...groups: string[]) => string;\n\n// The seams below are matched against this package's own `index.html`, so a miss means the\n// document and this function have drifted apart within one release — a build-time invariant,\n// not a bad caller. Throw rather than return a half-rendered document.\n//\n// Every replacement is a function, so `$&`-style sequences in settings json, urls or the\n// bundle are inserted literally instead of being interpreted as replacement patterns.\n// Annotation text is user-authored, so this matters.\nconst replaceOnce = (source: string, pattern: RegExp, replacement: Replacer) => {\n if (!pattern.test(source)) {\n throw new Error(`renderViewerHtml: no match for ${String(pattern)} in the viewer html`);\n }\n return source.replace(pattern, replacement);\n};\n\n// Serialize for embedding in a `<script type=\"application/json\">` block. Every `<` is\n// escaped with its json unicode escape (so the payload round-trips byte-exact), which\n// neutralises all of the parser's script-content hazards at once: `</script` ending\n// the block early, and `<!--` followed by `<script` switching the tokenizer into the\n// double-escaped state, where the block's own close tag is consumed as text and the rest of\n// the document is swallowed. U+2028/U+2029 are escaped because they are legal in json\n// strings but terminate a line in some js parsers.\nconst jsonForScriptBlock = (value: unknown) => {\n return JSON.stringify(value)\n .replace(/</g, '\\\\u003c')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n};\n\n// Escape for use inside a double-quoted html attribute. `headExtras` is documented as raw\n// markup and is deliberately not escaped, but scalar options like `baseHref` are not an\n// injection channel and a caller passing one through from user input should be safe.\nconst escapeAttribute = (value: string) => {\n return value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n};\n\nconst indent = (text: string, spaces: number) => {\n const whitespace = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => whitespace + line)\n .join('\\n');\n};\n\nconst BOOTSTRAP = /<script type=\"application\\/json\" id=\"sse-bootstrap\">[\\s\\S]*?<\\/script>/;\nconst BASE_HREF = /<base\\b[^>]*>/;\nconst STYLESHEET = /<link\\b[^>]*href=\"\\.\\/index\\.css\"[^>]*>/;\nconst MODULE_IMPORT = /import \\{ createViewer \\} from '\\.\\/index\\.js';/;\nconst HEAD_CLOSE = /^([ \\t]*)<\\/head>/m;\nconst BODY_OPEN = /<body\\b[^>]*>/;\n\n/**\n * Render a standalone viewer document.\n *\n * This is the supported way to embed the viewer in a page you generate. Called with no\n * options it returns the document this package ships, unmodified.\n *\n * @param options - Embedding options; see {@link RenderViewerHtmlOptions}.\n * @returns The rendered html document.\n */\nconst renderViewerHtml = (options: RenderViewerHtmlOptions = {}) => {\n const { bootstrap, baseHref, backgroundColor, headExtras, bodyStartExtras, inlineCss, inlineJs } = options;\n\n let result = html;\n\n // Order matters. Each seam is matched with a non-global regex, so the *first* occurrence\n // in the document wins — and caller-controlled content (the bootstrap json, `headExtras`)\n // can contain text that looks like a seam. Settings carry user-authored annotation text,\n // so treat that as hostile. Every seam is therefore replaced before any caller content is\n // inserted, and the two insertions go last, in document order.\n\n if (baseHref !== undefined) {\n result = replaceOnce(result, BASE_HREF, () => `<base href=\"${escapeAttribute(baseHref)}\">`);\n }\n\n if (inlineCss) {\n // A `<style>` element is rawtext: it ends at the first `</style` regardless of css\n // syntax, so a stylesheet containing that sequence cannot be inlined. The built css\n // contains no `<` at all today; fail loudly if that ever changes.\n if (/<\\/style/i.test(css)) {\n throw new Error('renderViewerHtml: the viewer stylesheet contains \"</style\" and cannot be inlined');\n }\n result = replaceOnce(result, STYLESHEET, () => `<style>\\n${indent(css, 12)}\\n </style>`);\n }\n\n if (inlineJs) {\n // The bundle's trailing sourceMappingURL comment points at a sibling index.js.map\n // that an inlined document does not sit next to, so devtools would 404 on it (or\n // bind whatever stranger's map the host serves at that path).\n const inlineJsSource = js.replace(/\\n\\/\\/# sourceMappingURL=\\S+\\s*$/, '\\n');\n\n // An inline module script ends at the first `</script`, and `<!--` followed by\n // `<script` switches the tokenizer into a state where that close tag is consumed as\n // text instead — either way the symptom is an exported file that renders nothing.\n // The bundle contains none of these today; fail loudly if that ever changes.\n // Case-insensitive, because the html parser is.\n if (/<\\/script|<!--|<script/i.test(inlineJsSource)) {\n throw new Error(\n 'renderViewerHtml: the viewer bundle contains markup the html parser acts on and cannot be inlined'\n );\n }\n result = replaceOnce(result, MODULE_IMPORT, () => inlineJsSource);\n }\n\n if (bodyStartExtras !== undefined) {\n result = replaceOnce(result, BODY_OPEN, (bodyTag) => `${bodyTag}\\n ${bodyStartExtras}`);\n }\n\n const headAppend: string[] = [];\n if (headExtras !== undefined) {\n headAppend.push(headExtras);\n }\n if (backgroundColor) {\n const rgb = backgroundColor.map((c) => Math.round(c * 255)).join(', ');\n headAppend.push(`<style>body { background-color: rgb(${rgb}); }</style>`);\n }\n\n // Emitted at the end of head, so the background rule wins over the stylesheet on equal\n // specificity. Only the first line gains indentation: `headExtras` is raw markup, and\n // reindenting its interior lines would rewrite whitespace-sensitive content (a template\n // literal in an inline script, for instance).\n if (headAppend.length > 0) {\n result = replaceOnce(result, HEAD_CLOSE, (_match, ws) => `${ws} ${headAppend.join('\\n')}\\n${ws}</head>`);\n }\n\n // Last: the bootstrap block sits earlier in the document than `</head>`, so its own seam\n // still matches ahead of anything `headExtras` added.\n if (bootstrap) {\n const json = jsonForScriptBlock(bootstrap);\n result = replaceOnce(\n result,\n BOOTSTRAP,\n () => `<script type=\"application/json\" id=\"sse-bootstrap\">${json}</script>`\n );\n }\n\n return result;\n};\n\nexport type { RenderViewerHtmlOptions, ViewerBootstrap };\nexport { renderViewerHtml };\n","import cssSource from '../../public/index.css';\nimport htmlSource from '../../public/index.html';\nimport jsSource from '../../public/index.js';\n\n/**\n * The viewer's html document.\n *\n * @deprecated Use {@link renderViewerHtml} instead. Pattern-matching this string is\n * unsupported — its formatting is not part of this package's api and changes between\n * releases.\n */\nconst html: string = htmlSource;\n\n/** The viewer's stylesheet, for serving alongside a rendered document. */\nconst css: string = cssSource;\n\n/** The viewer's module bundle, for serving alongside a rendered document. */\nconst js: string = jsSource;\n\nexport type { ViewerAssets } from '../options';\nexport type { RenderViewerHtmlOptions, ViewerBootstrap } from './render-html';\nexport { renderViewerHtml } from './render-html';\n\nexport { html, css, js };\n"],"names":["html","css","js"],"mappings":";;;;;;AAyDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,OAAe,EAAE,WAAqB,KAAI;IAC3E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,CAAA,+BAAA,EAAkC,MAAM,CAAC,OAAO,CAAC,CAAA,mBAAA,CAAqB,CAAC;IAC3F;IACA,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC;AAC/C,CAAC;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,CAAC,KAAc,KAAI;AAC1C,IAAA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;AACtB,SAAA,OAAO,CAAC,IAAI,EAAE,SAAS;AACvB,SAAA,OAAO,CAAC,SAAS,EAAE,SAAS;AAC5B,SAAA,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;AACtC,CAAC;AAED;AACA;AACA;AACA,MAAM,eAAe,GAAG,CAAC,KAAa,KAAI;AACtC,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AAC3G,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,MAAc,KAAI;IAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;AACrC,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AAM,GAAG,GAAW;AAEpB;AACA,MAAM,EAAE,GAAW;;"}
|
package/dist/viewer.css
CHANGED
|
@@ -11,14 +11,6 @@
|
|
|
11
11
|
--sse-bkg-darkest: #141414;
|
|
12
12
|
--sse-bkg-light: #444;
|
|
13
13
|
--canvas-opacity: 1;
|
|
14
|
-
--sse-lift: 0px;
|
|
15
|
-
}
|
|
16
|
-
@media (pointer: coarse) {
|
|
17
|
-
.sse-viewer {
|
|
18
|
-
--sse-lift: var(--sse-experimental-touch-inset-bottom, 0px);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
.sse-viewer {
|
|
22
14
|
position: relative;
|
|
23
15
|
width: 100%;
|
|
24
16
|
height: 100%;
|
|
@@ -138,19 +130,10 @@
|
|
|
138
130
|
.sse-viewer .sse-controlsHint {
|
|
139
131
|
position: absolute;
|
|
140
132
|
right: max(16px, env(safe-area-inset-right));
|
|
141
|
-
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px
|
|
142
|
-
max-height: calc(100% - 16px - calc(max(16px, env(safe-area-inset-bottom)) + 70px + var(--sse-lift)));
|
|
143
|
-
box-sizing: border-box;
|
|
144
|
-
overflow-y: auto;
|
|
145
|
-
overscroll-behavior: contain;
|
|
146
|
-
}
|
|
147
|
-
.sse-viewer .sse-controlsHint,
|
|
148
|
-
.sse-viewer .sse-controlsHint * {
|
|
149
|
-
touch-action: pan-y;
|
|
150
|
-
}
|
|
151
|
-
.sse-viewer .sse-controlsHint {
|
|
133
|
+
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px);
|
|
152
134
|
min-width: 200px;
|
|
153
135
|
max-width: calc(100% - 32px);
|
|
136
|
+
box-sizing: border-box;
|
|
154
137
|
padding: 8px 8px 8px 12px;
|
|
155
138
|
border-radius: 16px;
|
|
156
139
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
@@ -324,7 +307,7 @@
|
|
|
324
307
|
}
|
|
325
308
|
.sse-viewer .sse-loadingWrap {
|
|
326
309
|
position: absolute;
|
|
327
|
-
bottom:
|
|
310
|
+
bottom: 120px;
|
|
328
311
|
left: 50%;
|
|
329
312
|
transform: translate(-50%, 0);
|
|
330
313
|
width: min(380px, 100% - 32px);
|
|
@@ -352,7 +335,7 @@
|
|
|
352
335
|
position: absolute;
|
|
353
336
|
left: max(16px, env(safe-area-inset-left));
|
|
354
337
|
right: max(16px, env(safe-area-inset-right));
|
|
355
|
-
bottom:
|
|
338
|
+
bottom: max(16px, env(safe-area-inset-bottom));
|
|
356
339
|
display: flex;
|
|
357
340
|
flex-direction: column;
|
|
358
341
|
}
|
|
@@ -484,17 +467,7 @@
|
|
|
484
467
|
.sse-viewer .sse-settingsPanel {
|
|
485
468
|
position: absolute;
|
|
486
469
|
right: max(16px, env(safe-area-inset-right));
|
|
487
|
-
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px
|
|
488
|
-
max-height: calc(100% - 16px - calc(max(16px, env(safe-area-inset-bottom)) + 70px + var(--sse-lift)));
|
|
489
|
-
box-sizing: border-box;
|
|
490
|
-
overflow-y: auto;
|
|
491
|
-
overscroll-behavior: contain;
|
|
492
|
-
}
|
|
493
|
-
.sse-viewer .sse-settingsPanel,
|
|
494
|
-
.sse-viewer .sse-settingsPanel * {
|
|
495
|
-
touch-action: pan-y;
|
|
496
|
-
}
|
|
497
|
-
.sse-viewer .sse-settingsPanel {
|
|
470
|
+
bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px);
|
|
498
471
|
padding: 12px;
|
|
499
472
|
border-radius: 16px;
|
|
500
473
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
@@ -790,7 +763,7 @@
|
|
|
790
763
|
.sse-viewer .sse-joystickBase {
|
|
791
764
|
position: absolute;
|
|
792
765
|
left: 70px;
|
|
793
|
-
bottom:
|
|
766
|
+
bottom: 140px;
|
|
794
767
|
width: 56px;
|
|
795
768
|
height: 100px;
|
|
796
769
|
transform: translate(-50%, 50%);
|
|
@@ -942,7 +915,7 @@
|
|
|
942
915
|
.sse-viewer .sse-xrHint {
|
|
943
916
|
position: absolute;
|
|
944
917
|
left: 50%;
|
|
945
|
-
bottom:
|
|
918
|
+
bottom: 96px;
|
|
946
919
|
transform: translateX(-50%);
|
|
947
920
|
padding: 12px 20px;
|
|
948
921
|
border-radius: 20px;
|
package/dist/viewer.d.ts
CHANGED
|
@@ -32,7 +32,8 @@ type ViewerAssets = {
|
|
|
32
32
|
type ViewerFlags = {
|
|
33
33
|
/**
|
|
34
34
|
* Requested renderer; the engine falls back to WebGL when WebGPU is unavailable. Default
|
|
35
|
-
* `webgpu`.
|
|
35
|
+
* `webgpu`. For now the Quest Browser, whose WebGPU cannot host an XR session, gets `webgl`
|
|
36
|
+
* whatever is requested, unless the page url has `?webgpu`. Both are temporary.
|
|
36
37
|
*/
|
|
37
38
|
renderer?: 'webgl' | 'webgpu';
|
|
38
39
|
/**
|
|
@@ -44,14 +45,6 @@ type ViewerFlags = {
|
|
|
44
45
|
* fallback prompt live in that ui, so a headless host owns those affordances too.
|
|
45
46
|
*/
|
|
46
47
|
ui?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Css pixels by which the toolbar, and everything else anchored to the viewer's bottom edge,
|
|
49
|
-
* is lifted, so chrome a host app draws over the bottom of the viewer does not cover it. On
|
|
50
|
-
* touch devices (a coarse primary pointer) only; elsewhere the toolbar stays at the edge.
|
|
51
|
-
* Clamped to 0–200. Defaults to `0`. Experimental: it may be renamed or removed in a minor
|
|
52
|
-
* release.
|
|
53
|
-
*/
|
|
54
|
-
experimentalTouchInsetBottom?: number;
|
|
55
48
|
/** Show the centre reticle in desktop fly/walk mode with gaming controls. Defaults to `false`. */
|
|
56
49
|
reticle?: boolean;
|
|
57
50
|
/** Start with the camera animation paused. */
|
|
@@ -250,7 +243,8 @@ type State = {
|
|
|
250
243
|
/**
|
|
251
244
|
* In XR with tracked hands, a left fist held upright for two seconds, the right hand open,
|
|
252
245
|
* puts the scene or object in miniature on top of the fist, like an ice cream in its cone,
|
|
253
|
-
* until the hand opens
|
|
246
|
+
* until the hand opens; with controllers, the left grip squeezed does the same on the
|
|
247
|
+
* controller's top face. Persisted; on by default. The XR menu offers it as Ice Cream.
|
|
254
248
|
*/
|
|
255
249
|
iceCream: boolean;
|
|
256
250
|
/**
|