@playcanvas/supersplat-viewer 1.30.0 → 1.30.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/README.md +9 -6
- package/dist/index.d.ts +8 -5
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/public/index.html +6 -0
- package/public/index.js +12 -5
- 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';\n\n/**\n * Asset urls and settings the embedder supplies to the viewer.\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 */\ntype ViewerBootstrap = {\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 /** Splat url. May be a `data:` uri, for a document with no sibling files. */\n contentUrl?: string;\n /** Poster image shown, blurred, while the splat loads. */\n posterUrl?: string;\n /** Equirectangular skybox texture url. */\n skyboxUrl?: string;\n /** Collision data url, for walk mode. A `.glb` is treated as a mesh, otherwise voxels. */\n collisionUrl?: 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 \\{ main \\} 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/**\n * The viewer's stylesheet.\n *\n * @deprecated Use {@link renderViewerHtml} instead, which can inline it for you.\n */\nconst css: string = cssSource;\n\n/** The viewer's module bundle, for serving alongside a rendered document. */\nconst js: string = jsSource;\n\nexport type { RenderViewerHtmlOptions, ViewerBootstrap } from './render-html';\nexport { renderViewerHtml } from './render-html';\n\nexport { html, css, js };\n"],"names":["html","css","js"],"mappings":";;;;;;AA6DA;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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EAAsD,IAAI,CAAA,SAAA,CAAW,CAC9E;IACL;AAEA,IAAA,OAAO,MAAM;AACjB;;ACjMA;;;;;;AAMG;AACH,MAAM,IAAI,GAAW;AAErB;;;;AAIG;AACH,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';\n\n/**\n * Asset urls and settings the embedder supplies to the viewer.\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 */\ntype ViewerBootstrap = {\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 /** Splat url. May be a `data:` uri, for a document with no sibling files. */\n contentUrl?: string;\n /**\n * Filename describing {@link ViewerBootstrap.contentUrl}, e.g. `scene.sog`. The splat\n * format is chosen by the name's extension, so this is required when the url itself has\n * no usable name — a `data:` uri. Ignored when a `?content=` url param overrides the url\n * it describes.\n */\n contentFilename?: string;\n /** Poster image shown, blurred, while the splat loads. */\n posterUrl?: string;\n /** Equirectangular skybox texture url. */\n skyboxUrl?: string;\n /** Collision data url, for walk mode. A `.glb` is treated as a mesh, otherwise voxels. */\n collisionUrl?: 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 \\{ main \\} 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 { RenderViewerHtmlOptions, ViewerBootstrap } from './render-html';\nexport { renderViewerHtml } from './render-html';\n\nexport { html, css, js };\n"],"names":["html","css","js"],"mappings":";;;;;;AAoEA;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,CA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A,mDAAA,EAAsD,IAAI,CAAA,SAAA,CAAW,CAC9E;IACL;AAEA,IAAA,OAAO,MAAM;AACjB;;ACxMA;;;;;;AAMG;AACH,MAAM,IAAI,GAAW;AAErB;AACA,MAAM,GAAG,GAAW;AAEpB;AACA,MAAM,EAAE,GAAW;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/supersplat-viewer",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.1",
|
|
4
4
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://github.com/playcanvas/supersplat-viewer#readme",
|
|
6
6
|
"description": "Viewer for https://superspl.at",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"autoprefixer": "10.5.4",
|
|
53
53
|
"concurrently": "9.2.4",
|
|
54
54
|
"eslint": "9.39.5",
|
|
55
|
-
"globals": "17.
|
|
56
|
-
"playcanvas": "2.21.
|
|
57
|
-
"postcss": "8.5.
|
|
55
|
+
"globals": "17.11.0",
|
|
56
|
+
"playcanvas": "2.21.4",
|
|
57
|
+
"postcss": "8.5.26",
|
|
58
58
|
"prettier": "3.9.6",
|
|
59
|
-
"publint": "0.3.
|
|
60
|
-
"rollup": "4.62.
|
|
59
|
+
"publint": "0.3.24",
|
|
60
|
+
"rollup": "4.62.5",
|
|
61
61
|
"rollup-plugin-dts": "6.5.1",
|
|
62
62
|
"rollup-plugin-scss": "4.0.1",
|
|
63
63
|
"rollup-plugin-string": "3.0.0",
|
|
64
|
-
"sass": "1.
|
|
64
|
+
"sass": "1.103.1",
|
|
65
65
|
"serve": "14.2.6",
|
|
66
66
|
"typescript": "5.9.3"
|
|
67
67
|
},
|
package/public/index.html
CHANGED
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
const settingsUrl = url.searchParams.get('settings') ?? bootstrap.settingsUrl ?? './settings.json';
|
|
43
43
|
const contentUrl = url.searchParams.get('content') ?? bootstrap.contentUrl ?? './scene.compressed.ply';
|
|
44
44
|
|
|
45
|
+
// Names the bootstrap's contentUrl when the url itself has no usable name (a data:
|
|
46
|
+
// uri, say) — the splat format is chosen by the name's extension. Ignored when a
|
|
47
|
+
// ?content= override replaces the url it describes.
|
|
48
|
+
const contentFilename = url.searchParams.has('content') ? null : (bootstrap.contentFilename ?? null);
|
|
49
|
+
|
|
45
50
|
const renderer = url.searchParams.has('webgl') ? 'webgl' : 'webgpu';
|
|
46
51
|
|
|
47
52
|
const budgetParam = url.searchParams.get('budget');
|
|
@@ -52,6 +57,7 @@
|
|
|
52
57
|
skyboxUrl,
|
|
53
58
|
collisionUrl,
|
|
54
59
|
contentUrl,
|
|
60
|
+
contentFilename,
|
|
55
61
|
contents: fetch(contentUrl),
|
|
56
62
|
noui: url.searchParams.has('noui'),
|
|
57
63
|
noanim: url.searchParams.has('noanim'),
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = "GpuTimings";
|
|
2
2
|
|
|
3
|
-
const version$1 = "2.21.
|
|
4
|
-
const revision = "
|
|
3
|
+
const version$1 = "2.21.4";
|
|
4
|
+
const revision = "e287e0c";
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for (const prop in ex) {
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -42717,6 +42717,7 @@ void main(void) {
|
|
|
42717
42717
|
#define MODIFIED_DEPTH
|
|
42718
42718
|
#endif
|
|
42719
42719
|
#if SHADOW_TYPE == VSM_16F || SHADOW_TYPE == VSM_32F
|
|
42720
|
+
if (!(depth >= 0.0 && depth <= 1.0)) discard;
|
|
42720
42721
|
#if SHADOW_TYPE == VSM_32F
|
|
42721
42722
|
float exponent = 15.0;
|
|
42722
42723
|
#else
|
|
@@ -48224,6 +48225,9 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
48224
48225
|
#define MODIFIED_DEPTH
|
|
48225
48226
|
#endif
|
|
48226
48227
|
#if SHADOW_TYPE == VSM_16F || SHADOW_TYPE == VSM_32F
|
|
48228
|
+
if (!(depth >= 0.0 && depth <= 1.0)) {
|
|
48229
|
+
discard;
|
|
48230
|
+
}
|
|
48227
48231
|
#if SHADOW_TYPE == VSM_32F
|
|
48228
48232
|
var exponent: f32 = 15.0;
|
|
48229
48233
|
#else
|
|
@@ -83411,7 +83415,7 @@ const importSettings = (settings) => {
|
|
|
83411
83415
|
return result;
|
|
83412
83416
|
};
|
|
83413
83417
|
|
|
83414
|
-
var version = "1.30.
|
|
83418
|
+
var version = "1.30.1";
|
|
83415
83419
|
|
|
83416
83420
|
class Tooltip {
|
|
83417
83421
|
register;
|
|
@@ -92331,9 +92335,12 @@ const initXr = (global) => {
|
|
|
92331
92335
|
};
|
|
92332
92336
|
|
|
92333
92337
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
92334
|
-
const { contents, contentUrl } = config;
|
|
92338
|
+
const { contents, contentUrl, contentFilename } = config;
|
|
92335
92339
|
const c = contents;
|
|
92336
|
-
|
|
92340
|
+
// the filename's extension selects the gsplat parser, so a url with no usable name (a
|
|
92341
|
+
// data: uri) needs the config to name its content instead; falsy (an empty name) falls
|
|
92342
|
+
// back to the url-derived name
|
|
92343
|
+
const filename = contentFilename || new URL(contentUrl, location.href).pathname.split('/').pop();
|
|
92337
92344
|
const data = filename.toLowerCase() === 'meta.json' ? await (await contents).json() : undefined;
|
|
92338
92345
|
const asset = new Asset(filename, 'gsplat', { url: contentUrl, filename, contents: c }, data);
|
|
92339
92346
|
return new Promise((resolve, reject) => {
|