Skip to content

Commit 9f5cce0

Browse files
authored
Merge pull request #61 from minhsueh/animation
add CrystalToolkitAnimationScene
2 parents 2a4d3d6 + 6914155 commit 9f5cce0

File tree

2 files changed

+367
-0
lines changed

2 files changed

+367
-0
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# AUTO GENERATED FILE - DO NOT EDIT
2+
3+
import typing # noqa: F401
4+
from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401
5+
from dash.development.base_component import Component, _explicitize_args
6+
7+
ComponentType = typing.Union[
8+
str,
9+
int,
10+
float,
11+
Component,
12+
None,
13+
typing.Sequence[typing.Union[str, int, float, Component, None]],
14+
]
15+
16+
NumberType = typing.Union[
17+
typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex
18+
]
19+
20+
21+
class CrystalToolkitAnimationScene(Component):
22+
"""A CrystalToolkitAnimationScene component.
23+
24+
25+
Keyword arguments:
26+
27+
- children (optional):
28+
First child will be rendered as the settings panel. Second child
29+
will be rendered as the bottom panel (legend).
30+
31+
- id (optional):
32+
The ID used to identify this component in Dash callbacks.
33+
34+
- animation (optional):
35+
Animation type.
36+
37+
- axisView (optional):
38+
Where is the axis displayed ( 'NW' / 'NE' / 'SE' / 'SW' / 'HIDDEN'
39+
).
40+
41+
- className (optional):
42+
Class name that will wrap around the whole scene component. When
43+
enlarged, this class name is applied to the modal-content element.
44+
45+
- currentCameraState (optional):
46+
THIS PROP IS SET AUTOMATICALLY Object that maintains the current
47+
state of the camera. e.g. { position: {x: 0, y: 0, z: 0},
48+
quarternion: {x: 0, y: 0, z: 0, w: 0}, zoom: 1,
49+
setByComponentId: \"1\", following: True }.
50+
51+
- customCameraState (optional):
52+
Object for setting the scene to a custom camera state. When
53+
modified, the camera will update to new custom state. e.g. {
54+
position: {x: 0, y: 0, z: 0}, quarternion: {x: 0, y: 0, z: 0, w:
55+
0}, (optional) zoom: 1 (optional) }.
56+
57+
- data (optional):
58+
Simple3DScene JSON, the easiest way to generate this is to use the
59+
Scene class in crystal_toolkit.core.scene and its to_json method.
60+
61+
- debug (optional):
62+
Display a debug view.
63+
64+
- fileOptions (optional):
65+
List of options to show in file download dropdown.
66+
67+
- fileTimestamp (optional):
68+
THIS PROP IS SET AUTOMATICALLY Date string that represents the
69+
time fileType was set. Use this prop in dash callbacks to trigger
70+
file downloads.
71+
72+
- fileType (optional):
73+
THIS PROP IS SET AUTOMATICALLY The last file type clicked in the
74+
file download menu.
75+
76+
- imageData (optional):
77+
THIS PROP IS SET AUTOMATICALLY Data string for the image generated
78+
on image button click.
79+
80+
- imageDataTimestamp (optional):
81+
THIS PROP IS SET AUTOMATICALLY Date string that represents the
82+
time imageData was set. Use this prop in dash callbacks to trigger
83+
downloads of imageData.
84+
85+
- imageRequest (optional):
86+
Set to trigger a screenshot or scene download. Must be an object
87+
with the following structure: { \"filetype\": \"png\" // the
88+
image format (\"png\", \"dae\") } Passing this prop as an object
89+
ensures that new requests are triggered any time the prop is set.
90+
91+
- imageType (optional):
92+
File type to be downloaded as an image. Either png or dae.
93+
94+
- inletPadding (optional):
95+
Padding of the axis view.
96+
97+
- inletSize (optional):
98+
Size of the axis view.
99+
100+
- sceneSize (optional):
101+
Width / Height of the displayed component.
102+
103+
- selectedObject (optional):
104+
This points to the last clicked objects. Use it in your dash
105+
callback to know which objects are currently selected in the
106+
scene.
107+
108+
- setProps (optional):
109+
Dash-assigned callback that should be called whenever any of the
110+
properties change.
111+
112+
- settings (optional):
113+
Options used for generating scene. Supported options and their
114+
defaults are given as follows: { antialias: True, // set to
115+
False to improve performance renderer: 'webgl', // 'svg' also
116+
an option, used for unit testing transparentBackground: False,
117+
// transparent background background: '#ffffff', // background
118+
color if not transparent, sphereSegments: 32, // decrease to
119+
improve performance cylinderSegments: 16, // decrease to
120+
improve performance staticScene: True, // disable if animation
121+
required defaultZoom: 1, // 1 will zoom to fit object exactly,
122+
<1 will add padding between object and box bounds zoomToFit2D:
123+
False // if True, will zoom to fit object only along the X and Y
124+
axes (not Z) extractAxis: False // will remove the axis from
125+
the main scene isMultiSelectionEnabled: False // allow to use
126+
shift to select, secondaryObjectView: True // show the selected
127+
object in a detail view animation: 'play' | 'slider' | 'none'
128+
// choose which style of animation is use } There are several
129+
additional options used for debugging and testing, please consult
130+
the source code directly for these.
131+
132+
- showControls (optional)
133+
134+
- showExpandButton (optional)
135+
136+
- showExportButton (optional)
137+
138+
- showImageButton (optional)
139+
140+
- showPositionButton (optional)
141+
142+
- toggleVisibility (optional):
143+
Hide/show nodes in scene by its name (key), value is 1 to show the
144+
node and 0 to hide it."""
145+
_children_props = []
146+
_base_nodes = ['children']
147+
_namespace = 'dash_mp_components'
148+
_type = 'CrystalToolkitAnimationScene'
149+
150+
151+
def __init__(
152+
self,
153+
children: typing.Optional[ComponentType] = None,
154+
id: typing.Optional[typing.Union[str, dict]] = None,
155+
className: typing.Optional[typing.Any] = None,
156+
data: typing.Optional[typing.Any] = None,
157+
settings: typing.Optional[typing.Any] = None,
158+
toggleVisibility: typing.Optional[typing.Any] = None,
159+
imageRequest: typing.Optional[typing.Any] = None,
160+
imageType: typing.Optional[typing.Any] = None,
161+
imageData: typing.Optional[typing.Any] = None,
162+
imageDataTimestamp: typing.Optional[typing.Any] = None,
163+
fileOptions: typing.Optional[typing.Any] = None,
164+
fileType: typing.Optional[typing.Any] = None,
165+
fileTimestamp: typing.Optional[typing.Any] = None,
166+
selectedObject: typing.Optional[typing.Any] = None,
167+
sceneSize: typing.Optional[typing.Any] = None,
168+
axisView: typing.Optional[typing.Any] = None,
169+
inletSize: typing.Optional[typing.Any] = None,
170+
inletPadding: typing.Optional[typing.Any] = None,
171+
debug: typing.Optional[typing.Any] = None,
172+
animation: typing.Optional[typing.Any] = None,
173+
currentCameraState: typing.Optional[typing.Any] = None,
174+
customCameraState: typing.Optional[typing.Any] = None,
175+
showControls: typing.Optional[typing.Any] = None,
176+
showExpandButton: typing.Optional[typing.Any] = None,
177+
showImageButton: typing.Optional[typing.Any] = None,
178+
showExportButton: typing.Optional[typing.Any] = None,
179+
showPositionButton: typing.Optional[typing.Any] = None,
180+
**kwargs
181+
):
182+
self._prop_names = ['children', 'id', 'animation', 'axisView', 'className', 'currentCameraState', 'customCameraState', 'data', 'debug', 'fileOptions', 'fileTimestamp', 'fileType', 'imageData', 'imageDataTimestamp', 'imageRequest', 'imageType', 'inletPadding', 'inletSize', 'sceneSize', 'selectedObject', 'setProps', 'settings', 'showControls', 'showExpandButton', 'showExportButton', 'showImageButton', 'showPositionButton', 'toggleVisibility']
183+
self._valid_wildcard_attributes = []
184+
self.available_properties = ['children', 'id', 'animation', 'axisView', 'className', 'currentCameraState', 'customCameraState', 'data', 'debug', 'fileOptions', 'fileTimestamp', 'fileType', 'imageData', 'imageDataTimestamp', 'imageRequest', 'imageType', 'inletPadding', 'inletSize', 'sceneSize', 'selectedObject', 'setProps', 'settings', 'showControls', 'showExpandButton', 'showExportButton', 'showImageButton', 'showPositionButton', 'toggleVisibility']
185+
self.available_wildcard_properties = []
186+
_explicit_args = kwargs.pop('_explicit_args')
187+
_locals = locals()
188+
_locals.update(kwargs) # For wildcard attrs and excess named props
189+
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
190+
191+
super(CrystalToolkitAnimationScene, self).__init__(children=children, **args)
192+
193+
setattr(CrystalToolkitAnimationScene, "__init__", _explicitize_args(CrystalToolkitAnimationScene.__init__))
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import * as mp from '@materialsproject/mp-react-components';
2+
import React, {Component} from 'react';
3+
4+
export default class CrystalToolkitAnimationScene extends Component {
5+
render() {
6+
return (
7+
<mp.CrystalToolkitAnimationScene
8+
{...this.props}
9+
onObjectClicked={o => {
10+
this.props.setProps({selectedObject: o});
11+
}}
12+
/>
13+
);
14+
}
15+
}
16+
17+
CrystalToolkitAnimationScene.propTypes = {
18+
/**
19+
* The ID used to identify this component in Dash callbacks
20+
*/
21+
id: PropTypes.string,
22+
/**
23+
* Dash-assigned callback that should be called whenever any of the
24+
* properties change
25+
*/
26+
setProps: PropTypes.func,
27+
/**
28+
* First child will be rendered as the settings panel.
29+
* Second child will be rendered as the bottom panel (legend).
30+
*/
31+
children: PropTypes.node,
32+
/**
33+
* Class name that will wrap around the whole scene component.
34+
* When enlarged, this class name is applied to the modal-content element.
35+
*/
36+
className: PropTypes.string,
37+
/**
38+
* Simple3DScene JSON, the easiest way to generate this is to use the Scene class
39+
* in crystal_toolkit.core.scene and its to_json method.
40+
*/
41+
data: PropTypes.object,
42+
/**
43+
* Options used for generating scene.
44+
* Supported options and their defaults are given as follows:
45+
* {
46+
* antialias: true, // set to false to improve performance
47+
* renderer: 'webgl', // 'svg' also an option, used for unit testing
48+
* transparentBackground: false, // transparent background
49+
* background: '#ffffff', // background color if not transparent,
50+
* sphereSegments: 32, // decrease to improve performance
51+
* cylinderSegments: 16, // decrease to improve performance
52+
* staticScene: true, // disable if animation required
53+
* defaultZoom: 1, // 1 will zoom to fit object exactly, <1 will add padding between object and box bounds
54+
* zoomToFit2D: false // if true, will zoom to fit object only along the X and Y axes (not Z)
55+
* extractAxis: false // will remove the axis from the main scene
56+
* isMultiSelectionEnabled: false // allow to use shift to select,
57+
* secondaryObjectView: true // show the selected object in a detail view
58+
* animation: 'play' | 'slider' | 'none' // choose which style of animation is use
59+
* }
60+
* There are several additional options used for debugging and testing,
61+
* please consult the source code directly for these.
62+
*/
63+
settings: PropTypes.object,
64+
/**
65+
* Hide/show nodes in scene by its name (key), value is 1 to show the node
66+
* and 0 to hide it.
67+
*/
68+
toggleVisibility: PropTypes.object,
69+
/**
70+
* Set to trigger a screenshot or scene download.
71+
* Must be an object with the following structure:
72+
* {
73+
* "filetype": "png" // the image format ("png", "dae")
74+
* }
75+
* Passing this prop as an object ensures that
76+
* new requests are triggered any time the prop
77+
* is set.
78+
*/
79+
imageRequest: PropTypes.object,
80+
/**
81+
* THIS PROP IS SET AUTOMATICALLY
82+
* Data string for the image generated by imageRequest
83+
* This string can be downloaded as the filetype specified in your imageRequest object
84+
*/
85+
/**
86+
* File type to be downloaded as an image. Either png or dae
87+
*/
88+
imageType: PropTypes.oneOf(['png', 'dae']),
89+
/**
90+
* THIS PROP IS SET AUTOMATICALLY
91+
* Data string for the image generated on image button click
92+
*/
93+
imageData: PropTypes.string,
94+
/**
95+
* THIS PROP IS SET AUTOMATICALLY
96+
* Date string that represents the time imageData was set.
97+
* Use this prop in dash callbacks to trigger downloads of imageData.
98+
*/
99+
imageDataTimestamp: PropTypes.any,
100+
/**
101+
* List of options to show in file download dropdown
102+
*/
103+
fileOptions: PropTypes.array,
104+
/**
105+
* THIS PROP IS SET AUTOMATICALLY
106+
* The last file type clicked in the file download menu
107+
*/
108+
fileType: PropTypes.string,
109+
/**
110+
* THIS PROP IS SET AUTOMATICALLY
111+
* Date string that represents the time fileType was set.
112+
* Use this prop in dash callbacks to trigger file downloads.
113+
*/
114+
fileTimestamp: PropTypes.any,
115+
/**
116+
* This points to the last clicked objects. Use it in your dash callback
117+
* to know which objects are currently selected in the scene
118+
*
119+
*/
120+
selectedObject: PropTypes.array,
121+
/**
122+
* Width / Height of the displayed component
123+
*/
124+
sceneSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
125+
/**
126+
* Where is the axis displayed ( 'NW' / 'NE' / 'SE' / 'SW' / 'HIDDEN' )
127+
*/
128+
axisView: PropTypes.string,
129+
/**
130+
* Size of the axis view
131+
*/
132+
inletSize: PropTypes.number,
133+
/**
134+
* Padding of the axis view
135+
*/
136+
inletPadding: PropTypes.number,
137+
/**
138+
* Display a debug view
139+
*/
140+
debug: PropTypes.bool,
141+
/**
142+
* Animation type
143+
*/
144+
animation: PropTypes.string,
145+
/**
146+
* THIS PROP IS SET AUTOMATICALLY
147+
* Object that maintains the current state of the camera.
148+
* e.g.
149+
* {
150+
* position: {x: 0, y: 0, z: 0},
151+
* quarternion: {x: 0, y: 0, z: 0, w: 0},
152+
* zoom: 1,
153+
* setByComponentId: "1",
154+
* following: true
155+
* }
156+
*/
157+
currentCameraState: PropTypes.object,
158+
/**
159+
* Object for setting the scene to a custom camera state.
160+
* When modified, the camera will update to new custom state.
161+
* e.g.
162+
* {
163+
* position: {x: 0, y: 0, z: 0},
164+
* quarternion: {x: 0, y: 0, z: 0, w: 0}, (optional)
165+
* zoom: 1 (optional)
166+
* }
167+
*/
168+
customCameraState: PropTypes.object,
169+
showControls: PropTypes.bool,
170+
showExpandButton: PropTypes.bool,
171+
showImageButton: PropTypes.bool,
172+
showExportButton: PropTypes.bool,
173+
showPositionButton: PropTypes.bool,
174+
};

0 commit comments

Comments
 (0)