瀏覽代碼

Speed up loads by only parsing units once for GIS-related entities

Cloning an existing unit and changing its value is a fair bit faster.
tags/v0.1.0
Fen Dweller 5 年之前
父節點
當前提交
579a755385
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. +9
    -2
      presets/naturals.js

+ 9
- 2
presets/naturals.js 查看文件

@@ -929,25 +929,32 @@ function makeMountains() {
}

function makeGIS(data, category) {
const baseLength = math.unit(1, "meters");
const baseArea = math.unit(1, "meters^2");
return {
name: category,
constructor: () => {
views = {};
data.forEach(entry => {
name = entry[0]
length = baseLength.clone();
area = baseArea.clone();
length.value = entry[2];
area.value = entry[1];

views[entry[0]] = {
attributes: {
height: {
name: "Size",
power: 1,
type: "length",
base: math.unit(entry[2], "meters")
base: length
},
area: {
name: "Area",
power: 2,
type: "area",
base: math.unit(entry[1], "meters^2")
base: area
},
},
name: name,


Loading…
取消
儲存