Skip to content

Commit c299e85

Browse files
First commit
1 parent 8fa7d43 commit c299e85

File tree

215 files changed

+89301
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+89301
-28
lines changed

.gitignore

-28
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ pids
1111
*.seed
1212
*.pid.lock
1313

14-
# Directory for instrumented libs generated by jscoverage/JSCover
15-
lib-cov
16-
17-
# Coverage directory used by tools like istanbul
18-
coverage
19-
20-
# nyc test coverage
21-
.nyc_output
22-
2314
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
2415
.grunt
2516

@@ -36,9 +27,6 @@ build/Release
3627
node_modules/
3728
jspm_packages/
3829

39-
# TypeScript v1 declaration files
40-
typings/
41-
4230
# Optional npm cache directory
4331
.npm
4432

@@ -57,20 +45,4 @@ typings/
5745
# dotenv environment variables file
5846
.env
5947

60-
# parcel-bundler cache (https://parceljs.org/)
61-
.cache
62-
63-
# next.js build output
64-
.next
65-
66-
# nuxt.js build output
67-
.nuxt
68-
69-
# vuepress build output
70-
.vuepress/dist
71-
72-
# Serverless directories
73-
.serverless
7448

75-
# FuseBox cache
76-
.fusebox/

blend_to_collada.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import sys
2+
import bpy
3+
4+
argv = sys.argv
5+
argv = argv[argv.index("--") + 1:]
6+
output = argv[0]
7+
8+
bpy.ops.wm.collada_export(filepath=output, check_existing=True, filter_blender=False, filter_backup=False, filter_image=False, filter_movie=False, filter_python=False, filter_font=False, filter_sound=False, filter_text=False, filter_btx=False, filter_collada=True, filter_alembic=False, filter_folder=True, filter_blenlib=False, filemode=8, display_type='DEFAULT', sort_method='FILE_SORT_ALPHA', prop_bc_export_ui_section='main', apply_modifiers=True, export_mesh_type=0, export_mesh_type_selection='view', selected=False, include_children=False, include_armatures=False, include_shapekeys=False, deform_bones_only=False, include_animations=True, include_all_actions=True, export_animation_type_selection='sample', sampling_rate=1, keep_smooth_curves=False, keep_keyframes=False, active_uv_only=False, use_texture_copies=True, triangulate=True, use_object_instantiation=True, use_blender_profile=True, sort_by_name=False, export_transformation_type=0, export_transformation_type_selection='matrix', open_sim=False, limit_precision=False, keep_bind_info=False)

blend_to_gltf.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import sys
2+
import bpy
3+
4+
argv = sys.argv
5+
argv = argv[argv.index("--") + 1:]
6+
output = argv[0]
7+
8+
bpy.ops.export_scene.gltf(export_format='GLTF_EMBEDDED', ui_tab='GENERAL', export_copyright='', export_texcoords=True, export_normals=True, export_tangents=False, export_materials=True, export_colors=True, export_cameras=False, export_selected=False, export_extras=False, export_yup=True, export_apply=False, export_animations=False, export_frame_range=False, export_frame_step=1, export_move_keyframes=False, export_force_sampling=False, export_current_frame=False, export_skins=False, export_bake_skins=False, export_all_influences=False, export_morph=False, export_morph_normal=False, export_morph_tangent=False, export_lights=False, export_texture_transform=False, export_displacement=False, will_save_settings=False, filepath=output, check_existing=False, filter_glob='*.glb;*.gltf')

