Multiple patches, embedded on same page? #595
-
Do you have some tips on how to embed multiple patches on the same website? <script type="text/javascript" src="/src/cables/patch1/js/libs.core.min.js"></script>
<script type="text/javascript" src="/src/cables/patch1/js/cables.min.js"></script>
<script type="text/javascript" src="/src/cables/patch1/js/ops.js"></script>
<script type="text/javascript" src="/src/cables/patch1/js/cgl_shadermodifier.js"></script>
<script type="text/javascript" src="/src/cables/patch1/js/cgl_copytexture.js"></script> const patch1 = new CABLES.Patch({
patchFile: 'patch1/patch.json',
glCanvasId: 'canvas1',
})
const patch2 = new CABLES.Patch({
patchFile: 'patch2/patch.json',
glCanvasId: 'canvas2',
})
const patch3 = new CABLES.Patch({
patchFile: 'patch3/patch.json',
glCanvasId: 'canvas3',
}) Which of the JavaScript files do I need to load per patch? Or asked differently: which of the JavaScript files do I only need to load once (from patch 1)? For responsiveness, I would need to create a ResizeObserver for each canvas, I guess. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
window.addEventListener("resize", ...); should be fine for "responsiveness". |
Beta Was this translation helpful? Give feedback.
libs.core.min.js
andcables.min.js
can be shared, ops.js basically needs to be combined, or renamed toops1.js
,ops2.js
and so on. to not have duplicate ops, we have that option-C
in https://github.com/cables-gl/cables-cli, maybe give that a try.window.addEventListener("resize", ...);
window.addEventListener("orientationchange", ...);
should be fine for "responsiveness".