| 162 | |
| 163 | |
| 164 | def display(shape): |
| 165 | |
| 166 | payload: List[Dict[str, Any]] = [] |
| 167 | |
| 168 | if isinstance(shape, Shape): |
| 169 | shape_edges, shape_faces = toString(shape) |
| 170 | |
| 171 | payload.append( |
| 172 | dict( |
| 173 | shape=shape_edges, |
| 174 | color=(0.0, 0.0, 0.0, 1.0), |
| 175 | position=[0, 0, 0], |
| 176 | orientation=[0, 0, 0], |
| 177 | ) |
| 178 | ) |
| 179 | payload.append( |
| 180 | dict( |
| 181 | shape=shape_faces, |
| 182 | color=DEFAULT_COLOR + (1,), |
| 183 | position=[0, 0, 0], |
| 184 | orientation=[0, 0, 0], |
| 185 | ) |
| 186 | ) |
| 187 | elif isinstance(shape, Assembly): |
| 188 | payload = toJSON(shape) |
| 189 | else: |
| 190 | raise ValueError(f"Type {type(shape)} is not supported") |
| 191 | |
| 192 | code = TEMPLATE.format(data=dumps(payload), element="element", ratio=0.5) |
| 193 | |
| 194 | return Javascript(code) |