adds obj-mtl example

This commit is contained in:
buttle 2021-06-13 14:11:22 +02:00
parent 397fb2a031
commit 7f4460b88a
10 changed files with 13984 additions and 9 deletions

View File

@ -0,0 +1,31 @@
# 3D tester
An utility to test 3D models
## Installation
First make sure you have python3 installed
Then..
```
git clone git@git.hangar.org:21036/arcHIVE-tech/3D-tester.git
cd 3D-tester
python3 -m venv ./venv
source ./venv/bin/activate
pip install bottle
chmod +x run.sh
```
## Usage
```
cd 3D-tester
./run.sh
```
Now you can browse to `http://localhost:8080`
### Adding 3D models
Add your 3D models to the `./objects` folder. Create subdirectories as needed.

6
app.py
View File

@ -78,10 +78,10 @@ def render(file_path):
return "Opps, no object type" return "Opps, no object type"
print("object: ", object) print("object: ", object)
if object['type'] == 'gltf': if object['type'] == 'gltf' or object['type'] == 'glb':
page_tpl = "render" page_tpl = "google"
else: else:
page_tpl = "render_1" page_tpl = "vue-3d"
return template(page_tpl, return template(page_tpl,
current_dir=file_path.replace(file_name, ""), current_dir=file_path.replace(file_name, ""),

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,56 @@
# Material Count: 5
newmtl _01_-_Default1noCulli__01_-_Default1noCulli
Ns 30.0000
Ka 0.640000 0.640000 0.640000
Kd 0.640000 0.640000 0.640000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd 01_-_Default1noCulling.dds
newmtl FrontColorNoCullingID_male-02-1noCulling.JP
Ns 30.0000
Ka 0.800000 0.800000 0.800000
Kd 0.800000 0.800000 0.800000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd male-02-1noCulling.dds
newmtl male-02-1noCullingID_male-02-1noCulling.JP
Ns 30.0000
Ka 0.640000 0.640000 0.640000
Kd 0.640000 0.640000 0.640000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd male-02-1noCulling.dds
newmtl orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu
Ns 30.0000
Ka 0.640000 0.640000 0.640000
Kd 0.640000 0.640000 0.640000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd orig_02_-_Defaul1noCulling.dds
newmtl FrontColorNoCullingID_orig_02_-_Defaul1noCu
Ns 30.0000
Ka 0.800000 0.800000 0.800000
Kd 0.800000 0.800000 0.800000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd orig_02_-_Defaul1noCulling.dds

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ BASE_DIR = os.path.abspath(
'../') '../')
) )
OBJECT_DIR = os.path.join(BASE_DIR, 'objects') OBJECT_DIR = os.path.join(BASE_DIR, 'objects')
OBJECT_TYPES = ['gltf', 'obj', 'fbx', 'stl', 'dae'] OBJECT_TYPES = ['gltf', 'glb', 'obj', 'fbx', 'stl', 'dae']
def get_directory_content(dir_path): def get_directory_content(dir_path):
content = [] content = []
@ -102,6 +102,11 @@ def get_object(file_path, result={}):
object_path = str(file_path).replace(OBJECT_DIR, "") object_path = str(file_path).replace(OBJECT_DIR, "")
result['urls'].append(f"/objects{object_path}") result['urls'].append(f"/objects{object_path}")
return result return result
if extension == 'glb':
result['type'] = "glb"
object_path = str(file_path).replace(OBJECT_DIR, "")
result['urls'].append(f"/objects{object_path}")
return result
return None return None

View File

@ -1,8 +1,5 @@
% rebase('base.tpl') % rebase('base.tpl')
<script src="/static/vendor/vue/vue.js"></script>
<script src="/static/vendor/vue-3d-model/vue-3d-model.umd.js"></script>
<style> <style>
model-viewer { model-viewer {
width: 500px; width: 500px;

View File

@ -67,5 +67,3 @@
el: "#object" el: "#object"
}) })
</script> </script>
<script type="module" src="/static/vendor/google/model-viewer.js"></script>