def OldStarMesh(temp=Te_Sun, rad=1, scale=(1, 1, 1), pos=[0, 0, 0]): """ This function creates a pythreejs object that represents a star using a texture based on public domain STEREO Heliographic map made with images taken of the Sun on Dec. 30, 2011. Image downloaded from https://stereo.gsfc.nasa.gov/360blog/ and had its brightness and resolution rescaled. Parameters ---------- temp : float temperature of star in Kelvin (default 5777) rad : float radius of the star in system units (default 1) scale : tuple pythreejs scale in each dimension as tuple (default (1, 1, 1) ) pos : list three-dimensional position as list (default [0, 0, 0] ) Returns ------- star : pythreejs.Mesh a spherical pythreejs Mesh object representing a star """ # Check is position is a list if isinstance(pos, list): # Check if this is a list of 3 items if (len(pos) != 3): raise TypeError('pos passed to StarMesh must be list of 3 numbers') # Check that all the items in the list are numbers for this_pos in pos: try: i = float(this_pos) except ValueError: raise TypeError('ValueError: pos contains list item that is not a number.') else: raise TypeError('pos passed to StarMesh must be list of 3 numbers') # Check is scale is a tuple if isinstance(scale, tuple): if (len(scale) != 3): raise TypeError('scale passed to StarMesh must be tuple of 3 numbers') else: raise TypeError('scale must be a tuple') # Define color and texture of star surface hexcolor = tc.rgb2hex(tc.temp2rgb(float(temp)))[0] StarTexture = p3j.ImageTexture(imageUri='images/sun_surface.jpg') # Create sphere using MeshBasicMaterial (which is unaffected by lighting) StarSurface = p3j.MeshBasicMaterial(color=hexcolor, map=StarTexture) StarGeom = p3j.SphereBufferGeometry(radius=rad, widthSegments=32, heightSegments=16) return p3j.Mesh(geometry=StarGeom, material=StarSurface, position=pos, scale=scale)
def getTexture(self, filename): tex = None if filename is not None: tex = three.ImageTexture(filename) return tex