question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Question) Adding arbitrary units/models to an already loaded map

See original GitHub issue

If I want to render, say a sphere, into an already loaded + rendered wc3 map, what would be the most appropriate way to go about this?

Looking at the code in mdx-m3-viewer\src\viewer\handlers\w3x\viewer.ts lines 627-656:

for (let unit of unitsDoo.units) {
      let row: MappedDataRow | undefined;
      let path;

      // Hardcoded?
      if (unit.id === 'sloc') {
        path = 'Objects\\StartLocation\\StartLocation.mdx';
      } else {
        row = this.unitsData.getRow(unit.id);

        path = <string>row.file;

        if (path.endsWith('.mdl')) {
          path = path.slice(0, -4);
        }

        path += '.mdx';
      }

      if (path) {
        this.load(path)
          .then((model) => {
            if (model) {
              this.units.push(new Unit(this, <MdxModel>model, row, unit));
            }
          });
      } else {
        console.log('Unknown unit ID', unit.id, unit);
      }
    }

It looks like I can just add units/objects to the map like so -

    if (model) {
        this.units.push(new Unit(this, <MdxModel>model, row, unit));
    }

given that I provide -

  • a model class
  • stub object for unit that holds info such as scale, location, angle, player, etc.
  • stub object for row
  • a model instance class that implements the setScene method

My understanding is that the model should be able to create a model instance and is in charge of determining what webgl program to use to render itself. I would start off by using an existing primitive such as a sphere.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
flowtsohgcommented, Jan 28, 2021

I recommend reading this tutorial and other relevant pages on that site, it has been very useful to me in the past.

1reaction
flowtsohgcommented, Jan 28, 2021

Also I just realized that uses heightMap, from the time the height values were saved on the client. But you can look at groundNormal() just above it 😂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Arbitrary DEM Preparation for use as a Custom Terrain Source
This is an advanced user activity. Map Pilot can use terrain model data that is created by processing imagery in Maps Made Easy....
Read more >
Working with models and mapping templates - Amazon API ...
A mapping template is a script expressed in Velocity Template Language (VTL) and applied to the payload using JSONPath expressions .
Read more >
HST.583: LAB6 Instructions
You will run a matlab program that loads some images (T1 and proton density maps). You will be asked questions about these images....
Read more >
Work with elevation surfaces—ArcGIS Pro | Documentation
Add a ground surface to a map · On the Map tab, in the Layer group, click the Add Data arrow Add Data...
Read more >
Django Tutorial Part 3: Using models - Learn web development
This article shows how to define models for the LocalLibrary website. It explains what a model is, how it is declared, and some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found