Skip to content

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

Nikola edited this page Dec 9, 2022 · 1 revision

DEV MODE:

// DEV MODE imports
import {sys, ActivateModifiers, application} from 'visual-js';

// For dev stage
import {sys, ActivateModifiers,  loadEditor, runEditor, loadEditorObjects} 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;
  ActivateModifiers();

  // Run editor
  runEditor();
  // loadEditor(); - this load keyboard and other gui staff no need now.

  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");
  // smodul.NEW_OBJECT("IamNewObject", 25, 50, 12, 25, 10);

  // Run editor ASYNC!
  loadEditorObjects();

  sys.SCRIPT.LOAD("res/animations/resource.js").then(() => {
    addEventListener('postScriptReady', () => {
      // 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;