Skip to content

Commit 672a0e8

Browse files
committed
preliminary functioning BufferGeometry
1 parent f36d3d1 commit 672a0e8

File tree

413 files changed

+3086
-1381
lines changed

Some content is hidden

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

413 files changed

+3086
-1381
lines changed

examples/test.ipynb

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 16,
5+
"execution_count": 1,
66
"metadata": {
77
"collapsed": false
88
},
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"cell_type": "code",
17-
"execution_count": 17,
17+
"execution_count": null,
1818
"metadata": {
1919
"collapsed": false
2020
},
@@ -28,22 +28,55 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 18,
31+
"execution_count": 5,
3232
"metadata": {
3333
"collapsed": true
3434
},
3535
"outputs": [],
3636
"source": [
3737
"# Geometries\n",
3838
"torus = TorusGeometry(radius=12, tube=3, radialSegments=16, tubularSegments=100)\n",
39-
"sphere = SphereGeometry(radius=3)"
39+
"sphere = SphereGeometry(radius=12)"
4040
]
4141
},
4242
{
4343
"cell_type": "code",
44-
"execution_count": 19,
44+
"execution_count": 2,
4545
"metadata": {
46-
"collapsed": true
46+
"collapsed": false
47+
},
48+
"outputs": [],
49+
"source": [
50+
"bufferSphere = SphereBufferGeometry(radius=12, _flat=True)"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": 6,
56+
"metadata": {
57+
"collapsed": false
58+
},
59+
"outputs": [],
60+
"source": [
61+
"sphere"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 3,
67+
"metadata": {
68+
"collapsed": false
69+
},
70+
"outputs": [],
71+
"source": [
72+
"bufferSphere"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {
79+
"collapsed": false
4780
},
4881
"outputs": [],
4982
"source": [
@@ -58,7 +91,7 @@
5891
},
5992
{
6093
"cell_type": "code",
61-
"execution_count": 20,
94+
"execution_count": null,
6295
"metadata": {
6396
"collapsed": false
6497
},
@@ -70,7 +103,7 @@
70103
},
71104
{
72105
"cell_type": "code",
73-
"execution_count": 21,
106+
"execution_count": null,
74107
"metadata": {
75108
"collapsed": true
76109
},
@@ -83,7 +116,7 @@
83116
},
84117
{
85118
"cell_type": "code",
86-
"execution_count": 22,
119+
"execution_count": null,
87120
"metadata": {
88121
"collapsed": true
89122
},
@@ -96,7 +129,7 @@
96129
},
97130
{
98131
"cell_type": "code",
99-
"execution_count": 23,
132+
"execution_count": null,
100133
"metadata": {
101134
"collapsed": true
102135
},
@@ -107,7 +140,7 @@
107140
},
108141
{
109142
"cell_type": "code",
110-
"execution_count": 24,
143+
"execution_count": null,
111144
"metadata": {
112145
"collapsed": true
113146
},
@@ -123,7 +156,7 @@
123156
},
124157
{
125158
"cell_type": "code",
126-
"execution_count": 25,
159+
"execution_count": null,
127160
"metadata": {
128161
"collapsed": true
129162
},
@@ -135,7 +168,7 @@
135168
},
136169
{
137170
"cell_type": "code",
138-
"execution_count": 26,
171+
"execution_count": null,
139172
"metadata": {
140173
"collapsed": true
141174
},
@@ -147,7 +180,7 @@
147180
},
148181
{
149182
"cell_type": "code",
150-
"execution_count": 27,
183+
"execution_count": null,
151184
"metadata": {
152185
"collapsed": true
153186
},
@@ -158,7 +191,7 @@
158191
},
159192
{
160193
"cell_type": "code",
161-
"execution_count": 30,
194+
"execution_count": null,
162195
"metadata": {
163196
"collapsed": false
164197
},
@@ -169,7 +202,7 @@
169202
},
170203
{
171204
"cell_type": "code",
172-
"execution_count": 29,
205+
"execution_count": null,
173206
"metadata": {
174207
"collapsed": true
175208
},
@@ -197,6 +230,25 @@
197230
"nbconvert_exporter": "python",
198231
"pygments_lexer": "ipython2",
199232
"version": "2.7.12"
233+
},
234+
"widgets": {
235+
"state": {
236+
"0a809e8300f346eb862771f52c7a56e9": {
237+
"views": [
238+
{
239+
"cell_index": 5
240+
}
241+
]
242+
},
243+
"1b7dbab4e7bd42eb95a23627821497f7": {
244+
"views": [
245+
{
246+
"cell_index": 4
247+
}
248+
]
249+
}
250+
},
251+
"version": "1.2.0"
200252
}
201253
},
202254
"nbformat": 4,

js/scripts/generate-wrappers.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,21 @@ function getClassConfig(className, doLog) {
6767
var result = {};
6868
_.extend(result, curClass);
6969

70+
result.propsDefinedByThree = [];
71+
result.propsDefinedByThree = result.propsDefinedByThree.concat(curClass.propsDefinedByThree || []);
72+
7073
// combine cur props with superclass properties for allProperties
7174
result.allProperties = {};
7275
if (curClass.superClass && curClass.superClass !== classConfigs._defaults.superClass) {
7376
var superClassConfig = getClassConfig(curClass.superClass);
7477
_.extend(result.allProperties, superClassConfig.allProperties);
78+
79+
result.propsDefinedByThree = result.propsDefinedByThree.concat(superClassConfig.propsDefinedByThree || []);
7580
}
7681
_.extend(result.allProperties, curClass.properties);
7782

83+
// we want to inherit all propsDefinedByThree
84+
7885
// add defaults
7986
_.defaults(
8087
result,
@@ -306,6 +313,7 @@ _.extend(JavascriptWrapper.prototype, {
306313
return {
307314
defaultJson: prop.getJSPropertyValue(),
308315
property_array_name: prop.getPropArrayName(),
316+
property_converter: prop.getPropertyConverterFn(),
309317
};
310318

311319
}, this);
@@ -382,9 +390,9 @@ _.extend(JavascriptWrapper.prototype, {
382390
if (!prop) {
383391
throw new Error('invalid propName: ' + propName);
384392
}
385-
var converter = prop.propToValueConverterFn();
393+
var converter = prop.getPropertyConverterFn();
386394
if (converter) {
387-
return "this." + converter + "(this.get('" + propName + "'))";
395+
return "this." + converter + "ModelToThree(this.get('" + propName + "'), '" + propName +"')";
388396
} else {
389397
return "this.get('" + propName + "')";
390398
}
@@ -537,12 +545,15 @@ function PythonWrapper(modulePath) {
537545
this.pyBaseRelativePath = path.relative(this.destDirAbsolutePath, pySrcDir);
538546
this.pyBaseRelativePath = relativePathToPythonImportPath(this.pyBaseRelativePath);
539547

548+
this.hasParameters = false;
549+
540550
this.config = getClassConfig(this.className);
541551

542552
this.processSuperClass();
543553
this.processDependencies();
544554
this.processProperties();
545555
this.processDocsUrl();
556+
this.processConstructorArgs();
546557

547558
// Template and context
548559
this.template = pyWrapperTemplate;
@@ -551,6 +562,10 @@ function PythonWrapper(modulePath) {
551562
generatorScriptName: path.basename(__filename),
552563
threejs_docs_url: this.docsUrl,
553564
py_base_relative_path: this.pyBaseRelativePath,
565+
constructor: {
566+
args: this.constructorArgs,
567+
hasParameters: this.hasParameters,
568+
},
554569

555570
className: this.className,
556571
viewName: this.className + 'View',
@@ -646,15 +661,36 @@ _.extend(PythonWrapper.prototype, {
646661
processProperties: function() {
647662

648663
this.properties = _.mapObject(this.config.properties, function(prop, propName) {
649-
650664
return {
651665
trait_declaration: prop.getTraitlet(),
666+
defaultJson: prop.getPythonDefaultValue(),
652667
};
653-
654668
}, this);
655669

656670
},
657671

672+
processConstructorArgs: function() {
673+
this.constructorArgs = this.config.constructorArgs.map(function(propName) {
674+
// Currently, we don't generate an __init__ method for classes that use the parameters
675+
// constructor arg
676+
if (propName === 'parameters') {
677+
this.hasParameters = true;
678+
return {
679+
name: propName,
680+
prop: {
681+
defaultJson: '{}',
682+
}
683+
}
684+
}
685+
return {
686+
name: propName,
687+
prop: {
688+
defaultJson: this.config.allProperties[propName].getPythonDefaultValue(),
689+
}
690+
};
691+
}, this);
692+
},
693+
658694
processDocsUrl: function() {
659695

660696
var refTokens = this.modulePath.split(path.sep);
@@ -694,6 +730,7 @@ function createPythonWrapper(modulePath) {
694730
try {
695731
var wrapper = new PythonWrapper(modulePath);
696732
} catch (e) {
733+
console.log(e);
697734
console.log('skipping: ' + modulePath);
698735
return Promise.resolve(false);
699736
}

0 commit comments

Comments
 (0)