| @@ 36-76 (lines=41) @@ | ||
| 33 | * The position component defines where an entity is placed in the scene's world space. |
|
| 34 | * It takes a coordinate value as three space-delimited numbers. |
|
| 35 | */ |
|
| 36 | class Component extends ComponentAbstract implements PositionInterface |
|
| 37 | { |
|
| 38 | use ComponentHelper; |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Initialize Component |
|
| 42 | * |
|
| 43 | * {@inheritdoc} |
|
| 44 | * |
|
| 45 | * @return bool |
|
| 46 | * |
|
| 47 | */ |
|
| 48 | public function initializeComponent(): bool |
|
| 49 | { |
|
| 50 | $this->setDomAttributeName('position'); |
|
| 51 | return true; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * Return DOM attribute contents |
|
| 56 | * |
|
| 57 | * @return string |
|
| 58 | */ |
|
| 59 | public function getDomAttributeString(): string |
|
| 60 | { |
|
| 61 | $attrs = $this->getDOMAttributesArray(); |
|
| 62 | return $this->createCoordinateString($attrs['x'], $attrs['y'], $attrs['z']); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Get current position coordinates |
|
| 67 | * |
|
| 68 | * {@inheritdoc} |
|
| 69 | * |
|
| 70 | * @return string |
|
| 71 | */ |
|
| 72 | public function getPosition(): string |
|
| 73 | { |
|
| 74 | return $this->getDomAttributeString(); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| @@ 41-80 (lines=40) @@ | ||
| 38 | * and yaw (z) |
|
| 39 | * as three space-delimited numbers indicating degrees of rotation. |
|
| 40 | */ |
|
| 41 | class Component extends ComponentAbstract implements RotationInterface |
|
| 42 | { |
|
| 43 | use ComponentHelper; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Initialize Component |
|
| 47 | * |
|
| 48 | * {@inheritdoc} |
|
| 49 | * |
|
| 50 | * @return bool |
|
| 51 | */ |
|
| 52 | public function initializeComponent(): bool |
|
| 53 | { |
|
| 54 | $this->setDomAttributeName('rotation'); |
|
| 55 | return true; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Return DOM attribute contents |
|
| 60 | * |
|
| 61 | * @return string |
|
| 62 | */ |
|
| 63 | public function getDomAttributeString(): string |
|
| 64 | { |
|
| 65 | $attrs = $this->getDOMAttributesArray(); |
|
| 66 | return $this->createCoordinateString($attrs['x'], $attrs['y'], $attrs['z']); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Get Rotation |
|
| 71 | * |
|
| 72 | * {@inheritdoc} |
|
| 73 | * |
|
| 74 | * @return string |
|
| 75 | */ |
|
| 76 | public function getRotation(): string |
|
| 77 | { |
|
| 78 | return $this->getDomAttributeString(); |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||
| @@ 36-75 (lines=40) @@ | ||
| 33 | * The scale component defines a shrinking, stretching, or skewing transformation of an entity. |
|
| 34 | * It takes three scaling factors for the X, Y, and Z axes. |
|
| 35 | */ |
|
| 36 | class Component extends ComponentAbstract implements ScaleInterface |
|
| 37 | { |
|
| 38 | use ComponentHelper; |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Initialize Component |
|
| 42 | * |
|
| 43 | * {@inheritdoc} |
|
| 44 | * |
|
| 45 | * @return bool |
|
| 46 | */ |
|
| 47 | public function initializeComponent(): bool |
|
| 48 | { |
|
| 49 | $this->setDomAttributeName('scale'); |
|
| 50 | return true; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Return DOM attribute contents |
|
| 55 | * |
|
| 56 | * @return string |
|
| 57 | */ |
|
| 58 | public function getDomAttributeString(): string |
|
| 59 | { |
|
| 60 | $attrs = $this->getDOMAttributesArray(); |
|
| 61 | return $this->createCoordinateString($attrs['x'], $attrs['y'], $attrs['z']); |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * Get scale |
|
| 66 | * |
|
| 67 | * {@inheritdoc} |
|
| 68 | * |
|
| 69 | * @return string |
|
| 70 | */ |
|
| 71 | public function getScale(): string |
|
| 72 | { |
|
| 73 | return $this->getDomAttributeString(); |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||