Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your <code>initialize</code>method, you access global variables instead of instance variables: <code>scene = new THREE.Scene();</code> will in fact reference <code>window.scene</code>.</p> <p>Check this example</p> <pre><code>var BodyShapeView = Backbone.View.extend({ scene:null, initialize:function(opts) { scene=opts.scene; } }); var s1=new BodyShapeView({scene:'s1'}); var s2=new BodyShapeView({scene:'s2'}); console.log(window.scene); //outputs s2 console.log(s1.scene); //outputs null </code></pre> <p><a href="http://jsfiddle.net/K8tjJ/1/" rel="nofollow">http://jsfiddle.net/K8tjJ/1/</a></p> <p>Change these references to <code>this.scene</code>, <code>this.camera</code>, etc.</p> <pre><code>var BodyShapeView = Backbone.View.extend({ scene:null, initialize:function(opts) { this.scene=opts.scene; } }); var s1=new BodyShapeView({scene:'s1'}); var s2=new BodyShapeView({scene:'s2'}); console.log(window.scene); //outputs undefined console.log(s1.scene); //outputs s1 </code></pre> <p><a href="http://jsfiddle.net/K8tjJ/2/" rel="nofollow">http://jsfiddle.net/K8tjJ/2/</a></p> <p>Additionally, <code>loader.load</code> uses a callback to process its results, you will (probably) lose the reference to <code>this</code> in the function. Try</p> <pre><code>var _this=this; loader.load( "img/originalMeanModel.obj", function ( object ) { ... _this.scene.add( _this.mesh ); // or _this.model if you prefer, but beware }); </code></pre> <p>Note that <code>this.model</code> is a special variable in Backbone.View and should be treated with care if you ever want to pass a model to your view.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload