Create transformations based on a square defining the view port for animations and dynamic framing. This is based on the old but really great dCam source by @Luckyde.
I came across a small issue, that when using regular boxes instead of a symbol in Hype the transformation is slightly off duo to the way Hype reports width and height including borders. Hence, I added some CSS to create the border on the camera in this example. This CSS was added to the code base starting from version 1.2.4 and remember to avoid Hype native borders on cameras for the highest precision.
β look at project 1.2.4 Added border style for IDE, HypeDynamicCamera.hideBorderInIDE, .dynamic-camera-no-border and --dynamic-camera-border
I added the border for the cameras through the extension because adding them using the Hype API introduces calculation problems (as Hype adds the border width in contrast to the default box model). Every rectangle that gets the additional attribute data-dynamic-camera also gets a border. Remove any border in Hype for most precise results. These borders are only applied in the Hype IDE. If you want to disable borders on a specific camera, just add dynamic-camera-no-border as a class. If you want to have a specific border, just define and add a class setting the CSS variable --dynamic-camera-border either as a class name or :root
.dynamic-camera-green-border {
--dynamic-camera-border: solid green 4px;
}
I updated all the example files to use the built-in border, rather than one added through Hype.
If for some reason you want to hide borders in the IDE you can add HypeDynamicCamera.hideBorderInIDE() to Head HTML in a script tag.
Playing around with parsing skew and I also replaced the one remaining Matrix calculation with a getter from the API. Also, adding support to retain the translation of the stage in a multi stage setup.
β look at project 1.2.5 Fixed stage selector to be more user-friendly by adding a new stageFit and exposing showCamera to data attributes
This update introduces new defaults to simplify stage assignment and enable the use of a camera with a different aspect ratio than the scene. It utilizes the same logic as object fitting (contain, cover, and fill, with contain as the default). Additionally, grouping the camera and stage allows for movement within the scene. To conceal elements extending beyond the bounds, set the container to 'hidden'.