UNPKG

agentscript

Version:

AgentScript Model in Model/View architecture

56 lines (46 loc) 1.67 kB
<html> <head> <title>terrain</title> </head> <body> <script type="module"> import * as util from '/src/utils.js' import World from '/src/World.js' import Animator from '/src/Animator.js' import { redfishUSA } from '/src/TileData.js' import Model from '/models/HelloModel.js' import ThreeDraw from '/src/ThreeDraw.js' const [Z, X, Y] = [13, 1594, 3339] const elevation = await redfishUSA.zxyToDataSet(Z, X, Y) const el0to10 = elevation.scale(0, 10) const model = new Model(World.defaultOptions(50)) model.population = 0 model.patches.importDataSet(el0to10, 'z') await model.startup() model.setup() // REMIND: fix patches to update only once const drawOptions = { patchesMesh: 'PointsMesh', patchesSize: 5, patchesMap: 'Jet', patchesColor: p => { const map = view.drawOptions.patchesMap const color = map.scaleColor(p.z, 0, 10) return color }, } const view = new ThreeDraw(model, { div: 'modelDiv' }, drawOptions) util.toWindow({ util, model, view }) await new Animator( () => { model.step() view.draw() }, 1, // just draw once, is static 30 ) view.idle() </script> <div id="modelDiv"></div> </body> </html>