converter.js

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
'use strict'
2+
3+
var fs = require('fs');
4+
var path = require('path');
5+
var args = require('yargs').argv;
6+
var child_process = require('child_process');
7+
var dotenv = require('dotenv').config();
8+
9+
var input_file = args.input || args.i || args._[0];
10+
if(input_file === undefined)
11+
{
12+
console.error('No input file supplied');
13+
process.exit(1);
14+
}
15+
16+
var output_directory = args.output || args.o;
17+
if(output_directory === undefined) output_directory = path.dirname(input_file);
18+
19+
var name = path.basename(input_file).split('.')[0];
20+
21+
var gltf_dir = output_directory + '/gltf';
22+
if(!fs.existsSync(gltf_dir)) fs.mkdirSync(gltf_dir);
23+
24+
var usdz_dir = output_directory + '/usdz';
25+
if(!fs.existsSync(usdz_dir)) fs.mkdirSync(usdz_dir);
26+
27+
var dae_dir = output_directory + '/dae';
28+
if(!fs.existsSync(dae_dir)) fs.mkdirSync(dae_dir);
29+
30+
var gltf_path = gltf_dir + '/' + name + '.gltf';
31+
var usdz_path = usdz_dir + '/' + name + '.usdz';
32+
var dae_path = dae_dir + '/' + name + '.dae';
33+
34+
var task_finished = false;
35+
36+
37+
function export_gltf()
38+
{
39+
console.log('---- EXPORTING GLTF ------');
40+
41+
var gltf_args =
42+
[
43+
input_file,
44+
'--background',
45+
'--python',
46+
'blend_to_gltf.py',
47+
'--',
48+
gltf_path
49+
];
50+
51+
run_blender(gltf_args);
52+
}
53+
54+
function export_collada()
55+
{
56+
console.log('---- EXPORTING DAE COLLADA ------');
57+
58+
var collada_args =
59+
[
60+
input_file,
61+
'--background',
62+
'--python',
63+
'blend_to_collada.py',
64+
'--',
65+
dae_path
66+
];
67+
68+
run_blender(collada_args);
69+
}
70+
71+
function export_usdz()
72+
{
73+
console.log('---- EXPORTING USDZ ------');
74+
75+
var usdz_args =
76+
[
77+
'./libs/gltf2usd-master/Source/gltf2usd.py',
78+
'--arkit',
79+
'--optimize-textures',
80+
'-g',
81+
gltf_path,
82+
'-o',
83+
usdz_path
84+
];
85+
86+
var usdz = child_process.spawn('python', usdz_args);
87+
/*
88+
usdz.stdout.on('data', function(data)
89+
{
90+
console.log(data.toString());
91+
});
92+
usdz.stderr.on('data', function(data)
93+
{
94+
console.error(data.toString());
95+
});
96+
*/
97+
usdz.on('close', function(data)
98+
{
99+
task_finished = true;
100+
});
101+
}
102+
103+
function run_blender(args)
104+
{
105+
task_finished = false;
106+
var blender_path = process.env.BLENDER;
107+
var blender = child_process.spawn(blender_path, args);
108+
109+
/*
110+
blender.stdout.on('data', function(data)
111+
{
112+
console.log(data.toString());
113+
});
114+
blender.stderr.on('data', function(data)
115+
{
116+
console.error(data.toString());
117+
});
118+
*/
119+
120+
blender.on('close', function(code)
121+
{
122+
task_finished = true;
123+
});
124+
}
125+
126+
127+
var State =
128+
{
129+
INIT:0,
130+
GLTF:1,
131+
DAE:2,
132+
USDZ:3
133+
};
134+
135+
var state = State.INIT;
136+
137+
function loop()
138+
{
139+
switch(state)
140+
{
141+
case State.INIT:
142+
{
143+
export_gltf();
144+
state = State.GLTF;
145+
break;
146+
}
147+
case State.GLTF:
148+
{
149+
if(task_finished === true)
150+
{
151+
export_collada();
152+
state = State.DAE;
153+
}
154+
break;
155+
}
156+
case State.DAE:
157+
{
158+
if(task_finished === true)
159+
{
160+
export_usdz();
161+
state = State.USDZ;
162+
}
163+
break;
164+
}
165+
case State.USDZ:
166+
{
167+
if(task_finished === true)
168+
{
169+
process.exit(1);
170+
return;
171+
}
172+
}
173+
}
174+
}
175+
setInterval(loop, 0.1);

libs/USDPython/LICENSE/LICENSE.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Copyright © 2018 Apple Inc.
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.
8+

libs/USDPython/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Precompiled macOS Python Modules for Pixar's USD Library (Version 18.09)
2+
3+
This archive contains precompiled macOS Python modules for Pixar's USD library, and a set of sample scripts that demonstrate how to generate usd files.
4+
5+
## Python Bindings
6+
7+
This binary library was compiled using version 18.09 of [the public USD Github repository](http://openusd.org) with the following build script arguments (see USDPython/README.md for further details):
8+
9+
python USD/build_scripts/build_usd.py --build-args TBB,extra_inc=big_iron.inc --python --no-imaging --docs --no-usdview --build-monolithic USDPython
10+
11+
To start using USD in Python, set your PATH and PYTHONPATH variables as follows (replace `<PATH_TO_USDPYTHON>` with the path to this USDPython folder):
12+
13+
export PATH=$PATH:<PATH_TO_USDPYTHON>/USD
14+
export PYTHONPATH=$PYTHONPATH:<PATH_TO_USDPYTHON>/USD
15+
16+
You should then be able to easily inspect the content of any text or binary .usd file or a .usdz archive usding `usdcat`, e.g.:
17+
18+
usdcat samples/assets/island.usdz
19+
20+
21+
## Samples
22+
23+
The `samples` folder contains a set of simple scripts that focus on different aspects of writing USD data, such as geometry, materials, skinning and animation.
24+
Each script generates a .usdc and a .usdz file in the `assets` subfolder, and also prints the generated .usd file's content.
25+
26+
| Script | Purpose |
27+
| ------ | --- |
28+
| `simpleMesh.py` | creates a cube mesh |
29+
| `simpleTransforms.py` | builds a scene graph of several objects and sets (animated) translate, rotate, and scale transforms |
30+
| `simpleMaterial.py` | creates a simple PBR material |
31+
| `meshGroups.py` | creates a cube mesh with two mesh groups and assigns each a separate material |
32+
| `texturedMaterial.py` | creates a cube mesh and assigns it a PBR material with a diffuse texture |
33+
| `complexMaterial.py` | creates a cube mesh and assigns it a more complex PBR material with textures for normal, roughness and diffuse channels |
34+
| `skinnedMeshAnimation.py` | creates an animated skinned cube |
35+
36+

0 commit comments

Comments
 (0)