Skip to content

How to define `Texture editor` [visual js game engine] in matrix engine for PRODC MODE

Nikola edited this page Dec 10, 2022 · 2 revisions
// Final build
import {sys, ActivateModifiers, application} from 'visual-js';

// npm run build.tex.editor
// BUILD FROM EDITOR TO REAL JS FILE
// DISBALE NOW EDITOR

var runTextureEditor = (curTexId) => {

  // Visual-JS 3 part

  // must be fixed - double call
  if(typeof window.RESOURCE !== 'undefined') return;

  // Final build
  application.EDITOR = false;
  ActivateModifiers();

  sys.DOM.CREATE_SURFACE("SURF", curTexId, 100, 99.4, "DIAMETRIC");
  actualTexture.ENGINE.CREATE_MODUL("STARTER");

  /**
   * @description
   * Create non-editor game objects here (from code)
   */
  let smodul = actualTexture.ENGINE.MODULES.ACCESS_MODULE("STARTER");

  sys.SCRIPT.LOAD("res/animations/resource.js").then(() => {
    // addEventListener('postScriptReady', () => {
    sys.SCRIPT.LOAD("starter/visual.js").then(() => {
      // Access
      console.log("window.parent.matrixEngine.App.scene.outsideBox.streamTextures ",
        window.parent.matrixEngine.App.scene.outsideBox.streamTextures)

      var posGreen = new sys.MATH.OSCILLATOR(10, 80, 1);
      var posBlend1 = new sys.MATH.OSCILLATOR(-30, 120, 2);
      pilLeft.ANIMATION.ROTATE.ANGLE = 90;
      pilRight.ANIMATION.ROTATE.ANGLE = 90;
      pilLeft.POSITION.SET_POSITION(-185, 230);
      text1.TEXTBOX.font = '33px stormfaze';
      title.TEXTBOX.font = '43px stormfaze';

      // VJS3 Staff
      pilLeft.ON_UPDATE = function() {
        test.ANIMATION.ROTATE.ANGLE++;
        pilGreen.POSITION.TRANSLATE(8, posGreen.UPDATE());
        blend1.POSITION.TRANSLATE(8, posBlend1.UPDATE());
      };
    });
  });
}

// Automatic run
runTextureEditor('actualTexture');

// Easy console access
window.runTextureEditor = runTextureEditor;