Skip to content

npxpy.nodes.space.Scene

Bases: _GatekeeperSpace

Class representing a scene node.

Attributes:

Name Type Description
position List[float]

Position of the scene [x, y, z].

rotation List[float]

Rotation of the scene [psi, theta, phi].

writing_direction_upward bool

Writing direction of the scene.

Source code in npxpy/nodes/space.py
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
class Scene(_GatekeeperSpace):
    """
    Class representing a scene node.

    Attributes:
        position (List[float]): Position of the scene [x, y, z].
        rotation (List[float]): Rotation of the scene [psi, theta, phi].
        writing_direction_upward (bool): Writing direction of the scene.
    """

    def __init__(
        self,
        name: str = "Scene",
        position: List[float] = [0, 0, 0],
        rotation: List[float] = [0.0, 0.0, 0.0],
        writing_direction_upward: bool = True,
    ):
        """
        Initialize a Scene node.
        """
        super().__init__("scene", name)
        self.position = position
        self.rotation = rotation
        self._writing_direction_upward = None
        self.writing_direction_upward = (
            writing_direction_upward  # Using setter
        )

    # Getter and setter for writing direction
    @property
    def writing_direction_upward(self):
        return self._writing_direction_upward

    @writing_direction_upward.setter
    def writing_direction_upward(self, value: bool):
        if not isinstance(value, bool):
            raise ValueError("writing_direction_upward must be a boolean.")
        self._writing_direction_upward = value

    def to_dict(self) -> Dict:
        """
        Convert the Scene object into a dictionary.
        """
        node_dict = super().to_dict()
        node_dict["position"] = self.position
        node_dict["rotation"] = self.rotation
        node_dict["writing_direction_upward"] = self.writing_direction_upward
        return node_dict

__init__(name='Scene', position=[0, 0, 0], rotation=[0.0, 0.0, 0.0], writing_direction_upward=True)

Initialize a Scene node.

Source code in npxpy/nodes/space.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def __init__(
    self,
    name: str = "Scene",
    position: List[float] = [0, 0, 0],
    rotation: List[float] = [0.0, 0.0, 0.0],
    writing_direction_upward: bool = True,
):
    """
    Initialize a Scene node.
    """
    super().__init__("scene", name)
    self.position = position
    self.rotation = rotation
    self._writing_direction_upward = None
    self.writing_direction_upward = (
        writing_direction_upward  # Using setter
    )

to_dict()

Convert the Scene object into a dictionary.

Source code in npxpy/nodes/space.py
197
198
199
200
201
202
203
204
205
def to_dict(self) -> Dict:
    """
    Convert the Scene object into a dictionary.
    """
    node_dict = super().to_dict()
    node_dict["position"] = self.position
    node_dict["rotation"] = self.rotation
    node_dict["writing_direction_upward"] = self.writing_direction_upward
    return node_dict