visual-song 0.12.1 → 0.12.2
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 -1
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ type VisualSongRef = {
|
|
|
52
52
|
updateLayout(): void;
|
|
53
53
|
setVertexShaderTransition(shader: string, mode: number, time: number, vertexCount: number, backgroundColor: Float32Array, easingType: EasingType): boolean;
|
|
54
54
|
_render(): void;
|
|
55
|
-
|
|
55
|
+
setUseCustomResolution(use: boolean, width?: number, height?: number): void;
|
|
56
56
|
};
|
|
57
57
|
type Props = {
|
|
58
58
|
style?: React.CSSProperties;
|
package/dist/index.js
CHANGED
|
@@ -6208,7 +6208,11 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6208
6208
|
const canvasWrapperRef = useRef(null);
|
|
6209
6209
|
const glContextRef = useRef(null);
|
|
6210
6210
|
const module = useRef(null);
|
|
6211
|
-
const
|
|
6211
|
+
const resolutionRef = useRef({
|
|
6212
|
+
width: 0,
|
|
6213
|
+
height: 0
|
|
6214
|
+
});
|
|
6215
|
+
const useCustomResolutionRef = useRef(false);
|
|
6212
6216
|
useImperativeHandle(ref, ()=>({
|
|
6213
6217
|
resumeMainLoop () {
|
|
6214
6218
|
module.current.resumeMainLoop();
|
|
@@ -6294,12 +6298,11 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6294
6298
|
_render () {
|
|
6295
6299
|
module.current.frame();
|
|
6296
6300
|
},
|
|
6297
|
-
|
|
6298
|
-
|
|
6301
|
+
setUseCustomResolution (use, width, height) {
|
|
6302
|
+
useCustomResolutionRef.current = use;
|
|
6303
|
+
resolutionRef.current.width = width ?? 0;
|
|
6304
|
+
resolutionRef.current.height = height ?? 0;
|
|
6299
6305
|
updateLayout();
|
|
6300
|
-
},
|
|
6301
|
-
getIsSquare () {
|
|
6302
|
-
return isSquareRef.current;
|
|
6303
6306
|
}
|
|
6304
6307
|
}), []);
|
|
6305
6308
|
useEffect(()=>{
|
|
@@ -6454,24 +6457,22 @@ const VisualSong = /*#__PURE__*/ forwardRef(function VisualSong({ style, mainLoo
|
|
|
6454
6457
|
if (!wrapperWidth || !wrapperHeight) {
|
|
6455
6458
|
return;
|
|
6456
6459
|
}
|
|
6457
|
-
|
|
6458
|
-
let canvasHeight = wrapperHeight;
|
|
6459
|
-
if (isSquareRef.current) {
|
|
6460
|
-
canvasWidth = Math.min(wrapperWidth, wrapperHeight);
|
|
6461
|
-
canvasHeight = canvasWidth;
|
|
6460
|
+
if (useCustomResolutionRef.current) {
|
|
6462
6461
|
const divAspectRatio = wrapperWidth / wrapperHeight;
|
|
6463
|
-
|
|
6462
|
+
const engineAspectRatio = resolutionRef.current.width / resolutionRef.current.height;
|
|
6463
|
+
if (engineAspectRatio > divAspectRatio) {
|
|
6464
6464
|
canvas.style.setProperty("width", "100%");
|
|
6465
|
-
canvas.style.setProperty("height", `${
|
|
6465
|
+
canvas.style.setProperty("height", `${canvas.offsetWidth / engineAspectRatio}px`);
|
|
6466
6466
|
} else {
|
|
6467
|
-
canvas.style.setProperty("width", `${Math.floor(canvasWidth)}px`);
|
|
6468
6467
|
canvas.style.setProperty("height", "100%");
|
|
6468
|
+
canvas.style.setProperty("width", `${Math.floor(canvas.offsetHeight * engineAspectRatio)}px`);
|
|
6469
6469
|
}
|
|
6470
|
+
_resizeRenderer(window.devicePixelRatio * canvas.offsetWidth, window.devicePixelRatio * canvas.offsetHeight);
|
|
6470
6471
|
} else {
|
|
6471
6472
|
canvas.style.setProperty("width", "100%");
|
|
6472
6473
|
canvas.style.setProperty("height", "100%");
|
|
6474
|
+
_resizeRenderer(window.devicePixelRatio * wrapperWidth, window.devicePixelRatio * wrapperHeight);
|
|
6473
6475
|
}
|
|
6474
|
-
_resizeRenderer(window.devicePixelRatio * canvasWidth, window.devicePixelRatio * canvasHeight);
|
|
6475
6476
|
}
|
|
6476
6477
|
function destroy() {
|
|
6477
6478
|
if (module.current) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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