Add mvconfig tag
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -47,9 +47,10 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
*/
|
||||
public function toHtml($options = []) {
|
||||
$descriptText = $this->file->getDescriptionText();
|
||||
preg_match('/<pre mvconfig.*?>([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
|
||||
$metadata = json_decode($modelDescript[1], true);
|
||||
|
||||
if ($this->thumb) {
|
||||
preg_match('/<pre>([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
|
||||
$metadata = json_decode($modelDescript[1], true);
|
||||
$poster = $metadata['viewerConfig'][$this->view]['poster'] ?? false;
|
||||
|
||||
if ($poster) {
|
||||
@@ -78,7 +79,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
$this->parameters['preview'] = $options['preview'];
|
||||
}
|
||||
|
||||
return self::buildViewer($descriptText,$this->url,$this->parameters);
|
||||
return self::buildViewer($metadata,$this->url,$this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,15 +89,13 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
* and produces the html string for the model-viewer and all relevant child
|
||||
* elements.
|
||||
*
|
||||
* @param string $inText The metadata text which must include a json formatted string inside a pre tag
|
||||
* @param string $metadata The metadata object parsed from the text
|
||||
* @param string $srcUrl The full url pointing to the model file
|
||||
* @param array $frameParams The additional user defined parameters for the viewer such as hotspot and view classes
|
||||
* @return string Html string of the complete model-viewer element inside a div container
|
||||
*/
|
||||
private function buildViewer($inText, $srcUrl, $viewParams) {
|
||||
private function buildViewer($metadata, $srcUrl, $viewParams) {
|
||||
//Gather basic data
|
||||
preg_match('/<pre>([\S\s]*?)<\/pre>/',$inText,$modelDescript);
|
||||
$metadata = json_decode($modelDescript[1], true);
|
||||
$hsSet = (isset($metadata['annotationSets']) && isset($metadata['annotationSets'][$this->hsset])) ? $this->hsset : 'default';
|
||||
$view = (isset($metadata['viewerConfig']) && isset($metadata['viewerConfig'][$this->view])) ? $this->view : 'default';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user