HTML example to use the non-compiled development version of xtk does not work

StackOverflow https://stackoverflow.com/questions/12492683

  •  02-07-2021
  •  | 
  •  

Pergunta

I'm trying to run the development version of xtk (it's the 1st time I use github, and I'm fairly new to javascript...):

  • I did as indicated in https://github.com/xtk/X/wiki/X:DevelopersHeadsUp, forked xtk, cloned it into my computer and run utils/deps.py. It is now sitting at ~/myself/X,

  • Next I wrote an html file at ~/myself/X.html with the example html code in DevelopersHeadsUp,

  • because my .html file is at the same level as the X directory, I changed the src="../X/lib/closure-library/closure/goog/base.js" lines to src="X/lib/closure-library/closure/goog/base.js",

  • I opened X.html with Safari (5.1.7)...

... and it doesn't work.

I get these 2 errors in the console:

TypeError: 'undefined' is not a constructor (evaluating 'new goog.structs.Map()')

X.html:19TypeError: 'undefined' is not a constructor (evaluating 'new X.renderer3D()')

Foi útil?

Solução

Sounds all good: the first TypeError is something in the Closure library - it is normal :) The second one: you probably forgot to include goog.require('X.renderer3D'); and the other XTK classes you use just before the run function.

<script type="text/javascript">

  // include all used X-classes here
  // this is only required when using the xtk-deps.js file
  goog.require('X.renderer3D');
  goog.require('X.cube');

  var run = function() {

    var r = new X.renderer3D();
    r.container = 'r';
    r.init();

    var cube = new X.cube();

    r.add(cube);

    r.render();

  };
</script>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top