react-godot-shader-preview 0.6.2 → 0.6.4
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/GodotMaterialPreview.css +25 -0
- package/dist/GodotMaterialPreviewView.js +1 -1
- package/dist/style.css +25 -0
- package/godot/embed.html +2 -3
- package/package.json +1 -1
|
@@ -212,3 +212,28 @@
|
|
|
212
212
|
@media (max-width: 700px) {
|
|
213
213
|
.rgs-previewWrap { flex: 0 0 auto; width: 100%; max-width: 400px; }
|
|
214
214
|
}
|
|
215
|
+
|
|
216
|
+
/* Print: keep iframe and preview block on one page, avoid breaks inside */
|
|
217
|
+
@media print {
|
|
218
|
+
.rgs-root,
|
|
219
|
+
.rgs-previewWrap,
|
|
220
|
+
.rgs-preview,
|
|
221
|
+
.rgs-canvas {
|
|
222
|
+
break-inside: avoid;
|
|
223
|
+
page-break-inside: avoid;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.rgs-previewOverlays,
|
|
227
|
+
.rgs-modeStrip,
|
|
228
|
+
.rgs-statusOverlay,
|
|
229
|
+
.rgs-paramsPanel,
|
|
230
|
+
.rgs-paramRow {
|
|
231
|
+
break-inside: avoid;
|
|
232
|
+
page-break-inside: avoid;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Keep iframe content from breaking; canvas is the iframe */
|
|
236
|
+
.rgs-canvas {
|
|
237
|
+
overflow: hidden;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -45,7 +45,7 @@ const cn = {
|
|
|
45
45
|
export function GodotMaterialPreviewView({ iframeRef, embedUrl, previewWidth, showMeshSwitch, allowMouseInteraction, showParameters, status, godotLoading, uniforms, samplerState, displayMode, setDisplayMode, updateUniform, updateSampler, setParameter, className, }) {
|
|
46
46
|
const rootStyle = previewWidth != null ? { flex: `0 0 ${previewWidth}px` } : undefined;
|
|
47
47
|
const rootClass = [cn.root, previewWidth == null ? cn.rootFill : '', className].filter(Boolean).join(' ');
|
|
48
|
-
return (_jsxs("div", { className: rootClass, style: rootStyle, children: [_jsx("div", { className: cn.previewWrap, children: _jsxs("div", { className: cn.preview, children: [_jsx("iframe", { ref: iframeRef, src: embedUrl, title: "Shader preview", className: cn.canvas }), !allowMouseInteraction && _jsx("div", { className: cn.mouseBlockOverlay, "aria-hidden": true }), _jsxs("div", { className: cn.previewOverlays, children: [showMeshSwitch && (_jsxs("div", { className: cn.modeStrip, role: "group", "aria-label": "Preview display mode", children: [_jsx("button", { type: "button", className: `${cn.modeStripButton} ${displayMode === 'Circle' ? cn.modeStripButtonActive : ''}`, onClick: () => setDisplayMode('Circle'), "aria-pressed": displayMode === 'Circle', "aria-label": "Sphere", children: _jsx(CircleIcon, {}) }), _jsx("button", { type: "button", className: `${cn.modeStripButton} ${displayMode === 'Plane' ? cn.modeStripButtonActive : ''}`, onClick: () => setDisplayMode('Plane'), "aria-pressed": displayMode === 'Plane', "aria-label": "Plane", children: _jsx(DiamondIcon, {}) })] })), godotLoading && (_jsx("div", { className: cn.loadingOverlay, children: _jsx("div", { children: status?.message ?? 'Loading...' }) })), status && !godotLoading && (_jsx("div", { className: cn.statusOverlay, children: _jsx("span", { className: status.error ? cn.statusError : cn.statusSuccess, children: status.message }) }))] })] }) }), showParameters && (_jsxs("div", { className: cn.paramsPanel, children: [_jsx("div", { className: cn.paramsTitle, children: uniforms.length > 0 ? 'Shader parameters' : 'Parameters' }), uniforms.length > 0 ? (uniforms.map((u, i) => (_jsx(ParamRow, { u: u, i: i, samplerState: samplerState, updateUniform: updateUniform, updateSampler: updateSampler, setParameter: setParameter }, u.name)))) : (_jsx("p", { className: cn.paramsPlaceholder, children: "Load a shader with uniform variables to see and edit parameters here." }))] }))] }));
|
|
48
|
+
return (_jsxs("div", { className: rootClass, style: rootStyle, children: [_jsx("div", { className: cn.previewWrap, children: _jsxs("div", { className: cn.preview, children: [_jsx("iframe", { ref: iframeRef, src: embedUrl, title: "Shader preview", className: cn.canvas, tabIndex: -1 }), !allowMouseInteraction && _jsx("div", { className: cn.mouseBlockOverlay, "aria-hidden": true }), _jsxs("div", { className: cn.previewOverlays, children: [showMeshSwitch && (_jsxs("div", { className: cn.modeStrip, role: "group", "aria-label": "Preview display mode", children: [_jsx("button", { type: "button", className: `${cn.modeStripButton} ${displayMode === 'Circle' ? cn.modeStripButtonActive : ''}`, onClick: () => setDisplayMode('Circle'), "aria-pressed": displayMode === 'Circle', "aria-label": "Sphere", children: _jsx(CircleIcon, {}) }), _jsx("button", { type: "button", className: `${cn.modeStripButton} ${displayMode === 'Plane' ? cn.modeStripButtonActive : ''}`, onClick: () => setDisplayMode('Plane'), "aria-pressed": displayMode === 'Plane', "aria-label": "Plane", children: _jsx(DiamondIcon, {}) })] })), godotLoading && (_jsx("div", { className: cn.loadingOverlay, children: _jsx("div", { children: status?.message ?? 'Loading...' }) })), status && !godotLoading && (_jsx("div", { className: cn.statusOverlay, children: _jsx("span", { className: status.error ? cn.statusError : cn.statusSuccess, children: status.message }) }))] })] }) }), showParameters && (_jsxs("div", { className: cn.paramsPanel, children: [_jsx("div", { className: cn.paramsTitle, children: uniforms.length > 0 ? 'Shader parameters' : 'Parameters' }), uniforms.length > 0 ? (uniforms.map((u, i) => (_jsx(ParamRow, { u: u, i: i, samplerState: samplerState, updateUniform: updateUniform, updateSampler: updateSampler, setParameter: setParameter }, u.name)))) : (_jsx("p", { className: cn.paramsPlaceholder, children: "Load a shader with uniform variables to see and edit parameters here." }))] }))] }));
|
|
49
49
|
}
|
|
50
50
|
function ParamRow({ u, i, samplerState, updateUniform, updateSampler, setParameter }) {
|
|
51
51
|
const state = samplerState[u.name] ?? DEFAULT_SAMPLER_STATE;
|
package/dist/style.css
CHANGED
|
@@ -212,3 +212,28 @@
|
|
|
212
212
|
@media (max-width: 700px) {
|
|
213
213
|
.rgs-previewWrap { flex: 0 0 auto; width: 100%; max-width: 400px; }
|
|
214
214
|
}
|
|
215
|
+
|
|
216
|
+
/* Print: keep iframe and preview block on one page, avoid breaks inside */
|
|
217
|
+
@media print {
|
|
218
|
+
.rgs-root,
|
|
219
|
+
.rgs-previewWrap,
|
|
220
|
+
.rgs-preview,
|
|
221
|
+
.rgs-canvas {
|
|
222
|
+
break-inside: avoid;
|
|
223
|
+
page-break-inside: avoid;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.rgs-previewOverlays,
|
|
227
|
+
.rgs-modeStrip,
|
|
228
|
+
.rgs-statusOverlay,
|
|
229
|
+
.rgs-paramsPanel,
|
|
230
|
+
.rgs-paramRow {
|
|
231
|
+
break-inside: avoid;
|
|
232
|
+
page-break-inside: avoid;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Keep iframe content from breaking; canvas is the iframe */
|
|
236
|
+
.rgs-canvas {
|
|
237
|
+
overflow: hidden;
|
|
238
|
+
}
|
|
239
|
+
}
|
package/godot/embed.html
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
9
|
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; }
|
|
10
10
|
#godot-canvas { display: block; max-width: 100%; max-height: 100%; width: 100% !important; height: 100% !important; object-fit: contain; cursor: grab;
|
|
11
|
+
break-inside: avoid; page-break-inside: avoid;
|
|
11
12
|
/* Override Godot engine inline positioning/sizing so flex centering works */
|
|
12
13
|
position: relative !important; left: auto !important; top: auto !important; min-width: 0 !important; }
|
|
13
14
|
</style>
|
|
@@ -21,9 +22,7 @@
|
|
|
21
22
|
console.error('[embed] Engine not found. index.js did not load.');
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
var baseConfig = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2830792,"index.wasm":30805867},"focusCanvas":
|
|
25
|
-
var path = window.location.pathname;
|
|
26
|
-
var assetBase = window.location.origin + path.replace(/\/[^/]*$/, '/');
|
|
25
|
+
var baseConfig = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":true,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":2830792,"index.wasm":30805867},"focusCanvas":false,"gdextensionLibs":[],"godotPoolSize":4};
|
|
27
26
|
var canvasEl = document.getElementById('godot-canvas');
|
|
28
27
|
var engine = new Engine(baseConfig);
|
|
29
28
|
var startOverrides = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-godot-shader-preview",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "React component for live Godot shader preview via WebAssembly. Load shader code, switch mesh (sphere/plane), edit uniforms and samplers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|