############################################### # x3d.py X3D Package for Python # generator: X3duomToX3dPythonPackage.xslt # X3DUOM: X3dUnifiedObjectModel-4.0.xml # Python X3D: https://www.web3d.org/x3d/stylesheets/python/python.html """ The x3d.py Python X3D Package supports programmers with Python interfaces and objects for standards-based X3D programming, all as open source. This work is part of the X3D Python Scene Access Interface Library (X3DPSAIL). """ # Include regular expression (regex) library: re is built into Python # https://docs.python.org/3/library/re.html # https://docs.python.org/3/howto/regex.html#regex-howto # https://www.web3d.org/specifications/X3dRegularExpressions.html import re _DEBUG = False # options True False ############################################### # SimpleType Enumerations ACCESSTYPECHOICES = ( # strict set of allowed values follow, no other values are valid 'initializeOnly', # A field with accessType initializeOnly can be initialized, but cannot send or receive events. 'inputOnly', # A field with accessType inputOnly cannot be initialized or included in a scene file, but can receive input event values via a ROUTE. 'outputOnly', # A field with accessType outputOnly cannot be initialized or included in a scene file, but can send output event values via a ROUTE. 'inputOutput' # A field with accessType inputOutput can be initialized, and can also send or receive events. ) def assertValidAccessType(fieldName, value): """ Utility function to assert type validity of accessTypeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in ACCESSTYPECHOICES: # print('*** assertValidAccessType ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in ACCESSTYPECHOICES: # print('*** assertValidAccessType ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in ACCESSTYPECHOICES=' + str(ACCESSTYPECHOICES)) ALPHAMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'AUTO', # Material transparency is applied to texture transparency 'OPAQUE', # Ignore alpha channel texture transparency, opaque 'MASK', # Alpha-testing mode for transparent when alpha value less than 0.5 and opaque when greater than or equal to 0.5 'BLEND' # Blend combines partial transparency of textures and materials ) def assertValidAlphaMode(fieldName, value): """ Utility function to assert type validity of alphaModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in ALPHAMODECHOICES: # print('*** assertValidAlphaMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in ALPHAMODECHOICES: # print('*** assertValidAlphaMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in ALPHAMODECHOICES=' + str(ALPHAMODECHOICES)) APPLIEDPARAMETERSCHOICES = ( # note these MFString values use XML syntax # strict set of allowed values follow, no other values are valid '"BOUNCE"', # The bounce field value is used. '"USER_FRICTION"', # The system will normally calculate the friction direction vector that is perpendicular to the contact normal. This setting indicates that the user-supplied value in this contact should be used. '"FRICTION_COEFFICIENT-2"', # Apply frictionCoefficients values '"ERROR_REDUCTION"', # Apply softnessErrorCorrection value '"CONSTANT_FORCE"', # Apply softnessConstantForceMix value '"SPEED-1"', # Apply first component of surfaceSpeed array '"SPEED-2"', # Apply second component of surfaceSpeed array '"SLIP-1"', # Apply first component of slipFactors array '"SLIP-2"' # Apply second component of slipFactors array ) def assertValidAppliedParameters(fieldName, value): """ Utility function to assert type validity of appliedParametersChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in APPLIEDPARAMETERSCHOICES: # print('*** assertValidAppliedParameters ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in APPLIEDPARAMETERSCHOICES: # print('*** assertValidAppliedParameters ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in APPLIEDPARAMETERSCHOICES=' + str(APPLIEDPARAMETERSCHOICES)) BIQUADTYPEFILTERCHOICES = ( # strict set of allowed values follow, no other values are valid 'LOWPASS', # X3D version of "lowpass" in Web Audio API. 'HIGHPASS', # X3D version of "highpass" in Web Audio API. 'BANDPASS', # X3D version of "bandpass" in Web Audio API. 'LOWSHELF', # X3D version of "lowshelf" in Web Audio API. 'HIGHSHELF', # X3D version of "highshelf" in Web Audio API. 'PEAKING', # X3D version of "peaking" in Web Audio API. 'NOTCH', # X3D version of "notch" in Web Audio API. 'ALLPASS' # X3D version of "allpass" in Web Audio API. ) def assertValidBiquadTypeFilter(fieldName, value): """ Utility function to assert type validity of biquadTypeFilterChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in BIQUADTYPEFILTERCHOICES: # print('*** assertValidBiquadTypeFilter ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in BIQUADTYPEFILTERCHOICES: # print('*** assertValidBiquadTypeFilter ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in BIQUADTYPEFILTERCHOICES=' + str(BIQUADTYPEFILTERCHOICES)) CHANNELCOUNTMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'MAX', # X3D version of "max" in Web Audio API. 'CLAMPED_MAX', # X3D version of "clamped-max" in Web Audio API. 'EXPLICIT' # X3D version of "explicit" in Web Audio API. ) def assertValidChannelCountMode(fieldName, value): """ Utility function to assert type validity of channelCountModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in CHANNELCOUNTMODECHOICES: # print('*** assertValidChannelCountMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in CHANNELCOUNTMODECHOICES: # print('*** assertValidChannelCountMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in CHANNELCOUNTMODECHOICES=' + str(CHANNELCOUNTMODECHOICES)) CHANNELINTERPRETATIONCHOICES = ( # strict set of allowed values follow, no other values are valid 'SPEAKERS', # X3D version of "speakers" in Web Audio API. 'DISCRETE' # X3D version of "discrete" in Web Audio API. ) def assertValidChannelInterpretation(fieldName, value): """ Utility function to assert type validity of channelInterpretationChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in CHANNELINTERPRETATIONCHOICES: # print('*** assertValidChannelInterpretation ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in CHANNELINTERPRETATIONCHOICES: # print('*** assertValidChannelInterpretation ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in CHANNELINTERPRETATIONCHOICES=' + str(CHANNELINTERPRETATIONCHOICES)) CLOSURETYPECHOICES = ( # strict set of allowed values follow, no other values are valid 'PIE', # Connects arc endpoints to center, forming a pie wedge 'CHORD' # Connects arc endpoints directly to each other, as in chord on a circle ) def assertValidClosureType(fieldName, value): """ Utility function to assert type validity of closureTypeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in CLOSURETYPECHOICES: # print('*** assertValidClosureType ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in CLOSURETYPECHOICES: # print('*** assertValidClosureType ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in CLOSURETYPECHOICES=' + str(CLOSURETYPECHOICES)) COMPONENTNAMECHOICES = ( # strict set of allowed values follow, no other values are valid 'Core', # The Core component supplies the base functionality for the X3D run-time system, including the abstract base node type, field types, the event model, and routing. 'CADGeometry', # The CADGeometry component is provided for Computer-Aided Design (CAD) nodes. 'CubeMapTexturing', # The Cube Map Environmental Texturing component describes how additional texturing effects are defined to produce environmental effects such as reflections from objects. 'DIS', # The Distributed Interactive Simulation (DIS) component provides networked interoperability with the IEEE DIS protocol for sharing state and conducting real-time platform-level simulations across multiple host computers. 'EnvironmentalEffects', # Nodes in the Environmental effects component support the creation of realistic environmental effects such as panoramic backgrounds and fog. 'EnvironmentalSensor', # The Environment Sensor nodes emit events indicating activity in the scene environment, usually based on interactions between the viewer and the world. 'EventUtilities', # The Event Utility nodes provide the capability to filter, trigger, convert, or sequence numerous event-types for common interactive applications without the use of a Script node. 'Followers', # The Follower nodes (Chasers and Dampers) support dynamic creation of smooth parameter transitions at run time. 'Geometry2D', # The Geometry2D component defines how two-dimensional geometry is specified and what shapes are available. 'Geometry3D', # The Geometry3D component describes how three-dimensional geometry is specified and defines ElevationGrid, Extrusion, IndexedFaceSet, and most primitive geometry nodes (Box, Cone, Cylinder, Sphere). 'Geospatial', # The Geospatial component defines how to associate real-world locations in an X3D scene and specifies nodes particularly tuned for geospatial applications. 'Grouping', # The Grouping component describes how nodes are organized into groups to establish a transformation hierarchy for the X3D scene graph. 'HAnim', # The Humanoid Animation (HAnim) component for X3D defines node bindings and other details for implementing ISO/IEC 19774, the HAnim International Specification. Original name was H-Anim for X3D versions 3.0 through 3.3, both enumeration values HAnim and H-Anim are allowed to pass validation. 'H-Anim', # Legacy enumeration H-Anim for X3D versions 3.0-3.3 provides backwards compatibility with Humanoid Animation (HAnim) version 1, preferred form of enumeration value is HAnim. 'Interpolation', # Interpolator nodes provide keyframe-based animation capability. 'KeyDeviceSensor', # The Key Device Sensor defines how keyboard keystrokes are inserted into an X3D world. 'Layering', # The Layering component describes how to layer a set of subscene layers into a composite scene. 'Layout', # The Layout component defines how to precisely position content in a scene in relation to the rendered results, especially for integrating 2D content with 3D content. 'Lighting', # The Lighting component specifies how light sources are defined and positioned, as well as how lights effect the rendered image. 'Navigation', # The Navigation component specifies how a user can effectively and intuitively move through and around a 3D scene. 'Networking', # The Networking component defines node types and other features used to access file-based and streaming resources on the World Wide Web. 'NURBS', # The NURBS component describes Non-uniform Rational B-Spline (NURBS) geometry and interpolation nodes. 'ParticleSystems', # The Particle Systems component specifies how to model particles and their interactions through the application of basic physics principles to affect motion. 'Picking', # The Picking component provides the ability to test for arbitrary object collision and provide basic capabilities to detecting object intersections and interactions. 'PointingDeviceSensor', # Pointing device sensor nodes detect pointing events from user-interface devices, defining activities such as a user selecting a piece of geometry. 'TextureProjection', # TextureProjection nodes project texture images onto geometry in a scene. 'Rendering', # The Rendering component includes fundamental rendering primitives such as TriangleSet and PointSet nodes, as well as geometric properties nodes that define how coordinate indices, colors, normals and texture coordinates are specified. 'RigidBodyPhysics', # The Rigid Body Physics component describes how to model rigid bodies and their interactions through the application of basic physics principles to effect motion. 'Scripting', # The Scripting component describes how Script nodes are used to effect changes in X3D worlds. 'Shaders', # The Programmable Shaders component describes how programmable shaders are specified and how they affect the visual appearance of geometry. 'Shape', # The Shape component defines nodes for associating geometry with their visible properties and the scene environment. 'Sound', # The Sound component defines how sound is delivered to an X3D world as well as how sounds are accessed. 'Text', # The Text component defines how text strings are rendered in an X3D scene. 'Texturing', # The Texturing component specifies how 2D texture images are defined and then positioned on associated geometry. 'Texturing3D', # The Texturing3D component specifies how 3D volumetric textures describe surface properties as data points in a volume of space, rather than a flat surface. 'Time', # The Time component defines how time is sensed, computed and associated with events in an X3D scene. 'VolumeRendering' # The Volume Rendering component provides the ability to specify and render volumetric data sets. ) def assertValidComponentName(fieldName, value): """ Utility function to assert type validity of componentNameChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in COMPONENTNAMECHOICES: # print('*** assertValidComponentName ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in COMPONENTNAMECHOICES: # print('*** assertValidComponentName ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in COMPONENTNAMECHOICES=' + str(COMPONENTNAMECHOICES)) DISTANCEMODELCHOICES = ( # strict set of allowed values follow, no other values are valid 'LINEAR', # X3D version of "linear" in Web Audio API. 'INVERSE', # X3D version of "inverse" in Web Audio API. 'EXPONENTIAL' # X3D version of "exponential" in Web Audio API. ) def assertValidDistanceModel(fieldName, value): """ Utility function to assert type validity of distanceModelChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in DISTANCEMODELCHOICES: # print('*** assertValidDistanceModel ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in DISTANCEMODELCHOICES: # print('*** assertValidDistanceModel ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in DISTANCEMODELCHOICES=' + str(DISTANCEMODELCHOICES)) FIELDTYPECHOICES = ( # strict set of allowed values follow, no other values are valid 'SFBool', # Single Field (singleton) Boolean 'MFBool', # Multiple Field (list) Boolean 'SFColor', # Single Field (singleton) color value, red-green-blue 'MFColor', # Multiple Field (list) color value, red-green-blue 'SFColorRGBA', # Single Field (singleton) color value, red-green-blue alpha (opacity) 'MFColorRGBA', # Multiple Field (list) color value, red-green-blue alpha (opacity) 'SFDouble', # Single Field (singleton) double-precision (64-bit) float 'MFDouble', # Multiple Field (list) 2-tuple double-precision (64-bit) float vector 'SFFloat', # Single Field (singleton) single-precision (32-bit) float 'MFFloat', # Multiple Field (list) single-precision (32-bit) float vector 'SFImage', # Single Field (singleton) image value 'MFImage', # Multiple Field (list) image values 'SFInt32', # Single Field (singleton) 32-bit integer 'MFInt32', # Multiple Field (list) 32-bit integer 'SFNode', # Single Field (singleton) node 'MFNode', # Multiple Field (list) nodes 'SFRotation', # Single Field (singleton) rotation value using 3-tuple axis, radian angle 'MFRotation', # Multiple Field (list) rotation values using 3-tuple axis, radian angle 'SFString', # Single Field (singleton) string value 'MFString', # Multiple Field (list) SFString array 'SFTime', # Single Field (singleton) time value in seconds 'MFTime', # Multiple Field (list) time array in seconds 'SFVec2d', # Single Field (singleton) 2-tuple double-precision float vector 'MFVec2d', # Multiple Field (list) 2-tuple double-precision float vectors 'SFVec2f', # Single Field (singleton) 2-tuple single-precision float vector 'MFVec2f', # Multiple Field (list) 2-tuple single-precision float vectors 'SFVec3d', # Single Field (singleton) 3-tuple double-precision float vector 'MFVec3d', # Multiple Field (list) 3-tuple double-precision float vectors 'SFVec3f', # Single Field (singleton) 3-tuple single-precision float vector 'MFVec3f', # Multiple Field (list) 3-tuple single-precision float vectors 'SFVec4d', # Single Field (singleton) 4-tuple double-precision float vector 'MFVec4d', # Multiple Field (list) 4-tuple double-precision float vectors 'SFVec4f', # Single Field (singleton) 4-tuple single-precision float vector 'MFVec4f', # Multiple Field (list) 4-tuple single-precision float vectors 'SFMatrix3d', # Single Field (singleton) 3×3 matrix of double-precision floating point numbers 'MFMatrix3d', # Multiple Field (list) 3×3 matrices of double-precision floating point numbers 'SFMatrix3f', # Single Field (singleton) 3×3 matrix of single-precision floating point numbers 'MFMatrix3f', # Multiple Field (list) 3×3 matrices of double-precision floating point numbers 'SFMatrix4d', # Single Field (singleton) 4×4 matrix of double-precision floating point numbers 'MFMatrix4d', # Multiple Field (list) 4×4 matric3w of double-precision floating point numbers 'SFMatrix4f', # Single Field (singleton) 4×4 matrix of single-precision floating point numbers 'MFMatrix4f' # Multiple Field (list) 4×4 matrices of single-precision floating point numbers ) def assertValidFieldType(fieldName, value): """ Utility function to assert type validity of fieldTypeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in FIELDTYPECHOICES: # print('*** assertValidFieldType ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in FIELDTYPECHOICES: # print('*** assertValidFieldType ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in FIELDTYPECHOICES=' + str(FIELDTYPECHOICES)) FOGTYPECHOICES = ( # strict set of allowed values follow, no other values are valid 'LINEAR', # linear blending as a function of distance 'EXPONENTIAL' # exponential blending as a function of distance ) def assertValidFogType(fieldName, value): """ Utility function to assert type validity of fogTypeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in FOGTYPECHOICES: # print('*** assertValidFogType ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in FOGTYPECHOICES: # print('*** assertValidFogType ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in FOGTYPECHOICES=' + str(FOGTYPECHOICES)) FONTFAMILYVALUES = ( # specification-defined values follow, other values are also allowed '"SANS"', # default font family for sans-serif font such as Helvetica '"SERIF"', # default font family for serif font such as Times-Roman '"TYPEWRITER"' # default font family for a fixed-pitch font such as Courier ) FONTSTYLECHOICES = ( # strict set of allowed values follow, no other values are valid 'PLAIN', # default plain type 'BOLD', # boldface type 'ITALIC', # italic type 'BOLDITALIC' # bold and italic type ) def assertValidFontStyle(fieldName, value): """ Utility function to assert type validity of fontStyleChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in FONTSTYLECHOICES: # print('*** assertValidFontStyle ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in FONTSTYLECHOICES: # print('*** assertValidFontStyle ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in FONTSTYLECHOICES=' + str(FONTSTYLECHOICES)) FORCEOUTPUTVALUES = ( # specification-defined values follow, other values are also allowed '"ALL"', # all forceOutput fields computed '"NONE"' # no forceOutput fields computed ) GENERATEDCUBEMAPTEXTUREUPDATECHOICES = ( # strict set of allowed values follow, no other values are valid 'NONE', # no further texture updates are rendered 'NEXT_FRAME_ONLY', # render texture once at end of frame 'ALWAYS' # texture to be rendered every frame ) def assertValidGeneratedCubeMapTextureUpdate(fieldName, value): """ Utility function to assert type validity of generatedCubeMapTextureUpdateChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in GENERATEDCUBEMAPTEXTUREUPDATECHOICES: # print('*** assertValidGeneratedCubeMapTextureUpdate ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in GENERATEDCUBEMAPTEXTUREUPDATECHOICES: # print('*** assertValidGeneratedCubeMapTextureUpdate ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in GENERATEDCUBEMAPTEXTUREUPDATECHOICES=' + str(GENERATEDCUBEMAPTEXTUREUPDATECHOICES)) GEOMETADATASUMMARYKEYVALUES = ( # specification-defined values follow, other values are also allowed 'title', # A name to succinctly identify the dataset to user. For example, "San Francisco, California". 'description', # A brief textual description or summary of the content of the dataset. For example, "LANDSAT 7 satellite imagery taken over northern Scotland". 'coordinateSystem', # The spatial reference frame used to represent the data (e.g., GD, UTM, or LCC). The list of valid codes that can be used in this field are defined in ISO/IEC 18026. In the case of UTM, the zone number should also be specified in the format "UTM Zx", where the zone number is in the range [1,60]. For example, "UTM Z11". 'horizontalDatum', # The name of the geodetic datum. The list of valid codes that can be used in this field are defined in ISO/IEC 18026. For example, "W84". 'verticalDatum', # The name of the vertical datum (geoid). The list of valid codes that can be used in this field are defined in ISO/IEC 18026. For example, "W84". 'ellipsoid', # The name of the geodetic ellipsoid. The list of valid codes that can be used in this field are defined in ISO/IEC 18026. For example, "WE". 'extent', # The bounding coordinates for the dataset given in spatial reference frame specified by the coordinateSystem keyword. These are provided in the order eastmost, southmost, westmost, northmost. An example for GD is: "-180.0 -90.0 180.0 90.0". 'resolution', # SFFloat resolution, or ground sample distance, given in units of length base units. For example, "30". 'originator', # A string defining the originator of the data, for example the author, agency, organization, publisher, etc. For example, "John Doe, Any Corporation, Some Town, Some Country" 'copyright', # Any appropriate copyright declaration that pertains to the data. For example, "(c) Copyright 2000, Any Corporation. All rights reserved. Freely distributable." 'date', # A single date/time, or a date/time range, defining the valid time period to which the data pertains. Dates are specified in the format "YYYY MM DD [HH:MM]". Years in the current time period should be specified using four digits (EXAMPLE "1999" or "2001"). Years can have other than four digits and can be negative. A date range is specified by supplying two values separated by a "-" (hyphen) character. An optional time can be supplied should this level of accuracy be required. Times are to be specified in 24-hour format with respect to GMT. For example, "1999 01 01 00:00 - 1999 12 31 23:59". 'metadataFormat', # A string that specifies the format of the external metadata description specified by the url field of the GeoMetadata node. For example, "FGDC", "ISO TC211", "CEN TC287", or "OGC". 'dataUrl', # A hypertext link to the source data used to create the X3D node(s) to which this metadata pertains. Multiple dataUrl keyword/value pairs can be specified in order to provide alternative locations for the same source data. For example, "https://www.foo.bar/data/sf1". 'dataFormat' # A free-text string that describes the format of the source data used to create the X3D node(s) to which this metadata pertains. This refers to the source data specified by the dataUrl keyword (if present). For example, "USGS 5.5-min DEM". ) GEOSYSTEMEARTHELLIPSOIDVALUES = ( # specification-defined values follow, other values are also allowed 'AM', # Modified Airy 'AN', # Australian National 'BN', # Bessel 1841 (Namibia) 'BR', # Bessel 1841 (Ethiopia Indonesia ...) 'CC', # Clarke 1866 'CD', # Clarke 1880 'EA', # Everest (India 1830) 'EB', # Everest (Sabah & Sarawak) 'EC', # Everest (India 1956) 'ED', # Everest (W. Malaysia 1969) 'EE', # Everest (W. Malaysia & Singapore 1948) 'EF', # Everest (Pakistan) 'FA', # Modified Fischer 1960 'HE', # Helmert 1906 'HO', # Hough 1960 'ID', # Indonesia 1974 'IN', # International 1924 'KA', # Krassovsky 1940 'RF', # Geodetic Reference System 1980 (GRS 80) 'SA', # South American 1969 'WD', # WGS 72 'WE', # WGS 84 'WGS84', # WGS84 geoid 'Zn', # Zone number (1..60) (only used with UTM) 'S' # Southern hemisphere (only used with UTM) ) GEOSYSTEMSPATIALREFERENCEFRAMEVALUES = ( # specification-defined values follow, other values are also allowed 'GD', # Geodetic spatial reference frame (latitude/longitude), to be followed by ellipsoid 'UTM', # Universal Transverse Mercator. One further required argument must be supplied for UTM in order to specify the zone number (1..60) with optional suffix of "S" may be appended in order to specify that the coordinates are in the southern hemisphere. Optional arguments can follow. 'GC', # Earth-fixed Geocentric with respect to the WGS84 ellipsoid. No additional arguments are supported. 'GDC', # Synonymous to GD, but may be subject to future deprecation 'GCC' # Synonymous to GC, but may be subject to future deprecation ) HANIMFEATUREPOINTNAMEVALUES = ( # specification-defined values follow, other values are also allowed 'skull_vertex', # CAESAR 2003 skull_vertex matches ISO 7250-1 part 5.22 Vertex (top of head). No corresponding landmark provided in CAESAR 2018. 'glabella', # glabella is between the eyebrows and above the nose 'sellion', # osseocartilaginous junction of the nasal dorsum 'l_infraorbitale', # Left Infraorbitale foramen is opening in maxillary bone of skull located below the infraorbital margin of the orbit. 'l_tragion', # notch just above the tragus of the ear 'l_gonion', # Left Gonion is midpoint of mandibular angle of the jaw. 'r_infraorbitale', # Right Infraorbitale foramen is opening in maxillary bone of skull located below the infraorbital margin of the orbit. 'r_tragion', # notch just above the tragus of the ear 'r_gonion', # Right Gonion is midpoint of the mandibular angle of the jaw. 'supramenton', # center point above tip of chin 'cervicale', 'adams_apple', 'suprasternale', # Suprasternale 'substernale', 'l_clavicle', 'l_acromion', 'l_axilla_proximal', # Left Axilla Proximal (Anterior) 'l_axilla_distal', # Left Axilla Distal (Posterior) 'l_axilla_posterior_folds', 'r_clavicle', 'r_acromion', 'r_axilla_proximal', # Right Axilla Proximal (Anterior) 'r_axilla_distal', # Right Axilla Distal (Posterior) 'r_axilla_posterior_folds', # Right Posterior Axillary Folds 'spine_1_middle_back', 'spine_2_lower_back', 'waist_preferred_anterior', 'waist_preferred_posterior', 'l_rib10', 'l_thelion', 'r_rib10', 'r_thelion', 'l_asis', 'l_iliocristale', 'l_psis', 'r_asis', 'r_iliocristale', 'r_psis', 'crotch', 'l_femoral_lateral_epicondyle', 'l_femoral_medial_epicondyle', 'l_suprapatella', 'l_trochanterion', 'r_femoral_lateral_epicondyle', 'r_femoral_medial_epicondyle', 'r_suprapatella', 'r_trochanterion', 'l_tibiale', 'l_medial_malleolus', 'l_lateral_malleolus', 'l_sphyrion', 'r_tibiale', 'r_medial_malleolus', 'r_lateral_malleolus', 'r_sphyrion', 'l_metatarsal_phalanx_1', 'l_metatarsal_phalanx_5', 'l_dactylion', 'l_calcaneus_posterior', 'r_metatarsal_phalanx_1', 'r_metatarsal_phalanx_5', 'r_dactylion', 'r_calcaneus_posterior', 'l_humeral_lateral_epicondyle', 'l_humeral_medial_epicondyle', 'l_olecranon', 'r_humeral_lateral_epicondyle', 'r_humeral_medial_epicondyle', 'r_olecranon', 'l_radiale', 'l_ulnar_styloid', 'l_radial_styloid', 'r_radiale', 'r_ulnar_styloid', 'r_radial_styloid', 'l_metacarpal_phalanx_2', 'l_metacarpal_phalanx_3', 'l_metacarpal_phalanx_5', 'r_metacarpal_phalanx_2', 'r_metacarpal_phalanx_3', 'r_metacarpal_phalanx_5', 'nuchale', 'l_neck_base', 'r_neck_base', 'navel', 'l_ectocanthus', 'r_ectocanthus', 'menton', 'mesosternale', 'opisthocranion', 'l_knee_crease', 'r_knee_crease', 'rear_center_midsagittal_plane', 'buttocks_standing_wall_contact_point', 'l_chest_midsagittal_plane', 'r_chest_midsagittal_plane', 'l_bideltoid', 'r_bideltoid', 'l_carpal_distal_phalanx_1', 'l_carpal_distal_phalanx_2', 'l_carpal_distal_phalanx_3', 'l_carpal_distal_phalanx_4', 'l_carpal_distal_phalanx_5', 'r_carpal_distal_phalanx_1', 'r_carpal_distal_phalanx_2', 'r_carpal_distal_phalanx_3', 'r_carpal_distal_phalanx_4', 'r_carpal_distal_phalanx_5', 'l_tarsal_distal_phalanx_1', 'l_tarsal_distal_phalanx_2', 'l_tarsal_distal_phalanx_3', 'l_tarsal_distal_phalanx_4', 'l_tarsal_distal_phalanx_5', 'r_tarsal_distal_phalanx_1', 'r_tarsal_distal_phalanx_2', 'r_tarsal_distal_phalanx_3', 'r_tarsal_distal_phalanx_4', 'r_tarsal_distal_phalanx_5' ) HANIMHUMANOIDINFOKEYVALUES = ( # specification-defined values follow, other values are also allowed 'authorName', # Name of Humanoid author. 'authorEmail', # Email address of Humanoid author. 'copyright', # Copyright information for this Humanoid model (if any). 'creationDate', # Creation data for this for this Humanoid model. 'usageRestrictions', # Usage restrictions for this Humanoid model (if any). 'humanoidVersion', # The humanoidVersion term refers to the version of the humanoid being used, in order to track revisions to the data. It is not the same as the version field of the Humanoid object, which refers to the version of the HAnim specification that was used when building the humanoid. 'age', # Description of Humanoid age (not necessarily numeric). 'gender', # The gender term typically has a value of female, male or neuter. 'height', # SFFloat Humanoid height in base units (typically meters). 'weight' # SFFloat Humanoid weight in base units (typically kilograms). ) HANIMJOINTNAMEVALUES = ( # specification-defined values follow, other values are also allowed 'humanoid_root', 'sacroiliac', 'l_hip', 'l_knee', 'l_talocrural', 'l_talocalcaneonavicular', 'l_cuneonavicular_1', 'l_tarsometatarsal_1', 'l_metatarsophalangeal_1', 'l_tarsal_interphalangeal_1', 'l_cuneonavicular_2', 'l_tarsometatarsal_2', 'l_metatarsophalangeal_2', 'l_tarsal_proximal_interphalangeal_2', 'l_tarsal_distal_interphalangeal_2', 'l_cuneonavicular_3', 'l_tarsometatarsal_3', 'l_metatarsophalangeal_3', 'l_tarsal_proximal_interphalangeal_3', 'l_tarsal_distal_interphalangeal_3', 'l_calcaneocuboid', 'l_transversetarsal', 'l_tarsometatarsal_4', 'l_metatarsophalangeal_4', 'l_tarsal_proximal_interphalangeal_4', 'l_tarsal_distal_interphalangeal_4', 'l_tarsometatarsal_5', 'l_metatarsophalangeal_5', 'l_tarsal_proximal_interphalangeal_5', 'l_tarsal_distal_interphalangeal_5', 'r_hip', 'r_knee', 'r_talocrural', 'r_talocalcaneonavicular', 'r_cuneonavicular_1', 'r_tarsometatarsal_1', 'r_metatarsophalangeal_1', 'r_tarsal_interphalangeal_1', 'r_cuneonavicular_2', 'r_tarsometatarsal_2', 'r_metatarsophalangeal_2', 'r_tarsal_proximal_interphalangeal_2', 'r_tarsal_distal_interphalangeal_2', 'r_cuneonavicular_3', 'r_tarsometatarsal_3', 'r_metatarsophalangeal_3', 'r_tarsal_proximal_interphalangeal_3', 'r_tarsal_distal_interphalangeal_3', 'r_calcaneocuboid', 'r_transversetarsal', 'r_tarsometatarsal_4', 'r_metatarsophalangeal_4', 'r_tarsal_proximal_interphalangeal_4', 'r_tarsal_distal_interphalangeal_4', 'r_tarsometatarsal_5', 'r_metatarsophalangeal_5', 'r_tarsal_proximal_interphalangeal_5', 'r_tarsal_distal_interphalangeal_5', 'vl5', 'vl4', 'vl3', 'vl2', 'vl1', 'vt12', 'vt11', 'vt10', 'vt9', 'vt8', 'vt7', 'vt6', 'vt5', 'vt4', 'vt3', 'vt2', 'vt1', 'vc7', 'vc6', 'vc5', 'vc4', 'vc3', 'vc2', 'vc1', 'skullbase', 'l_eyelid_joint', 'r_eyelid_joint', 'l_eyeball_joint', 'r_eyeball_joint', 'l_eyebrow_joint', 'r_eyebrow_joint', 'temporomandibular', 'l_sternoclavicular', 'l_acromioclavicular', 'l_shoulder', 'l_elbow', 'l_radiocarpal', 'l_midcarpal_1', 'l_carpometacarpal_1', 'l_metacarpophalangeal_1', 'l_carpal_interphalangeal_1', 'l_midcarpal_2', 'l_carpometacarpal_2', 'l_metacarpophalangeal_2', 'l_carpal_proximal_interphalangeal_2', 'l_carpal_distal_interphalangeal_2', 'l_midcarpal_3', 'l_carpometacarpal_3', 'l_metacarpophalangeal_3', 'l_carpal_proximal_interphalangeal_3', 'l_carpal_distal_interphalangeal_3', 'l_midcarpal_4_5', 'l_carpometacarpal_4', 'l_metacarpophalangeal_4', 'l_carpal_proximal_interphalangeal_4', 'l_carpal_distal_interphalangeal_4', 'l_carpometacarpal_5', 'l_metacarpophalangeal_5', 'l_carpal_proximal_interphalangeal_5', 'l_carpal_distal_interphalangeal_5', 'r_sternoclavicular', 'r_acromioclavicular', 'r_shoulder', 'r_elbow', 'r_radiocarpal', 'r_midcarpal_1', 'r_carpometacarpal_1', 'r_metacarpophalangeal_1', 'r_carpal_interphalangeal_1', 'r_midcarpal_2', 'r_carpometacarpal_2', 'r_metacarpophalangeal_2', 'r_carpal_proximal_interphalangeal_2', 'r_carpal_distal_interphalangeal_2', 'r_midcarpal_3', 'r_carpometacarpal_3', 'r_metacarpophalangeal_3', 'r_carpal_proximal_interphalangeal_3', 'r_carpal_distal_interphalangeal_3', 'r_midcarpal_4_5', 'r_carpometacarpal_4', 'r_metacarpophalangeal_4', 'r_carpal_proximal_interphalangeal_4', 'r_carpal_distal_interphalangeal_4', 'r_carpometacarpal_5', 'r_metacarpophalangeal_5', 'r_carpal_proximal_interphalangeal_5', 'r_carpal_distal_interphalangeal_5' ) HANIMSEGMENTNAMEVALUES = ( # specification-defined values follow, other values are also allowed 'sacrum', 'pelvis', 'l_thigh', 'l_calf', 'l_talus', 'l_navicular', 'l_cuneiform_1', 'l_metatarsal_1', 'l_tarsal_proximal_phalanx_1', 'l_tarsal_distal_phalanx_1', 'l_cuneiform_2', 'l_metatarsal_2', 'l_tarsal_proximal_phalanx_2', 'l_tarsal_middle_phalanx_2', 'l_tarsal_distal_phalanx_2', 'l_cuneiform_3', 'l_metatarsal_3', 'l_tarsal_proximal_phalanx_3', 'l_tarsal_middle_phalanx_3', 'l_tarsal_distal_phalanx_3', 'l_calcaneus', 'l_cuboid', 'l_metatarsal_4', 'l_tarsal_proximal_phalanx_4', 'l_tarsal_middle_phalanx_4', 'l_tarsal_distal_phalanx_4', 'l_metatarsal_5', 'l_tarsal_proximal_phalanx_5', 'l_tarsal_middle_phalanx_5', 'l_tarsal_distal_phalanx_5', 'r_thigh', 'r_calf', 'r_talus', 'r_navicular', 'r_cuneiform_1', 'r_metatarsal_1', 'r_tarsal_proximal_phalanx_1', 'r_tarsal_distal_phalanx_1', 'r_cuneiform_2', 'r_metatarsal_2', 'r_tarsal_proximal_phalanx_2', 'r_tarsal_middle_phalanx_2', 'r_tarsal_distal_phalanx_2', 'r_cuneiform_3', 'r_metatarsal_3', 'r_tarsal_proximal_phalanx_3', 'r_tarsal_middle_phalanx_3', 'r_tarsal_distal_phalanx_3', 'r_calcaneus', 'r_cuboid', 'r_metatarsal_4', 'r_tarsal_proximal_phalanx_4', 'r_tarsal_middle_phalanx_4', 'r_tarsal_distal_phalanx_4', 'r_metatarsal_5', 'r_tarsal_proximal_phalanx_5', 'r_tarsal_middle_phalanx_5', 'r_tarsal_distal_phalanx_5', 'l5', 'l4', 'l3', 'l2', 'l1', 't12', 't11', 't10', 't9', 't8', 't7', 't6', 't5', 't4', 't3', 't2', 't1', 'c7', 'c6', 'c5', 'c4', 'c3', 'c2', 'c1', 'skull', 'l_eyelid', 'r_eyelid', 'l_eyeball', 'r_eyeball', 'l_eyebrow', 'r_eyebrow', 'jaw', 'l_clavicle', 'l_scapula', 'l_upperarm', 'l_forearm', 'l_carpal', 'l_trapezium', 'l_metacarpal_1', 'l_carpal_proximal_phalanx_1', 'l_carpal_distal_phalanx_1', 'l_trapezoid', 'l_metacarpal_2', 'l_carpal_proximal_phalanx_2', 'l_carpal_middle_phalanx_2', 'l_carpal_distal_phalanx_2', 'l_capitate', 'l_metacarpal_3', 'l_carpal_proximal_phalanx_3', 'l_carpal_middle_phalanx_3', 'l_carpal_distal_phalanx_3', 'l_hamate', 'l_metacarpal_4', 'l_carpal_proximal_phalanx_4', 'l_carpal_middle_phalanx_4', 'l_carpal_distal_phalanx_4', 'l_metacarpal_5', 'l_carpal_proximal_phalanx_5', 'l_carpal_middle_phalanx_5', 'l_carpal_distal_phalanx_5', 'r_clavicle', 'r_scapula', 'r_upperarm', 'r_forearm', 'r_carpal', 'r_trapezium', 'r_metacarpal_1', 'r_carpal_proximal_phalanx_1', 'r_carpal_distal_phalanx_1', 'r_trapezoid', 'r_metacarpal_2', 'r_carpal_proximal_phalanx_2', 'r_carpal_middle_phalanx_2', 'r_carpal_distal_phalanx_2', 'r_capitate', 'r_metacarpal_3', 'r_carpal_proximal_phalanx_3', 'r_carpal_middle_phalanx_3', 'r_carpal_distal_phalanx_3', 'r_hamate', 'r_metacarpal_4', 'r_carpal_proximal_phalanx_4', 'r_carpal_middle_phalanx_4', 'r_carpal_distal_phalanx_4', 'r_metacarpal_5', 'r_carpal_proximal_phalanx_5', 'r_carpal_middle_phalanx_5', 'r_carpal_distal_phalanx_5' ) HANIMVERSIONCHOICES = ( # strict set of allowed values follow, no other values are valid '2.0' # Revised standard HAnim 19774 version 2 (parts 1 and 2) were approved by ISO in November 2019, published by Web3D Consortium May 2020. ) def assertValidHanimVersion(fieldName, value): """ Utility function to assert type validity of hanimVersionChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in HANIMVERSIONCHOICES: # print('*** assertValidHanimVersion ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in HANIMVERSIONCHOICES: # print('*** assertValidHanimVersion ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in HANIMVERSIONCHOICES=' + str(HANIMVERSIONCHOICES)) HATCHSTYLEVALUES = ( # specification-defined values follow, other values are also allowed '1', # Horizontal equally spaced parallel lines '2', # Vertical equally spaced parallel lines '3', # Positive slope equally spaced parallel lines '4', # Negative slope equally spaced parallel lines '5', # Horizontal/vertical crosshatch '6', # Positive slope/negative slope crosshatch '7', # (cast iron or malleable iron and general use for all materials) '8', # (steel) '9', # (bronze, brass, copper, and compositions) '10', # (white metal, zinc, lead, babbit, and alloys) '11', # (magnesium, aluminum, and aluminum alloys) '12', # (rubber, plastic, and electrical insulation) '13', # (cork, felt, fabric, leather, and fibre/fiber) '14', # (thermal insulation) '15', # (titanium and refi-actory material) '16', # (marble, slate, porcelain, glass, etc.) '17', # (earth) '18', # (sand) '19' # (repeating dot) ) # Enumeration alias values HATCHSTYLEVALUES_HORIZONTAL = 1 HATCHSTYLEVALUES_VERTICAL = 2 HATCHSTYLEVALUES_POSITIVE_SLOPE = 3 HATCHSTYLEVALUES_NEGATIVE_SLOPE = 4 HATCHSTYLEVALUES_HORIZONTAL_VERTICAL_CROSSHATCH = 5 HATCHSTYLEVALUES_POSITIVE_NEGATIVE_SLOPE_CROSSHATCH = 6 HATCHSTYLEVALUES_CAST_IRON = 7 HATCHSTYLEVALUES_STEEL = 8 HATCHSTYLEVALUES_BRONZE_BRASS_COPPER_COMPOSITIONS = 9 HATCHSTYLEVALUES_WHITE_METAL_ZINC_LEAD_BABBIT_ALLOYS = 10 HATCHSTYLEVALUES_MAGNESIUM_ALUMINUM_ALLOYS = 11 HATCHSTYLEVALUES_RUBBER_PLASTIC_ELECTRICAL_INSULATION = 12 HATCHSTYLEVALUES_CORK_FELT_FABRIC_LEATHER_FIBRE = 13 HATCHSTYLEVALUES_THERMAL_INSULATION = 14 HATCHSTYLEVALUES_TITANIUM = 15 HATCHSTYLEVALUES_MARBLE_SLATE_PORCELAIN_GLASS = 16 HATCHSTYLEVALUES_EARTH = 17 HATCHSTYLEVALUES_SAND = 18 HATCHSTYLEVALUES_REPEATING_DOT = 19 INTERSECTIONTYPEVALUES = ( # specification-defined values follow, other values are also allowed 'BOUNDS', # TODO undefined in X3D specification 'GEOMETRY' # TODO undefined in X3D specification ) JUSTIFYCHOICES = ( # note these MFString values use XML syntax # strict set of allowed values follow, no other values are valid '"MIDDLE"', '"MIDDLE" "BEGIN"', '"MIDDLE" "END"', '"MIDDLE" "FIRST"', '"MIDDLE" "MIDDLE"', '"BEGIN"', '"BEGIN" "BEGIN"', '"BEGIN" "END"', '"BEGIN" "FIRST"', '"BEGIN" "MIDDLE"', '"END"', '"END" "BEGIN"', '"END" "END"', '"END" "FIRST"', '"END" "MIDDLE"', '"FIRST"', '"FIRST" "BEGIN"', '"FIRST" "END"', '"FIRST" "FIRST"', '"FIRST" "MIDDLE"' ) def assertValidJustify(fieldName, value): """ Utility function to assert type validity of justifyChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in JUSTIFYCHOICES: # print('*** assertValidJustify ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in JUSTIFYCHOICES: # print('*** assertValidJustify ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in JUSTIFYCHOICES=' + str(JUSTIFYCHOICES)) LAYOUTALIGNCHOICES = ( # note these MFString values use XML syntax # strict set of allowed values follow, no other values are valid '"LEFT" "BOTTOM"', '"LEFT" "CENTER"', '"LEFT" "TOP"', '"CENTER" "BOTTOM"', '"CENTER" "CENTER"', '"CENTER" "TOP"', '"RIGHT" "BOTTOM"', '"RIGHT" "CENTER"', '"RIGHT" "TOP"' ) def assertValidLayoutAlign(fieldName, value): """ Utility function to assert type validity of layoutAlignChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in LAYOUTALIGNCHOICES: # print('*** assertValidLayoutAlign ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in LAYOUTALIGNCHOICES: # print('*** assertValidLayoutAlign ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in LAYOUTALIGNCHOICES=' + str(LAYOUTALIGNCHOICES)) LAYOUTSCALEMODECHOICES = ( # note these MFString values use XML syntax # strict set of allowed values follow, no other values are valid '"NONE" "NONE"', '"NONE" "FRACTION"', '"NONE" "STRETCH"', '"NONE" "PIXEL"', '"FRACTION" "NONE"', '"FRACTION" "FRACTION"', '"FRACTION" "STRETCH"', '"FRACTION" "PIXEL"', '"STRETCH" "NONE"', '"STRETCH" "FRACTION"', '"STRETCH" "STRETCH"', '"STRETCH" "PIXEL"', '"PIXEL" "NONE"', '"PIXEL" "FRACTION"', '"PIXEL" "STRETCH"', '"PIXEL" "PIXEL"' ) def assertValidLayoutScaleMode(fieldName, value): """ Utility function to assert type validity of layoutScaleModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in LAYOUTSCALEMODECHOICES: # print('*** assertValidLayoutScaleMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in LAYOUTSCALEMODECHOICES: # print('*** assertValidLayoutScaleMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in LAYOUTSCALEMODECHOICES=' + str(LAYOUTSCALEMODECHOICES)) LAYOUTUNITSCHOICES = ( # note these MFString values use XML syntax # strict set of allowed values follow, no other values are valid '"WORLD" "WORLD"', '"WORLD" "FRACTION"', '"WORLD" "PIXEL"', '"FRACTION" "WORLD"', '"FRACTION" "FRACTION"', '"FRACTION" "PIXEL"', '"PIXEL" "WORLD"', '"PIXEL" "FRACTION"', '"PIXEL" "PIXEL"' ) def assertValidLayoutUnits(fieldName, value): """ Utility function to assert type validity of layoutUnitsChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in LAYOUTUNITSCHOICES: # print('*** assertValidLayoutUnits ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in LAYOUTUNITSCHOICES: # print('*** assertValidLayoutUnits ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in LAYOUTUNITSCHOICES=' + str(LAYOUTUNITSCHOICES)) LINETYPEVALUES = ( # specification-defined values follow, other values are also allowed '1', # Solid '2', # Dashed '3', # Dotted '4', # Dashed-dotted '5', # Dash-dot-dot '6', # (single arrow) '7', # (single dot) '8', # (double arrow) '9', # (stitch line) '10', # (chain line) '11', # (center line) '12', # (hidden line) '13', # (phantom line) '14', # (break line - style 1) '15', # (break line - style 2) '16' # User-specified dash pattern ) # Enumeration alias values LINETYPEVALUES_SOLID = 1 LINETYPEVALUES_DASHED = 2 LINETYPEVALUES_DOTTED = 3 LINETYPEVALUES_DASHED_DOTTED = 4 LINETYPEVALUES_DASHED_DOT_DOT = 5 LINETYPEVALUES_SINGLE_ARROW = 6 LINETYPEVALUES_SINGLE_DOT = 7 LINETYPEVALUES_DOUBLE_ARROW = 8 LINETYPEVALUES_STITCH_LINE = 9 LINETYPEVALUES_CHAIN_LINE = 10 LINETYPEVALUES_CENTER_LINE = 11 LINETYPEVALUES_HIDDEN_LINE = 12 LINETYPEVALUES_PHANTOM_LINE = 13 LINETYPEVALUES_BREAK_LINE_STYLE_1 = 14 LINETYPEVALUES_BREAK_LINE_STYLE_2 = 15 LINETYPEVALUES_USER_SPECIFIED_DASH_PATTERN = 16 METADIRECTIONCHOICES = ( # strict set of allowed values follow, no other values are valid 'rtl', # right-to-left 'ltr' # left-to-right ) def assertValidMetaDirection(fieldName, value): """ Utility function to assert type validity of metaDirectionChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in METADIRECTIONCHOICES: # print('*** assertValidMetaDirection ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in METADIRECTIONCHOICES: # print('*** assertValidMetaDirection ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in METADIRECTIONCHOICES=' + str(METADIRECTIONCHOICES)) METANAMEVALUES = ( # specification-defined values follow, other values are also allowed 'accessRights', # permission required to access resource or security status 'author', # name of individual author 'contributor', # name of individual contributing to this resource 'created', # date of initial version 'creator', # name of original author 'description', # summary overview describing this resource 'disclaimer', # statement of denial or disavowal regarding potential claims or responsiblity 'drawing', # name or reference link to a supporting drawing or sketch file 'error', # information about an error (or known problem) that can prevent proper operation 'generator', # authoring tool or translation tool 'hint', # user hint about resource features or operation 'identifier', # url address or unique Uniform Resource Identifier (URI) for resource 'Image', # name or reference link to supporting image file 'info', # additional info of interest 'information', # additional information of interest 'isVersionOf', # Related resource of which the described resource is a version, edition, or adaptation. 'keywords', # comma-separated tokens, each of which is a keyword of interest 'license', # content or software license 'mediator', # entity that mediates access to resource and for whom resource is intended or useful 'modified', # date of modified version 'movie', # name or reference link to supporting movie file (note that Dublin Core term is MovingImage) 'MovingImage', # name or reference link to supporting movie 'original', # name or reference link to original file or resource 'photo', # name or reference link to supporting photo file (note that Dublin Core term is Image) 'photograph', # name or reference link to supporting photograph file (note that Dublin Core term is Image) 'publisher', # entity responsible for making the resource available 'reference', # name or reference link to supporting reference 'requires', # prerequisites for operation or viewing 'rights', # intellectual property rights (IPR) 'robots', # search engine and web-spider guidance value: noindex to block page indexing, nofollow to block following links 'Sound', # name or reference link to supporting sound file 'source', # related resource from which the described resource is derived 'specificationSection', # title of relevant specification section 'specificationUrl', # url for relevant specification section 'subject', # search-index subject keywords, key phrases, or classification codes 'Text', # resource consisting primarily of words for reading 'title', # file name for this resource 'TODO', # action item "to do" that still needs to be performed 'translator', # name of person performing translation from another format or language 'translated', # date of translation from another format or language 'version', # current version number or ID of this resource 'warning' # warning information about a known problem that impedes proper operation ) MULTITEXTUREFUNCTIONVALUES = ( # specification-defined values follow, other values are also allowed '"COMPLEMENT"', # Invert argument x as (1 - x) '"ALPHAREPLICATE"', # Replicate alpha information to all color channels before operation completes. '""' # No function is applied - empty SFString is allowed value within MFString array ) MULTITEXTUREMODEVALUES = ( # specification-defined values follow, other values are also allowed '"ADD"', '"ADDSIGNED"', '"ADDSIGNED2X"', '"ADDSMOOTH"', '"BLENDCURRENTALPHA"', '"BLENDDIFFUSEALPHA"', '"BLENDFACTORALPHA"', '"BLENDTEXTUREALPHA"', '"DOTPRODUCT3"', '"MODULATE"', '"MODULATE2X"', '"MODULATE4X"', '"MODULATEALPHA_ADDCOLOR"', '"MODULATEINVALPHA_ADDCOLOR"', '"MODULATEINVCOLOR_ADDALPHA"', '"OFF"', '"REPLACE"', '"SELECTARG1"', '"SELECTARG2"', '"SUBTRACT"' ) MULTITEXTURESOURCEVALUES = ( # specification-defined values follow, other values are also allowed '"DIFFUSE"', '"FACTOR"', '"SPECULAR"', '""' ) NAVIGATIONTRANSITIONTYPEVALUES = ( # specification-defined values follow, other values are also allowed '"TELEPORT"', # immediate transition '"LINEAR"', # transition may proceed directly through intervening objects '"ANIMATE"' # rowser-specific transition ) NAVIGATIONTYPEVALUES = ( # specification-defined values follow, other values are also allowed '"ANY"', # browser can offer any type for user to choose '"WALK"', # free navigation, avatar remains on ground, collision detection '"EXAMINE"', # view an individual object by rotating view about center '"FLY"', # free navigation, collision detection '"LOOKAT"', # navigate to particular object '"NONE"', # disables all navigation interfaces '"EXPLORE"' # consistent keystroke navigation for both geospatial and Cartesian modes ) NETWORKMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'standAlone', # ignore network but still respond to events in local scene 'networkReader', # listen to network and read PDU packets at readInterval, act as remotely linked copy of entity 'networkWriter' # send PDU packets to network at writeInterval, act as master entity ) def assertValidNetworkMode(fieldName, value): """ Utility function to assert type validity of networkModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in NETWORKMODECHOICES: # print('*** assertValidNetworkMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in NETWORKMODECHOICES: # print('*** assertValidNetworkMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in NETWORKMODECHOICES=' + str(NETWORKMODECHOICES)) PARTICLESYSTEMGEOMETRYTYPEVALUES = ( # specification-defined values follow, other values are also allowed 'LINE', # line is drawn along current velocity vector of particle 'POINT', # point geometry is rendered at particle position 'QUAD', # quad geometry is rendered at particle position facing direction traveled 'SPRITE', # quad geometry is rendered at particle position facing screen 'TRIANGLE', # pair of triangles creating quad geometry is rendered at particle position facing direction traveled 'GEOMETRY' # geometry field is used for rendering each particle ) PERIODICWAVETYPECHOICES = ( # strict set of allowed values follow, no other values are valid 'SINE', # X3D version of "sine" in Web Audio API. 'SQUARE', # X3D version of "square" in Web Audio API. 'SAWTOOTH', # X3D version of "sawtooth" in Web Audio API. 'TRIANGLE', # X3D version of "triangle" in Web Audio API. 'CUSTOM' # X3D version of "custom" in Web Audio API. ) def assertValidPeriodicWaveType(fieldName, value): """ Utility function to assert type validity of periodicWaveTypeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in PERIODICWAVETYPECHOICES: # print('*** assertValidPeriodicWaveType ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in PERIODICWAVETYPECHOICES: # print('*** assertValidPeriodicWaveType ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in PERIODICWAVETYPECHOICES=' + str(PERIODICWAVETYPECHOICES)) PHASEFUNCTIONVALUES = ( # specification-defined values follow, other values are also allowed 'Henyey-Greenstein', # Henyey-Greenstein phase function for scattering model 'NONE' # no scattering ) PICKABLEOBJECTTYPEVALUES = ( # specification-defined values follow, other values are also allowed '"ALL"', # each node is available for picking '"NONE"', # no node is available for picking '"TERRAIN"' # TERRAIN is an example value ) PICKSENSORMATCHCRITERIONCHOICES = ( # strict set of allowed values follow, no other values are valid 'MATCH_ANY', # any match of objectType values is acceptable 'MATCH_EVERY', # every objectType value in X3DPickSensorNode and X3DPickableObject shall match 'MATCH_ONLY_ONE' # one and only one objectType value can match ) def assertValidPickSensorMatchCriterion(fieldName, value): """ Utility function to assert type validity of pickSensorMatchCriterionChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in PICKSENSORMATCHCRITERIONCHOICES: # print('*** assertValidPickSensorMatchCriterion ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in PICKSENSORMATCHCRITERIONCHOICES: # print('*** assertValidPickSensorMatchCriterion ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in PICKSENSORMATCHCRITERIONCHOICES=' + str(PICKSENSORMATCHCRITERIONCHOICES)) PICKSENSORSORTORDERVALUES = ( # specification-defined values follow, other values are also allowed 'ANY', # any single object that can satisfy picking conditions 'CLOSEST', # return closest object by distance that satisfies conditions of this pick sensor 'ALL', # every object that satisfies picking conditions for this pick sensor is returned 'ALL_SORTED' # every object that satisfies picking conditions for this pick sensor is returned, in sorted order ) PROFILENAMECHOICES = ( # strict set of allowed values follow, no other values are valid 'Core', # Core Profile includes no nodes and is provided as the basis for custom componentization. Allowed X3D statements for all profiles are: connect ExternProtoDeclare EXPORT field fieldValue IMPORT IS ProtoBody ProtoDeclare ProtoInterface ProtoInstance ROUTE X3D. Allowed X3D nodes for this profile are: MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString. 'Interchange', # Interchange Profile equals the minimum subset of nodes needed to display lightweight compelling content. Allowed X3D nodes for this profile are: Appearance Background Box Color ColorInterpolator ColorRGBA Cone Coordinate CoordinateInterpolator Cylinder DirectionalLight Group ImageTexture IndexedFaceSet IndexedLineSet IndexedTriangleFanSet IndexedTriangleSet IndexedTriangleStripSet LineSet Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString MultiTexture MultiTextureCoordinate MultiTextureTransform NavigationInfo Normal NormalInterpolator OrientationInterpolator PixelTexture PointSet PositionInterpolator ScalarInterpolator Shape Sphere TextureCoordinate TextureCoordinateGenerator TextureTransform TimeSensor Transform TriangleFanSet TriangleSet TriangleStripSet Viewpoint WorldInfo. 'CADInterchange', # CADInterchange Profile adds support for CADGeometry component nodes to Interchange Profile. Allowed X3D nodes for this profile are: Anchor Appearance CADAssembly CADFace CADLayer CADPart Billboard Collision Color ColorRGBA Coordinate DirectionalLight FragmentShader Group ImageTexture IndexedLineSet IndexedQuadSet IndexedTriangleFanSet IndexedTriangleSet IndexedTriangleStripSet Inline LineProperties LineSet LOD Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString MultiShader MultiTexture MultiTextureCoordinate MultiTextureTransform NavigationInfo Normal PixelTexture PointSet QuadSet Shader ShaderAppearance Shape TextureCoordinate TextureCoordinateGenerator TextureTransform Transform TriangleFanSet TriangleSet TriangleStripSet Viewpoint VertexShader WorldInfo. 'Interactive', # Interactive Profile adds interaction nodes (Anchor, KeySensor) to the minimum subset of nodes needed to display lightweight compelling content. Allowed X3D nodes for this profile are: Anchor Appearance Background BooleanFilter BooleanSequencer BooleanToggle BooleanTrigger Box Color ColorInterpolator ColorRGBA Cone Coordinate CoordinateInterpolator Cylinder CylinderSensor DirectionalLight ElevationGrid Group ImageTexture IndexedFaceSet IndexedLineSet IndexedTriangleFanSet IndexedTriangleSet IndexedTriangleStripSet Inline IntegerSequencer IntegerTrigger KeySensor LineSet Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString MultiTexture MultiTextureCoordinate MultiTextureTransform NavigationInfo Normal NormalInterpolator OrientationInterpolator IndexedTriangleStripSet Inline IntegerSequencer IntegerTrigger KeySensor LineSet Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString MultiTexture MultiTextureCoordinate MultiTextureTransform NavigationInfo Normal NormalInterpolator OrientationInterpolator PixelTexture PlaneSensor PointLight PointSet PositionInterpolator ProximitySensor ScalarInterpolator Shape Sphere SphereSensor SpotLight StringSensor Switch TextureCoordinate TextureCoordinateGenerator TextureTransform TimeSensor TimeTrigger TouchSensor Transform TriangleFanSet TriangleSet TriangleStripSet Viewpoint VisibilitySensor WorldInfo. 'Immersive', # Immersive Profile equals all of the nodes in the VRML97 Specification, plus various X3D node additions including KeySensor, StringSensor and Scene. Allowed X3D nodes for this profile are: Anchor Appearance AudioClip Background Billboard BooleanFilter BooleanSequencer BooleanToggle BooleanTrigger Box Collision Color ColorInterpolator ColorRGBA Cone Coordinate CoordinateInterpolator Cylinder CylinderSensor DirectionalLight ElevationGrid Extrusion Fog FontStyle Group ImageTexture IndexedFaceSet IndexedLineSet IndexedTriangleFan IndexedTriangleSet IndexedTriangleStripSet Inline IntegerSequencer IntegerTrigger KeySensor LineProperties LineSet LoadSensor LOD Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString MovieTexture MultiTexture MultiTextureCoordinate MultiTextureTransform NavigationInfo Normal NormalInterpolator OrientationInterpolator PixelTexture PlaneSensor PointLight PointSet Polyline2D Polypoint2D PositionInterpolator ProximitySensor Rectangle2D ScalarInterpolator Script Shape Sound Sphere SphereSensor SpotLight StringSensor Switch Text TextureCoordinate TextureCoordinateGenerator TextureTransform TimeSensor TimeTrigger TouchSensor TriangleFanSet TriangleSet TriangleSet2D TriangleStripSet Transform Viewpoint VisibilitySensor WorldInfo. 'MedicalInterchange', # The MedicalInterchange profile adds support for VolumeRendering component to Interchange profile. Allowed X3D nodes for this profile are: Anchor Arc2D ArcClose2D Appearance Background Billboard BlendedVolumeStyle BooleanFilter BooleanSequencer BooleanToggle BooleanTrigger BoundaryEnhancementVolumeStyle Box CartoonVolumeStyle Circle2D ClipPlane Collision Color ColorInterpolator ColorRGBA ComposedVolumeStyle CompositeTexture3D Cone Coordinate CoordinateDouble CoordinateInterpolator Cylinder DirectionalLight Disk2D EdgeEnhancementVolumeStyle FillProperties FontStyle Group ImageTexture ImageTexture3D IndexedFaceSet IndexedLineSet IndexedTriangleFanSet IndexedTriangleSet IndexedTriangleStripSet Inline IntegerSequencer IntegerTrigger IsoSurfaceVolumeData LineProperties LineSet LOD Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString MultiTexture MultiTextureCoordinate MultiTextureTransform NavigationInfo Normal NormalInterpolator OctTree OpacityMapVolumeStyle OrientationInterpolator OrthoViewpoint PixelTexture PixelTexture3D PointSet Polyline2D Polypoint2D PositionInterpolator ProjectionVolumeStyle Rectangle2D ScalarInterpolator SegmentedVolumeData ShadedVolumeStyle Shape SilhouetteEnhancementVolumeStyle Sphere StaticGroup Switch Text TextureCoordinate TextureCoordinate3D TextureCoordinate4D TextureCoordinateGenerator TextureMatrixTransform TextureProperties TextureTransform TextureTransform3D TimeSensor TimeTrigger ToneMappedVolumeStyle Transform TriangleFanSet TriangleSet TriangleStripSet Viewpoint ViewpointGroup VolumeData WorldInfo. 'MPEG4Interactive', # MPEGInteractive Profile defines base interoperability with MPEG4 standards to a small subset of nodes needed to display lightweight compelling content. Allowed X3D nodes for this profile are: Anchor Appearance Background Box Color ColorInterpolator ColorRGBA Cone Coordinate CoordinateInterpolator Cylinder CylinderSensor DirectionalLight ElevationGrid Group ImageTexture IndexedFaceSet IndexedLineSet Inline LineSet Material MetadataBoolean MetadataDouble MetadataFloat MetadataInteger MetadataSet MetadataString NavigationInfo NormalInterpolator OrientationInterpolator PixelTexture PlaneSensor PointLight PointSet PositionInterpolator ProximitySensor ScalarInterpolator Shape Sphere SphereSensor SpotLight Switch TextureCoordinate TextureTransform TimeSensor TouchSensor Transform Viewpoint WorldInfo. 'Full' # The Full Profile corresponds to all Immersive X3D nodes plus all approved/implemented extensions. All X3D nodes and statements are allowed in this profile. ) def assertValidProfileName(fieldName, value): """ Utility function to assert type validity of profileNameChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in PROFILENAMECHOICES: # print('*** assertValidProfileName ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in PROFILENAMECHOICES: # print('*** assertValidProfileName ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in PROFILENAMECHOICES=' + str(PROFILENAMECHOICES)) PROJECTIONVOLUMESTYLETYPECHOICES = ( # strict set of allowed values follow, no other values are valid 'MAX', # Maximum Intensity Projection (MIP) or Least MIP (LMIP) algorithm is used to generate output color 'MIN', # Minimum Intensity Projection algorithm is used to generate output color 'AVERAGE' # All voxels along ray are averaged to generate output color ) def assertValidProjectionVolumeStyleType(fieldName, value): """ Utility function to assert type validity of projectionVolumeStyleTypeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in PROJECTIONVOLUMESTYLETYPECHOICES: # print('*** assertValidProjectionVolumeStyleType ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in PROJECTIONVOLUMESTYLETYPECHOICES: # print('*** assertValidProjectionVolumeStyleType ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in PROJECTIONVOLUMESTYLETYPECHOICES=' + str(PROJECTIONVOLUMESTYLETYPECHOICES)) SHADERLANGUAGEVALUES = ( # specification-defined values follow, other values are also allowed 'Cg', # nVidia Cg shading language 'GLSL', # OpenGL shading language (GLSL) 'HLSL' # Microsoft High Level Shading Language (HLSL) ) SHADERPARTTYPEVALUES = ( # specification-defined values follow, other values are also allowed 'VERTEX', # vertex shader 'FRAGMENT' # fragment shader ) TEXTUREBOUNDARYMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'CLAMP', # Clamp texture coordinates to range [0,1] 'CLAMP_TO_EDGE', # Clamp texture coordinates such that a border texel is never sampled 'CLAMP_TO_BOUNDARY', # Clamp texture coordinates such that texture samples are border texels for fragments 'MIRRORED_REPEAT', # Texture coordinates are mirrored and then clamped as in CLAMP_TO_EDGE 'REPEAT' # Repeat a texture across the fragment ) def assertValidTextureBoundaryMode(fieldName, value): """ Utility function to assert type validity of textureBoundaryModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in TEXTUREBOUNDARYMODECHOICES: # print('*** assertValidTextureBoundaryMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in TEXTUREBOUNDARYMODECHOICES: # print('*** assertValidTextureBoundaryMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in TEXTUREBOUNDARYMODECHOICES=' + str(TEXTUREBOUNDARYMODECHOICES)) TEXTURECOMPRESSIONMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'DEFAULT', # browser-specified default compression mode 'FASTEST', # fastest method available 'HIGH', # greatest amount of compression 'LOW', # least amount of compression 'MEDIUM', # moderate amount of compressions 'NICEST' # highest quality method available ) def assertValidTextureCompressionMode(fieldName, value): """ Utility function to assert type validity of textureCompressionModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in TEXTURECOMPRESSIONMODECHOICES: # print('*** assertValidTextureCompressionMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in TEXTURECOMPRESSIONMODECHOICES: # print('*** assertValidTextureCompressionMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in TEXTURECOMPRESSIONMODECHOICES=' + str(TEXTURECOMPRESSIONMODECHOICES)) TEXTURECOORDINATEGENERATORMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'SPHERE', # Creates texture coordinates for a spherical environment 'CAMERASPACENORMAL', # Use vertex normal, transformed to camera space, as input texture coordinates 'CAMERASPACEPOSITION', # Use vertex position, transformed to camera space, as input texture coordinates 'CAMERASPACEREFLECTIONVECTOR', # Use reflection vector, transformed to camera space, as input texture coordinates 'SPHERE-LOCAL', # Sphere mapping but in local coordinates 'COORD', # Use vertex coordinates 'COORD-EYE', # Use vertex coordinates transformed to camera space 'NOISE', # Apply Perlin solid noise function on vertex coordinates 'NOISE-EYE', # Apply Perlin solid noise function on vertex coordinates transformed to camera space 'SPHERE-REFLECT', # similar to CAMERASPACEREFLECTIONVECTOR with optional index of refraction 'SPHERE-REFLECT-LOCAL' # Similar to SPHERE-REFLECT transformed to camera space ) def assertValidTextureCoordinateGeneratorMode(fieldName, value): """ Utility function to assert type validity of textureCoordinateGeneratorModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in TEXTURECOORDINATEGENERATORMODECHOICES: # print('*** assertValidTextureCoordinateGeneratorMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in TEXTURECOORDINATEGENERATORMODECHOICES: # print('*** assertValidTextureCoordinateGeneratorMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in TEXTURECOORDINATEGENERATORMODECHOICES=' + str(TEXTURECOORDINATEGENERATORMODECHOICES)) TEXTUREMAGNIFICATIONMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'AVG_PIXEL', # weighted average of four texture elements closest to center of pixel being textured 'DEFAULT', # browser-specified default magnification mode 'FASTEST', # fastest method available 'NEAREST_PIXEL', # texture element nearest to the center of pixel being textured 'NICEST' # highest quality method available ) def assertValidTextureMagnificationMode(fieldName, value): """ Utility function to assert type validity of textureMagnificationModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in TEXTUREMAGNIFICATIONMODECHOICES: # print('*** assertValidTextureMagnificationMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in TEXTUREMAGNIFICATIONMODECHOICES: # print('*** assertValidTextureMagnificationMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in TEXTUREMAGNIFICATIONMODECHOICES=' + str(TEXTUREMAGNIFICATIONMODECHOICES)) TEXTUREMINIFICATIONMODECHOICES = ( # strict set of allowed values follow, no other values are valid 'AVG_PIXEL', # weighted average of four texture elements closest to center of pixel being textured 'AVG_PIXEL_AVG_MIPMAP', # tri-linear mipmap filtering 'AVG_PIXEL_NEAREST_MIPMAP', # choose mipmap that most closely matches size of pixel being textured, use weighted average of four texture elements closest to center of pixel 'DEFAULT', # browser-specified default minification mode 'FASTEST', # fastest method available, use mipmaps if possible 'NEAREST_PIXEL', # texture element nearest to center of pixel being textured 'NEAREST_PIXEL_AVG_MIPMAP', # texture element nearest to center of pixel being textured, use average of two nearest mipmaps 'NEAREST_PIXEL_NEAREST_MIPMAP', # texture element nearest to center of pixel being textured, use nearest mipmap 'NICEST' # highest quality method available ) def assertValidTextureMinificationMode(fieldName, value): """ Utility function to assert type validity of textureMinificationModeChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in TEXTUREMINIFICATIONMODECHOICES: # print('*** assertValidTextureMinificationMode ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in TEXTUREMINIFICATIONMODECHOICES: # print('*** assertValidTextureMinificationMode ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in TEXTUREMINIFICATIONMODECHOICES=' + str(TEXTUREMINIFICATIONMODECHOICES)) UNITCATEGORYCHOICES = ( # strict set of allowed values follow, no other values are valid 'angle', # angle default is radians 'force', # force default is newtons 'length', # length default is meters 'mass' # mass default is kilograms ) def assertValidUnitCategory(fieldName, value): """ Utility function to assert type validity of unitCategoryChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in UNITCATEGORYCHOICES: # print('*** assertValidUnitCategory ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in UNITCATEGORYCHOICES: # print('*** assertValidUnitCategory ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in UNITCATEGORYCHOICES=' + str(UNITCATEGORYCHOICES)) VOLUMERENDERINGWEIGHTFUNCTIONCHOICES = ( # strict set of allowed values follow, no other values are valid 'CONSTANT', # Use weightConstant1 'ALPHA1', # Use O_v 'ALPHA2', # Use O_blend 'ONE_MINUS_ALPHA1', # Use 1 - O_v 'ONE_MINUS_ALPHA2', # Use 1 - O_blend 'TABLE' # Use table lookup value ) def assertValidVolumeRenderingWeightFunction(fieldName, value): """ Utility function to assert type validity of volumeRenderingWeightFunctionChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in VOLUMERENDERINGWEIGHTFUNCTIONCHOICES: # print('*** assertValidVolumeRenderingWeightFunction ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in VOLUMERENDERINGWEIGHTFUNCTIONCHOICES: # print('*** assertValidVolumeRenderingWeightFunction ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in VOLUMERENDERINGWEIGHTFUNCTIONCHOICES=' + str(VOLUMERENDERINGWEIGHTFUNCTIONCHOICES)) WAVESHAPEROVERSAMPLECHOICES = ( # strict set of allowed values follow, no other values are valid 'NONE', # No oversampling. X3D version of "none" in Web Audio API. '2X', # Double sampling rate. X3D version of "2x" in Web Audio API. '4X' # Quadruple sampling rate. X3D version of "4x" in Web Audio API. ) def assertValidWaveShaperOversample(fieldName, value): """ Utility function to assert type validity of waveShaperOversampleChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in WAVESHAPEROVERSAMPLECHOICES: # print('*** assertValidWaveShaperOversample ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in WAVESHAPEROVERSAMPLECHOICES: # print('*** assertValidWaveShaperOversample ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in WAVESHAPEROVERSAMPLECHOICES=' + str(WAVESHAPEROVERSAMPLECHOICES)) X3DVERSIONCHOICES = ( # strict set of allowed values follow, no other values are valid '3.0', # X3D version 3.0 approved by ISO in 2004. '3.1', # X3D version 3.1 Amendment 1 approved by ISO in 2005. Backwards compatibility maintained with version 3.0. '3.2', # X3D version 3.2 Amendment 2 approved by ISO in 2007. Backwards compatibility maintained with versions 3.0 and 3.1. '3.3', # X3D version 3.3 approved by ISO in 2013 as International Standard (IS). Backwards compatibility maintained with versions 3.0, 3.1 and 3.2. '4.0' # X3D version 4.0 under final development by Web3D Consortium. Backwards compatibility maintained with versions 3.0, 3.1, 3.2 and 3.3. ) def assertValidX3dVersion(fieldName, value): """ Utility function to assert type validity of x3dVersionChoices value, otherwise raise X3DTypeError with diagnostic message. Note MFString enumeration values are provided in XML syntax, so check validity accordingly. """ if not value: return True # no failure on empty defaults if str(MFString(value).XML()) in X3DVERSIONCHOICES: # print('*** assertValidX3dVersion ' + fieldName + ' str(MFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True if isinstance(value, (SFString, str)) and str(SFString(value).XML()) in X3DVERSIONCHOICES: # print('*** assertValidX3dVersion ' + fieldName + ' str(SFString(' + str(value) + ').XML())=' + str(MFString(value).XML()), flush=True) # diagnostic return True raise X3DTypeError(fieldName + ' value=\'' + MFString(value).XML() + '\' does not match allowed enumerations in X3DVERSIONCHOICES=' + str(X3DVERSIONCHOICES)) ############################################### # Utility Functions def metaDiagnostics(self, headElement=None): """ Utility function to return any meta info, hint, warning, error, TODO values in this model. """ if headElement is None: headElement = self if isinstance(headElement, X3D): headElement = headElement.head # print('type(headElement)=' + str(type(headElement)), flush=True) # diagnostic if isinstance(headElement, head): result = "meta information, " for each in headElement.children: if isinstance(each, meta) and each.name in ('info', 'hint', 'warning', 'error', 'TODO'): result += each.name.strip() + ': ' + each.content.strip() if result.endswith('.') or result.endswith(','): result += ' ' else: result += ', ' if result.strip() != "meta information,": return result.rstrip(', ').strip() return '' def prependLineNumbers(someText="", lineNumber=0, blockInterval = 3): """ Utility function to prepend line numbers to block of text, can optionally define lineNumber and blockInterval. """ # https://stackoverflow.com/questions/64621076/how-to-add-line-numbers-to-multiline-string result = '' count = 1 splitLines = someText.splitlines() if not lineNumber: lineNumber = 0 if lineNumber == 0: first = 0 last = len(splitLines) else: first = max(lineNumber - blockInterval - 1, 0) last = min(lineNumber + blockInterval, len(splitLines)) print("*** issue in line", str(lineNumber), "of", str(len(splitLines)), "***") # "first=" + str(first), "last=" + str(last) + for line in splitLines[first:last]: result += ("{}{:2d}{}{}".format("[",first + count,"] ",line)) + '\n' count += 1 return result ############################################### # Field Validation Functions # Type-specific functions to check for valid values, throw exception if illegal value is found def fixBoolean(value, default=None): """ Utility function to convert boolean to corresponding Python value. """ # if _DEBUG: print('fixBoolean(value=' + str(value) + ', type=' + str(type(value)) + ', default=' + str(default) + ')', flush=True) if value is None: # if _DEBUG: print('...DEBUG... fixBoolean set value to default=' + str(default)) return default # print('fixBoolean #0a') # if isinstance(value, MFBool): # value = value.value # dereference # print('fixBoolean #0a dereferenced') # print('fixBoolean #0b') if isinstance(value, list) and len(value) == 0: return value # print('fixBoolean #1') # debug if isinstance(value, list) and len(value) == 1: # if _DEBUG: print('fixBoolean downcasting by resetting singleton list value=' + str(value) + ' as value=' + str(value[0]), flush=True) return value[0] # dereference if isinstance(value, SFBool): return value.value # dereference if isinstance(value, MFBool) and len(value) == 1: return value.value[0] # dereference # print('fixBoolean #2') # debug if value in ('true', 'True'): return True if value in ('false', 'False'): return False # print('fixBoolean #3') # debug if isinstance(value, bool): return value # print('fixBoolean #4') # debug if isinstance(value, MFBool): value = value.value # dereference value from base type # print('fixBoolean #4a, dereference MFBool') # debug if isinstance(value, list): # print('fixBoolean #4b found list, value=' + str(value), ' length=' + str(len(value))) # debug index = 0 result = value for each in value: if each in ('true', 'True'): result[index] = True elif each in ('false', 'False'): result[index] = False while isinstance(each, list) and len(each) == 1: # if _DEBUG: print('fixBoolean downcasting by extracting singleton list value[' + str(index) + ']=' + str(each) + ' as each[0]=' + str(each[0]), flush=True) result[index] = each[0] # print('fixBoolean #4c found each=' + str(each), 'result=' + str(result), flush=True) # debug if not isinstance(result[index], bool): # print(flush=True) raise X3DTypeError('fixBoolean(value=' + str(value) + ') MFBool value[' + str(index) + ']=' + str(each) + ', result[' + str(index) + ']=' + str(result[index]) + ' with type=' + str(type(value)) + ' is not a valid Python bool expression') index += 1 # if _DEBUG: print('...DEBUG...fixBoolean result=' + str(result), flush=True) return result # print('fixBoolean #5, unhandled case: value=' + str(value), ' length=' + str(len(value))) # debug print(flush=True) raise X3DTypeError('fixBoolean(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python bool') def isPositive(value): """ Utility function to confirm positive value(s) greater than or equal to zero. """ if value is None: return None if isinstance(value, list) and any(isinstance(x, tuple) for x in value): for each in value: for element in each: if element <= 0: return False return True if isinstance(value, (list, tuple)): for each in value: if each <= 0: return False return True if isinstance(value, (int, float)): return value > 0 raise X3DTypeError('isPositive(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertPositive(fieldName, value): """ Utility function to raise X3DTypeError if not isPositive(value). """ # if _DEBUG: print('...DEBUG... assertPositive(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isPositive(value), str(fieldName) + '=' + str(value) + ' fails assertPositive requirements: value(s) must be greater than or equal to zero' def isNonNegative(value): """ Utility function to confirm nonnegative value(s) greater than or equal to zero. """ if value is None: return None if isinstance(value, list) and any(isinstance(x, tuple) for x in value): for each in value: for element in each: if element < 0: return False return True if isinstance(value, (list, tuple)): # if _DEBUG: print('isNonNegative: ', value, flush=True) for each in value: if each < 0: return False return True if isinstance(value, (int, float)): return value >= 0 raise X3DTypeError('isNonNegative(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertNonNegative(fieldName, value): """ Utility function to raise X3DTypeError if not isNonNegative(value). """ # if _DEBUG: print('...DEBUG... assertNonNegative(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isNonNegative(value), str(fieldName) + '=' + str(value) + ' fails assertNonNegative requirements: value(s) must be greater than or equal to zero' def isZeroToOne(value): """ Utility function to confirm value(s) in range [0..1] """ # if _DEBUG: print('...DEBUG... isZeroToOne(' + str(value) + ')', flush=True) if value is None: return None if isinstance(value,_X3DField): value = value.value # dereference if isinstance(value, (list, tuple)): for each in value: if isinstance(each, (list, tuple)): for another in each: if not 0 <= another <= 1: return False elif not 0 <= each <= 1: return False return True if isinstance(value, (int, float)): return 0 <= value <= 1 raise X3DTypeError('isZeroToOne(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertZeroToOne(fieldName, value): """ Utility function to raise X3DTypeError if not isZeroToOne(value) """ # if _DEBUG: print('...DEBUG... assertZeroToOne(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isZeroToOne(value), str(fieldName) + '=' + str(value) + ' fails assertZeroToOne requirements: value(s) must be in range [0..1]' def isLessThanEquals(value, maximum): """ Utility function to confirm value(s) less than or equal to maximum. """ # if True or _DEBUG: print('* debug: isLessThanEquals(' + str(value) + ')', flush=True) if value is None: return None if isinstance(value, list) and any(isinstance(x, tuple) for x in value): for each in value: for element in each: if element > maximum: return False return True if isinstance(value, (list, tuple)): for each in value: if each > maximum: return False return True if isinstance(value, (int, float)): return value <= maximum raise X3DTypeError('isLessThanEquals(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertLessThanEquals(fieldName, value, maximum): """ Utility function to raise X3DTypeError if not isLessThanEquals(value) """ # if _DEBUG: print('...DEBUG... assertLessThanEquals(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isLessThanEquals(value, maximum), fieldName + '=' + str(value) + ' fails assertLessThanEquals maximum=' + str(maximum) def isLessThan(value, maximum): """ Utility function to confirm value(s) less than maximum. """ # if True or _DEBUG: print('* debug: isLessThan(' + str(value) + ')', flush=True) if value is None: return None if isinstance(value, list) and any(isinstance(x, tuple) for x in value): for each in value: for element in each: if element >= maximum: return False return True if isinstance(value, (list, tuple)): for each in value: if each >= maximum: return False return True if isinstance(value, (int, float)): return value < maximum raise X3DTypeError('isLessThan(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertLessThan(fieldName, value, maximum): """ Utility function to raise X3DTypeError if not isLessThan(value) """ # if _DEBUG: print('...DEBUG... assertLessThan(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isLessThan(value, maximum), str(fieldName) + '=' + str(value) + ' fails assertLessThan maximum=' + str(maximum) ###### def isGreaterThanEquals(value, minimum): """ Utility function to confirm value(s) less than or equal to minimum. """ # if True or _DEBUG: print('* debug: isGreaterThanEquals(' + str(value) + ')', flush=True) if value is None: return None if isinstance(value, list) and any(isinstance(x, tuple) for x in value): for each in value: for element in each: if element < minimum: return False return True if isinstance(value, (list, tuple)): for each in value: if each < minimum: return False return True if isinstance(value, (int, float)): return value >= minimum raise X3DTypeError('isGreaterThanEquals(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertGreaterThanEquals(fieldName, value, minimum): """ Utility function to raise X3DTypeError if not isGreaterThanEquals(value) """ # if _DEBUG: print('...DEBUG... assertGreaterThanEquals(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isGreaterThanEquals(value, minimum), str(fieldName) + '=' + str(value) + ' fails assertGreaterThanEquals minimum=' + str(minimum) def isGreaterThan(value, minimum): """ Utility function to confirm value(s) less than minimum. """ # if True or _DEBUG: print('* debug: isGreaterThan(' + str(value) + ')', flush=True) if isinstance(value, list) and any(isinstance(x, tuple) for x in value): for each in value: for element in each: if element <= minimum: return False return True if isinstance(value, (list, tuple)): for each in value: if each <= minimum: return False return True if isinstance(value, (int, float)): return value > minimum raise X3DTypeError('isGreaterThan(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python number') def assertGreaterThan(fieldName, value, minimum): """ Utility function to raise X3DTypeError if not isGreaterThan(value) """ # if _DEBUG: print('...DEBUG... assertGreaterThan(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isGreaterThan(value, minimum), str(fieldName) + '=' + str(value) + ' fails assertGreaterThan minimum=' + str(minimum) def isBoundingBox(value): """ Utility function to confirm legal X3D bounding box value of (-1 -1 -1) or nonnegative triple. """ if value is None: return None # if True or _DEBUG: print('* debug: isBoundingBox(' + str(value) + ')', 'isinstance(value, tuple)=' + str(isinstance(value, tuple)), 'len(value)=' + str(len(value)), flush=True) if isinstance(value, (list, tuple)): if len(value) != 3: return False if value[0] == -1 and value[1] == -1 and value[2] == -1: return True return isNonNegative(value) # legal bounding box tuple raise X3DTypeError('isBoundingBox(value=' + str(value) + ') with type=' + str(type(value)) + ') is not a valid Python numeric triple') def assertBoundingBox(fieldName, value): """ Utility function to raise X3DTypeError if not isBoundingBox(value) """ # if True or _DEBUG: print('* debug: assertBoundingBox(' + str(fieldName) + ', ' + str(value) + ')', flush=True) assert isBoundingBox(value), str(fieldName) + '=' + str(value) + ' fails assertBoundingBox requirements: must be (-1, -1, -1) or non-negative 3-tuple' def isValidSFBool(value): """ Utility function to determine type validity of a SFBool value. """ if re.fullmatch(SFBool().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFBool().REGEX_PYTHON(),' + str(value) + ')') return False try: SFBool(value) return True except ValueError: print('isValidSFBool failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFBool) and not isinstance(value, MFBool): ### # if _DEBUG: print('SFBool type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFBool)=' + str(isinstance(value, SFBool)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFBool): ### value = value.value # dereference value from base type ### if re.fullmatch(SFBool().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFBool) and (len(value) == 1) and isValidMFBool(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, bool): ### return False ### return True def assertValidSFBool(value): """ Utility function to assert type validity of a SFBool value, otherwise raise X3DTypeError with diagnostic message. """ try: SFBool(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFBool') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFBool) and not isinstance(value, MFBool): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFBool') ### if isinstance(value, SFBool): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFBool) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b ### if not isinstance(value, bool): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid bool value (True or False) for SFBool') ### if not isValidSFBool(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python bool value (True or False) for SFBool') return True def isValidMFBool(value): """ Utility function to determine type validity of a MFBool value. """ if re.fullmatch(MFBool().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFBool().REGEX_PYTHON(),' + str(value) + ')') return False try: MFBool(value) return True except ValueError: print('isValidMFBool failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFBool) and not isinstance(value, MFBool): ### # if _DEBUG: print('MFBool type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFBool)=' + str(isinstance(value, MFBool)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFBool): ### value = value.value # dereference value from base type ### if re.fullmatch(MFBool().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFBool): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFBool): ### each = each.value # dereference ### if not isinstance(each, bool): ### return False ### return True def assertValidMFBool(value): """ Utility function to assert type validity of a MFBool value, otherwise raise X3DTypeError with diagnostic message. """ try: MFBool(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFBool') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFBool) and not isinstance(value, MFBool): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFBool') ### if isinstance(value, MFBool): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFBool)) and not isinstance(value, list): ### value = list(SFBool(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFBool') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFBool): ### each = each.value # dereference ### if not isinstance(each, bool): ### # print(flush=True) ### raise X3DTypeError('MFBool list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid bool') ### if not isValidMFBool(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFBool') return True def isValidSFColor(value): """ Utility function to determine type validity of a SFColor value. """ if re.fullmatch(SFColor().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFColor().REGEX_PYTHON(),' + str(value) + ')') return False try: SFColor(value) return True except ValueError: print('isValidSFColor failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFColor) and not isinstance(value, MFColor): ### # if _DEBUG: print('SFColor type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFColor)=' + str(isinstance(value, SFColor)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFColor): ### value = value.value # dereference value from base type ### if re.fullmatch(SFColor().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFColor) and (len(value) == 1) and isValidMFColor(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFColor): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if (each < 0) or (each > 1): ### return False ### if tupleCount != 3: ### return False ### if not isZeroToOne(value): ### return False ### return True def assertValidSFColor(value): """ Utility function to assert type validity of a SFColor value, otherwise raise X3DTypeError with diagnostic message. """ try: SFColor(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFColor') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFColor) and not isinstance(value, MFColor): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFColor') ### if isinstance(value, SFColor): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFColor(value) ### print('found string for SFColor, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFColor) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFColor encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFColor') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFColor') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFColor): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFColor list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if (each < 0) or (each > 1): ### # print(flush=True) ### raise X3DTypeError('SFColor' + str(value)[:100] + ' has value ' + str(each) + ' with type=' + str(type(value)) + ' is out of range [0..1] and is not a valid SFColor') ### if tupleCount != 3: ### # print(flush=True) ### raise X3DTypeError('SFColor ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 3') ### assertZeroToOne('SFColor', value) ### if not isValidSFColor(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFColor') return True def isValidMFColor(value): """ Utility function to determine type validity of a MFColor value. """ if re.fullmatch(MFColor().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFColor().REGEX_PYTHON(),' + str(value) + ')') return False try: MFColor(value) return True except ValueError: print('isValidMFColor failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFColor) and not isinstance(value, MFColor): ### # if _DEBUG: print('MFColor type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFColor)=' + str(isinstance(value, MFColor)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFColor): ### value = value.value # dereference value from base type ### if re.fullmatch(MFColor().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFColor): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFColor().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFColor tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFColor().TUPLE_SIZE() =' + str(MFColor().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### if (element < 0) or (element > 1): ### return False ### if not isZeroToOne(value): ### return False ### return True def assertValidMFColor(value): """ Utility function to assert type validity of a MFColor value, otherwise raise X3DTypeError with diagnostic message. """ try: MFColor(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFColor') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFColor) and not isinstance(value, MFColor): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFColor') ### if isinstance(value, MFColor): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFColor(value) ### print('found string for MFColor, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFColor)) and not isinstance(value, list): ### value = list(SFColor(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFColor') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFColor().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFColor tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFColor().TUPLE_SIZE() =' + str(MFColor().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFColor)): # # print(flush=True) # raise X3DTypeError('MFColor element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFColor element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if (element < 0) or (element > 1): ### # print(flush=True) ### raise X3DTypeError('MFColor' + str(value)[:100] + ' has value ' + str(element) + ' with type=' + str(type(value)) + ' out of range [0..1] and is not a valid MFColor') ### assertZeroToOne('MFColor', value) ### if not isValidMFColor(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFColor') return True def isValidSFColorRGBA(value): """ Utility function to determine type validity of a SFColorRGBA value. """ if re.fullmatch(SFColorRGBA().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFColorRGBA().REGEX_PYTHON(),' + str(value) + ')') return False try: SFColorRGBA(value) return True except ValueError: print('isValidSFColorRGBA failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFColorRGBA) and not isinstance(value, MFColorRGBA): ### # if _DEBUG: print('SFColorRGBA type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFColorRGBA)=' + str(isinstance(value, SFColorRGBA)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFColorRGBA): ### value = value.value # dereference value from base type ### if re.fullmatch(SFColorRGBA().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFColorRGBA) and (len(value) == 1) and isValidMFColorRGBA(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFColorRGBA): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if (each < 0) or (each > 1): ### return False ### if tupleCount != 4: ### return False ### if not isZeroToOne(value): ### return False ### return True def assertValidSFColorRGBA(value): """ Utility function to assert type validity of a SFColorRGBA value, otherwise raise X3DTypeError with diagnostic message. """ try: SFColorRGBA(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFColorRGBA') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFColorRGBA) and not isinstance(value, MFColorRGBA): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFColorRGBA') ### if isinstance(value, SFColorRGBA): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFColorRGBA(value) ### print('found string for SFColorRGBA, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFColorRGBA) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFColorRGBA encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFColorRGBA') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFColorRGBA') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFColorRGBA): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFColorRGBA list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if (each < 0) or (each > 1): ### # print(flush=True) ### raise X3DTypeError('SFColorRGBA' + str(value)[:100] + ' has value ' + str(each) + ' with type=' + str(type(value)) + ' is out of range [0..1] and is not a valid SFColorRGBA') ### if tupleCount != 4: ### # print(flush=True) ### raise X3DTypeError('SFColorRGBA ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 4') ### assertZeroToOne('SFColorRGBA', value) ### if not isValidSFColorRGBA(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFColorRGBA') return True def isValidMFColorRGBA(value): """ Utility function to determine type validity of a MFColorRGBA value. """ if re.fullmatch(MFColorRGBA().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFColorRGBA().REGEX_PYTHON(),' + str(value) + ')') return False try: MFColorRGBA(value) return True except ValueError: print('isValidMFColorRGBA failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFColorRGBA) and not isinstance(value, MFColorRGBA): ### # if _DEBUG: print('MFColorRGBA type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFColorRGBA)=' + str(isinstance(value, MFColorRGBA)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFColorRGBA): ### value = value.value # dereference value from base type ### if re.fullmatch(MFColorRGBA().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFColorRGBA): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFColorRGBA().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFColorRGBA tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFColorRGBA().TUPLE_SIZE() =' + str(MFColorRGBA().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### if (element < 0) or (element > 1): ### return False ### if not isZeroToOne(value): ### return False ### return True def assertValidMFColorRGBA(value): """ Utility function to assert type validity of a MFColorRGBA value, otherwise raise X3DTypeError with diagnostic message. """ try: MFColorRGBA(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFColorRGBA') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFColorRGBA) and not isinstance(value, MFColorRGBA): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFColorRGBA') ### if isinstance(value, MFColorRGBA): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFColorRGBA(value) ### print('found string for MFColorRGBA, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFColorRGBA)) and not isinstance(value, list): ### value = list(SFColorRGBA(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFColorRGBA') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFColorRGBA().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFColorRGBA tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFColorRGBA().TUPLE_SIZE() =' + str(MFColorRGBA().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFColorRGBA)): # # print(flush=True) # raise X3DTypeError('MFColorRGBA element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFColorRGBA element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if (element < 0) or (element > 1): ### # print(flush=True) ### raise X3DTypeError('MFColorRGBA' + str(value)[:100] + ' has value ' + str(element) + ' with type=' + str(type(value)) + ' out of range [0..1] and is not a valid MFColorRGBA') ### assertZeroToOne('MFColorRGBA', value) ### if not isValidMFColorRGBA(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFColorRGBA') return True def isValidSFDouble(value): """ Utility function to determine type validity of a SFDouble value. """ if re.fullmatch(SFDouble().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFDouble().REGEX_PYTHON(),' + str(value) + ')') return False try: SFDouble(value) return True except ValueError: print('isValidSFDouble failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFDouble) and not isinstance(value, MFDouble): ### # if _DEBUG: print('SFDouble type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFDouble)=' + str(isinstance(value, SFDouble)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFDouble): ### value = value.value # dereference value from base type ### if re.fullmatch(SFDouble().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFDouble) and (len(value) == 1) and isValidMFDouble(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, float) and not isinstance(value, int): ### return False ### return True def assertValidSFDouble(value): """ Utility function to assert type validity of a SFDouble value, otherwise raise X3DTypeError with diagnostic message. """ try: SFDouble(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFDouble') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFDouble) and not isinstance(value, MFDouble): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFDouble') ### if isinstance(value, SFDouble): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFDouble(value) ### print('found string for SFDouble, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFDouble) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFDouble encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFDouble') ### if not isinstance(value, float) and not isinstance(value, int): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFDouble') ### if not isValidSFDouble(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python float value for SFDouble') return True def isValidMFDouble(value): """ Utility function to determine type validity of a MFDouble value. """ if re.fullmatch(MFDouble().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFDouble().REGEX_PYTHON(),' + str(value) + ')') return False try: MFDouble(value) return True except ValueError: print('isValidMFDouble failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFDouble) and not isinstance(value, MFDouble): ### # if _DEBUG: print('MFDouble type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFDouble)=' + str(isinstance(value, MFDouble)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFDouble): ### value = value.value # dereference value from base type ### if re.fullmatch(MFDouble().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFDouble): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFDouble): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### return True def assertValidMFDouble(value): """ Utility function to assert type validity of a MFDouble value, otherwise raise X3DTypeError with diagnostic message. """ try: MFDouble(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFDouble') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFDouble) and not isinstance(value, MFDouble): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFDouble') ### if isinstance(value, MFDouble): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFDouble(value) ### print('found string for MFDouble, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFDouble)) and not isinstance(value, list): ### value = list(SFDouble(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFDouble') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFDouble): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('MFDouble list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if not isValidMFDouble(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFDouble') return True def isValidSFFloat(value): """ Utility function to determine type validity of a SFFloat value. """ if re.fullmatch(SFFloat().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFFloat().REGEX_PYTHON(),' + str(value) + ')') return False try: SFFloat(value) return True except ValueError: print('isValidSFFloat failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFFloat) and not isinstance(value, MFFloat): ### # if _DEBUG: print('SFFloat type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFFloat)=' + str(isinstance(value, SFFloat)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFFloat): ### value = value.value # dereference value from base type ### if re.fullmatch(SFFloat().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFFloat) and (len(value) == 1) and isValidMFFloat(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, float) and not isinstance(value, int): ### return False ### return True def assertValidSFFloat(value): """ Utility function to assert type validity of a SFFloat value, otherwise raise X3DTypeError with diagnostic message. """ try: SFFloat(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFFloat') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFFloat) and not isinstance(value, MFFloat): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFFloat') ### if isinstance(value, SFFloat): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFFloat(value) ### print('found string for SFFloat, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFFloat) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFFloat encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFFloat') ### if not isinstance(value, float) and not isinstance(value, int): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFFloat') ### if not isValidSFFloat(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python float value for SFFloat') return True def isValidMFFloat(value): """ Utility function to determine type validity of a MFFloat value. """ if re.fullmatch(MFFloat().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFFloat().REGEX_PYTHON(),' + str(value) + ')') return False try: MFFloat(value) return True except ValueError: print('isValidMFFloat failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFFloat) and not isinstance(value, MFFloat): ### # if _DEBUG: print('MFFloat type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFFloat)=' + str(isinstance(value, MFFloat)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFFloat): ### value = value.value # dereference value from base type ### if re.fullmatch(MFFloat().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFFloat): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFFloat): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### return True def assertValidMFFloat(value): """ Utility function to assert type validity of a MFFloat value, otherwise raise X3DTypeError with diagnostic message. """ try: MFFloat(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFFloat') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFFloat) and not isinstance(value, MFFloat): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFFloat') ### if isinstance(value, MFFloat): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFFloat(value) ### print('found string for MFFloat, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFFloat)) and not isinstance(value, list): ### value = list(SFFloat(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFFloat') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFFloat): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('MFFloat list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if not isValidMFFloat(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFFloat') return True def isValidSFImage(value): """ Utility function to determine type validity of a SFImage value. """ if re.fullmatch(SFImage().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFImage().REGEX_PYTHON(),' + str(value) + ')') return False try: SFImage(value) return True except ValueError: print('isValidSFImage failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFImage) and not isinstance(value, MFImage): ### # if _DEBUG: print('SFImage type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFImage)=' + str(isinstance(value, SFImage)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFImage): ### value = value.value # dereference value from base type ### if re.fullmatch(SFImage().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFImage) and (len(value) == 1) and isValidMFImage(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFImage): ### each = each.value # dereference ### if not isinstance(each, int): ### return False ### if len(value) > 0: # SFImage list length checks ### if 0 < len(value) < 3: ### return False # SFImage list must start with width, height and number of components (0..4) ### width = value[0] ### height = value[1] ### # numberComponents = value[2] ### if len(value) != (width * height) + 3: # assumes each value in array has all component values in single integer ### print('SFImage array length of ' + str(len(value)) + ' does not equal (width=' + str(width)+ ' * height=' + str(height)+ ') + 3) = ' + str(width * height * numberComponents + 3) + ' (numberComponents=' + numberComponents + ')', flush=True) ### return False # SFImage has invalid list length ### return True def assertValidSFImage(value): """ Utility function to assert type validity of a SFImage value, otherwise raise X3DTypeError with diagnostic message. """ try: SFImage(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFImage') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFImage) and not isinstance(value, MFImage): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFImage') ### if isinstance(value, SFImage): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFImage) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFImage encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFImage') ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for SFImage') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFImage): ### each = each.value # dereference ### if not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFImage list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid int') ### if not isValidSFImage(value): ### # print(flush=True) ### diagnostic = '' ### if len(value) > 0: # SFImage list length checks ### if 0 < len(value) < 3: ### diagnostic = 'SFImage list must start with width, height and number of components (0..4)' ### else: ### width = value[0] ### height = value[1] ### numberComponents = value[2] ### diagnostic = ' array length of ' + str(len(value)) + ' does not equal (width=' + str(width)+ ' * height=' + str(height)+ ') + 3) = ' + str(width * height + 3) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for SFImage' + diagnostic) return True def isValidMFImage(value): """ Utility function to determine type validity of a MFImage value. """ if re.fullmatch(MFImage().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFImage().REGEX_PYTHON(),' + str(value) + ')') return False try: MFImage(value) return True except ValueError: print('isValidMFImage failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFImage) and not isinstance(value, MFImage): ### # if _DEBUG: print('MFImage type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFImage)=' + str(isinstance(value, MFImage)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFImage): ### value = value.value # dereference value from base type ### if re.fullmatch(MFImage().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFImage): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFImage): ### each = each.value # dereference ### if not isinstance(each, int): ### return False ### return True def assertValidMFImage(value): """ Utility function to assert type validity of a MFImage value, otherwise raise X3DTypeError with diagnostic message. """ try: MFImage(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFImage') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFImage) and not isinstance(value, MFImage): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFImage') ### if isinstance(value, MFImage): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFImage)) and not isinstance(value, list): ### value = list(SFImage(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFImage') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFImage): ### each = each.value # dereference ### if not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('MFImage list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid int') ### if not isValidMFImage(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFImage') return True def isValidSFInt32(value): """ Utility function to determine type validity of a SFInt32 value. """ if re.fullmatch(SFInt32().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFInt32().REGEX_PYTHON(),' + str(value) + ')') return False try: SFInt32(value) return True except ValueError: print('isValidSFInt32 failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFInt32) and not isinstance(value, MFInt32): ### # if _DEBUG: print('SFInt32 type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFInt32)=' + str(isinstance(value, SFInt32)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFInt32): ### value = value.value # dereference value from base type ### if re.fullmatch(SFInt32().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFInt32) and (len(value) == 1) and isValidMFInt32(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, int): ### return False ### return True def assertValidSFInt32(value): """ Utility function to assert type validity of a SFInt32 value, otherwise raise X3DTypeError with diagnostic message. """ try: SFInt32(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFInt32') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFInt32) and not isinstance(value, MFInt32): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFInt32') ### if isinstance(value, SFInt32): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### try: ### value = SFInt32(value) ### print('found string for SFInt32, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### return True ### except: ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid int value for SFInt32') ### elif isinstance(value, MFInt32) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### int(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFInt32 encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid int value for SFInt32') ### if not isinstance(value, int): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid int value for SFInt32') ### if not isValidSFInt32(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python int value for SFInt32') return True def isValidMFInt32(value): """ Utility function to determine type validity of a MFInt32 value. """ if re.fullmatch(MFInt32().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFInt32().REGEX_PYTHON(),' + str(value) + ')') return False try: MFInt32(value) return True except ValueError: print('isValidMFInt32 failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFInt32) and not isinstance(value, MFInt32): ### # if _DEBUG: print('MFInt32 type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFInt32)=' + str(isinstance(value, MFInt32)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFInt32): ### value = value.value # dereference value from base type ### if re.fullmatch(MFInt32().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFInt32): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFInt32): ### each = each.value # dereference ### if not isinstance(each, int): ### return False ### return True def assertValidMFInt32(value): """ Utility function to assert type validity of a MFInt32 value, otherwise raise X3DTypeError with diagnostic message. """ try: MFInt32(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFInt32') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFInt32) and not isinstance(value, MFInt32): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFInt32') ### if isinstance(value, MFInt32): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### try: ### value = SFInt32(value) ### print('found string for MFInt32, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### return True ### except: ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid int value for SFInt32') ### elif (isinstance(value, SFInt32)) and not isinstance(value, list): ### value = list(SFInt32(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFInt32') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFInt32): ### each = each.value # dereference ### if not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('MFInt32 list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid int') ### if not isValidMFInt32(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFInt32') return True def isValidSFMatrix3d(value): """ Utility function to determine type validity of a SFMatrix3d value. """ if re.fullmatch(SFMatrix3d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFMatrix3d().REGEX_PYTHON(),' + str(value) + ')') return False try: SFMatrix3d(value) return True except ValueError: print('isValidSFMatrix3d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix3d) and not isinstance(value, MFMatrix3d): ### # if _DEBUG: print('SFMatrix3d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFMatrix3d)=' + str(isinstance(value, SFMatrix3d)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFMatrix3d): ### value = value.value # dereference value from base type ### if re.fullmatch(SFMatrix3d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFMatrix3d) and (len(value) == 1) and isValidMFMatrix3d(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix3d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 9: ### return False ### return True def assertValidSFMatrix3d(value): """ Utility function to assert type validity of a SFMatrix3d value, otherwise raise X3DTypeError with diagnostic message. """ try: SFMatrix3d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFMatrix3d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix3d) and not isinstance(value, MFMatrix3d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFMatrix3d') ### if isinstance(value, SFMatrix3d): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFMatrix3d) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFMatrix3d encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFMatrix3d') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix3d') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix3d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFMatrix3d list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 9: ### # print(flush=True) ### raise X3DTypeError('SFMatrix3d ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 9') ### if not isValidSFMatrix3d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix3d') return True def isValidMFMatrix3d(value): """ Utility function to determine type validity of a MFMatrix3d value. """ if re.fullmatch(MFMatrix3d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFMatrix3d().REGEX_PYTHON(),' + str(value) + ')') return False try: MFMatrix3d(value) return True except ValueError: print('isValidMFMatrix3d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix3d) and not isinstance(value, MFMatrix3d): ### # if _DEBUG: print('MFMatrix3d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFMatrix3d)=' + str(isinstance(value, MFMatrix3d)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFMatrix3d): ### value = value.value # dereference value from base type ### if re.fullmatch(MFMatrix3d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFMatrix3d): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFMatrix3d().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFMatrix3d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix3d().TUPLE_SIZE() =' + str(MFMatrix3d().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFMatrix3d(value): """ Utility function to assert type validity of a MFMatrix3d value, otherwise raise X3DTypeError with diagnostic message. """ try: MFMatrix3d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFMatrix3d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix3d) and not isinstance(value, MFMatrix3d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFMatrix3d') ### if isinstance(value, MFMatrix3d): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFMatrix3d)) and not isinstance(value, list): ### value = list(SFMatrix3d(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix3d') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFMatrix3d().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFMatrix3d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix3d().TUPLE_SIZE() =' + str(MFMatrix3d().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFMatrix3d)): # # print(flush=True) # raise X3DTypeError('MFMatrix3d element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFMatrix3d element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFMatrix3d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix3d') return True def isValidSFMatrix3f(value): """ Utility function to determine type validity of a SFMatrix3f value. """ if re.fullmatch(SFMatrix3f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFMatrix3f().REGEX_PYTHON(),' + str(value) + ')') return False try: SFMatrix3f(value) return True except ValueError: print('isValidSFMatrix3f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix3f) and not isinstance(value, MFMatrix3f): ### # if _DEBUG: print('SFMatrix3f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFMatrix3f)=' + str(isinstance(value, SFMatrix3f)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFMatrix3f): ### value = value.value # dereference value from base type ### if re.fullmatch(SFMatrix3f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFMatrix3f) and (len(value) == 1) and isValidMFMatrix3f(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix3f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 9: ### return False ### return True def assertValidSFMatrix3f(value): """ Utility function to assert type validity of a SFMatrix3f value, otherwise raise X3DTypeError with diagnostic message. """ try: SFMatrix3f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFMatrix3f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix3f) and not isinstance(value, MFMatrix3f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFMatrix3f') ### if isinstance(value, SFMatrix3f): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFMatrix3f) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFMatrix3f encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFMatrix3f') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix3f') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix3f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFMatrix3f list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 9: ### # print(flush=True) ### raise X3DTypeError('SFMatrix3f ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 9') ### if not isValidSFMatrix3f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix3f') return True def isValidMFMatrix3f(value): """ Utility function to determine type validity of a MFMatrix3f value. """ if re.fullmatch(MFMatrix3f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFMatrix3f().REGEX_PYTHON(),' + str(value) + ')') return False try: MFMatrix3f(value) return True except ValueError: print('isValidMFMatrix3f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix3f) and not isinstance(value, MFMatrix3f): ### # if _DEBUG: print('MFMatrix3f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFMatrix3f)=' + str(isinstance(value, MFMatrix3f)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFMatrix3f): ### value = value.value # dereference value from base type ### if re.fullmatch(MFMatrix3f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFMatrix3f): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFMatrix3f().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFMatrix3f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix3f().TUPLE_SIZE() =' + str(MFMatrix3f().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFMatrix3f(value): """ Utility function to assert type validity of a MFMatrix3f value, otherwise raise X3DTypeError with diagnostic message. """ try: MFMatrix3f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFMatrix3f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix3f) and not isinstance(value, MFMatrix3f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFMatrix3f') ### if isinstance(value, MFMatrix3f): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFMatrix3f)) and not isinstance(value, list): ### value = list(SFMatrix3f(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix3f') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFMatrix3f().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFMatrix3f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix3f().TUPLE_SIZE() =' + str(MFMatrix3f().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFMatrix3f)): # # print(flush=True) # raise X3DTypeError('MFMatrix3f element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFMatrix3f element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFMatrix3f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix3f') return True def isValidSFMatrix4d(value): """ Utility function to determine type validity of a SFMatrix4d value. """ if re.fullmatch(SFMatrix4d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFMatrix4d().REGEX_PYTHON(),' + str(value) + ')') return False try: SFMatrix4d(value) return True except ValueError: print('isValidSFMatrix4d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix4d) and not isinstance(value, MFMatrix4d): ### # if _DEBUG: print('SFMatrix4d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFMatrix4d)=' + str(isinstance(value, SFMatrix4d)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFMatrix4d): ### value = value.value # dereference value from base type ### if re.fullmatch(SFMatrix4d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFMatrix4d) and (len(value) == 1) and isValidMFMatrix4d(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix4d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 16: ### return False ### return True def assertValidSFMatrix4d(value): """ Utility function to assert type validity of a SFMatrix4d value, otherwise raise X3DTypeError with diagnostic message. """ try: SFMatrix4d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFMatrix4d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix4d) and not isinstance(value, MFMatrix4d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFMatrix4d') ### if isinstance(value, SFMatrix4d): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFMatrix4d) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFMatrix4d encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFMatrix4d') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix4d') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix4d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFMatrix4d list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 16: ### # print(flush=True) ### raise X3DTypeError('SFMatrix4d ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 16') ### if not isValidSFMatrix4d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix4d') return True def isValidMFMatrix4d(value): """ Utility function to determine type validity of a MFMatrix4d value. """ if re.fullmatch(MFMatrix4d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFMatrix4d().REGEX_PYTHON(),' + str(value) + ')') return False try: MFMatrix4d(value) return True except ValueError: print('isValidMFMatrix4d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix4d) and not isinstance(value, MFMatrix4d): ### # if _DEBUG: print('MFMatrix4d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFMatrix4d)=' + str(isinstance(value, MFMatrix4d)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFMatrix4d): ### value = value.value # dereference value from base type ### if re.fullmatch(MFMatrix4d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFMatrix4d): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFMatrix4d().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFMatrix4d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix4d().TUPLE_SIZE() =' + str(MFMatrix4d().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFMatrix4d(value): """ Utility function to assert type validity of a MFMatrix4d value, otherwise raise X3DTypeError with diagnostic message. """ try: MFMatrix4d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFMatrix4d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix4d) and not isinstance(value, MFMatrix4d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFMatrix4d') ### if isinstance(value, MFMatrix4d): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFMatrix4d)) and not isinstance(value, list): ### value = list(SFMatrix4d(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix4d') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFMatrix4d().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFMatrix4d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix4d().TUPLE_SIZE() =' + str(MFMatrix4d().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFMatrix4d)): # # print(flush=True) # raise X3DTypeError('MFMatrix4d element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFMatrix4d element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFMatrix4d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix4d') return True def isValidSFMatrix4f(value): """ Utility function to determine type validity of a SFMatrix4f value. """ if re.fullmatch(SFMatrix4f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFMatrix4f().REGEX_PYTHON(),' + str(value) + ')') return False try: SFMatrix4f(value) return True except ValueError: print('isValidSFMatrix4f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix4f) and not isinstance(value, MFMatrix4f): ### # if _DEBUG: print('SFMatrix4f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFMatrix4f)=' + str(isinstance(value, SFMatrix4f)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFMatrix4f): ### value = value.value # dereference value from base type ### if re.fullmatch(SFMatrix4f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFMatrix4f) and (len(value) == 1) and isValidMFMatrix4f(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix4f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 16: ### return False ### return True def assertValidSFMatrix4f(value): """ Utility function to assert type validity of a SFMatrix4f value, otherwise raise X3DTypeError with diagnostic message. """ try: SFMatrix4f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFMatrix4f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix4f) and not isinstance(value, MFMatrix4f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFMatrix4f') ### if isinstance(value, SFMatrix4f): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFMatrix4f) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFMatrix4f encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFMatrix4f') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix4f') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix4f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFMatrix4f list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 16: ### # print(flush=True) ### raise X3DTypeError('SFMatrix4f ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 16') ### if not isValidSFMatrix4f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFMatrix4f') return True def isValidMFMatrix4f(value): """ Utility function to determine type validity of a MFMatrix4f value. """ if re.fullmatch(MFMatrix4f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFMatrix4f().REGEX_PYTHON(),' + str(value) + ')') return False try: MFMatrix4f(value) return True except ValueError: print('isValidMFMatrix4f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFMatrix4f) and not isinstance(value, MFMatrix4f): ### # if _DEBUG: print('MFMatrix4f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFMatrix4f)=' + str(isinstance(value, MFMatrix4f)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFMatrix4f): ### value = value.value # dereference value from base type ### if re.fullmatch(MFMatrix4f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFMatrix4f): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFMatrix4f().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFMatrix4f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix4f().TUPLE_SIZE() =' + str(MFMatrix4f().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFMatrix4f(value): """ Utility function to assert type validity of a MFMatrix4f value, otherwise raise X3DTypeError with diagnostic message. """ try: MFMatrix4f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFMatrix4f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFMatrix4f) and not isinstance(value, MFMatrix4f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFMatrix4f') ### if isinstance(value, MFMatrix4f): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFMatrix4f)) and not isinstance(value, list): ### value = list(SFMatrix4f(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix4f') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFMatrix4f().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFMatrix4f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFMatrix4f().TUPLE_SIZE() =' + str(MFMatrix4f().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFMatrix4f)): # # print(flush=True) # raise X3DTypeError('MFMatrix4f element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFMatrix4f element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFMatrix4f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFMatrix4f') return True def isValidSFNode(value): """ Utility function to determine type validity of a SFNode value. """ try: SFNode(value) return True except ValueError: print('isValidSFNode failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFNode) and not isinstance(value, MFNode): ### # if _DEBUG: print('SFNode type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFNode)=' + str(isinstance(value, SFNode)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFNode): ### value = value.value # dereference value from base type ### return True ### if isinstance(value, MFNode) and (len(value) == 1) and isValidMFNode(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, object): ### return False ### return True def assertValidSFNode(value): """ Utility function to assert type validity of a SFNode value, otherwise raise X3DTypeError with diagnostic message. """ try: SFNode(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFNode') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFNode) and not isinstance(value, MFNode): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFNode') ### if isinstance(value, SFNode): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFNode) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b ### if not isinstance(value, object): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid object value for SFNode') ### if not isValidSFNode(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python object value for SFNode') return True def isValidMFNode(value): """ Utility function to determine type validity of a MFNode value. """ try: MFNode(value) return True except ValueError: print('isValidMFNode failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFNode) and not isinstance(value, MFNode): ### # if _DEBUG: print('MFNode type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFNode)=' + str(isinstance(value, MFNode)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFNode): ### value = value.value # dereference value from base type ### return True ### if isinstance(value, SFNode): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if value and isinstance(value,list): ### for each in value: ### if not isinstance(each, (_X3DNode, _X3DStatement)): ### return False ### return True def assertValidMFNode(value): """ Utility function to assert type validity of a MFNode value, otherwise raise X3DTypeError with diagnostic message. """ try: MFNode(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFNode') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFNode) and not isinstance(value, MFNode): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFNode') ### if isinstance(value, MFNode): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFNode)) and not isinstance(value, list): ### value = list(SFNode(value).value) # dereference value from this SF type, convert to list #2c ### if value and isinstance(value,list): ### for each in value: ### if not isinstance(each, _X3DNode) and not isinstance(each, _X3DStatement): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' element ' + str(each) + ', type=' + str(type(each)) + ' is not a valid _X3DNode or _X3DStatement for MFNode') ### if not isValidMFNode(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid _X3DNode or _X3DStatement for MFNode') return True def isValidSFRotation(value): """ Utility function to determine type validity of a SFRotation value. """ if re.fullmatch(SFRotation().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFRotation().REGEX_PYTHON(),' + str(value) + ')') return False try: SFRotation(value) return True except ValueError: print('isValidSFRotation failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFRotation) and not isinstance(value, MFRotation): ### # if _DEBUG: print('SFRotation type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFRotation)=' + str(isinstance(value, SFRotation)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFRotation): ### value = value.value # dereference value from base type ### if re.fullmatch(SFRotation().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFRotation) and (len(value) == 1) and isValidMFRotation(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFRotation): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 4: ### return False ### return True def assertValidSFRotation(value): """ Utility function to assert type validity of a SFRotation value, otherwise raise X3DTypeError with diagnostic message. """ try: SFRotation(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFRotation') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFRotation) and not isinstance(value, MFRotation): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFRotation') ### if isinstance(value, SFRotation): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFRotation(value) ### print('found string for SFRotation, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFRotation) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFRotation encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFRotation') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFRotation') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFRotation): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFRotation list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 4: ### # print(flush=True) ### raise X3DTypeError('SFRotation ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 4') ### if not isValidSFRotation(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFRotation') return True def isValidMFRotation(value): """ Utility function to determine type validity of a MFRotation value. """ if re.fullmatch(MFRotation().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFRotation().REGEX_PYTHON(),' + str(value) + ')') return False try: MFRotation(value) return True except ValueError: print('isValidMFRotation failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFRotation) and not isinstance(value, MFRotation): ### # if _DEBUG: print('MFRotation type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFRotation)=' + str(isinstance(value, MFRotation)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFRotation): ### value = value.value # dereference value from base type ### if re.fullmatch(MFRotation().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFRotation): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFRotation().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFRotation tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFRotation().TUPLE_SIZE() =' + str(MFRotation().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFRotation(value): """ Utility function to assert type validity of a MFRotation value, otherwise raise X3DTypeError with diagnostic message. """ try: MFRotation(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFRotation') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFRotation) and not isinstance(value, MFRotation): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFRotation') ### if isinstance(value, MFRotation): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFRotation(value) ### print('found string for MFRotation, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFRotation)) and not isinstance(value, list): ### value = list(SFRotation(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFRotation') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFRotation().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFRotation tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFRotation().TUPLE_SIZE() =' + str(MFRotation().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFRotation)): # # print(flush=True) # raise X3DTypeError('MFRotation element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFRotation element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFRotation(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFRotation') return True def isValidSFString(value): """ Utility function to determine type validity of a SFString value. """ if re.fullmatch(SFString().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFString().REGEX_PYTHON(),' + str(value) + ')') return False try: SFString(value) return True except ValueError: print('isValidSFString failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFString) and not isinstance(value, MFString): ### # if _DEBUG: print('SFString type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFString)=' + str(isinstance(value, SFString)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFString): ### value = value.value # dereference value from base type ### if re.fullmatch(SFString().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFString) and (len(value) == 1) and isValidMFString(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, str): ### return False ### return True def assertValidSFString(value): """ Utility function to assert type validity of a SFString value, otherwise raise X3DTypeError with diagnostic message. """ try: SFString(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFString') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFString) and not isinstance(value, MFString): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFString') ### if isinstance(value, SFString): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFString) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b ### if not isinstance(value, str): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid str value for SFString') ### if not isValidSFString(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python str value for SFString') return True def isValidMFString(value): """ Utility function to determine type validity of a MFString value. """ if re.fullmatch(MFString().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFString().REGEX_PYTHON(),' + str(value) + ')') return False try: MFString(value) return True except ValueError: print('isValidMFString failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFString) and not isinstance(value, MFString): ### # if _DEBUG: print('MFString type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFString)=' + str(isinstance(value, MFString)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFString): ### value = value.value # dereference value from base type ### if re.fullmatch(MFString().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFString): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFString): ### each = each.value # dereference ### if not isinstance(each, str): ### return False ### return True def assertValidMFString(value): """ Utility function to assert type validity of a MFString value, otherwise raise X3DTypeError with diagnostic message. """ try: MFString(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFString') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFString) and not isinstance(value, MFString): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFString') ### if isinstance(value, MFString): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFString) or isinstance(value, str)) and not isinstance(value, list): ### value = list(SFString(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFString') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFString): ### each = each.value # dereference ### if not isinstance(each, str): ### # print(flush=True) ### raise X3DTypeError('MFString list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid str') ### if not isValidMFString(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFString') return True def isValidSFTime(value): """ Utility function to determine type validity of a SFTime value. """ if re.fullmatch(SFTime().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFTime().REGEX_PYTHON(),' + str(value) + ')') return False try: SFTime(value) return True except ValueError: print('isValidSFTime failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFTime) and not isinstance(value, MFTime): ### # if _DEBUG: print('SFTime type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFTime)=' + str(isinstance(value, SFTime)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFTime): ### value = value.value # dereference value from base type ### if re.fullmatch(SFTime().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFTime) and (len(value) == 1) and isValidMFTime(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, float) and not isinstance(value, int): ### return False ### return True def assertValidSFTime(value): """ Utility function to assert type validity of a SFTime value, otherwise raise X3DTypeError with diagnostic message. """ try: SFTime(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFTime') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFTime) and not isinstance(value, MFTime): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFTime') ### if isinstance(value, SFTime): ### value = value.value # dereference value from this base type #2a ### elif isinstance(value, MFTime) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFTime encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFTime') ### if not isinstance(value, float) and not isinstance(value, int): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFTime') ### if not isValidSFTime(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python float value for SFTime') return True def isValidMFTime(value): """ Utility function to determine type validity of a MFTime value. """ if re.fullmatch(MFTime().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFTime().REGEX_PYTHON(),' + str(value) + ')') return False try: MFTime(value) return True except ValueError: print('isValidMFTime failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFTime) and not isinstance(value, MFTime): ### # if _DEBUG: print('MFTime type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFTime)=' + str(isinstance(value, MFTime)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFTime): ### value = value.value # dereference value from base type ### if re.fullmatch(MFTime().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFTime): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFTime): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### return True def assertValidMFTime(value): """ Utility function to assert type validity of a MFTime value, otherwise raise X3DTypeError with diagnostic message. """ try: MFTime(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFTime') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFTime) and not isinstance(value, MFTime): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFTime') ### if isinstance(value, MFTime): ### value = value.value # dereference value from this base type #2a ### elif (isinstance(value, SFTime)) and not isinstance(value, list): ### value = list(SFTime(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFTime') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFTime): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('MFTime list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if not isValidMFTime(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFTime') return True def isValidSFVec2d(value): """ Utility function to determine type validity of a SFVec2d value. """ if re.fullmatch(SFVec2d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFVec2d().REGEX_PYTHON(),' + str(value) + ')') return False try: SFVec2d(value) return True except ValueError: print('isValidSFVec2d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec2d) and not isinstance(value, MFVec2d): ### # if _DEBUG: print('SFVec2d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFVec2d)=' + str(isinstance(value, SFVec2d)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFVec2d): ### value = value.value # dereference value from base type ### if re.fullmatch(SFVec2d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFVec2d) and (len(value) == 1) and isValidMFVec2d(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec2d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 2: ### return False ### return True def assertValidSFVec2d(value): """ Utility function to assert type validity of a SFVec2d value, otherwise raise X3DTypeError with diagnostic message. """ try: SFVec2d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFVec2d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec2d) and not isinstance(value, MFVec2d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFVec2d') ### if isinstance(value, SFVec2d): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFVec2d(value) ### print('found string for SFVec2d, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFVec2d) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFVec2d encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFVec2d') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec2d') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec2d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFVec2d list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 2: ### # print(flush=True) ### raise X3DTypeError('SFVec2d ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 2') ### if not isValidSFVec2d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec2d') return True def isValidMFVec2d(value): """ Utility function to determine type validity of a MFVec2d value. """ if re.fullmatch(MFVec2d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFVec2d().REGEX_PYTHON(),' + str(value) + ')') return False try: MFVec2d(value) return True except ValueError: print('isValidMFVec2d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec2d) and not isinstance(value, MFVec2d): ### # if _DEBUG: print('MFVec2d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFVec2d)=' + str(isinstance(value, MFVec2d)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFVec2d): ### value = value.value # dereference value from base type ### if re.fullmatch(MFVec2d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFVec2d): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFVec2d().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFVec2d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec2d().TUPLE_SIZE() =' + str(MFVec2d().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFVec2d(value): """ Utility function to assert type validity of a MFVec2d value, otherwise raise X3DTypeError with diagnostic message. """ try: MFVec2d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFVec2d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec2d) and not isinstance(value, MFVec2d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFVec2d') ### if isinstance(value, MFVec2d): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFVec2d(value) ### print('found string for MFVec2d, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFVec2d)) and not isinstance(value, list): ### value = list(SFVec2d(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec2d') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFVec2d().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFVec2d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec2d().TUPLE_SIZE() =' + str(MFVec2d().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFVec2d)): # # print(flush=True) # raise X3DTypeError('MFVec2d element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFVec2d element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFVec2d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec2d') return True def isValidSFVec2f(value): """ Utility function to determine type validity of a SFVec2f value. """ if re.fullmatch(SFVec2f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFVec2f().REGEX_PYTHON(),' + str(value) + ')') return False try: SFVec2f(value) return True except ValueError: print('isValidSFVec2f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec2f) and not isinstance(value, MFVec2f): ### # if _DEBUG: print('SFVec2f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFVec2f)=' + str(isinstance(value, SFVec2f)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFVec2f): ### value = value.value # dereference value from base type ### if re.fullmatch(SFVec2f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFVec2f) and (len(value) == 1) and isValidMFVec2f(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec2f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 2: ### return False ### return True def assertValidSFVec2f(value): """ Utility function to assert type validity of a SFVec2f value, otherwise raise X3DTypeError with diagnostic message. """ try: SFVec2f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFVec2f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec2f) and not isinstance(value, MFVec2f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFVec2f') ### if isinstance(value, SFVec2f): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFVec2f(value) ### print('found string for SFVec2f, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFVec2f) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFVec2f encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFVec2f') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec2f') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec2f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFVec2f list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 2: ### # print(flush=True) ### raise X3DTypeError('SFVec2f ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 2') ### if not isValidSFVec2f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec2f') return True def isValidMFVec2f(value): """ Utility function to determine type validity of a MFVec2f value. """ if re.fullmatch(MFVec2f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFVec2f().REGEX_PYTHON(),' + str(value) + ')') return False try: MFVec2f(value) return True except ValueError: print('isValidMFVec2f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec2f) and not isinstance(value, MFVec2f): ### # if _DEBUG: print('MFVec2f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFVec2f)=' + str(isinstance(value, MFVec2f)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFVec2f): ### value = value.value # dereference value from base type ### if re.fullmatch(MFVec2f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFVec2f): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFVec2f().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFVec2f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec2f().TUPLE_SIZE() =' + str(MFVec2f().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFVec2f(value): """ Utility function to assert type validity of a MFVec2f value, otherwise raise X3DTypeError with diagnostic message. """ try: MFVec2f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFVec2f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec2f) and not isinstance(value, MFVec2f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFVec2f') ### if isinstance(value, MFVec2f): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFVec2f(value) ### print('found string for MFVec2f, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFVec2f)) and not isinstance(value, list): ### value = list(SFVec2f(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec2f') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFVec2f().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFVec2f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec2f().TUPLE_SIZE() =' + str(MFVec2f().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFVec2f)): # # print(flush=True) # raise X3DTypeError('MFVec2f element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFVec2f element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFVec2f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec2f') return True def isValidSFVec3d(value): """ Utility function to determine type validity of a SFVec3d value. """ if re.fullmatch(SFVec3d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFVec3d().REGEX_PYTHON(),' + str(value) + ')') return False try: SFVec3d(value) return True except ValueError: print('isValidSFVec3d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec3d) and not isinstance(value, MFVec3d): ### # if _DEBUG: print('SFVec3d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFVec3d)=' + str(isinstance(value, SFVec3d)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFVec3d): ### value = value.value # dereference value from base type ### if re.fullmatch(SFVec3d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFVec3d) and (len(value) == 1) and isValidMFVec3d(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec3d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 3: ### return False ### return True def assertValidSFVec3d(value): """ Utility function to assert type validity of a SFVec3d value, otherwise raise X3DTypeError with diagnostic message. """ try: SFVec3d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFVec3d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec3d) and not isinstance(value, MFVec3d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFVec3d') ### if isinstance(value, SFVec3d): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFVec3d(value) ### print('found string for SFVec3d, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFVec3d) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFVec3d encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFVec3d') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec3d') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec3d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFVec3d list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 3: ### # print(flush=True) ### raise X3DTypeError('SFVec3d ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 3') ### if not isValidSFVec3d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec3d') return True def isValidMFVec3d(value): """ Utility function to determine type validity of a MFVec3d value. """ if re.fullmatch(MFVec3d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFVec3d().REGEX_PYTHON(),' + str(value) + ')') return False try: MFVec3d(value) return True except ValueError: print('isValidMFVec3d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec3d) and not isinstance(value, MFVec3d): ### # if _DEBUG: print('MFVec3d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFVec3d)=' + str(isinstance(value, MFVec3d)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFVec3d): ### value = value.value # dereference value from base type ### if re.fullmatch(MFVec3d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFVec3d): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFVec3d().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFVec3d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec3d().TUPLE_SIZE() =' + str(MFVec3d().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFVec3d(value): """ Utility function to assert type validity of a MFVec3d value, otherwise raise X3DTypeError with diagnostic message. """ try: MFVec3d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFVec3d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec3d) and not isinstance(value, MFVec3d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFVec3d') ### if isinstance(value, MFVec3d): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFVec3d(value) ### print('found string for MFVec3d, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFVec3d)) and not isinstance(value, list): ### value = list(SFVec3d(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec3d') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFVec3d().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFVec3d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec3d().TUPLE_SIZE() =' + str(MFVec3d().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFVec3d)): # # print(flush=True) # raise X3DTypeError('MFVec3d element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFVec3d element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFVec3d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec3d') return True def isValidSFVec3f(value): """ Utility function to determine type validity of a SFVec3f value. """ if re.fullmatch(SFVec3f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFVec3f().REGEX_PYTHON(),' + str(value) + ')') return False try: SFVec3f(value) return True except ValueError: print('isValidSFVec3f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec3f) and not isinstance(value, MFVec3f): ### # if _DEBUG: print('SFVec3f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFVec3f)=' + str(isinstance(value, SFVec3f)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFVec3f): ### value = value.value # dereference value from base type ### if re.fullmatch(SFVec3f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFVec3f) and (len(value) == 1) and isValidMFVec3f(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec3f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 3: ### return False ### return True def assertValidSFVec3f(value): """ Utility function to assert type validity of a SFVec3f value, otherwise raise X3DTypeError with diagnostic message. """ try: SFVec3f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFVec3f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec3f) and not isinstance(value, MFVec3f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFVec3f') ### if isinstance(value, SFVec3f): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFVec3f(value) ### print('found string for SFVec3f, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFVec3f) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFVec3f encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFVec3f') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec3f') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec3f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFVec3f list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 3: ### # print(flush=True) ### raise X3DTypeError('SFVec3f ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 3') ### if not isValidSFVec3f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec3f') return True def isValidMFVec3f(value): """ Utility function to determine type validity of a MFVec3f value. """ if re.fullmatch(MFVec3f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFVec3f().REGEX_PYTHON(),' + str(value) + ')') return False try: MFVec3f(value) return True except ValueError: print('isValidMFVec3f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec3f) and not isinstance(value, MFVec3f): ### # if _DEBUG: print('MFVec3f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFVec3f)=' + str(isinstance(value, MFVec3f)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFVec3f): ### value = value.value # dereference value from base type ### if re.fullmatch(MFVec3f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFVec3f): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFVec3f().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFVec3f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec3f().TUPLE_SIZE() =' + str(MFVec3f().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFVec3f(value): """ Utility function to assert type validity of a MFVec3f value, otherwise raise X3DTypeError with diagnostic message. """ try: MFVec3f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFVec3f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec3f) and not isinstance(value, MFVec3f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFVec3f') ### if isinstance(value, MFVec3f): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFVec3f(value) ### print('found string for MFVec3f, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFVec3f)) and not isinstance(value, list): ### value = list(SFVec3f(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec3f') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFVec3f().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFVec3f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec3f().TUPLE_SIZE() =' + str(MFVec3f().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFVec3f)): # # print(flush=True) # raise X3DTypeError('MFVec3f element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFVec3f element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFVec3f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec3f') return True def isValidSFVec4d(value): """ Utility function to determine type validity of a SFVec4d value. """ if re.fullmatch(SFVec4d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFVec4d().REGEX_PYTHON(),' + str(value) + ')') return False try: SFVec4d(value) return True except ValueError: print('isValidSFVec4d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec4d) and not isinstance(value, MFVec4d): ### # if _DEBUG: print('SFVec4d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFVec4d)=' + str(isinstance(value, SFVec4d)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFVec4d): ### value = value.value # dereference value from base type ### if re.fullmatch(SFVec4d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFVec4d) and (len(value) == 1) and isValidMFVec4d(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec4d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 4: ### return False ### return True def assertValidSFVec4d(value): """ Utility function to assert type validity of a SFVec4d value, otherwise raise X3DTypeError with diagnostic message. """ try: SFVec4d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFVec4d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec4d) and not isinstance(value, MFVec4d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFVec4d') ### if isinstance(value, SFVec4d): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFVec4d(value) ### print('found string for SFVec4d, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFVec4d) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFVec4d encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFVec4d') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec4d') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec4d): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFVec4d list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 4: ### # print(flush=True) ### raise X3DTypeError('SFVec4d ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 4') ### if not isValidSFVec4d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec4d') return True def isValidMFVec4d(value): """ Utility function to determine type validity of a MFVec4d value. """ if re.fullmatch(MFVec4d().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFVec4d().REGEX_PYTHON(),' + str(value) + ')') return False try: MFVec4d(value) return True except ValueError: print('isValidMFVec4d failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec4d) and not isinstance(value, MFVec4d): ### # if _DEBUG: print('MFVec4d type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFVec4d)=' + str(isinstance(value, MFVec4d)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFVec4d): ### value = value.value # dereference value from base type ### if re.fullmatch(MFVec4d().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFVec4d): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFVec4d().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFVec4d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec4d().TUPLE_SIZE() =' + str(MFVec4d().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFVec4d(value): """ Utility function to assert type validity of a MFVec4d value, otherwise raise X3DTypeError with diagnostic message. """ try: MFVec4d(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFVec4d') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec4d) and not isinstance(value, MFVec4d): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFVec4d') ### if isinstance(value, MFVec4d): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFVec4d(value) ### print('found string for MFVec4d, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFVec4d)) and not isinstance(value, list): ### value = list(SFVec4d(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec4d') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFVec4d().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFVec4d tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec4d().TUPLE_SIZE() =' + str(MFVec4d().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFVec4d)): # # print(flush=True) # raise X3DTypeError('MFVec4d element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFVec4d element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFVec4d(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec4d') return True def isValidSFVec4f(value): """ Utility function to determine type validity of a SFVec4f value. """ if re.fullmatch(SFVec4f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch SFVec4f().REGEX_PYTHON(),' + str(value) + ')') return False try: SFVec4f(value) return True except ValueError: print('isValidSFVec4f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec4f) and not isinstance(value, MFVec4f): ### # if _DEBUG: print('SFVec4f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, SFVec4f)=' + str(isinstance(value, SFVec4f)), flush=True) ### return False # type mismatch! ### if isinstance(value, SFVec4f): ### value = value.value # dereference value from base type ### if re.fullmatch(SFVec4f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, MFVec4f) and (len(value) == 1) and isValidMFVec4f(value): ### value = value.value[0] # dereference value from this MF type ### return True ### if not isinstance(value, tuple): ### return False ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec4f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### return False ### if tupleCount != 4: ### return False ### return True def assertValidSFVec4f(value): """ Utility function to assert type validity of a SFVec4f value, otherwise raise X3DTypeError with diagnostic message. """ try: SFVec4f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid SFVec4f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec4f) and not isinstance(value, MFVec4f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a SFVec4f') ### if isinstance(value, SFVec4f): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = SFVec4f(value) ### print('found string for SFVec4f, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif isinstance(value, MFVec4f) and len(value) == 1: ### value = value.value[0] # dereference value from this MF type #2b # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float ### elif isinstance(value, str): ### try: ### float(value) # checks but does not set value, may throw exception ### except ValueError: ### print('SFVec4f encountered string with illegal value=' + str(value)) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid float value for SFVec4f') ### if not isinstance(value, tuple): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec4f') ### # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #1 ### tupleCount = 0 ### for each in value: ### tupleCount += 1 ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec4f): ### each = each.value # dereference ### if not isinstance(each, float) and not isinstance(each, int): ### # print(flush=True) ### raise X3DTypeError('SFVec4f list has contained value=' + str(each) + ' with type=' + str(type(each)) + ' which is not a valid float') ### if tupleCount != 4: ### # print(flush=True) ### raise X3DTypeError('SFVec4f ' + str(value)[:100] + ', type=' + str(type(value)) + ' has ' + str(tupleCount) + ' elements instead of 4') ### if not isValidSFVec4f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python tuple for SFVec4f') return True def isValidMFVec4f(value): """ Utility function to determine type validity of a MFVec4f value. """ if re.fullmatch(MFVec4f().REGEX_PYTHON(),str(value)) is None: print('* regex mismatch MFVec4f().REGEX_PYTHON(),' + str(value) + ')') return False try: MFVec4f(value) return True except ValueError: print('isValidMFVec4f failed with illegal value=' + str(value)) return False ### if isinstance(value, _X3DField): ### if not isinstance(value, SFVec4f) and not isinstance(value, MFVec4f): ### # if _DEBUG: print('MFVec4f type mismatch diagnostic: value=' + str(value)[:100] + ' has type=' + str(type(value)) + ', isinstance(value, MFVec4f)=' + str(isinstance(value, MFVec4f)), flush=True) ### return False # type mismatch! ### if isinstance(value, MFVec4f): ### value = value.value # dereference value from base type ### if re.fullmatch(MFVec4f().REGEX_PYTHON(),str(value)) is None: ### return False ### return True ### if isinstance(value, SFVec4f): ### value = list(value.value) # dereference value from this SF type, convert to list #1 ### return True ### if not isinstance(value, list): ### return False ### index = 0 ### for each in value: ### index += 1 ### if len(each) % MFVec4f().TUPLE_SIZE() != 0: ### # if _DEBUG: ### print('* isValidMFVec4f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec4f().TUPLE_SIZE() =' + str(MFVec4f().TUPLE_SIZE() ) + ' for value=' + str(value), flush=True) ### return False ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### return False ### return True def assertValidMFVec4f(value): """ Utility function to assert type validity of a MFVec4f value, otherwise raise X3DTypeError with diagnostic message. """ try: MFVec4f(value) except Exception as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion print(flush=True) raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' but is not a valid MFVec4f') from error # if _DEBUG: print('...DEBUG... debug value.__class__=' + str(value.__class__) + ', issubclass(value.__class__, _X3DField)=' + str(issubclass(value.__class__, _X3DField)) + ', super(value.__class__)=' + str(super(value.__class__)), flush=True) # if _DEBUG: print('value=', value, 'str(value)=', str(value)) ### if isinstance(value, _X3DField) and not isinstance(value, SFVec4f) and not isinstance(value, MFVec4f): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ' has type ' + str(type(value)) + ' and is not a MFVec4f') ### if isinstance(value, MFVec4f): ### value = value.value # dereference value from this base type #2a ### if isinstance(value,str): ### value = MFVec4f(value) ### print('found string for MFVec4f, isinstance(value,list)=' + str(isinstance(value,list)),flush=True) ### elif (isinstance(value, SFVec4f)) and not isinstance(value, list): ### value = list(SFVec4f(value).value) # dereference value from this SF type, convert to list #2c ### if not isinstance(value, list): ### print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec4f') # perform duplicative tests prior to isValid call in order to provide better assertion diagnostics #2 ### if isinstance(value, list): ### index = 0 ### for each in value: ### if len(each) % MFVec4f().TUPLE_SIZE() != 0: # print(flush=True) ### raise X3DValueError('MFVec4f tuple ' + str(each) + ' has length ' + str(len(each)) + ' which is not a multiple of MFVec4f().TUPLE_SIZE() =' + str(MFVec4f().TUPLE_SIZE() ) + ' for value=' + str(value)[:100]) # if not isinstance(each, (tuple, SFVec4f)): # # print(flush=True) # raise X3DTypeError('MFVec4f element #' + str(index) + ' with value ' + str(each) + ', type=' + str(type(each)) + ' is not a valid tuple') ### index += 1 ### if isinstance(each, tuple): ### for element in each: ### if not isinstance(element, float) and not isinstance(element, int): ### # print(flush=True) ### raise X3DTypeError('MFVec4f element #' + str(index) + ' tuple ' + str(each) + ' has value=' + str(element) + ', type=' + str(type(element)) + ' that is not a valid float') ### if not isValidMFVec4f(value): ### # print(flush=True) ### raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value)) + ' is not a valid Python list for MFVec4f') return True def assertValidFieldInitializationValue(name, fieldType, value, parent=''): """ Utility function to assert fieldType validity of a field initialization value, otherwise raise X3DTypeError with diagnostic message. """ # if _DEBUG: print('...DEBUG... assertValidFieldInitializationValue name=' + str(name) + ', fieldType=' + str(fieldType) + ', value=' + str(value)[:100] + ', parent=' + parent, flush=True) # note that ExternProtoDeclare field definitions do not have any value if name is None: print('* assertValidFieldInitializationValue improper invocation: name=' + str(name) + ', fieldType=' + str(fieldType) + ', value=' + str(value)[:100] + ', parent=' + parent + ', ignored', flush=True) return None # ignore if value is None or (not(fieldType == bool) and not value): return None # ignore if fieldType == 'SFString': assertValidSFString(value) elif fieldType == 'MFString': assertValidMFString(value) elif (fieldType == 'SFBool') or (fieldType == bool) or isinstance(value, bool): assertValidSFBool(value) elif fieldType == 'MFBool': assertValidMFBool(value) elif (fieldType == 'SFInt32') or (fieldType == int) or isinstance(value, int): assertValidSFInt32(value) elif fieldType == 'MFInt32': assertValidMFInt32(value) elif (fieldType == 'SFFloat') or (fieldType == float) or isinstance(value, float): assertValidSFFloat(value) elif fieldType == 'MFFloat': assertValidMFFloat(value) elif fieldType == 'SFDouble': assertValidSFDouble(value) elif fieldType == 'MFDouble': assertValidMFDouble(value) elif fieldType == 'SFTime': assertValidSFTime(value) elif fieldType == 'MFTime': assertValidMFTime(value) elif fieldType == 'SFColor': assertValidSFColor(value) elif fieldType == 'MFColorRGBA': assertValidMFColorRGBA(value) elif fieldType == 'SFRotation': assertValidSFRotation(value) elif fieldType == 'MFRotation': assertValidMFRotation(value) elif fieldType == 'SFImage': assertValidSFImage(value) elif fieldType == 'MFImage': assertValidMFImage(value) elif fieldType == 'SFNode': assertValidSFNode(value) elif fieldType == 'MFNode': assertValidMFNode(value) elif fieldType == 'SFVec2f': assertValidSFVec2f(value) elif fieldType == 'MFVec2f': assertValidMFVec2f(value) elif fieldType == 'SFVec3f': assertValidSFVec3f(value) elif fieldType == 'MFVec3f': assertValidMFVec3f(value) elif fieldType == 'SFVec4f': assertValidSFVec4f(value) elif fieldType == 'MFVec4f': assertValidMFVec4f(value) elif fieldType == 'SFVec2d': assertValidSFVec2d(value) elif fieldType == 'MFVec2d': assertValidMFVec2d(value) elif fieldType == 'SFVec3d': assertValidSFVec3d(value) elif fieldType == 'MFVec3d': assertValidMFVec3d(value) elif fieldType == 'SFVec4d': assertValidSFVec4d(value) elif fieldType == 'MFVec4d': assertValidMFVec4d(value) elif fieldType == 'SFMatrix3d': assertValidSFMatrix3f(value) elif fieldType == 'MFMatrix3f': assertValidMFMatrix3f(value) elif fieldType == 'SFMatrix4f': assertValidSFMatrix4f(value) elif fieldType == 'MFMatrix4f': assertValidMFMatrix4f(value) elif fieldType == 'SFMatrix3d': assertValidSFMatrix3d(value) elif fieldType == 'MFMatrix3d': assertValidMFMatrix3d(value) elif fieldType == 'SFMatrix4d': assertValidSFMatrix4d(value) elif fieldType == 'MFMatrix4d': assertValidMFMatrix4d(value) elif (fieldType == str) or isinstance(value, str): assertValidSFString(value) elif str(parent) == 'fieldValue': return True # TODO check further if possible elif (fieldType == list) or isinstance(value, list): try: if isinstance(value[0], tuple): print('*** assertValidFieldInitializationValue TODO validate list fieldType: name=' + str(name) + ', passed fieldType=' + str(fieldType) + ', fieldType(value)=' + str(fieldType(value)) + ', value=' + str(value)[:100] + ', parent=' + parent, flush=True) return True # TODO check further initialListItemType = fieldType(value[0]) # https://stackoverflow.com/questions/522563/accessing-the-index-in-for-loops/28072982#28072982 # https://stackoverflow.com/questions/1952464/in-python-how-do-i-determine-if-an-object-is-iterable for index, each in enumerate(value): assertValidFieldInitializationValue(name + '[' + str(index) + ']', initialListItemType, value[index], parent) return True except TypeError: return False # TODO check further if possible elif (fieldType == tuple) or isinstance(value, tuple): print('*** assertValidFieldInitializationValue TODO validate tuple fieldType: name=' + str(name) + ', passed fieldType=' + str(fieldType) + ', fieldType(value)=' + str(fieldType(value)) + ', value=' + str(value)[:100] + ', parent=' + parent, flush=True) return True # TODO check further if possible # initialListItemType = fieldType(value[0]) # for index, each in enumerate(value): # assertValidFieldInitializationValue(name + '[' + str(index) + '], fieldType(value[index])', value[index], parent) else: print('*** assertValidFieldInitializationValue unknown fieldType: name=' + str(name) + ', passed fieldType=' + str(fieldType) + ', fieldType(value)=' + str(fieldType(value)) + ', value=' + str(value)[:100] + ', parent=' + parent, flush=True) return False # TODO check further if possible return True ############################################### class _X3DField: """ X3DField is the abstract field type from which all single values field types are derived. All fields directly derived from X3DField have names beginning with SF (single-valued field). SF fields may only contain a single value of the type indicated by the name of the field type. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return '_X3DField' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldTypes.html#X3DField' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#FieldTypesTable' @property # getter - - - - - - - - - - def value(self): """ Provide value of this field type. """ return self.__value def __repl__(self): # if _DEBUG: print('...DEBUG... type(self.value)=' + str(type(self.value)), flush=True) if isinstance(self.value, (SFString, str)): return "'" + self.value + "'" if isinstance(self.value, tuple) and 'SF' in str(type(self)): # avoid X3DTypeError if value is not iterable result = '(' if self.value: # walk each child in list, if any (avoid empty list recursion) for each in self.value: result += str(each) + ', ' # if _DEBUG: print('...DEBUG... _X3DField debug: str(each)=' + str(each), flush=True) return result.rstrip(', ') + ')' if isinstance(self.value, list) and 'MF' in str(type(self)): # avoid X3DTypeError if value is not iterable # isinstance(self.value, MFNode): not working, what got passed in was not an MFNode object apparently result = '[' if self.value: # walk each child in list, if any (avoid empty list recursion) for each in self.value: result += str(each) + ', ' # if _DEBUG: print('...DEBUG... _X3DField debug: str(each)=' + str(each), flush=True) return result.rstrip(', ') + ']' return str(self.value) def __str__(self): return self.__repl__() class _X3DArrayField(_X3DField): """ X3DArrayField is the abstract field type from which all field types that can contain multiple values are derived, implementing the X3DField interface. All fields derived from X3DArrayField have names beginning with MF (multiple-valued field). MF fields may zero or more values, each of which shall be of the type indicated by the corresponding SF field type. It is illegal for any MF field to mix values of different SF field types. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DArrayField' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldTypes.html#X3DArrayField' def isX3DField(value): """ Determine whether object is an instance of _X3DField. """ return isinstance(value, _X3DField) # Access Types class AccessType(_X3DField): """ accessType determines whether a field corresponds to event input, event output, or persistent state information. Events are strictly typed values with a corresponding timestamp. ROUTE connections must match accessType between source field and target field. """ @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/concepts.html#FieldSemantics' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#accessType' @staticmethod def initializeOnly(): """ initializeOnly: can be initialized, but cannot send or receive events. This is usually the case for fields that are considered too computationally expensive to change at run time. """ return 'initializeOnly' @staticmethod def inputOutput(): """ inputOutput: can be initialized, and can also send or receive events during run-time operations. """ return 'inputOutput' @staticmethod def inputOnly(): """ inputOnly: cannot be initialized or included in a scene file, but can receive input event values via a ROUTE during run-time operations. """ return 'inputOnly' @staticmethod def outputOnly(): """ outputOnly: cannot be initialized or included in a scene file, but can send output event values via a ROUTE during run-time operations. """ return 'outputOnly' # Field Types class FieldType(_X3DField): """ The X3D Architecture specification of field types classify the possible values for a field. Each field in each node (i.e. each XML attribute) has a strictly defined data type. Multiple data types are provided for boolean, integer, floating-point and string values. X3D is a strongly typed language, meaning that all data must strictly conform to these data types in order for a scene to be correct. """ @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#type' # string constants listing each allowed type @staticmethod def SFBool(): """ Type SFBool https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFBool """ return 'SFBool' @staticmethod def MFBool(): """ Type MFBool https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFBool """ return 'MFBool' @staticmethod def SFColor(): """ Type SFColor https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFColor """ return 'SFColor' @staticmethod def MFColor(): """ Type MFColor https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFColor """ return 'MFColor' @staticmethod def SFColorRGBA(): """ Type SFColorRGBA https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFColorRGBA """ return 'SFColorRGBA' @staticmethod def MFColorRGBA(): """ Type MFColorRGBA https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFColorRGBA """ return 'MFColorRGBA' @staticmethod def SFDouble(): """ Type SFDouble https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFDouble """ return 'SFDouble' @staticmethod def MFDouble(): """ Type MFDouble https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFDouble """ return 'MFDouble' @staticmethod def SFFloat(): """ Type SFFloat https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFFloat """ return 'SFFloat' @staticmethod def MFFloat(): """ Type MFFloat https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFFloat """ return 'MFFloat' @staticmethod def SFImage(): """ Type SFImage https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFImage """ return 'SFImage' @staticmethod def MFImage(): """ Type MFImage https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFImage """ return 'MFImage' @staticmethod def SFInt32(): """ Type SFInt32 https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFInt32 """ return 'SFInt32' @staticmethod def MFInt32(): """ Type MFInt32 https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFInt32 """ return 'MFInt32' @staticmethod def SFMatrix3d(): """ Type SFMatrix3d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix3d """ return 'SFMatrix3d' @staticmethod def MFMatrix3d(): """ Type MFMatrix3d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix3d """ return 'MFMatrix3d' @staticmethod def SFMatrix3f(): """ Type SFMatrix3f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix3f """ return 'SFMatrix3f' @staticmethod def MFMatrix3f(): """ Type MFMatrix3f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix3f """ return 'MFMatrix3f' @staticmethod def SFMatrix4d(): """ Type SFMatrix4d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix4d """ return 'SFMatrix4d' @staticmethod def MFMatrix4d(): """ Type MFMatrix4d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix4d """ return 'MFMatrix4d' @staticmethod def SFMatrix4f(): """ Type SFMatrix4f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix4f """ return 'SFMatrix4f' @staticmethod def MFMatrix4f(): """ Type MFMatrix4f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix4f """ return 'MFMatrix4f' @staticmethod def SFNode(): """ Type SFNode https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFNode """ return 'SFNode' @staticmethod def MFNode(): """ Type MFNode https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFNode """ return 'MFNode' @staticmethod def SFRotation(): """ Type SFRotation https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFRotation """ return 'SFRotation' @staticmethod def MFRotation(): """ Type MFRotation https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFRotation """ return 'MFRotation' @staticmethod def SFString(): """ Type SFString https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFString """ return 'SFString' @staticmethod def MFString(): """ Type MFString https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFString """ return 'MFString' @staticmethod def SFTime(): """ Type SFTime https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFTime """ return 'SFTime' @staticmethod def MFTime(): """ Type MFTime https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFTime """ return 'MFTime' @staticmethod def SFVec2d(): """ Type SFVec2d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec2d """ return 'SFVec2d' @staticmethod def MFVec2d(): """ Type MFVec2d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec2d """ return 'MFVec2d' @staticmethod def SFVec2f(): """ Type SFVec2f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec2f """ return 'SFVec2f' @staticmethod def MFVec2f(): """ Type MFVec2f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec2f """ return 'MFVec2f' @staticmethod def SFVec3d(): """ Type SFVec3d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec3d """ return 'SFVec3d' @staticmethod def MFVec3d(): """ Type MFVec3d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec3d """ return 'MFVec3d' @staticmethod def SFVec3f(): """ Type SFVec3f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec3f """ return 'SFVec3f' @staticmethod def MFVec3f(): """ Type MFVec3f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec3f """ return 'MFVec3f' @staticmethod def SFVec4d(): """ Type SFVec4d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec4d """ return 'SFVec4d' @staticmethod def MFVec4d(): """ Type MFVec4d https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec4d """ return 'MFVec4d' @staticmethod def SFVec4f(): """ Type SFVec4f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec4f """ return 'SFVec4f' @staticmethod def MFVec4f(): """ Type MFVec4f https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec4f """ return 'MFVec4f' class SFBool(_X3DField): """ Field type Python Boolean values are capitalized as True or False. SFBool is a logical type with possible values (true|false) to match the XML boolean type. Hint: XML boolean values are lower case (true|false) in order to maintain compatibility with HTML and other XML documents. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFBool' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFBoolAndMFBool' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFBool' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return False @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(true|false|True|False)\s*' # (less than fully strict Python: allows lower-case strings true, false) @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(true|false)\s*' # - - - - - - - - - - def __init__(self, value=False): # print('*** SFBool __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ value = fixBoolean(value, default=SFBool.DEFAULT_VALUE()) if isinstance(value,SFBool): value = value.value # dereference elif value is None: value = SFBool.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFBool.DEFAULT_VALUE()=' + str(SFBool.DEFAULT_VALUE())) elif isinstance(value, MFBool) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFBool self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower() def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).upper() def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower() class MFBool(_X3DArrayField): """ Field type Python Boolean values are capitalized as True or False. MFBool is an array of boolean values. Type MFBool was previously undefined in the VRML97 Specification, but nevertheless needed for event utilities and scripting. Example use: MFBool is useful for defining a series of behavior states using a BooleanSequencer prototype. Hint: XML boolean values are lower case (true|false) in order to maintain compatibility with HTML and other XML documents. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFBool' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFBoolAndMFBool' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFBool' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*((true|false|True|False)\s*,?\s*)*\]?\s*' # (less than fully strict Python: allows lower-case strings true, false) @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((true|false)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFBool __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ value = fixBoolean(value, default=MFBool.DEFAULT_VALUE()) if not isinstance(value,list): _newValue = [ value ] else: _newValue = [] for each in value: _newValue.append(SFBool(each).value) value = _newValue if isinstance(value,SFBool): value = value.value # dereference elif value is None: value = MFBool.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFBool.DEFAULT_VALUE()=' + str(MFBool.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFBool(value): ### print(' upcast to MF type', value) ### value = MFBool(SFBool(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFBool(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ bool(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFBool): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFBool): self.__value.append(SFBool(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFBool): for each in value: self.__value.append(SFBool(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFBool(value).value) # checks validity ### if not value is None: ### if isValidSFBool(value): ### if isinstance(value, SFBool): ### value = SFBool(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFBool(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFBool): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFBool(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFBool self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).upper().replace(',', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('[', '').replace(']', '') class SFColor(_X3DField): """ Field type SFColor specifies one RGB (red-green-blue) color triple, where each color value is an RGB triple of floating point numbers in range [0,1]. The default value of an uninitialized SFColor field is (0 0 0). Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFColor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFColorAndMFColor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFColor' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0, 0, 0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 3 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*\,?\s*){2}([+]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s+){2}([+]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None): # print('*** SFColor __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) if isinstance(value,SFColor): value = value.value # dereference elif value is None: value = SFColor.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFColor.DEFAULT_VALUE()=' + str(SFColor.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 3: value = (value[0],value[1],value[2]) else: # no tuples found, create 3-tuples value = [(x, y, z) for x, y, z in value] elif isinstance(value, MFColor) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFColor encountered string with illegal value=' + str(value)) from error assertZeroToOne(SFColor,value) self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFColor self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFColor(_X3DArrayField): """ Field type MFColor specifies zero or more SFColor RGB triples, where each color value is an RGB triple of floating point numbers in range [0,1]. The default value of an uninitialized MFColor field is the empty list. Individual SFColor array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFColor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFColorAndMFColor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFColor' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 3 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*\,?\s*){2}([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s+){2}([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFColor __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) if isinstance(value,SFColor): value = value.value # dereference elif value is None: value = MFColor.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFColor.DEFAULT_VALUE()=' + str(MFColor.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 3: value = (value[0],value[1],value[2]) else: # no tuples found, create 3-tuples value = [(x, y, z) for x, y, z in value] ### elif not isinstance(value, list) and isValidSFColor(value): ### print(' upcast to MF type', value) ### value = MFColor(SFColor(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFColor(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] assertZeroToOne(MFColor,value) self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFColor): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFColor): self.__value.append(SFColor(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFColor): for each in value: self.__value.append(SFColor(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFColor(value).value) # checks validity ### if not value is None: ### if isValidSFColor(value): ### if isinstance(value, SFColor): ### value = SFColor(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFColor(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFColor): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFColor(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFColor self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFColorRGBA(_X3DField): """ Field type SFColorRGBA specifies one RGBA (red-green-blue-alpha) color 4-tuple, where each color value is an RGBA 4-tuple of floating point numbers in range [0,1]. Alpha (opacity) values = (1 - transparency). The default value of an uninitialized SFColorRGBA field is (0 0 0 0). Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFColorRGBA' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFColorRGBAAndMFColorRGBA' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFColorRGBA' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0, 0, 0, 0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): # print('*** SFColorRGBA __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFColorRGBA): value = value.value # dereference elif value is None: value = SFColorRGBA.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFColorRGBA.DEFAULT_VALUE()=' + str(SFColorRGBA.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] elif isinstance(value, MFColorRGBA) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFColorRGBA encountered string with illegal value=' + str(value)) from error assertZeroToOne(SFColorRGBA,value) self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFColorRGBA self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFColorRGBA(_X3DArrayField): """ Field type MFColorRGBA specifies zero or more SFColorRGBA 4-tuples, where each color value is an RGBA 4-tuple of floating point numbers in range [0,1]. Alpha (opacity) values = (1 - transparency). The default value of an uninitialized MFColor field is the empty list. Individual SFColorRGBA array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFColorRGBA' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFColorRGBAAndMFColorRGBA' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFColorRGBA' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0(\.[0-9]*)?|\.[0-9]+)|1(\.0*)?)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFColorRGBA __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFColorRGBA): value = value.value # dereference elif value is None: value = MFColorRGBA.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFColorRGBA.DEFAULT_VALUE()=' + str(MFColorRGBA.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] ### elif not isinstance(value, list) and isValidSFColorRGBA(value): ### print(' upcast to MF type', value) ### value = MFColorRGBA(SFColorRGBA(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFColorRGBA(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] assertZeroToOne(MFColorRGBA,value) self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFColorRGBA): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFColorRGBA): self.__value.append(SFColorRGBA(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFColorRGBA): for each in value: self.__value.append(SFColorRGBA(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFColorRGBA(value).value) # checks validity ### if not value is None: ### if isValidSFColorRGBA(value): ### if isinstance(value, SFColorRGBA): ### value = SFColorRGBA(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFColorRGBA(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFColorRGBA): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFColorRGBA(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFColorRGBA self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFDouble(_X3DField): """ Field type SFDouble is a double-precision floating-point type. Array values are optionally separated by commas in XML syntax. See GeoVRML 1.0 Recommended Practice, Section 2.3, Limitations of Single Precision for rationale. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFDouble' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFDoubleAndMFDouble' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFDouble' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return 0.0 @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=0.0): # print('*** SFDouble __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFDouble): value = value.value # dereference elif value is None: value = SFDouble.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFDouble.DEFAULT_VALUE()=' + str(SFDouble.DEFAULT_VALUE())) elif isinstance(value, MFDouble) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFDouble encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFDouble self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFDouble(_X3DArrayField): """ Field type MFDouble is an array of Double values, meaning a double-precision floating-point array type. See GeoVRML 1.0 Recommended Practice, Section 2.3, Limitations of Single Precision for rationale. Array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFDouble' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFDoubleAndMFDouble' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFDouble' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFDouble __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFDouble): value = value.value # dereference elif value is None: value = MFDouble.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFDouble.DEFAULT_VALUE()=' + str(MFDouble.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFDouble(value): ### print(' upcast to MF type', value) ### value = MFDouble(SFDouble(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFDouble(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFDouble): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFDouble): self.__value.append(SFDouble(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFDouble): for each in value: self.__value.append(SFDouble(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFDouble(value).value) # checks validity ### if not value is None: ### if isValidSFDouble(value): ### if isinstance(value, SFDouble): ### value = SFDouble(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFDouble(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFDouble): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFDouble(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFDouble self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFFloat(_X3DField): """ Field type SFFloat is a single-precision floating-point type. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFFloat' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFFloatAndMFFloat' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFFloat' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return 0.0 @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=0.0): # print('*** SFFloat __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFFloat): value = value.value # dereference elif value is None: value = SFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFFloat.DEFAULT_VALUE()=' + str(SFFloat.DEFAULT_VALUE())) elif isinstance(value, MFFloat) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFFloat encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFFloat self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFFloat(_X3DArrayField): """ Field type MFFloat is an array of SFFloat values, meaning a single-precision floating-point array type. Array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFFloat' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFFloatAndMFFloat' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFFloat' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFFloat __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFFloat): value = value.value # dereference elif value is None: value = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFFloat(value): ### print(' upcast to MF type', value) ### value = MFFloat(SFFloat(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFFloat(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFFloat): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFFloat): self.__value.append(SFFloat(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFFloat): for each in value: self.__value.append(SFFloat(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFFloat(value).value) # checks validity ### if not value is None: ### if isValidSFFloat(value): ### if isinstance(value, SFFloat): ### value = SFFloat(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFFloat(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFFloat): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFFloat(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFFloat self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFImage(_X3DField): """ Field type SFImage specifies a single uncompressed 2-dimensional pixel image. SFImage fields contain three integers representing the width, height and number of components in the image, followed by (width x height) hexadecimal or integer values representing the pixels in the image. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFImage' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFImageAndMFImage' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFImage' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [0, 0, 0] @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?\s+){2}[+]?[0-4](\s+(0x[0-9a-fA-F]{1,16}|[+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?))*\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?\s+){2}[+]?[0-4](\s+(0x[0-9a-fA-F]{1,16}|[+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?))*\s*' # - - - - - - - - - - def __init__(self, value=[0, 0, 0]): # print('*** SFImage __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFImage): value = value.value # dereference elif value is None: value = SFImage.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFImage.DEFAULT_VALUE()=' + str(SFImage.DEFAULT_VALUE())) elif isinstance(value, MFImage) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFImage encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFImage self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFImage(_X3DArrayField): """ Field type MFImage is an array of SFImage values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFImage' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFImageAndMFImage' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFImage' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(([+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?\s+){2}[+]?[0-4](\s+(0x[0-9a-fA-F]{1,16}|[+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?))*\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?\s+){2}[+]?[0-4](\s+(0x[0-9a-fA-F]{1,16}|[+]?(0|[1-9][0-9]*)([Ee][+]?[0-9]+)?))*\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFImage __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFImage): value = value.value # dereference elif value is None: value = MFImage.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFImage.DEFAULT_VALUE()=' + str(MFImage.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFImage(value): ### print(' upcast to MF type', value) ### value = MFImage(SFImage(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFImage(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ int(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFImage): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFImage): self.__value.append(SFImage(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFImage): for each in value: self.__value.append(SFImage(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFImage(value).value) # checks validity ### if not value is None: ### if isValidSFImage(value): ### if isinstance(value, SFImage): ### value = SFImage(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFImage(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFImage): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFImage(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFImage self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFInt32(_X3DField): """ Field type SFInt32 specifies one 32-bit signed integer. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFInt32' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFInt32AndMFInt32' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFInt32' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return 0 @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*[+-]?(0|[1-9][0-9]*)([Ee][+-]?[0-9]+)?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*[+-]?(0|[1-9][0-9]*)([Ee][+-]?[0-9]+)?\s*' # - - - - - - - - - - def __init__(self, value=0): # print('*** SFInt32 __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = int(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFInt32): value = value.value # dereference elif value is None: value = SFInt32.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFInt32.DEFAULT_VALUE()=' + str(SFInt32.DEFAULT_VALUE())) elif isinstance(value, MFInt32) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: int(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', int(value)=' + str(int(value)), flush=True) value = int(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFInt32 encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFInt32 self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFInt32(_X3DArrayField): """ Field type MFInt32 defines an array of 32-bit signed integers. Array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFInt32' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFInt32AndMFInt32' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFInt32' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*([+-]?(0|[1-9][0-9]*)([Ee][+-]?[0-9]+)?\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?(0|[1-9][0-9]*)([Ee][+-]?[0-9]+)?\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFInt32 __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFInt32): value = value.value # dereference elif value is None: value = MFInt32.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFInt32.DEFAULT_VALUE()=' + str(MFInt32.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFInt32(value): ### print(' upcast to MF type', value) ### value = MFInt32(SFInt32(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFInt32(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ int(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFInt32): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFInt32): self.__value.append(SFInt32(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFInt32): for each in value: self.__value.append(SFInt32(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFInt32(value).value) # checks validity ### if not value is None: ### if isValidSFInt32(value): ### if isinstance(value, SFInt32): ### value = SFInt32(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFInt32(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFInt32): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFInt32(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFInt32 self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFMatrix3d(_X3DField): """ Field type SFMatrix3d specifies a 3x3 matrix of double-precision floating point numbers, organized in row-major fashion. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFMatrix3d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix3dAndMFMatrix3d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix3d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (1, 0, 0, 0, 1, 0, 0, 0, 1) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 9 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=(1, 0, 0, 0, 1, 0, 0, 0, 1)): # print('*** SFMatrix3d __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix3d): value = value.value # dereference elif value is None: value = SFMatrix3d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFMatrix3d.DEFAULT_VALUE()=' + str(SFMatrix3d.DEFAULT_VALUE())) elif isinstance(value, MFMatrix3d) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFMatrix3d encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFMatrix3d self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFMatrix3d(_X3DArrayField): """ Field type MFMatrix3d specifies zero or more 3x3 matrices of double-precision floating point numbers, organized in row-major fashion. Warning: comma characters can only appear between singleton 9-tuple values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFMatrix3d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix3dAndMFMatrix3d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix3d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 9 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFMatrix3d __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix3d): value = value.value # dereference elif value is None: value = MFMatrix3d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFMatrix3d.DEFAULT_VALUE()=' + str(MFMatrix3d.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFMatrix3d(value): ### print(' upcast to MF type', value) ### value = MFMatrix3d(SFMatrix3d(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFMatrix3d(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFMatrix3d): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFMatrix3d): self.__value.append(SFMatrix3d(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFMatrix3d): for each in value: self.__value.append(SFMatrix3d(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFMatrix3d(value).value) # checks validity ### if not value is None: ### if isValidSFMatrix3d(value): ### if isinstance(value, SFMatrix3d): ### value = SFMatrix3d(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFMatrix3d(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix3d): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFMatrix3d(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFMatrix3d self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFMatrix3f(_X3DField): """ Field type SFMatrix3f specifies a 3x3 matrix of single-precision floating point numbers, organized in row-major fashion. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFMatrix3f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix3fAndMFMatrix3f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix3f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (1, 0, 0, 0, 1, 0, 0, 0, 1) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 9 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=(1, 0, 0, 0, 1, 0, 0, 0, 1)): # print('*** SFMatrix3f __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix3f): value = value.value # dereference elif value is None: value = SFMatrix3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFMatrix3f.DEFAULT_VALUE()=' + str(SFMatrix3f.DEFAULT_VALUE())) elif isinstance(value, MFMatrix3f) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFMatrix3f encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFMatrix3f self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFMatrix3f(_X3DArrayField): """ Field type MFMatrix3f specifies zero or more 3x3 matrices of single-precision floating point numbers, organized in row-major fashion. Warning: comma characters can only appear between singleton 9-tuple values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFMatrix3f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix3fAndMFMatrix3f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix3f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 9 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){8}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFMatrix3f __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix3f): value = value.value # dereference elif value is None: value = MFMatrix3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFMatrix3f.DEFAULT_VALUE()=' + str(MFMatrix3f.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFMatrix3f(value): ### print(' upcast to MF type', value) ### value = MFMatrix3f(SFMatrix3f(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFMatrix3f(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFMatrix3f): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFMatrix3f): self.__value.append(SFMatrix3f(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFMatrix3f): for each in value: self.__value.append(SFMatrix3f(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFMatrix3f(value).value) # checks validity ### if not value is None: ### if isValidSFMatrix3f(value): ### if isinstance(value, SFMatrix3f): ### value = SFMatrix3f(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFMatrix3f(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix3f): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFMatrix3f(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFMatrix3f self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFMatrix4d(_X3DField): """ Field type SFMatrix4d specifies a 4x4 matrix of double-precision floating point numbers, organized in row-major fashion. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFMatrix4d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix4dAndMFMatrix4d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix4d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 16 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)): # print('*** SFMatrix4d __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix4d): value = value.value # dereference elif value is None: value = SFMatrix4d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFMatrix4d.DEFAULT_VALUE()=' + str(SFMatrix4d.DEFAULT_VALUE())) elif isinstance(value, MFMatrix4d) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFMatrix4d encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFMatrix4d self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFMatrix4d(_X3DArrayField): """ Field type MFMatrix4d specifies zero or more 4x4 matrices of double-precision floating point numbers, organized in row-major fashion. Warning: comma characters can only appear between singleton 16-tuple values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFMatrix4d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix4dAndMFMatrix4d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix4d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 16 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFMatrix4d __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix4d): value = value.value # dereference elif value is None: value = MFMatrix4d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFMatrix4d.DEFAULT_VALUE()=' + str(MFMatrix4d.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFMatrix4d(value): ### print(' upcast to MF type', value) ### value = MFMatrix4d(SFMatrix4d(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFMatrix4d(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFMatrix4d): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFMatrix4d): self.__value.append(SFMatrix4d(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFMatrix4d): for each in value: self.__value.append(SFMatrix4d(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFMatrix4d(value).value) # checks validity ### if not value is None: ### if isValidSFMatrix4d(value): ### if isinstance(value, SFMatrix4d): ### value = SFMatrix4d(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFMatrix4d(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix4d): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFMatrix4d(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFMatrix4d self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFMatrix4f(_X3DField): """ Field type SFMatrix4f specifies a 4x4 matrix of single-precision floating point numbers, organized in row-major fashion. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFMatrix4f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix4fAndMFMatrix4f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFMatrix4f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 16 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)): # print('*** SFMatrix4f __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix4f): value = value.value # dereference elif value is None: value = SFMatrix4f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFMatrix4f.DEFAULT_VALUE()=' + str(SFMatrix4f.DEFAULT_VALUE())) elif isinstance(value, MFMatrix4f) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFMatrix4f encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFMatrix4f self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFMatrix4f(_X3DArrayField): """ Field type MFMatrix4f specifies zero or more 4x4 matrices of single-precision floating point numbers, organized in row-major fashion. Warning: comma characters can only appear between singleton 16-tuple values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFMatrix4f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFMatrix4fAndMFMatrix4f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFMatrix4f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 16 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){15}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFMatrix4f __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFMatrix4f): value = value.value # dereference elif value is None: value = MFMatrix4f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFMatrix4f.DEFAULT_VALUE()=' + str(MFMatrix4f.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFMatrix4f(value): ### print(' upcast to MF type', value) ### value = MFMatrix4f(SFMatrix4f(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFMatrix4f(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFMatrix4f): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFMatrix4f): self.__value.append(SFMatrix4f(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFMatrix4f): for each in value: self.__value.append(SFMatrix4f(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFMatrix4f(value).value) # checks validity ### if not value is None: ### if isValidSFMatrix4f(value): ### if isinstance(value, SFMatrix4f): ### value = SFMatrix4f(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFMatrix4f(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFMatrix4f): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFMatrix4f(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFMatrix4f self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFNode(_X3DField): """ Field type SFNode specifies an X3D node; the default empty value of an uninitialized SFNode field is sometimes described as NULL. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFNodeAndMFNode' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFNode' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return None @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [('value', 'None', FieldType.SFNode, AccessType.inputOutput, 'SFNode')] @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'' # - - - - - - - - - - def __init__(self, value=None): # print('*** SFNode __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFNode): value = value.value # dereference elif value is None: value = SFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFNode.DEFAULT_VALUE()=' + str(SFNode.DEFAULT_VALUE())) elif isinstance(value, MFNode) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFNode self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ if not self.__value is None: return self.__value.XML() return None def VRML(self): """ Provide VRML value for this field type. """ if not self.__value is None: return self.__value.VRML() return None def JSON(self): """ Provide JSON value for this field type. """ if not self.__value is None: return self.__value.JSON() return None class MFNode(_X3DArrayField): """ Field type MFNode specifies zero or more nodes; the default value of an MFNode field is the empty list. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFNodeAndMFNode' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFNode' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [('value', None, FieldType.MFNode, AccessType.inputOutput, 'MFNode')] @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFNode __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFNode): value = value.value # dereference elif value is None: value = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFNode(value): ### print(' upcast to MF type', value) ### value = MFNode(SFNode(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFNode(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ list(value) ] self.__value = value def __repl__(self): result = '[' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: result += str(each) + ', ' return result.rstrip(', ') + ']' def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFNode): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFNode): self.__value.append(SFNode(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFNode): for each in value: self.__value.append(SFNode(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFNode(value).value) # checks validity ### if not value is None: ### if isValidSFNode(value): ### if isinstance(value, SFNode): ### value = SFNode(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFNode(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFNode): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFNode(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFNode self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ result = '' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: if not self.__value is None: result += each.XML() # has line break '\n' at end, which is OK result = result.rstrip('\n') return result def VRML(self): """ Provide VRML value for this field type. """ result = '' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: if not self.__value is None: result += each.VRML() # has line break '\n' at end, which is OK result = result.rstrip('\n') return result def JSON(self): """ Provide JSON value for this field type. """ result = '' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: if not self.__value is None: result += each.JSON() # TODO? has line break '\n' at end, which is OK result = result.rstrip('\n') return result class SFRotation(_X3DField): """ Field type SFRotation is an axis-angle 4-tuple, indicating X-Y-Z direction axis plus angle orientation about that axis. The first three values specify a normalized axis vector about which the rotation takes place, so the first three values shall be within the range [-1..+1] in order to represent a normalized unit vector. The fourth value specifies the amount of right-handed rotation about that axis in radians. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFRotation' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFRotationAndMFRotation' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFRotation' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0, 0, 1, 0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): # print('*** SFRotation __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFRotation): value = value.value # dereference elif value is None: value = SFRotation.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFRotation.DEFAULT_VALUE()=' + str(SFRotation.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] elif isinstance(value, MFRotation) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFRotation encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFRotation self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFRotation(_X3DArrayField): """ Field type MFRotation is an array of SFRotation values. Individual singleton SFRotation array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFRotation' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFRotationAndMFRotation' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFRotation' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFRotation __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFRotation): value = value.value # dereference elif value is None: value = MFRotation.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFRotation.DEFAULT_VALUE()=' + str(MFRotation.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] ### elif not isinstance(value, list) and isValidSFRotation(value): ### print(' upcast to MF type', value) ### value = MFRotation(SFRotation(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFRotation(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFRotation): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFRotation): self.__value.append(SFRotation(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFRotation): for each in value: self.__value.append(SFRotation(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFRotation(value).value) # checks validity ### if not value is None: ### if isValidSFRotation(value): ### if isinstance(value, SFRotation): ### value = SFRotation(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFRotation(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFRotation): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFRotation(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFRotation self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFString(_X3DField): """ Field type SFString defines a single string encoded with the UTF-8 universal character set. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFString' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFStringAndMFString' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFString' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return '' @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'(\s|\S)*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'(\s|\S)*' # - - - - - - - - - - def __init__(self, value=''): # print('*** SFString __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFString): value = value.value # dereference elif value is None: value = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) elif isinstance(value, MFString) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFString self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).replace("'","'").replace("& ","& ").replace("<","<").replace(">",">") def VRML(self): """ Provide VRML value for this field type. """ return '"' + str(self.__value) + '"' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).replace('"','"') class MFString(_X3DArrayField): """ Field type MFString is an array of SFString values, each "quoted" and separated by whitespace. Individual SFString array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFString' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFStringAndMFString' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFString' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?(\s|\S)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'(\s|\S)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFString __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFString): value = value.value # dereference elif value is None: value = MFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFString.DEFAULT_VALUE()=' + str(MFString.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFString(value): ### print(' upcast to MF type', value) ### value = MFString(SFString(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFString(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ str(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFString): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFString): self.__value.append(SFString(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFString): for each in value: self.__value.append(SFString(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFString(value).value) # checks validity ### if not value is None: ### if isValidSFString(value): ### if isinstance(value, SFString): ### value = SFString(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFString(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFString): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFString(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFString self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ result = '' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: result += '"' + str(each).replace("'","'").replace("& ","& ").replace("<","<").replace(">",">") + '"' + ' ' result = result.rstrip(' ') return result def VRML(self): """ Provide VRML value for this field type. """ result = '' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: result += '"' + str(each) + '"' + ' ' result = '[' + result.rstrip(' ') + ']' return result def JSON(self): """ Provide JSON value for this field type. """ result = '' if self.__value: # walk each child in list, if any (avoid empty list recursion) for each in self.__value: result += '"' + str(each).replace('"','"') + '"' + ' ' result = result.rstrip(' ') return result class SFTime(_X3DField): """ Field type SFTime specifies a single time value, expressed as a double-precision floating point number. Typically, SFTime fields represent the number of seconds since Jan 1, 1970, 00:00:00 GMT. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFTime' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFTimeAndMFTime' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFTime' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return -1.0 @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=-1.0): # print('*** SFTime __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFTime): value = value.value # dereference elif value is None: value = SFTime.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFTime.DEFAULT_VALUE()=' + str(SFTime.DEFAULT_VALUE())) elif isinstance(value, MFTime) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFTime encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFTime self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFTime(_X3DArrayField): """ Field type MFTime is an array of SFTime values. Array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFTime' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFTimeAndMFTime' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFTime' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 1 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFTime __init__ value=' + str(value), 'type=' + str(type(value))) # debug self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed and sized values. """ if isinstance(value,SFTime): value = value.value # dereference elif value is None: value = MFTime.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFTime.DEFAULT_VALUE()=' + str(MFTime.DEFAULT_VALUE())) ### elif not isinstance(value, list) and isValidSFTime(value): ### print(' upcast to MF type', value) ### value = MFTime(SFTime(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFTime(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFTime): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFTime): self.__value.append(SFTime(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFTime): for each in value: self.__value.append(SFTime(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFTime(value).value) # checks validity ### if not value is None: ### if isValidSFTime(value): ### if isinstance(value, SFTime): ### value = SFTime(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFTime(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFTime): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFTime(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFTime self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFVec2d(_X3DField): """ Field type SFVec2d is a 2-tuple pair of SFDouble values. Hint: SFVec2d can be used to specify a 2D double-precision coordinate. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFVec2d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec2dAndMFVec2d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec2d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0.0, 0.0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 2 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None): # print('*** SFVec2d __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None: value = (float(value),float(value2)) if isinstance(value,SFVec2d): value = value.value # dereference elif value is None: value = SFVec2d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFVec2d.DEFAULT_VALUE()=' + str(SFVec2d.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 2: value = (value[0],value[1]) else: # no tuples found, create 2-tuples value = [(x, y) for x, y, in value] elif isinstance(value, MFVec2d) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFVec2d encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFVec2d self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFVec2d(_X3DArrayField): """ Field type MFVec2d is an array of SFVec2d values. Individual singleton SFVec2d array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFVec2d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec2dAndMFVec2d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec2d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 2 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFVec2d __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None: value = (float(value),float(value2)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None: value = (float(value),float(value2)) if isinstance(value,SFVec2d): value = value.value # dereference elif value is None: value = MFVec2d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2d.DEFAULT_VALUE()=' + str(MFVec2d.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 2: value = (value[0],value[1]) else: # no tuples found, create 2-tuples value = [(x, y) for x, y, in value] ### elif not isinstance(value, list) and isValidSFVec2d(value): ### print(' upcast to MF type', value) ### value = MFVec2d(SFVec2d(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFVec2d(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFVec2d): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFVec2d): self.__value.append(SFVec2d(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFVec2d): for each in value: self.__value.append(SFVec2d(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFVec2d(value).value) # checks validity ### if not value is None: ### if isValidSFVec2d(value): ### if isinstance(value, SFVec2d): ### value = SFVec2d(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFVec2d(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec2d): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFVec2d(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFVec2d self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFVec2f(_X3DField): """ Field type SFVec2f is a 2-tuple pair of SFFloat values. Hint: SFVec2f can be used to specify a 2D single-precision coordinate. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFVec2f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec2fAndMFVec2f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec2f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0.0, 0.0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 2 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None): # print('*** SFVec2f __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None: value = (float(value),float(value2)) if isinstance(value,SFVec2f): value = value.value # dereference elif value is None: value = SFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFVec2f.DEFAULT_VALUE()=' + str(SFVec2f.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 2: value = (value[0],value[1]) else: # no tuples found, create 2-tuples value = [(x, y) for x, y, in value] elif isinstance(value, MFVec2f) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFVec2f encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFVec2f self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFVec2f(_X3DArrayField): """ Field type MFVec2f is an array of SFVec2f values. Individual singleton SFVec2f array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFVec2f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec2fAndMFVec2f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec2f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 2 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){1}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFVec2f __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None: value = (float(value),float(value2)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None: value = (float(value),float(value2)) if isinstance(value,SFVec2f): value = value.value # dereference elif value is None: value = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 2: value = (value[0],value[1]) else: # no tuples found, create 2-tuples value = [(x, y) for x, y, in value] ### elif not isinstance(value, list) and isValidSFVec2f(value): ### print(' upcast to MF type', value) ### value = MFVec2f(SFVec2f(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFVec2f(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFVec2f): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFVec2f): self.__value.append(SFVec2f(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFVec2f): for each in value: self.__value.append(SFVec2f(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFVec2f(value).value) # checks validity ### if not value is None: ### if isValidSFVec2f(value): ### if isinstance(value, SFVec2f): ### value = SFVec2f(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFVec2f(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec2f): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFVec2f(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFVec2f self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFVec3d(_X3DField): """ Field type SFVec3d is a 3-tuple triplet of SFDouble values. See GeoVRML 1.0 Recommended Practice, Section 2.3, Limitations of Single Precision. Hint: SFVec3d can be used to specify a georeferenced 3D coordinate. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFVec3d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec3dAndMFVec3d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec3d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0.0, 0.0, 0.0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 3 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None): # print('*** SFVec3d __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) if isinstance(value,SFVec3d): value = value.value # dereference elif value is None: value = SFVec3d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFVec3d.DEFAULT_VALUE()=' + str(SFVec3d.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 3: value = (value[0],value[1],value[2]) else: # no tuples found, create 3-tuples value = [(x, y, z) for x, y, z in value] elif isinstance(value, MFVec3d) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFVec3d encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFVec3d self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFVec3d(_X3DArrayField): """ Field type MFVec3d is an array of SFVec3d values. Individual singleton SFVec3d array values are optionally separated by commas in XML syntax. Original rationale for inclusion: GeoVRML 1.0 Recommended Practice, Section 2.3, Limitations of Single Precision. Hint: MFVec3d can be used to specify a list of georeferenced 3D coordinates. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFVec3d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec3dAndMFVec3d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec3d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 3 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFVec3d __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) if isinstance(value,SFVec3d): value = value.value # dereference elif value is None: value = MFVec3d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec3d.DEFAULT_VALUE()=' + str(MFVec3d.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 3: value = (value[0],value[1],value[2]) else: # no tuples found, create 3-tuples value = [(x, y, z) for x, y, z in value] ### elif not isinstance(value, list) and isValidSFVec3d(value): ### print(' upcast to MF type', value) ### value = MFVec3d(SFVec3d(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFVec3d(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFVec3d): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFVec3d): self.__value.append(SFVec3d(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFVec3d): for each in value: self.__value.append(SFVec3d(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFVec3d(value).value) # checks validity ### if not value is None: ### if isValidSFVec3d(value): ### if isinstance(value, SFVec3d): ### value = SFVec3d(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFVec3d(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec3d): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFVec3d(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFVec3d self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFVec3f(_X3DField): """ Field type SFVec3f is a 3-tuple triplet of SFFloat values. Hint: SFVec3f can be used to specify a 3D coordinate or a 3D scale value. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFVec3f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec3fAndMFVec3f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec3f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0.0, 0.0, 0.0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 3 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None): # print('*** SFVec3f __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) if isinstance(value,SFVec3f): value = value.value # dereference elif value is None: value = SFVec3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFVec3f.DEFAULT_VALUE()=' + str(SFVec3f.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 3: value = (value[0],value[1],value[2]) else: # no tuples found, create 3-tuples value = [(x, y, z) for x, y, z in value] elif isinstance(value, MFVec3f) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFVec3f encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFVec3f self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFVec3f(_X3DArrayField): """ Field type MFVec3f is an array of SFVec3f values. Individual singleton SFVec3f array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFVec3f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec3fAndMFVec3f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec3f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 3 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){2}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFVec3f __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None: value = (float(value),float(value2),float(value3)) if isinstance(value,SFVec3f): value = value.value # dereference elif value is None: value = MFVec3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec3f.DEFAULT_VALUE()=' + str(MFVec3f.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 3: value = (value[0],value[1],value[2]) else: # no tuples found, create 3-tuples value = [(x, y, z) for x, y, z in value] ### elif not isinstance(value, list) and isValidSFVec3f(value): ### print(' upcast to MF type', value) ### value = MFVec3f(SFVec3f(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFVec3f(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFVec3f): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFVec3f): self.__value.append(SFVec3f(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFVec3f): for each in value: self.__value.append(SFVec3f(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFVec3f(value).value) # checks validity ### if not value is None: ### if isValidSFVec3f(value): ### if isinstance(value, SFVec3f): ### value = SFVec3f(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFVec3f(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec3f): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFVec3f(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFVec3f self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFVec4d(_X3DField): """ Field type SFVec4d is a 4-tuple set of double-precision floating-point values, specifying a 3D homogeneous vector. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFVec4d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec4dAndMFVec4d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec4d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0.0, 0.0, 0.0, 1.0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): # print('*** SFVec4d __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFVec4d): value = value.value # dereference elif value is None: value = SFVec4d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFVec4d.DEFAULT_VALUE()=' + str(SFVec4d.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] elif isinstance(value, MFVec4d) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFVec4d encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFVec4d self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFVec4d(_X3DArrayField): """ Field type MFVec4d is zero or more SFVec4d values. Individual singleton SFVec4d array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFVec4d' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec4dAndMFVec4d' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec4d' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFVec4d __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFVec4d): value = value.value # dereference elif value is None: value = MFVec4d.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec4d.DEFAULT_VALUE()=' + str(MFVec4d.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] ### elif not isinstance(value, list) and isValidSFVec4d(value): ### print(' upcast to MF type', value) ### value = MFVec4d(SFVec4d(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFVec4d(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFVec4d): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFVec4d): self.__value.append(SFVec4d(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFVec4d): for each in value: self.__value.append(SFVec4d(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFVec4d(value).value) # checks validity ### if not value is None: ### if isValidSFVec4d(value): ### if isinstance(value, SFVec4d): ### value = SFVec4d(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFVec4d(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec4d): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFVec4d(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFVec4d self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') class SFVec4f(_X3DField): """ Field type SFVec4f is a 4-tuple set of single-precision floating-point values, specifying a 3D homogeneous vector. Warning: comma characters within singleton values do not pass strict XML validation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'SFVec4f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec4fAndMFVec4f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SFVec4f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return (0.0, 0.0, 0.0, 1.0) @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return False @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\(\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\)\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): # print('*** SFVec4f __init__ value=' + str(value), 'type=' + str(type(value))) # debug if isinstance(value,str): value = float(value) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFVec4f): value = value.value # dereference elif value is None: value = SFVec4f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFVec4f.DEFAULT_VALUE()=' + str(SFVec4f.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] elif isinstance(value, MFVec4f) and isinstance(value.value, list) and len(value.value) == 1: print("downcasting by dereferencing simple-list value=" + str(value)[:100] + ", type=" + str(type(value)) + " as " + str(value.value[0])) value = value.value[0] # dereference elif isinstance(value, list) and len(value) == 1: value = value[0] # dereference # https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float if isinstance(value, str): try: float(value) # this statement checks but does not set value, may throw exception print('*** string value provided, value=' + str(value) + ', float(value)=' + str(float(value)), flush=True) value = float(value) except ValueError as error: # https://stackoverflow.com/questions/66995878/consider-explicitly-re-raising-using-the-from-keyword-pylint-suggestion raise X3DTypeError('SFVec4f encountered string with illegal value=' + str(value)) from error self.__value = value def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, SFVec4f self.__value type=' + str(type(self.__value)) + ' is not a list') return len(self.__value) > 0 def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace(',', '').replace('(', '').replace(')', '').replace('[', '').replace(']', '') class MFVec4f(_X3DArrayField): """ Field type MFVec4f is zero or more SFVec4f values. Individual singleton SFVec4f array values are optionally separated by commas in XML syntax. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Field class. """ return 'MFVec4f' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/fieldsDef.html#SFVec4fAndMFVec4f' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#MFVec4f' @classmethod def DEFAULT_VALUE(cls): """ Default value defined for this data type by the X3D Specification """ return [] # use empty list object, don't keep resetting a mutable python DEFAULT_VALUE @classmethod def ARRAY_TYPE(cls): """ Whether or not this field class is array based. """ return True @classmethod def TUPLE_SIZE(cls): """ How many values make up each data tuple. """ return 4 @classmethod def REGEX_PYTHON(cls): """ Regular expression for validating Python values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*\[?\s*(\s*\(?\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*\,?\s*){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*\)?\s*\,?)*\s*\]?\s*' @classmethod def REGEX_XML(cls): """ Regular expression for validating XML values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'\s*((([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s+){3}([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*' # - - - - - - - - - - def __init__(self, value=None,value2=None,value3=None,value4=None): if value is None: value = self.DEFAULT_VALUE() # print('*** MFVec4f __init__ value=' + str(value), 'type=' + str(type(value))) # debug if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide typed value of this field instance. """ return self.__value @value.setter def value(self, value,value2=None,value3=None,value4=None): """ The value setter only allows correctly typed and sized values. """ if value2 is not None and value3 is not None and value4 is not None: value = (float(value),float(value2),float(value3),float(value4)) if isinstance(value,SFVec4f): value = value.value # dereference elif value is None: value = MFVec4f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec4f.DEFAULT_VALUE()=' + str(MFVec4f.DEFAULT_VALUE())) elif isinstance(value, list): for each in value: # check that contained elements are not tuples or lists if isinstance(each, tuple): break if len(value) == 4: value = (value[0],value[1],value[2],value[3]) else: # no tuples found, create 4-tuples value = [(x, y, z, w) for x, y, z, w in value] ### elif not isinstance(value, list) and isValidSFVec4f(value): ### print(' upcast to MF type', value) ### value = MFVec4f(SFVec4f(value)) elif isinstance(value, list): if not value is None and not (isinstance(value,list) and len(value) == 0): _newValue = [] for each in value: _newValue.append(SFVec4f(each).value) # if _DEBUG: print('...DEBUG... assign list, value=' + str(value), ', type=' + str(type(value)), ', _newValue=' + str(_newValue),flush=True) value = _newValue elif isinstance(value, str): value = [ float(value) ] self.__value = value def append(self, value=None): """ Add to existing value list, first ensuring that a correctly typed value is applied. """ if not value is None: # if _DEBUG: print('...DEBUG... append to list, value=' + str(self.__value), ', type=' + str(type(self.__value)), ', value=' + str(value),flush=True) if isinstance(value,SFVec4f): self.__value.append(value.value) # dereference elif not isinstance(value,list) and not isinstance(value,MFVec4f): self.__value.append(SFVec4f(value).value) # checks validity elif (isinstance(value,list) and len(value) > 0) or isinstance(value,MFVec4f): for each in value: self.__value.append(SFVec4f(each).value) # checks validity elif isinstance(value,str): self.__value.append(SFVec4f(value).value) # checks validity ### if not value is None: ### if isValidSFVec4f(value): ### if isinstance(value, SFVec4f): ### value = SFVec4f(value).value # dereference value from base type ### self.__value.append(value) ### elif isValidMFVec4f(value): ### for each in value: ### while isinstance(each, list) and len(each) == 1: ### each = each[0] # dereference ### if isinstance(each, SFVec4f): ### each = each.value # dereference ### self.__value.append(each) ### else: ### assertValidMFVec4f(value) # report type failure def __bool__(self): if not isinstance(self.__value,list): print('*** x3d.py internal error, MFVec4f self.__value type=' + str(type(self.__value)) + ' is not a list', flush=True) return len(self.__value) > 0 def __len__(self): return len(self.__value) def XML(self): """ Provide XML value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') def VRML(self): """ Provide VRML value for this field type. """ return '[' + str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') + ']' def JSON(self): """ Provide JSON value for this field type. """ return str(self.__value).lower().replace('(', '').replace(')', '').replace(',', '').replace('[', '').replace(']', '') ############################################### # Abstract Node Types # Note that these package-internal class names are preceded by an underscore _ character for hidden scope, since X3D authors are not expected to use them. class _X3DNode: """ All instantiable nodes implement X3DNode, which corresponds to SFNode type in the X3D specification. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#X3DNode' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html' # Field declarations for this node are performed by implementing node def __init__(self, DEF="", USE="", class_="", id_="", style_="", IS=None, metadata=None): self.DEF = DEF self.USE = USE self.class_ = class_ self.id_ = id_ self.style_ = style_ self.IS = IS self.metadata = metadata # if _DEBUG: print('...DEBUG... in X3DNode __init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) @property # getter - - - - - - - - - - def DEF(self): """ Unique ID name for this node, referenceable by other X3D nodes. """ return self.__DEF @DEF.setter def DEF(self, DEF): if DEF is None: DEF = SFString.DEFAULT_VALUE() assertValidSFString(DEF) self.__DEF = str(DEF) if self.__DEF: self.__USE = None # DEF and USE are mutually exclusive @property # getter - - - - - - - - - - def USE(self): """ Reuse an already DEF-ed node ID, excluding all child nodes and all other attributes. """ return self.__USE @USE.setter def USE(self, USE): if USE is None: USE = SFString.DEFAULT_VALUE() assertValidSFString(USE) self.__USE = str(USE) if self.__USE: self.__DEF = None # DEF and USE are mutually exclusive @property # getter - - - - - - - - - - def class_(self): """ Space-separated list of classes, reserved for use by CSS cascading stylesheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__class_ @class_.setter def class_(self, class_): if class_ is None: class_ = SFString.DEFAULT_VALUE() assertValidSFString(class_) self.__class_ = class_ @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() assertValidSFString(id_) self.__id = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() assertValidSFString(style_) self.__style_ = style_ @property # getter - - - - - - - - - - def IS(self): """ The IS statement connects node fields defined inside a ProtoBody declaration back to corresponding ProtoInterface fields. """ return self.__IS @IS.setter def IS(self, IS): if IS is None: self.__IS = SFNode.DEFAULT_VALUE() assertValidSFNode(IS) if not isinstance(IS, object) and not isinstance(IS, [ IS ] ): # TODO disambiguate IS naming # print(flush=True) raise X3DTypeError(str(IS) + ' IS.setter does not have a valid node type object, must be an IS node') self.__IS = IS @property # getter - - - - - - - - - - def metadata(self): """ The metadata field can contain a single MetadataBoolean, MetadataInteger, MetadataFloat, MetadataDouble, MetadataString or MetadataSet node. """ return self.__metadata @metadata.setter def metadata(self, metadata): if metadata is None: metadata = SFNode.DEFAULT_VALUE() assertValidSFNode(metadata) if not isinstance(metadata, object) and not isinstance(metadata, ( MetadataBoolean, MetadataInteger, MetadataFloat, MetadataDouble, MetadataString, MetadataSet, ProtoInstance ) ): # print(flush=True) raise X3DTypeError(str(metadata) + ' metadata.setter does not have a valid node type object, must be a Metadata* node or ProtoInstance') self.__metadata = metadata def __repl__(self): result = self.NAME() + '(' # TODO put DEF first, matching canonical form if self.FIELD_DECLARATIONS(): for each in self.FIELD_DECLARATIONS(): # if _DEBUG: print(self.NAME() + ' for each in self.FIELD_DECLARATIONS(): each=' + str(each)) name = each[0] default = each[1] type_ = each[2] accessType = each[3] value = getattr(self, name) # if _DEBUG: print('gettattr(self, ' + str(name) + ') value="' + str(value)[:100] + '" for FIELD_DECLARATIONS() ' + str(each) + ')', flush=True) if value != default: # consider whether indentation is useful; probably not # print("\n\t") if isinstance(value, list): # avoid X3DTypeError if value is not iterable result += str(name) + '=[' for each in value: # if _DEBUG: print('...DEBUG... X3DNode debug: str(each)=' + str(each), flush=True) result += str(each) + ', ' result = result.rstrip(', ') result += '],' elif isinstance(value, str) and "'" in value: result += str(name) + '=' + '"' + str(value)[:100] + '"' + ',' elif isinstance(value, str) and value != default: result += str(name) + '=' + "'" + str(value)[:100] + "'" + ',' elif value != default: result += str(name) + '=' + str(value)[:100] + ',' # elif _DEBUG: # result += str(name) + '=' + "'" + str(value)[:100] + "'" + ',' return result.strip().rstrip(',').rstrip(', ') + ')' def __str__(self): return self.__repl__().strip() # X3DNode class _X3DChildNode(_X3DNode): """ A node that implements X3DChildNode is one of the legal children for a X3DGroupingNode parent. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DChildNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#X3DChildNode' class _X3DSoundNode(_X3DChildNode): """ Base type for all sound nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSoundNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#X3DSoundNode' class _X3DSoundChannelNode(_X3DSoundNode): """ Base type for all sound destination nodes, which represent the final destination of an audio signal and are what the user can ultimately hear. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSoundChannelNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#X3DSoundChannelNode' class _X3DTimeDependentNode(_X3DChildNode): """ Base type from which all time-dependent nodes are derived. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTimeDependentNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/time.html#X3DTimeDependentNode' class _X3DGeometryNode(_X3DNode): """ Geometry nodes produce renderable geometry and are contained by a Shape node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DGeometryNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#X3DGeometryNode' class _X3DParametricGeometryNode(_X3DGeometryNode): """ Base type for all geometry node types that are created parametrically and use control points to describe the final shape of the surface. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DParametricGeometryNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/nurbs.html#X3DParametricGeometryNode' class _X3DAppearanceChildNode(_X3DNode): """ Nodes of this type can be used as child nodes for Appearance. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DAppearanceChildNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#X3DAppearanceChildNode' class _X3DTextureNode(_X3DAppearanceChildNode): """ Base type for all nodes which specify sources for texture images. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTextureNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DTextureNode' class _X3DSensorNode(_X3DChildNode): """ Base type for all sensors. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#X3DSensorNode' class _X3DPointingDeviceSensorNode(_X3DSensorNode): """ Base type for all pointing device sensors. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DPointingDeviceSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/pointingDeviceSensor.html#X3DPointingDeviceSensorNode' class _X3DVolumeRenderStyleNode(_X3DNode): """ The X3DVolumeRenderStyleNode abstract node type is the base type for all node types that specify a specific visual rendering style to be used when rendering volume data. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DVolumeRenderStyleNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#X3DVolumeRenderStyleNode' class _X3DGeometricPropertyNode(_X3DNode): """ Base type for all geometric property node types. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DGeometricPropertyNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#X3DGeometricPropertyNode' class _X3DFollowerNode(_X3DChildNode): """ X3DFollowerNode is the abstract base class for all nodes in the Followers component. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DFollowerNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/followers.html#X3DFollowerNode' class _X3DBindableNode(_X3DChildNode): """ Bindable nodes implement the binding stack, so that only one of each node type is active at a given time. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DBindableNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#X3DBindableNode' class _X3DAppearanceNode(_X3DNode): """ Base type for all Appearance nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DAppearanceNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#X3DAppearanceNode' class _X3DBackgroundNode(_X3DBindableNode): """ Abstract type from which all backgrounds inherit, also defining a background binding stack. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DBackgroundNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalEffects.html#X3DBackgroundNode' class _X3DChaserNode(_X3DFollowerNode): """ The X3DChaserNode abstract node type calculates the output on value_changed as a finite impulse response (FIR) based on the events received on set_destination field. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DChaserNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/followers.html#X3DChaserNode' class _X3DColorNode(_X3DGeometricPropertyNode): """ Base type for color specifications in X3D. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DColorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#X3DColorNode' class _X3DComposableVolumeRenderStyleNode(_X3DVolumeRenderStyleNode): """ The X3DComposableVolumeRenderStyleNode abstract node type is the base type for all node types that allow rendering styles to be sequentially composed together to form a single renderable output. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DComposableVolumeRenderStyleNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#X3DComposableVolumeRenderStyleNode' class _X3DComposedGeometryNode(_X3DGeometryNode): """ Composed geometry nodes produce renderable geometry, can contain Color Coordinate Normal TextureCoordinate, and are contained by a Shape node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DComposedGeometryNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#X3DComposedGeometryNode' class _X3DCoordinateNode(_X3DGeometricPropertyNode): """ Base type for all coordinate node types in X3D. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DCoordinateNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#X3DCoordinateNode' class _X3DDamperNode(_X3DFollowerNode): """ The X3DDamperNode abstract node type creates an IIR response that approaches the destination value according to the shape of the e-function only asymptotically but very quickly. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DDamperNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/followers.html#X3DDamperNode' class _X3DDragSensorNode(_X3DPointingDeviceSensorNode): """ Base type for all drag-style pointing device sensors. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DDragSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/pointingDeviceSensor.html#X3DDragSensorNode' class _X3DEnvironmentalSensorNode(_X3DSensorNode): """ Base type for the environmental sensor nodes ProximitySensor, TransformSensor and VisibilitySensor. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DEnvironmentalSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalSensor.html#X3DEnvironmentalSensorNode' class _X3DEnvironmentTextureNode(_X3DTextureNode): """ Base type for all nodes that specify cubic environment map sources for texture images. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DEnvironmentTextureNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalTexturing#X3DEnvironmentTextureNode' class _X3DFontStyleNode(_X3DNode): """ Base type for all font style nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DFontStyleNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/text.html#X3DFontStyleNode' class _X3DGroupingNode(_X3DChildNode): """ Grouping nodes can contain other nodes as children, thus making up the backbone of a scene graph. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DGroupingNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/grouping.html#X3DGroupingNode' class _X3DInfoNode(_X3DChildNode): """ Base type for all nodes that contain only information without visual semantics. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DInfoNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/grouping.html#X3DInfoNode' class _X3DInterpolatorNode(_X3DChildNode): """ Interpolator nodes are designed for linear keyframed animation. Interpolators are driven by an input key ranging [0..1] and produce corresponding piecewise-linear output functions. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DInterpolatorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/interpolators.html#X3DInterpolatorNode' class _X3DKeyDeviceSensorNode(_X3DSensorNode): """ Base type for all sensor node types that operate using key devices. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DKeyDeviceSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/keyDeviceSensor.html#X3DKeyDeviceSensorNode' class _X3DLayerNode(_X3DNode): """ The X3DLayerNode abstract node type is the base node type for layer nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DLayerNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/layering.html#X3DLayerNode' class _X3DLayoutNode(_X3DChildNode): """ X3DLayoutNode is the base node type for layout nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DLayoutNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/layout.html#X3DLayoutNode' class _X3DLightNode(_X3DChildNode): """ Light nodes provide illumination for rendering geometry in the scene. Implementing nodes must include a global field with type SFBool and accessType inputOutput. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DLightNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/lighting.html#X3DLightNode' class _X3DMaterialNode(_X3DAppearanceChildNode): """ Base type for all Material nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DMaterialNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#X3DMaterialNode' class _X3DNBodyCollidableNode(_X3DChildNode): """ The X3DNBodyCollidableNode abstract node type represents objects that act as the interface between the rigid body physics, collision geometry proxy, and renderable objects in the scene graph hierarchy. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNBodyCollidableNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rigidBodyPhysics.html#X3DNBodyCollidableNode' class _X3DNBodyCollisionSpaceNode(_X3DNode): """ The X3DNBodyCollisionSpaceNode abstract node type represents objects that act as a self-contained spatial collection of objects that can interact through collision detection routines. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNBodyCollisionSpaceNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rigidBodyPhysics.html#X3DNBodyCollisionSpaceNode' class _X3DNetworkSensorNode(_X3DSensorNode): """ Base typefor all sensors that generate events based on network activity. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNetworkSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/networking.html#X3DNetworkSensorNode' class _X3DNormalNode(_X3DGeometricPropertyNode): """ Base type for all normal node types in X3D. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNormalNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#X3DNormalNode' class _X3DNurbsControlCurveNode(_X3DNode): """ Base type for all nodes that provide control curve information in 2D space. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNurbsControlCurveNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/nurbs.html#X3DNurbsControlCurveNode' class _X3DNurbsSurfaceGeometryNode(_X3DParametricGeometryNode): """ Abstract geometry type for all types of NURBS surfaces. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DNurbsSurfaceGeometryNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/nurbs.html#X3DNurbsSurfaceGeometryNode' class _X3DOneSidedMaterialNode(_X3DMaterialNode): """ Base type for material nodes that describe how the shape looks like from one side. A different number of contanied texture nodes are allowed by each of the implementing nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DOneSidedMaterialNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#X3DOneSidedMaterialNode' class _X3DParticleEmitterNode(_X3DNode): """ The X3DParticleEmitterNode abstract type represents any node that is an emitter of particles. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DParticleEmitterNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/particleSystems.html#X3DParticleEmitterNode' class _X3DParticlePhysicsModelNode(_X3DNode): """ The X3DParticlePhysicsModelNode abstract type represents any node that applies a form of constraints on the particles after they have been generated. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DParticlePhysicsModelNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/particleSystems.html#X3DParticlePhysicsModelNode' class _X3DPickSensorNode(_X3DSensorNode): """ The X3DPickSensorNode abstract node type is the base node type that represents the lowest common denominator of picking capabilities. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DPickSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/picking.html#X3DPickSensorNode' class _X3DProductStructureChildNode(_X3DChildNode): """ Base type marking nodes that are valid product structure children for the CADGeometry component. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DProductStructureChildNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/CADGeometry.html#X3DProductStructureChildNode' class _X3DPrototypeInstance(_X3DNode): """ Base type for all prototype instances. Note that direct children nodes are disallowed, instead let fieldValue with type SFNode/MFNode contain them. Current practice is that, if desired, prototype authors must explicitly add the metadata SFNode field in the ProtoInterface. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DPrototypeInstance' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#X3DPrototypeInstance' class _X3DRigidJointNode(_X3DNode): """ The X3DRigidJointNode abstract node type is the base type for all joint types. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DRigidJointNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rigidBodyPhysics.html#X3DRigidJointNode' class _X3DScriptNode(_X3DChildNode): """ Base type for scripting nodes (but not shader nodes). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DScriptNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/scripting.html#X3DScriptNode' class _X3DSequencerNode(_X3DChildNode): """ Base type from which all Sequencers are derived. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSequencerNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/eventUtilities.html#X3DSequencerNode' class _X3DShaderNode(_X3DAppearanceChildNode): """ Base type for all nodes that specify a programmable shader. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DShaderNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shaders.html#X3DShaderNode' class _X3DShapeNode(_X3DChildNode): """ Base type for all Shape nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DShapeNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#X3DShapeNode' class _X3DSoundDestinationNode(_X3DSoundNode): """ Base type for all sound destination nodes, which represent the final destination of an audio signal and are what the user can ultimately hear. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSoundDestinationNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#X3DSoundDestinationNode' class _X3DSoundProcessingNode(_X3DTimeDependentNode): """ Base type for all sound processing nodes, which are used to enhance audio with filtering, delaying, changing gain, etc. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSoundProcessingNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#X3DSoundProcessingNode' class _X3DSoundSourceNode(_X3DTimeDependentNode): """ Nodes implementing X3DSoundSourceNode provide signal inputs to the audio graph. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSoundSourceNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#X3DSoundSourceNode' class _X3DTexture3DNode(_X3DTextureNode): """ Base type for all nodes that specify 3D sources for texture images. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTexture3DNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texture3D.html#X3DTexture3DNode' class _X3DTextureProjectorNode(_X3DLightNode): """ Base type for all node types that specify texture projector nodes, which provide a form of lighting. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTextureProjectorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/textureProjector.html#X3DTextureProjectorNode' class _X3DTouchSensorNode(_X3DPointingDeviceSensorNode): """ Base type for all touch-style pointing device sensors. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTouchSensorNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/pointingDeviceSensor.html#X3DTouchSensorNode' class _X3DTriggerNode(_X3DChildNode): """ Base type from which all trigger nodes are derived. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTriggerNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/eventUtilities.html#X3DTriggerNode' class _X3DVertexAttributeNode(_X3DGeometricPropertyNode): """ Base type for all nodes that specify per-vertex attribute information to the shader. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DVertexAttributeNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shaders.html#X3DVertexAttributeNode' class _X3DViewpointNode(_X3DBindableNode): """ Node type X3DViewpointNode defines a specific location in the local coordinate system from which the user may view the scene, and also defines a viewpoint binding stack. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DViewpointNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/navigation.html#X3DViewpointNode' class _X3DViewportNode(_X3DGroupingNode): """ The X3DViewportNode abstract node type is the base node type for viewport nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DViewportNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/layering.html#X3DViewportNode' class _X3DVolumeDataNode(_X3DChildNode): """ The X3DVolumeDataNode abstract node type is the base type for all node types that describe volumetric data to be rendered. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DVolumeDataNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#X3DVolumeDataNode' class _X3DTextureTransformNode(_X3DAppearanceChildNode): """ Base type for all nodes which specify a transformation of texture coordinates. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTextureTransformNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DTextureTransformNode' class _X3DSingleTextureTransformNode(_X3DTextureTransformNode): """ Base type for all texture transform nodes which specify texture coordinate transformation for a single texture. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSingleTextureTransformNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DSingleTextureTransformNode' class _X3DTextureCoordinateNode(_X3DGeometricPropertyNode): """ Base type for all nodes which specify texture coordinates. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTextureCoordinateNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DTextureCoordinateNode' class _X3DSingleTextureCoordinateNode(_X3DTextureCoordinateNode): """ Base type for all texture coordinate nodes which specify texture coordinates for a single texture. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSingleTextureCoordinateNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DSingleTextureCoordinateNode' class _X3DSingleTextureNode(_X3DTextureNode): """ Base type for all texture node types that define a single texture. A single texture can be used to influence a parameter of various material nodes in the Shape component, and it can be a child of MultiTexture. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DSingleTextureNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DSingleTextureNode' class _X3DTexture2DNode(_X3DSingleTextureNode): """ Base type for all nodes which specify 2D sources for texture images. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DTexture2DNode' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#X3DTexture2DNode' ############################################### # Abstract Object Types # Note that these package-internal class names are preceded by an underscore _ character since X3D authors are not expected to use them class _X3DBoundedObject(_X3DNode): """ X3DBoundedObject indicates that bounding box values can be provided (or computed) to encompass this node and any children. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DBoundedObject' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/grouping.html#X3DBoundedObject' class _X3DFogObject(_X3DNode): """ Abstract type describing a node that influences the lighting equation through the use of fog semantics. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DFogObject' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalEffects.html#X3DFogOjbect' class _X3DMetadataObject(_X3DNode): """ Each node inheriting the X3DMetadataObject interface contains a single array of strictly typed values: MFBool, MFInt32, MFFloat, MFDouble, MFString, or MFNode, the latter having children that are all Metadata nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DMetadataObject' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#X3DMetadataObject' class _X3DPickableObject(_X3DNode): """ The X3DPickableObject abstract interface marks a node as being capable of having customized picking performed on its contents or children. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DPickableObject' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/picking.html#X3DPickableObject' class _X3DProgrammableShaderObject(_X3DNode): """ Base type for all nodes that specify arbitrary fields for interfacing with per-object attribute values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DProgrammableShaderObject' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shaders.html#X3DProgrammableShaderObject' class _X3DUrlObject(_X3DNode): """ X3DUrlObject indicates that a node has content loaded from a Uniform Resource Locator (URL) and can be tracked via a LoadSensor. Such child nodes have containerField='children' to indicate their relationship to the parent LoadSensor node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Abstract Type class. """ return '_X3DUrlObject' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/networking.html#X3DUrlObject' ############################################### # Statements class _X3DStatement: """ All X3D statements implement _X3DStatement abstract type. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Statement class. """ return '_X3DStatement' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [] @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/core.html#AbstractX3DStructure' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html' def __init__(self, class_="", id_="", style_=""): self.class_ = class_ self.id_ = id_ self.style_ = style_ # if _DEBUG: print('...DEBUG... in X3DNode __init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + ')', flush=True) @property # getter - - - - - - - - - - def class_(self): """ Space-separated list of classes, reserved for use by CSS cascading stylesheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__class_ @class_.setter def class_(self, class_): if class_ is None: class_ = SFString.DEFAULT_VALUE() assertValidSFString(class_) self.__class_ = class_ @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ if style_ is None: style_ = SFString.DEFAULT_VALUE() assertValidSFString(style_) self.__style_ = style_ def __repl__(self): result = self.NAME() + '(' # if _DEBUG: print(self.NAME() + ' self.FIELD_DECLARATIONS(): ' + str(self.FIELD_DECLARATIONS)) if self.FIELD_DECLARATIONS(): for each in self.FIELD_DECLARATIONS(): # if _DEBUG: print(self.NAME() + ' for each in self.FIELD_DECLARATIONS(): each=' + str(each)) name = each[0] default = each[1] type_ = each[2] accessType = each[3] value = getattr(self, name) # if _DEBUG: print('gettattr(self, ' + str(name) + ') value="' + str(value)[:100] + '" for FIELD_DECLARATIONS() ' + str(each) + ')', flush=True) if value != default: if isinstance(value, list): # avoid X3DTypeError if value is not iterable result += str(name) + '=[' for each in value: result += str(each) + ', ' # if _DEBUG: print('...DEBUG... _X3DStatement debug: str(each)=' + str(each), flush=True) result = result.rstrip(', ') result += '],' elif isinstance(value, str) and "'" in value: result += str(name) + '=' + '"' + str(value)[:100] + '"' + ',' elif isinstance(value, str) and value != default: result += str(name) + '=' + "'" + str(value)[:100] + "'" + ',' elif value != default: result += str(name) + '=' + str(value)[:100] + ',' # elif _DEBUG: # result += str(name) + '=' + "'" + str(value)[:100] + "'" + ',' return result.strip().rstrip(',').rstrip(', ') + ')' def __str__(self): return self.__repl__().strip() # _X3DStatement def isX3DStatement(value): """ Whether or not value is an _X3DStatement object. """ return isinstance(value, _X3DStatement) class Comment(_X3DStatement): """ X3D statement containing zero or more comment strings. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Statement class. """ return 'Comment' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#Organization' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html' # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def DEFAULT_VALUE(cls): """ Default value for comments is empty string """ return '' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [] @classmethod def REGEX_PYTHON(cls): """' Regular expression for validating values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'(\s|\S)*' # (includes lower-case true, false) @classmethod def REGEX_XML(cls): """' Regular expression for validating values, for more information see https://www.web3d.org/specifications/X3dRegularExpressions.html """ return r'(\s|\S)*' # (includes lower-case true, false) def __init__(self, value=''): self.value = value @property # getter - - - - - - - - - - def value(self): """ Provide list of comment strings. """ return self.__value @value.setter def value(self, value): """ The value setter only allows correctly typed values. """ if value is None: value = SFString.DEFAULT_VALUE() self.__value = str(value) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ """ result = '' indent = ' ' * indentLevel if self.value: result = indent + '' + '\n' return result # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ VRML comments begin with # effective to end of line """ result = '' indent = ' ' * indentLevel if self.value: result = '\n' + indent + '# ' + self.value + '\n' + indent return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ JSON does not support comments, so X3D JSON created a specific object for them """ result = '' indent = ' ' * indentLevel if self.value: result = indent + '{ "#comment" : "' + self.value + '" }' + '\n' return result def isComment(value): """ Whether or not value is a Comment object. """ return isinstance(value, Comment) class component(_X3DStatement): """ Functional summary: each added component statement indicates needed scene functionality support above the given X3D profile. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'component' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/concepts.html#Components' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#component' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('level', 1, FieldType.SFInt32, AccessType.inputOutput, 'component'), ('name', '', FieldType.SFString, AccessType.inputOutput, 'component'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, level=1, name='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement component __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.level = level self.name = name self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def level(self): """Necessary level of support for this scene, as defined in corresponding Support table for a given node's component.""" return self.__level @level.setter def level(self, level): if level is None: level = 1 # default assertValidSFInt32(level) assertGreaterThanEquals('level', level, 1) assertLessThanEquals('level', level, 5) self.__level = level @property # getter - - - - - - - - - - def name(self): """Provides name of this component, as defined in corresponding X3D Specification component Introduction.""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) assertValidComponentName('name', name) self.__name = name @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function component.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function component.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"component":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.level != 1: attributeResult += " " + '"@level":"' + SFInt32(self.level).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' result += 'COMPONENT ' + self.name + ':' + str(self.level) + '\n' # print('VRML serialization complete.', flush=True) return result class connect(_X3DStatement): """ Functional summary: connect statements define event-routing connections between node fields defined inside a ProtoBody declaration back to corresponding ProtoInterface fields. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'connect' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#IS_ConnectStatementSyntax' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#connect' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('nodeField', '', FieldType.SFString, AccessType.inputOutput, 'connect'), ('protoField', '', FieldType.SFString, AccessType.inputOutput, 'connect'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, nodeField='', protoField='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement connect __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.nodeField = nodeField self.protoField = protoField self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def nodeField(self): """Name of field within this node which IS CONNECTed to the ancestor ProtoDeclare field definition.""" return self.__nodeField @nodeField.setter def nodeField(self, nodeField): if nodeField is None: nodeField = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(nodeField) self.__nodeField = nodeField @property # getter - - - - - - - - - - def protoField(self): """Name of parent ProtoDeclare field definition connecting to field in this node.""" return self.__protoField @protoField.setter def protoField(self, protoField): if protoField is None: protoField = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(protoField) self.__protoField = protoField @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function connect.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function connect.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"connect":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.nodeField: attributeResult += " " + '"@nodeField":"' + SFString(self.nodeField).JSON() + '"' + ',\n' if self.protoField: attributeResult += " " + '"@protoField":"' + SFString(self.protoField).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function connect.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' result += 'connect' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.nodeField: result += '\n' + indent + ' ' + "nodeField " + '"' + self.nodeField + '"' + "" if self.protoField: result += '\n' + indent + ' ' + "protoField " + '"' + self.protoField + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class EXPORT(_X3DStatement): """ Functional summary: EXPORT exposes a local node for ROUTE passing of event values when the current Scene is included via Inline by a parent external world. These connections allow event values to be exchanged via ROUTE statements between a parent model and a child Inline model. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'EXPORT' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/concepts.html#EXPORTSemantics' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#EXPORT' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('AS', '', FieldType.SFString, AccessType.inputOutput, 'EXPORT'), ('localDEF', '', FieldType.SFString, AccessType.inputOutput, 'EXPORT'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, AS='', localDEF='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement EXPORT __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.AS = AS self.localDEF = localDEF self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def AS(self): """rename localDEF node AS a different name when exporting.""" return self.__AS @AS.setter def AS(self, AS): if AS is None: AS = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(AS) self.__AS = AS @property # getter - - - - - - - - - - def localDEF(self): """localDEF is the DEF name of the local node to be EXPORTed.""" return self.__localDEF @localDEF.setter def localDEF(self, localDEF): if localDEF is None: localDEF = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(localDEF) self.__localDEF = localDEF @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function EXPORT.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function EXPORT.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"EXPORT":\n' result += indent + '{\n' attributeResult = '' if self.AS: attributeResult += " " + '"@AS":"' + SFString(self.AS).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.localDEF: attributeResult += " " + '"@localDEF":"' + SFString(self.localDEF).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function EXPORT.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' result += 'EXPORT' + ' {' if self.AS: result += '\n' + indent + ' ' + "AS " + '"' + self.AS + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.localDEF: result += '\n' + indent + ' ' + "localDEF " + '"' + self.localDEF + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ExternProtoDeclare(_X3DStatement): """ ExternProtoDeclare refers to a ProtoDeclare node declaration provided in another file. ExternProtoDeclare interfaces are defined by field statements (and without IS/connect statements). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ExternProtoDeclare' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/concepts.html#Externalprototypesemantics' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ExternProtoDeclare' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('appinfo', '', FieldType.SFString, AccessType.inputOutput, 'ExternProtoDeclare'), ('documentation', '', FieldType.SFString, AccessType.inputOutput, 'ExternProtoDeclare'), ('name', '', FieldType.SFString, AccessType.inputOutput, 'ExternProtoDeclare'), ('url', [], FieldType.MFString, AccessType.inputOutput, 'ExternProtoDeclare'), ('field', [], FieldType.MFNode, AccessType.inputOutput, 'ExternProtoDeclare'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, appinfo='', documentation='', name='', url=None, field=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement ExternProtoDeclare __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.appinfo = appinfo self.documentation = documentation self.name = name self.url = url self.field = field self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def appinfo(self): """Application information to provide simple description usable as a tooltip, similar to XML Schema appinfo tag.""" return self.__appinfo @appinfo.setter def appinfo(self, appinfo): if appinfo is None: appinfo = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(appinfo) self.__appinfo = appinfo @property # getter - - - - - - - - - - def documentation(self): """Documentation url for further information, similar to XML Schema documentation tag.""" return self.__documentation @documentation.setter def documentation(self, documentation): if documentation is None: documentation = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(documentation) self.__documentation = documentation @property # getter - - - - - - - - - - def name(self): """name of the ExternProtoDeclare (External Prototype Declaration) being referenced.""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) self.__name = name @property # getter - - - - - - - - - - def url(self): """Location and filename of ProtoDeclare source declaration of interest.""" return self.__url @url.setter def url(self, url): if url is None: url = MFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFString.DEFAULT_VALUE()=' + str(MFString.DEFAULT_VALUE())) assertValidMFString(url) self.__url = url @property # getter - - - - - - - - - - def field(self): """Include a field statement for each field declaration in the corresponding original ProtoDeclare.""" return self.__field @field.setter def field(self, field): if field is None: field = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) # TODO type-aware checks for field if field: # walk each child in list, if any (avoid empty list recursion) for each in field: assertValidFieldInitializationValue(each.name, type(each.value), each.value, parent='ExternProtoDeclare/field') self.__field = field @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.field) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ExternProtoDeclare.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ExternProtoDeclare.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ExternProtoDeclare":\n' result += indent + '{\n' attributeResult = '' if self.appinfo: attributeResult += " " + '"@appinfo":"' + SFString(self.appinfo).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.documentation: attributeResult += " " + '"@documentation":"' + SFString(self.documentation).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.url != []: attributeResult += " " + '"@url":"' + MFString(self.url).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.field: # walk each child in list, if any (avoid empty list recursion) ### print('* ExternProtoDeclare found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(field)=' + str(len(self.field)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.field: # walk each child in list, if any (avoid empty list recursion) for each in self.field: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel if indentLevel == 0: result += '\n' result += 'ExternProtoDeclare' + ' {' if self.appinfo: result += '\n' + indent + ' ' + "appinfo " + '"' + self.appinfo + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.documentation: result += '\n' + indent + ' ' + "documentation " + '"' + self.documentation + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.name: result += '\n' + indent + ' ' + "name " + '"' + self.name + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.url != []: result += '\n' + indent + ' ' + "url " + MFString(self.url).VRML() + "" if self.field: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.field: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class field(_X3DStatement): """ Functional summary: a field statement defines an interface attribute or node. Each field statement can contain either attribute-value or node content. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'field' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#NodeAndFieldStatementSyntax' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#field' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('accessType', '', FieldType.SFString, AccessType.inputOutput, 'field'), ('appinfo', '', FieldType.SFString, AccessType.inputOutput, 'field'), ('documentation', '', FieldType.SFString, AccessType.inputOutput, 'field'), ('name', '', FieldType.SFString, AccessType.inputOutput, 'field'), ('type', '', FieldType.SFString, AccessType.inputOutput, 'field'), ('value', '', FieldType.SFString, AccessType.inputOutput, 'field'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'field'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, accessType='', appinfo='', documentation='', name='', type='', value='', children=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement field __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.accessType = accessType self.appinfo = appinfo self.documentation = documentation self.name = name self.type = type self.value = value self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def accessType(self): """Event-model semantics for field set/get capabilities.""" return self.__accessType @accessType.setter def accessType(self, accessType): if accessType is None: accessType = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(accessType) assertValidAccessType('accessType', accessType) self.__accessType = accessType @property # getter - - - - - - - - - - def appinfo(self): """Application information to provide simple description usable as a tooltip, similar to XML Schema appinfo tag.""" return self.__appinfo @appinfo.setter def appinfo(self, appinfo): if appinfo is None: appinfo = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(appinfo) self.__appinfo = appinfo @property # getter - - - - - - - - - - def documentation(self): """Documentation url for further information, similar to XML Schema documentation tag.""" return self.__documentation @documentation.setter def documentation(self, documentation): if documentation is None: documentation = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(documentation) self.__documentation = documentation @property # getter - - - - - - - - - - def name(self): """Name of this field declaration.""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) self.__name = name @property # getter - - - - - - - - - - def type(self): """Base type of this field variable.""" return self.__type @type.setter def type(self, type): if type is None: type = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(type) assertValidFieldType('type', type) self.__type = type @property # getter - - - - - - - - - - def value(self): """Provide default initialization value for this field variable (which may be re-initialized later by instantiation value of a named ProtoInstance fieldValue).""" return self.__value @value.setter def value(self, value): if value is None: value = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidFieldInitializationValue(self.name, self.type, value, parent='field/@value') self.__value = value @property # getter - - - - - - - - - - def children(self): """[X3DNode] If this field definition has type SFNode or MFNode, then initialization node (or nodes) of any appropriate type may be provided as children of the field definition.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function field.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function field.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"field":\n' result += indent + '{\n' attributeResult = '' if self.accessType: attributeResult += " " + '"@accessType":"' + SFString(self.accessType).JSON() + '"' + ',\n' if self.appinfo: attributeResult += " " + '"@appinfo":"' + SFString(self.appinfo).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.documentation: attributeResult += " " + '"@documentation":"' + SFString(self.documentation).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.type: attributeResult += " " + '"@type":"' + SFString(self.type).JSON() + '"' + ',\n' if self.value: attributeResult += " " + '"@value":"' + str(self.value) + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* field found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function field.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' result += 'field' + ' {' if self.accessType: result += '\n' + indent + ' ' + "accessType " + '"' + self.accessType + '"' + "" if self.appinfo: result += '\n' + indent + ' ' + "appinfo " + '"' + self.appinfo + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.documentation: result += '\n' + indent + ' ' + "documentation " + '"' + self.documentation + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.name: result += '\n' + indent + ' ' + "name " + '"' + self.name + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.type: result += '\n' + indent + ' ' + "type " + '"' + self.type + '"' + "" if self.value: result += '\n' + indent + ' ' + "value " + str(self.value) + "" if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class fieldValue(_X3DStatement): """ Functional summary: a fieldValue statement re-initializes the default value of a field in a ProtoInstance. Each fieldValue statement can contain either attribute-value or node content. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'fieldValue' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#ProtoInstanceAndFieldValueStatement' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#fieldValue' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('name', '', FieldType.SFString, AccessType.inputOutput, 'fieldValue'), ('value', '', FieldType.SFString, AccessType.inputOutput, 'fieldValue'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'fieldValue'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, name='', value='', children=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement fieldValue __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.name = name self.value = value self.children = children self.id_ = id_ self.style_ = style_ self.type='SFString' # convenience property matching corresponding field declaration @property # getter - - - - - - - - - - # convenience property matching corresponding field declaration def type(self): """ Computed type of this fieldValue corresponding to corresponding field declaration. """ if self.__type is None: self.__type = 'SFString' #print('*** need to find fieldValue type, using type=' + str(self.__type)) return self.__type @type.setter def type(self, type): if type is None: type = SFString.NAME() # if _DEBUG: print('...DEBUG... set type to SFString.NAME()=' + str(SFString.NAME())) assertValidSFString(type) ### assertValidFieldType('type', type) # something strange is happening here self.__type = type @property # getter - - - - - - - - - - def name(self): """Name of the ProtoInstance field being re-initialized (corresponding to field name already defined in ProtoDeclare or ExternProtoDeclare).""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) self.__name = name @property # getter - - - - - - - - - - def value(self): """Initial value for this field, which overrides default initialization value defined in original ProtoDeclare field.""" return self.__value @value.setter def value(self, value): if value is None: value = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidFieldInitializationValue(self.name, type(value), value, parent='fieldValue') if isinstance(value,list) and isinstance(value[0],str): # print('*** found MFString when setting fieldValue name=' + self.name) # hack, better would be matching proto declaration self.type = 'MFString' self.__value = value @property # getter - - - - - - - - - - def children(self): """[X3DNode] If this field definition has type SFNode or MFNode, then initialization node (or nodes) of any appropriate type may be provided as children of the field definition.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function fieldValue.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function fieldValue.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"fieldValue":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.value: attributeResult += " " + '"@value":"' + str(self.value) + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* fieldValue found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function fieldValue.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' result += 'fieldValue' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.name: result += '\n' + indent + ' ' + "name " + '"' + self.name + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.value: result += '\n' + indent + ' ' + "value " + str(self.value) + "" if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class head(_X3DStatement): """ Functional summary: each X3D scene includes a head statement that can contain component, unit and meta statements. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'head' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#Header' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#head' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [('children', None, FieldType.MFNode, AccessType.inputOutput, 'head')] def __init__(self, class_="", id_="", style_="", children=None): self.class_ = class_ self.id_ = id_ self.style_ = style_ self.children = children @property # getter - - - - - - - - - - def class_(self): """ Space-separated list of classes, reserved for use by CSS cascading stylesheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__class_ @class_.setter def class_(self, class_): if class_ is None: class_ = SFString.DEFAULT_VALUE() assertValidSFString(class_) self.__class_ = class_ @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() assertValidSFString(id_) self.__id = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() assertValidSFString(style_) self.__style_ = style_ @property # getter - - - - - - - - - - def children(self): """ The head statement has children consisting of component, unit and meta statements. """ return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() assertValidMFNode(children) self.__children = children # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return bool(self.children) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function head.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function head.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"head":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.__children: # walk each child in list, if any ## print('* head found self.children, now invoking JSON(' + str(indentLevel+1) + ')', flush=True) # order is significant for component, unit, meta statements if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: # TODO check order of output: component unit meta result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' if self.children: # walk each child in list, if any (avoid empty list recursion) ## print('* head found self.children, now invoking VRML(' + str(indentLevel+1) + ', ' + VRML97 + ')', flush=True) # order is significant for component, unit, meta statements for each in self.children: # TODO check order of output: component unit meta result += each.VRML(indentLevel=indentLevel+1, VRML97=VRML97) # print('VRML serialization complete.', flush=True) return result class IMPORT(_X3DStatement): """ Functional summary: IMPORT provides ROUTE access to a node that has a corresponding EXPORT statement within an Inline scene. These connections allow event values to be exchanged via ROUTE statements between a parent model and a child Inline model. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'IMPORT' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/concepts.html#ImportExportsemantics' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#IMPORT' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('AS', '', FieldType.SFString, AccessType.inputOutput, 'IMPORT'), ('importedDEF', '', FieldType.SFString, AccessType.inputOutput, 'IMPORT'), ('inlineDEF', '', FieldType.SFString, AccessType.inputOutput, 'IMPORT'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, AS='', importedDEF='', inlineDEF='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement IMPORT __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.AS = AS self.importedDEF = importedDEF self.inlineDEF = inlineDEF self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def AS(self): """map importedDEF name AS a new name in current scene.""" return self.__AS @AS.setter def AS(self, AS): if AS is None: AS = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(AS) self.__AS = AS @property # getter - - - - - - - - - - def importedDEF(self): """importedDEF is DEF name of the node of interest that is contained in the remote inlineDEF scene.""" return self.__importedDEF @importedDEF.setter def importedDEF(self, importedDEF): if importedDEF is None: importedDEF = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(importedDEF) self.__importedDEF = importedDEF @property # getter - - - - - - - - - - def inlineDEF(self): """inlineDEF is the DEF name of Inline node in the same scene as this IMPORT statement.""" return self.__inlineDEF @inlineDEF.setter def inlineDEF(self, inlineDEF): if inlineDEF is None: inlineDEF = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(inlineDEF) self.__inlineDEF = inlineDEF @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function IMPORT.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function IMPORT.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"IMPORT":\n' result += indent + '{\n' attributeResult = '' if self.AS: attributeResult += " " + '"@AS":"' + SFString(self.AS).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.importedDEF: attributeResult += " " + '"@importedDEF":"' + SFString(self.importedDEF).JSON() + '"' + ',\n' if self.inlineDEF: attributeResult += " " + '"@inlineDEF":"' + SFString(self.inlineDEF).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function IMPORT.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' result += 'IMPORT' + ' {' if self.AS: result += '\n' + indent + ' ' + "AS " + '"' + self.AS + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.importedDEF: result += '\n' + indent + ' ' + "importedDEF " + '"' + self.importedDEF + '"' + "" if self.inlineDEF: result += '\n' + indent + ' ' + "inlineDEF " + '"' + self.inlineDEF + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class IS(_X3DStatement): """ Functional summary: the IS statement connects node fields defined inside a ProtoBody declaration back to corresponding ProtoInterface fields. IS/connect statements can be added if the parent node is within a ProtoBody and connect statements define correspondences between prototype fields and built-in node fields. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'IS' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/concepts.html#PROTOdefinitionsemantics' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#IS' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('connect', [], FieldType.MFNode, AccessType.inputOutput, 'IS'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, connect=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement IS __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.connect = connect self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def connect(self): """When inside a ProtoBody declaration and an IS statement, add a connect statement to define event-routing connections between a parent node's field to a corresponding ProtoInterface field.""" return self.__connect @connect.setter def connect(self, connect): if connect is None: connect = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(connect) self.__connect = connect @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.connect) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function IS.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function IS.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"IS":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.connect: # walk each child in list, if any (avoid empty list recursion) ### print('* IS found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(connect)=' + str(len(self.connect)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.connect: # walk each child in list, if any (avoid empty list recursion) for each in self.connect: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function IS.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' result += 'IS' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.connect: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.connect: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class meta(_X3DStatement): """ Functional summary: the meta statement provides metadata information about a scene, where name and content attributes provide attribute=value metadata pairs. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'meta' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#Header' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#meta' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('content', '', FieldType.SFString, AccessType.inputOutput, 'meta'), ('dir', '', FieldType.SFString, AccessType.inputOutput, 'meta'), ('httpequiv', '', FieldType.SFString, AccessType.inputOutput, 'meta'), ('lang', '', FieldType.SFString, AccessType.inputOutput, 'meta'), ('name', '', FieldType.SFString, AccessType.inputOutput, 'meta'), ('scheme', '', FieldType.SFString, AccessType.inputOutput, 'meta'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, content='', dir='', httpequiv='', lang='', name='', scheme='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement meta __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.content = content self.dir = dir self.httpequiv = httpequiv self.lang = lang self.name = name self.scheme = scheme self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def content(self): """The content attribute provides metadata information relevant to the name attribute provided.""" return self.__content @content.setter def content(self, content): if content is None: content = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(content) self.__content = content @property # getter - - - - - - - - - - def dir(self): """Direction for weak/neutral text (ltr=left-to-right, rtl=right-to-left).""" return self.__dir @dir.setter def dir(self, dir): if dir is None: dir = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(dir) assertValidMetaDirection('dir', dir) self.__dir = dir @property # getter - - - - - - - - - - def httpequiv(self): """The http-equiv attribute provides an HTTP header for the value of the content attribute.""" return self.__httpequiv @httpequiv.setter def httpequiv(self, httpequiv): if httpequiv is None: httpequiv = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(httpequiv) self.__httpequiv = httpequiv @property # getter - - - - - - - - - - def lang(self): """Language code, as per [IETF BCP47/RFC5646].""" return self.__lang @lang.setter def lang(self, lang): if lang is None: lang = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(lang) self.__lang = lang @property # getter - - - - - - - - - - def name(self): """Keyword name of the meta attribute, following the same naming conventions as HTML's meta tag.""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) self.__name = name @property # getter - - - - - - - - - - def scheme(self): """The scheme attribute allows authors to provide user agents more context for the correct interpretation of meta information.""" return self.__scheme @scheme.setter def scheme(self, scheme): if scheme is None: scheme = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(scheme) self.__scheme = scheme @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function meta.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function meta.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"meta":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.content: attributeResult += " " + '"@content":"' + SFString(self.content).JSON() + '"' + ',\n' if self.dir: attributeResult += " " + '"@dir":"' + SFString(self.dir).JSON() + '"' + ',\n' if self.httpequiv: attributeResult += " " + '"@httpequiv":"' + SFString(self.httpequiv).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.lang: attributeResult += " " + '"@lang":"' + SFString(self.lang).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.scheme: attributeResult += " " + '"@scheme":"' + SFString(self.scheme).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' result += 'META "' + self.name + '" "' + self.content + '"' + '\n' # print('VRML serialization complete.', flush=True) return result class ProtoBody(_X3DStatement): """ ProtoBody contains the definition nodes for new Prototype nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ProtoBody' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#PrototypeAndFieldDeclarationSyntax' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ProtoBody' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('children', [], FieldType.MFNode, AccessType.inputOutput, 'ProtoBody'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, children=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement ProtoBody __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def children(self): """[X3DNode] ProtoBody can contain nodes, statements and comments.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ProtoBody.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ProtoBody.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ProtoBody":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* ProtoBody found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel if indentLevel == 0: result += '\n' result += 'ProtoBody' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ProtoDeclare(_X3DStatement): """ ProtoDeclare defines new Prototype nodes. Nested ProtoDeclares and ProtoInstances are allowed by the specification. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ProtoDeclare' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#PrototypeAndFieldDeclarationSyntax' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ProtoDeclare' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('appinfo', '', FieldType.SFString, AccessType.inputOutput, 'ProtoDeclare'), ('documentation', '', FieldType.SFString, AccessType.inputOutput, 'ProtoDeclare'), ('name', '', FieldType.SFString, AccessType.inputOutput, 'ProtoDeclare'), ('ProtoBody', None, FieldType.SFNode, AccessType.inputOutput, 'ProtoDeclare'), ('ProtoInterface', None, FieldType.SFNode, AccessType.inputOutput, 'ProtoDeclare'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, appinfo='', documentation='', name='', ProtoBody=None, ProtoInterface=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement ProtoDeclare __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.appinfo = appinfo self.documentation = documentation self.name = name self.ProtoBody = ProtoBody self.ProtoInterface = ProtoInterface self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def appinfo(self): """Application information to provide simple description usable as a tooltip, similar to XML Schema appinfo tag.""" return self.__appinfo @appinfo.setter def appinfo(self, appinfo): if appinfo is None: appinfo = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(appinfo) self.__appinfo = appinfo @property # getter - - - - - - - - - - def documentation(self): """Documentation url for further information, similar to XML Schema documentation tag.""" return self.__documentation @documentation.setter def documentation(self, documentation): if documentation is None: documentation = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(documentation) self.__documentation = documentation @property # getter - - - - - - - - - - def name(self): """name of this prototype being declared.""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) self.__name = name @property # getter - - - - - - - - - - def ProtoBody(self): """Include one ProtoBody statement after the ProtoInterface statement.""" return self.__ProtoBody @ProtoBody.setter def ProtoBody(self, ProtoBody): if ProtoBody is None: ProtoBody = None # default assertValidSFNode(ProtoBody) self.__ProtoBody = ProtoBody @property # getter - - - - - - - - - - def ProtoInterface(self): """Include an optional ProtoInterface statement if this ProtoDeclare has field declarations.""" return self.__ProtoInterface @ProtoInterface.setter def ProtoInterface(self, ProtoInterface): if ProtoInterface is None: ProtoInterface = None # default assertValidSFNode(ProtoInterface) self.__ProtoInterface = ProtoInterface @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.ProtoBody or self.ProtoInterface # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ProtoDeclare.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ProtoDeclare.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ProtoDeclare":\n' result += indent + '{\n' attributeResult = '' if self.appinfo: attributeResult += " " + '"@appinfo":"' + SFString(self.appinfo).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.documentation: attributeResult += " " + '"@documentation":"' + SFString(self.documentation).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.ProtoInterface: # output this SFNode result += self.ProtoInterface.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.ProtoBody: # output this SFNode result += self.ProtoBody.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel if indentLevel == 0: result += '\n' result += 'ProtoDeclare' + ' {' if self.appinfo: result += '\n' + indent + ' ' + "appinfo " + '"' + self.appinfo + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.documentation: result += '\n' + indent + ' ' + "documentation " + '"' + self.documentation + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.name: result += '\n' + indent + ' ' + "name " + '"' + self.name + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.ProtoInterface: # output this SFNode result += '\n' + ' ' + indent + 'ProtoInterface ' + self.ProtoInterface.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.ProtoBody: # output this SFNode result += '\n' + ' ' + indent + 'ProtoBody ' + self.ProtoBody.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ProtoInterface(_X3DStatement): """ ProtoInterface defines fields for new Prototype nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ProtoInterface' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#PrototypeAndFieldDeclarationSyntax' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ProtoInterface' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('field', [], FieldType.MFNode, AccessType.inputOutput, 'ProtoInterface'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, field=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement ProtoInterface __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.field = field self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def field(self): """Include a field statement for each field declaration in this ProtoDeclare's ProtoInterface.""" return self.__field @field.setter def field(self, field): if field is None: field = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) # TODO type-aware checks for field if field: # walk each child in list, if any (avoid empty list recursion) for each in field: assertValidFieldInitializationValue(each.name, each.type, each.value, parent='ProtoInterface') self.__field = field @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.field) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ProtoInterface.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ProtoInterface.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ProtoInterface":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.field: # walk each child in list, if any (avoid empty list recursion) ### print('* ProtoInterface found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(field)=' + str(len(self.field)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.field: # walk each child in list, if any (avoid empty list recursion) for each in self.field: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel if indentLevel == 0: result += '\n' result += 'ProtoInterface' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.field: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.field: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ROUTE(_X3DStatement): """ ROUTE connects output fields of event-producing nodes to input fields of event-consuming nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ROUTE' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/concepts.html#ModifyingObjectsRoutes' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ROUTE' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('fromField', '', FieldType.SFString, AccessType.inputOutput, 'ROUTE'), ('fromNode', '', FieldType.SFString, AccessType.inputOutput, 'ROUTE'), ('toField', '', FieldType.SFString, AccessType.inputOutput, 'ROUTE'), ('toNode', '', FieldType.SFString, AccessType.inputOutput, 'ROUTE'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, fromField='', fromNode='', toField='', toNode='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement ROUTE __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.fromField = fromField self.fromNode = fromNode self.toField = toField self.toNode = toNode self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def fromField(self): """fromField is the field name in the source node which is originating an event.""" return self.__fromField @fromField.setter def fromField(self, fromField): if fromField is None: fromField = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(fromField) self.__fromField = fromField @property # getter - - - - - - - - - - def fromNode(self): """fromNode is the DEF name of the node originating an event.""" return self.__fromNode @fromNode.setter def fromNode(self, fromNode): if fromNode is None: fromNode = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(fromNode) self.__fromNode = fromNode @property # getter - - - - - - - - - - def toField(self): """toField is the field name in the destination node which is receiving an event.""" return self.__toField @toField.setter def toField(self, toField): if toField is None: toField = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(toField) self.__toField = toField @property # getter - - - - - - - - - - def toNode(self): """toNode is the DEF name of the destination node receiving an event.""" return self.__toNode @toNode.setter def toNode(self, toNode): if toNode is None: toNode = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(toNode) self.__toNode = toNode @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ROUTE.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ROUTE.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ROUTE":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.fromField: attributeResult += " " + '"@fromField":"' + SFString(self.fromField).JSON() + '"' + ',\n' if self.fromNode: attributeResult += " " + '"@fromNode":"' + SFString(self.fromNode).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.toField: attributeResult += " " + '"@toField":"' + SFString(self.toField).JSON() + '"' + ',\n' if self.toNode: attributeResult += " " + '"@toNode":"' + SFString(self.toNode).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel result += '\n' + indent + 'ROUTE ' + self.fromNode + '.' + self.fromField + ' TO ' + self.toNode + '.' + self.toField + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Scene(_X3DStatement): """ Scene is the implicit root node of the X3D scene graph. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Scene' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#Header' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Scene' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('children', [], FieldType.MFNode, AccessType.inputOutput, 'Scene'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, children=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement Scene __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def children(self): """[X3DNode] Scene can contain nodes, statements and comments.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Scene.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Scene.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Scene":\n' result += indent + '{\n' attributeResult = '' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* Scene found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.VRML(indentLevel=indentLevel+1, VRML97=VRML97) # print('VRML serialization complete.', flush=True) return result class unit(_X3DStatement): """ Functional summary: unit statement defines data-conversion factors for typed values defined in a scene. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'unit' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#UNITStatement' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#unit' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('category', '', FieldType.SFString, AccessType.initializeOnly, 'unit'), ('conversionFactor', 1.0, FieldType.SFDouble, AccessType.inputOutput, 'unit'), ('name', '', FieldType.SFString, AccessType.inputOutput, 'unit'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DStatement')] def __init__(self, category='', conversionFactor=1.0, name='', class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in Statement unit __init__ calling super.__init__(' + str(class_) + ',' + str(id_) + ',' + str(style_) + + ')', flush=True) super().__init__(class_, id_, style_) # fields for _X3DStatement only self.category = category self.conversionFactor = conversionFactor self.name = name self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def category(self): """Base-unit category as defined in X3D Specification.""" return self.__category @category.setter def category(self, category): if category is None: category = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(category) assertValidUnitCategory('category', category) self.__category = category @property # getter - - - - - - - - - - def conversionFactor(self): """[0,+infinity) Positive double-precision factor that converts new base unit to default base unit.""" return self.__conversionFactor @conversionFactor.setter def conversionFactor(self, conversionFactor): if conversionFactor is None: conversionFactor = 1.0 # default assertValidSFDouble(conversionFactor) assertPositive('conversionFactor', conversionFactor) self.__conversionFactor = conversionFactor @property # getter - - - - - - - - - - def name(self): """Author-defined name for this unit conversionFactor value (for example, FeetToMeters).""" return self.__name @name.setter def name(self, name): if name is None: name = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(name) self.__name = name @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return False # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function unit.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function unit.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"unit":\n' result += indent + '{\n' attributeResult = '' if self.category: attributeResult += " " + '"@category":"' + SFString(self.category).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.conversionFactor != 1.0: attributeResult += " " + '"@conversionFactor":"' + SFDouble(self.conversionFactor).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.name: attributeResult += " " + '"@name":"' + SFString(self.name).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' result += 'UNIT ' + self.category + ' ' + self.name + ' ' + str(self.conversionFactor) + '\n' # print('VRML serialization complete.', flush=True) return result class X3D(_X3DNode): """ X3D is the root node for an Extensible 3D (X3D) Graphics model. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'X3D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/concepts.html#Header' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#X3D' XML_HEADER = '' XML_DOCTYPE_X3D_3_0 = '' XML_DOCTYPE_X3D_3_1 = '' XML_DOCTYPE_X3D_3_2 = '' XML_DOCTYPE_X3D_3_3 = '' XML_DOCTYPE_X3D_4_0 = '' XML_DOCTYPE_X3D_4_1 = '' X3D_XML_SCHEMA_ATTRIBUTES_3_0 = "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'" X3D_XML_SCHEMA_ATTRIBUTES_3_1 = "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.1.xsd'" X3D_XML_SCHEMA_ATTRIBUTES_3_2 = "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.2.xsd'" X3D_XML_SCHEMA_ATTRIBUTES_3_3 = "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'" X3D_XML_SCHEMA_ATTRIBUTES_4_0 = "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.0.xsd'" X3D_XML_SCHEMA_ATTRIBUTES_4_1 = "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.1.xsd'" VRML97_HEADER = '#VRML V2.0 utf8' CLASSIC_VRML_HEADER_PREFIX = '#VRML V' # followed by X3D version number CLASSIC_VRML_HEADER_SUFFIX = ' utf8' # TODO confirm JSON Schema header JSON_HEADER = '''{ "X3D":, { "encoding":"UTF-8", "$id": "https://www.web3d.org/specifications/x3d-4.0-JSONSchema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", ''' X3D_XML_VALIDATOR = "https://savage.nps.edu/X3dValidator" X3D_JSON_VALIDATOR = "https://coderextreme.net/X3DJSONLD/src/main/html/validator.html" X3DOM_HEADER = """ ' + '\n' # no self-closing tags allowed by HTML5 elif syntax.upper() == "XML": result += '/>' + '\n' # singleton element else: raise X3DValueError('.toXML(syntax=' + syntax + ') is incorrect, allowed values are "HTML5" and "XML"') else: result += '>' + '\n' if self.IS: # output this SFNode result += self.IS.XML(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.XML(indentLevel=indentLevel+1, syntax=syntax, field="metadata") ### if self.field: # walk each child in list, if any ### print('* Script found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(field)=' + str(len(self.field)) + ', now invoking XML(' + str(indentLevel+1) + ')', flush=True) if self.field: # walk each child in list, if any (avoid empty list recursion) for each in self.field: result += each.XML(indentLevel=indentLevel+1, syntax=syntax, field="field") if self.sourceCode: result += indent + '\n' result += indent + '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Script.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Script":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.autoRefresh != 0: attributeResult += " " + '"@autoRefresh":"' + SFTime(self.autoRefresh).JSON() + '"' + ',\n' if self.autoRefreshTimeLimit != 3600: attributeResult += " " + '"@autoRefreshTimeLimit":"' + SFTime(self.autoRefreshTimeLimit).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.directOutput: # default=false attributeResult += " " + '"@directOutput":"' + SFBool(self.directOutput).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.load: # default=true attributeResult += " " + '"@load":"' + SFBool(self.load).JSON() + '"' + ',\n' if self.mustEvaluate: # default=false attributeResult += " " + '"@mustEvaluate":"' + SFBool(self.mustEvaluate).JSON() + '"' + ',\n' if self.sourceCode: attributeResult += " " + '"@sourceCode":"' + SFString(self.sourceCode).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.url != []: attributeResult += " " + '"@url":"' + MFString(self.url).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.field: # walk each child in list, if any (avoid empty list recursion) ### print('* Script found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(field)=' + str(len(self.field)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.field: # walk each child in list, if any (avoid empty list recursion) for each in self.field: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Script.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Script' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Script' + ' {' if self.autoRefresh != 0: result += '\n' + indent + ' ' + "autoRefresh " + SFTime(self.autoRefresh).VRML() + "" if self.autoRefreshTimeLimit != 3600: result += '\n' + indent + ' ' + "autoRefreshTimeLimit " + SFTime(self.autoRefreshTimeLimit).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.directOutput: # default=false result += '\n' + indent + ' ' + "directOutput " + SFBool(self.directOutput).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.load: # default=true result += '\n' + indent + ' ' + "load " + SFBool(self.load).VRML() + "" if self.mustEvaluate: # default=false result += '\n' + indent + ' ' + "mustEvaluate " + SFBool(self.mustEvaluate).VRML() + "" if self.sourceCode: result += '\n' + indent + ' ' + "url " + '"' + self.sourceCode + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.url != []: result += '\n' + indent + ' ' + "url " + MFString(self.url).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.field: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.field: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SegmentedVolumeData(_X3DVolumeDataNode): """ SegmentedVolumeData displays a segmented voxel dataset with different RenderStyle nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SegmentedVolumeData' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#SegmentedVolumeData' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SegmentedVolumeData' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DVolumeDataNode'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeDataNode'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DVolumeDataNode'), ('dimensions', (1, 1, 1), FieldType.SFVec3f, AccessType.inputOutput, 'X3DVolumeDataNode'), ('segmentEnabled', [], FieldType.MFBool, AccessType.inputOutput, 'SegmentedVolumeData'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeDataNode'), ('segmentIdentifiers', None, FieldType.SFNode, AccessType.inputOutput, 'SegmentedVolumeData'), ('voxels', None, FieldType.SFNode, AccessType.inputOutput, 'SegmentedVolumeData'), ('renderStyle', [], FieldType.MFNode, AccessType.inputOutput, 'SegmentedVolumeData'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), dimensions=(1, 1, 1), segmentEnabled=None, visible=True, segmentIdentifiers=None, voxels=None, renderStyle=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SegmentedVolumeData __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.dimensions = dimensions self.segmentEnabled = segmentEnabled self.visible = visible self.segmentIdentifiers = segmentIdentifiers self.voxels = voxels self.renderStyle = renderStyle self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def dimensions(self): """Actual-size X-Y-Z dimensions of volume data in local coordinate system.""" return self.__dimensions @dimensions.setter def dimensions(self, dimensions): if dimensions is None: dimensions = (1, 1, 1) # default assertValidSFVec3f(dimensions) assertPositive('dimensions', dimensions) self.__dimensions = dimensions @property # getter - - - - - - - - - - def segmentEnabled(self): """Array of boolean values that indicates whether to draw each segment, with indices corresponding to the segment identifier.""" return self.__segmentEnabled @segmentEnabled.setter def segmentEnabled(self, segmentEnabled): if segmentEnabled is None: segmentEnabled = MFBool.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFBool.DEFAULT_VALUE()=' + str(MFBool.DEFAULT_VALUE())) assertValidMFBool(segmentEnabled) self.__segmentEnabled = segmentEnabled @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def segmentIdentifiers(self): """[X3DTexture3DNode] Single contained X3DTexture3DNode (ComposedTexture3D, ImageTexture3D, PixelTexture3D) holds component texture that provides corresponding segment identifier.""" return self.__segmentIdentifiers @segmentIdentifiers.setter def segmentIdentifiers(self, segmentIdentifiers): if segmentIdentifiers is None: segmentIdentifiers = None # default assertValidSFNode(segmentIdentifiers) if not segmentIdentifiers is None and not isinstance(segmentIdentifiers,(_X3DTexture3DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(segmentIdentifiers) + ' does not match required node type (_X3DTexture3DNode,ProtoInstance) and is invalid') self.__segmentIdentifiers = segmentIdentifiers @property # getter - - - - - - - - - - def voxels(self): """[X3DTexture3DNode] Single contained X3DTexture3DNode (ComposedTexture3D, ImageTexture3D, PixelTexture3D) that provides raw voxel information utilized by corresponding rendering styles.""" return self.__voxels @voxels.setter def voxels(self, voxels): if voxels is None: voxels = None # default assertValidSFNode(voxels) if not voxels is None and not isinstance(voxels,(_X3DTexture3DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(voxels) + ' does not match required node type (_X3DTexture3DNode,ProtoInstance) and is invalid') self.__voxels = voxels @property # getter - - - - - - - - - - def renderStyle(self): """[X3DVolumeRenderStyleNode] Multiple contained X3DVolumeRenderStyleNode nodes corresponding to each isosurface that define specific rendering technique for this volumetric object.""" return self.__renderStyle @renderStyle.setter def renderStyle(self, renderStyle): if renderStyle is None: renderStyle = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(renderStyle) self.__renderStyle = renderStyle @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.segmentIdentifiers or self.voxels or (len(self.renderStyle) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SegmentedVolumeData.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SegmentedVolumeData.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SegmentedVolumeData":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.dimensions != (1, 1, 1): attributeResult += " " + '"@dimensions":"' + SFVec3f(self.dimensions).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.segmentEnabled != []: attributeResult += " " + '"@segmentEnabled":"' + MFBool(self.segmentEnabled).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.segmentIdentifiers: # output this SFNode result += self.segmentIdentifiers.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.voxels: # output this SFNode result += self.voxels.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.renderStyle: # walk each child in list, if any (avoid empty list recursion) ### print('* SegmentedVolumeData found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(renderStyle)=' + str(len(self.renderStyle)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.renderStyle: # walk each child in list, if any (avoid empty list recursion) for each in self.renderStyle: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SegmentedVolumeData.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SegmentedVolumeData' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SegmentedVolumeData' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.dimensions != (1, 1, 1): result += '\n' + indent + ' ' + "dimensions " + SFVec3f(self.dimensions).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.segmentEnabled != []: result += '\n' + indent + ' ' + "segmentEnabled " + MFBool(self.segmentEnabled).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.segmentIdentifiers: # output this SFNode result += '\n' + ' ' + indent + 'segmentIdentifiers ' + self.segmentIdentifiers.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.voxels: # output this SFNode result += '\n' + ' ' + indent + 'voxels ' + self.voxels.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.renderStyle: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.renderStyle: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ShadedVolumeStyle(_X3DComposableVolumeRenderStyleNode): """ All fields fully supported except shadows supported with at least Phong shading at level 3. All fields fully supported with at least Phong shading and Henyey-Greenstein phase function, shadows fully supported at level 4. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ShadedVolumeStyle' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#ShadedVolumeStyle' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ShadedVolumeStyle' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeRenderStyleNode'), ('lighting', False, FieldType.SFBool, AccessType.inputOutput, 'ShadedVolumeStyle'), ('phaseFunction', 'Henyey-Greenstein', FieldType.SFString, AccessType.initializeOnly, 'ShadedVolumeStyle'), ('shadows', False, FieldType.SFBool, AccessType.inputOutput, 'ShadedVolumeStyle'), ('material', None, FieldType.SFNode, AccessType.inputOutput, 'ShadedVolumeStyle'), ('surfaceNormals', None, FieldType.SFNode, AccessType.inputOutput, 'ShadedVolumeStyle'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, enabled=True, lighting=False, phaseFunction='Henyey-Greenstein', shadows=False, material=None, surfaceNormals=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode ShadedVolumeStyle __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.enabled = enabled self.lighting = lighting self.phaseFunction = phaseFunction self.shadows = shadows self.material = material self.surfaceNormals = surfaceNormals self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def lighting(self): """Whether rendering calculates and applies shading effects to visual output.""" return self.__lighting @lighting.setter def lighting(self, lighting): if lighting is None: lighting = False # default assertValidSFBool(lighting) self.__lighting = lighting @property # getter - - - - - - - - - - def phaseFunction(self): """define scattering model for implementations using global illumination (NONE or Henyey-Greenstein phase function).""" return self.__phaseFunction @phaseFunction.setter def phaseFunction(self, phaseFunction): if phaseFunction is None: phaseFunction = 'Henyey-Greenstein' # default assertValidSFString(phaseFunction) self.__phaseFunction = phaseFunction @property # getter - - - - - - - - - - def shadows(self): """Whether rendering calculates and applies shadows to visual output (using global illumination model).""" return self.__shadows @shadows.setter def shadows(self, shadows): if shadows is None: shadows = False # default assertValidSFBool(shadows) self.__shadows = shadows @property # getter - - - - - - - - - - def material(self): """[X3DMaterialNode] Colour and opacity is determined based on whether a value has been specified for the material field.""" return self.__material @material.setter def material(self, material): if material is None: material = None # default assertValidSFNode(material) if not material is None and not isinstance(material,(_X3DMaterialNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(material) + ' does not match required node type (_X3DMaterialNode,ProtoInstance) and is invalid') self.__material = material @property # getter - - - - - - - - - - def surfaceNormals(self): """[X3DTexture3DNode] The surfaceNormals field contains a 3D texture with at least three component values.""" return self.__surfaceNormals @surfaceNormals.setter def surfaceNormals(self, surfaceNormals): if surfaceNormals is None: surfaceNormals = None # default assertValidSFNode(surfaceNormals) if not surfaceNormals is None and not isinstance(surfaceNormals,(_X3DTexture3DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(surfaceNormals) + ' does not match required node type (_X3DTexture3DNode,ProtoInstance) and is invalid') self.__surfaceNormals = surfaceNormals @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.material or self.metadata or self.surfaceNormals # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ShadedVolumeStyle.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ShadedVolumeStyle.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ShadedVolumeStyle":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.lighting: # default=false attributeResult += " " + '"@lighting":"' + SFBool(self.lighting).JSON() + '"' + ',\n' if self.phaseFunction != 'Henyey-Greenstein': attributeResult += " " + '"@phaseFunction":"' + SFString(self.phaseFunction).JSON() + '"' + ',\n' if self.shadows: # default=false attributeResult += " " + '"@shadows":"' + SFBool(self.shadows).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.material: # output this SFNode result += self.material.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.surfaceNormals: # output this SFNode result += self.surfaceNormals.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function ShadedVolumeStyle.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'ShadedVolumeStyle' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'ShadedVolumeStyle' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.lighting: # default=false result += '\n' + indent + ' ' + "lighting " + SFBool(self.lighting).VRML() + "" if self.phaseFunction != 'Henyey-Greenstein': result += '\n' + indent + ' ' + "phaseFunction " + '"' + self.phaseFunction + '"' + "" if self.shadows: # default=false result += '\n' + indent + ' ' + "shadows " + SFBool(self.shadows).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.material: # output this SFNode result += '\n' + ' ' + indent + 'material ' + self.material.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.surfaceNormals: # output this SFNode result += '\n' + ' ' + indent + 'surfaceNormals ' + self.surfaceNormals.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ShaderPart(_X3DNode): # , _X3DUrlObject # TODO fix additional inheritance method resolution order (MRO) """ ShaderPart can contain a CDATA section of plain-text source code. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ShaderPart' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shaders.html#ShaderPart' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ShaderPart' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('autoRefresh', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DUrlObject'), ('autoRefreshTimeLimit', 3600, FieldType.SFTime, AccessType.inputOutput, 'X3DUrlObject'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DUrlObject'), ('load', True, FieldType.SFBool, AccessType.inputOutput, 'X3DUrlObject'), ('sourceCode', '', FieldType.SFString, AccessType.inputOutput, 'ShaderPart'), ('type', 'VERTEX', FieldType.SFString, AccessType.initializeOnly, 'ShaderPart'), ('url', [], FieldType.MFString, AccessType.inputOutput, 'X3DUrlObject'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, autoRefresh=0, autoRefreshTimeLimit=3600, description='', load=True, sourceCode='', type='VERTEX', url=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode ShaderPart __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.autoRefresh = autoRefresh self.autoRefreshTimeLimit = autoRefreshTimeLimit self.description = description self.load = load self.sourceCode = sourceCode self.type = type self.url = url self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def autoRefresh(self): """autoRefresh defines interval in seconds before automatic reload of current url asset is performed.""" return self.__autoRefresh @autoRefresh.setter def autoRefresh(self, autoRefresh): if autoRefresh is None: autoRefresh = 0 # default assertValidSFTime(autoRefresh) assertNonNegative('autoRefresh', autoRefresh) self.__autoRefresh = autoRefresh @property # getter - - - - - - - - - - def autoRefreshTimeLimit(self): """autoRefreshTimeLimit defines maximum duration that automatic refresh activity can occur.""" return self.__autoRefreshTimeLimit @autoRefreshTimeLimit.setter def autoRefreshTimeLimit(self, autoRefreshTimeLimit): if autoRefreshTimeLimit is None: autoRefreshTimeLimit = 3600 # default assertValidSFTime(autoRefreshTimeLimit) assertNonNegative('autoRefreshTimeLimit', autoRefreshTimeLimit) self.__autoRefreshTimeLimit = autoRefreshTimeLimit @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def load(self): """load=true means load immediately, load=false means defer loading or else unload a previously loaded scene.""" return self.__load @load.setter def load(self, load): if load is None: load = True # default assertValidSFBool(load) self.__load = load @property # getter - - - - - - - - - - def sourceCode(self): """ Embedded source code for a local program. """ return self.__sourceCode @sourceCode.setter def sourceCode(self, sourceCode): if sourceCode is None: sourceCode = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(sourceCode) self.__sourceCode = sourceCode @property # getter - - - - - - - - - - def type(self): """type indicates whether this ShaderProgram is a vertex or fragment (pixel) shader.""" return self.__type @type.setter def type(self, type): if type is None: type = 'VERTEX' # default assertValidSFString(type) self.__type = type @property # getter - - - - - - - - - - def url(self): """Location and filename of shader.""" return self.__url @url.setter def url(self, url): if url is None: url = MFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFString.DEFAULT_VALUE()=' + str(MFString.DEFAULT_VALUE())) assertValidMFString(url) self.__url = url @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ShaderPart.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '\n' result += indent + '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ShaderPart.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ShaderPart":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.autoRefresh != 0: attributeResult += " " + '"@autoRefresh":"' + SFTime(self.autoRefresh).JSON() + '"' + ',\n' if self.autoRefreshTimeLimit != 3600: attributeResult += " " + '"@autoRefreshTimeLimit":"' + SFTime(self.autoRefreshTimeLimit).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.load: # default=true attributeResult += " " + '"@load":"' + SFBool(self.load).JSON() + '"' + ',\n' if self.sourceCode: attributeResult += " " + '"@sourceCode":"' + SFString(self.sourceCode).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.type != 'VERTEX': attributeResult += " " + '"@type":"' + SFString(self.type).JSON() + '"' + ',\n' if self.url != []: attributeResult += " " + '"@url":"' + MFString(self.url).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function ShaderPart.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'ShaderPart' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'ShaderPart' + ' {' if self.autoRefresh != 0: result += '\n' + indent + ' ' + "autoRefresh " + SFTime(self.autoRefresh).VRML() + "" if self.autoRefreshTimeLimit != 3600: result += '\n' + indent + ' ' + "autoRefreshTimeLimit " + SFTime(self.autoRefreshTimeLimit).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.load: # default=true result += '\n' + indent + ' ' + "load " + SFBool(self.load).VRML() + "" if self.sourceCode: result += '\n' + indent + ' ' + "url " + '"' + self.sourceCode + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.type != 'VERTEX': result += '\n' + indent + ' ' + "type " + '"' + self.type + '"' + "" if self.url != []: result += '\n' + indent + ' ' + "url " + MFString(self.url).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ShaderProgram(_X3DNode): # , _X3DUrlObject, _X3DProgrammableShaderObject # TODO fix additional inheritance method resolution order (MRO) """ ShaderProgram can contain field declarations and a CDATA section of plain-text source code. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ShaderProgram' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shaders.html#ShaderProgram' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ShaderProgram' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('autoRefresh', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DUrlObject'), ('autoRefreshTimeLimit', 3600, FieldType.SFTime, AccessType.inputOutput, 'X3DUrlObject'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DUrlObject'), ('load', True, FieldType.SFBool, AccessType.inputOutput, 'X3DUrlObject'), ('sourceCode', '', FieldType.SFString, AccessType.inputOutput, 'ShaderProgram'), ('type', 'VERTEX', FieldType.SFString, AccessType.initializeOnly, 'ShaderProgram'), ('url', [], FieldType.MFString, AccessType.inputOutput, 'X3DUrlObject'), ('field', [], FieldType.MFNode, AccessType.inputOutput, 'ShaderProgram'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, autoRefresh=0, autoRefreshTimeLimit=3600, description='', load=True, sourceCode='', type='VERTEX', url=None, field=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode ShaderProgram __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.autoRefresh = autoRefresh self.autoRefreshTimeLimit = autoRefreshTimeLimit self.description = description self.load = load self.sourceCode = sourceCode self.type = type self.url = url self.field = field self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def autoRefresh(self): """autoRefresh defines interval in seconds before automatic reload of current url asset is performed.""" return self.__autoRefresh @autoRefresh.setter def autoRefresh(self, autoRefresh): if autoRefresh is None: autoRefresh = 0 # default assertValidSFTime(autoRefresh) assertNonNegative('autoRefresh', autoRefresh) self.__autoRefresh = autoRefresh @property # getter - - - - - - - - - - def autoRefreshTimeLimit(self): """autoRefreshTimeLimit defines maximum duration that automatic refresh activity can occur.""" return self.__autoRefreshTimeLimit @autoRefreshTimeLimit.setter def autoRefreshTimeLimit(self, autoRefreshTimeLimit): if autoRefreshTimeLimit is None: autoRefreshTimeLimit = 3600 # default assertValidSFTime(autoRefreshTimeLimit) assertNonNegative('autoRefreshTimeLimit', autoRefreshTimeLimit) self.__autoRefreshTimeLimit = autoRefreshTimeLimit @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def load(self): """load=true means load immediately, load=false means defer loading or else unload a previously loaded scene.""" return self.__load @load.setter def load(self, load): if load is None: load = True # default assertValidSFBool(load) self.__load = load @property # getter - - - - - - - - - - def sourceCode(self): """ Embedded source code for a local program. """ return self.__sourceCode @sourceCode.setter def sourceCode(self, sourceCode): if sourceCode is None: sourceCode = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(sourceCode) self.__sourceCode = sourceCode @property # getter - - - - - - - - - - def type(self): """type indicates whether this ShaderProgram is a vertex or fragment (pixel) shader.""" return self.__type @type.setter def type(self, type): if type is None: type = 'VERTEX' # default assertValidSFString(type) self.__type = type @property # getter - - - - - - - - - - def url(self): """Location and filename of shader.""" return self.__url @url.setter def url(self, url): if url is None: url = MFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFString.DEFAULT_VALUE()=' + str(MFString.DEFAULT_VALUE())) assertValidMFString(url) self.__url = url @property # getter - - - - - - - - - - def field(self): """Include a field statement for each field declaration in the ShaderProgram node.""" return self.__field @field.setter def field(self, field): if field is None: field = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) # TODO type-aware checks for field if field: # walk each child in list, if any (avoid empty list recursion) for each in field: assertValidFieldInitializationValue(each.name, each.type, each.value, parent='ShaderProgram') self.__field = field @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.field) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ShaderProgram.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '\n' result += indent + '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ShaderProgram.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ShaderProgram":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.autoRefresh != 0: attributeResult += " " + '"@autoRefresh":"' + SFTime(self.autoRefresh).JSON() + '"' + ',\n' if self.autoRefreshTimeLimit != 3600: attributeResult += " " + '"@autoRefreshTimeLimit":"' + SFTime(self.autoRefreshTimeLimit).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.load: # default=true attributeResult += " " + '"@load":"' + SFBool(self.load).JSON() + '"' + ',\n' if self.sourceCode: attributeResult += " " + '"@sourceCode":"' + SFString(self.sourceCode).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.type != 'VERTEX': attributeResult += " " + '"@type":"' + SFString(self.type).JSON() + '"' + ',\n' if self.url != []: attributeResult += " " + '"@url":"' + MFString(self.url).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.field: # walk each child in list, if any (avoid empty list recursion) ### print('* ShaderProgram found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(field)=' + str(len(self.field)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.field: # walk each child in list, if any (avoid empty list recursion) for each in self.field: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function ShaderProgram.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'ShaderProgram' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'ShaderProgram' + ' {' if self.autoRefresh != 0: result += '\n' + indent + ' ' + "autoRefresh " + SFTime(self.autoRefresh).VRML() + "" if self.autoRefreshTimeLimit != 3600: result += '\n' + indent + ' ' + "autoRefreshTimeLimit " + SFTime(self.autoRefreshTimeLimit).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.load: # default=true result += '\n' + indent + ' ' + "load " + SFBool(self.load).VRML() + "" if self.sourceCode: result += '\n' + indent + ' ' + "url " + '"' + self.sourceCode + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.type != 'VERTEX': result += '\n' + indent + ' ' + "type " + '"' + self.type + '"' + "" if self.url != []: result += '\n' + indent + ' ' + "url " + MFString(self.url).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.field: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.field: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Shape(_X3DShapeNode): """ Shape can appear under any grouping node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Shape' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#Shape' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Shape' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DShapeNode'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DShapeNode'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DShapeNode'), ('castShadow', True, FieldType.SFBool, AccessType.inputOutput, 'X3DShapeNode'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DShapeNode'), ('appearance', None, FieldType.SFNode, AccessType.inputOutput, 'X3DShapeNode'), ('geometry', None, FieldType.SFNode, AccessType.inputOutput, 'X3DShapeNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), castShadow=True, visible=True, appearance=None, geometry=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Shape __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.castShadow = castShadow self.visible = visible self.appearance = appearance self.geometry = geometry self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def castShadow(self): """castShadow defines whether this Shape casts shadows as produced by lighting nodes.""" return self.__castShadow @castShadow.setter def castShadow(self, castShadow): if castShadow is None: castShadow = True # default assertValidSFBool(castShadow) self.__castShadow = castShadow @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def appearance(self): """[X3DAppearanceNode] Single contained Appearance node that can specify visual attributes (such as material, texture, fillProperties and lineProperties) applied to corresponding geometry.""" return self.__appearance @appearance.setter def appearance(self, appearance): if appearance is None: appearance = None # default assertValidSFNode(appearance) if not appearance is None and not isinstance(appearance,(_X3DAppearanceNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(appearance) + ' does not match required node type (_X3DAppearanceNode,ProtoInstance) and is invalid') self.__appearance = appearance @property # getter - - - - - - - - - - def geometry(self): """[X3DGeometryNode] Single contained geometry node that is rendered according to corresponding appearance.""" return self.__geometry @geometry.setter def geometry(self, geometry): if geometry is None: geometry = None # default assertValidSFNode(geometry) if not geometry is None and not isinstance(geometry,(_X3DGeometryNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(geometry) + ' does not match required node type (_X3DGeometryNode,ProtoInstance) and is invalid') self.__geometry = geometry @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.appearance or self.geometry or self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Shape.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Shape.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Shape":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if not self.castShadow: # default=true attributeResult += " " + '"@castShadow":"' + SFBool(self.castShadow).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.appearance: # output this SFNode result += self.appearance.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.geometry: # output this SFNode result += self.geometry.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Shape.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Shape' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Shape' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if not self.castShadow: # default=true result += '\n' + indent + ' ' + "castShadow " + SFBool(self.castShadow).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.appearance: # output this SFNode result += '\n' + ' ' + indent + 'appearance ' + self.appearance.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.geometry: # output this SFNode result += '\n' + ' ' + indent + 'geometry ' + self.geometry.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SignalPdu(_X3DNetworkSensorNode, _X3DBoundedObject): """ SignalPdu is a networked Protocol Data Unit (PDU) information node that communicates the transmission of voice, audio or other data modeled in a simulation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SignalPdu' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/dis.html#SignalPdu' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SignalPdu' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('address', 'localhost', FieldType.SFString, AccessType.inputOutput, 'SignalPdu'), ('applicationID', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DBoundedObject'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DBoundedObject'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DBoundedObject'), ('data', [], FieldType.MFInt32, AccessType.inputOutput, 'SignalPdu'), ('dataLength', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('encodingScheme', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('entityID', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('geoCoords', (0, 0, 0), FieldType.SFVec3d, AccessType.inputOutput, 'SignalPdu'), ('geoSystem', ["GD", "WE"], FieldType.MFString, AccessType.initializeOnly, 'SignalPdu'), ('multicastRelayHost', '', FieldType.SFString, AccessType.inputOutput, 'SignalPdu'), ('multicastRelayPort', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('networkMode', 'standAlone', FieldType.SFString, AccessType.inputOutput, 'SignalPdu'), ('port', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('radioID', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('readInterval', 0.1, FieldType.SFTime, AccessType.inputOutput, 'SignalPdu'), ('rtpHeaderExpected', False, FieldType.SFBool, AccessType.inputOutput, 'SignalPdu'), ('sampleRate', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('samples', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('siteID', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('tdlType', 0, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DBoundedObject'), ('whichGeometry', 1, FieldType.SFInt32, AccessType.inputOutput, 'SignalPdu'), ('writeInterval', 1.0, FieldType.SFTime, AccessType.inputOutput, 'SignalPdu'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, address='localhost', applicationID=0, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), data=None, dataLength=0, description='', enabled=True, encodingScheme=0, entityID=0, geoCoords=(0, 0, 0), geoSystem=None, multicastRelayHost='', multicastRelayPort=0, networkMode='standAlone', port=0, radioID=0, readInterval=0.1, rtpHeaderExpected=False, sampleRate=0, samples=0, siteID=0, tdlType=0, visible=True, whichGeometry=1, writeInterval=1.0, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SignalPdu __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.address = address self.applicationID = applicationID self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.data = data self.dataLength = dataLength self.description = description self.enabled = enabled self.encodingScheme = encodingScheme self.entityID = entityID self.geoCoords = geoCoords self.geoSystem = geoSystem self.multicastRelayHost = multicastRelayHost self.multicastRelayPort = multicastRelayPort self.networkMode = networkMode self.port = port self.radioID = radioID self.readInterval = readInterval self.rtpHeaderExpected = rtpHeaderExpected self.sampleRate = sampleRate self.samples = samples self.siteID = siteID self.tdlType = tdlType self.visible = visible self.whichGeometry = whichGeometry self.writeInterval = writeInterval self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def address(self): """Multicast network address, or else 'localhost'.""" return self.__address @address.setter def address(self, address): if address is None: address = 'localhost' # default assertValidSFString(address) self.__address = address @property # getter - - - - - - - - - - def applicationID(self): """Each simulation application that can respond to simulation management PDUs needs to have a unique applicationID.""" return self.__applicationID @applicationID.setter def applicationID(self, applicationID): if applicationID is None: applicationID = 0 # default assertValidSFInt32(applicationID) self.__applicationID = applicationID @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def data(self): """Holds audio or digital data conveyed by the radio transmission.""" return self.__data @data.setter def data(self, data): if data is None: data = MFInt32.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFInt32.DEFAULT_VALUE()=' + str(MFInt32.DEFAULT_VALUE())) assertValidMFInt32(data) self.__data = data @property # getter - - - - - - - - - - def dataLength(self): """number of bits of digital voice audio or digital data being sent in the Signal PDU.""" return self.__dataLength @dataLength.setter def dataLength(self, dataLength): if dataLength is None: dataLength = 0 # default assertValidSFInt32(dataLength) self.__dataLength = dataLength @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables the sensor node.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def encodingScheme(self): """designates both Encoding Class and Encoding Type.""" return self.__encodingScheme @encodingScheme.setter def encodingScheme(self, encodingScheme): if encodingScheme is None: encodingScheme = 0 # default assertValidSFInt32(encodingScheme) self.__encodingScheme = encodingScheme @property # getter - - - - - - - - - - def entityID(self): """EntityID unique ID for entity within that application.""" return self.__entityID @entityID.setter def entityID(self, entityID): if entityID is None: entityID = 0 # default assertValidSFInt32(entityID) self.__entityID = entityID @property # getter - - - - - - - - - - def geoCoords(self): """Geographic location (specified in current geoSystem coordinates) for children geometry (specified in relative coordinate system, in meters).""" return self.__geoCoords @geoCoords.setter def geoCoords(self, geoCoords): if geoCoords is None: geoCoords = (0, 0, 0) # default assertValidSFVec3d(geoCoords) self.__geoCoords = geoCoords @property # getter - - - - - - - - - - def geoSystem(self): """Identifies spatial reference frame: Geodetic (GD), Geocentric (GC), Universal Transverse Mercator (UTM).""" return self.__geoSystem @geoSystem.setter def geoSystem(self, geoSystem): if geoSystem is None: geoSystem = ["GD", "WE"] # default assertValidMFString(geoSystem) self.__geoSystem = geoSystem @property # getter - - - - - - - - - - def multicastRelayHost(self): """Fallback server address if multicast not available locally.""" return self.__multicastRelayHost @multicastRelayHost.setter def multicastRelayHost(self, multicastRelayHost): if multicastRelayHost is None: multicastRelayHost = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(multicastRelayHost) self.__multicastRelayHost = multicastRelayHost @property # getter - - - - - - - - - - def multicastRelayPort(self): """Fallback server port if multicast not available locally.""" return self.__multicastRelayPort @multicastRelayPort.setter def multicastRelayPort(self, multicastRelayPort): if multicastRelayPort is None: multicastRelayPort = 0 # default assertValidSFInt32(multicastRelayPort) self.__multicastRelayPort = multicastRelayPort @property # getter - - - - - - - - - - def networkMode(self): """Whether this entity is ignoring the network, sending DIS packets to the network, or receiving DIS packets from the network.""" return self.__networkMode @networkMode.setter def networkMode(self, networkMode): if networkMode is None: networkMode = 'standAlone' # default assertValidSFString(networkMode) assertValidNetworkMode('networkMode', networkMode) self.__networkMode = networkMode @property # getter - - - - - - - - - - def port(self): """Multicast network port, for example: 3000.""" return self.__port @port.setter def port(self, port): if port is None: port = 0 # default assertValidSFInt32(port) self.__port = port @property # getter - - - - - - - - - - def radioID(self): """Identifies a particular radio within a given entity.""" return self.__radioID @radioID.setter def radioID(self, radioID): if radioID is None: radioID = 0 # default assertValidSFInt32(radioID) self.__radioID = radioID @property # getter - - - - - - - - - - def readInterval(self): """[0,+infinity) Seconds between read updates, 0 means no reading.""" return self.__readInterval @readInterval.setter def readInterval(self, readInterval): if readInterval is None: readInterval = 0.1 # default assertValidSFTime(readInterval) assertNonNegative('readInterval', readInterval) self.__readInterval = readInterval @property # getter - - - - - - - - - - def rtpHeaderExpected(self): """Whether RTP headers are prepended to DIS PDUs.""" return self.__rtpHeaderExpected @rtpHeaderExpected.setter def rtpHeaderExpected(self, rtpHeaderExpected): if rtpHeaderExpected is None: rtpHeaderExpected = False # default assertValidSFBool(rtpHeaderExpected) self.__rtpHeaderExpected = rtpHeaderExpected @property # getter - - - - - - - - - - def sampleRate(self): """sampleRate gives either (1) sample rate in samples per second if Encoding Class is encoded audio, or (2) data rate in bits per second for data transmissions.""" return self.__sampleRate @sampleRate.setter def sampleRate(self, sampleRate): if sampleRate is None: sampleRate = 0 # default assertValidSFInt32(sampleRate) self.__sampleRate = sampleRate @property # getter - - - - - - - - - - def samples(self): """Number of samples in the PDU if the Encoding Class is encoded voice, otherwise the field is set to zero.""" return self.__samples @samples.setter def samples(self, samples): if samples is None: samples = 0 # default assertValidSFInt32(samples) self.__samples = samples @property # getter - - - - - - - - - - def siteID(self): """Simulation/exercise siteID of the participating LAN or organization.""" return self.__siteID @siteID.setter def siteID(self, siteID): if siteID is None: siteID = 0 # default assertValidSFInt32(siteID) self.__siteID = siteID @property # getter - - - - - - - - - - def tdlType(self): """Tactical Data Link (TDL) type as an enumerated value when the Encoding Class is voice, raw binary, application-specific, or database index representation of a TDL message.""" return self.__tdlType @tdlType.setter def tdlType(self, tdlType): if tdlType is None: tdlType = 0 # default assertValidSFInt32(tdlType) self.__tdlType = tdlType @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def whichGeometry(self): """Select geometry to render: -1 for no geometry, 0 for text trace, 1 for default geometry, (optional) higher values to render different states.""" return self.__whichGeometry @whichGeometry.setter def whichGeometry(self, whichGeometry): if whichGeometry is None: whichGeometry = 1 # default assertValidSFInt32(whichGeometry) self.__whichGeometry = whichGeometry @property # getter - - - - - - - - - - def writeInterval(self): """[0,+infinity) Seconds between write updates, 0 means no writing (sending).""" return self.__writeInterval @writeInterval.setter def writeInterval(self, writeInterval): if writeInterval is None: writeInterval = 1.0 # default assertValidSFTime(writeInterval) assertNonNegative('writeInterval', writeInterval) self.__writeInterval = writeInterval @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SignalPdu.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SignalPdu.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SignalPdu":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.address != 'localhost': attributeResult += " " + '"@address":"' + SFString(self.address).JSON() + '"' + ',\n' if self.applicationID != 0: attributeResult += " " + '"@applicationID":"' + SFInt32(self.applicationID).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.data != []: attributeResult += " " + '"@data":"' + MFInt32(self.data).JSON() + '"' + ',\n' if self.dataLength != 0: attributeResult += " " + '"@dataLength":"' + SFInt32(self.dataLength).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.encodingScheme != 0: attributeResult += " " + '"@encodingScheme":"' + SFInt32(self.encodingScheme).JSON() + '"' + ',\n' if self.entityID != 0: attributeResult += " " + '"@entityID":"' + SFInt32(self.entityID).JSON() + '"' + ',\n' if self.geoCoords != (0, 0, 0): attributeResult += " " + '"@geoCoords":"' + SFVec3d(self.geoCoords).JSON() + '"' + ',\n' if self.geoSystem != ["GD", "WE"]: attributeResult += " " + '"@geoSystem":"' + MFString(self.geoSystem).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.multicastRelayHost: attributeResult += " " + '"@multicastRelayHost":"' + SFString(self.multicastRelayHost).JSON() + '"' + ',\n' if self.multicastRelayPort != 0: attributeResult += " " + '"@multicastRelayPort":"' + SFInt32(self.multicastRelayPort).JSON() + '"' + ',\n' if self.networkMode != 'standAlone': attributeResult += " " + '"@networkMode":"' + SFString(self.networkMode).JSON() + '"' + ',\n' if self.port != 0: attributeResult += " " + '"@port":"' + SFInt32(self.port).JSON() + '"' + ',\n' if self.radioID != 0: attributeResult += " " + '"@radioID":"' + SFInt32(self.radioID).JSON() + '"' + ',\n' if self.readInterval != 0.1: attributeResult += " " + '"@readInterval":"' + SFTime(self.readInterval).JSON() + '"' + ',\n' if self.rtpHeaderExpected: # default=false attributeResult += " " + '"@rtpHeaderExpected":"' + SFBool(self.rtpHeaderExpected).JSON() + '"' + ',\n' if self.sampleRate != 0: attributeResult += " " + '"@sampleRate":"' + SFInt32(self.sampleRate).JSON() + '"' + ',\n' if self.samples != 0: attributeResult += " " + '"@samples":"' + SFInt32(self.samples).JSON() + '"' + ',\n' if self.siteID != 0: attributeResult += " " + '"@siteID":"' + SFInt32(self.siteID).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.tdlType != 0: attributeResult += " " + '"@tdlType":"' + SFInt32(self.tdlType).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' + ',\n' if self.whichGeometry != 1: attributeResult += " " + '"@whichGeometry":"' + SFInt32(self.whichGeometry).JSON() + '"' + ',\n' if self.writeInterval != 1.0: attributeResult += " " + '"@writeInterval":"' + SFTime(self.writeInterval).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SignalPdu.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SignalPdu' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SignalPdu' + ' {' if self.address != 'localhost': result += '\n' + indent + ' ' + "address " + '"' + self.address + '"' + "" if self.applicationID != 0: result += '\n' + indent + ' ' + "applicationID " + SFInt32(self.applicationID).VRML() + "" if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.data != []: result += '\n' + indent + ' ' + "data " + MFInt32(self.data).VRML() + "" if self.dataLength != 0: result += '\n' + indent + ' ' + "dataLength " + SFInt32(self.dataLength).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.encodingScheme != 0: result += '\n' + indent + ' ' + "encodingScheme " + SFInt32(self.encodingScheme).VRML() + "" if self.entityID != 0: result += '\n' + indent + ' ' + "entityID " + SFInt32(self.entityID).VRML() + "" if self.geoCoords != (0, 0, 0): result += '\n' + indent + ' ' + "geoCoords " + SFVec3d(self.geoCoords).VRML() + "" if self.geoSystem != ["GD", "WE"]: result += '\n' + indent + ' ' + "geoSystem " + MFString(self.geoSystem).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.multicastRelayHost: result += '\n' + indent + ' ' + "multicastRelayHost " + '"' + self.multicastRelayHost + '"' + "" if self.multicastRelayPort != 0: result += '\n' + indent + ' ' + "multicastRelayPort " + SFInt32(self.multicastRelayPort).VRML() + "" if self.networkMode != 'standAlone': result += '\n' + indent + ' ' + "networkMode " + '"' + self.networkMode + '"' + "" if self.port != 0: result += '\n' + indent + ' ' + "port " + SFInt32(self.port).VRML() + "" if self.radioID != 0: result += '\n' + indent + ' ' + "radioID " + SFInt32(self.radioID).VRML() + "" if self.readInterval != 0.1: result += '\n' + indent + ' ' + "readInterval " + SFTime(self.readInterval).VRML() + "" if self.rtpHeaderExpected: # default=false result += '\n' + indent + ' ' + "rtpHeaderExpected " + SFBool(self.rtpHeaderExpected).VRML() + "" if self.sampleRate != 0: result += '\n' + indent + ' ' + "sampleRate " + SFInt32(self.sampleRate).VRML() + "" if self.samples != 0: result += '\n' + indent + ' ' + "samples " + SFInt32(self.samples).VRML() + "" if self.siteID != 0: result += '\n' + indent + ' ' + "siteID " + SFInt32(self.siteID).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.tdlType != 0: result += '\n' + indent + ' ' + "tdlType " + SFInt32(self.tdlType).VRML() + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.whichGeometry != 1: result += '\n' + indent + ' ' + "whichGeometry " + SFInt32(self.whichGeometry).VRML() + "" if self.writeInterval != 1.0: result += '\n' + indent + ' ' + "writeInterval " + SFTime(self.writeInterval).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SilhouetteEnhancementVolumeStyle(_X3DComposableVolumeRenderStyleNode): """ SilhouetteEnhancementVolumeStyle specifies that volumetric data is rendered with silhouette enhancement. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SilhouetteEnhancementVolumeStyle' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#SilhouetteEnhancementVolumeStyle' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SilhouetteEnhancementVolumeStyle' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeRenderStyleNode'), ('silhouetteBoundaryOpacity', 0, FieldType.SFFloat, AccessType.inputOutput, 'SilhouetteEnhancementVolumeStyle'), ('silhouetteRetainedOpacity', 1, FieldType.SFFloat, AccessType.inputOutput, 'SilhouetteEnhancementVolumeStyle'), ('silhouetteSharpness', 0.5, FieldType.SFFloat, AccessType.inputOutput, 'SilhouetteEnhancementVolumeStyle'), ('surfaceNormals', None, FieldType.SFNode, AccessType.inputOutput, 'SilhouetteEnhancementVolumeStyle'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, enabled=True, silhouetteBoundaryOpacity=0, silhouetteRetainedOpacity=1, silhouetteSharpness=0.5, surfaceNormals=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SilhouetteEnhancementVolumeStyle __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.enabled = enabled self.silhouetteBoundaryOpacity = silhouetteBoundaryOpacity self.silhouetteRetainedOpacity = silhouetteRetainedOpacity self.silhouetteSharpness = silhouetteSharpness self.surfaceNormals = surfaceNormals self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def silhouetteBoundaryOpacity(self): """[0,1] amount of the silhouette enhancement to use.""" return self.__silhouetteBoundaryOpacity @silhouetteBoundaryOpacity.setter def silhouetteBoundaryOpacity(self, silhouetteBoundaryOpacity): if silhouetteBoundaryOpacity is None: silhouetteBoundaryOpacity = 0 # default assertValidSFFloat(silhouetteBoundaryOpacity) assertZeroToOne('silhouetteBoundaryOpacity', silhouetteBoundaryOpacity) self.__silhouetteBoundaryOpacity = silhouetteBoundaryOpacity @property # getter - - - - - - - - - - def silhouetteRetainedOpacity(self): """[0,1] scaling of non-silhouette regions.""" return self.__silhouetteRetainedOpacity @silhouetteRetainedOpacity.setter def silhouetteRetainedOpacity(self, silhouetteRetainedOpacity): if silhouetteRetainedOpacity is None: silhouetteRetainedOpacity = 1 # default assertValidSFFloat(silhouetteRetainedOpacity) assertZeroToOne('silhouetteRetainedOpacity', silhouetteRetainedOpacity) self.__silhouetteRetainedOpacity = silhouetteRetainedOpacity @property # getter - - - - - - - - - - def silhouetteSharpness(self): """[0,+infinity) power function to control sharpness of the silhouette.""" return self.__silhouetteSharpness @silhouetteSharpness.setter def silhouetteSharpness(self, silhouetteSharpness): if silhouetteSharpness is None: silhouetteSharpness = 0.5 # default assertValidSFFloat(silhouetteSharpness) assertNonNegative('silhouetteSharpness', silhouetteSharpness) self.__silhouetteSharpness = silhouetteSharpness @property # getter - - - - - - - - - - def surfaceNormals(self): """[X3DTexture3DNode] The surfaceNormals field contains a 3D texture with at least three component values.""" return self.__surfaceNormals @surfaceNormals.setter def surfaceNormals(self, surfaceNormals): if surfaceNormals is None: surfaceNormals = None # default assertValidSFNode(surfaceNormals) if not surfaceNormals is None and not isinstance(surfaceNormals,(_X3DTexture3DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(surfaceNormals) + ' does not match required node type (_X3DTexture3DNode,ProtoInstance) and is invalid') self.__surfaceNormals = surfaceNormals @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.surfaceNormals # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SilhouetteEnhancementVolumeStyle.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SilhouetteEnhancementVolumeStyle.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SilhouetteEnhancementVolumeStyle":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.silhouetteBoundaryOpacity != 0: attributeResult += " " + '"@silhouetteBoundaryOpacity":"' + SFFloat(self.silhouetteBoundaryOpacity).JSON() + '"' + ',\n' if self.silhouetteRetainedOpacity != 1: attributeResult += " " + '"@silhouetteRetainedOpacity":"' + SFFloat(self.silhouetteRetainedOpacity).JSON() + '"' + ',\n' if self.silhouetteSharpness != 0.5: attributeResult += " " + '"@silhouetteSharpness":"' + SFFloat(self.silhouetteSharpness).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.surfaceNormals: # output this SFNode result += self.surfaceNormals.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SilhouetteEnhancementVolumeStyle.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SilhouetteEnhancementVolumeStyle' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SilhouetteEnhancementVolumeStyle' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.silhouetteBoundaryOpacity != 0: result += '\n' + indent + ' ' + "silhouetteBoundaryOpacity " + SFFloat(self.silhouetteBoundaryOpacity).VRML() + "" if self.silhouetteRetainedOpacity != 1: result += '\n' + indent + ' ' + "silhouetteRetainedOpacity " + SFFloat(self.silhouetteRetainedOpacity).VRML() + "" if self.silhouetteSharpness != 0.5: result += '\n' + indent + ' ' + "silhouetteSharpness " + SFFloat(self.silhouetteSharpness).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.surfaceNormals: # output this SFNode result += '\n' + ' ' + indent + 'surfaceNormals ' + self.surfaceNormals.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SingleAxisHingeJoint(_X3DRigidJointNode): """ SingleAxisHingeJoint has single axis about which to rotate, similar to a traditional door hinge. Contains two RigidBody nodes (containerField values body1, body2). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SingleAxisHingeJoint' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rigidBodyPhysics.html#SingleAxisHingeJoint' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SingleAxisHingeJoint' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('anchorPoint', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'SingleAxisHingeJoint'), ('axis', (0, 1, 0), FieldType.SFVec3f, AccessType.inputOutput, 'SingleAxisHingeJoint'), ('forceOutput', ["NONE"], FieldType.MFString, AccessType.inputOutput, 'X3DRigidJointNode'), ('maxAngle', 3.141592653, FieldType.SFFloat, AccessType.inputOutput, 'SingleAxisHingeJoint'), ('minAngle', -3.141592653, FieldType.SFFloat, AccessType.inputOutput, 'SingleAxisHingeJoint'), ('stopBounce', 0, FieldType.SFFloat, AccessType.inputOutput, 'SingleAxisHingeJoint'), ('stopErrorCorrection', 0.8, FieldType.SFFloat, AccessType.inputOutput, 'SingleAxisHingeJoint'), ('body1', None, FieldType.SFNode, AccessType.inputOutput, 'X3DRigidJointNode'), ('body2', None, FieldType.SFNode, AccessType.inputOutput, 'X3DRigidJointNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, anchorPoint=(0, 0, 0), axis=(0, 1, 0), forceOutput=None, maxAngle=3.141592653, minAngle=-3.141592653, stopBounce=0, stopErrorCorrection=0.8, body1=None, body2=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SingleAxisHingeJoint __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.anchorPoint = anchorPoint self.axis = axis self.forceOutput = forceOutput self.maxAngle = maxAngle self.minAngle = minAngle self.stopBounce = stopBounce self.stopErrorCorrection = stopErrorCorrection self.body1 = body1 self.body2 = body2 self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def anchorPoint(self): """anchorPoint is joint center, specified in world coordinates.""" return self.__anchorPoint @anchorPoint.setter def anchorPoint(self, anchorPoint): if anchorPoint is None: anchorPoint = (0, 0, 0) # default assertValidSFVec3f(anchorPoint) self.__anchorPoint = anchorPoint @property # getter - - - - - - - - - - def axis(self): """axis defines vector of joint connection between body1 and body2.""" return self.__axis @axis.setter def axis(self, axis): if axis is None: axis = (0, 1, 0) # default assertValidSFVec3f(axis) self.__axis = axis @property # getter - - - - - - - - - - def forceOutput(self): """forceOutput controls which output fields are generated for the next frame.""" return self.__forceOutput @forceOutput.setter def forceOutput(self, forceOutput): if forceOutput is None: forceOutput = ["NONE"] # default assertValidMFString(forceOutput) self.__forceOutput = forceOutput @property # getter - - - - - - - - - - def maxAngle(self): """[-pi,pi] maxAngle is maximum rotation angle for hinge.""" return self.__maxAngle @maxAngle.setter def maxAngle(self, maxAngle): if maxAngle is None: maxAngle = 3.141592653 # default assertValidSFFloat(maxAngle) self.__maxAngle = maxAngle @property # getter - - - - - - - - - - def minAngle(self): """[-pi,pi] minAngle is minimum rotation angle for hinge.""" return self.__minAngle @minAngle.setter def minAngle(self, minAngle): if minAngle is None: minAngle = -3.141592653 # default assertValidSFFloat(minAngle) self.__minAngle = minAngle @property # getter - - - - - - - - - - def stopBounce(self): """[0,1] stopBounce is velocity factor for bounce back once stop point is reached.""" return self.__stopBounce @stopBounce.setter def stopBounce(self, stopBounce): if stopBounce is None: stopBounce = 0 # default assertValidSFFloat(stopBounce) self.__stopBounce = stopBounce @property # getter - - - - - - - - - - def stopErrorCorrection(self): """[0,1] stopErrorCorrection is fraction of error correction performed during time step once stop point is reached.""" return self.__stopErrorCorrection @stopErrorCorrection.setter def stopErrorCorrection(self, stopErrorCorrection): if stopErrorCorrection is None: stopErrorCorrection = 0.8 # default assertValidSFFloat(stopErrorCorrection) self.__stopErrorCorrection = stopErrorCorrection @property # getter - - - - - - - - - - def body1(self): """[RigidBody] The body1 and body2 fields indicate the two RigidBody nodes connected by this joint.""" return self.__body1 @body1.setter def body1(self, body1): if body1 is None: body1 = None # default assertValidSFNode(body1) if not body1 is None and not isinstance(body1,(RigidBody,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(body1) + ' does not match required node type (RigidBody,ProtoInstance) and is invalid') self.__body1 = body1 @property # getter - - - - - - - - - - def body2(self): """[RigidBody] The body1 and body2 fields indicate the two RigidBody nodes connected by this joint.""" return self.__body2 @body2.setter def body2(self, body2): if body2 is None: body2 = None # default assertValidSFNode(body2) if not body2 is None and not isinstance(body2,(RigidBody,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(body2) + ' does not match required node type (RigidBody,ProtoInstance) and is invalid') self.__body2 = body2 @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.body1 or self.body2 or self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SingleAxisHingeJoint.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SingleAxisHingeJoint.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SingleAxisHingeJoint":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.anchorPoint != (0, 0, 0): attributeResult += " " + '"@anchorPoint":"' + SFVec3f(self.anchorPoint).JSON() + '"' + ',\n' if self.axis != (0, 1, 0): attributeResult += " " + '"@axis":"' + SFVec3f(self.axis).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.forceOutput != ["NONE"]: attributeResult += " " + '"@forceOutput":"' + MFString(self.forceOutput).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.maxAngle != 3.141592653: attributeResult += " " + '"@maxAngle":"' + SFFloat(self.maxAngle).JSON() + '"' + ',\n' if self.minAngle != -3.141592653: attributeResult += " " + '"@minAngle":"' + SFFloat(self.minAngle).JSON() + '"' + ',\n' if self.stopBounce != 0: attributeResult += " " + '"@stopBounce":"' + SFFloat(self.stopBounce).JSON() + '"' + ',\n' if self.stopErrorCorrection != 0.8: attributeResult += " " + '"@stopErrorCorrection":"' + SFFloat(self.stopErrorCorrection).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.body1: # output this SFNode result += self.body1.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.body2: # output this SFNode result += self.body2.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SingleAxisHingeJoint.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SingleAxisHingeJoint' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SingleAxisHingeJoint' + ' {' if self.anchorPoint != (0, 0, 0): result += '\n' + indent + ' ' + "anchorPoint " + SFVec3f(self.anchorPoint).VRML() + "" if self.axis != (0, 1, 0): result += '\n' + indent + ' ' + "axis " + SFVec3f(self.axis).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.forceOutput != ["NONE"]: result += '\n' + indent + ' ' + "forceOutput " + MFString(self.forceOutput).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.maxAngle != 3.141592653: result += '\n' + indent + ' ' + "maxAngle " + SFFloat(self.maxAngle).VRML() + "" if self.minAngle != -3.141592653: result += '\n' + indent + ' ' + "minAngle " + SFFloat(self.minAngle).VRML() + "" if self.stopBounce != 0: result += '\n' + indent + ' ' + "stopBounce " + SFFloat(self.stopBounce).VRML() + "" if self.stopErrorCorrection != 0.8: result += '\n' + indent + ' ' + "stopErrorCorrection " + SFFloat(self.stopErrorCorrection).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.body1: # output this SFNode result += '\n' + ' ' + indent + 'body1 ' + self.body1.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.body2: # output this SFNode result += '\n' + ' ' + indent + 'body2 ' + self.body2.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SliderJoint(_X3DRigidJointNode): """ SliderJoint constrains all movement between body1 and body2 along a single axis. Contains two RigidBody nodes (containerField values body1, body2). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SliderJoint' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rigidBodyPhysics.html#SliderJoint' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SliderJoint' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('axis', (0, 1, 0), FieldType.SFVec3f, AccessType.inputOutput, 'SliderJoint'), ('forceOutput', ["NONE"], FieldType.MFString, AccessType.inputOutput, 'X3DRigidJointNode'), ('maxSeparation', 1, FieldType.SFFloat, AccessType.inputOutput, 'SliderJoint'), ('minSeparation', 0, FieldType.SFFloat, AccessType.inputOutput, 'SliderJoint'), ('sliderForce', 0, FieldType.SFFloat, AccessType.inputOutput, 'SliderJoint'), ('stopBounce', 0, FieldType.SFFloat, AccessType.inputOutput, 'SliderJoint'), ('stopErrorCorrection', 1, FieldType.SFFloat, AccessType.inputOutput, 'SliderJoint'), ('body1', None, FieldType.SFNode, AccessType.inputOutput, 'X3DRigidJointNode'), ('body2', None, FieldType.SFNode, AccessType.inputOutput, 'X3DRigidJointNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, axis=(0, 1, 0), forceOutput=None, maxSeparation=1, minSeparation=0, sliderForce=0, stopBounce=0, stopErrorCorrection=1, body1=None, body2=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SliderJoint __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.axis = axis self.forceOutput = forceOutput self.maxSeparation = maxSeparation self.minSeparation = minSeparation self.sliderForce = sliderForce self.stopBounce = stopBounce self.stopErrorCorrection = stopErrorCorrection self.body1 = body1 self.body2 = body2 self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def axis(self): """[0,1] axis is normalized vector specifying direction of motion.""" return self.__axis @axis.setter def axis(self, axis): if axis is None: axis = (0, 1, 0) # default assertValidSFVec3f(axis) self.__axis = axis @property # getter - - - - - - - - - - def forceOutput(self): """forceOutput controls which output fields are generated for the next frame.""" return self.__forceOutput @forceOutput.setter def forceOutput(self, forceOutput): if forceOutput is None: forceOutput = ["NONE"] # default assertValidMFString(forceOutput) self.__forceOutput = forceOutput @property # getter - - - - - - - - - - def maxSeparation(self): """maxSeparation is maximum separation distance between the two bodies.""" return self.__maxSeparation @maxSeparation.setter def maxSeparation(self, maxSeparation): if maxSeparation is None: maxSeparation = 1 # default assertValidSFFloat(maxSeparation) self.__maxSeparation = maxSeparation @property # getter - - - - - - - - - - def minSeparation(self): """minSeparation is minimum separation distance between the two bodies.""" return self.__minSeparation @minSeparation.setter def minSeparation(self, minSeparation): if minSeparation is None: minSeparation = 0 # default assertValidSFFloat(minSeparation) self.__minSeparation = minSeparation @property # getter - - - - - - - - - - def sliderForce(self): """[-infinity,infinity] sliderForce value is used to apply a force (specified in force base units) along the axis of the slider in equal and opposite directions to the two bodies.""" return self.__sliderForce @sliderForce.setter def sliderForce(self, sliderForce): if sliderForce is None: sliderForce = 0 # default assertValidSFFloat(sliderForce) self.__sliderForce = sliderForce @property # getter - - - - - - - - - - def stopBounce(self): """[0,1] stopBounce is velocity factor for bounce back once stop point is reached.""" return self.__stopBounce @stopBounce.setter def stopBounce(self, stopBounce): if stopBounce is None: stopBounce = 0 # default assertValidSFFloat(stopBounce) self.__stopBounce = stopBounce @property # getter - - - - - - - - - - def stopErrorCorrection(self): """[0,1] stopErrorCorrection is fraction of error correction performed during time step once stop point is reached.""" return self.__stopErrorCorrection @stopErrorCorrection.setter def stopErrorCorrection(self, stopErrorCorrection): if stopErrorCorrection is None: stopErrorCorrection = 1 # default assertValidSFFloat(stopErrorCorrection) self.__stopErrorCorrection = stopErrorCorrection @property # getter - - - - - - - - - - def body1(self): """[RigidBody] The body1 and body2 fields indicate the two RigidBody nodes connected by this joint.""" return self.__body1 @body1.setter def body1(self, body1): if body1 is None: body1 = None # default assertValidSFNode(body1) if not body1 is None and not isinstance(body1,(RigidBody,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(body1) + ' does not match required node type (RigidBody,ProtoInstance) and is invalid') self.__body1 = body1 @property # getter - - - - - - - - - - def body2(self): """[RigidBody] The body1 and body2 fields indicate the two RigidBody nodes connected by this joint.""" return self.__body2 @body2.setter def body2(self, body2): if body2 is None: body2 = None # default assertValidSFNode(body2) if not body2 is None and not isinstance(body2,(RigidBody,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(body2) + ' does not match required node type (RigidBody,ProtoInstance) and is invalid') self.__body2 = body2 @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.body1 or self.body2 or self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SliderJoint.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SliderJoint.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SliderJoint":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.axis != (0, 1, 0): attributeResult += " " + '"@axis":"' + SFVec3f(self.axis).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.forceOutput != ["NONE"]: attributeResult += " " + '"@forceOutput":"' + MFString(self.forceOutput).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.maxSeparation != 1: attributeResult += " " + '"@maxSeparation":"' + SFFloat(self.maxSeparation).JSON() + '"' + ',\n' if self.minSeparation != 0: attributeResult += " " + '"@minSeparation":"' + SFFloat(self.minSeparation).JSON() + '"' + ',\n' if self.sliderForce != 0: attributeResult += " " + '"@sliderForce":"' + SFFloat(self.sliderForce).JSON() + '"' + ',\n' if self.stopBounce != 0: attributeResult += " " + '"@stopBounce":"' + SFFloat(self.stopBounce).JSON() + '"' + ',\n' if self.stopErrorCorrection != 1: attributeResult += " " + '"@stopErrorCorrection":"' + SFFloat(self.stopErrorCorrection).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.body1: # output this SFNode result += self.body1.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.body2: # output this SFNode result += self.body2.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SliderJoint.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SliderJoint' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SliderJoint' + ' {' if self.axis != (0, 1, 0): result += '\n' + indent + ' ' + "axis " + SFVec3f(self.axis).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.forceOutput != ["NONE"]: result += '\n' + indent + ' ' + "forceOutput " + MFString(self.forceOutput).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.maxSeparation != 1: result += '\n' + indent + ' ' + "maxSeparation " + SFFloat(self.maxSeparation).VRML() + "" if self.minSeparation != 0: result += '\n' + indent + ' ' + "minSeparation " + SFFloat(self.minSeparation).VRML() + "" if self.sliderForce != 0: result += '\n' + indent + ' ' + "sliderForce " + SFFloat(self.sliderForce).VRML() + "" if self.stopBounce != 0: result += '\n' + indent + ' ' + "stopBounce " + SFFloat(self.stopBounce).VRML() + "" if self.stopErrorCorrection != 1: result += '\n' + indent + ' ' + "stopErrorCorrection " + SFFloat(self.stopErrorCorrection).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.body1: # output this SFNode result += '\n' + ' ' + indent + 'body1 ' + self.body1.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.body2: # output this SFNode result += '\n' + ' ' + indent + 'body2 ' + self.body2.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Sound(_X3DSoundNode): """ The Sound node controls the 3D spatialization of sound playback by a child AudioClip or MovieTexture node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Sound' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#Sound' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Sound' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSoundNode'), ('direction', (0, 0, 1), FieldType.SFVec3f, AccessType.inputOutput, 'Sound'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSoundNode'), ('intensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'Sound'), ('location', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'Sound'), ('maxBack', 10, FieldType.SFFloat, AccessType.inputOutput, 'Sound'), ('maxFront', 10, FieldType.SFFloat, AccessType.inputOutput, 'Sound'), ('minBack', 1, FieldType.SFFloat, AccessType.inputOutput, 'Sound'), ('minFront', 1, FieldType.SFFloat, AccessType.inputOutput, 'Sound'), ('priority', 0, FieldType.SFFloat, AccessType.inputOutput, 'Sound'), ('spatialize', True, FieldType.SFBool, AccessType.initializeOnly, 'Sound'), ('source', None, FieldType.SFNode, AccessType.inputOutput, 'Sound'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, description='', direction=(0, 0, 1), enabled=True, intensity=1, location=(0, 0, 0), maxBack=10, maxFront=10, minBack=1, minFront=1, priority=0, spatialize=True, source=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Sound __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.description = description self.direction = direction self.enabled = enabled self.intensity = intensity self.location = location self.maxBack = maxBack self.maxFront = maxFront self.minBack = minBack self.minFront = minFront self.priority = priority self.spatialize = spatialize self.source = source self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of this node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def direction(self): """direction of sound axis, relative to local coordinate system.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (0, 0, 1) # default assertValidSFVec3f(direction) self.__direction = direction @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def intensity(self): """Factor [0,1] adjusting loudness (decibels) of emitted sound.""" return self.__intensity @intensity.setter def intensity(self, intensity): if intensity is None: intensity = 1 # default assertValidSFFloat(intensity) assertZeroToOne('intensity', intensity) self.__intensity = intensity @property # getter - - - - - - - - - - def location(self): """Position of sound ellipsoid center, relative to local coordinate system.""" return self.__location @location.setter def location(self, location): if location is None: location = (0, 0, 0) # default assertValidSFVec3f(location) self.__location = location @property # getter - - - - - - - - - - def maxBack(self): """Outer (zero loudness)ellipsoid distance along back direction.""" return self.__maxBack @maxBack.setter def maxBack(self, maxBack): if maxBack is None: maxBack = 10 # default assertValidSFFloat(maxBack) assertNonNegative('maxBack', maxBack) self.__maxBack = maxBack @property # getter - - - - - - - - - - def maxFront(self): """Outer (zero loudness)ellipsoid distance along front direction.""" return self.__maxFront @maxFront.setter def maxFront(self, maxFront): if maxFront is None: maxFront = 10 # default assertValidSFFloat(maxFront) assertNonNegative('maxFront', maxFront) self.__maxFront = maxFront @property # getter - - - - - - - - - - def minBack(self): """Inner (full loudness) ellipsoid distance along back direction.""" return self.__minBack @minBack.setter def minBack(self, minBack): if minBack is None: minBack = 1 # default assertValidSFFloat(minBack) assertNonNegative('minBack', minBack) self.__minBack = minBack @property # getter - - - - - - - - - - def minFront(self): """Inner (full loudness) ellipsoid distance along front direction.""" return self.__minFront @minFront.setter def minFront(self, minFront): if minFront is None: minFront = 1 # default assertValidSFFloat(minFront) assertNonNegative('minFront', minFront) self.__minFront = minFront @property # getter - - - - - - - - - - def priority(self): """Player hint [0,1] if needed to choose which sounds to play.""" return self.__priority @priority.setter def priority(self, priority): if priority is None: priority = 0 # default assertValidSFFloat(priority) assertZeroToOne('priority', priority) self.__priority = priority @property # getter - - - - - - - - - - def spatialize(self): """Whether to spatialize sound playback relative to viewer.""" return self.__spatialize @spatialize.setter def spatialize(self, spatialize): if spatialize is None: spatialize = True # default assertValidSFBool(spatialize) self.__spatialize = spatialize @property # getter - - - - - - - - - - def source(self): """[X3DSoundSourceNode] sound source for the Sound node, either an AudioClip node or a MovieTexture node.""" return self.__source @source.setter def source(self, source): if source is None: source = None # default assertValidSFNode(source) if not source is None and not isinstance(source,(_X3DSoundSourceNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(source) + ' does not match required node type (_X3DSoundSourceNode,ProtoInstance) and is invalid') self.__source = source @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.source # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Sound.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Sound.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Sound":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.direction != (0, 0, 1): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.intensity != 1: attributeResult += " " + '"@intensity":"' + SFFloat(self.intensity).JSON() + '"' + ',\n' if self.location != (0, 0, 0): attributeResult += " " + '"@location":"' + SFVec3f(self.location).JSON() + '"' + ',\n' if self.maxBack != 10: attributeResult += " " + '"@maxBack":"' + SFFloat(self.maxBack).JSON() + '"' + ',\n' if self.maxFront != 10: attributeResult += " " + '"@maxFront":"' + SFFloat(self.maxFront).JSON() + '"' + ',\n' if self.minBack != 1: attributeResult += " " + '"@minBack":"' + SFFloat(self.minBack).JSON() + '"' + ',\n' if self.minFront != 1: attributeResult += " " + '"@minFront":"' + SFFloat(self.minFront).JSON() + '"' + ',\n' if self.priority != 0: attributeResult += " " + '"@priority":"' + SFFloat(self.priority).JSON() + '"' + ',\n' if not self.spatialize: # default=true attributeResult += " " + '"@spatialize":"' + SFBool(self.spatialize).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.source: # output this SFNode result += self.source.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Sound.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Sound' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Sound' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.direction != (0, 0, 1): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.intensity != 1: result += '\n' + indent + ' ' + "intensity " + SFFloat(self.intensity).VRML() + "" if self.location != (0, 0, 0): result += '\n' + indent + ' ' + "location " + SFVec3f(self.location).VRML() + "" if self.maxBack != 10: result += '\n' + indent + ' ' + "maxBack " + SFFloat(self.maxBack).VRML() + "" if self.maxFront != 10: result += '\n' + indent + ' ' + "maxFront " + SFFloat(self.maxFront).VRML() + "" if self.minBack != 1: result += '\n' + indent + ' ' + "minBack " + SFFloat(self.minBack).VRML() + "" if self.minFront != 1: result += '\n' + indent + ' ' + "minFront " + SFFloat(self.minFront).VRML() + "" if self.priority != 0: result += '\n' + indent + ' ' + "priority " + SFFloat(self.priority).VRML() + "" if not self.spatialize: # default=true result += '\n' + indent + ' ' + "spatialize " + SFBool(self.spatialize).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.source: # output this SFNode result += '\n' + ' ' + indent + 'source ' + self.source.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SpatialSound(_X3DSoundNode): """ The SpatialSound node controls the 3D spatialization of sound playback by a child AudioClip or MovieTexture node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SpatialSound' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#Sound' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SpatialSound' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('coneInnerAngle', 6.2832, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('coneOuterAngle', 6.2832, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('coneOuterGain', 0, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSoundNode'), ('direction', (0, 0, 1), FieldType.SFVec3f, AccessType.inputOutput, 'SpatialSound'), ('distanceModel', 'INVERSE', FieldType.SFString, AccessType.inputOutput, 'SpatialSound'), ('dopplerEnabled', False, FieldType.SFBool, AccessType.inputOutput, 'SpatialSound'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSoundNode'), ('enableHRTF', False, FieldType.SFBool, AccessType.inputOutput, 'SpatialSound'), ('gain', 1, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('intensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('location', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'SpatialSound'), ('maxDistance', 10000, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('priority', 0, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('referenceDistance', 1, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('rolloffFactor', 1, FieldType.SFFloat, AccessType.inputOutput, 'SpatialSound'), ('spatialize', True, FieldType.SFBool, AccessType.initializeOnly, 'SpatialSound'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'SpatialSound'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, coneInnerAngle=6.2832, coneOuterAngle=6.2832, coneOuterGain=0, description='', direction=(0, 0, 1), distanceModel='INVERSE', dopplerEnabled=False, enabled=True, enableHRTF=False, gain=1, intensity=1, location=(0, 0, 0), maxDistance=10000, priority=0, referenceDistance=1, rolloffFactor=1, spatialize=True, children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SpatialSound __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.coneInnerAngle = coneInnerAngle self.coneOuterAngle = coneOuterAngle self.coneOuterGain = coneOuterGain self.description = description self.direction = direction self.distanceModel = distanceModel self.dopplerEnabled = dopplerEnabled self.enabled = enabled self.enableHRTF = enableHRTF self.gain = gain self.intensity = intensity self.location = location self.maxDistance = maxDistance self.priority = priority self.referenceDistance = referenceDistance self.rolloffFactor = rolloffFactor self.spatialize = spatialize self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def coneInnerAngle(self): """[0,2pi] coneInnerAngle is centered along direction and defines the inner conical volume, inside of which no source gain reduction occurs.""" return self.__coneInnerAngle @coneInnerAngle.setter def coneInnerAngle(self, coneInnerAngle): if coneInnerAngle is None: coneInnerAngle = 6.2832 # default assertValidSFFloat(coneInnerAngle) assertGreaterThanEquals('coneInnerAngle', coneInnerAngle, 0) assertLessThanEquals('coneInnerAngle', coneInnerAngle, 6.2832) self.__coneInnerAngle = coneInnerAngle @property # getter - - - - - - - - - - def coneOuterAngle(self): """[0,2pi] coneOuterAngle is centered along direction and defines an outer conical volume, within which the sound gain decreases linearly from full gain to coneOuterGain.""" return self.__coneOuterAngle @coneOuterAngle.setter def coneOuterAngle(self, coneOuterAngle): if coneOuterAngle is None: coneOuterAngle = 6.2832 # default assertValidSFFloat(coneOuterAngle) assertGreaterThanEquals('coneOuterAngle', coneOuterAngle, 0) assertLessThanEquals('coneOuterAngle', coneOuterAngle, 6.2832) self.__coneOuterAngle = coneOuterAngle @property # getter - - - - - - - - - - def coneOuterGain(self): """(-infinity,+infinity) coneOuterGain is minimum gain value found outside coneOuterAngle.""" return self.__coneOuterGain @coneOuterGain.setter def coneOuterGain(self, coneOuterGain): if coneOuterGain is None: coneOuterGain = 0 # default assertValidSFFloat(coneOuterGain) self.__coneOuterGain = coneOuterGain @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def direction(self): """direction of sound axis, relative to local coordinate system.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (0, 0, 1) # default assertValidSFVec3f(direction) self.__direction = direction @property # getter - - - - - - - - - - def distanceModel(self): """distanceModel determines how field specifies which algorithm to use for sound attenuation, corresponding to distance between an audio source and a listener, as it moves away from the listener.""" return self.__distanceModel @distanceModel.setter def distanceModel(self, distanceModel): if distanceModel is None: distanceModel = 'INVERSE' # default assertValidSFString(distanceModel) assertValidDistanceModel('distanceModel', distanceModel) self.__distanceModel = distanceModel @property # getter - - - - - - - - - - def dopplerEnabled(self): """dopplerEnabled enables/disables whether real-time Doppler effects (due to relation motion between sources and listeners) are computed by browser between virtual sound sources and active listening locations, then applied to received frequency at active listening locations.""" return self.__dopplerEnabled @dopplerEnabled.setter def dopplerEnabled(self, dopplerEnabled): if dopplerEnabled is None: dopplerEnabled = False # default assertValidSFBool(dopplerEnabled) self.__dopplerEnabled = dopplerEnabled @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def enableHRTF(self): """enableHRTF enables/disables Head Related Transfer Function (HRTF) auralization, if available.""" return self.__enableHRTF @enableHRTF.setter def enableHRTF(self, enableHRTF): if enableHRTF is None: enableHRTF = False # default assertValidSFBool(enableHRTF) self.__enableHRTF = enableHRTF @property # getter - - - - - - - - - - def gain(self): """(-infinity,+infinity) The gain field is a factor that represents the amount of linear amplification to apply to the output of the node.""" return self.__gain @gain.setter def gain(self, gain): if gain is None: gain = 1 # default assertValidSFFloat(gain) self.__gain = gain @property # getter - - - - - - - - - - def intensity(self): """Factor [0,1] adjusting loudness (decibels) of emitted sound.""" return self.__intensity @intensity.setter def intensity(self, intensity): if intensity is None: intensity = 1 # default assertValidSFFloat(intensity) assertZeroToOne('intensity', intensity) self.__intensity = intensity @property # getter - - - - - - - - - - def location(self): """[0,+infinity) Position of sound ellipsoid center, relative to local coordinate system.""" return self.__location @location.setter def location(self, location): if location is None: location = (0, 0, 0) # default assertValidSFVec3f(location) self.__location = location @property # getter - - - - - - - - - - def maxDistance(self): """[0,+infinity) maxDistance is the maximum distance where sound is renderable between source and listener, after which no reduction in sound volume occurs.""" return self.__maxDistance @maxDistance.setter def maxDistance(self, maxDistance): if maxDistance is None: maxDistance = 10000 # default assertValidSFFloat(maxDistance) assertNonNegative('maxDistance', maxDistance) self.__maxDistance = maxDistance @property # getter - - - - - - - - - - def priority(self): """Player hint [0,1] if needed to choose which sounds to play.""" return self.__priority @priority.setter def priority(self, priority): if priority is None: priority = 0 # default assertValidSFFloat(priority) assertZeroToOne('priority', priority) self.__priority = priority @property # getter - - - - - - - - - - def referenceDistance(self): """[0,+infinity) referenceDistance for reducing volume as source moves further from the listener.""" return self.__referenceDistance @referenceDistance.setter def referenceDistance(self, referenceDistance): if referenceDistance is None: referenceDistance = 1 # default assertValidSFFloat(referenceDistance) assertNonNegative('referenceDistance', referenceDistance) self.__referenceDistance = referenceDistance @property # getter - - - - - - - - - - def rolloffFactor(self): """[0,+infinity) rolloffFactor indicates how quickly volume is reduced as source moves further from listener.""" return self.__rolloffFactor @rolloffFactor.setter def rolloffFactor(self, rolloffFactor): if rolloffFactor is None: rolloffFactor = 1 # default assertValidSFFloat(rolloffFactor) assertNonNegative('rolloffFactor', rolloffFactor) self.__rolloffFactor = rolloffFactor @property # getter - - - - - - - - - - def spatialize(self): """Whether to spatialize sound playback relative to viewer.""" return self.__spatialize @spatialize.setter def spatialize(self, spatialize): if spatialize is None: spatialize = True # default assertValidSFBool(spatialize) self.__spatialize = spatialize @property # getter - - - - - - - - - - def children(self): """[X3DSoundChannelNode|X3DSoundProcessingNode|X3DSoundSourceNode] The children field specifies audio-graph sound sources providing input signals for this node.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SpatialSound.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SpatialSound.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SpatialSound":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.coneInnerAngle != 6.2832: attributeResult += " " + '"@coneInnerAngle":"' + SFFloat(self.coneInnerAngle).JSON() + '"' + ',\n' if self.coneOuterAngle != 6.2832: attributeResult += " " + '"@coneOuterAngle":"' + SFFloat(self.coneOuterAngle).JSON() + '"' + ',\n' if self.coneOuterGain != 0: attributeResult += " " + '"@coneOuterGain":"' + SFFloat(self.coneOuterGain).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.direction != (0, 0, 1): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if self.distanceModel != 'INVERSE': attributeResult += " " + '"@distanceModel":"' + SFString(self.distanceModel).JSON() + '"' + ',\n' if self.dopplerEnabled: # default=false attributeResult += " " + '"@dopplerEnabled":"' + SFBool(self.dopplerEnabled).JSON() + '"' + ',\n' if self.enableHRTF: # default=false attributeResult += " " + '"@enableHRTF":"' + SFBool(self.enableHRTF).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.gain != 1: attributeResult += " " + '"@gain":"' + SFFloat(self.gain).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.intensity != 1: attributeResult += " " + '"@intensity":"' + SFFloat(self.intensity).JSON() + '"' + ',\n' if self.location != (0, 0, 0): attributeResult += " " + '"@location":"' + SFVec3f(self.location).JSON() + '"' + ',\n' if self.maxDistance != 10000: attributeResult += " " + '"@maxDistance":"' + SFFloat(self.maxDistance).JSON() + '"' + ',\n' if self.priority != 0: attributeResult += " " + '"@priority":"' + SFFloat(self.priority).JSON() + '"' + ',\n' if self.referenceDistance != 1: attributeResult += " " + '"@referenceDistance":"' + SFFloat(self.referenceDistance).JSON() + '"' + ',\n' if self.rolloffFactor != 1: attributeResult += " " + '"@rolloffFactor":"' + SFFloat(self.rolloffFactor).JSON() + '"' + ',\n' if not self.spatialize: # default=true attributeResult += " " + '"@spatialize":"' + SFBool(self.spatialize).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* SpatialSound found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SpatialSound.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SpatialSound' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SpatialSound' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.coneInnerAngle != 6.2832: result += '\n' + indent + ' ' + "coneInnerAngle " + SFFloat(self.coneInnerAngle).VRML() + "" if self.coneOuterAngle != 6.2832: result += '\n' + indent + ' ' + "coneOuterAngle " + SFFloat(self.coneOuterAngle).VRML() + "" if self.coneOuterGain != 0: result += '\n' + indent + ' ' + "coneOuterGain " + SFFloat(self.coneOuterGain).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.direction != (0, 0, 1): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if self.distanceModel != 'INVERSE': result += '\n' + indent + ' ' + "distanceModel " + '"' + self.distanceModel + '"' + "" if self.dopplerEnabled: # default=false result += '\n' + indent + ' ' + "dopplerEnabled " + SFBool(self.dopplerEnabled).VRML() + "" if self.enableHRTF: # default=false result += '\n' + indent + ' ' + "enableHRTF " + SFBool(self.enableHRTF).VRML() + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.gain != 1: result += '\n' + indent + ' ' + "gain " + SFFloat(self.gain).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.intensity != 1: result += '\n' + indent + ' ' + "intensity " + SFFloat(self.intensity).VRML() + "" if self.location != (0, 0, 0): result += '\n' + indent + ' ' + "location " + SFVec3f(self.location).VRML() + "" if self.maxDistance != 10000: result += '\n' + indent + ' ' + "maxDistance " + SFFloat(self.maxDistance).VRML() + "" if self.priority != 0: result += '\n' + indent + ' ' + "priority " + SFFloat(self.priority).VRML() + "" if self.referenceDistance != 1: result += '\n' + indent + ' ' + "referenceDistance " + SFFloat(self.referenceDistance).VRML() + "" if self.rolloffFactor != 1: result += '\n' + indent + ' ' + "rolloffFactor " + SFFloat(self.rolloffFactor).VRML() + "" if not self.spatialize: # default=true result += '\n' + indent + ' ' + "spatialize " + SFBool(self.spatialize).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Sphere(_X3DGeometryNode): """ Sphere is a geometry node, representing a perfectly round geometrical object that is the surface of a completely round ball. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Sphere' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/geometry3D.html#Sphere' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Sphere' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('radius', 1, FieldType.SFFloat, AccessType.initializeOnly, 'Sphere'), ('solid', True, FieldType.SFBool, AccessType.inputOutput, 'Sphere'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, radius=1, solid=True, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Sphere __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.radius = radius self.solid = solid self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def radius(self): """(0,+infinity) Size in meters.""" return self.__radius @radius.setter def radius(self, radius): if radius is None: radius = 1 # default assertValidSFFloat(radius) assertPositive('radius', radius) self.__radius = radius @property # getter - - - - - - - - - - def solid(self): """Setting solid true means draw only one side of polygons (backface culling on), setting solid false means draw both sides of polygons (backface culling off).""" return self.__solid @solid.setter def solid(self, solid): if solid is None: solid = True # default assertValidSFBool(solid) self.__solid = solid @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Sphere.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Sphere.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Sphere":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.radius != 1: attributeResult += " " + '"@radius":"' + SFFloat(self.radius).JSON() + '"' + ',\n' if not self.solid: # default=true attributeResult += " " + '"@solid":"' + SFBool(self.solid).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Sphere.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Sphere' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Sphere' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.radius != 1: result += '\n' + indent + ' ' + "radius " + SFFloat(self.radius).VRML() + "" if not self.solid: # default=true result += '\n' + indent + ' ' + "solid " + SFBool(self.solid).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SphereSensor(_X3DDragSensorNode): """ SphereSensor converts pointing device motion into a spherical rotation about the origin of the local coordinate system. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SphereSensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/pointingDeviceSensor.html#SphereSensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SphereSensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('autoOffset', True, FieldType.SFBool, AccessType.inputOutput, 'X3DDragSensorNode'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('offset', (0, 1, 0, 0), FieldType.SFRotation, AccessType.inputOutput, 'SphereSensor'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, autoOffset=True, description='', enabled=True, offset=(0, 1, 0, 0), DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SphereSensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.autoOffset = autoOffset self.description = description self.enabled = enabled self.offset = offset self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def autoOffset(self): """Determines whether previous offset values are remembered/accumulated.""" return self.__autoOffset @autoOffset.setter def autoOffset(self, autoOffset): if autoOffset is None: autoOffset = True # default assertValidSFBool(autoOffset) self.__autoOffset = autoOffset @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of this node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def offset(self): """Sends event and remembers last value sensed.""" return self.__offset @offset.setter def offset(self, offset): if offset is None: offset = (0, 1, 0, 0) # default assertValidSFRotation(offset) self.__offset = offset @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SphereSensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SphereSensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SphereSensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if not self.autoOffset: # default=true attributeResult += " " + '"@autoOffset":"' + SFBool(self.autoOffset).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.offset != (0, 1, 0, 0): attributeResult += " " + '"@offset":"' + SFRotation(self.offset).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SphereSensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SphereSensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SphereSensor' + ' {' if not self.autoOffset: # default=true result += '\n' + indent + ' ' + "autoOffset " + SFBool(self.autoOffset).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.offset != (0, 1, 0, 0): result += '\n' + indent + ' ' + "offset " + SFRotation(self.offset).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SplinePositionInterpolator(_X3DInterpolatorNode): """ SplinePositionInterpolator performs non-linear interpolation among paired lists of 3-tuple values and velocities to produce an SFVec3f value_changed output event. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SplinePositionInterpolator' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/interpolators.html#SplinePositionInterpolator' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SplinePositionInterpolator' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('closed', False, FieldType.SFBool, AccessType.initializeOnly, 'SplinePositionInterpolator'), ('key', [], FieldType.MFFloat, AccessType.inputOutput, 'X3DInterpolatorNode'), ('keyValue', [], FieldType.MFVec3f, AccessType.inputOutput, 'SplinePositionInterpolator'), ('keyVelocity', [], FieldType.MFVec3f, AccessType.inputOutput, 'SplinePositionInterpolator'), ('normalizeVelocity', False, FieldType.SFBool, AccessType.inputOutput, 'SplinePositionInterpolator'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, closed=False, key=None, keyValue=None, keyVelocity=None, normalizeVelocity=False, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SplinePositionInterpolator __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.closed = closed self.key = key self.keyValue = keyValue self.keyVelocity = keyVelocity self.normalizeVelocity = normalizeVelocity self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def closed(self): """Whether or not the curve is closed (i.""" return self.__closed @closed.setter def closed(self, closed): if closed is None: closed = False # default assertValidSFBool(closed) self.__closed = closed @property # getter - - - - - - - - - - def key(self): """Definition parameters for nonlinear-interpolation function time intervals, listed in non-decreasing order and corresponding to keyValue, keyVelocity array values.""" return self.__key @key.setter def key(self, key): if key is None: key = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(key) self.__key = key @property # getter - - - - - - - - - - def keyValue(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyValue @keyValue.setter def keyValue(self, keyValue): if keyValue is None: keyValue = MFVec3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec3f.DEFAULT_VALUE()=' + str(MFVec3f.DEFAULT_VALUE())) assertValidMFVec3f(keyValue) self.__keyValue = keyValue @property # getter - - - - - - - - - - def keyVelocity(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyVelocity @keyVelocity.setter def keyVelocity(self, keyVelocity): if keyVelocity is None: keyVelocity = MFVec3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec3f.DEFAULT_VALUE()=' + str(MFVec3f.DEFAULT_VALUE())) assertValidMFVec3f(keyVelocity) self.__keyVelocity = keyVelocity @property # getter - - - - - - - - - - def normalizeVelocity(self): """normalizeVelocity field specifies whether the velocity vectors are normalized to produce smooth speed transitions, or transformed into tangency vectors.""" return self.__normalizeVelocity @normalizeVelocity.setter def normalizeVelocity(self, normalizeVelocity): if normalizeVelocity is None: normalizeVelocity = False # default assertValidSFBool(normalizeVelocity) self.__normalizeVelocity = normalizeVelocity @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SplinePositionInterpolator.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SplinePositionInterpolator.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SplinePositionInterpolator":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.closed: # default=false attributeResult += " " + '"@closed":"' + SFBool(self.closed).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.key != []: attributeResult += " " + '"@key":"' + MFFloat(self.key).JSON() + '"' + ',\n' if self.keyValue != []: attributeResult += " " + '"@keyValue":"' + MFVec3f(self.keyValue).JSON() + '"' + ',\n' if self.keyVelocity != []: attributeResult += " " + '"@keyVelocity":"' + MFVec3f(self.keyVelocity).JSON() + '"' + ',\n' if self.normalizeVelocity: # default=false attributeResult += " " + '"@normalizeVelocity":"' + SFBool(self.normalizeVelocity).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SplinePositionInterpolator.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SplinePositionInterpolator' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SplinePositionInterpolator' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.closed: # default=false result += '\n' + indent + ' ' + "closed " + SFBool(self.closed).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.key != []: result += '\n' + indent + ' ' + "key " + MFFloat(self.key).VRML() + "" if self.keyValue != []: result += '\n' + indent + ' ' + "keyValue " + MFVec3f(self.keyValue).VRML() + "" if self.keyVelocity != []: result += '\n' + indent + ' ' + "keyVelocity " + MFVec3f(self.keyVelocity).VRML() + "" if self.normalizeVelocity: # default=false result += '\n' + indent + ' ' + "normalizeVelocity " + SFBool(self.normalizeVelocity).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SplinePositionInterpolator2D(_X3DInterpolatorNode): """ SplinePositionInterpolator2D performs non-linear interpolation among paired lists of 2-tuple values and velocities to produce an SFVec2f value_changed output event. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SplinePositionInterpolator2D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/interpolators.html#SplinePositionInterpolator2D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SplinePositionInterpolator2D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('closed', False, FieldType.SFBool, AccessType.initializeOnly, 'SplinePositionInterpolator2D'), ('key', [], FieldType.MFFloat, AccessType.inputOutput, 'X3DInterpolatorNode'), ('keyValue', [], FieldType.MFVec2f, AccessType.inputOutput, 'SplinePositionInterpolator2D'), ('keyVelocity', [], FieldType.MFVec2f, AccessType.inputOutput, 'SplinePositionInterpolator2D'), ('normalizeVelocity', False, FieldType.SFBool, AccessType.inputOutput, 'SplinePositionInterpolator2D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, closed=False, key=None, keyValue=None, keyVelocity=None, normalizeVelocity=False, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SplinePositionInterpolator2D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.closed = closed self.key = key self.keyValue = keyValue self.keyVelocity = keyVelocity self.normalizeVelocity = normalizeVelocity self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def closed(self): """Whether or not the curve is closed (i.""" return self.__closed @closed.setter def closed(self, closed): if closed is None: closed = False # default assertValidSFBool(closed) self.__closed = closed @property # getter - - - - - - - - - - def key(self): """Definition parameters for nonlinear-interpolation function time intervals, listed in non-decreasing order and corresponding to keyValue, keyVelocity array values.""" return self.__key @key.setter def key(self, key): if key is None: key = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(key) self.__key = key @property # getter - - - - - - - - - - def keyValue(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyValue @keyValue.setter def keyValue(self, keyValue): if keyValue is None: keyValue = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(keyValue) self.__keyValue = keyValue @property # getter - - - - - - - - - - def keyVelocity(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyVelocity @keyVelocity.setter def keyVelocity(self, keyVelocity): if keyVelocity is None: keyVelocity = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(keyVelocity) self.__keyVelocity = keyVelocity @property # getter - - - - - - - - - - def normalizeVelocity(self): """normalizeVelocity field specifies whether the velocity vectors are normalized to produce smooth speed transitions, or transformed into tangency vectors.""" return self.__normalizeVelocity @normalizeVelocity.setter def normalizeVelocity(self, normalizeVelocity): if normalizeVelocity is None: normalizeVelocity = False # default assertValidSFBool(normalizeVelocity) self.__normalizeVelocity = normalizeVelocity @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SplinePositionInterpolator2D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SplinePositionInterpolator2D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SplinePositionInterpolator2D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.closed: # default=false attributeResult += " " + '"@closed":"' + SFBool(self.closed).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.key != []: attributeResult += " " + '"@key":"' + MFFloat(self.key).JSON() + '"' + ',\n' if self.keyValue != []: attributeResult += " " + '"@keyValue":"' + MFVec2f(self.keyValue).JSON() + '"' + ',\n' if self.keyVelocity != []: attributeResult += " " + '"@keyVelocity":"' + MFVec2f(self.keyVelocity).JSON() + '"' + ',\n' if self.normalizeVelocity: # default=false attributeResult += " " + '"@normalizeVelocity":"' + SFBool(self.normalizeVelocity).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SplinePositionInterpolator2D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SplinePositionInterpolator2D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SplinePositionInterpolator2D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.closed: # default=false result += '\n' + indent + ' ' + "closed " + SFBool(self.closed).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.key != []: result += '\n' + indent + ' ' + "key " + MFFloat(self.key).VRML() + "" if self.keyValue != []: result += '\n' + indent + ' ' + "keyValue " + MFVec2f(self.keyValue).VRML() + "" if self.keyVelocity != []: result += '\n' + indent + ' ' + "keyVelocity " + MFVec2f(self.keyVelocity).VRML() + "" if self.normalizeVelocity: # default=false result += '\n' + indent + ' ' + "normalizeVelocity " + SFBool(self.normalizeVelocity).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SplineScalarInterpolator(_X3DInterpolatorNode): """ SplineScalarInterpolator performs non-linear interpolation among paired lists of float values and velocities to produce an SFFloat value_changed output event. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SplineScalarInterpolator' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/interpolators.html#SplineScalarInterpolator' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SplineScalarInterpolator' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('closed', False, FieldType.SFBool, AccessType.initializeOnly, 'SplineScalarInterpolator'), ('key', [], FieldType.MFFloat, AccessType.inputOutput, 'X3DInterpolatorNode'), ('keyValue', [], FieldType.MFFloat, AccessType.inputOutput, 'SplineScalarInterpolator'), ('keyVelocity', [], FieldType.MFFloat, AccessType.inputOutput, 'SplineScalarInterpolator'), ('normalizeVelocity', False, FieldType.SFBool, AccessType.inputOutput, 'SplineScalarInterpolator'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, closed=False, key=None, keyValue=None, keyVelocity=None, normalizeVelocity=False, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SplineScalarInterpolator __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.closed = closed self.key = key self.keyValue = keyValue self.keyVelocity = keyVelocity self.normalizeVelocity = normalizeVelocity self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def closed(self): """Whether or not the curve is closed (i.""" return self.__closed @closed.setter def closed(self, closed): if closed is None: closed = False # default assertValidSFBool(closed) self.__closed = closed @property # getter - - - - - - - - - - def key(self): """Definition parameters for nonlinear-interpolation function time intervals, listed in non-decreasing order and corresponding to keyValue, keyVelocity array values.""" return self.__key @key.setter def key(self, key): if key is None: key = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(key) self.__key = key @property # getter - - - - - - - - - - def keyValue(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyValue @keyValue.setter def keyValue(self, keyValue): if keyValue is None: keyValue = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(keyValue) self.__keyValue = keyValue @property # getter - - - - - - - - - - def keyVelocity(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyVelocity @keyVelocity.setter def keyVelocity(self, keyVelocity): if keyVelocity is None: keyVelocity = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(keyVelocity) self.__keyVelocity = keyVelocity @property # getter - - - - - - - - - - def normalizeVelocity(self): """normalizeVelocity field specifies whether the velocity vectors are normalized to produce smooth speed transitions, or transformed into tangency vectors.""" return self.__normalizeVelocity @normalizeVelocity.setter def normalizeVelocity(self, normalizeVelocity): if normalizeVelocity is None: normalizeVelocity = False # default assertValidSFBool(normalizeVelocity) self.__normalizeVelocity = normalizeVelocity @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SplineScalarInterpolator.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SplineScalarInterpolator.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SplineScalarInterpolator":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.closed: # default=false attributeResult += " " + '"@closed":"' + SFBool(self.closed).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.key != []: attributeResult += " " + '"@key":"' + MFFloat(self.key).JSON() + '"' + ',\n' if self.keyValue != []: attributeResult += " " + '"@keyValue":"' + MFFloat(self.keyValue).JSON() + '"' + ',\n' if self.keyVelocity != []: attributeResult += " " + '"@keyVelocity":"' + MFFloat(self.keyVelocity).JSON() + '"' + ',\n' if self.normalizeVelocity: # default=false attributeResult += " " + '"@normalizeVelocity":"' + SFBool(self.normalizeVelocity).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SplineScalarInterpolator.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SplineScalarInterpolator' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SplineScalarInterpolator' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.closed: # default=false result += '\n' + indent + ' ' + "closed " + SFBool(self.closed).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.key != []: result += '\n' + indent + ' ' + "key " + MFFloat(self.key).VRML() + "" if self.keyValue != []: result += '\n' + indent + ' ' + "keyValue " + MFFloat(self.keyValue).VRML() + "" if self.keyVelocity != []: result += '\n' + indent + ' ' + "keyVelocity " + MFFloat(self.keyVelocity).VRML() + "" if self.normalizeVelocity: # default=false result += '\n' + indent + ' ' + "normalizeVelocity " + SFBool(self.normalizeVelocity).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SpotLight(_X3DLightNode): """ Linear attenuation may occur at level 2, full support at level 3. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SpotLight' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/lighting.html#SpotLight' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SpotLight' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ambientIntensity', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('attenuation', (1, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'SpotLight'), ('beamWidth', 0.589049, FieldType.SFFloat, AccessType.inputOutput, 'SpotLight'), ('color', (1, 1, 1), FieldType.SFColor, AccessType.inputOutput, 'X3DLightNode'), ('cutOffAngle', 1.570796, FieldType.SFFloat, AccessType.inputOutput, 'SpotLight'), ('direction', (0, 0, -1), FieldType.SFVec3f, AccessType.inputOutput, 'SpotLight'), ('global_', True, FieldType.SFBool, AccessType.inputOutput, 'SpotLight'), ('intensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('location', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'SpotLight'), ('on', True, FieldType.SFBool, AccessType.inputOutput, 'X3DLightNode'), ('radius', 100, FieldType.SFFloat, AccessType.initializeOnly, 'SpotLight'), ('shadowIntensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('shadows', False, FieldType.SFBool, AccessType.inputOutput, 'X3DLightNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ambientIntensity=0, attenuation=(1, 0, 0), beamWidth=0.589049, color=(1, 1, 1), cutOffAngle=1.570796, direction=(0, 0, -1), global_=True, intensity=1, location=(0, 0, 0), on=True, radius=100, shadowIntensity=1, shadows=False, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SpotLight __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ambientIntensity = ambientIntensity self.attenuation = attenuation self.beamWidth = beamWidth self.color = color self.cutOffAngle = cutOffAngle self.direction = direction self.global_ = global_ self.intensity = intensity self.location = location self.on = on self.radius = radius self.shadowIntensity = shadowIntensity self.shadows = shadows self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ambientIntensity(self): """[0,1] Brightness of ambient (nondirectional background) emission from the light.""" return self.__ambientIntensity @ambientIntensity.setter def ambientIntensity(self, ambientIntensity): if ambientIntensity is None: ambientIntensity = 0 # default assertValidSFFloat(ambientIntensity) assertZeroToOne('ambientIntensity', ambientIntensity) self.__ambientIntensity = ambientIntensity @property # getter - - - - - - - - - - def attenuation(self): """Constant, linear-distance and squared-distance dropoff factors as radial distance increases from the source.""" return self.__attenuation @attenuation.setter def attenuation(self, attenuation): if attenuation is None: attenuation = (1, 0, 0) # default assertValidSFVec3f(attenuation) assertNonNegative('attenuation', attenuation) self.__attenuation = attenuation @property # getter - - - - - - - - - - def beamWidth(self): """[0,1.""" return self.__beamWidth @beamWidth.setter def beamWidth(self, beamWidth): if beamWidth is None: beamWidth = 0.589049 # default assertValidSFFloat(beamWidth) assertGreaterThan('beamWidth', beamWidth, 0) assertLessThanEquals('beamWidth', beamWidth, 1.570796) self.__beamWidth = beamWidth @property # getter - - - - - - - - - - def color(self): """[0,1] color of light, applied to colors of objects.""" return self.__color @color.setter def color(self, color): if color is None: color = (1, 1, 1) # default assertValidSFColor(color) assertZeroToOne('color', color) self.__color = color @property # getter - - - - - - - - - - def cutOffAngle(self): """[0,1.""" return self.__cutOffAngle @cutOffAngle.setter def cutOffAngle(self, cutOffAngle): if cutOffAngle is None: cutOffAngle = 1.570796 # default assertValidSFFloat(cutOffAngle) assertGreaterThan('cutOffAngle', cutOffAngle, 0) assertLessThanEquals('cutOffAngle', cutOffAngle, 1.570796) self.__cutOffAngle = cutOffAngle @property # getter - - - - - - - - - - def direction(self): """Orientation vector of light relative to local coordinate system.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (0, 0, -1) # default assertValidSFVec3f(direction) self.__direction = direction @property # getter - - - - - - - - - - def global_(self): """Global lights illuminate all objects within their volume of lighting influence.""" return self.__global_ @global_.setter def global_(self, global_): if global_ is None: global_ = True # default assertValidSFBool(global_) self.__global_ = global_ @property # getter - - - - - - - - - - def intensity(self): """[0,+infinity] Brightness of direct emission from the light.""" return self.__intensity @intensity.setter def intensity(self, intensity): if intensity is None: intensity = 1 # default assertValidSFFloat(intensity) assertNonNegative('intensity', intensity) self.__intensity = intensity @property # getter - - - - - - - - - - def location(self): """Position of light relative to local coordinate system.""" return self.__location @location.setter def location(self, location): if location is None: location = (0, 0, 0) # default assertValidSFVec3f(location) self.__location = location @property # getter - - - - - - - - - - def on(self): """Enables/disables this light source.""" return self.__on @on.setter def on(self, on): if on is None: on = True # default assertValidSFBool(on) self.__on = on @property # getter - - - - - - - - - - def radius(self): """Maximum effective distance of light relative to local light position, affected by ancestor scaling.""" return self.__radius @radius.setter def radius(self, radius): if radius is None: radius = 100 # default assertValidSFFloat(radius) assertNonNegative('radius', radius) self.__radius = radius @property # getter - - - - - - - - - - def shadowIntensity(self): """[0,1] shadowIntensity field defines how much light is obscured by shapes that cast shadows, ranging from 0 (light not obscured, no visible shadows) to 1 (light completely obscured, full-intensity shadows).""" return self.__shadowIntensity @shadowIntensity.setter def shadowIntensity(self, shadowIntensity): if shadowIntensity is None: shadowIntensity = 1 # default assertValidSFFloat(shadowIntensity) assertZeroToOne('shadowIntensity', shadowIntensity) self.__shadowIntensity = shadowIntensity @property # getter - - - - - - - - - - def shadows(self): """shadows field indicates whether or not this light casts a shadow behind illuminated X3DShapeNode geometry.""" return self.__shadows @shadows.setter def shadows(self, shadows): if shadows is None: shadows = False # default assertValidSFBool(shadows) self.__shadows = shadows @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SpotLight.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SpotLight.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SpotLight":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.ambientIntensity != 0: attributeResult += " " + '"@ambientIntensity":"' + SFFloat(self.ambientIntensity).JSON() + '"' + ',\n' if self.attenuation != (1, 0, 0): attributeResult += " " + '"@attenuation":"' + SFVec3f(self.attenuation).JSON() + '"' + ',\n' if self.beamWidth != 0.589049: attributeResult += " " + '"@beamWidth":"' + SFFloat(self.beamWidth).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.color != (1, 1, 1): attributeResult += " " + '"@color":"' + SFColor(self.color).JSON() + '"' + ',\n' if self.cutOffAngle != 1.570796: attributeResult += " " + '"@cutOffAngle":"' + SFFloat(self.cutOffAngle).JSON() + '"' + ',\n' if self.direction != (0, 0, -1): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if not self.global_: # default=true attributeResult += " " + '"@global":"' + SFBool(self.global_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.intensity != 1: attributeResult += " " + '"@intensity":"' + SFFloat(self.intensity).JSON() + '"' + ',\n' if self.location != (0, 0, 0): attributeResult += " " + '"@location":"' + SFVec3f(self.location).JSON() + '"' + ',\n' if not self.on: # default=true attributeResult += " " + '"@on":"' + SFBool(self.on).JSON() + '"' + ',\n' if self.radius != 100: attributeResult += " " + '"@radius":"' + SFFloat(self.radius).JSON() + '"' + ',\n' if self.shadowIntensity != 1: attributeResult += " " + '"@shadowIntensity":"' + SFFloat(self.shadowIntensity).JSON() + '"' + ',\n' if self.shadows: # default=false attributeResult += " " + '"@shadows":"' + SFBool(self.shadows).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SpotLight.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SpotLight' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SpotLight' + ' {' if self.ambientIntensity != 0: result += '\n' + indent + ' ' + "ambientIntensity " + SFFloat(self.ambientIntensity).VRML() + "" if self.attenuation != (1, 0, 0): result += '\n' + indent + ' ' + "attenuation " + SFVec3f(self.attenuation).VRML() + "" if self.beamWidth != 0.589049: result += '\n' + indent + ' ' + "beamWidth " + SFFloat(self.beamWidth).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.color != (1, 1, 1): result += '\n' + indent + ' ' + "color " + SFColor(self.color).VRML() + "" if self.cutOffAngle != 1.570796: result += '\n' + indent + ' ' + "cutOffAngle " + SFFloat(self.cutOffAngle).VRML() + "" if self.direction != (0, 0, -1): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if not self.global_: # default=true result += '\n' + indent + ' ' + "global " + SFBool(self.global_).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.intensity != 1: result += '\n' + indent + ' ' + "intensity " + SFFloat(self.intensity).VRML() + "" if self.location != (0, 0, 0): result += '\n' + indent + ' ' + "location " + SFVec3f(self.location).VRML() + "" if not self.on: # default=true result += '\n' + indent + ' ' + "on " + SFBool(self.on).VRML() + "" if self.radius != 100: result += '\n' + indent + ' ' + "radius " + SFFloat(self.radius).VRML() + "" if self.shadowIntensity != 1: result += '\n' + indent + ' ' + "shadowIntensity " + SFFloat(self.shadowIntensity).VRML() + "" if self.shadows: # default=false result += '\n' + indent + ' ' + "shadows " + SFBool(self.shadows).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SquadOrientationInterpolator(_X3DInterpolatorNode): """ SquadOrientationInterpolator performs non-linear interpolation among paired lists of rotation values to produce an SFRotation value_changed output event. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SquadOrientationInterpolator' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/interpolators.html#SquadOrientationInterpolator' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SquadOrientationInterpolator' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('key', [], FieldType.MFFloat, AccessType.inputOutput, 'X3DInterpolatorNode'), ('keyValue', [], FieldType.MFRotation, AccessType.inputOutput, 'SquadOrientationInterpolator'), ('normalizeVelocity', False, FieldType.SFBool, AccessType.inputOutput, 'SquadOrientationInterpolator'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, key=None, keyValue=None, normalizeVelocity=False, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SquadOrientationInterpolator __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.key = key self.keyValue = keyValue self.normalizeVelocity = normalizeVelocity self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def key(self): """Definition parameters for nonlinear-interpolation function time intervals, listed in non-decreasing order and corresponding to keyValue, keyVelocity array values.""" return self.__key @key.setter def key(self, key): if key is None: key = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(key) self.__key = key @property # getter - - - - - - - - - - def keyValue(self): """Output values for nonlinear interpolation, each corresponding to an input-fraction value in the key array.""" return self.__keyValue @keyValue.setter def keyValue(self, keyValue): if keyValue is None: keyValue = MFRotation.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFRotation.DEFAULT_VALUE()=' + str(MFRotation.DEFAULT_VALUE())) assertValidMFRotation(keyValue) self.__keyValue = keyValue @property # getter - - - - - - - - - - def normalizeVelocity(self): """normalizeVelocity field specifies whether the velocity vectors are normalized to produce smooth speed transitions, or transformed into tangency vectors.""" return self.__normalizeVelocity @normalizeVelocity.setter def normalizeVelocity(self, normalizeVelocity): if normalizeVelocity is None: normalizeVelocity = False # default assertValidSFBool(normalizeVelocity) self.__normalizeVelocity = normalizeVelocity @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SquadOrientationInterpolator.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SquadOrientationInterpolator.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SquadOrientationInterpolator":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.key != []: attributeResult += " " + '"@key":"' + MFFloat(self.key).JSON() + '"' + ',\n' if self.keyValue != []: attributeResult += " " + '"@keyValue":"' + MFRotation(self.keyValue).JSON() + '"' + ',\n' if self.normalizeVelocity: # default=false attributeResult += " " + '"@normalizeVelocity":"' + SFBool(self.normalizeVelocity).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SquadOrientationInterpolator.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SquadOrientationInterpolator' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SquadOrientationInterpolator' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.key != []: result += '\n' + indent + ' ' + "key " + MFFloat(self.key).VRML() + "" if self.keyValue != []: result += '\n' + indent + ' ' + "keyValue " + MFRotation(self.keyValue).VRML() + "" if self.normalizeVelocity: # default=false result += '\n' + indent + ' ' + "normalizeVelocity " + SFBool(self.normalizeVelocity).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class StaticGroup(_X3DChildNode, _X3DBoundedObject): """ StaticGroup is similar to Group node but does not allow access to children after creation time. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'StaticGroup' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/grouping.html#StaticGroup' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#StaticGroup' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DBoundedObject'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DBoundedObject'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DBoundedObject'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DBoundedObject'), ('children', [], FieldType.MFNode, AccessType.initializeOnly, 'StaticGroup'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), visible=True, children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode StaticGroup __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.visible = visible self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def children(self): """[X3DChildNode] Grouping nodes contain an ordered list of children nodes.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StaticGroup.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StaticGroup.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"StaticGroup":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* StaticGroup found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function StaticGroup.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'StaticGroup' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'StaticGroup' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class StreamAudioDestination(_X3DSoundDestinationNode): """ StreamAudioDestination node represents the final audio destination via a media stream. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'StreamAudioDestination' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#StreamAudioDestination' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#StreamAudioDestination' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('channelCountMode', 'MAX', FieldType.SFString, AccessType.inputOutput, 'X3DSoundDestinationNode'), ('channelInterpretation', 'SPEAKERS', FieldType.SFString, AccessType.inputOutput, 'X3DSoundDestinationNode'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSoundNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSoundNode'), ('gain', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DSoundDestinationNode'), ('mediaDeviceID', '', FieldType.SFString, AccessType.inputOutput, 'X3DSoundDestinationNode'), ('streamIdentifier', '', FieldType.SFString, AccessType.inputOutput, 'StreamAudioDestination'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'StreamAudioDestination'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, channelCountMode='MAX', channelInterpretation='SPEAKERS', description='', enabled=True, gain=1, mediaDeviceID='', streamIdentifier='', children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode StreamAudioDestination __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.channelCountMode = channelCountMode self.channelInterpretation = channelInterpretation self.description = description self.enabled = enabled self.gain = gain self.mediaDeviceID = mediaDeviceID self.streamIdentifier = streamIdentifier self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def channelCountMode(self): """channelCountMode determines how individual channels are counted when up-mixing and down-mixing connections to any inputs.""" return self.__channelCountMode @channelCountMode.setter def channelCountMode(self, channelCountMode): if channelCountMode is None: channelCountMode = 'MAX' # default assertValidSFString(channelCountMode) assertValidChannelCountMode('channelCountMode', channelCountMode) self.__channelCountMode = channelCountMode @property # getter - - - - - - - - - - def channelInterpretation(self): """channelInterpretation determines how individual channels are treated when up-mixing and down-mixing connections to any inputs.""" return self.__channelInterpretation @channelInterpretation.setter def channelInterpretation(self, channelInterpretation): if channelInterpretation is None: channelInterpretation = 'SPEAKERS' # default assertValidSFString(channelInterpretation) assertValidChannelInterpretation('channelInterpretation', channelInterpretation) self.__channelInterpretation = channelInterpretation @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def gain(self): """(-infinity,+infinity) The gain field is a factor that represents the amount of linear amplification to apply to the output of the node.""" return self.__gain @gain.setter def gain(self, gain): if gain is None: gain = 1 # default assertValidSFFloat(gain) self.__gain = gain @property # getter - - - - - - - - - - def mediaDeviceID(self): """mediaDeviceID field provides ID parameter functionality.""" return self.__mediaDeviceID @mediaDeviceID.setter def mediaDeviceID(self, mediaDeviceID): if mediaDeviceID is None: mediaDeviceID = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(mediaDeviceID) self.__mediaDeviceID = mediaDeviceID @property # getter - - - - - - - - - - def streamIdentifier(self): """Stream identification TBD Hint: W3C Media Capture and Streams https://www.""" return self.__streamIdentifier @streamIdentifier.setter def streamIdentifier(self, streamIdentifier): if streamIdentifier is None: streamIdentifier = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(streamIdentifier) self.__streamIdentifier = streamIdentifier @property # getter - - - - - - - - - - def children(self): """[X3DSoundChannelNode|X3DSoundProcessingNode|X3DSoundSourceNode] The children field specifies audio-graph sound sources providing input signals for this node.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StreamAudioDestination.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StreamAudioDestination.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"StreamAudioDestination":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.channelCountMode != 'MAX': attributeResult += " " + '"@channelCountMode":"' + SFString(self.channelCountMode).JSON() + '"' + ',\n' if self.channelInterpretation != 'SPEAKERS': attributeResult += " " + '"@channelInterpretation":"' + SFString(self.channelInterpretation).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.gain != 1: attributeResult += " " + '"@gain":"' + SFFloat(self.gain).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.mediaDeviceID: attributeResult += " " + '"@mediaDeviceID":"' + SFString(self.mediaDeviceID).JSON() + '"' + ',\n' if self.streamIdentifier: attributeResult += " " + '"@streamIdentifier":"' + SFString(self.streamIdentifier).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* StreamAudioDestination found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function StreamAudioDestination.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'StreamAudioDestination' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'StreamAudioDestination' + ' {' if self.channelCountMode != 'MAX': result += '\n' + indent + ' ' + "channelCountMode " + '"' + self.channelCountMode + '"' + "" if self.channelInterpretation != 'SPEAKERS': result += '\n' + indent + ' ' + "channelInterpretation " + '"' + self.channelInterpretation + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.gain != 1: result += '\n' + indent + ' ' + "gain " + SFFloat(self.gain).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.mediaDeviceID: result += '\n' + indent + ' ' + "mediaDeviceID " + '"' + self.mediaDeviceID + '"' + "" if self.streamIdentifier: result += '\n' + indent + ' ' + "streamIdentifier " + '"' + self.streamIdentifier + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class StreamAudioSource(_X3DSoundSourceNode): """ StreamAudioSource operates as an audio source whose media is received from a MediaStream obtained using the WebRTC or Media Capture and Streams APIs. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'StreamAudioSource' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#StreamAudioSource' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#StreamAudioSource' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('channelCountMode', 'MAX', FieldType.SFString, AccessType.inputOutput, 'StreamAudioSource'), ('channelInterpretation', 'SPEAKERS', FieldType.SFString, AccessType.inputOutput, 'StreamAudioSource'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DTimeDependentNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSoundSourceNode'), ('gain', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DSoundSourceNode'), ('pauseTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('resumeTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('startTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('stopTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('streamIdentifier', '', FieldType.SFString, AccessType.inputOutput, 'StreamAudioSource'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, channelCountMode='MAX', channelInterpretation='SPEAKERS', description='', enabled=True, gain=1, pauseTime=0, resumeTime=0, startTime=0, stopTime=0, streamIdentifier='', DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode StreamAudioSource __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.channelCountMode = channelCountMode self.channelInterpretation = channelInterpretation self.description = description self.enabled = enabled self.gain = gain self.pauseTime = pauseTime self.resumeTime = resumeTime self.startTime = startTime self.stopTime = stopTime self.streamIdentifier = streamIdentifier self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def channelCountMode(self): """channelCountMode determines how individual channels are counted when up-mixing and down-mixing connections to any inputs.""" return self.__channelCountMode @channelCountMode.setter def channelCountMode(self, channelCountMode): if channelCountMode is None: channelCountMode = 'MAX' # default assertValidSFString(channelCountMode) assertValidChannelCountMode('channelCountMode', channelCountMode) self.__channelCountMode = channelCountMode @property # getter - - - - - - - - - - def channelInterpretation(self): """channelInterpretation determines how individual channels are treated when up-mixing and down-mixing connections to any inputs.""" return self.__channelInterpretation @channelInterpretation.setter def channelInterpretation(self, channelInterpretation): if channelInterpretation is None: channelInterpretation = 'SPEAKERS' # default assertValidSFString(channelInterpretation) assertValidChannelInterpretation('channelInterpretation', channelInterpretation) self.__channelInterpretation = channelInterpretation @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def gain(self): """(-infinity,+infinity) The gain field is a factor that represents the amount of linear amplification to apply to the output of the node.""" return self.__gain @gain.setter def gain(self, gain): if gain is None: gain = 1 # default assertValidSFFloat(gain) self.__gain = gain @property # getter - - - - - - - - - - def pauseTime(self): """When time now >= pauseTime, isPaused becomes true and AudioClip becomes paused.""" return self.__pauseTime @pauseTime.setter def pauseTime(self, pauseTime): if pauseTime is None: pauseTime = 0 # default assertValidSFTime(pauseTime) self.__pauseTime = pauseTime @property # getter - - - - - - - - - - def resumeTime(self): """When resumeTime becomes <= time now, isPaused becomes false and AudioClip becomes active.""" return self.__resumeTime @resumeTime.setter def resumeTime(self, resumeTime): if resumeTime is None: resumeTime = 0 # default assertValidSFTime(resumeTime) self.__resumeTime = resumeTime @property # getter - - - - - - - - - - def startTime(self): """Absolute time: number of seconds since January 1, 1970, 00:00:00 GMT.""" return self.__startTime @startTime.setter def startTime(self, startTime): if startTime is None: startTime = 0 # default assertValidSFTime(startTime) self.__startTime = startTime @property # getter - - - - - - - - - - def stopTime(self): """Absolute time: number of seconds since January 1, 1970, 00:00:00 GMT.""" return self.__stopTime @stopTime.setter def stopTime(self, stopTime): if stopTime is None: stopTime = 0 # default assertValidSFTime(stopTime) self.__stopTime = stopTime @property # getter - - - - - - - - - - def streamIdentifier(self): """Stream identification TBD Hint: W3C Media Capture and Streams https://www.""" return self.__streamIdentifier @streamIdentifier.setter def streamIdentifier(self, streamIdentifier): if streamIdentifier is None: streamIdentifier = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(streamIdentifier) self.__streamIdentifier = streamIdentifier @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StreamAudioSource.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StreamAudioSource.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"StreamAudioSource":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.channelCountMode != 'MAX': attributeResult += " " + '"@channelCountMode":"' + SFString(self.channelCountMode).JSON() + '"' + ',\n' if self.channelInterpretation != 'SPEAKERS': attributeResult += " " + '"@channelInterpretation":"' + SFString(self.channelInterpretation).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.gain != 1: attributeResult += " " + '"@gain":"' + SFFloat(self.gain).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.pauseTime != 0: attributeResult += " " + '"@pauseTime":"' + SFTime(self.pauseTime).JSON() + '"' + ',\n' if self.resumeTime != 0: attributeResult += " " + '"@resumeTime":"' + SFTime(self.resumeTime).JSON() + '"' + ',\n' if self.startTime != 0: attributeResult += " " + '"@startTime":"' + SFTime(self.startTime).JSON() + '"' + ',\n' if self.stopTime != 0: attributeResult += " " + '"@stopTime":"' + SFTime(self.stopTime).JSON() + '"' + ',\n' if self.streamIdentifier: attributeResult += " " + '"@streamIdentifier":"' + SFString(self.streamIdentifier).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function StreamAudioSource.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'StreamAudioSource' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'StreamAudioSource' + ' {' if self.channelCountMode != 'MAX': result += '\n' + indent + ' ' + "channelCountMode " + '"' + self.channelCountMode + '"' + "" if self.channelInterpretation != 'SPEAKERS': result += '\n' + indent + ' ' + "channelInterpretation " + '"' + self.channelInterpretation + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.gain != 1: result += '\n' + indent + ' ' + "gain " + SFFloat(self.gain).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.pauseTime != 0: result += '\n' + indent + ' ' + "pauseTime " + SFTime(self.pauseTime).VRML() + "" if self.resumeTime != 0: result += '\n' + indent + ' ' + "resumeTime " + SFTime(self.resumeTime).VRML() + "" if self.startTime != 0: result += '\n' + indent + ' ' + "startTime " + SFTime(self.startTime).VRML() + "" if self.stopTime != 0: result += '\n' + indent + ' ' + "stopTime " + SFTime(self.stopTime).VRML() + "" if self.streamIdentifier: result += '\n' + indent + ' ' + "streamIdentifier " + '"' + self.streamIdentifier + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class StringSensor(_X3DKeyDeviceSensorNode): """ StringSensor generates events as the user presses keys on the keyboard. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'StringSensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/keyDeviceSensor.html#StringSensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#StringSensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('deletionAllowed', True, FieldType.SFBool, AccessType.inputOutput, 'StringSensor'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, deletionAllowed=True, description='', enabled=True, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode StringSensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.deletionAllowed = deletionAllowed self.description = description self.enabled = enabled self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def deletionAllowed(self): """If deletionAllowed is true, then previously entered character in enteredText can be removed.""" return self.__deletionAllowed @deletionAllowed.setter def deletionAllowed(self, deletionAllowed): if deletionAllowed is None: deletionAllowed = True # default assertValidSFBool(deletionAllowed) self.__deletionAllowed = deletionAllowed @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StringSensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function StringSensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"StringSensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if not self.deletionAllowed: # default=true attributeResult += " " + '"@deletionAllowed":"' + SFBool(self.deletionAllowed).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function StringSensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'StringSensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'StringSensor' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if not self.deletionAllowed: # default=true result += '\n' + indent + ' ' + "deletionAllowed " + SFBool(self.deletionAllowed).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class SurfaceEmitter(_X3DParticleEmitterNode): """ SurfaceEmitter generates particles from the surface of an object. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'SurfaceEmitter' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/particleSystems.html#SurfaceEmitter' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#SurfaceEmitter' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('coordIndex', [-1], FieldType.MFInt32, AccessType.initializeOnly, 'SurfaceEmitter'), ('mass', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('on', True, FieldType.SFBool, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('speed', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('surfaceArea', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('variation', 0.25, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('surface', None, FieldType.SFNode, AccessType.initializeOnly, 'SurfaceEmitter'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, coordIndex=None, mass=0, on=True, speed=0, surfaceArea=0, variation=0.25, surface=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode SurfaceEmitter __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.coordIndex = coordIndex self.mass = mass self.on = on self.speed = speed self.surfaceArea = surfaceArea self.variation = variation self.surface = surface self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def coordIndex(self): """[-1,+infinity) coordIndex indices are applied to contained Coordinate values in order to define randomly generated initial geometry of the particles.""" return self.__coordIndex @coordIndex.setter def coordIndex(self, coordIndex): if coordIndex is None: coordIndex = [-1] # default assertValidMFInt32(coordIndex) assertGreaterThanEquals('coordIndex', coordIndex, -1) self.__coordIndex = coordIndex @property # getter - - - - - - - - - - def mass(self): """[0,+infinity) Basic mass of each particle, defined in mass base units (default is kilograms).""" return self.__mass @mass.setter def mass(self, mass): if mass is None: mass = 0 # default assertValidSFFloat(mass) assertNonNegative('mass', mass) self.__mass = mass @property # getter - - - - - - - - - - def on(self): """Enables/disables production of particles from this emitter node.""" return self.__on @on.setter def on(self, on): if on is None: on = True # default assertValidSFBool(on) self.__on = on @property # getter - - - - - - - - - - def speed(self): """[0,+infinity) Initial linear speed (default is m/s) imparted to all particles along their direction of movement.""" return self.__speed @speed.setter def speed(self, speed): if speed is None: speed = 0 # default assertValidSFFloat(speed) assertNonNegative('speed', speed) self.__speed = speed @property # getter - - - - - - - - - - def surfaceArea(self): """[0,+infinity) Particle surface area in area base units (default is meters squared).""" return self.__surfaceArea @surfaceArea.setter def surfaceArea(self, surfaceArea): if surfaceArea is None: surfaceArea = 0 # default assertValidSFFloat(surfaceArea) assertNonNegative('surfaceArea', surfaceArea) self.__surfaceArea = surfaceArea @property # getter - - - - - - - - - - def variation(self): """[0,+infinity) Multiplier for the randomness used to control the range of possible output values.""" return self.__variation @variation.setter def variation(self, variation): if variation is None: variation = 0.25 # default assertValidSFFloat(variation) assertNonNegative('variation', variation) self.__variation = variation @property # getter - - - - - - - - - - def surface(self): """[X3DGeometryNode] The geometry node provides geometry used as the emitting surface.""" return self.__surface @surface.setter def surface(self, surface): if surface is None: surface = None # default assertValidSFNode(surface) if not surface is None and not isinstance(surface,(_X3DGeometryNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(surface) + ' does not match required node type (_X3DGeometryNode,ProtoInstance) and is invalid') self.__surface = surface @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.surface # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SurfaceEmitter.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function SurfaceEmitter.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"SurfaceEmitter":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.coordIndex != [-1]: attributeResult += " " + '"@coordIndex":"' + MFInt32(self.coordIndex).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.mass != 0: attributeResult += " " + '"@mass":"' + SFFloat(self.mass).JSON() + '"' + ',\n' if not self.on: # default=true attributeResult += " " + '"@on":"' + SFBool(self.on).JSON() + '"' + ',\n' if self.speed != 0: attributeResult += " " + '"@speed":"' + SFFloat(self.speed).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.surfaceArea != 0: attributeResult += " " + '"@surfaceArea":"' + SFFloat(self.surfaceArea).JSON() + '"' + ',\n' if self.variation != 0.25: attributeResult += " " + '"@variation":"' + SFFloat(self.variation).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.surface: # output this SFNode result += self.surface.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function SurfaceEmitter.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'SurfaceEmitter' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'SurfaceEmitter' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.coordIndex != [-1]: result += '\n' + indent + ' ' + "coordIndex " + MFInt32(self.coordIndex).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.mass != 0: result += '\n' + indent + ' ' + "mass " + SFFloat(self.mass).VRML() + "" if not self.on: # default=true result += '\n' + indent + ' ' + "on " + SFBool(self.on).VRML() + "" if self.speed != 0: result += '\n' + indent + ' ' + "speed " + SFFloat(self.speed).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.surfaceArea != 0: result += '\n' + indent + ' ' + "surfaceArea " + SFFloat(self.surfaceArea).VRML() + "" if self.variation != 0.25: result += '\n' + indent + ' ' + "variation " + SFFloat(self.variation).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.surface: # output this SFNode result += '\n' + ' ' + indent + 'surface ' + self.surface.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Switch(_X3DGroupingNode): """ Switch is a Grouping node that only renders one (or zero) child at a time. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Switch' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/grouping.html#Switch' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Switch' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DGroupingNode'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DGroupingNode'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DGroupingNode'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DGroupingNode'), ('whichChoice', -1, FieldType.SFInt32, AccessType.inputOutput, 'Switch'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'X3DGroupingNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), visible=True, whichChoice=-1, children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Switch __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.visible = visible self.whichChoice = whichChoice self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def whichChoice(self): """[-1,+infinity) Index of active child choice, counting from 0.""" return self.__whichChoice @whichChoice.setter def whichChoice(self, whichChoice): if whichChoice is None: whichChoice = -1 # default assertValidSFInt32(whichChoice) assertGreaterThanEquals('whichChoice', whichChoice, -1) self.__whichChoice = whichChoice @property # getter - - - - - - - - - - def children(self): """[X3DChildNode] Grouping nodes contain an ordered list of children nodes.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Switch.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Switch.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Switch":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' + ',\n' if self.whichChoice != -1: attributeResult += " " + '"@whichChoice":"' + SFInt32(self.whichChoice).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* Switch found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Switch.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Switch' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Switch' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.whichChoice != -1: result += '\n' + indent + ' ' + "whichChoice " + SFInt32(self.whichChoice).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TexCoordChaser2D(_X3DChaserNode): """ TexCoordChaser2D generates a series of single floating-point values that progressively change from initial value to destination value. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TexCoordChaser2D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/followers.html#TexCoordChaser2D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TexCoordChaser2D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('duration', 1, FieldType.SFTime, AccessType.initializeOnly, 'X3DChaserNode'), ('initialDestination', [], FieldType.MFVec2f, AccessType.initializeOnly, 'TexCoordChaser2D'), ('initialValue', [], FieldType.MFVec2f, AccessType.initializeOnly, 'TexCoordChaser2D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, duration=1, initialDestination=None, initialValue=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TexCoordChaser2D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.duration = duration self.initialDestination = initialDestination self.initialValue = initialValue self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def duration(self): """[0,+infinity) duration is the time interval for filter response in seconds.""" return self.__duration @duration.setter def duration(self, duration): if duration is None: duration = 1 # default assertValidSFTime(duration) assertNonNegative('duration', duration) self.__duration = duration @property # getter - - - - - - - - - - def initialDestination(self): """Initial destination value for this node.""" return self.__initialDestination @initialDestination.setter def initialDestination(self, initialDestination): if initialDestination is None: initialDestination = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(initialDestination) self.__initialDestination = initialDestination @property # getter - - - - - - - - - - def initialValue(self): """Initial starting value for this node.""" return self.__initialValue @initialValue.setter def initialValue(self, initialValue): if initialValue is None: initialValue = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(initialValue) self.__initialValue = initialValue @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TexCoordChaser2D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TexCoordChaser2D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TexCoordChaser2D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.duration != 1: attributeResult += " " + '"@duration":"' + SFTime(self.duration).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.initialDestination != []: attributeResult += " " + '"@initialDestination":"' + MFVec2f(self.initialDestination).JSON() + '"' + ',\n' if self.initialValue != []: attributeResult += " " + '"@initialValue":"' + MFVec2f(self.initialValue).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TexCoordChaser2D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TexCoordChaser2D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TexCoordChaser2D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.duration != 1: result += '\n' + indent + ' ' + "duration " + SFTime(self.duration).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.initialDestination != []: result += '\n' + indent + ' ' + "initialDestination " + MFVec2f(self.initialDestination).VRML() + "" if self.initialValue != []: result += '\n' + indent + ' ' + "initialValue " + MFVec2f(self.initialValue).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TexCoordDamper2D(_X3DDamperNode): """ TexCoordDamper2D generates a series of 2D floating-point arrays that progressively change from initial value to destination value. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TexCoordDamper2D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/followers.html#TexCoordDamper2D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TexCoordDamper2D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('initialDestination', [], FieldType.MFVec2f, AccessType.initializeOnly, 'TexCoordDamper2D'), ('initialValue', [], FieldType.MFVec2f, AccessType.initializeOnly, 'TexCoordDamper2D'), ('order', 3, FieldType.SFInt32, AccessType.initializeOnly, 'X3DDamperNode'), ('tau', 0.3, FieldType.SFTime, AccessType.inputOutput, 'X3DDamperNode'), ('tolerance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DDamperNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, initialDestination=None, initialValue=None, order=3, tau=0.3, tolerance=-1, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TexCoordDamper2D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.initialDestination = initialDestination self.initialValue = initialValue self.order = order self.tau = tau self.tolerance = tolerance self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def initialDestination(self): """Initial destination value for this node.""" return self.__initialDestination @initialDestination.setter def initialDestination(self, initialDestination): if initialDestination is None: initialDestination = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(initialDestination) self.__initialDestination = initialDestination @property # getter - - - - - - - - - - def initialValue(self): """Initial starting value for this node.""" return self.__initialValue @initialValue.setter def initialValue(self, initialValue): if initialValue is None: initialValue = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(initialValue) self.__initialValue = initialValue @property # getter - - - - - - - - - - def order(self): """[0,5] order defines the number of internal filters (larger means smoother response, longer delay).""" return self.__order @order.setter def order(self, order): if order is None: order = 3 # default assertValidSFInt32(order) assertGreaterThanEquals('order', order, 0) assertLessThanEquals('order', order, 5) self.__order = order @property # getter - - - - - - - - - - def tau(self): """[0,+infinity) tau is the exponential-decay time constant for filter response in seconds.""" return self.__tau @tau.setter def tau(self, tau): if tau is None: tau = 0.3 # default assertValidSFTime(tau) assertNonNegative('tau', tau) self.__tau = tau @property # getter - - - - - - - - - - def tolerance(self): """[0,+infinity) or -1.""" return self.__tolerance @tolerance.setter def tolerance(self, tolerance): if tolerance is None: tolerance = -1 # default assertValidSFFloat(tolerance) self.__tolerance = tolerance @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TexCoordDamper2D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TexCoordDamper2D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TexCoordDamper2D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.initialDestination != []: attributeResult += " " + '"@initialDestination":"' + MFVec2f(self.initialDestination).JSON() + '"' + ',\n' if self.initialValue != []: attributeResult += " " + '"@initialValue":"' + MFVec2f(self.initialValue).JSON() + '"' + ',\n' if self.order != 3: attributeResult += " " + '"@order":"' + SFInt32(self.order).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.tau != 0.3: attributeResult += " " + '"@tau":"' + SFTime(self.tau).JSON() + '"' + ',\n' if self.tolerance != -1: attributeResult += " " + '"@tolerance":"' + SFFloat(self.tolerance).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TexCoordDamper2D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TexCoordDamper2D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TexCoordDamper2D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.initialDestination != []: result += '\n' + indent + ' ' + "initialDestination " + MFVec2f(self.initialDestination).VRML() + "" if self.initialValue != []: result += '\n' + indent + ' ' + "initialValue " + MFVec2f(self.initialValue).VRML() + "" if self.order != 3: result += '\n' + indent + ' ' + "order " + SFInt32(self.order).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.tau != 0.3: result += '\n' + indent + ' ' + "tau " + SFTime(self.tau).VRML() + "" if self.tolerance != -1: result += '\n' + indent + ' ' + "tolerance " + SFFloat(self.tolerance).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Text(_X3DGeometryNode): """ Text is a 2D (flat) geometry node that can contain multiple lines of string values. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Text' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/text.html#Text' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Text' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('length', [], FieldType.MFFloat, AccessType.inputOutput, 'Text'), ('maxExtent', 0.0, FieldType.SFFloat, AccessType.inputOutput, 'Text'), ('solid', False, FieldType.SFBool, AccessType.inputOutput, 'Text'), ('string', [], FieldType.MFString, AccessType.inputOutput, 'Text'), ('fontStyle', None, FieldType.SFNode, AccessType.inputOutput, 'Text'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, length=None, maxExtent=0.0, solid=False, string=None, fontStyle=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Text __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.length = length self.maxExtent = maxExtent self.solid = solid self.string = string self.fontStyle = fontStyle self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def length(self): """Array of length values for each text string in the local coordinate system.""" return self.__length @length.setter def length(self, length): if length is None: length = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(length) assertNonNegative('length', length) self.__length = length @property # getter - - - - - - - - - - def maxExtent(self): """Limits/compresses all text strings if max string length is longer than maxExtent, as measured in local coordinate system.""" return self.__maxExtent @maxExtent.setter def maxExtent(self, maxExtent): if maxExtent is None: maxExtent = 0.0 # default assertValidSFFloat(maxExtent) assertNonNegative('maxExtent', maxExtent) self.__maxExtent = maxExtent @property # getter - - - - - - - - - - def solid(self): """Setting solid true means draw only one side of polygons (backface culling on), setting solid false means draw both sides of polygons (backface culling off).""" return self.__solid @solid.setter def solid(self, solid): if solid is None: solid = False # default assertValidSFBool(solid) self.__solid = solid @property # getter - - - - - - - - - - def string(self): """Single or multiple string values to present as Text.""" return self.__string @string.setter def string(self, string): if string is None: string = MFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFString.DEFAULT_VALUE()=' + str(MFString.DEFAULT_VALUE())) assertValidMFString(string) self.__string = string @property # getter - - - - - - - - - - def fontStyle(self): """[X3DFontStyleNode] The fontStyle field can contain a FontStyle or ScreenFontStyle node defining size, family, and style for presented text.""" return self.__fontStyle @fontStyle.setter def fontStyle(self, fontStyle): if fontStyle is None: fontStyle = None # default assertValidSFNode(fontStyle) if not fontStyle is None and not isinstance(fontStyle,(_X3DFontStyleNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(fontStyle) + ' does not match required node type (_X3DFontStyleNode,ProtoInstance) and is invalid') self.__fontStyle = fontStyle @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.fontStyle or self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Text.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Text.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Text":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.length != []: attributeResult += " " + '"@length":"' + MFFloat(self.length).JSON() + '"' + ',\n' if self.maxExtent != 0.0: attributeResult += " " + '"@maxExtent":"' + SFFloat(self.maxExtent).JSON() + '"' + ',\n' if self.solid: # default=false attributeResult += " " + '"@solid":"' + SFBool(self.solid).JSON() + '"' + ',\n' if self.string != []: attributeResult += " " + '"@string":"' + MFString(self.string).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.fontStyle: # output this SFNode result += self.fontStyle.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Text.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Text' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Text' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.length != []: result += '\n' + indent + ' ' + "length " + MFFloat(self.length).VRML() + "" if self.maxExtent != 0.0: result += '\n' + indent + ' ' + "maxExtent " + SFFloat(self.maxExtent).VRML() + "" if self.solid: # default=false result += '\n' + indent + ' ' + "solid " + SFBool(self.solid).VRML() + "" if self.string != []: result += '\n' + indent + ' ' + "string " + MFString(self.string).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.fontStyle: # output this SFNode result += '\n' + ' ' + indent + 'fontStyle ' + self.fontStyle.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureBackground(_X3DBackgroundNode): """ TextureBackground simulates ground and sky, using vertical arrays of wraparound color values, TextureBackground can also provide backdrop texture images on all six sides. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureBackground' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalEffects.html#TextureBackground' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureBackground' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('groundAngle', [], FieldType.MFFloat, AccessType.inputOutput, 'X3DBackgroundNode'), ('groundColor', [], FieldType.MFColor, AccessType.inputOutput, 'X3DBackgroundNode'), ('skyAngle', [], FieldType.MFFloat, AccessType.inputOutput, 'X3DBackgroundNode'), ('skyColor', [(0, 0, 0)], FieldType.MFColor, AccessType.inputOutput, 'X3DBackgroundNode'), ('transparency', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DBackgroundNode'), ('backTexture', None, FieldType.SFNode, AccessType.inputOutput, 'TextureBackground'), ('bottomTexture', None, FieldType.SFNode, AccessType.inputOutput, 'TextureBackground'), ('frontTexture', None, FieldType.SFNode, AccessType.inputOutput, 'TextureBackground'), ('leftTexture', None, FieldType.SFNode, AccessType.inputOutput, 'TextureBackground'), ('rightTexture', None, FieldType.SFNode, AccessType.inputOutput, 'TextureBackground'), ('topTexture', None, FieldType.SFNode, AccessType.inputOutput, 'TextureBackground'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, groundAngle=None, groundColor=None, skyAngle=None, skyColor=None, transparency=0, backTexture=None, bottomTexture=None, frontTexture=None, leftTexture=None, rightTexture=None, topTexture=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureBackground __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.groundAngle = groundAngle self.groundColor = groundColor self.skyAngle = skyAngle self.skyColor = skyColor self.transparency = transparency self.backTexture = backTexture self.bottomTexture = bottomTexture self.frontTexture = frontTexture self.leftTexture = leftTexture self.rightTexture = rightTexture self.topTexture = topTexture self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def groundAngle(self): """[0,pi/2] The angle array values increase from 0.""" return self.__groundAngle @groundAngle.setter def groundAngle(self, groundAngle): if groundAngle is None: groundAngle = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(groundAngle) assertGreaterThanEquals('groundAngle', groundAngle, 0) assertLessThanEquals('groundAngle', groundAngle, 1.5708) self.__groundAngle = groundAngle @property # getter - - - - - - - - - - def groundColor(self): """Color of the ground at the various angles on the ground partial sphere.""" return self.__groundColor @groundColor.setter def groundColor(self, groundColor): if groundColor is None: groundColor = MFColor.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFColor.DEFAULT_VALUE()=' + str(MFColor.DEFAULT_VALUE())) assertValidMFColor(groundColor) assertZeroToOne('groundColor', groundColor) self.__groundColor = groundColor @property # getter - - - - - - - - - - def skyAngle(self): """[0,pi] The angle array values increase from 0.""" return self.__skyAngle @skyAngle.setter def skyAngle(self, skyAngle): if skyAngle is None: skyAngle = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(skyAngle) assertGreaterThanEquals('skyAngle', skyAngle, 0) assertLessThanEquals('skyAngle', skyAngle, 3.1416) self.__skyAngle = skyAngle @property # getter - - - - - - - - - - def skyColor(self): """Color of the sky at various angles on the sky sphere.""" return self.__skyColor @skyColor.setter def skyColor(self, skyColor): if skyColor is None: skyColor = [(0, 0, 0)] # default assertValidMFColor(skyColor) assertZeroToOne('skyColor', skyColor) self.__skyColor = skyColor @property # getter - - - - - - - - - - def transparency(self): """transparency applied to texture images, enabling an X3D scene to overlay an HTML page or desktop.""" return self.__transparency @transparency.setter def transparency(self, transparency): if transparency is None: transparency = 0 # default assertValidSFFloat(transparency) assertZeroToOne('transparency', transparency) self.__transparency = transparency @property # getter - - - - - - - - - - def backTexture(self): """[X3DTexture2DNode|MultiTexture] Parent TextureBackground element can contain up to six image nodes (ImageTexture PixelTexture MovieTexture MultiTexture).""" return self.__backTexture @backTexture.setter def backTexture(self, backTexture): if backTexture is None: backTexture = None # default assertValidSFNode(backTexture) if not backTexture is None and not isinstance(backTexture,(_X3DTexture2DNode,MultiTexture,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(backTexture) + ' does not match required node type (_X3DTexture2DNode,MultiTexture,ProtoInstance) and is invalid') self.__backTexture = backTexture @property # getter - - - - - - - - - - def bottomTexture(self): """[X3DTexture2DNode|MultiTexture] Parent TextureBackground element can contain up to six image nodes (ImageTexture PixelTexture MovieTexture MultiTexture).""" return self.__bottomTexture @bottomTexture.setter def bottomTexture(self, bottomTexture): if bottomTexture is None: bottomTexture = None # default assertValidSFNode(bottomTexture) if not bottomTexture is None and not isinstance(bottomTexture,(_X3DTexture2DNode,MultiTexture,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(bottomTexture) + ' does not match required node type (_X3DTexture2DNode,MultiTexture,ProtoInstance) and is invalid') self.__bottomTexture = bottomTexture @property # getter - - - - - - - - - - def frontTexture(self): """[X3DTexture2DNode|MultiTexture] Parent TextureBackground element can contain up to six image nodes (ImageTexture PixelTexture MovieTexture MultiTexture).""" return self.__frontTexture @frontTexture.setter def frontTexture(self, frontTexture): if frontTexture is None: frontTexture = None # default assertValidSFNode(frontTexture) if not frontTexture is None and not isinstance(frontTexture,(_X3DTexture2DNode,MultiTexture,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(frontTexture) + ' does not match required node type (_X3DTexture2DNode,MultiTexture,ProtoInstance) and is invalid') self.__frontTexture = frontTexture @property # getter - - - - - - - - - - def leftTexture(self): """[X3DTexture2DNode|MultiTexture] Parent TextureBackground element can contain up to six image nodes (ImageTexture PixelTexture MovieTexture MultiTexture).""" return self.__leftTexture @leftTexture.setter def leftTexture(self, leftTexture): if leftTexture is None: leftTexture = None # default assertValidSFNode(leftTexture) if not leftTexture is None and not isinstance(leftTexture,(_X3DTexture2DNode,MultiTexture,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(leftTexture) + ' does not match required node type (_X3DTexture2DNode,MultiTexture,ProtoInstance) and is invalid') self.__leftTexture = leftTexture @property # getter - - - - - - - - - - def rightTexture(self): """[X3DTexture2DNode|MultiTexture] Parent TextureBackground element can contain up to six image nodes (ImageTexture PixelTexture MovieTexture MultiTexture).""" return self.__rightTexture @rightTexture.setter def rightTexture(self, rightTexture): if rightTexture is None: rightTexture = None # default assertValidSFNode(rightTexture) if not rightTexture is None and not isinstance(rightTexture,(_X3DTexture2DNode,MultiTexture,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(rightTexture) + ' does not match required node type (_X3DTexture2DNode,MultiTexture,ProtoInstance) and is invalid') self.__rightTexture = rightTexture @property # getter - - - - - - - - - - def topTexture(self): """[X3DTexture2DNode|MultiTexture] Parent TextureBackground element can contain up to six image nodes (ImageTexture PixelTexture MovieTexture MultiTexture).""" return self.__topTexture @topTexture.setter def topTexture(self, topTexture): if topTexture is None: topTexture = None # default assertValidSFNode(topTexture) if not topTexture is None and not isinstance(topTexture,(_X3DTexture2DNode,MultiTexture,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(topTexture) + ' does not match required node type (_X3DTexture2DNode,MultiTexture,ProtoInstance) and is invalid') self.__topTexture = topTexture @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.backTexture or self.bottomTexture or self.frontTexture or self.IS or self.leftTexture or self.metadata or self.rightTexture or self.topTexture # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureBackground.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureBackground.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureBackground":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.groundAngle != []: attributeResult += " " + '"@groundAngle":"' + MFFloat(self.groundAngle).JSON() + '"' + ',\n' if self.groundColor != []: attributeResult += " " + '"@groundColor":"' + MFColor(self.groundColor).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.skyAngle != []: attributeResult += " " + '"@skyAngle":"' + MFFloat(self.skyAngle).JSON() + '"' + ',\n' if self.skyColor != [(0, 0, 0)]: attributeResult += " " + '"@skyColor":"' + MFColor(self.skyColor).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.transparency != 0: attributeResult += " " + '"@transparency":"' + SFFloat(self.transparency).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.backTexture: # output this SFNode result += self.backTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.bottomTexture: # output this SFNode result += self.bottomTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.frontTexture: # output this SFNode result += self.frontTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.leftTexture: # output this SFNode result += self.leftTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.rightTexture: # output this SFNode result += self.rightTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.topTexture: # output this SFNode result += self.topTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureBackground.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureBackground' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureBackground' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.groundAngle != []: result += '\n' + indent + ' ' + "groundAngle " + MFFloat(self.groundAngle).VRML() + "" if self.groundColor != []: result += '\n' + indent + ' ' + "groundColor " + MFColor(self.groundColor).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.skyAngle != []: result += '\n' + indent + ' ' + "skyAngle " + MFFloat(self.skyAngle).VRML() + "" if self.skyColor != [(0, 0, 0)]: result += '\n' + indent + ' ' + "skyColor " + MFColor(self.skyColor).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.transparency != 0: result += '\n' + indent + ' ' + "transparency " + SFFloat(self.transparency).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.backTexture: # output this SFNode result += '\n' + ' ' + indent + 'backTexture ' + self.backTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.bottomTexture: # output this SFNode result += '\n' + ' ' + indent + 'bottomTexture ' + self.bottomTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.frontTexture: # output this SFNode result += '\n' + ' ' + indent + 'frontTexture ' + self.frontTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.leftTexture: # output this SFNode result += '\n' + ' ' + indent + 'leftTexture ' + self.leftTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.rightTexture: # output this SFNode result += '\n' + ' ' + indent + 'rightTexture ' + self.rightTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.topTexture: # output this SFNode result += '\n' + ' ' + indent + 'topTexture ' + self.topTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureCoordinate(_X3DSingleTextureCoordinateNode): """ TextureCoordinate specifies 2D (s,t) texture-coordinate points, used by vertex-based geometry nodes (such as IndexedFaceSet or ElevationGrid) to map textures to vertices (and patches to NURBS surfaces). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureCoordinate' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#TextureCoordinate' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureCoordinate' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('mapping', '', FieldType.SFString, AccessType.inputOutput, 'X3DSingleTextureCoordinateNode'), ('point', [], FieldType.MFVec2f, AccessType.inputOutput, 'TextureCoordinate'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, mapping='', point=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureCoordinate __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.mapping = mapping self.point = point self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def mapping(self): """The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material.""" return self.__mapping @mapping.setter def mapping(self, mapping): if mapping is None: mapping = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(mapping) self.__mapping = mapping @property # getter - - - - - - - - - - def point(self): """pairs of 2D (s,t) texture coordinates, either in range [0,1] or higher if repeating.""" return self.__point @point.setter def point(self, point): if point is None: point = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(point) self.__point = point @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinate.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinate.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureCoordinate":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.mapping: attributeResult += " " + '"@mapping":"' + SFString(self.mapping).JSON() + '"' + ',\n' if self.point != []: attributeResult += " " + '"@point":"' + MFVec2f(self.point).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureCoordinate.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureCoordinate' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureCoordinate' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.mapping: result += '\n' + indent + ' ' + "mapping " + '"' + self.mapping + '"' + "" if self.point != []: result += '\n' + indent + ' ' + "point " + MFVec2f(self.point).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureCoordinate3D(_X3DSingleTextureCoordinateNode): """ TextureCoordinate3D specifies a set of 3D texture coordinates used by vertex-based geometry nodes (such as IndexedFaceSet or ElevationGrid) to map 3D textures to vertices. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureCoordinate3D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texture3D.html#TextureCoordinate3D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureCoordinate3D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('mapping', '', FieldType.SFString, AccessType.inputOutput, 'X3DSingleTextureCoordinateNode'), ('point', [], FieldType.MFVec3f, AccessType.inputOutput, 'TextureCoordinate3D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, mapping='', point=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureCoordinate3D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.mapping = mapping self.point = point self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def mapping(self): """The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material.""" return self.__mapping @mapping.setter def mapping(self, mapping): if mapping is None: mapping = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(mapping) self.__mapping = mapping @property # getter - - - - - - - - - - def point(self): """triplets of 3D (s,t,r) texture coordinates, either in range [0,1] or higher if repeating.""" return self.__point @point.setter def point(self, point): if point is None: point = MFVec3f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec3f.DEFAULT_VALUE()=' + str(MFVec3f.DEFAULT_VALUE())) assertValidMFVec3f(point) self.__point = point @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinate3D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinate3D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureCoordinate3D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.mapping: attributeResult += " " + '"@mapping":"' + SFString(self.mapping).JSON() + '"' + ',\n' if self.point != []: attributeResult += " " + '"@point":"' + MFVec3f(self.point).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureCoordinate3D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureCoordinate3D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureCoordinate3D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.mapping: result += '\n' + indent + ' ' + "mapping " + '"' + self.mapping + '"' + "" if self.point != []: result += '\n' + indent + ' ' + "point " + MFVec3f(self.point).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureCoordinate4D(_X3DSingleTextureCoordinateNode): """ TextureCoordinate4D specifies a set of 4D (homogeneous 3D) texture coordinates used by vertex-based geometry nodes (such as IndexedFaceSet or ElevationGrid) to map 3D textures to vertices. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureCoordinate4D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texture3D.html#TextureCoordinate4D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureCoordinate4D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('mapping', '', FieldType.SFString, AccessType.inputOutput, 'X3DSingleTextureCoordinateNode'), ('point', [], FieldType.MFVec4f, AccessType.inputOutput, 'TextureCoordinate4D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, mapping='', point=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureCoordinate4D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.mapping = mapping self.point = point self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def mapping(self): """The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material.""" return self.__mapping @mapping.setter def mapping(self, mapping): if mapping is None: mapping = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(mapping) self.__mapping = mapping @property # getter - - - - - - - - - - def point(self): """4-tuple values of 4D texture coordinates, either in range [0,1] or higher if repeating.""" return self.__point @point.setter def point(self, point): if point is None: point = MFVec4f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec4f.DEFAULT_VALUE()=' + str(MFVec4f.DEFAULT_VALUE())) assertValidMFVec4f(point) self.__point = point @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinate4D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinate4D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureCoordinate4D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.mapping: attributeResult += " " + '"@mapping":"' + SFString(self.mapping).JSON() + '"' + ',\n' if self.point != []: attributeResult += " " + '"@point":"' + MFVec4f(self.point).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureCoordinate4D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureCoordinate4D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureCoordinate4D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.mapping: result += '\n' + indent + ' ' + "mapping " + '"' + self.mapping + '"' + "" if self.point != []: result += '\n' + indent + ' ' + "point " + MFVec4f(self.point).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureCoordinateGenerator(_X3DSingleTextureCoordinateNode): """ TextureCoordinateGenerator computes 2D (s,t) texture-coordinate points, used by vertex-based geometry nodes (such as IndexedFaceSet or ElevationGrid) to map textures to vertices (and patches to NURBS surfaces). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureCoordinateGenerator' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#TextureCoordinateGenerator' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureCoordinateGenerator' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('mapping', '', FieldType.SFString, AccessType.inputOutput, 'X3DSingleTextureCoordinateNode'), ('mode', 'SPHERE', FieldType.SFString, AccessType.inputOutput, 'TextureCoordinateGenerator'), ('parameter', [], FieldType.MFFloat, AccessType.inputOutput, 'TextureCoordinateGenerator'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, mapping='', mode='SPHERE', parameter=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureCoordinateGenerator __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.mapping = mapping self.mode = mode self.parameter = parameter self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def mapping(self): """The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material.""" return self.__mapping @mapping.setter def mapping(self, mapping): if mapping is None: mapping = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(mapping) self.__mapping = mapping @property # getter - - - - - - - - - - def mode(self): """parameter field defines the algorithm used to compute texture coordinates.""" return self.__mode @mode.setter def mode(self, mode): if mode is None: mode = 'SPHERE' # default assertValidSFString(mode) assertValidTextureCoordinateGeneratorMode('mode', mode) self.__mode = mode @property # getter - - - - - - - - - - def parameter(self): """parameter array contains scale and translation (x y z) values for Perlin NOISE mode, parameter[0] contains index of refraction for SPHERE-REFLECT mode, parameter[0] contains index of refraction and parameter[1 to 3] contains the eye point in local coordinates for SPHERE-REFLECT-LOCAL mode.""" return self.__parameter @parameter.setter def parameter(self, parameter): if parameter is None: parameter = MFFloat.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFFloat.DEFAULT_VALUE()=' + str(MFFloat.DEFAULT_VALUE())) assertValidMFFloat(parameter) self.__parameter = parameter @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinateGenerator.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureCoordinateGenerator.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureCoordinateGenerator":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.mapping: attributeResult += " " + '"@mapping":"' + SFString(self.mapping).JSON() + '"' + ',\n' if self.mode != 'SPHERE': attributeResult += " " + '"@mode":"' + SFString(self.mode).JSON() + '"' + ',\n' if self.parameter != []: attributeResult += " " + '"@parameter":"' + MFFloat(self.parameter).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureCoordinateGenerator.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureCoordinateGenerator' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureCoordinateGenerator' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.mapping: result += '\n' + indent + ' ' + "mapping " + '"' + self.mapping + '"' + "" if self.mode != 'SPHERE': result += '\n' + indent + ' ' + "mode " + '"' + self.mode + '"' + "" if self.parameter != []: result += '\n' + indent + ' ' + "parameter " + MFFloat(self.parameter).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureProjector(_X3DTextureProjectorNode): """ TextureProjector is similar to a light that projects a texture into the scene, illuminating geometry that intersects the perspective projection volume. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureProjector' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/textureProjector.html#TextureProjector' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureProjector' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ambientIntensity', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('color', (1, 1, 1), FieldType.SFColor, AccessType.inputOutput, 'X3DLightNode'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('direction', (0, 0, 1), FieldType.SFVec3f, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('farDistance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('fieldOfView', 0.7854, FieldType.SFFloat, AccessType.inputOutput, 'TextureProjector'), ('global_', True, FieldType.SFBool, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('intensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('location', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('nearDistance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('on', True, FieldType.SFBool, AccessType.inputOutput, 'X3DLightNode'), ('shadowIntensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('shadows', False, FieldType.SFBool, AccessType.inputOutput, 'X3DLightNode'), ('upVector', (0, 0, 1), FieldType.SFVec3f, AccessType.inputOutput, 'TextureProjector'), ('texture', None, FieldType.SFNode, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ambientIntensity=0, color=(1, 1, 1), description='', direction=(0, 0, 1), farDistance=-1, fieldOfView=0.7854, global_=True, intensity=1, location=(0, 0, 0), nearDistance=-1, on=True, shadowIntensity=1, shadows=False, upVector=(0, 0, 1), texture=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureProjector __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ambientIntensity = ambientIntensity self.color = color self.description = description self.direction = direction self.farDistance = farDistance self.fieldOfView = fieldOfView self.global_ = global_ self.intensity = intensity self.location = location self.nearDistance = nearDistance self.on = on self.shadowIntensity = shadowIntensity self.shadows = shadows self.upVector = upVector self.texture = texture self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ambientIntensity(self): """[0,1] Brightness of ambient (nondirectional background) emission from the light.""" return self.__ambientIntensity @ambientIntensity.setter def ambientIntensity(self, ambientIntensity): if ambientIntensity is None: ambientIntensity = 0 # default assertValidSFFloat(ambientIntensity) assertZeroToOne('ambientIntensity', ambientIntensity) self.__ambientIntensity = ambientIntensity @property # getter - - - - - - - - - - def color(self): """[0,1] color of light, applied to colors of objects.""" return self.__color @color.setter def color(self, color): if color is None: color = (1, 1, 1) # default assertValidSFColor(color) assertZeroToOne('color', color) self.__color = color @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def direction(self): """Direction for projection.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (0, 0, 1) # default assertValidSFVec3f(direction) self.__direction = direction @property # getter - - - - - - - - - - def farDistance(self): """or (0,+infinity) maximum distance necessary for texture display.""" return self.__farDistance @farDistance.setter def farDistance(self, farDistance): if farDistance is None: farDistance = -1 # default assertValidSFFloat(farDistance) assertGreaterThanEquals('farDistance', farDistance, -1) self.__farDistance = farDistance @property # getter - - - - - - - - - - def fieldOfView(self): """Preferred minimum viewing angle for this projection in radians, providing minimum height or minimum width (whichever is smaller).""" return self.__fieldOfView @fieldOfView.setter def fieldOfView(self, fieldOfView): if fieldOfView is None: fieldOfView = 0.7854 # default assertValidSFFloat(fieldOfView) assertGreaterThanEquals('fieldOfView', fieldOfView, 0) assertLessThanEquals('fieldOfView', fieldOfView, 3.1416) self.__fieldOfView = fieldOfView @property # getter - - - - - - - - - - def global_(self): """Global texture projection illuminates all objects within their volume of influence.""" return self.__global_ @global_.setter def global_(self, global_): if global_ is None: global_ = True # default assertValidSFBool(global_) self.__global_ = global_ @property # getter - - - - - - - - - - def intensity(self): """[0,1] Brightness of direct emission from the light.""" return self.__intensity @intensity.setter def intensity(self, intensity): if intensity is None: intensity = 1 # default assertValidSFFloat(intensity) assertNonNegative('intensity', intensity) self.__intensity = intensity @property # getter - - - - - - - - - - def location(self): """Position of center of texture projection relative to local coordinate system.""" return self.__location @location.setter def location(self, location): if location is None: location = (0, 0, 0) # default assertValidSFVec3f(location) self.__location = location @property # getter - - - - - - - - - - def nearDistance(self): """or (0,+infinity) minimum distance necessary for texture display.""" return self.__nearDistance @nearDistance.setter def nearDistance(self, nearDistance): if nearDistance is None: nearDistance = -1 # default assertValidSFFloat(nearDistance) assertGreaterThanEquals('nearDistance', nearDistance, -1) self.__nearDistance = nearDistance @property # getter - - - - - - - - - - def on(self): """Enables/disables this texture projection source.""" return self.__on @on.setter def on(self, on): if on is None: on = True # default assertValidSFBool(on) self.__on = on @property # getter - - - - - - - - - - def shadowIntensity(self): """[0,1] shadowIntensity field defines how much light is obscured by shapes that cast shadows, ranging from 0 (light not obscured, no visible shadows) to 1 (light completely obscured, full-intensity shadows).""" return self.__shadowIntensity @shadowIntensity.setter def shadowIntensity(self, shadowIntensity): if shadowIntensity is None: shadowIntensity = 1 # default assertValidSFFloat(shadowIntensity) assertZeroToOne('shadowIntensity', shadowIntensity) self.__shadowIntensity = shadowIntensity @property # getter - - - - - - - - - - def shadows(self): """shadows field indicates whether or not this light casts a shadow behind illuminated X3DShapeNode geometry.""" return self.__shadows @shadows.setter def shadows(self, shadows): if shadows is None: shadows = False # default assertValidSFBool(shadows) self.__shadows = shadows @property # getter - - - - - - - - - - def upVector(self): """upVector describes the roll of the camera by saying which direction is up for the camera's orientation.""" return self.__upVector @upVector.setter def upVector(self, upVector): if upVector is None: upVector = (0, 0, 1) # default assertValidSFVec3f(upVector) self.__upVector = upVector @property # getter - - - - - - - - - - def texture(self): """[X3DTextureNode] Single contained texture node (ImageTexture, MovieTexture, PixelTexture, MultiTexture) that maps image(s) to surface geometry.""" return self.__texture @texture.setter def texture(self, texture): if texture is None: texture = None # default assertValidSFNode(texture) if not texture is None and not isinstance(texture,(_X3DTexture2DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(texture) + ' does not match required node type (_X3DTexture2DNode,ProtoInstance) and is invalid') self.__texture = texture @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.texture # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureProjector.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureProjector.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureProjector":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.ambientIntensity != 0: attributeResult += " " + '"@ambientIntensity":"' + SFFloat(self.ambientIntensity).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.color != (1, 1, 1): attributeResult += " " + '"@color":"' + SFColor(self.color).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.direction != (0, 0, 1): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if self.farDistance != -1: attributeResult += " " + '"@farDistance":"' + SFFloat(self.farDistance).JSON() + '"' + ',\n' if self.fieldOfView != 0.7854: attributeResult += " " + '"@fieldOfView":"' + SFFloat(self.fieldOfView).JSON() + '"' + ',\n' if not self.global_: # default=true attributeResult += " " + '"@global":"' + SFBool(self.global_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.intensity != 1: attributeResult += " " + '"@intensity":"' + SFFloat(self.intensity).JSON() + '"' + ',\n' if self.location != (0, 0, 0): attributeResult += " " + '"@location":"' + SFVec3f(self.location).JSON() + '"' + ',\n' if self.nearDistance != -1: attributeResult += " " + '"@nearDistance":"' + SFFloat(self.nearDistance).JSON() + '"' + ',\n' if not self.on: # default=true attributeResult += " " + '"@on":"' + SFBool(self.on).JSON() + '"' + ',\n' if self.shadowIntensity != 1: attributeResult += " " + '"@shadowIntensity":"' + SFFloat(self.shadowIntensity).JSON() + '"' + ',\n' if self.shadows: # default=false attributeResult += " " + '"@shadows":"' + SFBool(self.shadows).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.upVector != (0, 0, 1): attributeResult += " " + '"@upVector":"' + SFVec3f(self.upVector).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.texture: # output this SFNode result += self.texture.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureProjector.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureProjector' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureProjector' + ' {' if self.ambientIntensity != 0: result += '\n' + indent + ' ' + "ambientIntensity " + SFFloat(self.ambientIntensity).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.color != (1, 1, 1): result += '\n' + indent + ' ' + "color " + SFColor(self.color).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.direction != (0, 0, 1): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if self.farDistance != -1: result += '\n' + indent + ' ' + "farDistance " + SFFloat(self.farDistance).VRML() + "" if self.fieldOfView != 0.7854: result += '\n' + indent + ' ' + "fieldOfView " + SFFloat(self.fieldOfView).VRML() + "" if not self.global_: # default=true result += '\n' + indent + ' ' + "global " + SFBool(self.global_).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.intensity != 1: result += '\n' + indent + ' ' + "intensity " + SFFloat(self.intensity).VRML() + "" if self.location != (0, 0, 0): result += '\n' + indent + ' ' + "location " + SFVec3f(self.location).VRML() + "" if self.nearDistance != -1: result += '\n' + indent + ' ' + "nearDistance " + SFFloat(self.nearDistance).VRML() + "" if not self.on: # default=true result += '\n' + indent + ' ' + "on " + SFBool(self.on).VRML() + "" if self.shadowIntensity != 1: result += '\n' + indent + ' ' + "shadowIntensity " + SFFloat(self.shadowIntensity).VRML() + "" if self.shadows: # default=false result += '\n' + indent + ' ' + "shadows " + SFBool(self.shadows).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.upVector != (0, 0, 1): result += '\n' + indent + ' ' + "upVector " + SFVec3f(self.upVector).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.texture: # output this SFNode result += '\n' + ' ' + indent + 'texture ' + self.texture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureProjectorParallel(_X3DTextureProjectorNode): """ TextureProjectorParallel is similar to a light that projects a texture into the scene, illuminating geometry that intersects the parallel projection volume. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureProjectorParallel' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/textureProjector.html#TextureProjectorParallel' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureProjectorParallel' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ambientIntensity', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('color', (1, 1, 1), FieldType.SFColor, AccessType.inputOutput, 'X3DLightNode'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('direction', (0, 0, 1), FieldType.SFVec3f, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('farDistance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('fieldOfView', (-1, -1, 1, 1), FieldType.SFVec4f, AccessType.inputOutput, 'TextureProjectorParallel'), ('global_', True, FieldType.SFBool, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('intensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('location', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('nearDistance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('on', True, FieldType.SFBool, AccessType.inputOutput, 'X3DLightNode'), ('shadowIntensity', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DLightNode'), ('shadows', False, FieldType.SFBool, AccessType.inputOutput, 'X3DLightNode'), ('texture', None, FieldType.SFNode, AccessType.inputOutput, 'X3DTextureProjectorNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ambientIntensity=0, color=(1, 1, 1), description='', direction=(0, 0, 1), farDistance=-1, fieldOfView=(-1, -1, 1, 1), global_=True, intensity=1, location=(0, 0, 0), nearDistance=-1, on=True, shadowIntensity=1, shadows=False, texture=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureProjectorParallel __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ambientIntensity = ambientIntensity self.color = color self.description = description self.direction = direction self.farDistance = farDistance self.fieldOfView = fieldOfView self.global_ = global_ self.intensity = intensity self.location = location self.nearDistance = nearDistance self.on = on self.shadowIntensity = shadowIntensity self.shadows = shadows self.texture = texture self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ambientIntensity(self): """[0,1] Brightness of ambient (nondirectional background) emission from the light.""" return self.__ambientIntensity @ambientIntensity.setter def ambientIntensity(self, ambientIntensity): if ambientIntensity is None: ambientIntensity = 0 # default assertValidSFFloat(ambientIntensity) assertZeroToOne('ambientIntensity', ambientIntensity) self.__ambientIntensity = ambientIntensity @property # getter - - - - - - - - - - def color(self): """[0,1] color of light, applied to colors of objects.""" return self.__color @color.setter def color(self, color): if color is None: color = (1, 1, 1) # default assertValidSFColor(color) assertZeroToOne('color', color) self.__color = color @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def direction(self): """Direction for projection.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (0, 0, 1) # default assertValidSFVec3f(direction) self.__direction = direction @property # getter - - - - - - - - - - def farDistance(self): """or (0,+infinity) maximum distance necessary for texture display.""" return self.__farDistance @farDistance.setter def farDistance(self, farDistance): if farDistance is None: farDistance = -1 # default assertValidSFFloat(farDistance) assertGreaterThanEquals('farDistance', farDistance, -1) self.__farDistance = farDistance @property # getter - - - - - - - - - - def fieldOfView(self): """Minimum and maximum extents of projection texture in units of local coordinate system.""" return self.__fieldOfView @fieldOfView.setter def fieldOfView(self, fieldOfView): if fieldOfView is None: fieldOfView = (-1, -1, 1, 1) # default assertValidSFVec4f(fieldOfView) self.__fieldOfView = fieldOfView @property # getter - - - - - - - - - - def global_(self): """Global texture projection illuminates all objects within their volume of influence.""" return self.__global_ @global_.setter def global_(self, global_): if global_ is None: global_ = True # default assertValidSFBool(global_) self.__global_ = global_ @property # getter - - - - - - - - - - def intensity(self): """[0,1] Brightness of direct emission from the light.""" return self.__intensity @intensity.setter def intensity(self, intensity): if intensity is None: intensity = 1 # default assertValidSFFloat(intensity) assertNonNegative('intensity', intensity) self.__intensity = intensity @property # getter - - - - - - - - - - def location(self): """Position of center of texture projection relative to local coordinate system.""" return self.__location @location.setter def location(self, location): if location is None: location = (0, 0, 0) # default assertValidSFVec3f(location) self.__location = location @property # getter - - - - - - - - - - def nearDistance(self): """or (0,+infinity) minimum distance necessary for texture display.""" return self.__nearDistance @nearDistance.setter def nearDistance(self, nearDistance): if nearDistance is None: nearDistance = -1 # default assertValidSFFloat(nearDistance) assertGreaterThanEquals('nearDistance', nearDistance, -1) self.__nearDistance = nearDistance @property # getter - - - - - - - - - - def on(self): """Enables/disables this texture projection source.""" return self.__on @on.setter def on(self, on): if on is None: on = True # default assertValidSFBool(on) self.__on = on @property # getter - - - - - - - - - - def shadowIntensity(self): """[0,1] shadowIntensity field defines how much light is obscured by shapes that cast shadows, ranging from 0 (light not obscured, no visible shadows) to 1 (light completely obscured, full-intensity shadows).""" return self.__shadowIntensity @shadowIntensity.setter def shadowIntensity(self, shadowIntensity): if shadowIntensity is None: shadowIntensity = 1 # default assertValidSFFloat(shadowIntensity) assertZeroToOne('shadowIntensity', shadowIntensity) self.__shadowIntensity = shadowIntensity @property # getter - - - - - - - - - - def shadows(self): """shadows field indicates whether or not this light casts a shadow behind illuminated X3DShapeNode geometry.""" return self.__shadows @shadows.setter def shadows(self, shadows): if shadows is None: shadows = False # default assertValidSFBool(shadows) self.__shadows = shadows @property # getter - - - - - - - - - - def texture(self): """[X3DTextureNode] Single contained texture node (ImageTexture, MovieTexture, PixelTexture, MultiTexture) that maps image(s) to surface geometry.""" return self.__texture @texture.setter def texture(self, texture): if texture is None: texture = None # default assertValidSFNode(texture) if not texture is None and not isinstance(texture,(_X3DTexture2DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(texture) + ' does not match required node type (_X3DTexture2DNode,ProtoInstance) and is invalid') self.__texture = texture @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.texture # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureProjectorParallel.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureProjectorParallel.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureProjectorParallel":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.ambientIntensity != 0: attributeResult += " " + '"@ambientIntensity":"' + SFFloat(self.ambientIntensity).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.color != (1, 1, 1): attributeResult += " " + '"@color":"' + SFColor(self.color).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.direction != (0, 0, 1): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if self.farDistance != -1: attributeResult += " " + '"@farDistance":"' + SFFloat(self.farDistance).JSON() + '"' + ',\n' if self.fieldOfView != (-1, -1, 1, 1): attributeResult += " " + '"@fieldOfView":"' + SFVec4f(self.fieldOfView).JSON() + '"' + ',\n' if not self.global_: # default=true attributeResult += " " + '"@global":"' + SFBool(self.global_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.intensity != 1: attributeResult += " " + '"@intensity":"' + SFFloat(self.intensity).JSON() + '"' + ',\n' if self.location != (0, 0, 0): attributeResult += " " + '"@location":"' + SFVec3f(self.location).JSON() + '"' + ',\n' if self.nearDistance != -1: attributeResult += " " + '"@nearDistance":"' + SFFloat(self.nearDistance).JSON() + '"' + ',\n' if not self.on: # default=true attributeResult += " " + '"@on":"' + SFBool(self.on).JSON() + '"' + ',\n' if self.shadowIntensity != 1: attributeResult += " " + '"@shadowIntensity":"' + SFFloat(self.shadowIntensity).JSON() + '"' + ',\n' if self.shadows: # default=false attributeResult += " " + '"@shadows":"' + SFBool(self.shadows).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.texture: # output this SFNode result += self.texture.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureProjectorParallel.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureProjectorParallel' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureProjectorParallel' + ' {' if self.ambientIntensity != 0: result += '\n' + indent + ' ' + "ambientIntensity " + SFFloat(self.ambientIntensity).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.color != (1, 1, 1): result += '\n' + indent + ' ' + "color " + SFColor(self.color).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.direction != (0, 0, 1): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if self.farDistance != -1: result += '\n' + indent + ' ' + "farDistance " + SFFloat(self.farDistance).VRML() + "" if self.fieldOfView != (-1, -1, 1, 1): result += '\n' + indent + ' ' + "fieldOfView " + SFVec4f(self.fieldOfView).VRML() + "" if not self.global_: # default=true result += '\n' + indent + ' ' + "global " + SFBool(self.global_).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.intensity != 1: result += '\n' + indent + ' ' + "intensity " + SFFloat(self.intensity).VRML() + "" if self.location != (0, 0, 0): result += '\n' + indent + ' ' + "location " + SFVec3f(self.location).VRML() + "" if self.nearDistance != -1: result += '\n' + indent + ' ' + "nearDistance " + SFFloat(self.nearDistance).VRML() + "" if not self.on: # default=true result += '\n' + indent + ' ' + "on " + SFBool(self.on).VRML() + "" if self.shadowIntensity != 1: result += '\n' + indent + ' ' + "shadowIntensity " + SFFloat(self.shadowIntensity).VRML() + "" if self.shadows: # default=false result += '\n' + indent + ' ' + "shadows " + SFBool(self.shadows).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.texture: # output this SFNode result += '\n' + ' ' + indent + 'texture ' + self.texture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureProperties(_X3DNode): """ TextureProperties allows precise fine-grained control over application of image textures to geometry. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureProperties' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#TextureProperties' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureProperties' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('anisotropicDegree', 1, FieldType.SFFloat, AccessType.inputOutput, 'TextureProperties'), ('borderColor', (0, 0, 0, 0), FieldType.SFColorRGBA, AccessType.inputOutput, 'TextureProperties'), ('borderWidth', 0, FieldType.SFInt32, AccessType.inputOutput, 'TextureProperties'), ('boundaryModeR', 'REPEAT', FieldType.SFString, AccessType.inputOutput, 'TextureProperties'), ('boundaryModeS', 'REPEAT', FieldType.SFString, AccessType.inputOutput, 'TextureProperties'), ('boundaryModeT', 'REPEAT', FieldType.SFString, AccessType.inputOutput, 'TextureProperties'), ('generateMipMaps', False, FieldType.SFBool, AccessType.initializeOnly, 'TextureProperties'), ('magnificationFilter', 'FASTEST', FieldType.SFString, AccessType.inputOutput, 'TextureProperties'), ('minificationFilter', 'FASTEST', FieldType.SFString, AccessType.inputOutput, 'TextureProperties'), ('textureCompression', 'FASTEST', FieldType.SFString, AccessType.inputOutput, 'TextureProperties'), ('texturePriority', 0, FieldType.SFFloat, AccessType.inputOutput, 'TextureProperties'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, anisotropicDegree=1, borderColor=(0, 0, 0, 0), borderWidth=0, boundaryModeR='REPEAT', boundaryModeS='REPEAT', boundaryModeT='REPEAT', generateMipMaps=False, magnificationFilter='FASTEST', minificationFilter='FASTEST', textureCompression='FASTEST', texturePriority=0, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureProperties __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.anisotropicDegree = anisotropicDegree self.borderColor = borderColor self.borderWidth = borderWidth self.boundaryModeR = boundaryModeR self.boundaryModeS = boundaryModeS self.boundaryModeT = boundaryModeT self.generateMipMaps = generateMipMaps self.magnificationFilter = magnificationFilter self.minificationFilter = minificationFilter self.textureCompression = textureCompression self.texturePriority = texturePriority self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def anisotropicDegree(self): """[1,+infinity) anisotropicDegree defines minimum degree of anisotropy to account for in texture filtering (1=no effect for symmetric filtering, otherwise provide higher value).""" return self.__anisotropicDegree @anisotropicDegree.setter def anisotropicDegree(self, anisotropicDegree): if anisotropicDegree is None: anisotropicDegree = 1 # default assertValidSFFloat(anisotropicDegree) assertGreaterThanEquals('anisotropicDegree', anisotropicDegree, 1) self.__anisotropicDegree = anisotropicDegree @property # getter - - - - - - - - - - def borderColor(self): """[0,1] borderColor defines border pixel color.""" return self.__borderColor @borderColor.setter def borderColor(self, borderColor): if borderColor is None: borderColor = (0, 0, 0, 0) # default assertValidSFColorRGBA(borderColor) assertZeroToOne('borderColor', borderColor) self.__borderColor = borderColor @property # getter - - - - - - - - - - def borderWidth(self): """[0,+infinity) borderWidth number of pixels for texture border.""" return self.__borderWidth @borderWidth.setter def borderWidth(self, borderWidth): if borderWidth is None: borderWidth = 0 # default assertValidSFInt32(borderWidth) assertNonNegative('borderWidth', borderWidth) self.__borderWidth = borderWidth @property # getter - - - - - - - - - - def boundaryModeR(self): """boundaryModeR describes handling of texture-coordinate boundaries.""" return self.__boundaryModeR @boundaryModeR.setter def boundaryModeR(self, boundaryModeR): if boundaryModeR is None: boundaryModeR = 'REPEAT' # default assertValidSFString(boundaryModeR) assertValidTextureBoundaryMode('boundaryModeR', boundaryModeR) self.__boundaryModeR = boundaryModeR @property # getter - - - - - - - - - - def boundaryModeS(self): """boundaryModeS describes handling of texture-coordinate boundaries.""" return self.__boundaryModeS @boundaryModeS.setter def boundaryModeS(self, boundaryModeS): if boundaryModeS is None: boundaryModeS = 'REPEAT' # default assertValidSFString(boundaryModeS) assertValidTextureBoundaryMode('boundaryModeS', boundaryModeS) self.__boundaryModeS = boundaryModeS @property # getter - - - - - - - - - - def boundaryModeT(self): """boundaryModeT describes handling of texture-coordinate boundaries.""" return self.__boundaryModeT @boundaryModeT.setter def boundaryModeT(self, boundaryModeT): if boundaryModeT is None: boundaryModeT = 'REPEAT' # default assertValidSFString(boundaryModeT) assertValidTextureBoundaryMode('boundaryModeT', boundaryModeT) self.__boundaryModeT = boundaryModeT @property # getter - - - - - - - - - - def generateMipMaps(self): """Determines whether MIPMAPs are generated for texture images.""" return self.__generateMipMaps @generateMipMaps.setter def generateMipMaps(self, generateMipMaps): if generateMipMaps is None: generateMipMaps = False # default assertValidSFBool(generateMipMaps) self.__generateMipMaps = generateMipMaps @property # getter - - - - - - - - - - def magnificationFilter(self): """magnificationFilter indicates texture filter when image is smaller than screen space representation.""" return self.__magnificationFilter @magnificationFilter.setter def magnificationFilter(self, magnificationFilter): if magnificationFilter is None: magnificationFilter = 'FASTEST' # default assertValidSFString(magnificationFilter) assertValidTextureMagnificationMode('magnificationFilter', magnificationFilter) self.__magnificationFilter = magnificationFilter @property # getter - - - - - - - - - - def minificationFilter(self): """minificationFilter indicates texture filter when image is larger than screen space representation.""" return self.__minificationFilter @minificationFilter.setter def minificationFilter(self, minificationFilter): if minificationFilter is None: minificationFilter = 'FASTEST' # default assertValidSFString(minificationFilter) assertValidTextureMinificationMode('minificationFilter', minificationFilter) self.__minificationFilter = minificationFilter @property # getter - - - - - - - - - - def textureCompression(self): """textureCompression indicates compression algorithm selection mode.""" return self.__textureCompression @textureCompression.setter def textureCompression(self, textureCompression): if textureCompression is None: textureCompression = 'FASTEST' # default assertValidSFString(textureCompression) assertValidTextureCompressionMode('textureCompression', textureCompression) self.__textureCompression = textureCompression @property # getter - - - - - - - - - - def texturePriority(self): """[0,1] texturePriority defines relative priority for this texture when allocating texture memory, an important rendering resource in graphics-card hardware.""" return self.__texturePriority @texturePriority.setter def texturePriority(self, texturePriority): if texturePriority is None: texturePriority = 0 # default assertValidSFFloat(texturePriority) assertZeroToOne('texturePriority', texturePriority) self.__texturePriority = texturePriority @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureProperties.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureProperties.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureProperties":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.anisotropicDegree != 1: attributeResult += " " + '"@anisotropicDegree":"' + SFFloat(self.anisotropicDegree).JSON() + '"' + ',\n' if self.borderColor != (0, 0, 0, 0): attributeResult += " " + '"@borderColor":"' + SFColorRGBA(self.borderColor).JSON() + '"' + ',\n' if self.borderWidth != 0: attributeResult += " " + '"@borderWidth":"' + SFInt32(self.borderWidth).JSON() + '"' + ',\n' if self.boundaryModeR != 'REPEAT': attributeResult += " " + '"@boundaryModeR":"' + SFString(self.boundaryModeR).JSON() + '"' + ',\n' if self.boundaryModeS != 'REPEAT': attributeResult += " " + '"@boundaryModeS":"' + SFString(self.boundaryModeS).JSON() + '"' + ',\n' if self.boundaryModeT != 'REPEAT': attributeResult += " " + '"@boundaryModeT":"' + SFString(self.boundaryModeT).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.generateMipMaps: # default=false attributeResult += " " + '"@generateMipMaps":"' + SFBool(self.generateMipMaps).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.magnificationFilter != 'FASTEST': attributeResult += " " + '"@magnificationFilter":"' + SFString(self.magnificationFilter).JSON() + '"' + ',\n' if self.minificationFilter != 'FASTEST': attributeResult += " " + '"@minificationFilter":"' + SFString(self.minificationFilter).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.textureCompression != 'FASTEST': attributeResult += " " + '"@textureCompression":"' + SFString(self.textureCompression).JSON() + '"' + ',\n' if self.texturePriority != 0: attributeResult += " " + '"@texturePriority":"' + SFFloat(self.texturePriority).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureProperties.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureProperties' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureProperties' + ' {' if self.anisotropicDegree != 1: result += '\n' + indent + ' ' + "anisotropicDegree " + SFFloat(self.anisotropicDegree).VRML() + "" if self.borderColor != (0, 0, 0, 0): result += '\n' + indent + ' ' + "borderColor " + SFColorRGBA(self.borderColor).VRML() + "" if self.borderWidth != 0: result += '\n' + indent + ' ' + "borderWidth " + SFInt32(self.borderWidth).VRML() + "" if self.boundaryModeR != 'REPEAT': result += '\n' + indent + ' ' + "boundaryModeR " + '"' + self.boundaryModeR + '"' + "" if self.boundaryModeS != 'REPEAT': result += '\n' + indent + ' ' + "boundaryModeS " + '"' + self.boundaryModeS + '"' + "" if self.boundaryModeT != 'REPEAT': result += '\n' + indent + ' ' + "boundaryModeT " + '"' + self.boundaryModeT + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.generateMipMaps: # default=false result += '\n' + indent + ' ' + "generateMipMaps " + SFBool(self.generateMipMaps).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.magnificationFilter != 'FASTEST': result += '\n' + indent + ' ' + "magnificationFilter " + '"' + self.magnificationFilter + '"' + "" if self.minificationFilter != 'FASTEST': result += '\n' + indent + ' ' + "minificationFilter " + '"' + self.minificationFilter + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.textureCompression != 'FASTEST': result += '\n' + indent + ' ' + "textureCompression " + '"' + self.textureCompression + '"' + "" if self.texturePriority != 0: result += '\n' + indent + ' ' + "texturePriority " + SFFloat(self.texturePriority).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureTransform(_X3DTextureTransformNode): """ TextureTransform shifts 2D texture coordinates for positioning, orienting and scaling image textures on geometry. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureTransform' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texturing.html#TextureTransform' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureTransform' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('center', (0, 0), FieldType.SFVec2f, AccessType.inputOutput, 'TextureTransform'), ('rotation', 0, FieldType.SFFloat, AccessType.inputOutput, 'TextureTransform'), ('scale', (1, 1), FieldType.SFVec2f, AccessType.inputOutput, 'TextureTransform'), ('translation', (0, 0), FieldType.SFVec2f, AccessType.inputOutput, 'TextureTransform'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, center=(0, 0), rotation=0, scale=(1, 1), translation=(0, 0), DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureTransform __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.center = center self.rotation = rotation self.scale = scale self.translation = translation self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def center(self): """center point in 2D (s,t) texture coordinates for rotation and scaling.""" return self.__center @center.setter def center(self, center): if center is None: center = (0, 0) # default assertValidSFVec2f(center) self.__center = center @property # getter - - - - - - - - - - def rotation(self): """single rotation angle of texture about center (opposite effect appears on geometry).""" return self.__rotation @rotation.setter def rotation(self, rotation): if rotation is None: rotation = 0 # default assertValidSFFloat(rotation) self.__rotation = rotation @property # getter - - - - - - - - - - def scale(self): """Non-uniform planar scaling of texture about center (opposite effect appears on geometry).""" return self.__scale @scale.setter def scale(self, scale): if scale is None: scale = (1, 1) # default assertValidSFVec2f(scale) self.__scale = scale @property # getter - - - - - - - - - - def translation(self): """Lateral/vertical shift in 2D (s,t) texture coordinates (opposite effect appears on geometry).""" return self.__translation @translation.setter def translation(self, translation): if translation is None: translation = (0, 0) # default assertValidSFVec2f(translation) self.__translation = translation @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureTransform.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureTransform.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureTransform":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.center != (0, 0): attributeResult += " " + '"@center":"' + SFVec2f(self.center).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.rotation != 0: attributeResult += " " + '"@rotation":"' + SFFloat(self.rotation).JSON() + '"' + ',\n' if self.scale != (1, 1): attributeResult += " " + '"@scale":"' + SFVec2f(self.scale).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.translation != (0, 0): attributeResult += " " + '"@translation":"' + SFVec2f(self.translation).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureTransform.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureTransform' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureTransform' + ' {' if self.center != (0, 0): result += '\n' + indent + ' ' + "center " + SFVec2f(self.center).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.rotation != 0: result += '\n' + indent + ' ' + "rotation " + SFFloat(self.rotation).VRML() + "" if self.scale != (1, 1): result += '\n' + indent + ' ' + "scale " + SFVec2f(self.scale).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.translation != (0, 0): result += '\n' + indent + ' ' + "translation " + SFVec2f(self.translation).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureTransform3D(_X3DTextureTransformNode): """ TextureTransform3D applies a 3D transformation to texture coordinates. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureTransform3D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texture3D.html#TextureTransform3D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureTransform3D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('center', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'TextureTransform3D'), ('rotation', (0, 0, 1, 0), FieldType.SFRotation, AccessType.inputOutput, 'TextureTransform3D'), ('scale', (1, 1, 1), FieldType.SFVec3f, AccessType.inputOutput, 'TextureTransform3D'), ('translation', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'TextureTransform3D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, center=(0, 0, 0), rotation=(0, 0, 1, 0), scale=(1, 1, 1), translation=(0, 0, 0), DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureTransform3D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.center = center self.rotation = rotation self.scale = scale self.translation = translation self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def center(self): """center point in 2D (s,t) texture coordinates for rotation and scaling.""" return self.__center @center.setter def center(self, center): if center is None: center = (0, 0, 0) # default assertValidSFVec3f(center) self.__center = center @property # getter - - - - - - - - - - def rotation(self): """rotation angle of texture about center (opposite effect appears on geometry).""" return self.__rotation @rotation.setter def rotation(self, rotation): if rotation is None: rotation = (0, 0, 1, 0) # default assertValidSFRotation(rotation) self.__rotation = rotation @property # getter - - - - - - - - - - def scale(self): """Non-uniform planar scaling of texture about center (opposite effect appears on geometry).""" return self.__scale @scale.setter def scale(self, scale): if scale is None: scale = (1, 1, 1) # default assertValidSFVec3f(scale) self.__scale = scale @property # getter - - - - - - - - - - def translation(self): """Lateral/vertical shift in 2D (s,t) texture coordinates (opposite effect appears on geometry).""" return self.__translation @translation.setter def translation(self, translation): if translation is None: translation = (0, 0, 0) # default assertValidSFVec3f(translation) self.__translation = translation @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureTransform3D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureTransform3D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureTransform3D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.center != (0, 0, 0): attributeResult += " " + '"@center":"' + SFVec3f(self.center).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.rotation != (0, 0, 1, 0): attributeResult += " " + '"@rotation":"' + SFRotation(self.rotation).JSON() + '"' + ',\n' if self.scale != (1, 1, 1): attributeResult += " " + '"@scale":"' + SFVec3f(self.scale).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.translation != (0, 0, 0): attributeResult += " " + '"@translation":"' + SFVec3f(self.translation).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureTransform3D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureTransform3D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureTransform3D' + ' {' if self.center != (0, 0, 0): result += '\n' + indent + ' ' + "center " + SFVec3f(self.center).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.rotation != (0, 0, 1, 0): result += '\n' + indent + ' ' + "rotation " + SFRotation(self.rotation).VRML() + "" if self.scale != (1, 1, 1): result += '\n' + indent + ' ' + "scale " + SFVec3f(self.scale).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.translation != (0, 0, 0): result += '\n' + indent + ' ' + "translation " + SFVec3f(self.translation).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TextureTransformMatrix3D(_X3DTextureTransformNode): """ TextureTransformMatrix3D applies a 3D transformation to texture coordinates. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TextureTransformMatrix3D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/texture3D.html#TextureTransformMatrix3D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TextureTransformMatrix3D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('matrix', (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), FieldType.SFMatrix4f, AccessType.inputOutput, 'TextureTransformMatrix3D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, matrix=(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TextureTransformMatrix3D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.matrix = matrix self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def matrix(self): """matrix is a generalized, unfiltered 4x4 transformation matrix to modify texture (opposite effect appears on geometry).""" return self.__matrix @matrix.setter def matrix(self, matrix): if matrix is None: matrix = (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) # default assertValidSFMatrix4f(matrix) self.__matrix = matrix @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureTransformMatrix3D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TextureTransformMatrix3D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TextureTransformMatrix3D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.matrix != (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1): attributeResult += " " + '"@matrix":"' + SFMatrix4f(self.matrix).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TextureTransformMatrix3D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TextureTransformMatrix3D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TextureTransformMatrix3D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.matrix != (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1): result += '\n' + indent + ' ' + "matrix " + SFMatrix4f(self.matrix).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TimeSensor(_X3DTimeDependentNode, _X3DSensorNode): """ TimeSensor continuously generates events as time passes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TimeSensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/time.html#TimeSensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TimeSensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('cycleInterval', 1.0, FieldType.SFTime, AccessType.inputOutput, 'TimeSensor'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DTimeDependentNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('loop', False, FieldType.SFBool, AccessType.inputOutput, 'TimeSensor'), ('pauseTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('resumeTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('startTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('stopTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, cycleInterval=1.0, description='', enabled=True, loop=False, pauseTime=0, resumeTime=0, startTime=0, stopTime=0, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TimeSensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.cycleInterval = cycleInterval self.description = description self.enabled = enabled self.loop = loop self.pauseTime = pauseTime self.resumeTime = resumeTime self.startTime = startTime self.stopTime = stopTime self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def cycleInterval(self): """[0,+infinity) cycleInterval is loop duration in seconds.""" return self.__cycleInterval @cycleInterval.setter def cycleInterval(self, cycleInterval): if cycleInterval is None: cycleInterval = 1.0 # default assertValidSFTime(cycleInterval) assertNonNegative('cycleInterval', cycleInterval) self.__cycleInterval = cycleInterval @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of this node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def loop(self): """Repeat indefinitely when loop=true, repeat only once when loop=false.""" return self.__loop @loop.setter def loop(self, loop): if loop is None: loop = False # default assertValidSFBool(loop) self.__loop = loop @property # getter - - - - - - - - - - def pauseTime(self): """When time now >= pauseTime, isPaused becomes true and TimeSensor becomes paused.""" return self.__pauseTime @pauseTime.setter def pauseTime(self, pauseTime): if pauseTime is None: pauseTime = 0 # default assertValidSFTime(pauseTime) self.__pauseTime = pauseTime @property # getter - - - - - - - - - - def resumeTime(self): """When resumeTime becomes <= time now, isPaused becomes false and TimeSensor becomes inactive.""" return self.__resumeTime @resumeTime.setter def resumeTime(self, resumeTime): if resumeTime is None: resumeTime = 0 # default assertValidSFTime(resumeTime) self.__resumeTime = resumeTime @property # getter - - - - - - - - - - def startTime(self): """When time now >= startTime, isActive becomes true and TimeSensor becomes active.""" return self.__startTime @startTime.setter def startTime(self, startTime): if startTime is None: startTime = 0 # default assertValidSFTime(startTime) self.__startTime = startTime @property # getter - - - - - - - - - - def stopTime(self): """When stopTime becomes <= time now, isActive becomes false and TimeSensor becomes inactive.""" return self.__stopTime @stopTime.setter def stopTime(self, stopTime): if stopTime is None: stopTime = 0 # default assertValidSFTime(stopTime) self.__stopTime = stopTime @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TimeSensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TimeSensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TimeSensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.cycleInterval != 1.0: attributeResult += " " + '"@cycleInterval":"' + SFTime(self.cycleInterval).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.loop: # default=false attributeResult += " " + '"@loop":"' + SFBool(self.loop).JSON() + '"' + ',\n' if self.pauseTime != 0: attributeResult += " " + '"@pauseTime":"' + SFTime(self.pauseTime).JSON() + '"' + ',\n' if self.resumeTime != 0: attributeResult += " " + '"@resumeTime":"' + SFTime(self.resumeTime).JSON() + '"' + ',\n' if self.startTime != 0: attributeResult += " " + '"@startTime":"' + SFTime(self.startTime).JSON() + '"' + ',\n' if self.stopTime != 0: attributeResult += " " + '"@stopTime":"' + SFTime(self.stopTime).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TimeSensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TimeSensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TimeSensor' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.cycleInterval != 1.0: result += '\n' + indent + ' ' + "cycleInterval " + SFTime(self.cycleInterval).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.loop: # default=false result += '\n' + indent + ' ' + "loop " + SFBool(self.loop).VRML() + "" if self.pauseTime != 0: result += '\n' + indent + ' ' + "pauseTime " + SFTime(self.pauseTime).VRML() + "" if self.resumeTime != 0: result += '\n' + indent + ' ' + "resumeTime " + SFTime(self.resumeTime).VRML() + "" if self.startTime != 0: result += '\n' + indent + ' ' + "startTime " + SFTime(self.startTime).VRML() + "" if self.stopTime != 0: result += '\n' + indent + ' ' + "stopTime " + SFTime(self.stopTime).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TimeTrigger(_X3DTriggerNode): """ TimeTrigger converts boolean true events to time events. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TimeTrigger' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/eventUtilities.html#TimeTrigger' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TimeTrigger' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TimeTrigger __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TimeTrigger.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TimeTrigger.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TimeTrigger":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TimeTrigger.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TimeTrigger' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TimeTrigger' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ToneMappedVolumeStyle(_X3DComposableVolumeRenderStyleNode): """ ToneMappedVolumeStyle specifies that volumetric data is rendered with Gooch shading model of two-toned warm/cool coloring. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ToneMappedVolumeStyle' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#ToneMappedVolumeStyle' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ToneMappedVolumeStyle' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('coolColor', (0, 0, 1, 0), FieldType.SFColorRGBA, AccessType.inputOutput, 'ToneMappedVolumeStyle'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeRenderStyleNode'), ('warmColor', (1, 1, 0, 0), FieldType.SFColorRGBA, AccessType.inputOutput, 'ToneMappedVolumeStyle'), ('surfaceNormals', None, FieldType.SFNode, AccessType.inputOutput, 'ToneMappedVolumeStyle'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, coolColor=(0, 0, 1, 0), enabled=True, warmColor=(1, 1, 0, 0), surfaceNormals=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode ToneMappedVolumeStyle __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.coolColor = coolColor self.enabled = enabled self.warmColor = warmColor self.surfaceNormals = surfaceNormals self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def coolColor(self): """[0,1] coolColor is used for surfaces facing away from the light direction.""" return self.__coolColor @coolColor.setter def coolColor(self, coolColor): if coolColor is None: coolColor = (0, 0, 1, 0) # default assertValidSFColorRGBA(coolColor) assertZeroToOne('coolColor', coolColor) self.__coolColor = coolColor @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def warmColor(self): """[0,1] warmColor is used for surfaces facing towards the light.""" return self.__warmColor @warmColor.setter def warmColor(self, warmColor): if warmColor is None: warmColor = (1, 1, 0, 0) # default assertValidSFColorRGBA(warmColor) assertZeroToOne('warmColor', warmColor) self.__warmColor = warmColor @property # getter - - - - - - - - - - def surfaceNormals(self): """[X3DTexture3DNode] The surfaceNormals field contains a 3D texture with at least three component values.""" return self.__surfaceNormals @surfaceNormals.setter def surfaceNormals(self, surfaceNormals): if surfaceNormals is None: surfaceNormals = None # default assertValidSFNode(surfaceNormals) if not surfaceNormals is None and not isinstance(surfaceNormals,(_X3DTexture3DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(surfaceNormals) + ' does not match required node type (_X3DTexture3DNode,ProtoInstance) and is invalid') self.__surfaceNormals = surfaceNormals @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.surfaceNormals # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ToneMappedVolumeStyle.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ToneMappedVolumeStyle.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ToneMappedVolumeStyle":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.coolColor != (0, 0, 1, 0): attributeResult += " " + '"@coolColor":"' + SFColorRGBA(self.coolColor).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.warmColor != (1, 1, 0, 0): attributeResult += " " + '"@warmColor":"' + SFColorRGBA(self.warmColor).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.surfaceNormals: # output this SFNode result += self.surfaceNormals.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function ToneMappedVolumeStyle.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'ToneMappedVolumeStyle' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'ToneMappedVolumeStyle' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.coolColor != (0, 0, 1, 0): result += '\n' + indent + ' ' + "coolColor " + SFColorRGBA(self.coolColor).VRML() + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.warmColor != (1, 1, 0, 0): result += '\n' + indent + ' ' + "warmColor " + SFColorRGBA(self.warmColor).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.surfaceNormals: # output this SFNode result += '\n' + ' ' + indent + 'surfaceNormals ' + self.surfaceNormals.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TouchSensor(_X3DTouchSensorNode): """ TouchSensor tracks location and state of the pointing device, detecting when a user points at or selects (activates) geometry. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TouchSensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/pointingDeviceSensor.html#TouchSensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TouchSensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, description='', enabled=True, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TouchSensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.description = description self.enabled = enabled self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of this node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TouchSensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TouchSensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TouchSensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TouchSensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TouchSensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TouchSensor' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Transform(_X3DGroupingNode): """ Transform is a Grouping node that can contain most nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Transform' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/grouping.html#Transform' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Transform' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DGroupingNode'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DGroupingNode'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DGroupingNode'), ('center', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'Transform'), ('rotation', (0, 0, 1, 0), FieldType.SFRotation, AccessType.inputOutput, 'Transform'), ('scale', (1, 1, 1), FieldType.SFVec3f, AccessType.inputOutput, 'Transform'), ('scaleOrientation', (0, 0, 1, 0), FieldType.SFRotation, AccessType.inputOutput, 'Transform'), ('translation', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'Transform'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DGroupingNode'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'X3DGroupingNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), center=(0, 0, 0), rotation=(0, 0, 1, 0), scale=(1, 1, 1), scaleOrientation=(0, 0, 1, 0), translation=(0, 0, 0), visible=True, children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Transform __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.center = center self.rotation = rotation self.scale = scale self.scaleOrientation = scaleOrientation self.translation = translation self.visible = visible self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def center(self): """Translation offset from origin of local coordinate system, applied prior to rotation or scaling.""" return self.__center @center.setter def center(self, center): if center is None: center = (0, 0, 0) # default assertValidSFVec3f(center) self.__center = center @property # getter - - - - - - - - - - def rotation(self): """Orientation (axis, angle in radians) of children relative to local coordinate system.""" return self.__rotation @rotation.setter def rotation(self, rotation): if rotation is None: rotation = (0, 0, 1, 0) # default assertValidSFRotation(rotation) self.__rotation = rotation @property # getter - - - - - - - - - - def scale(self): """Non-uniform x-y-z scale of child coordinate system, adjusted by center and scaleOrientation.""" return self.__scale @scale.setter def scale(self, scale): if scale is None: scale = (1, 1, 1) # default assertValidSFVec3f(scale) self.__scale = scale @property # getter - - - - - - - - - - def scaleOrientation(self): """Preliminary rotation of coordinate system before scaling (to allow scaling around arbitrary orientations).""" return self.__scaleOrientation @scaleOrientation.setter def scaleOrientation(self, scaleOrientation): if scaleOrientation is None: scaleOrientation = (0, 0, 1, 0) # default assertValidSFRotation(scaleOrientation) self.__scaleOrientation = scaleOrientation @property # getter - - - - - - - - - - def translation(self): """Position (x, y, z in meters) of children relative to local coordinate system.""" return self.__translation @translation.setter def translation(self, translation): if translation is None: translation = (0, 0, 0) # default assertValidSFVec3f(translation) self.__translation = translation @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def children(self): """[X3DChildNode] Grouping nodes contain an ordered list of children nodes.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Transform.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Transform.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Transform":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.center != (0, 0, 0): attributeResult += " " + '"@center":"' + SFVec3f(self.center).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.rotation != (0, 0, 1, 0): attributeResult += " " + '"@rotation":"' + SFRotation(self.rotation).JSON() + '"' + ',\n' if self.scale != (1, 1, 1): attributeResult += " " + '"@scale":"' + SFVec3f(self.scale).JSON() + '"' + ',\n' if self.scaleOrientation != (0, 0, 1, 0): attributeResult += " " + '"@scaleOrientation":"' + SFRotation(self.scaleOrientation).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.translation != (0, 0, 0): attributeResult += " " + '"@translation":"' + SFVec3f(self.translation).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* Transform found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Transform.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Transform' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Transform' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.center != (0, 0, 0): result += '\n' + indent + ' ' + "center " + SFVec3f(self.center).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.rotation != (0, 0, 1, 0): result += '\n' + indent + ' ' + "rotation " + SFRotation(self.rotation).VRML() + "" if self.scale != (1, 1, 1): result += '\n' + indent + ' ' + "scale " + SFVec3f(self.scale).VRML() + "" if self.scaleOrientation != (0, 0, 1, 0): result += '\n' + indent + ' ' + "scaleOrientation " + SFRotation(self.scaleOrientation).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.translation != (0, 0, 0): result += '\n' + indent + ' ' + "translation " + SFVec3f(self.translation).VRML() + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TransformSensor(_X3DEnvironmentalSensorNode): """ TransformSensor generates output events when its targetObject enters, exits, and moves within a region in space (defined by a box). """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TransformSensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalSensor.html#TransformSensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TransformSensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('center', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'TransformSensor'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('size', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'X3DEnvironmentalSensorNode'), ('targetObject', None, FieldType.SFNode, AccessType.inputOutput, 'TransformSensor'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, center=(0, 0, 0), description='', enabled=True, size=(0, 0, 0), targetObject=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TransformSensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.center = center self.description = description self.enabled = enabled self.size = size self.targetObject = targetObject self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def center(self): """Translation offset from origin of local coordinate system.""" return self.__center @center.setter def center(self, center): if center is None: center = (0, 0, 0) # default assertValidSFVec3f(center) self.__center = center @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def size(self): """[0,+infinity) size of intersection box, measured from center in meters.""" return self.__size @size.setter def size(self, size): if size is None: size = (0, 0, 0) # default assertValidSFVec3f(size) assertNonNegative('size', size) self.__size = size @property # getter - - - - - - - - - - def targetObject(self): """[X3DGroupingNode|X3DShapeNode] targetObject is the movable geometry represented by any valid X3DGroupingNode or X3DShapeNode which may enter or exit the box.""" return self.__targetObject @targetObject.setter def targetObject(self, targetObject): if targetObject is None: targetObject = None # default assertValidSFNode(targetObject) if not targetObject is None and not isinstance(targetObject,(_X3DGroupingNode,_X3DShapeNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(targetObject) + ' does not match required node type (_X3DGroupingNode,_X3DShapeNode,ProtoInstance) and is invalid') self.__targetObject = targetObject @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.targetObject # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TransformSensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TransformSensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TransformSensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.center != (0, 0, 0): attributeResult += " " + '"@center":"' + SFVec3f(self.center).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.size != (0, 0, 0): attributeResult += " " + '"@size":"' + SFVec3f(self.size).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.targetObject: # output this SFNode result += self.targetObject.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TransformSensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TransformSensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TransformSensor' + ' {' if self.center != (0, 0, 0): result += '\n' + indent + ' ' + "center " + SFVec3f(self.center).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.size != (0, 0, 0): result += '\n' + indent + ' ' + "size " + SFVec3f(self.size).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.targetObject: # output this SFNode result += '\n' + ' ' + indent + 'targetObject ' + self.targetObject.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TransmitterPdu(_X3DNetworkSensorNode, _X3DBoundedObject): """ TransmitterPdu is a networked Protocol Data Unit (PDU) information node that provides detailed information about a radio transmitter modeled in a simulation. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TransmitterPdu' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/dis.html#TransmitterPdu' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TransmitterPdu' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('address', 'localhost', FieldType.SFString, AccessType.inputOutput, 'TransmitterPdu'), ('antennaLocation', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'TransmitterPdu'), ('antennaPatternLength', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('antennaPatternType', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('applicationID', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DBoundedObject'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DBoundedObject'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DBoundedObject'), ('cryptoKeyID', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('cryptoSystem', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('entityID', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('frequency', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('geoCoords', (0, 0, 0), FieldType.SFVec3d, AccessType.inputOutput, 'TransmitterPdu'), ('geoSystem', ["GD", "WE"], FieldType.MFString, AccessType.initializeOnly, 'TransmitterPdu'), ('inputSource', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('lengthOfModulationParameters', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('modulationTypeDetail', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('modulationTypeMajor', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('modulationTypeSpreadSpectrum', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('modulationTypeSystem', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('multicastRelayHost', '', FieldType.SFString, AccessType.inputOutput, 'TransmitterPdu'), ('multicastRelayPort', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('networkMode', 'standAlone', FieldType.SFString, AccessType.inputOutput, 'TransmitterPdu'), ('port', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('power', 0.0, FieldType.SFFloat, AccessType.inputOutput, 'TransmitterPdu'), ('radioEntityTypeCategory', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('radioEntityTypeCountry', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('radioEntityTypeDomain', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('radioEntityTypeKind', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('radioEntityTypeNomenclature', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('radioEntityTypeNomenclatureVersion', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('radioID', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('readInterval', 0.1, FieldType.SFTime, AccessType.inputOutput, 'TransmitterPdu'), ('relativeAntennaLocation', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'TransmitterPdu'), ('rtpHeaderExpected', False, FieldType.SFBool, AccessType.inputOutput, 'TransmitterPdu'), ('siteID', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('transmitFrequencyBandwidth', 0, FieldType.SFFloat, AccessType.inputOutput, 'TransmitterPdu'), ('transmitState', 0, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DBoundedObject'), ('whichGeometry', 1, FieldType.SFInt32, AccessType.inputOutput, 'TransmitterPdu'), ('writeInterval', 1.0, FieldType.SFTime, AccessType.inputOutput, 'TransmitterPdu'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, address='localhost', antennaLocation=(0, 0, 0), antennaPatternLength=0, antennaPatternType=0, applicationID=0, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), cryptoKeyID=0, cryptoSystem=0, description='', enabled=True, entityID=0, frequency=0, geoCoords=(0, 0, 0), geoSystem=None, inputSource=0, lengthOfModulationParameters=0, modulationTypeDetail=0, modulationTypeMajor=0, modulationTypeSpreadSpectrum=0, modulationTypeSystem=0, multicastRelayHost='', multicastRelayPort=0, networkMode='standAlone', port=0, power=0.0, radioEntityTypeCategory=0, radioEntityTypeCountry=0, radioEntityTypeDomain=0, radioEntityTypeKind=0, radioEntityTypeNomenclature=0, radioEntityTypeNomenclatureVersion=0, radioID=0, readInterval=0.1, relativeAntennaLocation=(0, 0, 0), rtpHeaderExpected=False, siteID=0, transmitFrequencyBandwidth=0, transmitState=0, visible=True, whichGeometry=1, writeInterval=1.0, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TransmitterPdu __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.address = address self.antennaLocation = antennaLocation self.antennaPatternLength = antennaPatternLength self.antennaPatternType = antennaPatternType self.applicationID = applicationID self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.cryptoKeyID = cryptoKeyID self.cryptoSystem = cryptoSystem self.description = description self.enabled = enabled self.entityID = entityID self.frequency = frequency self.geoCoords = geoCoords self.geoSystem = geoSystem self.inputSource = inputSource self.lengthOfModulationParameters = lengthOfModulationParameters self.modulationTypeDetail = modulationTypeDetail self.modulationTypeMajor = modulationTypeMajor self.modulationTypeSpreadSpectrum = modulationTypeSpreadSpectrum self.modulationTypeSystem = modulationTypeSystem self.multicastRelayHost = multicastRelayHost self.multicastRelayPort = multicastRelayPort self.networkMode = networkMode self.port = port self.power = power self.radioEntityTypeCategory = radioEntityTypeCategory self.radioEntityTypeCountry = radioEntityTypeCountry self.radioEntityTypeDomain = radioEntityTypeDomain self.radioEntityTypeKind = radioEntityTypeKind self.radioEntityTypeNomenclature = radioEntityTypeNomenclature self.radioEntityTypeNomenclatureVersion = radioEntityTypeNomenclatureVersion self.radioID = radioID self.readInterval = readInterval self.relativeAntennaLocation = relativeAntennaLocation self.rtpHeaderExpected = rtpHeaderExpected self.siteID = siteID self.transmitFrequencyBandwidth = transmitFrequencyBandwidth self.transmitState = transmitState self.visible = visible self.whichGeometry = whichGeometry self.writeInterval = writeInterval self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def address(self): """Multicast network address, or else 'localhost'.""" return self.__address @address.setter def address(self, address): if address is None: address = 'localhost' # default assertValidSFString(address) self.__address = address @property # getter - - - - - - - - - - def antennaLocation(self): """World coordinates for antenna location.""" return self.__antennaLocation @antennaLocation.setter def antennaLocation(self, antennaLocation): if antennaLocation is None: antennaLocation = (0, 0, 0) # default assertValidSFVec3f(antennaLocation) self.__antennaLocation = antennaLocation @property # getter - - - - - - - - - - def antennaPatternLength(self): """.""" return self.__antennaPatternLength @antennaPatternLength.setter def antennaPatternLength(self, antennaPatternLength): if antennaPatternLength is None: antennaPatternLength = 0 # default assertValidSFInt32(antennaPatternLength) self.__antennaPatternLength = antennaPatternLength @property # getter - - - - - - - - - - def antennaPatternType(self): """Antenna shape pattern: 0 for omnidirectional, 1 for beam, 2 for spherical harmonic (deprecated), or optional higher value.""" return self.__antennaPatternType @antennaPatternType.setter def antennaPatternType(self, antennaPatternType): if antennaPatternType is None: antennaPatternType = 0 # default assertValidSFInt32(antennaPatternType) self.__antennaPatternType = antennaPatternType @property # getter - - - - - - - - - - def applicationID(self): """Each simulation application that can respond to simulation management PDUs needs to have a unique applicationID.""" return self.__applicationID @applicationID.setter def applicationID(self, applicationID): if applicationID is None: applicationID = 0 # default assertValidSFInt32(applicationID) self.__applicationID = applicationID @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def cryptoKeyID(self): """Nonzero value corresponding to the simulated cryptographic key.""" return self.__cryptoKeyID @cryptoKeyID.setter def cryptoKeyID(self, cryptoKeyID): if cryptoKeyID is None: cryptoKeyID = 0 # default assertValidSFInt32(cryptoKeyID) self.__cryptoKeyID = cryptoKeyID @property # getter - - - - - - - - - - def cryptoSystem(self): """Indicates type of crypto system being used, even if the encryption equipment is not keyed.""" return self.__cryptoSystem @cryptoSystem.setter def cryptoSystem(self, cryptoSystem): if cryptoSystem is None: cryptoSystem = 0 # default assertValidSFInt32(cryptoSystem) self.__cryptoSystem = cryptoSystem @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables the sensor node.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def entityID(self): """EntityID unique ID for entity within that application.""" return self.__entityID @entityID.setter def entityID(self, entityID): if entityID is None: entityID = 0 # default assertValidSFInt32(entityID) self.__entityID = entityID @property # getter - - - - - - - - - - def frequency(self): """Transmission frequency in Hz.""" return self.__frequency @frequency.setter def frequency(self, frequency): if frequency is None: frequency = 0 # default assertValidSFInt32(frequency) assertNonNegative('frequency', frequency) self.__frequency = frequency @property # getter - - - - - - - - - - def geoCoords(self): """Geographic location (specified in current geoSystem coordinates) for children geometry (specified in relative coordinate system, in meters).""" return self.__geoCoords @geoCoords.setter def geoCoords(self, geoCoords): if geoCoords is None: geoCoords = (0, 0, 0) # default assertValidSFVec3d(geoCoords) self.__geoCoords = geoCoords @property # getter - - - - - - - - - - def geoSystem(self): """Identifies spatial reference frame: Geodetic (GD), Geocentric (GC), Universal Transverse Mercator (UTM).""" return self.__geoSystem @geoSystem.setter def geoSystem(self, geoSystem): if geoSystem is None: geoSystem = ["GD", "WE"] # default assertValidMFString(geoSystem) self.__geoSystem = geoSystem @property # getter - - - - - - - - - - def inputSource(self): """Source of transmission input.""" return self.__inputSource @inputSource.setter def inputSource(self, inputSource): if inputSource is None: inputSource = 0 # default assertValidSFInt32(inputSource) self.__inputSource = inputSource @property # getter - - - - - - - - - - def lengthOfModulationParameters(self): """.""" return self.__lengthOfModulationParameters @lengthOfModulationParameters.setter def lengthOfModulationParameters(self, lengthOfModulationParameters): if lengthOfModulationParameters is None: lengthOfModulationParameters = 0 # default assertValidSFInt32(lengthOfModulationParameters) self.__lengthOfModulationParameters = lengthOfModulationParameters @property # getter - - - - - - - - - - def modulationTypeDetail(self): """Integer enumeration containing detailed information depending on the major modulation type.""" return self.__modulationTypeDetail @modulationTypeDetail.setter def modulationTypeDetail(self, modulationTypeDetail): if modulationTypeDetail is None: modulationTypeDetail = 0 # default assertValidSFInt32(modulationTypeDetail) self.__modulationTypeDetail = modulationTypeDetail @property # getter - - - - - - - - - - def modulationTypeMajor(self): """Integer enumeration containing major classification of the modulation type.""" return self.__modulationTypeMajor @modulationTypeMajor.setter def modulationTypeMajor(self, modulationTypeMajor): if modulationTypeMajor is None: modulationTypeMajor = 0 # default assertValidSFInt32(modulationTypeMajor) self.__modulationTypeMajor = modulationTypeMajor @property # getter - - - - - - - - - - def modulationTypeSpreadSpectrum(self): """Indicates the spread spectrum technique or combination of spread spectrum techniques in use.""" return self.__modulationTypeSpreadSpectrum @modulationTypeSpreadSpectrum.setter def modulationTypeSpreadSpectrum(self, modulationTypeSpreadSpectrum): if modulationTypeSpreadSpectrum is None: modulationTypeSpreadSpectrum = 0 # default assertValidSFInt32(modulationTypeSpreadSpectrum) self.__modulationTypeSpreadSpectrum = modulationTypeSpreadSpectrum @property # getter - - - - - - - - - - def modulationTypeSystem(self): """Specifies radio system associated with this Transmitter PDU and used to interpret other fields whose values depend on a specific radio system.""" return self.__modulationTypeSystem @modulationTypeSystem.setter def modulationTypeSystem(self, modulationTypeSystem): if modulationTypeSystem is None: modulationTypeSystem = 0 # default assertValidSFInt32(modulationTypeSystem) self.__modulationTypeSystem = modulationTypeSystem @property # getter - - - - - - - - - - def multicastRelayHost(self): """Fallback server address if multicast not available locally.""" return self.__multicastRelayHost @multicastRelayHost.setter def multicastRelayHost(self, multicastRelayHost): if multicastRelayHost is None: multicastRelayHost = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(multicastRelayHost) self.__multicastRelayHost = multicastRelayHost @property # getter - - - - - - - - - - def multicastRelayPort(self): """Fallback server port if multicast not available locally.""" return self.__multicastRelayPort @multicastRelayPort.setter def multicastRelayPort(self, multicastRelayPort): if multicastRelayPort is None: multicastRelayPort = 0 # default assertValidSFInt32(multicastRelayPort) self.__multicastRelayPort = multicastRelayPort @property # getter - - - - - - - - - - def networkMode(self): """Whether this entity is ignoring the network, sending DIS packets to the network, or receiving DIS packets from the network.""" return self.__networkMode @networkMode.setter def networkMode(self, networkMode): if networkMode is None: networkMode = 'standAlone' # default assertValidSFString(networkMode) assertValidNetworkMode('networkMode', networkMode) self.__networkMode = networkMode @property # getter - - - - - - - - - - def port(self): """Multicast network port, for example: 3000.""" return self.__port @port.setter def port(self, port): if port is None: port = 0 # default assertValidSFInt32(port) self.__port = port @property # getter - - - - - - - - - - def power(self): """Power that radio would be capable of outputting if on and transmitting, independent of actual transmit state of the radio.""" return self.__power @power.setter def power(self, power): if power is None: power = 0.0 # default assertValidSFFloat(power) self.__power = power @property # getter - - - - - - - - - - def radioEntityTypeCategory(self): """Integer enumeration containing EntityType of transmitter radio.""" return self.__radioEntityTypeCategory @radioEntityTypeCategory.setter def radioEntityTypeCategory(self, radioEntityTypeCategory): if radioEntityTypeCategory is None: radioEntityTypeCategory = 0 # default assertValidSFInt32(radioEntityTypeCategory) self.__radioEntityTypeCategory = radioEntityTypeCategory @property # getter - - - - - - - - - - def radioEntityTypeCountry(self): """Integer enumerations value for country to which the design of the entity or its design specification is attributed.""" return self.__radioEntityTypeCountry @radioEntityTypeCountry.setter def radioEntityTypeCountry(self, radioEntityTypeCountry): if radioEntityTypeCountry is None: radioEntityTypeCountry = 0 # default assertValidSFInt32(radioEntityTypeCountry) self.__radioEntityTypeCountry = radioEntityTypeCountry @property # getter - - - - - - - - - - def radioEntityTypeDomain(self): """Integer enumerations value for domain in which the entity operates: LAND, AIR, SURFACE, SUBSURFACE, SPACE or OTHER.""" return self.__radioEntityTypeDomain @radioEntityTypeDomain.setter def radioEntityTypeDomain(self, radioEntityTypeDomain): if radioEntityTypeDomain is None: radioEntityTypeDomain = 0 # default assertValidSFInt32(radioEntityTypeDomain) self.__radioEntityTypeDomain = radioEntityTypeDomain @property # getter - - - - - - - - - - def radioEntityTypeKind(self): """Integer enumerations value for whether entity is a PLATFORM, MUNITION, LIFE_FORM, ENVIRONMENTAL, CULTURAL_FEATURE, SUPPLY, RADIO, EXPENDABLE, SENSOR_EMITTER or OTHER.""" return self.__radioEntityTypeKind @radioEntityTypeKind.setter def radioEntityTypeKind(self, radioEntityTypeKind): if radioEntityTypeKind is None: radioEntityTypeKind = 0 # default assertValidSFInt32(radioEntityTypeKind) self.__radioEntityTypeKind = radioEntityTypeKind @property # getter - - - - - - - - - - def radioEntityTypeNomenclature(self): """Integer enumerations value indicating nomenclature (name) for a particular emitter.""" return self.__radioEntityTypeNomenclature @radioEntityTypeNomenclature.setter def radioEntityTypeNomenclature(self, radioEntityTypeNomenclature): if radioEntityTypeNomenclature is None: radioEntityTypeNomenclature = 0 # default assertValidSFInt32(radioEntityTypeNomenclature) self.__radioEntityTypeNomenclature = radioEntityTypeNomenclature @property # getter - - - - - - - - - - def radioEntityTypeNomenclatureVersion(self): """Named equipment version number.""" return self.__radioEntityTypeNomenclatureVersion @radioEntityTypeNomenclatureVersion.setter def radioEntityTypeNomenclatureVersion(self, radioEntityTypeNomenclatureVersion): if radioEntityTypeNomenclatureVersion is None: radioEntityTypeNomenclatureVersion = 0 # default assertValidSFInt32(radioEntityTypeNomenclatureVersion) self.__radioEntityTypeNomenclatureVersion = radioEntityTypeNomenclatureVersion @property # getter - - - - - - - - - - def radioID(self): """Identifies a particular radio within a given entity.""" return self.__radioID @radioID.setter def radioID(self, radioID): if radioID is None: radioID = 0 # default assertValidSFInt32(radioID) self.__radioID = radioID @property # getter - - - - - - - - - - def readInterval(self): """[0,+infinity) Seconds between read updates, 0 means no reading.""" return self.__readInterval @readInterval.setter def readInterval(self, readInterval): if readInterval is None: readInterval = 0.1 # default assertValidSFTime(readInterval) assertNonNegative('readInterval', readInterval) self.__readInterval = readInterval @property # getter - - - - - - - - - - def relativeAntennaLocation(self): """Relative coordinates for antenna location.""" return self.__relativeAntennaLocation @relativeAntennaLocation.setter def relativeAntennaLocation(self, relativeAntennaLocation): if relativeAntennaLocation is None: relativeAntennaLocation = (0, 0, 0) # default assertValidSFVec3f(relativeAntennaLocation) self.__relativeAntennaLocation = relativeAntennaLocation @property # getter - - - - - - - - - - def rtpHeaderExpected(self): """Whether RTP headers are prepended to DIS PDUs.""" return self.__rtpHeaderExpected @rtpHeaderExpected.setter def rtpHeaderExpected(self, rtpHeaderExpected): if rtpHeaderExpected is None: rtpHeaderExpected = False # default assertValidSFBool(rtpHeaderExpected) self.__rtpHeaderExpected = rtpHeaderExpected @property # getter - - - - - - - - - - def siteID(self): """Simulation/exercise siteID of the participating LAN or organization.""" return self.__siteID @siteID.setter def siteID(self, siteID): if siteID is None: siteID = 0 # default assertValidSFInt32(siteID) self.__siteID = siteID @property # getter - - - - - - - - - - def transmitFrequencyBandwidth(self): """Bandwidth of the particular transmitter measured between the half-power (-3 dB) points (this value represents total bandwidth, not the deviation from the center frequency).""" return self.__transmitFrequencyBandwidth @transmitFrequencyBandwidth.setter def transmitFrequencyBandwidth(self, transmitFrequencyBandwidth): if transmitFrequencyBandwidth is None: transmitFrequencyBandwidth = 0 # default assertValidSFFloat(transmitFrequencyBandwidth) self.__transmitFrequencyBandwidth = transmitFrequencyBandwidth @property # getter - - - - - - - - - - def transmitState(self): """Specify radio transmission state where enumerations value 0 is for off, value 1 for powered but not transmitting, or value 1 is for powered and transmitting,.""" return self.__transmitState @transmitState.setter def transmitState(self, transmitState): if transmitState is None: transmitState = 0 # default assertValidSFInt32(transmitState) self.__transmitState = transmitState @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def whichGeometry(self): """Select geometry to render: -1 for no geometry, 0 for text trace, 1 for default geometry, (optional) higher values to render different states.""" return self.__whichGeometry @whichGeometry.setter def whichGeometry(self, whichGeometry): if whichGeometry is None: whichGeometry = 1 # default assertValidSFInt32(whichGeometry) self.__whichGeometry = whichGeometry @property # getter - - - - - - - - - - def writeInterval(self): """[0,+infinity) Seconds between write updates, 0 means no writing (sending).""" return self.__writeInterval @writeInterval.setter def writeInterval(self, writeInterval): if writeInterval is None: writeInterval = 1.0 # default assertValidSFTime(writeInterval) assertNonNegative('writeInterval', writeInterval) self.__writeInterval = writeInterval @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TransmitterPdu.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TransmitterPdu.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TransmitterPdu":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.address != 'localhost': attributeResult += " " + '"@address":"' + SFString(self.address).JSON() + '"' + ',\n' if self.antennaLocation != (0, 0, 0): attributeResult += " " + '"@antennaLocation":"' + SFVec3f(self.antennaLocation).JSON() + '"' + ',\n' if self.antennaPatternLength != 0: attributeResult += " " + '"@antennaPatternLength":"' + SFInt32(self.antennaPatternLength).JSON() + '"' + ',\n' if self.antennaPatternType != 0: attributeResult += " " + '"@antennaPatternType":"' + SFInt32(self.antennaPatternType).JSON() + '"' + ',\n' if self.applicationID != 0: attributeResult += " " + '"@applicationID":"' + SFInt32(self.applicationID).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.cryptoKeyID != 0: attributeResult += " " + '"@cryptoKeyID":"' + SFInt32(self.cryptoKeyID).JSON() + '"' + ',\n' if self.cryptoSystem != 0: attributeResult += " " + '"@cryptoSystem":"' + SFInt32(self.cryptoSystem).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.entityID != 0: attributeResult += " " + '"@entityID":"' + SFInt32(self.entityID).JSON() + '"' + ',\n' if self.frequency != 0: attributeResult += " " + '"@frequency":"' + SFInt32(self.frequency).JSON() + '"' + ',\n' if self.geoCoords != (0, 0, 0): attributeResult += " " + '"@geoCoords":"' + SFVec3d(self.geoCoords).JSON() + '"' + ',\n' if self.geoSystem != ["GD", "WE"]: attributeResult += " " + '"@geoSystem":"' + MFString(self.geoSystem).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.inputSource != 0: attributeResult += " " + '"@inputSource":"' + SFInt32(self.inputSource).JSON() + '"' + ',\n' if self.lengthOfModulationParameters != 0: attributeResult += " " + '"@lengthOfModulationParameters":"' + SFInt32(self.lengthOfModulationParameters).JSON() + '"' + ',\n' if self.modulationTypeDetail != 0: attributeResult += " " + '"@modulationTypeDetail":"' + SFInt32(self.modulationTypeDetail).JSON() + '"' + ',\n' if self.modulationTypeMajor != 0: attributeResult += " " + '"@modulationTypeMajor":"' + SFInt32(self.modulationTypeMajor).JSON() + '"' + ',\n' if self.modulationTypeSpreadSpectrum != 0: attributeResult += " " + '"@modulationTypeSpreadSpectrum":"' + SFInt32(self.modulationTypeSpreadSpectrum).JSON() + '"' + ',\n' if self.modulationTypeSystem != 0: attributeResult += " " + '"@modulationTypeSystem":"' + SFInt32(self.modulationTypeSystem).JSON() + '"' + ',\n' if self.multicastRelayHost: attributeResult += " " + '"@multicastRelayHost":"' + SFString(self.multicastRelayHost).JSON() + '"' + ',\n' if self.multicastRelayPort != 0: attributeResult += " " + '"@multicastRelayPort":"' + SFInt32(self.multicastRelayPort).JSON() + '"' + ',\n' if self.networkMode != 'standAlone': attributeResult += " " + '"@networkMode":"' + SFString(self.networkMode).JSON() + '"' + ',\n' if self.port != 0: attributeResult += " " + '"@port":"' + SFInt32(self.port).JSON() + '"' + ',\n' if self.power != 0.0: attributeResult += " " + '"@power":"' + SFFloat(self.power).JSON() + '"' + ',\n' if self.radioEntityTypeCategory != 0: attributeResult += " " + '"@radioEntityTypeCategory":"' + SFInt32(self.radioEntityTypeCategory).JSON() + '"' + ',\n' if self.radioEntityTypeCountry != 0: attributeResult += " " + '"@radioEntityTypeCountry":"' + SFInt32(self.radioEntityTypeCountry).JSON() + '"' + ',\n' if self.radioEntityTypeDomain != 0: attributeResult += " " + '"@radioEntityTypeDomain":"' + SFInt32(self.radioEntityTypeDomain).JSON() + '"' + ',\n' if self.radioEntityTypeKind != 0: attributeResult += " " + '"@radioEntityTypeKind":"' + SFInt32(self.radioEntityTypeKind).JSON() + '"' + ',\n' if self.radioEntityTypeNomenclature != 0: attributeResult += " " + '"@radioEntityTypeNomenclature":"' + SFInt32(self.radioEntityTypeNomenclature).JSON() + '"' + ',\n' if self.radioEntityTypeNomenclatureVersion != 0: attributeResult += " " + '"@radioEntityTypeNomenclatureVersion":"' + SFInt32(self.radioEntityTypeNomenclatureVersion).JSON() + '"' + ',\n' if self.radioID != 0: attributeResult += " " + '"@radioID":"' + SFInt32(self.radioID).JSON() + '"' + ',\n' if self.readInterval != 0.1: attributeResult += " " + '"@readInterval":"' + SFTime(self.readInterval).JSON() + '"' + ',\n' if self.relativeAntennaLocation != (0, 0, 0): attributeResult += " " + '"@relativeAntennaLocation":"' + SFVec3f(self.relativeAntennaLocation).JSON() + '"' + ',\n' if self.rtpHeaderExpected: # default=false attributeResult += " " + '"@rtpHeaderExpected":"' + SFBool(self.rtpHeaderExpected).JSON() + '"' + ',\n' if self.siteID != 0: attributeResult += " " + '"@siteID":"' + SFInt32(self.siteID).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.transmitFrequencyBandwidth != 0: attributeResult += " " + '"@transmitFrequencyBandwidth":"' + SFFloat(self.transmitFrequencyBandwidth).JSON() + '"' + ',\n' if self.transmitState != 0: attributeResult += " " + '"@transmitState":"' + SFInt32(self.transmitState).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' + ',\n' if self.whichGeometry != 1: attributeResult += " " + '"@whichGeometry":"' + SFInt32(self.whichGeometry).JSON() + '"' + ',\n' if self.writeInterval != 1.0: attributeResult += " " + '"@writeInterval":"' + SFTime(self.writeInterval).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TransmitterPdu.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TransmitterPdu' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TransmitterPdu' + ' {' if self.address != 'localhost': result += '\n' + indent + ' ' + "address " + '"' + self.address + '"' + "" if self.antennaLocation != (0, 0, 0): result += '\n' + indent + ' ' + "antennaLocation " + SFVec3f(self.antennaLocation).VRML() + "" if self.antennaPatternLength != 0: result += '\n' + indent + ' ' + "antennaPatternLength " + SFInt32(self.antennaPatternLength).VRML() + "" if self.antennaPatternType != 0: result += '\n' + indent + ' ' + "antennaPatternType " + SFInt32(self.antennaPatternType).VRML() + "" if self.applicationID != 0: result += '\n' + indent + ' ' + "applicationID " + SFInt32(self.applicationID).VRML() + "" if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.cryptoKeyID != 0: result += '\n' + indent + ' ' + "cryptoKeyID " + SFInt32(self.cryptoKeyID).VRML() + "" if self.cryptoSystem != 0: result += '\n' + indent + ' ' + "cryptoSystem " + SFInt32(self.cryptoSystem).VRML() + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.entityID != 0: result += '\n' + indent + ' ' + "entityID " + SFInt32(self.entityID).VRML() + "" if self.frequency != 0: result += '\n' + indent + ' ' + "frequency " + SFInt32(self.frequency).VRML() + "" if self.geoCoords != (0, 0, 0): result += '\n' + indent + ' ' + "geoCoords " + SFVec3d(self.geoCoords).VRML() + "" if self.geoSystem != ["GD", "WE"]: result += '\n' + indent + ' ' + "geoSystem " + MFString(self.geoSystem).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.inputSource != 0: result += '\n' + indent + ' ' + "inputSource " + SFInt32(self.inputSource).VRML() + "" if self.lengthOfModulationParameters != 0: result += '\n' + indent + ' ' + "lengthOfModulationParameters " + SFInt32(self.lengthOfModulationParameters).VRML() + "" if self.modulationTypeDetail != 0: result += '\n' + indent + ' ' + "modulationTypeDetail " + SFInt32(self.modulationTypeDetail).VRML() + "" if self.modulationTypeMajor != 0: result += '\n' + indent + ' ' + "modulationTypeMajor " + SFInt32(self.modulationTypeMajor).VRML() + "" if self.modulationTypeSpreadSpectrum != 0: result += '\n' + indent + ' ' + "modulationTypeSpreadSpectrum " + SFInt32(self.modulationTypeSpreadSpectrum).VRML() + "" if self.modulationTypeSystem != 0: result += '\n' + indent + ' ' + "modulationTypeSystem " + SFInt32(self.modulationTypeSystem).VRML() + "" if self.multicastRelayHost: result += '\n' + indent + ' ' + "multicastRelayHost " + '"' + self.multicastRelayHost + '"' + "" if self.multicastRelayPort != 0: result += '\n' + indent + ' ' + "multicastRelayPort " + SFInt32(self.multicastRelayPort).VRML() + "" if self.networkMode != 'standAlone': result += '\n' + indent + ' ' + "networkMode " + '"' + self.networkMode + '"' + "" if self.port != 0: result += '\n' + indent + ' ' + "port " + SFInt32(self.port).VRML() + "" if self.power != 0.0: result += '\n' + indent + ' ' + "power " + SFFloat(self.power).VRML() + "" if self.radioEntityTypeCategory != 0: result += '\n' + indent + ' ' + "radioEntityTypeCategory " + SFInt32(self.radioEntityTypeCategory).VRML() + "" if self.radioEntityTypeCountry != 0: result += '\n' + indent + ' ' + "radioEntityTypeCountry " + SFInt32(self.radioEntityTypeCountry).VRML() + "" if self.radioEntityTypeDomain != 0: result += '\n' + indent + ' ' + "radioEntityTypeDomain " + SFInt32(self.radioEntityTypeDomain).VRML() + "" if self.radioEntityTypeKind != 0: result += '\n' + indent + ' ' + "radioEntityTypeKind " + SFInt32(self.radioEntityTypeKind).VRML() + "" if self.radioEntityTypeNomenclature != 0: result += '\n' + indent + ' ' + "radioEntityTypeNomenclature " + SFInt32(self.radioEntityTypeNomenclature).VRML() + "" if self.radioEntityTypeNomenclatureVersion != 0: result += '\n' + indent + ' ' + "radioEntityTypeNomenclatureVersion " + SFInt32(self.radioEntityTypeNomenclatureVersion).VRML() + "" if self.radioID != 0: result += '\n' + indent + ' ' + "radioID " + SFInt32(self.radioID).VRML() + "" if self.readInterval != 0.1: result += '\n' + indent + ' ' + "readInterval " + SFTime(self.readInterval).VRML() + "" if self.relativeAntennaLocation != (0, 0, 0): result += '\n' + indent + ' ' + "relativeAntennaLocation " + SFVec3f(self.relativeAntennaLocation).VRML() + "" if self.rtpHeaderExpected: # default=false result += '\n' + indent + ' ' + "rtpHeaderExpected " + SFBool(self.rtpHeaderExpected).VRML() + "" if self.siteID != 0: result += '\n' + indent + ' ' + "siteID " + SFInt32(self.siteID).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.transmitFrequencyBandwidth != 0: result += '\n' + indent + ' ' + "transmitFrequencyBandwidth " + SFFloat(self.transmitFrequencyBandwidth).VRML() + "" if self.transmitState != 0: result += '\n' + indent + ' ' + "transmitState " + SFInt32(self.transmitState).VRML() + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.whichGeometry != 1: result += '\n' + indent + ' ' + "whichGeometry " + SFInt32(self.whichGeometry).VRML() + "" if self.writeInterval != 1.0: result += '\n' + indent + ' ' + "writeInterval " + SFTime(self.writeInterval).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TriangleFanSet(_X3DComposedGeometryNode): """ TriangleFanSet is a geometry node containing a Coordinate|CoordinateDouble node, and can also contain Color|ColorRGBA, Normal and TextureCoordinate nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TriangleFanSet' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#TriangleFanSet' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TriangleFanSet' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ccw', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('colorPerVertex', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('fanCount', [], FieldType.MFInt32, AccessType.inputOutput, 'TriangleFanSet'), ('normalPerVertex', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('solid', True, FieldType.SFBool, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('color', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('coord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('fogCoord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('normal', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('texCoord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('attrib', [], FieldType.MFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ccw=True, colorPerVertex=True, fanCount=None, normalPerVertex=True, solid=True, color=None, coord=None, fogCoord=None, normal=None, texCoord=None, attrib=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TriangleFanSet __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ccw = ccw self.colorPerVertex = colorPerVertex self.fanCount = fanCount self.normalPerVertex = normalPerVertex self.solid = solid self.color = color self.coord = coord self.fogCoord = fogCoord self.normal = normal self.texCoord = texCoord self.attrib = attrib self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ccw(self): """ccw defines clockwise/counterclockwise ordering of vertex coordinates, which in turn defines front/back orientation of polygon normals according to Right-Hand Rule (RHR).""" return self.__ccw @ccw.setter def ccw(self, ccw): if ccw is None: ccw = True # default assertValidSFBool(ccw) self.__ccw = ccw @property # getter - - - - - - - - - - def colorPerVertex(self): """Whether Color|ColorRGBA values are applied to each point vertex (true) or to each polygon face (false).""" return self.__colorPerVertex @colorPerVertex.setter def colorPerVertex(self, colorPerVertex): if colorPerVertex is None: colorPerVertex = True # default assertValidSFBool(colorPerVertex) self.__colorPerVertex = colorPerVertex @property # getter - - - - - - - - - - def fanCount(self): """(3,+infinity) fanCount array provides number of vertices in each fan.""" return self.__fanCount @fanCount.setter def fanCount(self, fanCount): if fanCount is None: fanCount = MFInt32.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFInt32.DEFAULT_VALUE()=' + str(MFInt32.DEFAULT_VALUE())) assertValidMFInt32(fanCount) assertGreaterThanEquals('fanCount', fanCount, 3) self.__fanCount = fanCount @property # getter - - - - - - - - - - def normalPerVertex(self): """Whether Normal node vector values are applied to each point vertex (true) or to each polygon face (false).""" return self.__normalPerVertex @normalPerVertex.setter def normalPerVertex(self, normalPerVertex): if normalPerVertex is None: normalPerVertex = True # default assertValidSFBool(normalPerVertex) self.__normalPerVertex = normalPerVertex @property # getter - - - - - - - - - - def solid(self): """Setting solid true means draw only one side of polygons (backface culling on), setting solid false means draw both sides of polygons (backface culling off).""" return self.__solid @solid.setter def solid(self, solid): if solid is None: solid = True # default assertValidSFBool(solid) self.__solid = solid @property # getter - - - - - - - - - - def color(self): """[X3DColorNode] Single contained Color or ColorRGBA node that can specify color values applied to corresponding vertices according to colorIndex and colorPerVertex fields.""" return self.__color @color.setter def color(self, color): if color is None: color = None # default assertValidSFNode(color) if not color is None and not isinstance(color,(_X3DColorNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(color) + ' does not match required node type (_X3DColorNode,ProtoInstance) and is invalid') self.__color = color @property # getter - - - - - - - - - - def coord(self): """[X3DCoordinateNode] Single contained Coordinate or CoordinateDouble node that can specify a list of vertex values.""" return self.__coord @coord.setter def coord(self, coord): if coord is None: coord = None # default assertValidSFNode(coord) if not coord is None and not isinstance(coord,(_X3DCoordinateNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(coord) + ' does not match required node type (_X3DCoordinateNode,ProtoInstance) and is invalid') self.__coord = coord @property # getter - - - - - - - - - - def fogCoord(self): """[FogCoordinate] Single contained FogCoordinate node that can specify depth parameters for fog in corresponding geometry.""" return self.__fogCoord @fogCoord.setter def fogCoord(self, fogCoord): if fogCoord is None: fogCoord = None # default assertValidSFNode(fogCoord) if not fogCoord is None and not isinstance(fogCoord,(FogCoordinate,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(fogCoord) + ' does not match required node type (FogCoordinate,ProtoInstance) and is invalid') self.__fogCoord = fogCoord @property # getter - - - - - - - - - - def normal(self): """[X3DNormalNode] Single contained Normal node that can specify perpendicular vectors for corresponding vertices to support rendering computations, applied according to the normalPerVertex field.""" return self.__normal @normal.setter def normal(self, normal): if normal is None: normal = None # default assertValidSFNode(normal) if not normal is None and not isinstance(normal,(_X3DNormalNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(normal) + ' does not match required node type (_X3DNormalNode,ProtoInstance) and is invalid') self.__normal = normal @property # getter - - - - - - - - - - def texCoord(self): """[X3DTextureCoordinateNode] Single contained TextureCoordinate, TextureCoordinateGenerator or MultiTextureCoordinate node that can specify coordinates for texture mapping onto corresponding geometry.""" return self.__texCoord @texCoord.setter def texCoord(self, texCoord): if texCoord is None: texCoord = None # default assertValidSFNode(texCoord) if not texCoord is None and not isinstance(texCoord,(_X3DSingleTextureCoordinateNode,MultiTextureCoordinate,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(texCoord) + ' does not match required node type (_X3DSingleTextureCoordinateNode,MultiTextureCoordinate,ProtoInstance) and is invalid') self.__texCoord = texCoord @property # getter - - - - - - - - - - def attrib(self): """[X3DVertexAttributeNode] Single contained FloatVertexAttribute node that can specify list of per-vertex attribute information for programmable shaders.""" return self.__attrib @attrib.setter def attrib(self, attrib): if attrib is None: attrib = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(attrib) self.__attrib = attrib @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.color or self.coord or self.fogCoord or self.IS or self.metadata or self.normal or self.texCoord or (len(self.attrib) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleFanSet.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleFanSet.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TriangleFanSet":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if not self.ccw: # default=true attributeResult += " " + '"@ccw":"' + SFBool(self.ccw).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if not self.colorPerVertex: # default=true attributeResult += " " + '"@colorPerVertex":"' + SFBool(self.colorPerVertex).JSON() + '"' + ',\n' if self.fanCount != []: attributeResult += " " + '"@fanCount":"' + MFInt32(self.fanCount).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.normalPerVertex: # default=true attributeResult += " " + '"@normalPerVertex":"' + SFBool(self.normalPerVertex).JSON() + '"' + ',\n' if not self.solid: # default=true attributeResult += " " + '"@solid":"' + SFBool(self.solid).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.color: # output this SFNode result += self.color.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.coord: # output this SFNode result += self.coord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.fogCoord: # output this SFNode result += self.fogCoord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.normal: # output this SFNode result += self.normal.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.texCoord: # output this SFNode result += self.texCoord.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.attrib: # walk each child in list, if any (avoid empty list recursion) ### print('* TriangleFanSet found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(attrib)=' + str(len(self.attrib)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.attrib: # walk each child in list, if any (avoid empty list recursion) for each in self.attrib: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TriangleFanSet.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TriangleFanSet' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TriangleFanSet' + ' {' if not self.ccw: # default=true result += '\n' + indent + ' ' + "ccw " + SFBool(self.ccw).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if not self.colorPerVertex: # default=true result += '\n' + indent + ' ' + "colorPerVertex " + SFBool(self.colorPerVertex).VRML() + "" if self.fanCount != []: result += '\n' + indent + ' ' + "fanCount " + MFInt32(self.fanCount).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.normalPerVertex: # default=true result += '\n' + indent + ' ' + "normalPerVertex " + SFBool(self.normalPerVertex).VRML() + "" if not self.solid: # default=true result += '\n' + indent + ' ' + "solid " + SFBool(self.solid).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.color: # output this SFNode result += '\n' + ' ' + indent + 'color ' + self.color.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.coord: # output this SFNode result += '\n' + ' ' + indent + 'coord ' + self.coord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.fogCoord: # output this SFNode result += '\n' + ' ' + indent + 'fogCoord ' + self.fogCoord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.normal: # output this SFNode result += '\n' + ' ' + indent + 'normal ' + self.normal.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.texCoord: # output this SFNode result += '\n' + ' ' + indent + 'texCoord ' + self.texCoord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.attrib: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.attrib: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TriangleSet(_X3DComposedGeometryNode): """ TriangleSet is a geometry node containing a Coordinate|CoordinateDouble node, and can also contain Color|ColorRGBA, Normal and TextureCoordinate nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TriangleSet' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#TriangleSet' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TriangleSet' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ccw', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('colorPerVertex', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('normalPerVertex', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('solid', True, FieldType.SFBool, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('color', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('coord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('fogCoord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('normal', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('texCoord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('attrib', [], FieldType.MFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ccw=True, colorPerVertex=True, normalPerVertex=True, solid=True, color=None, coord=None, fogCoord=None, normal=None, texCoord=None, attrib=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TriangleSet __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ccw = ccw self.colorPerVertex = colorPerVertex self.normalPerVertex = normalPerVertex self.solid = solid self.color = color self.coord = coord self.fogCoord = fogCoord self.normal = normal self.texCoord = texCoord self.attrib = attrib self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ccw(self): """ccw defines clockwise/counterclockwise ordering of vertex coordinates, which in turn defines front/back orientation of polygon normals according to Right-Hand Rule (RHR).""" return self.__ccw @ccw.setter def ccw(self, ccw): if ccw is None: ccw = True # default assertValidSFBool(ccw) self.__ccw = ccw @property # getter - - - - - - - - - - def colorPerVertex(self): """Whether Color|ColorRGBA values are applied to each point vertex (true) or to each polygon face (false).""" return self.__colorPerVertex @colorPerVertex.setter def colorPerVertex(self, colorPerVertex): if colorPerVertex is None: colorPerVertex = True # default assertValidSFBool(colorPerVertex) self.__colorPerVertex = colorPerVertex @property # getter - - - - - - - - - - def normalPerVertex(self): """Whether Normal node vector values are applied to each point vertex (true) or to each polygon face (false).""" return self.__normalPerVertex @normalPerVertex.setter def normalPerVertex(self, normalPerVertex): if normalPerVertex is None: normalPerVertex = True # default assertValidSFBool(normalPerVertex) self.__normalPerVertex = normalPerVertex @property # getter - - - - - - - - - - def solid(self): """Setting solid true means draw only one side of polygons (backface culling on), setting solid false means draw both sides of polygons (backface culling off).""" return self.__solid @solid.setter def solid(self, solid): if solid is None: solid = True # default assertValidSFBool(solid) self.__solid = solid @property # getter - - - - - - - - - - def color(self): """[X3DColorNode] Single contained Color or ColorRGBA node that can specify color values applied to corresponding vertices according to colorIndex and colorPerVertex fields.""" return self.__color @color.setter def color(self, color): if color is None: color = None # default assertValidSFNode(color) if not color is None and not isinstance(color,(_X3DColorNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(color) + ' does not match required node type (_X3DColorNode,ProtoInstance) and is invalid') self.__color = color @property # getter - - - - - - - - - - def coord(self): """[X3DCoordinateNode] Single contained Coordinate or CoordinateDouble node that can specify a list of vertex values.""" return self.__coord @coord.setter def coord(self, coord): if coord is None: coord = None # default assertValidSFNode(coord) if not coord is None and not isinstance(coord,(_X3DCoordinateNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(coord) + ' does not match required node type (_X3DCoordinateNode,ProtoInstance) and is invalid') self.__coord = coord @property # getter - - - - - - - - - - def fogCoord(self): """[FogCoordinate] Single contained FogCoordinate node that can specify depth parameters for fog in corresponding geometry.""" return self.__fogCoord @fogCoord.setter def fogCoord(self, fogCoord): if fogCoord is None: fogCoord = None # default assertValidSFNode(fogCoord) if not fogCoord is None and not isinstance(fogCoord,(FogCoordinate,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(fogCoord) + ' does not match required node type (FogCoordinate,ProtoInstance) and is invalid') self.__fogCoord = fogCoord @property # getter - - - - - - - - - - def normal(self): """[X3DNormalNode] Single contained Normal node that can specify perpendicular vectors for corresponding vertices to support rendering computations, applied according to the normalPerVertex field.""" return self.__normal @normal.setter def normal(self, normal): if normal is None: normal = None # default assertValidSFNode(normal) if not normal is None and not isinstance(normal,(_X3DNormalNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(normal) + ' does not match required node type (_X3DNormalNode,ProtoInstance) and is invalid') self.__normal = normal @property # getter - - - - - - - - - - def texCoord(self): """[X3DTextureCoordinateNode] Single contained TextureCoordinate, TextureCoordinateGenerator or MultiTextureCoordinate node that can specify coordinates for texture mapping onto corresponding geometry.""" return self.__texCoord @texCoord.setter def texCoord(self, texCoord): if texCoord is None: texCoord = None # default assertValidSFNode(texCoord) if not texCoord is None and not isinstance(texCoord,(_X3DSingleTextureCoordinateNode,MultiTextureCoordinate,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(texCoord) + ' does not match required node type (_X3DSingleTextureCoordinateNode,MultiTextureCoordinate,ProtoInstance) and is invalid') self.__texCoord = texCoord @property # getter - - - - - - - - - - def attrib(self): """[X3DVertexAttributeNode] Single contained FloatVertexAttribute node that can specify list of per-vertex attribute information for programmable shaders.""" return self.__attrib @attrib.setter def attrib(self, attrib): if attrib is None: attrib = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(attrib) self.__attrib = attrib @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.color or self.coord or self.fogCoord or self.IS or self.metadata or self.normal or self.texCoord or (len(self.attrib) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleSet.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleSet.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TriangleSet":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if not self.ccw: # default=true attributeResult += " " + '"@ccw":"' + SFBool(self.ccw).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if not self.colorPerVertex: # default=true attributeResult += " " + '"@colorPerVertex":"' + SFBool(self.colorPerVertex).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.normalPerVertex: # default=true attributeResult += " " + '"@normalPerVertex":"' + SFBool(self.normalPerVertex).JSON() + '"' + ',\n' if not self.solid: # default=true attributeResult += " " + '"@solid":"' + SFBool(self.solid).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.color: # output this SFNode result += self.color.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.coord: # output this SFNode result += self.coord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.fogCoord: # output this SFNode result += self.fogCoord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.normal: # output this SFNode result += self.normal.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.texCoord: # output this SFNode result += self.texCoord.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.attrib: # walk each child in list, if any (avoid empty list recursion) ### print('* TriangleSet found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(attrib)=' + str(len(self.attrib)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.attrib: # walk each child in list, if any (avoid empty list recursion) for each in self.attrib: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TriangleSet.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TriangleSet' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TriangleSet' + ' {' if not self.ccw: # default=true result += '\n' + indent + ' ' + "ccw " + SFBool(self.ccw).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if not self.colorPerVertex: # default=true result += '\n' + indent + ' ' + "colorPerVertex " + SFBool(self.colorPerVertex).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.normalPerVertex: # default=true result += '\n' + indent + ' ' + "normalPerVertex " + SFBool(self.normalPerVertex).VRML() + "" if not self.solid: # default=true result += '\n' + indent + ' ' + "solid " + SFBool(self.solid).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.color: # output this SFNode result += '\n' + ' ' + indent + 'color ' + self.color.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.coord: # output this SFNode result += '\n' + ' ' + indent + 'coord ' + self.coord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.fogCoord: # output this SFNode result += '\n' + ' ' + indent + 'fogCoord ' + self.fogCoord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.normal: # output this SFNode result += '\n' + ' ' + indent + 'normal ' + self.normal.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.texCoord: # output this SFNode result += '\n' + ' ' + indent + 'texCoord ' + self.texCoord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.attrib: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.attrib: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TriangleSet2D(_X3DGeometryNode): """ TriangleSet2D is a geometry node that defines a set of filled 2D triangles in X-Y plane. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TriangleSet2D' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/geometry2D.html#TriangleSet2D' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TriangleSet2D' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('solid', False, FieldType.SFBool, AccessType.inputOutput, 'TriangleSet2D'), ('vertices', [], FieldType.MFVec2f, AccessType.inputOutput, 'TriangleSet2D'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, solid=False, vertices=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TriangleSet2D __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.solid = solid self.vertices = vertices self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def solid(self): """Setting solid true means draw only one side of polygons (backface culling on), setting solid false means draw both sides of polygons (backface culling off).""" return self.__solid @solid.setter def solid(self, solid): if solid is None: solid = False # default assertValidSFBool(solid) self.__solid = solid @property # getter - - - - - - - - - - def vertices(self): """2D coordinates of TriangleSet2D vertices.""" return self.__vertices @vertices.setter def vertices(self, vertices): if vertices is None: vertices = MFVec2f.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFVec2f.DEFAULT_VALUE()=' + str(MFVec2f.DEFAULT_VALUE())) assertValidMFVec2f(vertices) self.__vertices = vertices @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleSet2D.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleSet2D.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TriangleSet2D":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.solid: # default=false attributeResult += " " + '"@solid":"' + SFBool(self.solid).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.vertices != []: attributeResult += " " + '"@vertices":"' + MFVec2f(self.vertices).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TriangleSet2D.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TriangleSet2D' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TriangleSet2D' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.solid: # default=false result += '\n' + indent + ' ' + "solid " + SFBool(self.solid).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.vertices != []: result += '\n' + indent + ' ' + "vertices " + MFVec2f(self.vertices).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TriangleStripSet(_X3DComposedGeometryNode): """ TriangleStripSet is a geometry node containing a Coordinate|CoordinateDouble node, and can also contain Color|ColorRGBA, Normal and TextureCoordinate nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TriangleStripSet' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rendering.html#TriangleStripSet' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TriangleStripSet' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ccw', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('colorPerVertex', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('normalPerVertex', True, FieldType.SFBool, AccessType.initializeOnly, 'X3DComposedGeometryNode'), ('solid', True, FieldType.SFBool, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('stripCount', [], FieldType.MFInt32, AccessType.inputOutput, 'TriangleStripSet'), ('color', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('coord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('fogCoord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('normal', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('texCoord', None, FieldType.SFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('attrib', [], FieldType.MFNode, AccessType.inputOutput, 'X3DComposedGeometryNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ccw=True, colorPerVertex=True, normalPerVertex=True, solid=True, stripCount=None, color=None, coord=None, fogCoord=None, normal=None, texCoord=None, attrib=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TriangleStripSet __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ccw = ccw self.colorPerVertex = colorPerVertex self.normalPerVertex = normalPerVertex self.solid = solid self.stripCount = stripCount self.color = color self.coord = coord self.fogCoord = fogCoord self.normal = normal self.texCoord = texCoord self.attrib = attrib self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ccw(self): """ccw defines clockwise/counterclockwise ordering of vertex coordinates, which in turn defines front/back orientation of polygon normals according to Right-Hand Rule (RHR).""" return self.__ccw @ccw.setter def ccw(self, ccw): if ccw is None: ccw = True # default assertValidSFBool(ccw) self.__ccw = ccw @property # getter - - - - - - - - - - def colorPerVertex(self): """Whether Color|ColorRGBA values are applied to each point vertex (true) or to each polygon face (false).""" return self.__colorPerVertex @colorPerVertex.setter def colorPerVertex(self, colorPerVertex): if colorPerVertex is None: colorPerVertex = True # default assertValidSFBool(colorPerVertex) self.__colorPerVertex = colorPerVertex @property # getter - - - - - - - - - - def normalPerVertex(self): """Whether Normal node vector values are applied to each point vertex (true) or to each polygon face (false).""" return self.__normalPerVertex @normalPerVertex.setter def normalPerVertex(self, normalPerVertex): if normalPerVertex is None: normalPerVertex = True # default assertValidSFBool(normalPerVertex) self.__normalPerVertex = normalPerVertex @property # getter - - - - - - - - - - def solid(self): """Setting solid true means draw only one side of polygons (backface culling on), setting solid false means draw both sides of polygons (backface culling off).""" return self.__solid @solid.setter def solid(self, solid): if solid is None: solid = True # default assertValidSFBool(solid) self.__solid = solid @property # getter - - - - - - - - - - def stripCount(self): """(3,+infinity) stripCount array provides number of vertices in each strip.""" return self.__stripCount @stripCount.setter def stripCount(self, stripCount): if stripCount is None: stripCount = MFInt32.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFInt32.DEFAULT_VALUE()=' + str(MFInt32.DEFAULT_VALUE())) assertValidMFInt32(stripCount) assertGreaterThanEquals('stripCount', stripCount, 3) self.__stripCount = stripCount @property # getter - - - - - - - - - - def color(self): """[X3DColorNode] Single contained Color or ColorRGBA node that can specify color values applied to corresponding vertices according to colorIndex and colorPerVertex fields.""" return self.__color @color.setter def color(self, color): if color is None: color = None # default assertValidSFNode(color) if not color is None and not isinstance(color,(_X3DColorNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(color) + ' does not match required node type (_X3DColorNode,ProtoInstance) and is invalid') self.__color = color @property # getter - - - - - - - - - - def coord(self): """[X3DCoordinateNode] Single contained Coordinate or CoordinateDouble node that can specify a list of vertex values.""" return self.__coord @coord.setter def coord(self, coord): if coord is None: coord = None # default assertValidSFNode(coord) if not coord is None and not isinstance(coord,(_X3DCoordinateNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(coord) + ' does not match required node type (_X3DCoordinateNode,ProtoInstance) and is invalid') self.__coord = coord @property # getter - - - - - - - - - - def fogCoord(self): """[FogCoordinate] Single contained FogCoordinate node that can specify depth parameters for fog in corresponding geometry.""" return self.__fogCoord @fogCoord.setter def fogCoord(self, fogCoord): if fogCoord is None: fogCoord = None # default assertValidSFNode(fogCoord) if not fogCoord is None and not isinstance(fogCoord,(FogCoordinate,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(fogCoord) + ' does not match required node type (FogCoordinate,ProtoInstance) and is invalid') self.__fogCoord = fogCoord @property # getter - - - - - - - - - - def normal(self): """[X3DNormalNode] Single contained Normal node that can specify perpendicular vectors for corresponding vertices to support rendering computations, applied according to the normalPerVertex field.""" return self.__normal @normal.setter def normal(self, normal): if normal is None: normal = None # default assertValidSFNode(normal) if not normal is None and not isinstance(normal,(_X3DNormalNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(normal) + ' does not match required node type (_X3DNormalNode,ProtoInstance) and is invalid') self.__normal = normal @property # getter - - - - - - - - - - def texCoord(self): """[X3DTextureCoordinateNode] Single contained TextureCoordinate, TextureCoordinateGenerator or MultiTextureCoordinate node that can specify coordinates for texture mapping onto corresponding geometry.""" return self.__texCoord @texCoord.setter def texCoord(self, texCoord): if texCoord is None: texCoord = None # default assertValidSFNode(texCoord) if not texCoord is None and not isinstance(texCoord,(_X3DSingleTextureCoordinateNode,MultiTextureCoordinate,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(texCoord) + ' does not match required node type (_X3DSingleTextureCoordinateNode,MultiTextureCoordinate,ProtoInstance) and is invalid') self.__texCoord = texCoord @property # getter - - - - - - - - - - def attrib(self): """[X3DVertexAttributeNode] Single contained FloatVertexAttribute node that can specify list of per-vertex attribute information for programmable shaders.""" return self.__attrib @attrib.setter def attrib(self, attrib): if attrib is None: attrib = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(attrib) self.__attrib = attrib @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.color or self.coord or self.fogCoord or self.IS or self.metadata or self.normal or self.texCoord or (len(self.attrib) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleStripSet.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TriangleStripSet.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TriangleStripSet":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if not self.ccw: # default=true attributeResult += " " + '"@ccw":"' + SFBool(self.ccw).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if not self.colorPerVertex: # default=true attributeResult += " " + '"@colorPerVertex":"' + SFBool(self.colorPerVertex).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.normalPerVertex: # default=true attributeResult += " " + '"@normalPerVertex":"' + SFBool(self.normalPerVertex).JSON() + '"' + ',\n' if not self.solid: # default=true attributeResult += " " + '"@solid":"' + SFBool(self.solid).JSON() + '"' + ',\n' if self.stripCount != []: attributeResult += " " + '"@stripCount":"' + MFInt32(self.stripCount).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.color: # output this SFNode result += self.color.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.coord: # output this SFNode result += self.coord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.fogCoord: # output this SFNode result += self.fogCoord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.normal: # output this SFNode result += self.normal.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.texCoord: # output this SFNode result += self.texCoord.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.attrib: # walk each child in list, if any (avoid empty list recursion) ### print('* TriangleStripSet found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(attrib)=' + str(len(self.attrib)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.attrib: # walk each child in list, if any (avoid empty list recursion) for each in self.attrib: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TriangleStripSet.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TriangleStripSet' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TriangleStripSet' + ' {' if not self.ccw: # default=true result += '\n' + indent + ' ' + "ccw " + SFBool(self.ccw).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if not self.colorPerVertex: # default=true result += '\n' + indent + ' ' + "colorPerVertex " + SFBool(self.colorPerVertex).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.normalPerVertex: # default=true result += '\n' + indent + ' ' + "normalPerVertex " + SFBool(self.normalPerVertex).VRML() + "" if not self.solid: # default=true result += '\n' + indent + ' ' + "solid " + SFBool(self.solid).VRML() + "" if self.stripCount != []: result += '\n' + indent + ' ' + "stripCount " + MFInt32(self.stripCount).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.color: # output this SFNode result += '\n' + ' ' + indent + 'color ' + self.color.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.coord: # output this SFNode result += '\n' + ' ' + indent + 'coord ' + self.coord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.fogCoord: # output this SFNode result += '\n' + ' ' + indent + 'fogCoord ' + self.fogCoord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.normal: # output this SFNode result += '\n' + ' ' + indent + 'normal ' + self.normal.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.texCoord: # output this SFNode result += '\n' + ' ' + indent + 'texCoord ' + self.texCoord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.attrib: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.attrib: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class TwoSidedMaterial(_X3DMaterialNode): """ TwoSidedMaterial specifies surface rendering properties for associated geometry nodes, for outer (front) and inner (back) sides of polygons. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'TwoSidedMaterial' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#TwoSidedMaterial' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#TwoSidedMaterial' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('ambientIntensity', 0.2, FieldType.SFFloat, AccessType.inputOutput, 'TwoSidedMaterial'), ('backAmbientIntensity', 0.2, FieldType.SFFloat, AccessType.inputOutput, 'TwoSidedMaterial'), ('backDiffuseColor', (0.8, 0.8, 0.8), FieldType.SFColor, AccessType.inputOutput, 'TwoSidedMaterial'), ('backEmissiveColor', (0, 0, 0), FieldType.SFColor, AccessType.inputOutput, 'TwoSidedMaterial'), ('backShininess', 0.2, FieldType.SFFloat, AccessType.inputOutput, 'TwoSidedMaterial'), ('backSpecularColor', (0, 0, 0), FieldType.SFColor, AccessType.inputOutput, 'TwoSidedMaterial'), ('backTransparency', 0, FieldType.SFFloat, AccessType.inputOutput, 'TwoSidedMaterial'), ('diffuseColor', (0.8, 0.8, 0.8), FieldType.SFColor, AccessType.inputOutput, 'TwoSidedMaterial'), ('emissiveColor', (0, 0, 0), FieldType.SFColor, AccessType.inputOutput, 'TwoSidedMaterial'), ('separateBackColor', False, FieldType.SFBool, AccessType.inputOutput, 'TwoSidedMaterial'), ('shininess', 0.2, FieldType.SFFloat, AccessType.inputOutput, 'TwoSidedMaterial'), ('specularColor', (0, 0, 0), FieldType.SFColor, AccessType.inputOutput, 'TwoSidedMaterial'), ('transparency', 0, FieldType.SFFloat, AccessType.inputOutput, 'TwoSidedMaterial'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, ambientIntensity=0.2, backAmbientIntensity=0.2, backDiffuseColor=(0.8, 0.8, 0.8), backEmissiveColor=(0, 0, 0), backShininess=0.2, backSpecularColor=(0, 0, 0), backTransparency=0, diffuseColor=(0.8, 0.8, 0.8), emissiveColor=(0, 0, 0), separateBackColor=False, shininess=0.2, specularColor=(0, 0, 0), transparency=0, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode TwoSidedMaterial __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.ambientIntensity = ambientIntensity self.backAmbientIntensity = backAmbientIntensity self.backDiffuseColor = backDiffuseColor self.backEmissiveColor = backEmissiveColor self.backShininess = backShininess self.backSpecularColor = backSpecularColor self.backTransparency = backTransparency self.diffuseColor = diffuseColor self.emissiveColor = emissiveColor self.separateBackColor = separateBackColor self.shininess = shininess self.specularColor = specularColor self.transparency = transparency self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def ambientIntensity(self): """[0,1] how much ambient omnidirectional light is reflected from all light sources.""" return self.__ambientIntensity @ambientIntensity.setter def ambientIntensity(self, ambientIntensity): if ambientIntensity is None: ambientIntensity = 0.2 # default assertValidSFFloat(ambientIntensity) assertZeroToOne('ambientIntensity', ambientIntensity) self.__ambientIntensity = ambientIntensity @property # getter - - - - - - - - - - def backAmbientIntensity(self): """[0,1] how much ambient omnidirectional light is reflected from all light sources.""" return self.__backAmbientIntensity @backAmbientIntensity.setter def backAmbientIntensity(self, backAmbientIntensity): if backAmbientIntensity is None: backAmbientIntensity = 0.2 # default assertValidSFFloat(backAmbientIntensity) assertZeroToOne('backAmbientIntensity', backAmbientIntensity) self.__backAmbientIntensity = backAmbientIntensity @property # getter - - - - - - - - - - def backDiffuseColor(self): """[0,1] how much direct, angle-dependent light is reflected from all light sources.""" return self.__backDiffuseColor @backDiffuseColor.setter def backDiffuseColor(self, backDiffuseColor): if backDiffuseColor is None: backDiffuseColor = (0.8, 0.8, 0.8) # default assertValidSFColor(backDiffuseColor) assertZeroToOne('backDiffuseColor', backDiffuseColor) self.__backDiffuseColor = backDiffuseColor @property # getter - - - - - - - - - - def backEmissiveColor(self): """[0,1] how much glowing light is emitted from this object.""" return self.__backEmissiveColor @backEmissiveColor.setter def backEmissiveColor(self, backEmissiveColor): if backEmissiveColor is None: backEmissiveColor = (0, 0, 0) # default assertValidSFColor(backEmissiveColor) assertZeroToOne('backEmissiveColor', backEmissiveColor) self.__backEmissiveColor = backEmissiveColor @property # getter - - - - - - - - - - def backShininess(self): """[0,1] Lower shininess values provide soft specular glows, while higher values result in sharper, smaller highlights.""" return self.__backShininess @backShininess.setter def backShininess(self, backShininess): if backShininess is None: backShininess = 0.2 # default assertValidSFFloat(backShininess) assertZeroToOne('backShininess', backShininess) self.__backShininess = backShininess @property # getter - - - - - - - - - - def backSpecularColor(self): """[0,1] specular highlights are brightness reflections (example: shiny spots on an apple).""" return self.__backSpecularColor @backSpecularColor.setter def backSpecularColor(self, backSpecularColor): if backSpecularColor is None: backSpecularColor = (0, 0, 0) # default assertValidSFColor(backSpecularColor) assertZeroToOne('backSpecularColor', backSpecularColor) self.__backSpecularColor = backSpecularColor @property # getter - - - - - - - - - - def backTransparency(self): """[0,1] how "clear" an object is: 1.""" return self.__backTransparency @backTransparency.setter def backTransparency(self, backTransparency): if backTransparency is None: backTransparency = 0 # default assertValidSFFloat(backTransparency) assertZeroToOne('backTransparency', backTransparency) self.__backTransparency = backTransparency @property # getter - - - - - - - - - - def diffuseColor(self): """[0,1] how much direct, angle-dependent light is reflected from all light sources.""" return self.__diffuseColor @diffuseColor.setter def diffuseColor(self, diffuseColor): if diffuseColor is None: diffuseColor = (0.8, 0.8, 0.8) # default assertValidSFColor(diffuseColor) assertZeroToOne('diffuseColor', diffuseColor) self.__diffuseColor = diffuseColor @property # getter - - - - - - - - - - def emissiveColor(self): """[0,1] how much glowing light is emitted from this object.""" return self.__emissiveColor @emissiveColor.setter def emissiveColor(self, emissiveColor): if emissiveColor is None: emissiveColor = (0, 0, 0) # default assertValidSFColor(emissiveColor) assertZeroToOne('emissiveColor', emissiveColor) self.__emissiveColor = emissiveColor @property # getter - - - - - - - - - - def separateBackColor(self): """separateBackColor determines whether separate Material values are used for back faces.""" return self.__separateBackColor @separateBackColor.setter def separateBackColor(self, separateBackColor): if separateBackColor is None: separateBackColor = False # default assertValidSFBool(separateBackColor) self.__separateBackColor = separateBackColor @property # getter - - - - - - - - - - def shininess(self): """[0,1] Lower shininess values provide soft specular glows, while higher values result in sharper, smaller highlights.""" return self.__shininess @shininess.setter def shininess(self, shininess): if shininess is None: shininess = 0.2 # default assertValidSFFloat(shininess) assertZeroToOne('shininess', shininess) self.__shininess = shininess @property # getter - - - - - - - - - - def specularColor(self): """[0,1] specular highlights are brightness reflections (example: shiny spots on an apple).""" return self.__specularColor @specularColor.setter def specularColor(self, specularColor): if specularColor is None: specularColor = (0, 0, 0) # default assertValidSFColor(specularColor) assertZeroToOne('specularColor', specularColor) self.__specularColor = specularColor @property # getter - - - - - - - - - - def transparency(self): """[0,1] how "clear" an object is: 1.""" return self.__transparency @transparency.setter def transparency(self, transparency): if transparency is None: transparency = 0 # default assertValidSFFloat(transparency) assertZeroToOne('transparency', transparency) self.__transparency = transparency @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TwoSidedMaterial.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function TwoSidedMaterial.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"TwoSidedMaterial":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.ambientIntensity != 0.2: attributeResult += " " + '"@ambientIntensity":"' + SFFloat(self.ambientIntensity).JSON() + '"' + ',\n' if self.backAmbientIntensity != 0.2: attributeResult += " " + '"@backAmbientIntensity":"' + SFFloat(self.backAmbientIntensity).JSON() + '"' + ',\n' if self.backDiffuseColor != (0.8, 0.8, 0.8): attributeResult += " " + '"@backDiffuseColor":"' + SFColor(self.backDiffuseColor).JSON() + '"' + ',\n' if self.backEmissiveColor != (0, 0, 0): attributeResult += " " + '"@backEmissiveColor":"' + SFColor(self.backEmissiveColor).JSON() + '"' + ',\n' if self.backShininess != 0.2: attributeResult += " " + '"@backShininess":"' + SFFloat(self.backShininess).JSON() + '"' + ',\n' if self.backSpecularColor != (0, 0, 0): attributeResult += " " + '"@backSpecularColor":"' + SFColor(self.backSpecularColor).JSON() + '"' + ',\n' if self.backTransparency != 0: attributeResult += " " + '"@backTransparency":"' + SFFloat(self.backTransparency).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.diffuseColor != (0.8, 0.8, 0.8): attributeResult += " " + '"@diffuseColor":"' + SFColor(self.diffuseColor).JSON() + '"' + ',\n' if self.emissiveColor != (0, 0, 0): attributeResult += " " + '"@emissiveColor":"' + SFColor(self.emissiveColor).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.separateBackColor: # default=false attributeResult += " " + '"@separateBackColor":"' + SFBool(self.separateBackColor).JSON() + '"' + ',\n' if self.shininess != 0.2: attributeResult += " " + '"@shininess":"' + SFFloat(self.shininess).JSON() + '"' + ',\n' if self.specularColor != (0, 0, 0): attributeResult += " " + '"@specularColor":"' + SFColor(self.specularColor).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.transparency != 0: attributeResult += " " + '"@transparency":"' + SFFloat(self.transparency).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function TwoSidedMaterial.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'TwoSidedMaterial' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'TwoSidedMaterial' + ' {' if self.ambientIntensity != 0.2: result += '\n' + indent + ' ' + "ambientIntensity " + SFFloat(self.ambientIntensity).VRML() + "" if self.backAmbientIntensity != 0.2: result += '\n' + indent + ' ' + "backAmbientIntensity " + SFFloat(self.backAmbientIntensity).VRML() + "" if self.backDiffuseColor != (0.8, 0.8, 0.8): result += '\n' + indent + ' ' + "backDiffuseColor " + SFColor(self.backDiffuseColor).VRML() + "" if self.backEmissiveColor != (0, 0, 0): result += '\n' + indent + ' ' + "backEmissiveColor " + SFColor(self.backEmissiveColor).VRML() + "" if self.backShininess != 0.2: result += '\n' + indent + ' ' + "backShininess " + SFFloat(self.backShininess).VRML() + "" if self.backSpecularColor != (0, 0, 0): result += '\n' + indent + ' ' + "backSpecularColor " + SFColor(self.backSpecularColor).VRML() + "" if self.backTransparency != 0: result += '\n' + indent + ' ' + "backTransparency " + SFFloat(self.backTransparency).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.diffuseColor != (0.8, 0.8, 0.8): result += '\n' + indent + ' ' + "diffuseColor " + SFColor(self.diffuseColor).VRML() + "" if self.emissiveColor != (0, 0, 0): result += '\n' + indent + ' ' + "emissiveColor " + SFColor(self.emissiveColor).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.separateBackColor: # default=false result += '\n' + indent + ' ' + "separateBackColor " + SFBool(self.separateBackColor).VRML() + "" if self.shininess != 0.2: result += '\n' + indent + ' ' + "shininess " + SFFloat(self.shininess).VRML() + "" if self.specularColor != (0, 0, 0): result += '\n' + indent + ' ' + "specularColor " + SFColor(self.specularColor).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.transparency != 0: result += '\n' + indent + ' ' + "transparency " + SFFloat(self.transparency).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class UniversalJoint(_X3DRigidJointNode): """ UniversalJoint is like a BallJoint that constrains an extra degree of rotational freedom. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'UniversalJoint' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/rigidBodyPhysics.html#UniversalJoint' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#UniversalJoint' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('anchorPoint', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'UniversalJoint'), ('axis1', (1, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'UniversalJoint'), ('axis2', (0, 1, 0), FieldType.SFVec3f, AccessType.inputOutput, 'UniversalJoint'), ('forceOutput', ["NONE"], FieldType.MFString, AccessType.inputOutput, 'X3DRigidJointNode'), ('stop1Bounce', 0, FieldType.SFFloat, AccessType.inputOutput, 'UniversalJoint'), ('stop1ErrorCorrection', 0.8, FieldType.SFFloat, AccessType.inputOutput, 'UniversalJoint'), ('stop2Bounce', 0, FieldType.SFFloat, AccessType.inputOutput, 'UniversalJoint'), ('stop2ErrorCorrection', 0.8, FieldType.SFFloat, AccessType.inputOutput, 'UniversalJoint'), ('body1', None, FieldType.SFNode, AccessType.inputOutput, 'X3DRigidJointNode'), ('body2', None, FieldType.SFNode, AccessType.inputOutput, 'X3DRigidJointNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, anchorPoint=(0, 0, 0), axis1=(1, 0, 0), axis2=(0, 1, 0), forceOutput=None, stop1Bounce=0, stop1ErrorCorrection=0.8, stop2Bounce=0, stop2ErrorCorrection=0.8, body1=None, body2=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode UniversalJoint __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.anchorPoint = anchorPoint self.axis1 = axis1 self.axis2 = axis2 self.forceOutput = forceOutput self.stop1Bounce = stop1Bounce self.stop1ErrorCorrection = stop1ErrorCorrection self.stop2Bounce = stop2Bounce self.stop2ErrorCorrection = stop2ErrorCorrection self.body1 = body1 self.body2 = body2 self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def anchorPoint(self): """anchorPoint is joint center, specified in world coordinates.""" return self.__anchorPoint @anchorPoint.setter def anchorPoint(self, anchorPoint): if anchorPoint is None: anchorPoint = (0, 0, 0) # default assertValidSFVec3f(anchorPoint) self.__anchorPoint = anchorPoint @property # getter - - - - - - - - - - def axis1(self): """axis1 defines axis vector of joint connection to body1.""" return self.__axis1 @axis1.setter def axis1(self, axis1): if axis1 is None: axis1 = (1, 0, 0) # default assertValidSFVec3f(axis1) self.__axis1 = axis1 @property # getter - - - - - - - - - - def axis2(self): """axis2 defines axis vector of joint connection to body2.""" return self.__axis2 @axis2.setter def axis2(self, axis2): if axis2 is None: axis2 = (0, 1, 0) # default assertValidSFVec3f(axis2) self.__axis2 = axis2 @property # getter - - - - - - - - - - def forceOutput(self): """forceOutput controls which output fields are generated for the next frame.""" return self.__forceOutput @forceOutput.setter def forceOutput(self, forceOutput): if forceOutput is None: forceOutput = ["NONE"] # default assertValidMFString(forceOutput) self.__forceOutput = forceOutput @property # getter - - - - - - - - - - def stop1Bounce(self): """[0,1] stop1Bounce is velocity factor for bounce back once stop point is reached.""" return self.__stop1Bounce @stop1Bounce.setter def stop1Bounce(self, stop1Bounce): if stop1Bounce is None: stop1Bounce = 0 # default assertValidSFFloat(stop1Bounce) assertZeroToOne('stop1Bounce', stop1Bounce) self.__stop1Bounce = stop1Bounce @property # getter - - - - - - - - - - def stop1ErrorCorrection(self): """[0,1] stop1ErrorCorrection is fraction of error correction performed during time step once stop point is reached.""" return self.__stop1ErrorCorrection @stop1ErrorCorrection.setter def stop1ErrorCorrection(self, stop1ErrorCorrection): if stop1ErrorCorrection is None: stop1ErrorCorrection = 0.8 # default assertValidSFFloat(stop1ErrorCorrection) assertZeroToOne('stop1ErrorCorrection', stop1ErrorCorrection) self.__stop1ErrorCorrection = stop1ErrorCorrection @property # getter - - - - - - - - - - def stop2Bounce(self): """[0,1] stop2Bounce is velocity factor for bounce back once stop point is reached.""" return self.__stop2Bounce @stop2Bounce.setter def stop2Bounce(self, stop2Bounce): if stop2Bounce is None: stop2Bounce = 0 # default assertValidSFFloat(stop2Bounce) assertZeroToOne('stop2Bounce', stop2Bounce) self.__stop2Bounce = stop2Bounce @property # getter - - - - - - - - - - def stop2ErrorCorrection(self): """[0,1] stop2ErrorCorrection is fraction of error correction performed during time step once stop point is reached.""" return self.__stop2ErrorCorrection @stop2ErrorCorrection.setter def stop2ErrorCorrection(self, stop2ErrorCorrection): if stop2ErrorCorrection is None: stop2ErrorCorrection = 0.8 # default assertValidSFFloat(stop2ErrorCorrection) assertZeroToOne('stop2ErrorCorrection', stop2ErrorCorrection) self.__stop2ErrorCorrection = stop2ErrorCorrection @property # getter - - - - - - - - - - def body1(self): """[RigidBody] The body1 and body2 fields indicate the two RigidBody nodes connected by this joint.""" return self.__body1 @body1.setter def body1(self, body1): if body1 is None: body1 = None # default assertValidSFNode(body1) if not body1 is None and not isinstance(body1,(RigidBody,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(body1) + ' does not match required node type (RigidBody,ProtoInstance) and is invalid') self.__body1 = body1 @property # getter - - - - - - - - - - def body2(self): """[RigidBody] The body1 and body2 fields indicate the two RigidBody nodes connected by this joint.""" return self.__body2 @body2.setter def body2(self, body2): if body2 is None: body2 = None # default assertValidSFNode(body2) if not body2 is None and not isinstance(body2,(RigidBody,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(body2) + ' does not match required node type (RigidBody,ProtoInstance) and is invalid') self.__body2 = body2 @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.body1 or self.body2 or self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function UniversalJoint.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function UniversalJoint.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"UniversalJoint":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.anchorPoint != (0, 0, 0): attributeResult += " " + '"@anchorPoint":"' + SFVec3f(self.anchorPoint).JSON() + '"' + ',\n' if self.axis1 != (1, 0, 0): attributeResult += " " + '"@axis1":"' + SFVec3f(self.axis1).JSON() + '"' + ',\n' if self.axis2 != (0, 1, 0): attributeResult += " " + '"@axis2":"' + SFVec3f(self.axis2).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.forceOutput != ["NONE"]: attributeResult += " " + '"@forceOutput":"' + MFString(self.forceOutput).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.stop1Bounce != 0: attributeResult += " " + '"@stop1Bounce":"' + SFFloat(self.stop1Bounce).JSON() + '"' + ',\n' if self.stop1ErrorCorrection != 0.8: attributeResult += " " + '"@stop1ErrorCorrection":"' + SFFloat(self.stop1ErrorCorrection).JSON() + '"' + ',\n' if self.stop2Bounce != 0: attributeResult += " " + '"@stop2Bounce":"' + SFFloat(self.stop2Bounce).JSON() + '"' + ',\n' if self.stop2ErrorCorrection != 0.8: attributeResult += " " + '"@stop2ErrorCorrection":"' + SFFloat(self.stop2ErrorCorrection).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.body1: # output this SFNode result += self.body1.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.body2: # output this SFNode result += self.body2.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function UniversalJoint.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'UniversalJoint' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'UniversalJoint' + ' {' if self.anchorPoint != (0, 0, 0): result += '\n' + indent + ' ' + "anchorPoint " + SFVec3f(self.anchorPoint).VRML() + "" if self.axis1 != (1, 0, 0): result += '\n' + indent + ' ' + "axis1 " + SFVec3f(self.axis1).VRML() + "" if self.axis2 != (0, 1, 0): result += '\n' + indent + ' ' + "axis2 " + SFVec3f(self.axis2).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.forceOutput != ["NONE"]: result += '\n' + indent + ' ' + "forceOutput " + MFString(self.forceOutput).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.stop1Bounce != 0: result += '\n' + indent + ' ' + "stop1Bounce " + SFFloat(self.stop1Bounce).VRML() + "" if self.stop1ErrorCorrection != 0.8: result += '\n' + indent + ' ' + "stop1ErrorCorrection " + SFFloat(self.stop1ErrorCorrection).VRML() + "" if self.stop2Bounce != 0: result += '\n' + indent + ' ' + "stop2Bounce " + SFFloat(self.stop2Bounce).VRML() + "" if self.stop2ErrorCorrection != 0.8: result += '\n' + indent + ' ' + "stop2ErrorCorrection " + SFFloat(self.stop2ErrorCorrection).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.body1: # output this SFNode result += '\n' + ' ' + indent + 'body1 ' + self.body1.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.body2: # output this SFNode result += '\n' + ' ' + indent + 'body2 ' + self.body2.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class UnlitMaterial(_X3DOneSidedMaterialNode): """ UnlitMaterial specifies surface rendering properties for associated geometry nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'UnlitMaterial' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/shape.html#UnlitMaterial' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#UnlitMaterial' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('emissiveColor', (1, 1, 1), FieldType.SFColor, AccessType.inputOutput, 'UnlitMaterial'), ('emissiveTextureMapping', '', FieldType.SFString, AccessType.inputOutput, 'X3DOneSidedMaterialNode'), ('normalScale', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DOneSidedMaterialNode'), ('normalTextureMapping', '', FieldType.SFString, AccessType.inputOutput, 'X3DOneSidedMaterialNode'), ('transparency', 0, FieldType.SFFloat, AccessType.inputOutput, 'UnlitMaterial'), ('emissiveTexture', None, FieldType.SFNode, AccessType.inputOutput, 'UnlitMaterial'), ('normalTexture', None, FieldType.SFNode, AccessType.inputOutput, 'UnlitMaterial'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, emissiveColor=(1, 1, 1), emissiveTextureMapping='', normalScale=1, normalTextureMapping='', transparency=0, emissiveTexture=None, normalTexture=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode UnlitMaterial __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.emissiveColor = emissiveColor self.emissiveTextureMapping = emissiveTextureMapping self.normalScale = normalScale self.normalTextureMapping = normalTextureMapping self.transparency = transparency self.emissiveTexture = emissiveTexture self.normalTexture = normalTexture self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def emissiveColor(self): """[0,1] how much glowing light is emitted from this object.""" return self.__emissiveColor @emissiveColor.setter def emissiveColor(self, emissiveColor): if emissiveColor is None: emissiveColor = (1, 1, 1) # default assertValidSFColor(emissiveColor) assertZeroToOne('emissiveColor', emissiveColor) self.__emissiveColor = emissiveColor @property # getter - - - - - - - - - - def emissiveTextureMapping(self): """The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material.""" return self.__emissiveTextureMapping @emissiveTextureMapping.setter def emissiveTextureMapping(self, emissiveTextureMapping): if emissiveTextureMapping is None: emissiveTextureMapping = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(emissiveTextureMapping) self.__emissiveTextureMapping = emissiveTextureMapping @property # getter - - - - - - - - - - def normalScale(self): """[0,infinity] normalScale controls the degree to which normalTexture RGB values apply XYZ-normal bump mapping to pixels in the parent material.""" return self.__normalScale @normalScale.setter def normalScale(self, normalScale): if normalScale is None: normalScale = 1 # default assertValidSFFloat(normalScale) assertNonNegative('normalScale', normalScale) self.__normalScale = normalScale @property # getter - - - - - - - - - - def normalTextureMapping(self): """The mapping label identifies which texture coordinates and transformations are used to compute texture effects from corresponding geometry on a given material.""" return self.__normalTextureMapping @normalTextureMapping.setter def normalTextureMapping(self, normalTextureMapping): if normalTextureMapping is None: normalTextureMapping = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(normalTextureMapping) self.__normalTextureMapping = normalTextureMapping @property # getter - - - - - - - - - - def transparency(self): """[0,1] how "clear" an object is: 1.""" return self.__transparency @transparency.setter def transparency(self, transparency): if transparency is None: transparency = 0 # default assertValidSFFloat(transparency) assertZeroToOne('transparency', transparency) self.__transparency = transparency @property # getter - - - - - - - - - - def emissiveTexture(self): """[X3DSingleTextureNode] When applying emissiveColor for this material node, the contained texture provides Physically Based Rendering (PBR) modulation for each pixel.""" return self.__emissiveTexture @emissiveTexture.setter def emissiveTexture(self, emissiveTexture): if emissiveTexture is None: emissiveTexture = None # default assertValidSFNode(emissiveTexture) if not emissiveTexture is None and not isinstance(emissiveTexture,(_X3DSingleTextureNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(emissiveTexture) + ' does not match required node type (_X3DSingleTextureNode,ProtoInstance) and is invalid') self.__emissiveTexture = emissiveTexture @property # getter - - - - - - - - - - def normalTexture(self): """[X3DSingleTextureNode] When applying normalScale for this material node, the contained texture modulates the texture across the surface.""" return self.__normalTexture @normalTexture.setter def normalTexture(self, normalTexture): if normalTexture is None: normalTexture = None # default assertValidSFNode(normalTexture) if not normalTexture is None and not isinstance(normalTexture,(_X3DSingleTextureNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(normalTexture) + ' does not match required node type (_X3DSingleTextureNode,ProtoInstance) and is invalid') self.__normalTexture = normalTexture @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.emissiveTexture or self.IS or self.metadata or self.normalTexture # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function UnlitMaterial.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function UnlitMaterial.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"UnlitMaterial":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.emissiveColor != (1, 1, 1): attributeResult += " " + '"@emissiveColor":"' + SFColor(self.emissiveColor).JSON() + '"' + ',\n' if self.emissiveTextureMapping: attributeResult += " " + '"@emissiveTextureMapping":"' + SFString(self.emissiveTextureMapping).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.normalScale != 1: attributeResult += " " + '"@normalScale":"' + SFFloat(self.normalScale).JSON() + '"' + ',\n' if self.normalTextureMapping: attributeResult += " " + '"@normalTextureMapping":"' + SFString(self.normalTextureMapping).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.transparency != 0: attributeResult += " " + '"@transparency":"' + SFFloat(self.transparency).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.emissiveTexture: # output this SFNode result += self.emissiveTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.normalTexture: # output this SFNode result += self.normalTexture.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function UnlitMaterial.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'UnlitMaterial' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'UnlitMaterial' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.emissiveColor != (1, 1, 1): result += '\n' + indent + ' ' + "emissiveColor " + SFColor(self.emissiveColor).VRML() + "" if self.emissiveTextureMapping: result += '\n' + indent + ' ' + "emissiveTextureMapping " + '"' + self.emissiveTextureMapping + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.normalScale != 1: result += '\n' + indent + ' ' + "normalScale " + SFFloat(self.normalScale).VRML() + "" if self.normalTextureMapping: result += '\n' + indent + ' ' + "normalTextureMapping " + '"' + self.normalTextureMapping + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.transparency != 0: result += '\n' + indent + ' ' + "transparency " + SFFloat(self.transparency).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.emissiveTexture: # output this SFNode result += '\n' + ' ' + indent + 'emissiveTexture ' + self.emissiveTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.normalTexture: # output this SFNode result += '\n' + ' ' + indent + 'normalTexture ' + self.normalTexture.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Viewpoint(_X3DViewpointNode): """ Viewpoint provides a specific location and direction where the user may view the scene. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Viewpoint' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/navigation.html#Viewpoint' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Viewpoint' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('centerOfRotation', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'Viewpoint'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DViewpointNode'), ('farDistance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DViewpointNode'), ('fieldOfView', 0.7854, FieldType.SFFloat, AccessType.inputOutput, 'Viewpoint'), ('jump', True, FieldType.SFBool, AccessType.inputOutput, 'X3DViewpointNode'), ('nearDistance', -1, FieldType.SFFloat, AccessType.inputOutput, 'X3DViewpointNode'), ('orientation', (0, 0, 1, 0), FieldType.SFRotation, AccessType.inputOutput, 'X3DViewpointNode'), ('position', (0, 0, 10), FieldType.SFVec3f, AccessType.inputOutput, 'Viewpoint'), ('retainUserOffsets', False, FieldType.SFBool, AccessType.inputOutput, 'X3DViewpointNode'), ('viewAll', False, FieldType.SFBool, AccessType.inputOutput, 'X3DViewpointNode'), ('navigationInfo', None, FieldType.SFNode, AccessType.inputOutput, 'X3DViewpointNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, centerOfRotation=(0, 0, 0), description='', farDistance=-1, fieldOfView=0.7854, jump=True, nearDistance=-1, orientation=(0, 0, 1, 0), position=(0, 0, 10), retainUserOffsets=False, viewAll=False, navigationInfo=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Viewpoint __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.centerOfRotation = centerOfRotation self.description = description self.farDistance = farDistance self.fieldOfView = fieldOfView self.jump = jump self.nearDistance = nearDistance self.orientation = orientation self.position = position self.retainUserOffsets = retainUserOffsets self.viewAll = viewAll self.navigationInfo = navigationInfo self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def centerOfRotation(self): """centerOfRotation specifies center point about which to rotate user's eyepoint when in EXAMINE or LOOKAT mode.""" return self.__centerOfRotation @centerOfRotation.setter def centerOfRotation(self, centerOfRotation): if centerOfRotation is None: centerOfRotation = (0, 0, 0) # default assertValidSFVec3f(centerOfRotation) self.__centerOfRotation = centerOfRotation @property # getter - - - - - - - - - - def description(self): """Text description or navigation hint to describe the significance of this model Viewpoint.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def farDistance(self): """or (0,+infinity) farDistance defines maximum clipping plane distance allowed for object display.""" return self.__farDistance @farDistance.setter def farDistance(self, farDistance): if farDistance is None: farDistance = -1 # default assertValidSFFloat(farDistance) self.__farDistance = farDistance @property # getter - - - - - - - - - - def fieldOfView(self): """Preferred minimum viewing angle from this viewpoint in radians, providing minimum height or minimum width (whichever is smaller).""" return self.__fieldOfView @fieldOfView.setter def fieldOfView(self, fieldOfView): if fieldOfView is None: fieldOfView = 0.7854 # default assertValidSFFloat(fieldOfView) assertGreaterThan('fieldOfView', fieldOfView, 0) assertLessThan('fieldOfView', fieldOfView, 3.1416) self.__fieldOfView = fieldOfView @property # getter - - - - - - - - - - def jump(self): """Transition instantly by jumping, otherwise smoothly adjust offsets in place when changing to this Viewpoint.""" return self.__jump @jump.setter def jump(self, jump): if jump is None: jump = True # default assertValidSFBool(jump) self.__jump = jump @property # getter - - - - - - - - - - def nearDistance(self): """or (0,+infinity) nearDistance defines minimum clipping plane distance necessary for object display.""" return self.__nearDistance @nearDistance.setter def nearDistance(self, nearDistance): if nearDistance is None: nearDistance = -1 # default assertValidSFFloat(nearDistance) self.__nearDistance = nearDistance @property # getter - - - - - - - - - - def orientation(self): """Rotation (axis, angle in radians) of Viewpoint, relative to default -Z axis direction in local coordinate system.""" return self.__orientation @orientation.setter def orientation(self, orientation): if orientation is None: orientation = (0, 0, 1, 0) # default assertValidSFRotation(orientation) self.__orientation = orientation @property # getter - - - - - - - - - - def position(self): """position (x, y, z in meters) relative to local coordinate system.""" return self.__position @position.setter def position(self, position): if position is None: position = (0, 0, 10) # default assertValidSFVec3f(position) self.__position = position @property # getter - - - - - - - - - - def retainUserOffsets(self): """Retain (true) or reset to zero (false) any prior user navigation offsets from defined viewpoint position, orientation.""" return self.__retainUserOffsets @retainUserOffsets.setter def retainUserOffsets(self, retainUserOffsets): if retainUserOffsets is None: retainUserOffsets = False # default assertValidSFBool(retainUserOffsets) self.__retainUserOffsets = retainUserOffsets @property # getter - - - - - - - - - - def viewAll(self): """Viewpoint is automatically adjusted to view all visible geometry.""" return self.__viewAll @viewAll.setter def viewAll(self, viewAll): if viewAll is None: viewAll = False # default assertValidSFBool(viewAll) self.__viewAll = viewAll @property # getter - - - - - - - - - - def navigationInfo(self): """[NavigationInfo] The navigationInfo field defines a dedicated NavigationInfo node for this X3DViewpointNode.""" return self.__navigationInfo @navigationInfo.setter def navigationInfo(self, navigationInfo): if navigationInfo is None: navigationInfo = None # default assertValidSFNode(navigationInfo) if not navigationInfo is None and not isinstance(navigationInfo,(NavigationInfo,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(navigationInfo) + ' does not match required node type (NavigationInfo,ProtoInstance) and is invalid') self.__navigationInfo = navigationInfo @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.navigationInfo # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Viewpoint.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Viewpoint.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Viewpoint":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.centerOfRotation != (0, 0, 0): attributeResult += " " + '"@centerOfRotation":"' + SFVec3f(self.centerOfRotation).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if self.farDistance != -1: attributeResult += " " + '"@farDistance":"' + SFFloat(self.farDistance).JSON() + '"' + ',\n' if self.fieldOfView != 0.7854: attributeResult += " " + '"@fieldOfView":"' + SFFloat(self.fieldOfView).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.jump: # default=true attributeResult += " " + '"@jump":"' + SFBool(self.jump).JSON() + '"' + ',\n' if self.nearDistance != -1: attributeResult += " " + '"@nearDistance":"' + SFFloat(self.nearDistance).JSON() + '"' + ',\n' if self.orientation != (0, 0, 1, 0): attributeResult += " " + '"@orientation":"' + SFRotation(self.orientation).JSON() + '"' + ',\n' if self.position != (0, 0, 10): attributeResult += " " + '"@position":"' + SFVec3f(self.position).JSON() + '"' + ',\n' if self.retainUserOffsets: # default=false attributeResult += " " + '"@retainUserOffsets":"' + SFBool(self.retainUserOffsets).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.viewAll: # default=false attributeResult += " " + '"@viewAll":"' + SFBool(self.viewAll).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.navigationInfo: # output this SFNode result += self.navigationInfo.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Viewpoint.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Viewpoint' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Viewpoint' + ' {' if self.centerOfRotation != (0, 0, 0): result += '\n' + indent + ' ' + "centerOfRotation " + SFVec3f(self.centerOfRotation).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if self.farDistance != -1: result += '\n' + indent + ' ' + "farDistance " + SFFloat(self.farDistance).VRML() + "" if self.fieldOfView != 0.7854: result += '\n' + indent + ' ' + "fieldOfView " + SFFloat(self.fieldOfView).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.jump: # default=true result += '\n' + indent + ' ' + "jump " + SFBool(self.jump).VRML() + "" if self.nearDistance != -1: result += '\n' + indent + ' ' + "nearDistance " + SFFloat(self.nearDistance).VRML() + "" if self.orientation != (0, 0, 1, 0): result += '\n' + indent + ' ' + "orientation " + SFRotation(self.orientation).VRML() + "" if self.position != (0, 0, 10): result += '\n' + indent + ' ' + "position " + SFVec3f(self.position).VRML() + "" if self.retainUserOffsets: # default=false result += '\n' + indent + ' ' + "retainUserOffsets " + SFBool(self.retainUserOffsets).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.viewAll: # default=false result += '\n' + indent + ' ' + "viewAll " + SFBool(self.viewAll).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.navigationInfo: # output this SFNode result += '\n' + ' ' + indent + 'navigationInfo ' + self.navigationInfo.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class ViewpointGroup(_X3DChildNode): """ ViewpointGroup can contain Viewpoint, OrthoViewpoint, GeoViewpoint and other ViewpointGroup nodes for better user-navigation support with a shared description on the viewpoint list. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'ViewpointGroup' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/navigation.html#ViewpointGroup' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#ViewpointGroup' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('center', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'ViewpointGroup'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'ViewpointGroup'), ('displayed', True, FieldType.SFBool, AccessType.inputOutput, 'ViewpointGroup'), ('retainUserOffsets', False, FieldType.SFBool, AccessType.inputOutput, 'ViewpointGroup'), ('size', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'ViewpointGroup'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'ViewpointGroup'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, center=(0, 0, 0), description='', displayed=True, retainUserOffsets=False, size=(0, 0, 0), children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode ViewpointGroup __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.center = center self.description = description self.displayed = displayed self.retainUserOffsets = retainUserOffsets self.size = size self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def center(self): """center specifies center point of proximity box within which ViewpointGroup is usable and displayed on viewpoint list.""" return self.__center @center.setter def center(self, center): if center is None: center = (0, 0, 0) # default assertValidSFVec3f(center) self.__center = center @property # getter - - - - - - - - - - def description(self): """Text description or navigation hint to identify this ViewpointGroup.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def displayed(self): """displayed determines whether this ViewpointGroup is displayed in the current viewpoint list.""" return self.__displayed @displayed.setter def displayed(self, displayed): if displayed is None: displayed = True # default assertValidSFBool(displayed) self.__displayed = displayed @property # getter - - - - - - - - - - def retainUserOffsets(self): """Retain (true) or reset to zero (false) any prior user navigation offsets from defined viewpoint position, orientation.""" return self.__retainUserOffsets @retainUserOffsets.setter def retainUserOffsets(self, retainUserOffsets): if retainUserOffsets is None: retainUserOffsets = False # default assertValidSFBool(retainUserOffsets) self.__retainUserOffsets = retainUserOffsets @property # getter - - - - - - - - - - def size(self): """[0,+infinity) Size of proximity box around center location within which ViewpointGroup is usable and displayed on viewpoint list.""" return self.__size @size.setter def size(self, size): if size is None: size = (0, 0, 0) # default assertValidSFVec3f(size) assertNonNegative('size', size) self.__size = size @property # getter - - - - - - - - - - def children(self): """[X3DChildNode] ViewpointGroup contains Viewpoint, OrthoViewpoint, GeoViewpoint and other ViewpointGroup nodes that each have containerField='children' default value.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ViewpointGroup.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function ViewpointGroup.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"ViewpointGroup":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.center != (0, 0, 0): attributeResult += " " + '"@center":"' + SFVec3f(self.center).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.displayed: # default=true attributeResult += " " + '"@displayed":"' + SFBool(self.displayed).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.retainUserOffsets: # default=false attributeResult += " " + '"@retainUserOffsets":"' + SFBool(self.retainUserOffsets).JSON() + '"' + ',\n' if self.size != (0, 0, 0): attributeResult += " " + '"@size":"' + SFVec3f(self.size).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* ViewpointGroup found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function ViewpointGroup.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'ViewpointGroup' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'ViewpointGroup' + ' {' if self.center != (0, 0, 0): result += '\n' + indent + ' ' + "center " + SFVec3f(self.center).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.displayed: # default=true result += '\n' + indent + ' ' + "displayed " + SFBool(self.displayed).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.retainUserOffsets: # default=false result += '\n' + indent + ' ' + "retainUserOffsets " + SFBool(self.retainUserOffsets).VRML() + "" if self.size != (0, 0, 0): result += '\n' + indent + ' ' + "size " + SFVec3f(self.size).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class Viewport(_X3DViewportNode): """ Viewport is a Grouping node that can contain most nodes. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'Viewport' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/layering.html#Viewport' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#Viewport' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DGroupingNode'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DGroupingNode'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DGroupingNode'), ('clipBoundary', [0, 1, 0, 1], FieldType.MFFloat, AccessType.inputOutput, 'Viewport'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DGroupingNode'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'X3DGroupingNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), clipBoundary=None, visible=True, children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode Viewport __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.clipBoundary = clipBoundary self.visible = visible self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def clipBoundary(self): """[0,1] clipBoundary is specified in fractions of the normal render surface in the sequence left/right/bottom/top.""" return self.__clipBoundary @clipBoundary.setter def clipBoundary(self, clipBoundary): if clipBoundary is None: clipBoundary = [0, 1, 0, 1] # default assertValidMFFloat(clipBoundary) assertZeroToOne('clipBoundary', clipBoundary) self.__clipBoundary = clipBoundary @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def children(self): """[X3DChildNode] Grouping nodes contain an ordered list of children nodes.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Viewport.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function Viewport.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"Viewport":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.clipBoundary != [0, 1, 0, 1]: attributeResult += " " + '"@clipBoundary":"' + MFFloat(self.clipBoundary).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* Viewport found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function Viewport.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'Viewport' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'Viewport' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.clipBoundary != [0, 1, 0, 1]: result += '\n' + indent + ' ' + "clipBoundary " + MFFloat(self.clipBoundary).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class VisibilitySensor(_X3DEnvironmentalSensorNode): """ VisibilitySensor detects when user can see a specific object or region as they navigate the world. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'VisibilitySensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/environmentalSensor.html#VisibilitySensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#VisibilitySensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('center', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'VisibilitySensor'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('size', (0, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'X3DEnvironmentalSensorNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, center=(0, 0, 0), description='', enabled=True, size=(0, 0, 0), DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode VisibilitySensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.center = center self.description = description self.enabled = enabled self.size = size self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def center(self): """Translation offset from origin of local coordinate system.""" return self.__center @center.setter def center(self, center): if center is None: center = (0, 0, 0) # default assertValidSFVec3f(center) self.__center = center @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def size(self): """[0,+infinity) size of visibility box, measured from center in meters.""" return self.__size @size.setter def size(self, size): if size is None: size = (0, 0, 0) # default assertValidSFVec3f(size) assertNonNegative('size', size) self.__size = size @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VisibilitySensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VisibilitySensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"VisibilitySensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.center != (0, 0, 0): attributeResult += " " + '"@center":"' + SFVec3f(self.center).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.size != (0, 0, 0): attributeResult += " " + '"@size":"' + SFVec3f(self.size).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function VisibilitySensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'VisibilitySensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'VisibilitySensor' + ' {' if self.center != (0, 0, 0): result += '\n' + indent + ' ' + "center " + SFVec3f(self.center).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.size != (0, 0, 0): result += '\n' + indent + ' ' + "size " + SFVec3f(self.size).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class VolumeData(_X3DVolumeDataNode): """ VolumeData displays a simple non-segmented voxel dataset with a single RenderStyle node. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'VolumeData' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/volume.html#VolumeData' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#VolumeData' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('bboxCenter', (0, 0, 0), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DVolumeDataNode'), ('bboxDisplay', False, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeDataNode'), ('bboxSize', (-1, -1, -1), FieldType.SFVec3f, AccessType.initializeOnly, 'X3DVolumeDataNode'), ('dimensions', (1, 1, 1), FieldType.SFVec3f, AccessType.inputOutput, 'X3DVolumeDataNode'), ('visible', True, FieldType.SFBool, AccessType.inputOutput, 'X3DVolumeDataNode'), ('renderStyle', None, FieldType.SFNode, AccessType.inputOutput, 'VolumeData'), ('voxels', None, FieldType.SFNode, AccessType.inputOutput, 'VolumeData'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, bboxCenter=(0, 0, 0), bboxDisplay=False, bboxSize=(-1, -1, -1), dimensions=(1, 1, 1), visible=True, renderStyle=None, voxels=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode VolumeData __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.bboxCenter = bboxCenter self.bboxDisplay = bboxDisplay self.bboxSize = bboxSize self.dimensions = dimensions self.visible = visible self.renderStyle = renderStyle self.voxels = voxels self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def bboxCenter(self): """Bounding box center accompanies bboxSize and provides an optional hint for bounding box position offset from origin of local coordinate system.""" return self.__bboxCenter @bboxCenter.setter def bboxCenter(self, bboxCenter): if bboxCenter is None: bboxCenter = (0, 0, 0) # default assertValidSFVec3f(bboxCenter) self.__bboxCenter = bboxCenter @property # getter - - - - - - - - - - def bboxDisplay(self): """Whether to display bounding box for associated geometry, aligned with world coordinates.""" return self.__bboxDisplay @bboxDisplay.setter def bboxDisplay(self, bboxDisplay): if bboxDisplay is None: bboxDisplay = False # default assertValidSFBool(bboxDisplay) self.__bboxDisplay = bboxDisplay @property # getter - - - - - - - - - - def bboxSize(self): """or [0,+infinity) Bounding box size is usually omitted, and can easily be calculated automatically by an X3D player at scene-loading time with minimal computational cost.""" return self.__bboxSize @bboxSize.setter def bboxSize(self, bboxSize): if bboxSize is None: bboxSize = (-1, -1, -1) # default assertValidSFVec3f(bboxSize) assertBoundingBox('bboxSize', bboxSize) self.__bboxSize = bboxSize @property # getter - - - - - - - - - - def dimensions(self): """Actual-size X-Y-Z dimensions of volume data in local coordinate system.""" return self.__dimensions @dimensions.setter def dimensions(self, dimensions): if dimensions is None: dimensions = (1, 1, 1) # default assertValidSFVec3f(dimensions) assertPositive('dimensions', dimensions) self.__dimensions = dimensions @property # getter - - - - - - - - - - def visible(self): """Whether or not renderable content within this node is visually displayed.""" return self.__visible @visible.setter def visible(self, visible): if visible is None: visible = True # default assertValidSFBool(visible) self.__visible = visible @property # getter - - - - - - - - - - def renderStyle(self): """[X3DVolumeRenderStyleNode] Single contained X3DVolumeRenderStyleNode node that defines specific rendering technique for this volumetric object.""" return self.__renderStyle @renderStyle.setter def renderStyle(self, renderStyle): if renderStyle is None: renderStyle = None # default assertValidSFNode(renderStyle) if not renderStyle is None and not isinstance(renderStyle,(_X3DVolumeRenderStyleNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(renderStyle) + ' does not match required node type (_X3DVolumeRenderStyleNode,ProtoInstance) and is invalid') self.__renderStyle = renderStyle @property # getter - - - - - - - - - - def voxels(self): """[X3DTexture3DNode] Single contained X3DTexture3DNode (ComposedTexture3D, ImageTexture3D, PixelTexture3D) that provides raw voxel information utilized by corresponding rendering styles.""" return self.__voxels @voxels.setter def voxels(self, voxels): if voxels is None: voxels = None # default assertValidSFNode(voxels) if not voxels is None and not isinstance(voxels,(_X3DTexture3DNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(voxels) + ' does not match required node type (_X3DTexture3DNode,ProtoInstance) and is invalid') self.__voxels = voxels @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.renderStyle or self.voxels # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VolumeData.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VolumeData.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"VolumeData":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.bboxCenter != (0, 0, 0): attributeResult += " " + '"@bboxCenter":"' + SFVec3f(self.bboxCenter).JSON() + '"' + ',\n' if self.bboxDisplay: # default=false attributeResult += " " + '"@bboxDisplay":"' + SFBool(self.bboxDisplay).JSON() + '"' + ',\n' if self.bboxSize != (-1, -1, -1): attributeResult += " " + '"@bboxSize":"' + SFVec3f(self.bboxSize).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.dimensions != (1, 1, 1): attributeResult += " " + '"@dimensions":"' + SFVec3f(self.dimensions).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if not self.visible: # default=true attributeResult += " " + '"@visible":"' + SFBool(self.visible).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.renderStyle: # output this SFNode result += self.renderStyle.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.voxels: # output this SFNode result += self.voxels.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function VolumeData.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'VolumeData' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'VolumeData' + ' {' if self.bboxCenter != (0, 0, 0): result += '\n' + indent + ' ' + "bboxCenter " + SFVec3f(self.bboxCenter).VRML() + "" if self.bboxDisplay: # default=false result += '\n' + indent + ' ' + "bboxDisplay " + SFBool(self.bboxDisplay).VRML() + "" if self.bboxSize != (-1, -1, -1): result += '\n' + indent + ' ' + "bboxSize " + SFVec3f(self.bboxSize).VRML() + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.dimensions != (1, 1, 1): result += '\n' + indent + ' ' + "dimensions " + SFVec3f(self.dimensions).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if not self.visible: # default=true result += '\n' + indent + ' ' + "visible " + SFBool(self.visible).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.renderStyle: # output this SFNode result += '\n' + ' ' + indent + 'renderStyle ' + self.renderStyle.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.voxels: # output this SFNode result += '\n' + ' ' + indent + 'voxels ' + self.voxels.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class VolumeEmitter(_X3DParticleEmitterNode): """ VolumeEmitter emits particles from a random position confined within the given closed geometry volume. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'VolumeEmitter' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/particleSystems.html#VolumeEmitter' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#VolumeEmitter' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('coordIndex', [-1], FieldType.MFInt32, AccessType.initializeOnly, 'VolumeEmitter'), ('direction', (0, 1, 0), FieldType.SFVec3f, AccessType.inputOutput, 'VolumeEmitter'), ('internal', True, FieldType.SFBool, AccessType.initializeOnly, 'VolumeEmitter'), ('mass', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('on', True, FieldType.SFBool, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('speed', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('surfaceArea', 0, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('variation', 0.25, FieldType.SFFloat, AccessType.inputOutput, 'X3DParticleEmitterNode'), ('coord', None, FieldType.SFNode, AccessType.inputOutput, 'VolumeEmitter'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, coordIndex=None, direction=(0, 1, 0), internal=True, mass=0, on=True, speed=0, surfaceArea=0, variation=0.25, coord=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode VolumeEmitter __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.coordIndex = coordIndex self.direction = direction self.internal = internal self.mass = mass self.on = on self.speed = speed self.surfaceArea = surfaceArea self.variation = variation self.coord = coord self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def coordIndex(self): """[-1,+infinity) coordIndex indices are applied to contained Coordinate values in order to define randomly generated initial geometry of the particles.""" return self.__coordIndex @coordIndex.setter def coordIndex(self, coordIndex): if coordIndex is None: coordIndex = [-1] # default assertValidMFInt32(coordIndex) assertGreaterThanEquals('coordIndex', coordIndex, -1) self.__coordIndex = coordIndex @property # getter - - - - - - - - - - def direction(self): """Initial direction from which particles emanate.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (0, 1, 0) # default assertValidSFVec3f(direction) assertGreaterThanEquals('direction', direction, -1) assertLessThanEquals('direction', direction, 1) self.__direction = direction @property # getter - - - - - - - - - - def internal(self): """TODO, X3D specification is undefined.""" return self.__internal @internal.setter def internal(self, internal): if internal is None: internal = True # default assertValidSFBool(internal) self.__internal = internal @property # getter - - - - - - - - - - def mass(self): """[0,+infinity) Basic mass of each particle, defined in mass base units (default is kilograms).""" return self.__mass @mass.setter def mass(self, mass): if mass is None: mass = 0 # default assertValidSFFloat(mass) assertNonNegative('mass', mass) self.__mass = mass @property # getter - - - - - - - - - - def on(self): """Enables/disables production of particles from this emitter node.""" return self.__on @on.setter def on(self, on): if on is None: on = True # default assertValidSFBool(on) self.__on = on @property # getter - - - - - - - - - - def speed(self): """[0,+infinity) Initial linear speed (default is m/s) imparted to all particles along their direction of movement.""" return self.__speed @speed.setter def speed(self, speed): if speed is None: speed = 0 # default assertValidSFFloat(speed) assertNonNegative('speed', speed) self.__speed = speed @property # getter - - - - - - - - - - def surfaceArea(self): """[0,+infinity) Particle surface area in area base units (default is meters squared).""" return self.__surfaceArea @surfaceArea.setter def surfaceArea(self, surfaceArea): if surfaceArea is None: surfaceArea = 0 # default assertValidSFFloat(surfaceArea) assertNonNegative('surfaceArea', surfaceArea) self.__surfaceArea = surfaceArea @property # getter - - - - - - - - - - def variation(self): """[0,+infinity) Multiplier for the randomness used to control the range of possible output values.""" return self.__variation @variation.setter def variation(self, variation): if variation is None: variation = 0.25 # default assertValidSFFloat(variation) assertNonNegative('variation', variation) self.__variation = variation @property # getter - - - - - - - - - - def coord(self): """[X3DCoordinateNode] Coordinates for the geometry used as the emitting volume.""" return self.__coord @coord.setter def coord(self, coord): if coord is None: coord = None # default assertValidSFNode(coord) if not coord is None and not isinstance(coord,(_X3DCoordinateNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(coord) + ' does not match required node type (_X3DCoordinateNode,ProtoInstance) and is invalid') self.__coord = coord @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.coord or self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VolumeEmitter.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VolumeEmitter.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"VolumeEmitter":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.coordIndex != [-1]: attributeResult += " " + '"@coordIndex":"' + MFInt32(self.coordIndex).JSON() + '"' + ',\n' if self.direction != (0, 1, 0): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if not self.internal: # default=true attributeResult += " " + '"@internal":"' + SFBool(self.internal).JSON() + '"' + ',\n' if self.mass != 0: attributeResult += " " + '"@mass":"' + SFFloat(self.mass).JSON() + '"' + ',\n' if not self.on: # default=true attributeResult += " " + '"@on":"' + SFBool(self.on).JSON() + '"' + ',\n' if self.speed != 0: attributeResult += " " + '"@speed":"' + SFFloat(self.speed).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.surfaceArea != 0: attributeResult += " " + '"@surfaceArea":"' + SFFloat(self.surfaceArea).JSON() + '"' + ',\n' if self.variation != 0.25: attributeResult += " " + '"@variation":"' + SFFloat(self.variation).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.coord: # output this SFNode result += self.coord.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function VolumeEmitter.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'VolumeEmitter' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'VolumeEmitter' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.coordIndex != [-1]: result += '\n' + indent + ' ' + "coordIndex " + MFInt32(self.coordIndex).VRML() + "" if self.direction != (0, 1, 0): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if not self.internal: # default=true result += '\n' + indent + ' ' + "internal " + SFBool(self.internal).VRML() + "" if self.mass != 0: result += '\n' + indent + ' ' + "mass " + SFFloat(self.mass).VRML() + "" if not self.on: # default=true result += '\n' + indent + ' ' + "on " + SFBool(self.on).VRML() + "" if self.speed != 0: result += '\n' + indent + ' ' + "speed " + SFFloat(self.speed).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.surfaceArea != 0: result += '\n' + indent + ' ' + "surfaceArea " + SFFloat(self.surfaceArea).VRML() + "" if self.variation != 0.25: result += '\n' + indent + ' ' + "variation " + SFFloat(self.variation).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.coord: # output this SFNode result += '\n' + ' ' + indent + 'coord ' + self.coord.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class VolumePickSensor(_X3DPickSensorNode): """ VolumePickSensor tests picking intersections using the pickingGeometry against the pickTarget geometry volume. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'VolumePickSensor' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/picking.html#VolumePickSensor' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#VolumePickSensor' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DSensorNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSensorNode'), ('intersectionType', 'BOUNDS', FieldType.SFString, AccessType.initializeOnly, 'X3DPickSensorNode'), ('matchCriterion', 'MATCH_ANY', FieldType.SFString, AccessType.inputOutput, 'X3DPickSensorNode'), ('objectType', ["ALL"], FieldType.MFString, AccessType.inputOutput, 'X3DPickSensorNode'), ('sortOrder', 'CLOSEST', FieldType.SFString, AccessType.initializeOnly, 'X3DPickSensorNode'), ('pickingGeometry', None, FieldType.SFNode, AccessType.inputOutput, 'X3DPickSensorNode'), ('pickTarget', [], FieldType.MFNode, AccessType.inputOutput, 'X3DPickSensorNode'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, description='', enabled=True, intersectionType='BOUNDS', matchCriterion='MATCH_ANY', objectType=None, sortOrder='CLOSEST', pickingGeometry=None, pickTarget=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode VolumePickSensor __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.description = description self.enabled = enabled self.intersectionType = intersectionType self.matchCriterion = matchCriterion self.objectType = objectType self.sortOrder = sortOrder self.pickingGeometry = pickingGeometry self.pickTarget = pickTarget self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the node.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def intersectionType(self): """intersectionType specifies precision of the collision computation.""" return self.__intersectionType @intersectionType.setter def intersectionType(self, intersectionType): if intersectionType is None: intersectionType = 'BOUNDS' # default assertValidSFString(intersectionType) self.__intersectionType = intersectionType @property # getter - - - - - - - - - - def matchCriterion(self): """defines whether the intersection test (i.""" return self.__matchCriterion @matchCriterion.setter def matchCriterion(self, matchCriterion): if matchCriterion is None: matchCriterion = 'MATCH_ANY' # default assertValidSFString(matchCriterion) assertValidPickSensorMatchCriterion('matchCriterion', matchCriterion) self.__matchCriterion = matchCriterion @property # getter - - - - - - - - - - def objectType(self): """The objectType field specifies a set of labels used in the picking process.""" return self.__objectType @objectType.setter def objectType(self, objectType): if objectType is None: objectType = ["ALL"] # default assertValidMFString(objectType) self.__objectType = objectType @property # getter - - - - - - - - - - def sortOrder(self): """The sortOrder field determines the order provided for picked output events.""" return self.__sortOrder @sortOrder.setter def sortOrder(self, sortOrder): if sortOrder is None: sortOrder = 'CLOSEST' # default assertValidSFString(sortOrder) self.__sortOrder = sortOrder @property # getter - - - - - - - - - - def pickingGeometry(self): """[X3DGeometryNode] pickingGeometry specifies the exact geometry coordinates that are used to perform the intersection testing of the picking operation.""" return self.__pickingGeometry @pickingGeometry.setter def pickingGeometry(self, pickingGeometry): if pickingGeometry is None: pickingGeometry = None # default assertValidSFNode(pickingGeometry) if not pickingGeometry is None and not isinstance(pickingGeometry,(_X3DGeometryNode,ProtoInstance)): # print(flush=True) raise X3DTypeError(str(pickingGeometry) + ' does not match required node type (_X3DGeometryNode,ProtoInstance) and is invalid') self.__pickingGeometry = pickingGeometry @property # getter - - - - - - - - - - def pickTarget(self): """[X3DGroupingNode|X3DShapeNode|Inline] pickTarget specifies the list of nodes against which picking operations are performed.""" return self.__pickTarget @pickTarget.setter def pickTarget(self, pickTarget): if pickTarget is None: pickTarget = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(pickTarget) self.__pickTarget = pickTarget @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or self.pickingGeometry or (len(self.pickTarget) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VolumePickSensor.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function VolumePickSensor.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"VolumePickSensor":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.intersectionType != 'BOUNDS': attributeResult += " " + '"@intersectionType":"' + SFString(self.intersectionType).JSON() + '"' + ',\n' if self.matchCriterion != 'MATCH_ANY': attributeResult += " " + '"@matchCriterion":"' + SFString(self.matchCriterion).JSON() + '"' + ',\n' if self.objectType != ["ALL"]: attributeResult += " " + '"@objectType":"' + MFString(self.objectType).JSON() + '"' + ',\n' if self.sortOrder != 'CLOSEST': attributeResult += " " + '"@sortOrder":"' + SFString(self.sortOrder).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.pickingGeometry: # output this SFNode result += self.pickingGeometry.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.pickTarget: # walk each child in list, if any (avoid empty list recursion) ### print('* VolumePickSensor found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(pickTarget)=' + str(len(self.pickTarget)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.pickTarget: # walk each child in list, if any (avoid empty list recursion) for each in self.pickTarget: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function VolumePickSensor.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'VolumePickSensor' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'VolumePickSensor' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.intersectionType != 'BOUNDS': result += '\n' + indent + ' ' + "intersectionType " + '"' + self.intersectionType + '"' + "" if self.matchCriterion != 'MATCH_ANY': result += '\n' + indent + ' ' + "matchCriterion " + '"' + self.matchCriterion + '"' + "" if self.objectType != ["ALL"]: result += '\n' + indent + ' ' + "objectType " + MFString(self.objectType).VRML() + "" if self.sortOrder != 'CLOSEST': result += '\n' + indent + ' ' + "sortOrder " + '"' + self.sortOrder + '"' + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.pickingGeometry: # output this SFNode result += '\n' + ' ' + indent + 'pickingGeometry ' + self.pickingGeometry.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.pickTarget: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.pickTarget: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class WaveShaper(_X3DSoundProcessingNode): """ WaveShaper node represents a nonlinear distorter that applies a wave-shaping distortion curve to the signal. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'WaveShaper' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/sound.html#WaveShaper' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#WaveShaper' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('channelCountMode', 'MAX', FieldType.SFString, AccessType.inputOutput, 'X3DSoundProcessingNode'), ('channelInterpretation', 'SPEAKERS', FieldType.SFString, AccessType.inputOutput, 'X3DSoundProcessingNode'), ('description', '', FieldType.SFString, AccessType.inputOutput, 'X3DTimeDependentNode'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DSoundProcessingNode'), ('gain', 1, FieldType.SFFloat, AccessType.inputOutput, 'X3DSoundProcessingNode'), ('oversample', 'NONE', FieldType.SFString, AccessType.inputOutput, 'WaveShaper'), ('pauseTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('resumeTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('startTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('stopTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DTimeDependentNode'), ('tailTime', 0, FieldType.SFTime, AccessType.inputOutput, 'X3DSoundProcessingNode'), ('children', [], FieldType.MFNode, AccessType.inputOutput, 'WaveShaper'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, channelCountMode='MAX', channelInterpretation='SPEAKERS', description='', enabled=True, gain=1, oversample='NONE', pauseTime=0, resumeTime=0, startTime=0, stopTime=0, tailTime=0, children=None, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode WaveShaper __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.channelCountMode = channelCountMode self.channelInterpretation = channelInterpretation self.description = description self.enabled = enabled self.gain = gain self.oversample = oversample self.pauseTime = pauseTime self.resumeTime = resumeTime self.startTime = startTime self.stopTime = stopTime self.tailTime = tailTime self.children = children self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def channelCountMode(self): """channelCountMode determines how individual channels are counted when up-mixing and down-mixing connections to any inputs.""" return self.__channelCountMode @channelCountMode.setter def channelCountMode(self, channelCountMode): if channelCountMode is None: channelCountMode = 'MAX' # default assertValidSFString(channelCountMode) assertValidChannelCountMode('channelCountMode', channelCountMode) self.__channelCountMode = channelCountMode @property # getter - - - - - - - - - - def channelInterpretation(self): """channelInterpretation determines how individual channels are treated when up-mixing and down-mixing connections to any inputs.""" return self.__channelInterpretation @channelInterpretation.setter def channelInterpretation(self, channelInterpretation): if channelInterpretation is None: channelInterpretation = 'SPEAKERS' # default assertValidSFString(channelInterpretation) assertValidChannelInterpretation('channelInterpretation', channelInterpretation) self.__channelInterpretation = channelInterpretation @property # getter - - - - - - - - - - def description(self): """Author-provided prose that describes intended purpose of the url asset.""" return self.__description @description.setter def description(self, description): if description is None: description = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(description) self.__description = description @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def gain(self): """(-infinity,+infinity) The gain field is a factor that represents the amount of linear amplification to apply to the output of the node.""" return self.__gain @gain.setter def gain(self, gain): if gain is None: gain = 1 # default assertValidSFFloat(gain) self.__gain = gain @property # getter - - - - - - - - - - def oversample(self): """The oversample field is specifies what type of oversampling (if any) should be used when applying the shaping curve.""" return self.__oversample @oversample.setter def oversample(self, oversample): if oversample is None: oversample = 'NONE' # default assertValidSFString(oversample) assertValidWaveShaperOversample('oversample', oversample) self.__oversample = oversample @property # getter - - - - - - - - - - def pauseTime(self): """When time now >= pauseTime, isPaused becomes true and AudioClip becomes paused.""" return self.__pauseTime @pauseTime.setter def pauseTime(self, pauseTime): if pauseTime is None: pauseTime = 0 # default assertValidSFTime(pauseTime) self.__pauseTime = pauseTime @property # getter - - - - - - - - - - def resumeTime(self): """When resumeTime becomes <= time now, isPaused becomes false and AudioClip becomes active.""" return self.__resumeTime @resumeTime.setter def resumeTime(self, resumeTime): if resumeTime is None: resumeTime = 0 # default assertValidSFTime(resumeTime) self.__resumeTime = resumeTime @property # getter - - - - - - - - - - def startTime(self): """Absolute time: number of seconds since January 1, 1970, 00:00:00 GMT.""" return self.__startTime @startTime.setter def startTime(self, startTime): if startTime is None: startTime = 0 # default assertValidSFTime(startTime) self.__startTime = startTime @property # getter - - - - - - - - - - def stopTime(self): """Absolute time: number of seconds since January 1, 1970, 00:00:00 GMT.""" return self.__stopTime @stopTime.setter def stopTime(self, stopTime): if stopTime is None: stopTime = 0 # default assertValidSFTime(stopTime) self.__stopTime = stopTime @property # getter - - - - - - - - - - def tailTime(self): """[0,+infinity) tailTime is duration of time that a node continues to provide output signal after the input signal becomes silent.""" return self.__tailTime @tailTime.setter def tailTime(self, tailTime): if tailTime is None: tailTime = 0 # default assertValidSFTime(tailTime) assertNonNegative('tailTime', tailTime) self.__tailTime = tailTime @property # getter - - - - - - - - - - def children(self): """[X3DSoundChannelNode|X3DSoundProcessingNode|X3DSoundSourceNode] The children field specifies audio-graph sound sources providing input signals for this node.""" return self.__children @children.setter def children(self, children): if children is None: children = MFNode.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFNode.DEFAULT_VALUE()=' + str(MFNode.DEFAULT_VALUE())) assertValidMFNode(children) self.__children = children @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata or (len(self.children) > 0) # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function WaveShaper.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function WaveShaper.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"WaveShaper":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.channelCountMode != 'MAX': attributeResult += " " + '"@channelCountMode":"' + SFString(self.channelCountMode).JSON() + '"' + ',\n' if self.channelInterpretation != 'SPEAKERS': attributeResult += " " + '"@channelInterpretation":"' + SFString(self.channelInterpretation).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.description: attributeResult += " " + '"@description":"' + SFString(self.description).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.gain != 1: attributeResult += " " + '"@gain":"' + SFFloat(self.gain).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.oversample != 'NONE': attributeResult += " " + '"@oversample":"' + SFString(self.oversample).JSON() + '"' + ',\n' if self.pauseTime != 0: attributeResult += " " + '"@pauseTime":"' + SFTime(self.pauseTime).JSON() + '"' + ',\n' if self.resumeTime != 0: attributeResult += " " + '"@resumeTime":"' + SFTime(self.resumeTime).JSON() + '"' + ',\n' if self.startTime != 0: attributeResult += " " + '"@startTime":"' + SFTime(self.startTime).JSON() + '"' + ',\n' if self.stopTime != 0: attributeResult += " " + '"@stopTime":"' + SFTime(self.stopTime).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.tailTime != 0: attributeResult += " " + '"@tailTime":"' + SFTime(self.tailTime).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) ### if self.children: # walk each child in list, if any (avoid empty list recursion) ### print('* WaveShaper found self.children with self.hasChild()=' + str(self.hasChild()) + ' and len(children)=' + str(len(self.children)) + ', now invoking JSON(' + str(indentLevel+1) + ')', flush=True) if self.children: # walk each child in list, if any (avoid empty list recursion) for each in self.children: result += each.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function WaveShaper.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'WaveShaper' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'WaveShaper' + ' {' if self.channelCountMode != 'MAX': result += '\n' + indent + ' ' + "channelCountMode " + '"' + self.channelCountMode + '"' + "" if self.channelInterpretation != 'SPEAKERS': result += '\n' + indent + ' ' + "channelInterpretation " + '"' + self.channelInterpretation + '"' + "" if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.description: result += '\n' + indent + ' ' + "description " + '"' + self.description + '"' + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.gain != 1: result += '\n' + indent + ' ' + "gain " + SFFloat(self.gain).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.oversample != 'NONE': result += '\n' + indent + ' ' + "oversample " + '"' + self.oversample + '"' + "" if self.pauseTime != 0: result += '\n' + indent + ' ' + "pauseTime " + SFTime(self.pauseTime).VRML() + "" if self.resumeTime != 0: result += '\n' + indent + ' ' + "resumeTime " + SFTime(self.resumeTime).VRML() + "" if self.startTime != 0: result += '\n' + indent + ' ' + "startTime " + SFTime(self.startTime).VRML() + "" if self.stopTime != 0: result += '\n' + indent + ' ' + "stopTime " + SFTime(self.stopTime).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.tailTime != 0: result += '\n' + indent + ' ' + "tailTime " + SFTime(self.tailTime).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.children: # walk each child in list, if any (avoid empty list recursion) result += '\n' + indent + ' ' + 'children [' + '\n' + indent + ' ' + ' ' for each in self.children: result += each.VRML(indentLevel=indentLevel+2, VRML97=VRML97) result += '\n' + indent + ' ' + ']' + '\n' + indent else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class WindPhysicsModel(_X3DParticlePhysicsModelNode): """ WindPhysicsModel applies a wind effect to the particles. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'WindPhysicsModel' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/particleSystems.html#WindPhysicsModel' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#WindPhysicsModel' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('direction', (1, 0, 0), FieldType.SFVec3f, AccessType.inputOutput, 'WindPhysicsModel'), ('enabled', True, FieldType.SFBool, AccessType.inputOutput, 'X3DParticlePhysicsModelNode'), ('gustiness', 0.1, FieldType.SFFloat, AccessType.inputOutput, 'WindPhysicsModel'), ('speed', 0.1, FieldType.SFFloat, AccessType.inputOutput, 'WindPhysicsModel'), ('turbulence', 0, FieldType.SFFloat, AccessType.inputOutput, 'WindPhysicsModel'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, direction=(1, 0, 0), enabled=True, gustiness=0.1, speed=0.1, turbulence=0, DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode WindPhysicsModel __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.direction = direction self.enabled = enabled self.gustiness = gustiness self.speed = speed self.turbulence = turbulence self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def direction(self): """direction in which wind is travelling in the form of a normalized, unit vector.""" return self.__direction @direction.setter def direction(self, direction): if direction is None: direction = (1, 0, 0) # default assertValidSFVec3f(direction) self.__direction = direction @property # getter - - - - - - - - - - def enabled(self): """Enables/disables node operation.""" return self.__enabled @enabled.setter def enabled(self, enabled): if enabled is None: enabled = True # default assertValidSFBool(enabled) self.__enabled = enabled @property # getter - - - - - - - - - - def gustiness(self): """[0,+infinity) gustiness specifies how much wind speed varies from the average speed.""" return self.__gustiness @gustiness.setter def gustiness(self, gustiness): if gustiness is None: gustiness = 0.1 # default assertValidSFFloat(gustiness) assertNonNegative('gustiness', gustiness) self.__gustiness = gustiness @property # getter - - - - - - - - - - def speed(self): """[0,+infinity) Initial linear speed (default is m/s) imparted to all particles along their direction of movement.""" return self.__speed @speed.setter def speed(self, speed): if speed is None: speed = 0.1 # default assertValidSFFloat(speed) assertNonNegative('speed', speed) self.__speed = speed @property # getter - - - - - - - - - - def turbulence(self): """[0,1] turbulence field specifies how much the wind acts directly in line with the direction, and how much variation is applied in directions other than the wind direction.""" return self.__turbulence @turbulence.setter def turbulence(self, turbulence): if turbulence is None: turbulence = 0 # default assertValidSFFloat(turbulence) assertZeroToOne('turbulence', turbulence) self.__turbulence = turbulence @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function WindPhysicsModel.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function WindPhysicsModel.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"WindPhysicsModel":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.direction != (1, 0, 0): attributeResult += " " + '"@direction":"' + SFVec3f(self.direction).JSON() + '"' + ',\n' if not self.enabled: # default=true attributeResult += " " + '"@enabled":"' + SFBool(self.enabled).JSON() + '"' + ',\n' if self.gustiness != 0.1: attributeResult += " " + '"@gustiness":"' + SFFloat(self.gustiness).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.speed != 0.1: attributeResult += " " + '"@speed":"' + SFFloat(self.speed).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.turbulence != 0: attributeResult += " " + '"@turbulence":"' + SFFloat(self.turbulence).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' },' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function WindPhysicsModel.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'WindPhysicsModel' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'WindPhysicsModel' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.direction != (1, 0, 0): result += '\n' + indent + ' ' + "direction " + SFVec3f(self.direction).VRML() + "" if not self.enabled: # default=true result += '\n' + indent + ' ' + "enabled " + SFBool(self.enabled).VRML() + "" if self.gustiness != 0.1: result += '\n' + indent + ' ' + "gustiness " + SFFloat(self.gustiness).VRML() + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.speed != 0.1: result += '\n' + indent + ' ' + "speed " + SFFloat(self.speed).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.turbulence != 0: result += '\n' + indent + ' ' + "turbulence " + SFFloat(self.turbulence).VRML() + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result class WorldInfo(_X3DInfoNode): """ WorldInfo contains a title and simple persistent metadata information about an X3D scene. This node is strictly for documentation purposes and has no effect on the visual appearance or behaviour of the world. """ # immutable constant functions have getter but no setter - - - - - - - - - - @classmethod def NAME(cls): """ Name of this X3D Node class. """ return 'WorldInfo' @classmethod def SPECIFICATION_URL(cls): """ Extensible 3D (X3D) Graphics International Standard governs X3D architecture for all file formats and programming languages. """ return 'https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-DIS/Part01/components/core.html#WorldInfo' @classmethod def TOOLTIP_URL(cls): """ X3D Tooltips provide authoring tips, hints and warnings for each node and field in X3D. """ return 'https://www.web3d.org/x3d/tooltips/X3dTooltips.html#WorldInfo' @classmethod def FIELD_DECLARATIONS(cls): """ Field declarations for this node: name, defaultValue, type, accessType, inheritedFrom """ return [ ('info', [], FieldType.MFString, AccessType.inputOutput, 'WorldInfo'), ('title', '', FieldType.SFString, AccessType.inputOutput, 'WorldInfo'), ('DEF', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('USE', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('IS', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('metadata', None, FieldType.SFNode, AccessType.inputOutput, 'X3DNode'), ('class_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('id_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode'), ('style_', '', FieldType.SFString, AccessType.inputOutput, 'X3DNode')] def __init__(self, info=None, title='', DEF='', USE='', IS=None, metadata=None, class_='', id_='', style_=''): # if _DEBUG: print('...DEBUG... in ConcreteNode WorldInfo __init__ calling super.__init__(' + str(DEF) + ',' + str(USE) + ',' + str(class_) + ',' + str(id_) + ',' + str(style_) + ',' + str(metadata) + ',' + str(IS) + ')', flush=True) super().__init__(DEF, USE, class_, id_, style_, IS, metadata) # fields for _X3DNode only self.info = info self.title = title self.id_ = id_ self.style_ = style_ @property # getter - - - - - - - - - - def info(self): """Additional information about this model.""" return self.__info @info.setter def info(self, info): if info is None: info = MFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to MFString.DEFAULT_VALUE()=' + str(MFString.DEFAULT_VALUE())) assertValidMFString(info) self.__info = info @property # getter - - - - - - - - - - def title(self): """title of this world, placed in window title.""" return self.__title @title.setter def title(self, title): if title is None: title = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(title) self.__title = title @property # getter - - - - - - - - - - def id_(self): """ id_ attribute is a unique identifier for use within HTML pages. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__id_ @id_.setter def id_(self, id_): if id_ is None: id_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(id_) self.__id_ = id_ @property # getter - - - - - - - - - - def style_(self): """ Space-separated list of classes, reserved for use by CSS cascading style_sheets. Appended underscore to field name to avoid naming collision with Python reserved word. """ return self.__style_ @style_.setter def style_(self, style_): if style_ is None: style_ = SFString.DEFAULT_VALUE() # if _DEBUG: print('...DEBUG... set value to SFString.DEFAULT_VALUE()=' + str(SFString.DEFAULT_VALUE())) assertValidSFString(style_) self.__style_ = style_ # hasChild() function - - - - - - - - - - def hasChild(self): """ Whether or not this node has any child node or statement """ return self.IS or self.metadata # output function - - - - - - - - - - def XML(self, indentLevel=0, syntax="XML", field="children"): """ Provide Canonical X3D output serialization using XML encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function WorldInfo.XML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '' + '\n' # print('XML serialization complete.', flush=True) return result # output function - - - - - - - - - - def JSON(self, indentLevel=0, syntax="JSON"): """ Provide X3D output serialization using JSON encoding. """ result = '' indent = ' ' * indentLevel result = indent ### confirm # if _DEBUG: result += indent + '# invoked class function WorldInfo.JSON(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) result += '"WorldInfo":\n' result += indent + '{\n' attributeResult = '' if self.DEF: attributeResult += " " + '"@DEF":"' + SFString(self.DEF).JSON() + '"' + ',\n' if self.USE: attributeResult += " " + '"@USE":"' + SFString(self.USE).JSON() + '"' + ',\n' if self.class_: attributeResult += " " + '"@class":"' + SFString(self.class_).JSON() + '"' + ',\n' if self.id_: attributeResult += " " + '"@id":"' + SFString(self.id_).JSON() + '"' + ',\n' if self.info != []: attributeResult += " " + '"@info":"' + MFString(self.info).JSON() + '"' + ',\n' if self.style_: attributeResult += " " + '"@style":"' + SFString(self.style_).JSON() + '"' + ',\n' if self.title: attributeResult += " " + '"@title":"' + SFString(self.title).JSON() + '"' # print("attributeResult=" + attributeResult) # debug attributeResult = attributeResult.rstrip() if attributeResult.endswith(","): attributeResult = attributeResult[:-1] # remove trailing comma from last element of list if attributeResult: result += " {\n" + attributeResult + '\n' + " " + '}\n' if not self.hasChild(): if syntax.upper() == "JSON": result += ' }' + '\n' else: raise X3DValueError('.toJSON(syntax=' + syntax + ') is incorrect, allowed value is "JSON"') else: if self.IS: # output this SFNode result += self.IS.JSON(indentLevel=indentLevel+1, syntax=syntax) if self.metadata: # output this SFNode result += self.metadata.JSON(indentLevel=indentLevel+1, syntax=syntax) result += indent + '}' ### here? + '\n' # print('JSON serialization complete.', flush=True) return result # output function - - - - - - - - - - def HTML5(self, indentLevel=0): """ Provide HTML5 output serialization using XML encoding with no singleton self-closing elements. """ return self.XML(indentLevel=indentLevel+1, syntax="HTML5") # output function - - - - - - - - - - def VRML(self, indentLevel=0, VRML97=False): """ Provide X3D output serialization using VRML encoding. """ result = '' indent = ' ' * indentLevel # if _DEBUG: result += indent + '# invoked class function WorldInfo.VRML(self=' + str(self) + ', indentLevel=' + str(indentLevel) + '), indent="' + indent + '"' # print(result) if indentLevel == 0: result += '\n' if self.DEF: result += 'DEF ' + self.DEF + ' ' + 'WorldInfo' + ' {' elif self.USE: result += 'USE ' + self.USE # no node name, nothing follows else: result += 'WorldInfo' + ' {' if self.class_: result += '\n' + indent + ' ' + "class " + '"' + self.class_ + '"' + "" if self.id_: result += '\n' + indent + ' ' + "id " + '"' + self.id_ + '"' + "" if self.info != []: result += '\n' + indent + ' ' + "info " + MFString(self.info).VRML() + "" if self.style_: result += '\n' + indent + ' ' + "style " + '"' + self.style_ + '"' + "" if self.title: result += '\n' + indent + ' ' + "title " + '"' + self.title + '"' + "" if self.IS: # output this SFNode result += '\n' + ' ' + indent + 'IS ' + self.IS.VRML(indentLevel=indentLevel+1, VRML97=VRML97) if self.metadata: # output this SFNode result += '\n' + ' ' + indent + 'metadata ' + self.metadata.VRML(indentLevel=indentLevel+1, VRML97=VRML97) else: result += ' ' if not self.USE: result += '\n' + indent + '}' + '\n' + indent # print('VRML serialization complete.', flush=True) return result ############################################### # Exceptions class X3DError(Exception): """ Base class for all exceptions raised by this module. Reference: X3D Scene Access Interface (SAI), 5.3 Error types https://www.web3d.org/documents/specifications/19775-2/V3.3/Part02/dataRef.html """ class X3DTypeError(X3DError): """ Type error for simple fields (SFBool, SFInt32, SFVec3f etc.) or contained nodes (SFNode, MFNode) according to content model.""" class X3DValueError(X3DError): """ Value error for a given X3D type.""" ############################################### # Python x3d Package Loading Complete # TODO how to introspect the version number at run time from the object. Specifically, # get the magic dictionary __dict__ and then perform standard dictionary lookups on that version key. print("x3d.py package 4.0.64.4 loaded, have fun with X3D Graphics!", flush=True) ###############################################