User Tools

Site Tools


mtr_addon:nte:js:train:example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mtr_addon:nte:js:train:example [2024/02/07 08:32] – создано weryskokmtr_addon:nte:js:train:example [2024/02/07 22:09] (current) – added source weryskok
Line 1: Line 1:
 ====== Train Rendering Example ====== ====== Train Rendering Example ======
 ===== Based on the existing MTR model ===== ===== Based on the existing MTR model =====
-You can simply take the appearance of an existing model and add additional rendering logic using JS.+You can simply take the appearance of an existing model and add additional rendering logic using JS. It's probably easier to do it that way.
  
 ===== Complete rendering control with JS ===== ===== Complete rendering control with JS =====
 +It's also possible to use ''base_type'' and not use MTR's built-in model drawing process at all, instead using JS to control it all.
 +
 The following code implements loading the OBJ model, selecting groups to display as needed to achieve an effect similar to the original MTR train. Feel free to copy it and modify it. The following code implements loading the OBJ model, selecting groups to display as needed to achieve an effect similar to the original MTR train. Feel free to copy it and modify it.
  
 The following models are used: groups ''body'', ''head'', ''end'', ''headlight'', ''taillight'', where ''head'', ''headlight'', ''taillight'' are in the Z- direction and ''end'' is in the Z+ direction; and groups ''doorXNZN'', ''doorXNZP'', ''doorXPZN'', ''doorXPZP'', ''doorlightXN'', ''doorlightXP'' for doors and their indicators. The following models are used: groups ''body'', ''head'', ''end'', ''headlight'', ''taillight'', where ''head'', ''headlight'', ''taillight'' are in the Z- direction and ''end'' is in the Z+ direction; and groups ''doorXNZN'', ''doorXNZP'', ''doorXPZN'', ''doorXPZP'', ''doorlightXN'', ''doorlightXP'' for doors and their indicators.
  
-<code js>+<code javascript>
 // Load groups from train.obj as Map of RawModel // Load groups from train.obj as Map of RawModel
 var rawModels = ModelManager.loadPartedRawModel(Resources.manager(), Resources.idRelative("train.obj"), null); var rawModels = ModelManager.loadPartedRawModel(Resources.manager(), Resources.idRelative("train.obj"), null);
Line 105: Line 107:
     return valueChange * (1 - Math.cos(Math.PI * (time - startTime) / timeChange)) / 2 + startValue;     return valueChange * (1 - Math.cos(Math.PI * (time - startTime) / timeChange)) / 2 + startValue;
 } }
 +</code>
  
-// The end!+===== Source ===== 
 +  * https://www.zbx1425.cn/nautilus/mtr-nte/#/js-example-train
  
-</code> 
mtr_addon/nte/js/train/example.1707294771.txt.gz · Last modified: 2024/02/07 08:32 by weryskok