vsinghp / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

Error upon loading Uncaught TypeError: Cannot read property 'width' of null #150

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
<script type= "text/javascript" src="js/Detector.js"></script>
  <script type= "text/javascript"src="js/jsc3d.js"></script>
  <script type= "text/javascript"src="js/jsc3d.touch.js"></script>
 <script type= "text/javascript" src="js/jsc3d.webgl.js"></script>

<script type="text/javascript" id="virg">

var canvas= document.getElementById('virgin');
var viewer= new JSC3D.Viewer (canvas);

     viewer.setParameter('SceneUrl', 'virg.obj');
     viewer.setParameter('InitRotationX', 0);
     viewer.setParameter('InitRotationY', 0);
     viewer.setParameter('InitRotationZ', 0);
     viewer.setParameter('BackgroundColor', '#FFFFF');
     viewer.setParameter('RenderMode', 'texturesmooth');
     viewer.setParameter('SphereMapUrl', 'images/black.png');
     viewer.setParameter( 'Renderer', 'webgl');
     viewer.init();
     viewer.update();

        var ctx = canvas.getContext('2d');

    function changeDefinition(definition) {

                    if(definition == 'high' && viewer.isWebGLEnabled() && JSC3D.PlatformInfo.browser == 'chrome')
                    definition = 'standard';

                viewer.setDefinition(definition);
                viewer.update();
            }
</script>
What is the expected output? What do you see instead?
 I expect to have my obj loaded. in my console it says 
Uncaught TypeError: Cannot read property 'width' of null 
jsc3d.js:95

and anonymous function in my index referring to the .viewer

What version of the product are you using? On what operating system?

jscd 1.6.5

Original issue reported on code.google.com by ootsil.k...@gmail.com on 27 Feb 2015 at 11:01

GoogleCodeExporter commented 8 years ago
I am wondering what can i do to remedy the situation. It says the issue is in 
the jsc3d.js line 95 that sets the parameters for this.frameWidth = 
canvas.width;  

Original comment by ootsil.k...@gmail.com on 27 Feb 2015 at 11:04

GoogleCodeExporter commented 8 years ago
Not sure. It sounds like incorrect reference binding. How did you use the 
viewer instance? Have you checked whether the canvas object you passed to the 
viewer refered to a valid canvas element?

Original comment by Humu2...@gmail.com on 28 Feb 2015 at 4:05