<% if (isUsePhysX) { %> const systemInfo = tt.getSystemInfoSync(); tt.onShow((res) => { console.log("启动参数:", res.query); console.log("来源信息:", res.refererInfo); console.log("场景值:", res.scene); console.log("启动场景字段:", res.launch_from, ", ", res.location); if (res.launch_from == 'homepage' && res.location == 'sidebar_card') { window["cebianlan"] = true; console.log('从侧边栏启动') } }); // a hack way to load physics provide by bytedance if (tt.getPhysx) { tt.getPhysx({ success (physx) { if (!physx) { console.error('can not use native PhysX'); } else { console.info('physics plugin load success, version=' + physx.getVersion()); GameGlobal.nativePhysX = physx; } loadCC(); }, fail () { loadCC(); } }); } else if (systemInfo.platform === 'android' && tt.getLoader && tt.getLoader()) { const appid = "<%= appid %>"; const loader = tt.getLoader().loader; loader.load('physics', appid, "token", message => { if (message) { console.error('[tt.loader]:' + message); } else { console.info('[tt.loader]: physics plugin load success, version=' + tt.getPhy().getVersion()); GameGlobal.nativePhysX = tt.getPhy(); } loadCC(); }) } else { loadCC(); } <% } %> <% if (!isUsePhysX) { %> loadCC(); <% } %> function loadCC() { const TDAnalytics = require('./tdanalytics.mg.tt.min.js'); globalThis.TDAnalytics = TDAnalytics; tt.onShow((res) => { console.log("启动参数:", res.query); console.log("来源信息:", res.refererInfo); console.log("场景值:", res.scene); console.log("启动场景字段:", res.launch_from, ", ", res.location); if (res.launch_from == 'homepage' && res.location == 'sidebar_card') { window["cebianlan"] = true; console.log('从侧边栏启动') } }); require('./web-adapter'); <% if(polyfillsBundleFile) { %> // Polyfills bundle. require("<%= polyfillsBundleFile %>"); <% } %> // SystemJS support. require("<%= systemJsBundleFile %>"); // Adapt for IOS, swap if opposite if (canvas){ var _w = canvas.width; var _h = canvas.height; if (screen.width < screen.height) { if (canvas.width > canvas.height) { _w = canvas.height; _h = canvas.width; } } else { if (canvas.width < canvas.height) { _w = canvas.height; _h = canvas.width; } } canvas.width = _w; canvas.height = _h; } // Adjust initial canvas size if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;} const importMap = require("<%= importMapFile%>").default; System.warmup({ importMap, importMapUrl: '<%= importMapFile%>', defaultHandler: (urlNoSchema) => { require('.' + urlNoSchema); }, handlers: { 'plugin:': (urlNoSchema) => { typeof requirePlugin === 'function' ? requirePlugin(urlNoSchema) : require(urlNoSchema); }, 'project:': (urlNoSchema) => { require(urlNoSchema); }, }, }); System.import('<%= applicationJs %>').then(({ Application }) => { return new Application(); }).then((application) => { return onApplicationCreated(application); }).catch((err) => { console.error(err); }); function onApplicationCreated(application) { return System.import('cc').then((cc) => { require('./engine-adapter'); return application.init(cc); }).then(() => { return application.start(); }); } }