Changes 2020-10-20
This update to DynaMaker, which should not break any existing projects, focuses on making it easier to create and use geometry.
Deprecations
You will notice that some classes and functions that you've used previously have been deprecated. Deprecated classes and functions still work, but should be avoided in new code that you write.
Deprecated classes and functions will appear as strikethrough in the editor
Action Events
The way that actions related to the product are called from the UI code has changed for new projects. The new way brings a better developer experience through code completion and type checking.
// old way
Studio.actionEvent('generate-configurator')
// new way
ACTIONS.generateConfigurator()
The Geometry API
The way that we create and group geometry (models and sketches) has changed with this update.
- The new class
SKYCAD.GeometryGroup
should be used for grouping geometry (parent-child structure) SKYCAD.ModelInstance
should no longer be used as a parent of other models viaaddChildInstance()
ComponentInstance.getModelInstance()
is replaced byComponentInstance.generateGeometry()
and now returns aSKYCAD.GeometryGroup
SKYCAD.GeometryOnPlane
has been deprecated in favor of the similarSKYCAD.LayoutOnPlane
SKYCAD.Model
has been renamed toSKYCAD.ParametricModel
to differentiate it fromSKYCAD.MeshModel
SKYCAD.ModelMaterial
has been renamed toSKYCAD.Material
Geometry And The Component Handler
The component handler has been updated with some new functionality that makes it simple to gather all the geometry from your components!
componentHandler.generateAllGeometry(): SKYCAD.GeometryGroup
componentHandler.generateGeometry(componentType: string): SKYCAD.GeometryGroup
componentHandler.generateAllLightweightGeometry(): SKYCAD.GeometryGroup
componentHandler.generateLightweightGeometry(componentType: string): SKYCAD.GeometryGroup
These functions positions the geometry with respect to each component instance. They require that your components
implement the generateGeometry()
and generateLightweightGeometry()
functions respectively.
Updating The Scene
For new projects, getModels()
and getSketches()
in the COMPONENTS tab of the application-maker have been
replaced by updateGeometry()
and updateLightweightGeometry()
. This gives you more fine grained control over what
geometry should update and when.
// the old way
export function getModels(manager: STUDIO.Manager) {
// ...
}
export function getSketches(manager: STUDIO.Manager) {
// ...
}
// the new way
/**
* Add new Geometry to world depending on app state
*/
export function updateGeometry(data: STUDIO.DataForUpdateGeometry, worldControls: STUDIO.WorldControls) {
const geometryGroup = new SKYCAD.GeometryGroup()
switch (data.designStep) {
case CONSTANTS.DESIGN_STEP.PRODUCT:
geometryGroup.addGeometry(data.componentHandler.generateGeometry(CONSTANTS.COMPONENT_TYPE.MAIN))
break
case CONSTANTS.DESIGN_STEP.EXPORT:
geometryGroup.addGeometry(data.componentHandler.generateGeometry(CONSTANTS.COMPONENT_TYPE.MAIN))
break
}
worldControls.updateGeometry(geometryGroup, { groupId: 'primary' })
}
/**
* Optional lightweight geometry
*/
export function updateLightweightGeometry(data: STUDIO.DataForUpdateGeometry, worldControls: STUDIO.WorldControls) {
const geometry = data.componentHandler.generateAllLightweightGeometry()
worldControls.updateGeometry(geometry, { groupId: 'lightweight' })
}
Instead of calling Studio.update()
you should use Studio.requestGeometryUpdate()
and
Studio.requestLightweightGeometryUpdate()
together with this new update geometry pattern.
Components And The Configurator
New components created from this point forward have a new pattern for generating their configurator(s). Instead of
implementing the configure()
function on the component, you should export one or more functions from the
PARAMETERS tab in the component-maker.
You can switch between different configurators with the dropdown in the upper left corner
In the application, use the generator-functions to generate the configurator instead of calling configure()
.
// old way
export function actionEvent(type: string, args: any, manager: STUDIO.Manager) {
// ...
switch (type) {
case 'configure-component': return component.configure()
}
}
// new way
export function configureMainComponent() {
const component = getMainComponent()
return COMPONENT1.generateConfigurator(component)
}