Initial commit
This commit is contained in:
commit
38be97bec3
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018 Neo-Inspiration
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace Render3D;
|
||||
|
||||
use Omeka\Module\AbstractModule;
|
||||
use Laminas\EventManager\SharedEventManagerInterface;
|
||||
use Laminas\Mvc\MvcEvent;
|
||||
|
||||
class Module extends AbstractModule
|
||||
{
|
||||
const NAMESPACE = __NAMESPACE__;
|
||||
|
||||
const MODEL_TYPES = [
|
||||
'gltf' => 'gLTF',
|
||||
'obj' => 'OBJ',
|
||||
'obj+mtl' => 'OBJ + MTL',
|
||||
'json' => 'JSON',
|
||||
];
|
||||
|
||||
public function getConfig()
|
||||
{
|
||||
return include __DIR__ . '/config/module.config.php';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
# A 3D Renderer for Omeka S
|
||||
|
||||
[3D Renderer] is a module for [Omeka S] that integrates [Vue-3d-model].
|
||||
Built using Vue, based on threejs.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
cd ./modules
|
||||
https://git.hangar.org/arcHIVE-tech/3Drenderer/archive/main.zip
|
||||
unzip main.zip
|
||||
mv renderviewer/ Render3D
|
||||
```
|
||||
### Omeka global settings
|
||||
|
||||
Add these to the `Allowed media types`
|
||||
|
||||
```
|
||||
application/json
|
||||
```
|
||||
|
||||
Add these to the `Allowed file extensions`
|
||||
|
||||
```
|
||||
gltf, bin, json
|
||||
```
|
||||
|
||||
## LISENCE
|
||||
The module is released under the [MIT] License.
|
||||
|
||||
The 3D render feature is imported from [Vue-3d-model].
|
||||
|
||||
|
||||
[arc-hive]: https://arc-hive.zone/
|
||||
[3D Renderer]: https://git.hangar.org/arcHIVE-tech/Render3D
|
||||
[Vue-3d-model]: https://github.com/hujiulong/vue-3d-model
|
||||
[Omeka S]: https://omeka.org/s
|
||||
[MIT]: http://opensource.org/licenses/MIT
|
|
@ -0,0 +1,7 @@
|
|||
/* Panaorama viewer custom */
|
||||
@media screen {
|
||||
.render-3d {
|
||||
/* width: 600px; */
|
||||
/* height: 400px; */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-present, Jiulong Hu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -0,0 +1,6 @@
|
|||
# vue-3d-model
|
||||
|
||||
|
||||
https://github.com/hujiulong/vue-3d-model
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace Render3D;
|
||||
|
||||
return [
|
||||
'view_manager' => [
|
||||
'template_path_stack' => [
|
||||
dirname(__DIR__) . '/view',
|
||||
]
|
||||
],
|
||||
'block_layouts' => [
|
||||
'factories' => [
|
||||
'render3D' => Service\BlockLayout\Render3DFactory::class,
|
||||
],
|
||||
],
|
||||
'form_elements' => [
|
||||
'invokables' => [
|
||||
Form\Render3DBlockForm::class => Form\Render3DBlockForm::class,
|
||||
],
|
||||
],
|
||||
'DefaultSettings' => [
|
||||
'Render3DBlockForm' => [
|
||||
'model_type' => 'gltf',
|
||||
'title' => '',
|
||||
'width' => 600,
|
||||
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
|
||||
//'imgStyle' => '',
|
||||
'ui_background' => 'rgba(0,0,0,0.1)',
|
||||
]
|
||||
]
|
||||
];
|
|
@ -0,0 +1,12 @@
|
|||
[info]
|
||||
name = "Render3D"
|
||||
description = "Renders 3D"
|
||||
tags = ""
|
||||
license = "MIT"
|
||||
author = "Hangar.org"
|
||||
author_link = "https://git.hangar.org/chris"
|
||||
module_link = "https://git.hangar.org/arcHIVE-tech/Render3D"
|
||||
support_link = "https://git.hangar.org/arcHIVE-tech/Render3D/issues"
|
||||
configurable = false
|
||||
version = "1.0.0"
|
||||
omeka_version_constraint = "^3.0.1"
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
namespace Render3D\Form;
|
||||
|
||||
use Render3D\Module;
|
||||
use Laminas\Form\Element;
|
||||
use Laminas\Form\Form;
|
||||
|
||||
class Render3DBlockForm extends Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->add([
|
||||
'name' => 'o:block[__blockIndex__][o:data][model_type]',
|
||||
'type' => Element\Select::class,
|
||||
'options' => [
|
||||
'label' => 'Model type',
|
||||
'info' => 'Please enter ...',
|
||||
'value_options' => Module::MODEL_TYPES,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->add([
|
||||
'name' => 'o:block[__blockIndex__][o:data][title]',
|
||||
'type' => Element\Text::class,
|
||||
'options' => [
|
||||
'label' => 'Title (option)',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->add([
|
||||
'name' => 'o:block[__blockIndex__][o:data][width]',
|
||||
'type' => Element\Number::class,
|
||||
'options' => [
|
||||
'label' => 'Width in pixels',
|
||||
],
|
||||
'attributes' => [
|
||||
'min' => '100',
|
||||
],
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
namespace Render3D\Service\BlockLayout;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Render3D\Site\BlockLayout\Render3D;
|
||||
use Laminas\ServiceManager\Factory\FactoryInterface;
|
||||
|
||||
class Render3DFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $services, $requestedName, array $options = null)
|
||||
{
|
||||
return new Render3D(
|
||||
$services->get('FormElementManager'),
|
||||
$services->get('Config')['DefaultSettings']['Render3DBlockForm']
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
namespace Render3D\Site\BlockLayout;
|
||||
|
||||
use Omeka\Api\Representation\SiteRepresentation;
|
||||
use Omeka\Api\Representation\SitePageRepresentation;
|
||||
use Omeka\Api\Representation\SitePageBlockRepresentation;
|
||||
use Omeka\Site\BlockLayout\AbstractBlockLayout;
|
||||
use Laminas\View\Renderer\PhpRenderer;
|
||||
|
||||
use Laminas\Form\FormElementManager;
|
||||
|
||||
use Render3D\Form\Render3DBlockForm;
|
||||
|
||||
class Render3D extends AbstractBlockLayout
|
||||
{
|
||||
/**
|
||||
* @var FormElementManager
|
||||
*/
|
||||
protected $formElementManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultSettings = [];
|
||||
|
||||
/**
|
||||
* @param FormElementManager $formElementManager
|
||||
* @param array $defaultSettings
|
||||
*/
|
||||
public function __construct(FormElementManager $formElementManager, array $defaultSettings)
|
||||
{
|
||||
$this->formElementManager = $formElementManager;
|
||||
$this->defaultSettings = $defaultSettings;
|
||||
}
|
||||
|
||||
public function getLabel() {
|
||||
return 'Render 3D';
|
||||
}
|
||||
|
||||
public function form(PhpRenderer $view,
|
||||
SiteRepresentation $site,
|
||||
SitePageRepresentation $page = null,
|
||||
SitePageBlockRepresentation $block = null
|
||||
) {
|
||||
$form = $this->formElementManager->get(Render3DBlockForm::class);
|
||||
$data = $block
|
||||
? $block->data() + $this->defaultSettings
|
||||
: $this->defaultSettings;
|
||||
$form->setData([
|
||||
'o:block[__blockIndex__][o:data][model_type]' => $data['model_type'],
|
||||
'o:block[__blockIndex__][o:data][title]' => $data['title'],
|
||||
'o:block[__blockIndex__][o:data][width]' => $data['width'],
|
||||
]);
|
||||
$form->prepare();
|
||||
|
||||
$html = '';
|
||||
$html .= $view->blockAttachmentsForm($block);
|
||||
$html .= '<a href="#" class="collapse" aria-label="collapse"><h4>' . $view->translate('Options'). '</h4></a>';
|
||||
$html .= '<div class="collapsible" style="padding-top:6px;">';
|
||||
$html .= $view->formCollection($form);
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function render(PhpRenderer $view, SitePageBlockRepresentation $block)
|
||||
{
|
||||
$attachments = $block->attachments();
|
||||
if (!$attachments) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$urls = [];
|
||||
$media_types = [];
|
||||
$thumbnails = [];
|
||||
$model_type = $block->dataValue('model_type');
|
||||
static $id = 0;
|
||||
|
||||
foreach ($attachments as $attachment)
|
||||
{
|
||||
foreach($attachment->item()->media() as $media)
|
||||
{
|
||||
$mediaType = $media->mediaType();
|
||||
$mediaRenderer = $media->renderer();
|
||||
|
||||
array_push($urls, $media->originalUrl());
|
||||
array_push($media_types, $mediaType);
|
||||
array_push($thumbnails, $media->thumbnailUrls());
|
||||
}
|
||||
}
|
||||
$width = $block->dataValue('width');
|
||||
$height = $width;
|
||||
return $view->partial('common/block-layout/render-3d', [
|
||||
'model_type' => $model_type,
|
||||
'title' => $block->dataValue('title'),
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'urls' => $urls,
|
||||
'id' => 'v3d-' . ++$id,
|
||||
'mediaTypes' => $media_types,
|
||||
'thumbnails' => $thumbnails,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<div class="3d-model-wrap" style="position:relative;">
|
||||
|
||||
<?php
|
||||
$this->headScript()->appendFile($this->assetUrl('vendor/vue-3d-model/vue.js',
|
||||
'Render3D'));
|
||||
$this->headScript()->appendFile($this->assetUrl('vendor/vue-3d-model/vue-3d-model.umd.js',
|
||||
'Render3D'));
|
||||
if ($title !== false && $title !== "") {
|
||||
$title = sprintf('<p id="render-3d-title">%s</p>', $title);
|
||||
} else {
|
||||
$title = false;
|
||||
}
|
||||
?>
|
||||
|
||||
<script>
|
||||
console.log(<?= json_encode($urls, JSON_UNESCAPED_SLASHES) ?>)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#<?= $id ?> {
|
||||
height: <?= $height ?>px;
|
||||
width: <?= $width ?>px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="3d-model-wrap">
|
||||
<?php if ($model_type == "gltf") { ?>
|
||||
<div id="<?= $id ?>">
|
||||
<model-gltf
|
||||
src="<?= $urls[0]; ?>"
|
||||
@on-mousemove="onMouseMove">
|
||||
</model-gltf>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($model_type == "obj") { ?>
|
||||
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: "#<?= $id ?>"
|
||||
})
|
||||
</script>
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue