@ -0,0 +1,49 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
3D Image Viewer Widget |
||||
|
====================== |
||||
|
This module helps to render interactive 3D models. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* It only support 3D images with .glb extension |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Lesser General Public License, Version 3 (LGPL v3). |
||||
|
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developers : (V16) Athira Premanand, |
||||
|
(V17) Safa Faheem, |
||||
|
(V18) Aysha Shalin |
||||
|
Contact : odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import models |
@ -0,0 +1,49 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
{ |
||||
|
'name': '3D Image Viewer Widget', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Extra Tools', |
||||
|
'summary': """It helps to render interactive 3D models.""", |
||||
|
'description': """This module helps to render interactive 3D models. Zoom in |
||||
|
and zoom out feature is available and also can move in any direction.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['base', 'product', 'web'], |
||||
|
'data': [ |
||||
|
'views/product_template_views.xml', |
||||
|
], |
||||
|
'assets': { |
||||
|
'web.assets_backend': [ |
||||
|
'https://unpkg.com/@egjs/view3d@2.10.1/dist/view3d.pkgd.min.js', |
||||
|
'model_viewer_widget/static/src/js/widget.js', |
||||
|
'model_viewer_widget/static/src/xml/widget.xml', |
||||
|
] |
||||
|
}, |
||||
|
'images': ['static/description/banner.png'], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <model_viewer_widget> |
||||
|
|
||||
|
#### 11.11.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial Commit for 3D Image Viewer Widget |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from . import product_template |
@ -0,0 +1,30 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Aysha Shalin (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU LESSER |
||||
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
||||
|
# (LGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
from odoo import fields, models |
||||
|
|
||||
|
|
||||
|
class ProductTemplate(models.Model): |
||||
|
""" This class inherit the product template for adding the field for |
||||
|
uploading the 3D image of the product. """ |
||||
|
_inherit = 'product.template' |
||||
|
|
||||
|
model_3d = fields.Binary(string="Product", help="Used to upload images") |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 757 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 212 KiB |
After Width: | Height: | Size: 582 KiB |
After Width: | Height: | Size: 113 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 9.9 KiB |
@ -0,0 +1,83 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import { registry } from "@web/core/registry"; |
||||
|
import { isBinarySize } from "@web/core/utils/binary"; |
||||
|
import { url } from "@web/core/utils/urls"; |
||||
|
import {ImageField, imageField} from "@web/views/fields/image/image_field"; |
||||
|
import { useRef, useEffect } from "@odoo/owl"; |
||||
|
const { useState } = owl; |
||||
|
|
||||
|
/** |
||||
|
* Create canvas for adding 3D model |
||||
|
*/ |
||||
|
export class Field3D extends ImageField { |
||||
|
setup(){ |
||||
|
super.setup(); |
||||
|
this.useRef = useRef("field_3d") |
||||
|
this.elId = `#${this.props.name}_el` |
||||
|
this.state = useState({ |
||||
|
isValid: true, |
||||
|
value: url('/model_viewer_widget/static/src/assets/3d.glb') |
||||
|
}); |
||||
|
this.canvasEl = '<canvas class="view3d-canvas"/>' |
||||
|
useEffect(() => { |
||||
|
this.createCanvas() |
||||
|
if (isBinarySize(this.props.record.data[this.props.name])) { |
||||
|
this.state.value = url("/web/content", { |
||||
|
model: this.props.record.resModel, |
||||
|
id: this.props.record.resId, |
||||
|
field: this.props.name, |
||||
|
unique: this.rawCacheKey, |
||||
|
}); |
||||
|
} else if(this.props.record.data[this.props.name]){ |
||||
|
this.state.value = `data:model/gltf-binary;base64, ${this.props.record.data[this.props.name]}` |
||||
|
} |
||||
|
this.view3D = new View3D(this.elId, { |
||||
|
src: this.state.value |
||||
|
}); |
||||
|
}) |
||||
|
} |
||||
|
/** |
||||
|
* At the time of removing file, a default 3D model will be displayed |
||||
|
*/ |
||||
|
onFileRemove(){ |
||||
|
super.onFileRemove(); |
||||
|
this.createCanvas() |
||||
|
this.state.value = url('/model_viewer_widget/static/src/assets/3d.glb'); |
||||
|
if(this.view3D){ |
||||
|
this.view3D.load(this.state.value) |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
* Create canvas for adding 3D model |
||||
|
*/ |
||||
|
createCanvas(){ |
||||
|
var elem = this.useRef.el.querySelector(this.elId) |
||||
|
const prevCanvas = this.useRef.el.querySelector('canvas'); |
||||
|
if(prevCanvas) |
||||
|
elem.removeChild(prevCanvas) |
||||
|
const canvas = document.createElement('canvas'); |
||||
|
canvas.width = 600; |
||||
|
canvas.height = 500; |
||||
|
canvas.classList.add('view3d-canvas') |
||||
|
elem.appendChild(canvas); |
||||
|
} |
||||
|
/** |
||||
|
* At the time of uploading file, the uploaded 3D model will be displayed |
||||
|
*/ |
||||
|
async onFileUploaded(info) { |
||||
|
super.onFileUploaded(info) |
||||
|
this.createCanvas() |
||||
|
this.props.record.update({ [this.props.name]: info.data }); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Field3D.acceptedFileExtensions = "*" |
||||
|
Field3D.template = "Field3DWidget" |
||||
|
|
||||
|
export const image3D = { |
||||
|
...imageField, |
||||
|
component: Field3D, |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
registry.category("fields").add("3D_widget", image3D); |
@ -0,0 +1,31 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<templates> |
||||
|
<!-- Added an edit and delete button for 3D model also can upload 3D model--> |
||||
|
<t t-name="Field3DWidget" owl="1"> |
||||
|
<div t-ref="field_3d"> |
||||
|
<t t-if="!props.readonly"> |
||||
|
<FileUploader onUploaded.bind="onFileUploaded"> |
||||
|
<t t-set-slot="toggler"> |
||||
|
<button class="o_select_file_button btn btn-light |
||||
|
border-0 rounded-circle m-1 p-1" |
||||
|
data-tooltip="Edit" |
||||
|
aria-label="Edit"> |
||||
|
<i class="fa fa-pencil fa-fw"/> |
||||
|
</button> |
||||
|
</t> |
||||
|
<button t-if="this.props.record.data[this.props.name] and state.isValid" |
||||
|
class="o_clear_file_button btn btn-light |
||||
|
border-0 rounded-circle m-1 p-1" |
||||
|
data-tooltip="Clear" |
||||
|
aria-label="Clear" |
||||
|
t-on-click="onFileRemove"> |
||||
|
<i class="fa fa-trash-o fa-fw"/> |
||||
|
</button> |
||||
|
</FileUploader> |
||||
|
</t> |
||||
|
<div t-attf-id="{{props.name}}_el" |
||||
|
class="view3d-wrapper view3d-square"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</templates> |
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<!-- Added a notebook and inside that added a field for uploading the 3D model--> |
||||
|
<record id="product_template_only_form_view" |
||||
|
model="ir.ui.view"> |
||||
|
<field name="name">product.template.view.form.inherit.model.viewer.widget</field> |
||||
|
<field name="model">product.template</field> |
||||
|
<field name="inherit_id" |
||||
|
ref="product.product_template_only_form_view"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//notebook/page[@name='variants']" position="after"> |
||||
|
<page string="3D Model Viewer" name="viewer"> |
||||
|
<div id="3d_model_div" class="3d_model_viewer"/> |
||||
|
<field name="model_3d" string="Product" |
||||
|
widget="3D_widget"/> |
||||
|
</page> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |