"""Example of a composable curve deformation loaded with --plugin.""" import math from spatial_lab.kernel import register_operator @register_operator('wave-z', version=1, inputs=('path',), description='Displace a curve along world Z by a sinusoid of world X.') def wave_z(context, params, inputs): path = inputs['path'] if path['kind'] != 'curve': raise ValueError('wave-z requires a curve') amplitude = context.number(params.get('amplitude', 1)) wavelength = context.number(params.get('wavelength', 6)) if wavelength <= 0: raise ValueError('wavelength must be positive') points = [[x, y, z + amplitude * math.sin(math.tau * x / wavelength)] for x, y, z in path['points']] return {'kind': 'curve', 'points': points, 'closed': path['closed']}