Answer the question
In order to leave comments, you need to log in
How to setup/use modules for typescript?
Good evening. I'm desperate!
Please tell me why this pops up, I'm already allergic to this inscription, I sat overnight yesterday and continue today ...
Code before compilation:
TS - file2:
//Initialize canvas
let canvas: any;
canvas = document.getElementById('scene');
//Initialize engine
let engine: any;
engine = new BABYLON.Engine(canvas, true);
let createScene: any;
createScene = function () { ... }
export default {
createScene,
engine
}
import createScene from './modules/scene';
import engine from './modules/scene';
//Listener for document wait download
window.addEventListener('DOMContentLoaded', function() {
//Initialize scene
let firstScene: any;
firstScene = createScene;
engine.runRenderLoop(function() {
firstScene.render();
});
window.addEventListener('resize', function() {
engine.resize();
});
});
exports["default"] = {
createScene: createScene,
engine: engine
};
"use strict";
exports.__esModule = true;
var scene_1 = require("./modules/scene");
var scene_2 = require("./modules/scene");
//Listener for document wait download
window.addEventListener('DOMContentLoaded', function () {
//Initialize scene
var firstScene;
firstScene = scene_1["default"];
scene_2["default"].runRenderLoop(function () {
firstScene.render();
});
window.addEventListener('resize', function () {
scene_2["default"].resize();
});
});
Answer the question
In order to leave comments, you need to log in
Well, make a normal webpack config so that it compiles into regular js. Or connect the script to the page as a module. Both are in the documentation. Study. If you're lazy, then...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question