File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ var ThreeModel = widgets.WidgetModel.extend({
188
188
this . initialized_from_three [ propName ] = true ;
189
189
var obj = this . obj [ propName ] ;
190
190
// First, we need to figure out which model constructor to use
191
- var ctorName = obj . constructor . name + 'Model' ;
191
+ var ctorName = utils . lookupThreeConstructorName ( obj ) + 'Model' ;
192
192
var index = require ( '../' ) ;
193
193
var ctor = index [ ctorName ] ;
194
194
// Create the model
Original file line number Diff line number Diff line change @@ -376,6 +376,31 @@ function getModelScene(model) {
376
376
}
377
377
378
378
379
+ var three_reverse_lut ;
380
+
381
+ /**
382
+ * Fund the unminified name of the constructor of a three object.
383
+ */
384
+ function lookupThreeConstructorName ( obj ) {
385
+ var name = obj . constructor . name ;
386
+ if ( THREE [ name ] !== undefined ) {
387
+ return name ;
388
+ }
389
+ // Assume constructor name is minified, try a reverse lookup
390
+ if ( ! three_reverse_lut ) {
391
+ // Build reverse LUT and store it
392
+ three_reverse_lut = Object . keys ( THREE ) . reduce ( function ( res , key ) {
393
+ var value = THREE [ key ] ;
394
+ if ( ! ! value . prototype && ! ! value . prototype . constructor . name ) {
395
+ res [ value . prototype . constructor . name ] = key ;
396
+ }
397
+ return res ;
398
+ } , { } ) ;
399
+ }
400
+ return three_reverse_lut [ name ] ;
401
+ }
402
+
403
+
379
404
module . exports = {
380
405
createModel : createModel ,
381
406
computeBoundingSphere : computeBoundingSphere ,
@@ -389,4 +414,5 @@ module.exports = {
389
414
nestedDiff : nestedDiff ,
390
415
getObjectScene : getObjectScene ,
391
416
getModelScene : getModelScene ,
417
+ lookupThreeConstructorName : lookupThreeConstructorName ,
392
418
} ;
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ var MaterialModel = MaterialAutogen.extend({
11
11
break ;
12
12
default :
13
13
MaterialAutogen . prototype . onCustomMessage . call ( arguments ) ;
14
-
15
14
}
16
15
} ,
17
16
You can’t perform that action at this time.
0 commit comments